Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Electron runner #5633

Merged
merged 63 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
54e933d
Refactoring config options
wdanilo Jan 29, 2023
cd8a27d
Refactoring opts parsing in electron app
wdanilo Jan 29, 2023
cb85fae
Refactoring
wdanilo Jan 29, 2023
9baa8a8
refactoring
wdanilo Jan 30, 2023
d24bcb8
Refactoring
wdanilo Jan 30, 2023
e8ffe42
Making nested config work
wdanilo Jan 31, 2023
3f105e8
Refactoring
wdanilo Feb 1, 2023
130bfd2
Refactoring
wdanilo Feb 2, 2023
35e4223
Revert "Refactoring"
wdanilo Feb 2, 2023
3c0037f
Refactoring
wdanilo Feb 2, 2023
2a3a2fc
Refactoring
wdanilo Feb 2, 2023
ccdda51
Making it work again
wdanilo Feb 2, 2023
defe1f0
Refactoring
wdanilo Feb 4, 2023
1670acd
Refactoring
wdanilo Feb 4, 2023
cd86f7f
refactoring
wdanilo Feb 4, 2023
18f02e3
Making content typechecking in TS
wdanilo Feb 5, 2023
a113539
Making electron compile again
wdanilo Feb 5, 2023
0675ca1
Refactoring
wdanilo Feb 6, 2023
b34caa5
Refactoring
wdanilo Feb 8, 2023
8098bde
Refactoring
wdanilo Feb 9, 2023
45b772b
Refactoring
wdanilo Feb 9, 2023
db1f35e
Refactoring
wdanilo Feb 9, 2023
607ed24
Refactoring
wdanilo Feb 9, 2023
0a8d057
Refactoring
wdanilo Feb 9, 2023
4595393
Refactoring
wdanilo Feb 9, 2023
a09ad58
Refactoring
wdanilo Feb 11, 2023
bf832de
Refactoring
wdanilo Feb 11, 2023
68d19c7
Refactoring
wdanilo Feb 11, 2023
2011ece
Refactoring
wdanilo Feb 12, 2023
26ec66a
Adding Chrome options
wdanilo Feb 12, 2023
0263406
Refactoring
wdanilo Feb 12, 2023
0685854
Refactoring
wdanilo Feb 12, 2023
e9d27e2
Refactoring, applying review
wdanilo Feb 14, 2023
2be4549
Refactoring
wdanilo Feb 14, 2023
e5a8eb2
Refactoring, linting
wdanilo Feb 15, 2023
b954b66
Refactoring, applying review comments
wdanilo Feb 15, 2023
40018a1
Refactoring, extracting app configs to json files
wdanilo Feb 15, 2023
871098f
Merge branch 'develop' into wip/wdanilo/shader-compilation-improvemen…
wdanilo Feb 15, 2023
8830e95
Removing old files
wdanilo Feb 15, 2023
cbba1ed
Refactoring
wdanilo Feb 15, 2023
1776bc5
Refactoring
wdanilo Feb 15, 2023
26c81d6
Refactoring
wdanilo Feb 15, 2023
1122556
Refactoring
wdanilo Feb 15, 2023
fcd691f
Connecting new arg parser to Rust
wdanilo Feb 17, 2023
8e65da3
Refactoring
wdanilo Feb 17, 2023
d7ca350
Merge branch 'develop' into wip/wdanilo/shader-compilation-improvemen…
wdanilo Feb 17, 2023
bdba0e3
Linting
wdanilo Feb 17, 2023
2a57a59
Cleaning the code
wdanilo Feb 17, 2023
bc7a223
Applying review
wdanilo Feb 17, 2023
a5ebcf3
Merge branch 'develop' into wip/wdanilo/shader-compilation-improvemen…
wdanilo Feb 17, 2023
a97ac54
Fixing build
wdanilo Feb 17, 2023
2f5f4d9
Refactoring
wdanilo Feb 17, 2023
9ebbd3c
fixes #5664
wdanilo Feb 18, 2023
c2a42d2
Merge branch 'develop' into wip/wdanilo/shader-compilation-improvemen…
wdanilo Feb 18, 2023
a5812f0
Refactoring
wdanilo Feb 18, 2023
0ed3f8a
Improving json reading macro so it is re-evaluated when json files ch…
wdanilo Feb 18, 2023
130aea4
Attempt to fix builds of ide with non-local gui source.
mwu-tow Feb 18, 2023
1c29315
Merge remote-tracking branch 'origin/wip/wdanilo/shader-compilation-i…
mwu-tow Feb 18, 2023
9210aaa
one more take
mwu-tow Feb 18, 2023
25da309
Merge branch 'develop' into wip/wdanilo/shader-compilation-improvemen…
wdanilo Feb 18, 2023
a5924e4
another take
mwu-tow Feb 18, 2023
ce683f4
Merge remote-tracking branch 'origin/wip/wdanilo/shader-compilation-i…
mwu-tow Feb 18, 2023
2f69bf3
Linting
wdanilo Feb 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/gui/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
ensogl = { path = "../../../lib/rust/ensogl" }
enso-prelude = { path = "../../../lib/rust/prelude" }
enso-json-to-struct = { path = "../../../lib/rust/json-to-struct" }
semver = "1.0.0"

