@basthon/kernel-base 0.76.11 → 0.77.0
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/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.77.0";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.77.0";
|
|
@@ -10,6 +10,7 @@ export declare class KernelMainBase<Type extends KernelWorkerBase> extends Kerne
|
|
|
10
10
|
private _channelSyncer;
|
|
11
11
|
private _fallbackKey?;
|
|
12
12
|
private _encrypt;
|
|
13
|
+
private readonly _ephemeralAPI;
|
|
13
14
|
constructor(options: any);
|
|
14
15
|
/**
|
|
15
16
|
* Is this a legacy worker? i.e. not runing in a worker.
|
|
@@ -21,6 +21,9 @@ export class KernelMainBase extends KernelBase {
|
|
|
21
21
|
else
|
|
22
22
|
this._fallbackKey = globalThis.crypto.randomUUID();
|
|
23
23
|
}
|
|
24
|
+
// get ephemeral API URL or fallback to default
|
|
25
|
+
this._ephemeralAPI =
|
|
26
|
+
options?.ephemeralAPI ?? "https://api.basthon.fr/ephemeral";
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Is this a legacy worker? i.e. not runing in a worker.
|
|
@@ -104,6 +107,8 @@ export class KernelMainBase extends KernelBase {
|
|
|
104
107
|
const proxy = wrap(proxyWorker);
|
|
105
108
|
// setup the kernel worker
|
|
106
109
|
await this.setupWorker();
|
|
110
|
+
// always set... but not always useful
|
|
111
|
+
await this.remote?.setEphemeralAPI(this._ephemeralAPI);
|
|
107
112
|
if (this.syncCommSupport()) {
|
|
108
113
|
console.log("Using SharedArrayBuffer for synchronous worker communication.");
|
|
109
114
|
await this._remote?.setSAB(this._sab);
|
|
@@ -192,7 +197,7 @@ export class KernelMainBase extends KernelBase {
|
|
|
192
197
|
Atomics.notify(new Int32Array(this._sab), 0, 1);
|
|
193
198
|
}
|
|
194
199
|
else {
|
|
195
|
-
const response = await fetch(
|
|
200
|
+
const response = await fetch(this._ephemeralAPI, {
|
|
196
201
|
method: "POST",
|
|
197
202
|
headers: {
|
|
198
203
|
"X-API-Referer": self.location.href,
|
|
@@ -20,7 +20,7 @@ declare class KernelWorkerBase {
|
|
|
20
20
|
protected _options: any;
|
|
21
21
|
protected readonly _legacy: boolean;
|
|
22
22
|
private readonly _basthonRoot;
|
|
23
|
-
private
|
|
23
|
+
private _ephemeralAPI;
|
|
24
24
|
private _ready;
|
|
25
25
|
protected __eval_data__: any;
|
|
26
26
|
protected postMessage?: InstanceType<typeof MessagePort>["postMessage"];
|
|
@@ -70,6 +70,7 @@ declare class KernelWorkerBase {
|
|
|
70
70
|
*/
|
|
71
71
|
protected addEvalPromise(promise: Promise<void>): void;
|
|
72
72
|
setFallbackKeyAndPass(key: string, pass: string): Promise<void>;
|
|
73
|
+
setEphemeralAPI(url: string): Promise<void>;
|
|
73
74
|
protected _init(): Promise<void>;
|
|
74
75
|
/**
|
|
75
76
|
* Initialize the kernel. It is called by initWorker in KernelBase.
|
|
@@ -5,13 +5,12 @@ import { VERSION } from "../version";
|
|
|
5
5
|
import { DOMNodeBus } from "./worker-utils";
|
|
6
6
|
class KernelWorkerBase {
|
|
7
7
|
constructor(options) {
|
|
8
|
+
this._ephemeralAPI = "https://api.basthon.fr/ephemeral";
|
|
8
9
|
this._ready = new PromiseDelegate();
|
|
9
10
|
this._evalPromises = []; // used to wait all promises emitted during computation
|
|
10
11
|
this._decrypt = (s) => s;
|
|
11
12
|
this._options = options;
|
|
12
13
|
this._legacy = options?.legacy === true;
|
|
13
|
-
this._ephemeralAPI =
|
|
14
|
-
options?.ephemeralAPI ?? "https://api.basthon.fr/ephemeral";
|
|
15
14
|
this._basthonRoot = self._assetsURL + "/" + VERSION + "/" + this.language();
|
|
16
15
|
/* we mock the fetch function to:
|
|
17
16
|
* - redirect queries to local FS
|
|
@@ -110,6 +109,12 @@ class KernelWorkerBase {
|
|
|
110
109
|
const CryptoJS = await import("crypto-js");
|
|
111
110
|
this._decrypt = (message) => CryptoJS.AES.decrypt(message, pass).toString(CryptoJS.enc.Utf8);
|
|
112
111
|
}
|
|
112
|
+
/*
|
|
113
|
+
* Set the url of the ephemeral API.
|
|
114
|
+
*/
|
|
115
|
+
async setEphemeralAPI(url) {
|
|
116
|
+
this._ephemeralAPI = url;
|
|
117
|
+
}
|
|
113
118
|
/*
|
|
114
119
|
* Initialize the kernel. Should be overloaded.
|
|
115
120
|
*/
|