numbl 0.4.14 → 0.4.16
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/dist-browser/browser/protocol.d.ts +23 -0
- package/dist-browser/browser/session.d.ts +34 -0
- package/dist-browser/browser.js +53 -2
- package/dist-browser/numbl-core/jit/builtins/runtime/system/isequal.d.ts +2 -2
- package/dist-browser/numbl-core/jit/builtins/runtime/text/strcmp.d.ts +2 -2
- package/dist-browser/numbl-core/version.d.ts +1 -1
- package/dist-browser/syncInputChannel.d.ts +21 -0
- package/dist-cli/cli.js +10 -2
- package/dist-lib/lib.js +9 -1
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-site-viewer/assets/{index-CqtJ-i-7.js → index-ChbDz1FG.js} +3 -3
- package/dist-site-viewer/assets/{numbl-worker-B-MPuV6f.js → numbl-worker-DFeAt1Cu.js} +48 -48
- package/dist-site-viewer/index.html +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,20 @@ export interface BootMessage {
|
|
|
16
16
|
optimization: "0" | "1";
|
|
17
17
|
maxIterations: number;
|
|
18
18
|
displayResults: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Shared cancellation flag (Int32[0] != 0 ⇒ cancel the running code). The
|
|
21
|
+
* worker keeps this reference and passes it to every executeCode call, so
|
|
22
|
+
* the host can interrupt a runaway run cooperatively. Only present when the
|
|
23
|
+
* page is cross-origin isolated (SharedArrayBuffer available).
|
|
24
|
+
*/
|
|
25
|
+
cancelSAB?: SharedArrayBuffer;
|
|
26
|
+
/**
|
|
27
|
+
* Shared channel for synchronous `input()` (stdin). The worker blocks on it
|
|
28
|
+
* (Atomics.wait) after asking the host for a line via a `request-input`
|
|
29
|
+
* message; the host writes the reply back through it (see syncInputChannel).
|
|
30
|
+
* Only present when the page is cross-origin isolated.
|
|
31
|
+
*/
|
|
32
|
+
inputSAB?: SharedArrayBuffer;
|
|
19
33
|
}
|
|
20
34
|
export type ToWorker = BootMessage | {
|
|
21
35
|
type: "writeFile";
|
|
@@ -51,6 +65,12 @@ export interface ExecuteResult {
|
|
|
51
65
|
plotInstructions: PlotInstruction[];
|
|
52
66
|
/** Formatted error message when `ok` is false. */
|
|
53
67
|
error?: string;
|
|
68
|
+
/**
|
|
69
|
+
* True when the run ended because it was interrupted via
|
|
70
|
+
* `NumblSession.interrupt()` (rather than finishing or erroring). The
|
|
71
|
+
* workspace is left at its pre-run state, so variables survive the abort.
|
|
72
|
+
*/
|
|
73
|
+
aborted?: boolean;
|
|
54
74
|
}
|
|
55
75
|
export type FromWorker = {
|
|
56
76
|
type: "progress";
|
|
@@ -70,6 +90,9 @@ export type FromWorker = {
|
|
|
70
90
|
} | {
|
|
71
91
|
type: "bootError";
|
|
72
92
|
message: string;
|
|
93
|
+
} | {
|
|
94
|
+
type: "request-input";
|
|
95
|
+
prompt: string;
|
|
73
96
|
} | {
|
|
74
97
|
type: "htmlSourceEvent";
|
|
75
98
|
compId: string;
|
|
@@ -27,6 +27,13 @@ export interface NumblSessionOptions {
|
|
|
27
27
|
onOutput?: (text: string) => void;
|
|
28
28
|
/** Boot progress (package downloads, engine start). */
|
|
29
29
|
onProgress?: (message: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Called when running code reaches `input()` and needs a line of input.
|
|
32
|
+
* The execution is blocked until the host calls `provideInput(text)` with
|
|
33
|
+
* the user's response. Requires cross-origin isolation (see `canInput`);
|
|
34
|
+
* without it, `input()` errors instead of calling this.
|
|
35
|
+
*/
|
|
36
|
+
onInputRequest?: (prompt: string) => void;
|
|
30
37
|
/** A uihtml component was created/updated (Data JSON-encoded + markup). */
|
|
31
38
|
onUihtml?: (compId: string, dataJson: string, html: string) => void;
|
|
32
39
|
/** Script -> host events (MATLAB `sendEventToHTMLSource`). */
|
|
@@ -57,6 +64,33 @@ export interface NumblSession {
|
|
|
57
64
|
* the callback returns; rejects if it errors (the session stays usable).
|
|
58
65
|
*/
|
|
59
66
|
dispatchHtmlEvent(compId: string, name: string, data: unknown): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Cooperatively interrupt the currently running `execute` (or boot script):
|
|
69
|
+
* sets a shared cancel flag the worker polls at loop iterations and function
|
|
70
|
+
* calls, so it throws and the pending `execute` resolves with
|
|
71
|
+
* `aborted: true`. The worker and the persistent workspace survive — only
|
|
72
|
+
* the running command is abandoned. No-op when `canInterrupt` is false.
|
|
73
|
+
*/
|
|
74
|
+
interrupt(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Whether `interrupt()` can actually stop a run. True only when the page is
|
|
77
|
+
* cross-origin isolated (SharedArrayBuffer available). When false, a runaway
|
|
78
|
+
* run can only be stopped by disposing the session.
|
|
79
|
+
*/
|
|
80
|
+
readonly canInterrupt: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Supply the line of input that a pending `onInputRequest` is waiting for.
|
|
83
|
+
* Unblocks the `input()` call in the running code, which resumes with this
|
|
84
|
+
* text. Call exactly once per `onInputRequest`. No-op when `canInput` is
|
|
85
|
+
* false or nothing is waiting.
|
|
86
|
+
*/
|
|
87
|
+
provideInput(text: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Whether `input()` (stdin) works — true only when the page is cross-origin
|
|
90
|
+
* isolated. When false, `input()` in executed code throws instead of
|
|
91
|
+
* calling `onInputRequest`.
|
|
92
|
+
*/
|
|
93
|
+
readonly canInput: boolean;
|
|
60
94
|
/** Terminate the worker. The session is unusable afterwards. */
|
|
61
95
|
dispose(): void;
|
|
62
96
|
}
|