[build-dependencies]
Expand Down
61 changes: 27 additions & 34 deletions app/gui/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use enso_prelude::*;

use ensogl::system::web;
use enso_json_to_struct::json_to_struct;



Expand All @@ -37,37 +37,30 @@ pub fn engine_version_requirement() -> semver::VersionReq {
// === Args ===
// ============

ensogl::read_args! {
application_config_url: String,
authentication_enabled: bool,
dark_theme: bool,
data_gathering: bool,
debug: bool,
email: Option<String>,
emit_user_timing_measurements: bool,
enable_new_component_browser: bool,
enable_skip_and_freeze: bool,
enable_spector:bool,
entry: String,
frame: bool,
is_in_cloud: bool,
language_server_data: Option<String>,
language_server_rpc: Option<String>,
loader_download_to_init_ratio: f32,
max_before_main_entry_points_time_ms: f32,
namespace: Option<String>,
node_labels: bool,
pkg_js_url: String,
pkg_wasm_url: String,
platform: Option<web::platform::Platform>,
preferred_engine_version: Option<semver::Version>,
project: Option<String>,
project_manager: Option<String>,
shaders_url: String,
skip_min_version_check: bool,
/// When profiling the application (e.g. with the `./run profile` command), this argument
/// chooses what is profiled.
test_workflow: Option<String>,
theme: String,
use_loader: bool,
json_to_struct!(
"../../../../lib/rust/ensogl/pack/js/src/runner/config.json",
"../../../../app/ide-desktop/lib/content-config/src/config.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path makes a "dependency" cycle, because as a rule, the app/gui does not know about app/ide-desktop, but here we read a config from there.

If the config.json contains options influencing WASM logic, then it should be inside app/gui. If not, then why do we even care about it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I need to chat more about it. I will call you on Monday and we will discuss it. I will improve it in the next PR then.

);

pub fn read_args() -> Args {
debug_span!("Reading application arguments from JS.").in_scope(|| {
let mut args = Args::default();
if let Ok(js_app) = ensogl::system::js::app::app() {
for param in js_app.config().params() {
if let Some(value) = param.value() {
let path = format!("{}.value", param.structural_name());
if let Some(err) = args.set(&path, value) {
error!("{}", err.display())
}
}
}
} else {
error!("Could not connect to JS application. Using default configuration.")
}
args
})
}

lazy_static! {
pub static ref ARGS: Args = read_args();
}
2 changes: 1 addition & 1 deletion app/gui/language/parser-scala/src/jsclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl From<serde_json::error::Error> for Error {

impl From<JsValue> for Error {
fn from(jsvalue: JsValue) -> Self {
Error::ScalaException(format!("{:?}", jsvalue))
Error::ScalaException(format!("{jsvalue:?}"))
}
}

Expand Down
50 changes: 31 additions & 19 deletions app/gui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,44 @@ impl BackendService {
/// Read backend configuration from the web arguments. See also [`web::Arguments`]
/// documentation.
pub fn from_web_arguments(args: &Args) -> FallibleResult<Self> {
if let Some(endpoint) = &args.project_manager {
if args.language_server_rpc.is_some() || args.language_server_data.is_some() {
let endpoint = args.groups.engine.options.project_manager_url.value.as_str();
let rpc_url_option = &args.groups.engine.options.rpc_url;
let data_url_option = &args.groups.engine.options.data_url;
let rpc_url = rpc_url_option.value.as_str();
let data_url = data_url_option.value.as_str();
if !endpoint.is_empty() {
if !rpc_url.is_empty() || !data_url.is_empty() {
Err(MutuallyExclusiveOptions.into())
} else {
let endpoint = endpoint.clone();
let endpoint = endpoint.to_owned();
Ok(Self::ProjectManager { endpoint })
}
} else {
match (&args.language_server_rpc, &args.language_server_data) {
(Some(json_endpoint), Some(binary_endpoint)) => {
let json_endpoint = json_endpoint.clone();
let binary_endpoint = binary_endpoint.clone();
let default_namespace = || constants::DEFAULT_PROJECT_NAMESPACE.to_owned();
let namespace = args.namespace.clone().unwrap_or_else(default_namespace);
let missing_project_name = || MissingOption(args.names().project());
let project_name = args.project.clone().ok_or_else(missing_project_name)?;
match (rpc_url, data_url) {
("", "") => Ok(default()),
("", _) => Err(MissingOption(rpc_url_option.__name__.to_owned()).into()),
(_, "") => Err(MissingOption(data_url_option.__name__.to_owned()).into()),
(json_endpoint, binary_endpoint) => {
let json_endpoint = json_endpoint.to_owned();
let binary_endpoint = binary_endpoint.to_owned();
let def_namespace = || constants::DEFAULT_PROJECT_NAMESPACE.to_owned();
let namespace = args.groups.engine.options.namespace.value.clone();
let namespace = if namespace.is_empty() { def_namespace() } else { namespace };
let project_name_option = &args.groups.startup.options.project;
let project_name = project_name_option.value.as_str();
let no_project_name = || MissingOption(project_name_option.__name__.to_owned());
let project_name = if project_name.is_empty() {
Err(no_project_name())
} else {
Ok(project_name.to_owned())
}?;
Ok(Self::LanguageServer {
json_endpoint,
binary_endpoint,
namespace,
project_name,
})
}
(None, None) => Ok(default()),
(None, _) => Err(MissingOption(args.names().language_server_rpc()).into()),
(_, None) => Err(MissingOption(args.names().language_server_data()).into()),
}
}
}
Expand Down Expand Up @@ -111,11 +123,11 @@ impl Startup {
/// Read configuration from the web arguments. See also [`web::Arguments`] documentation.
pub fn from_web_arguments() -> FallibleResult<Startup> {
let backend = BackendService::from_web_arguments(&ARGS)?;
let project_name = ARGS.project.clone().map(Into::into);
let initial_view = match ARGS.project {
Some(_) => InitialView::Project,
None => InitialView::WelcomeScreen,
};
let project_name = ARGS.groups.startup.options.project.value.as_str();
let no_project_name = project_name.is_empty();
let initial_view =
if no_project_name { InitialView::WelcomeScreen } else { InitialView::Project };
let project_name = (!no_project_name).as_some_from(|| project_name.to_owned().into());
let dom_parent_id = None;
Ok(Startup { backend, project_name, initial_view, dom_parent_id })
}
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/controller/ide/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ impl ManagingProjectAPI for Handle {
let name = make_project_name(&template);
let name = choose_unique_project_name(&existing_names, &name);
let name = ProjectName::new_unchecked(name);
let version =
enso_config::ARGS.preferred_engine_version.as_ref().map(ToString::to_string);
let version = &enso_config::ARGS.groups.engine.options.preferred_version.value;
let version = (!version.is_empty()).as_some_from(|| version.clone());
let action = MissingComponentAction::Install;

let create_result = self
Expand Down
7 changes: 4 additions & 3 deletions app/gui/src/ide/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Initializer {
config::InitialView::Project => view.switch_view_to_project(),
}

if enso_config::ARGS.emit_user_timing_measurements {
if enso_config::ARGS.groups.profile.options.emit_user_timing_measurements.value {
ensogl_app.display.connect_profiler_to_user_timing();
}
let status_bar = view.status_bar().clone_ref();
Expand Down Expand Up @@ -185,7 +185,8 @@ impl WithProjectManager {
pub async fn create_project(&self) -> FallibleResult<Uuid> {
use project_manager::MissingComponentAction::Install;
info!("Creating a new project named '{}'.", self.project_name);
let version = enso_config::ARGS.preferred_engine_version.as_ref().map(ToString::to_string);
let version = &enso_config::ARGS.groups.engine.options.preferred_version.value;
let version = (!version.is_empty()).as_some_from(|| version.clone());
let name = &self.project_name;
let response = self.project_manager.create_project(name, &None, &version, &Install);
Ok(response.await?.project_id)
Expand Down Expand Up @@ -244,7 +245,7 @@ pub fn register_views(app: &Application) {
type PlaceholderEntryType = ensogl_component::list_view::entry::Label;
app.views.register::<ensogl_component::list_view::ListView<PlaceholderEntryType>>();

if enso_config::ARGS.is_in_cloud {
if enso_config::ARGS.groups.startup.options.platform.value == "web" {
app.views.register::<ide_view::window_control_buttons::View>();
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/gui/src/profile_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub async fn main() {
// Run selected workflow.
let need_workflow = "`profile` entry point requires --workflow argument. \
Try --workflow=help to see a list of options.";
let selected = enso_config::ARGS.test_workflow.as_ref().expect(need_workflow);
let selected = &enso_config::ARGS.groups.profile.options.workflow.value;
if selected.is_empty() {
panic!("{need_workflow}");
}
reflect_match!(match selected as options {
"collapse_nodes" => profile_collapse_nodes().await,
"create_node" => profile_create_node().await,
Expand Down
6 changes: 3 additions & 3 deletions app/gui/view/graph-editor/src/component/node/action_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Icons {
let visibility = ToggleButton::new();
let skip = ToggleButton::new();
display_object.add_child(&visibility);
if ARGS.enable_skip_and_freeze {
if ARGS.groups.feature_preview.options.skip_and_freeze.value {
display_object.add_child(&freeze);
display_object.add_child(&skip);
}
Expand Down Expand Up @@ -198,12 +198,12 @@ impl Model {
self.icons.set_x(-size.x / 2.0);

self.place_button_in_slot(&self.icons.visibility, 0);
if ARGS.enable_skip_and_freeze {
if ARGS.groups.feature_preview.options.skip_and_freeze.value {
self.place_button_in_slot(&self.icons.skip, 1);
self.place_button_in_slot(&self.icons.freeze, 2);
}

let buttons_count = if ARGS.enable_skip_and_freeze {
let buttons_count = if ARGS.groups.feature_preview.options.skip_and_freeze.value {
// Toggle visualization, skip and freeze buttons.
3
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl Model {

#[profile(Debug)]
fn set_label(&self, content: impl Into<String>) {
let str = if ARGS.node_labels { content.into() } else { default() };
let node_labels = ARGS.groups.style.options.node_labels.value;
let str = if node_labels { content.into() } else { default() };
self.label.set_content(str);
}

Expand Down
6 changes: 4 additions & 2 deletions app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ const MACOS_TRAFFIC_LIGHTS_VERTICAL_CENTER: f32 =
const MAX_ZOOM: f32 = 1.0;

fn traffic_lights_gap_width() -> f32 {
let is_macos = ARGS.platform.map(|p| p.is_macos()) == Some(true);
if is_macos && !ARGS.frame {
let platform_str = ARGS.groups.startup.options.platform.value.as_str();
let platform = web::platform::Platform::try_from(platform_str);
let is_macos = platform.map(|p| p.is_macos()).ok() == Some(true);
if is_macos && !ARGS.groups.window.options.frame.value {
MACOS_TRAFFIC_LIGHTS_CONTENT_WIDTH + MACOS_TRAFFIC_LIGHTS_SIDE_OFFSET
} else {
0.0
Expand Down
7 changes: 4 additions & 3 deletions app/gui/view/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub enum SearcherVariant {

impl SearcherVariant {
fn new(app: &Application) -> Self {
if ARGS.enable_new_component_browser {
if ARGS.groups.feature_preview.options.new_component_browser.value {
Self::ComponentBrowser(app.new_view::<component_browser::View>())
} else {
Self::OldNodeSearcher(Rc::new(app.new_view::<searcher::View>()))
Expand Down Expand Up @@ -261,7 +261,8 @@ impl Model {
let code_editor = app.new_view::<code_editor::View>();
let fullscreen_vis = default();
let debug_mode_popup = debug_mode_popup::View::new(app);
let window_control_buttons = ARGS.is_in_cloud.as_some_from(|| {
let runs_in_web = ARGS.groups.startup.options.platform.value == "web";
let window_control_buttons = runs_in_web.as_some_from(|| {
let window_control_buttons = app.new_view::<crate::window_control_buttons::View>();
display_object.add_child(&window_control_buttons);
scene.layers.panel.add(&window_control_buttons);
Expand Down Expand Up @@ -446,7 +447,7 @@ impl Deref for View {
impl View {
/// Constructor.
pub fn new(app: &Application) -> Self {
let theme = match ARGS.theme.as_ref() {
let theme = match ARGS.groups.feature_preview.options.theme.value.as_ref() {
"dark" => Theme::Dark,
_ => Theme::Light,
};
Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/welcome-screen/src/side_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Model {
fn create_new_project_button(projects_list: &web::Element) -> ClickableElement {
let element = web::document.create_element_or_panic("li");
element.set_id(crate::css_id::NEW_PROJECT);
element.set_inner_html(r#"<img src="/assets/new-project.svg" />Create a new project"#);
element.set_inner_html(r#"<img src="/new-project.svg" />Create a new project"#);
projects_list.append_or_warn(&element);
ClickableElement::new(element)
}
Expand All @@ -83,7 +83,7 @@ impl Model {

fn create_project_list_entry(project_name: &str) -> ClickableElement {
let element = web::document.create_element_or_panic("li");
element.set_inner_html(&format!(r#"<img src="assets/project.svg"/> {project_name}"#));
element.set_inner_html(&format!(r#"<img src="project.svg"/> {project_name}"#));
ClickableElement::new(element)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/welcome-screen/src/template_cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct CardDefinition {

const CARD_SPREADSHEETS: CardDefinition = CardDefinition {
class: crate::css_class::CARD_SPREADSHEETS,
background_image_url: Some("/assets/spreadsheets.png"),
background_image_url: Some("/spreadsheets.png"),
header: "Combine spreadsheets",
content: "Glue multiple spreadsheets together to analyse all your data at once.",
template: "orders",
Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/welcome-screen/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

.enso-internal-templates-view .enso-internal-card-geo {
flex: 0 0 530px;
background-image: url("/assets/geo.png");
background-image: url("/geo.png");
background-size: 100%;
}

Expand All @@ -131,6 +131,6 @@

.enso-internal-templates-view .enso-internal-card-visualize {
flex: 0 0 820px;
background-image: url("/assets/visualize.png");
background-image: url("/visualize.png");
background-size: 100% 100%;
}
Loading