@@ -389,9 +426,9 @@ function showCrashBanner(message) {
report_button.onclick = async _event => {
try {
await reportCrash(message)
- content.textContent = "Thank you, the crash was reported."
+ content.textContent = 'Thank you, the crash was reported.'
} catch (e) {
- content.textContent = "The crash could not be reported."
+ content.textContent = 'The crash could not be reported.'
}
}
close_button.onclick = () => {
@@ -399,20 +436,19 @@ function showCrashBanner(message) {
}
}
-async function reportCrash(message) {
+async function reportCrash(message: string) {
+ // @ts-ignore
const crashReportHost = API[globalConfig.windowAppScopeConfigName].crash_report_host
await fetch(`http://${crashReportHost}/`, {
method: 'POST',
mode: 'no-cors',
headers: {
- 'Content-Type': 'text/plain'
+ 'Content-Type': 'text/plain',
},
- body: message
- })
+ body: message,
+ })
}
-
-
// ========================
// === Main Entry Point ===
// ========================
@@ -425,6 +461,7 @@ function style_root() {
/// Waits for the window to finish its show animation. It is used when the website is run in
/// Electron. Please note that it returns immediately in the web browser.
async function windowShowAnimation() {
+ // @ts-ignore
await window.showAnimation
}
@@ -434,37 +471,104 @@ function disableContextMenu() {
})
}
-function ok(value) {
+function ok(value: any) {
return value !== null && value !== undefined
}
-/// Main entry point. Loads WASM, initializes it, chooses the scene to run.
-API.main = async function (inputConfig) {
- let defaultConfig = {
- use_loader : true,
- wasm_url : '/assets/ide.wasm',
- wasm_glue_url : '/assets/wasm_imports.js',
- crash_report_host : cfg.defaultLogServerHost,
- no_data_gathering : false,
- is_in_cloud : false,
+class Config {
+ public use_loader: boolean
+ public wasm_url: string
+ public wasm_glue_url: string
+ public crash_report_host: string
+ public no_data_gathering: boolean
+ public is_in_cloud: boolean
+ public entry: string
+
+ static default() {
+ let config = new Config()
+ config.use_loader = true
+ config.wasm_url = '/assets/ide.wasm'
+ config.wasm_glue_url = '/assets/wasm_imports.js'
+ config.crash_report_host = cfg.defaultLogServerHost
+ config.no_data_gathering = false
+ config.is_in_cloud = false
+ config.entry = null
+ return config
}
- let urlParams = new URLSearchParams(window.location.search);
- let urlConfig = Object.fromEntries(urlParams.entries())
- let config = Object.assign(defaultConfig,inputConfig,urlConfig)
- API[globalConfig.windowAppScopeConfigName] = config
- if (config.no_data_gathering) {
- API.remoteLog = function (_event, _data) {}
- } else {
- let logger = new MixpanelLogger
- API.remoteLog = function (event,data) {logger.log(event,data)}
+ updateFromObject(other: any) {
+ if (!ok(other)) {
+ return
+ }
+ this.use_loader = ok(other.use_loader) ? tryAsBoolean(other.use_loader) : this.use_loader
+ this.no_data_gathering = ok(other.no_data_gathering)
+ ? tryAsBoolean(other.no_data_gathering)
+ : this.no_data_gathering
+ this.is_in_cloud = ok(other.is_in_cloud)
+ ? tryAsBoolean(other.is_in_cloud)
+ : this.is_in_cloud
+ this.wasm_url = ok(other.wasm_url) ? tryAsString(other.wasm_url) : this.wasm_url
+ this.wasm_glue_url = ok(other.wasm_glue_url)
+ ? tryAsString(other.wasm_glue_url)
+ : this.wasm_glue_url
+ this.crash_report_host = ok(other.crash_report_host)
+ ? tryAsString(other.crash_report_host)
+ : this.crash_report_host
+ this.entry = ok(other.entry) ? tryAsString(other.entry) : this.entry
+ }
+}
+
+/// Check whether the value is a string with value `"true"`/`"false"`, if so, return the
+// appropriate boolean instead. Otherwise, return the original value.
+function parseBooleanOrLeaveAsIs(value: any): any {
+ if (value === 'true') {
+ return true
+ }
+ if (value === 'false') {
+ return false
}
+ return value
+}
+
+function tryAsBoolean(value: any): boolean {
+ value = parseBooleanOrLeaveAsIs(value)
+ assert(typeof value == 'boolean')
+ return value
+}
+
+function tryAsString(value: any): string {
+ return value.toString()
+}
- window.setInterval(() =>{API.remoteLog("alive");}, ALIVE_LOG_INTERVAL)
- //Build data injected during the build process. See `webpack.config.js` for the source.
- API.remoteLog("git_hash", {hash: GIT_HASH})
- API.remoteLog("build_information", BUILD_INFO)
- API.remoteLog("git_status", {satus: GIT_STATUS})
+/// Main entry point. Loads WASM, initializes it, chooses the scene to run.
+API.main = async function (inputConfig: any) {
+ const urlParams = new URLSearchParams(window.location.search)
+ // @ts-ignore
+ const urlConfig = Object.fromEntries(urlParams.entries())
+
+ const config = Config.default()
+ config.updateFromObject(inputConfig)
+ config.updateFromObject(urlConfig)
+
+ // @ts-ignore
+ API[globalConfig.windowAppScopeConfigName] = config
+
+ API.initLogging(config)
+
+ window.setInterval(() => {
+ API.remoteLog('alive')
+ }, ALIVE_LOG_INTERVAL)
+
+ // Build data injected during the build process. See `webpack.config.js` for the source.
+ // @ts-ignore
+ const hash = GIT_HASH
+ API.remoteLog('git_hash', { hash })
+ // @ts-ignore
+ const buildInfo = BUILD_INFO
+ API.remoteLog('build_information', buildInfo)
+ // @ts-ignore
+ const status = GIT_STATUS
+ API.remoteLog('git_status', { status })
//initCrashHandling()
style_root()
@@ -473,21 +577,23 @@ API.main = async function (inputConfig) {
disableContextMenu()
let entryTarget = ok(config.entry) ? config.entry : main_entry_point
- config.use_loader = config.use_loader && (entryTarget === main_entry_point)
+ config.use_loader = config.use_loader && entryTarget === main_entry_point
- API.remoteLog("window_show_animation")
+ API.remoteLog('window_show_animation')
await windowShowAnimation()
- API.remoteLog("download_content")
- let {wasm,loader} = await download_content(config)
- API.remoteLog("wasm_loaded")
+ API.remoteLog('download_content')
+ let { wasm, loader } = await download_content(config)
+ API.remoteLog('wasm_loaded')
if (entryTarget) {
let fn_name = wasm_entry_point_pfx + entryTarget
- let fn = wasm[fn_name]
- if (fn) { fn() } else {
+ let fn = wasm[fn_name]
+ if (fn) {
+ fn()
+ } else {
loader.destroy()
- show_debug_screen(wasm,"Unknown entry point '" + entryTarget + "'. ")
+ show_debug_screen(wasm, "Unknown entry point '" + entryTarget + "'. ")
}
} else {
- show_debug_screen(wasm)
+ show_debug_screen(wasm, '')
}
}
diff --git a/src/js/lib/content/tsconfig.json b/src/js/lib/content/tsconfig.json
new file mode 100644
index 0000000000..4d28ded9be
--- /dev/null
+++ b/src/js/lib/content/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "noImplicitAny": true,
+ "target": "ES5",
+ "module": "ES2015"
+ }
+}
\ No newline at end of file
diff --git a/src/js/lib/content/webpack.config.js b/src/js/lib/content/webpack.config.js
index 1f5d9c5945..44b5c1c967 100644
--- a/src/js/lib/content/webpack.config.js
+++ b/src/js/lib/content/webpack.config.js
@@ -18,7 +18,7 @@ const BUILD_INFO = JSON.parse(require('fs').readFileSync(buildPath, 'utf8'));
module.exports = {
entry: {
- index: path.resolve(thisPath,'src','index.js'),
+ index: path.resolve(thisPath,'src','index.ts'),
wasm_imports: './src/wasm_imports.js',
},
output: {
@@ -51,8 +51,9 @@ module.exports = {
},
resolve: {
alias: {
- wasm_rust_glue$: path.resolve(wasmPath,'ide.js')
- }
+ wasm_rust_glue$: path.resolve(wasmPath,'ide.js'),
+ },
+ extensions: [ '.ts', '.js' ],
},
performance: {
hints: false,
@@ -65,6 +66,11 @@ module.exports = {
test: /\.ya?ml$/,
type: 'json',
use: 'yaml-loader'
+ },
+ {
+ test: /\.tsx?/,
+ use: 'ts-loader',
+ exclude: /node_modules/,
}
]
}
diff --git a/src/js/lib/project-manager/src/build.ts b/src/js/lib/project-manager/src/build.ts
index 167bbb2eb6..5797085f23 100644
--- a/src/js/lib/project-manager/src/build.ts
+++ b/src/js/lib/project-manager/src/build.ts
@@ -38,7 +38,7 @@ async function get_project_manager_url(): Promise
{
console.log('webpack target ' + target_platform)
// Usually it is a good idea to synchronize this constant with `ENGINE_VERSION_FOR_NEW_PROJECTS` in
// src/rust/ide/src/ide/initializer.rs. See also https://github.com/enso-org/ide/issues/1359
- const version = '0.2.10'
+ const version = '0.2.11'
let base_url: string = 'https://github.com/enso-org/'
base_url += 'enso/releases/download/'
base_url += `enso-${version}/enso-project-manager-${version}`
diff --git a/src/rust/ide/Cargo.toml b/src/rust/ide/Cargo.toml
index dc02b56fa6..9e955ce720 100644
--- a/src/rust/ide/Cargo.toml
+++ b/src/rust/ide/Cargo.toml
@@ -62,8 +62,9 @@ features = [
'CloseEvent',
'Document',
'Element',
- "ErrorEvent",
- "MessageEvent",
+ 'ErrorEvent',
+ 'EventTarget',
+ 'MessageEvent',
'HtmlElement',
'Node',
'WebSocket',
diff --git a/src/rust/ide/lib/args/src/lib.rs b/src/rust/ide/lib/args/src/lib.rs
index 95fc55e61b..ace721d6ba 100644
--- a/src/rust/ide/lib/args/src/lib.rs
+++ b/src/rust/ide/lib/args/src/lib.rs
@@ -39,5 +39,6 @@ ensogl::read_args! {
crash_report_host : String,
no_data_gathering : bool,
is_in_cloud : bool,
+ verbose : bool,
}
}
diff --git a/src/rust/ide/lib/json-rpc/src/transport.rs b/src/rust/ide/lib/json-rpc/src/transport.rs
index 65418488c4..e22b86711d 100644
--- a/src/rust/ide/lib/json-rpc/src/transport.rs
+++ b/src/rust/ide/lib/json-rpc/src/transport.rs
@@ -42,5 +42,6 @@ pub enum TransportEvent {
/// A socket has been opened.
Opened,
/// A socket has been closed by the peer.
+ /// This event may be also emitted when reconnecting has failed.
Closed,
}
diff --git a/src/rust/ide/src/controller/project.rs b/src/rust/ide/src/controller/project.rs
index e4b95e912c..8acd3c4cb2 100644
--- a/src/rust/ide/src/controller/project.rs
+++ b/src/rust/ide/src/controller/project.rs
@@ -22,12 +22,12 @@ pub const COMPILING_STDLIB_LABEL:&str = "Compiling standard library. It can take
/// The requirements for Engine's version, in format understandable by
/// [`semver::VersionReq::parse`].
-pub const ENGINE_VERSION_SUPPORTED : &str = "^0.2.10";
+pub const ENGINE_VERSION_SUPPORTED : &str = "^0.2.11";
/// The Engine version used in projects created in IDE.
// Usually it is a good idea to synchronize this version with the bundled Engine version in
// src/js/lib/project-manager/src/build.ts. See also https://github.com/enso-org/ide/issues/1359
-pub const ENGINE_VERSION_FOR_NEW_PROJECTS : &str = "0.2.10";
+pub const ENGINE_VERSION_FOR_NEW_PROJECTS : &str = "0.2.11";
/// The name of the module initially opened in the project view.
///
diff --git a/src/rust/ide/src/executor/test_utils.rs b/src/rust/ide/src/executor/test_utils.rs
index 695ea83e0d..cc84d89e4b 100644
--- a/src/rust/ide/src/executor/test_utils.rs
+++ b/src/rust/ide/src/executor/test_utils.rs
@@ -29,6 +29,11 @@ impl TestWithLocalPoolExecutor {
Self {executor,running_task_count}
}
+ /// Check if there are any uncompleted tasks in the pool.
+ pub fn has_ongoing_task(&self) -> bool {
+ self.running_task_count.get() > 0
+ }
+
/// Spawn new task in executor.
pub fn run_task(&mut self, task: Task)
where Task : Future