@basthon/kernel-base 0.40.2 → 0.40.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/kernel.d.ts +0 -5
- package/lib/kernel.js +27 -43
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
package/lib/kernel.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare class KernelBase {
|
|
|
6
6
|
private _rootPath;
|
|
7
7
|
private _ready;
|
|
8
8
|
private readonly _loaded;
|
|
9
|
-
private readonly _pageLoad;
|
|
10
9
|
execution_count: number;
|
|
11
10
|
constructor(rootPath: string);
|
|
12
11
|
/**
|
|
@@ -72,10 +71,6 @@ export declare class KernelBase {
|
|
|
72
71
|
* Dynamically load a script asynchronously.
|
|
73
72
|
*/
|
|
74
73
|
static loadScript(url: string): Promise<any>;
|
|
75
|
-
/**
|
|
76
|
-
* Returns a promise that resolves when page is loaded.
|
|
77
|
-
*/
|
|
78
|
-
pageLoad(): Promise<void>;
|
|
79
74
|
/**
|
|
80
75
|
* Wraper around XMLHttpRequest.
|
|
81
76
|
*/
|
package/lib/kernel.js
CHANGED
|
@@ -26,20 +26,9 @@ export class KernelBase {
|
|
|
26
26
|
constructor(rootPath) {
|
|
27
27
|
this._ready = false;
|
|
28
28
|
this._loaded = new PromiseDelegate();
|
|
29
|
-
this._pageLoad = new PromiseDelegate();
|
|
30
29
|
this.execution_count = 0;
|
|
31
30
|
// root path where kernel is installed
|
|
32
31
|
this._rootPath = rootPath;
|
|
33
|
-
if (document.readyState === 'complete') {
|
|
34
|
-
this._pageLoad.resolve();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const callback = () => {
|
|
38
|
-
window.removeEventListener("load", callback);
|
|
39
|
-
this._pageLoad.resolve();
|
|
40
|
-
};
|
|
41
|
-
window.addEventListener("load", callback);
|
|
42
|
-
}
|
|
43
32
|
}
|
|
44
33
|
/**
|
|
45
34
|
* Kernel version number (string).
|
|
@@ -170,11 +159,6 @@ export class KernelBase {
|
|
|
170
159
|
});
|
|
171
160
|
}
|
|
172
161
|
;
|
|
173
|
-
/**
|
|
174
|
-
* Returns a promise that resolves when page is loaded.
|
|
175
|
-
*/
|
|
176
|
-
async pageLoad() { await this._pageLoad.promise; }
|
|
177
|
-
;
|
|
178
162
|
/**
|
|
179
163
|
* Wraper around XMLHttpRequest.
|
|
180
164
|
*/
|
|
@@ -253,35 +237,35 @@ export class KernelBase {
|
|
|
253
237
|
/**
|
|
254
238
|
* Internal. Code evaluation after an eval.request event.
|
|
255
239
|
*/
|
|
256
|
-
evalFromEvent(data) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
dataEvent.content = text;
|
|
263
|
-
that.dispatchEvent("eval.output", dataEvent);
|
|
264
|
-
};
|
|
240
|
+
async evalFromEvent(data) {
|
|
241
|
+
const stdCallback = (std) => (text) => {
|
|
242
|
+
let dataEvent = this.clone(data);
|
|
243
|
+
dataEvent.stream = std;
|
|
244
|
+
dataEvent.content = text;
|
|
245
|
+
this.dispatchEvent("eval.output", dataEvent);
|
|
265
246
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
dataEvent.execution_count = executionCount;
|
|
274
|
-
if (typeof result !== 'undefined') {
|
|
275
|
-
dataEvent.result = result;
|
|
276
|
-
}
|
|
277
|
-
that.dispatchEvent("eval.finished", dataEvent);
|
|
278
|
-
}, function (error) {
|
|
247
|
+
const outCallback = stdCallback("stdout");
|
|
248
|
+
const errCallback = stdCallback("stderr");
|
|
249
|
+
let args;
|
|
250
|
+
try {
|
|
251
|
+
args = await this.evalAsync(data.code, outCallback, errCallback, data);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
279
254
|
errCallback(error.toString());
|
|
280
|
-
|
|
255
|
+
const dataEvent = this.clone(data);
|
|
281
256
|
dataEvent.error = error;
|
|
282
|
-
dataEvent.execution_count =
|
|
283
|
-
|
|
284
|
-
|
|
257
|
+
dataEvent.execution_count = this.execution_count;
|
|
258
|
+
this.dispatchEvent("eval.error", dataEvent);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (args == null)
|
|
262
|
+
return; // this should not happend
|
|
263
|
+
const result = args[0];
|
|
264
|
+
const executionCount = args[1];
|
|
265
|
+
let dataEvent = this.clone(data);
|
|
266
|
+
dataEvent.execution_count = executionCount;
|
|
267
|
+
if (result != null)
|
|
268
|
+
dataEvent.result = result;
|
|
269
|
+
this.dispatchEvent("eval.finished", dataEvent);
|
|
285
270
|
}
|
|
286
|
-
;
|
|
287
271
|
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.40.
|
|
1
|
+
export declare const VERSION = "0.40.6";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.40.
|
|
1
|
+
export const VERSION = "0.40.6";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basthon/kernel-base",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.6",
|
|
4
4
|
"description": "Basthon - Base Kernel",
|
|
5
5
|
"homepage": "https://basthon.fr",
|
|
6
6
|
"bugs": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "b808aca161a9e22e3bef70ee45fe6aa262cc95a3"
|
|
40
40
|
}
|