numbl 0.4.4 → 0.4.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/README.md +5 -1
- package/dist-cli/cli.js +16094 -13802
- package/dist-lib/graphics/figuresReducer.d.ts +9 -0
- package/dist-lib/graphics/types.d.ts +12 -0
- package/dist-lib/lib.d.ts +2 -0
- package/dist-lib/lib.js +2330 -5207
- package/dist-lib/numbl-core/executeCode.d.ts +10 -0
- package/dist-lib/numbl-core/executors/plugins.d.ts +9 -0
- package/dist-lib/numbl-core/helpers/marching-cubes-tables.d.ts +10 -0
- package/dist-lib/numbl-core/helpers/marching-cubes.d.ts +46 -0
- package/dist-lib/numbl-core/interpreter/builtins/array-construction.d.ts +7 -1
- package/dist-lib/numbl-core/interpreter/builtins/geometry.d.ts +10 -0
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -0
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +1 -0
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.c.gen.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +0 -2
- package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +2 -0
- package/dist-lib/numbl-core/native/geometry-bridge.d.ts +29 -0
- package/dist-lib/numbl-core/native/qhull-browser.d.ts +15 -0
- package/dist-lib/numbl-core/native/qhull-node.d.ts +13 -0
- package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +6 -0
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +18 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +22 -0
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
- package/dist-lib/numbl-core/runtime/uihtmlSession.d.ts +40 -0
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-plot-viewer/assets/index-D4grNz8m.js +4504 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/assets/index-B2mCFC55.js +4826 -0
- package/dist-site-viewer/assets/numbl-worker-DWZE29ck.js +5116 -0
- package/dist-site-viewer/assets/qhull-DM50poqF.wasm +0 -0
- package/dist-site-viewer/index.html +1 -1
- package/dist-site-viewer/numbl-embed.js +55 -13
- package/package.json +2 -1
- package/dist-plot-viewer/assets/index-Ct51ZiF1.js +0 -4426
- package/dist-site-viewer/assets/index-USrK1-DZ.js +0 -4748
- package/dist-site-viewer/assets/numbl-worker-s3tsbJJ2.js +0 -12003
|
@@ -10,6 +10,8 @@ import type { FileIOAdapter } from "./fileIOAdapter.js";
|
|
|
10
10
|
import type { SystemAdapter } from "./systemAdapter.js";
|
|
11
11
|
import type { WorkspaceFile } from "../numbl-core/workspace/index.js";
|
|
12
12
|
import type { NativeBridge } from "./workspace/index.js";
|
|
13
|
+
import { type UihtmlSession } from "./runtime/uihtmlSession.js";
|
|
14
|
+
export type { UihtmlSession } from "./runtime/uihtmlSession.js";
|
|
13
15
|
export interface ExecOptions {
|
|
14
16
|
onOutput?: (text: string) => void;
|
|
15
17
|
onDrawnow?: (plotInstructions: PlotInstruction[]) => void;
|
|
@@ -48,6 +50,10 @@ export interface ExecOptions {
|
|
|
48
50
|
implicitCwdPath?: string | null;
|
|
49
51
|
/** SharedArrayBuffer for cooperative cancellation. Int32[0] != 0 means cancelled. */
|
|
50
52
|
cancelSAB?: SharedArrayBuffer;
|
|
53
|
+
/** Hook for `sendEventToHTMLSource(src,name,data)` — pushes an event from a
|
|
54
|
+
* uihtml callback back to the component's page (MATLAB → JS). `dataJson` is
|
|
55
|
+
* the data already `jsonencode`d. The host forwards it to the iframe. */
|
|
56
|
+
onHtmlSourceEvent?: (compId: string, name: string, dataJson: string) => void;
|
|
51
57
|
}
|
|
52
58
|
export interface BuiltinProfileEntry {
|
|
53
59
|
totalTimeMs: number;
|
|
@@ -94,5 +100,9 @@ export interface ExecResult {
|
|
|
94
100
|
workspaceFiles?: WorkspaceFile[];
|
|
95
101
|
/** Final implicit cwd path (for REPL persistence across commands). */
|
|
96
102
|
implicitCwdPath?: string | null;
|
|
103
|
+
/** Present when the run left `uihtml` reverse-channel callbacks registered.
|
|
104
|
+
* The host retains this to dispatch later iframe events into the still-live
|
|
105
|
+
* interpreter (see UihtmlSession). Absent for normal runs (no overhead). */
|
|
106
|
+
uihtmlSession?: UihtmlSession;
|
|
97
107
|
}
|
|
98
108
|
export declare function executeCode(source: string, options?: ExecOptions, workspaceFiles?: WorkspaceFile[], mainFileName?: string, searchPaths?: string[], nativeBridge?: NativeBridge): ExecResult;
|
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
* registered executor.
|
|
11
11
|
*/
|
|
12
12
|
import type { Registry } from "./registry.js";
|
|
13
|
+
import type { Executor } from "./types.js";
|
|
14
|
+
/** The three C-JIT executors, registered at Node bootstrap. */
|
|
15
|
+
export interface CJitExecutors {
|
|
16
|
+
topLevel: Executor;
|
|
17
|
+
loop: Executor;
|
|
18
|
+
call: Executor;
|
|
19
|
+
}
|
|
20
|
+
/** Register the C-JIT executors. Called once at Node bootstrap. */
|
|
21
|
+
export declare function registerCJitExecutors(execs: CJitExecutors): void;
|
|
13
22
|
/** Optimization mode label.
|
|
14
23
|
*
|
|
15
24
|
* - `"0"` — pure AST interpreter, no executors registered.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marching-cubes lookup tables (Paul Bourke / Lorensen-Cline).
|
|
3
|
+
*
|
|
4
|
+
* Vendored verbatim from mikolalysenko/isosurface (MIT). Generated from
|
|
5
|
+
* lib/marchingcubes.js; do not edit by hand.
|
|
6
|
+
*/
|
|
7
|
+
export declare const edgeTable: Uint32Array<ArrayBuffer>;
|
|
8
|
+
export declare const triTable: number[][];
|
|
9
|
+
export declare const cubeVerts: number[][];
|
|
10
|
+
export declare const edgeIndex: number[][];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marching cubes over a regular scalar grid, plus the MATLAB `isosurface`
|
|
3
|
+
* argument parsing. Backs the `isosurface` builtin.
|
|
4
|
+
*
|
|
5
|
+
* The 256-case lookup tables are vendored in `marching-cubes-tables.ts`
|
|
6
|
+
* (MIT, mikolalysenko/isosurface — Paul Bourke's classic table). The loop
|
|
7
|
+
* here adds the two things that library lacks for our use:
|
|
8
|
+
* - vertices interpolated from arbitrary X/Y/Z coordinate arrays (so it is
|
|
9
|
+
* correct for ndgrid, meshgrid, vector, and implicit grids), and
|
|
10
|
+
* - cross-cell vertex sharing (keyed by grid-edge identity), which MATLAB
|
|
11
|
+
* produces by default and which downstream code (e.g. triangle adjacency)
|
|
12
|
+
* relies on.
|
|
13
|
+
*/
|
|
14
|
+
import type { RuntimeValue } from "../runtime/types.js";
|
|
15
|
+
export interface IsoMesh {
|
|
16
|
+
/** Physical vertex coordinates, one `[x, y, z]` per vertex. */
|
|
17
|
+
vertices: number[][];
|
|
18
|
+
/** Triangles as 0-based vertex-index triples. */
|
|
19
|
+
faces: number[][];
|
|
20
|
+
/** Per-vertex scalar color data (present only when a colors array is given). */
|
|
21
|
+
colors?: number[];
|
|
22
|
+
}
|
|
23
|
+
type ScalarFn = (i: number, j: number, k: number) => number;
|
|
24
|
+
type CoordFn = (i: number, j: number, k: number) => [number, number, number];
|
|
25
|
+
/**
|
|
26
|
+
* Extract the isosurface of `getVal` at `iso` over an `m×n×p` grid.
|
|
27
|
+
* `getCoord` maps a grid corner to its physical position; `getColor` (if
|
|
28
|
+
* given) supplies a scalar field interpolated onto the surface vertices.
|
|
29
|
+
*/
|
|
30
|
+
export declare function marchingCubes(dims: [number, number, number], getVal: ScalarFn, getCoord: CoordFn, iso: number, opts?: {
|
|
31
|
+
share?: boolean;
|
|
32
|
+
getColor?: ScalarFn;
|
|
33
|
+
}): IsoMesh;
|
|
34
|
+
/**
|
|
35
|
+
* Parse `isosurface(...)` arguments and compute the mesh.
|
|
36
|
+
*
|
|
37
|
+
* Forms (by numeric-argument count, after stripping 'verbose'/'noshare'):
|
|
38
|
+
* 1: isosurface(V) 4: isosurface(X,Y,Z,V)
|
|
39
|
+
* 2: isosurface(V,iso) 5: isosurface(X,Y,Z,V,iso)
|
|
40
|
+
* 3: isosurface(V,iso,colors) 6: isosurface(X,Y,Z,V,iso,colors)
|
|
41
|
+
*
|
|
42
|
+
* When the isovalue is omitted it is chosen automatically (see autoIsovalue) —
|
|
43
|
+
* an approximation that does not match MATLAB's exact histogram heuristic.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isosurfaceFromArgs(args: RuntimeValue[]): IsoMesh;
|
|
46
|
+
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Array construction builtins: zeros, ones, nan/NaN, eye, linspace, logspace.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import type { RuntimeValue } from "../../runtime/types.js";
|
|
5
|
+
import type { JitType } from "../../jitTypes.js";
|
|
6
|
+
/** Drop a trailing class-name spec from the JIT arg types (used in `match`
|
|
7
|
+
* so the size cases still apply when a class string is present). */
|
|
8
|
+
export declare function stripClassNameTypes(argTypes: JitType[]): JitType[];
|
|
9
|
+
/** Drop a trailing class-name spec from the runtime args (used in `apply`). */
|
|
10
|
+
export declare function stripClassNameArgs(args: RuntimeValue[]): RuntimeValue[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interpreter IBuiltins for computational geometry functions: delaunay,
|
|
3
|
+
* delaunayn, inpolygon.
|
|
4
|
+
*
|
|
5
|
+
* delaunay/delaunayn are backed by the qhull WASM module, installed as the
|
|
6
|
+
* Delaunay backend at startup (see geometry-bridge.ts and the qhull-node /
|
|
7
|
+
* qhull-browser loaders). The backend must be installed before these builtins
|
|
8
|
+
* run; otherwise they throw.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -20,6 +20,17 @@ export declare function evalArgs(this: Interpreter, argExprs: Expr[]): unknown[]
|
|
|
20
20
|
export declare function evalBinary(this: Interpreter, expr: Extract<Expr, {
|
|
21
21
|
type: "Binary";
|
|
22
22
|
}>): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Evaluate an `if`/`while`/`elseif` condition.
|
|
25
|
+
*
|
|
26
|
+
* MATLAB short-circuits the element-wise `&` and `|` operators when they
|
|
27
|
+
* appear at the top of a conditional expression and the left operand is
|
|
28
|
+
* scalar — e.g. `if nargin<4 | isempty(x)` must NOT evaluate `isempty(x)`
|
|
29
|
+
* when `nargin<4` (otherwise `x` may be undefined). Outside this context
|
|
30
|
+
* `&`/`|` evaluate both operands element-wise, so the special handling
|
|
31
|
+
* lives here rather than in `evalBinary`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function evalCondition(this: Interpreter, expr: Expr): unknown;
|
|
23
34
|
export declare function evalUnary(this: Interpreter, expr: Extract<Expr, {
|
|
24
35
|
type: "Unary";
|
|
25
36
|
}>): unknown;
|
|
@@ -72,8 +72,6 @@ export * from "./tensor_ops/tensor_var.js";
|
|
|
72
72
|
export * from "./tensor_ops/tensor_zeros_nd.js";
|
|
73
73
|
export * from "./tensor_ops/tensor_zeros_square.js";
|
|
74
74
|
export * from "./text/strcmp.js";
|
|
75
|
-
/** C snippet bodies, keyed by basename (e.g. `disp_double.h`). */
|
|
76
|
-
export declare const C_SNIPPETS: Record<string, string>;
|
|
77
75
|
/** JS snippet bodies (with `export` keywords stripped), keyed by
|
|
78
76
|
* basename (e.g. `disp_double.js`). Inlined into emitted JS. The
|
|
79
77
|
* functions may reference host hooks (`$write`, …) as free
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* pulls dependencies in first.
|
|
15
15
|
*/
|
|
16
16
|
import type { Builtin } from "../builtins/registry.js";
|
|
17
|
+
/** Register the C runtime-snippet table. Called once at Node bootstrap. */
|
|
18
|
+
export declare function setCSnippets(snippets: Record<string, string>): void;
|
|
17
19
|
/** Minimal Workspace shape consulted at emit time. Importing the
|
|
18
20
|
* concrete Workspace class would create a cycle (workspace ↔ codegen);
|
|
19
21
|
* the structural type below captures exactly what codegen needs. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry bridge — a module-level singleton that holds the Delaunay
|
|
3
|
+
* triangulation backend.
|
|
4
|
+
*
|
|
5
|
+
* Startup (CLI, browser worker, test-runner) loads the qhull WASM module
|
|
6
|
+
* (exact, robust to cospherical/coplanar input) and installs it here. The
|
|
7
|
+
* builtins require it: if no backend is set, delaunay/delaunayn throw.
|
|
8
|
+
*
|
|
9
|
+
* Usage (startup):
|
|
10
|
+
* import { setDelaunayBackend } from './numbl-core/native/geometry-bridge.js';
|
|
11
|
+
* const qhull = await loadQhull();
|
|
12
|
+
* setDelaunayBackend((points, dim) => qhull.delaunay(points, dim).facets);
|
|
13
|
+
*
|
|
14
|
+
* Usage (builtin):
|
|
15
|
+
* import { getDelaunayBackend } from '../native/geometry-bridge.js';
|
|
16
|
+
* const backend = getDelaunayBackend();
|
|
17
|
+
* if (!backend) throw ...;
|
|
18
|
+
* const cells = backend(points, dim);
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Compute a Delaunay triangulation of `points` (an array of dim-dimensional
|
|
22
|
+
* tuples). Returns an array of simplices, each a list of `dim+1` 0-based input
|
|
23
|
+
* point indices.
|
|
24
|
+
*/
|
|
25
|
+
export type DelaunayBackend = (points: number[][], dim: number) => number[][];
|
|
26
|
+
/** Install (or clear, with null) the Delaunay backend. */
|
|
27
|
+
export declare function setDelaunayBackend(fn: DelaunayBackend | null): void;
|
|
28
|
+
/** Get the current Delaunay backend, or null if none is installed. */
|
|
29
|
+
export declare function getDelaunayBackend(): DelaunayBackend | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser/worker loader for the qhull WASM Delaunay backend.
|
|
3
|
+
*
|
|
4
|
+
* The CLI installs the backend in cli.ts (reading the `.wasm` from disk). In
|
|
5
|
+
* the browser there is no filesystem, so we let Vite emit the `.wasm` as an
|
|
6
|
+
* asset (`?url`), fetch its bytes, and pass them to the emscripten module as
|
|
7
|
+
* `wasmBinary` — this avoids relying on the glue locating the binary next to
|
|
8
|
+
* itself at runtime.
|
|
9
|
+
*
|
|
10
|
+
* `ensureQhullBackend()` is idempotent and best-effort: on any failure it
|
|
11
|
+
* resolves anyway (so it never crashes the worker), but then no backend is
|
|
12
|
+
* installed and a later `delaunay`/`delaunayn` call throws (see geometry.ts).
|
|
13
|
+
*/
|
|
14
|
+
/** Load and install the qhull backend (once). Safe to await before every run. */
|
|
15
|
+
export declare function ensureQhullBackend(): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node loader for the qhull WASM Delaunay backend.
|
|
3
|
+
*
|
|
4
|
+
* In Node the emscripten module reads its `.wasm` from disk on its own, so no
|
|
5
|
+
* asset wiring is needed (unlike the browser; see qhull-browser.ts). This is
|
|
6
|
+
* used by the CLI, the vitest setup, and is re-exported from the library entry
|
|
7
|
+
* (lib.ts) so programmatic consumers can install the backend before calling
|
|
8
|
+
* `delaunay` / `delaunayn`.
|
|
9
|
+
*
|
|
10
|
+
* Idempotent: the first call starts loading and caches the promise.
|
|
11
|
+
*/
|
|
12
|
+
/** Load the qhull WASM module and install it as the Delaunay backend (once). */
|
|
13
|
+
export declare function loadQhullNodeBackend(): Promise<void>;
|
|
@@ -42,6 +42,12 @@ import type { PlotInstruction } from "../../graphics/types.js";
|
|
|
42
42
|
export interface PlotDispatchState {
|
|
43
43
|
holdState: boolean;
|
|
44
44
|
tiledLayoutState: TiledLayoutState | null;
|
|
45
|
+
/** Current figure handle (0 = none created yet). */
|
|
46
|
+
currentFigureHandle?: number;
|
|
47
|
+
/** Highest figure handle allocated so far. `figure` with no argument
|
|
48
|
+
* creates a NEW figure with handle `maxFigureHandle + 1` (MATLAB
|
|
49
|
+
* semantics), rather than always reusing handle 1. */
|
|
50
|
+
maxFigureHandle?: number;
|
|
45
51
|
}
|
|
46
52
|
/** Active tiled-layout grid. `mode` controls how the grid grows: in
|
|
47
53
|
* `flow` (default), nexttile expands rows/cols to fit; `vertical` and
|
|
@@ -77,6 +77,24 @@ export declare function parsePatchArgs(args: RuntimeValue[]): PatchTrace;
|
|
|
77
77
|
* fill(ax, ___)
|
|
78
78
|
*/
|
|
79
79
|
export declare function parseFillArgs(args: RuntimeValue[]): PatchTrace[];
|
|
80
|
+
/**
|
|
81
|
+
* Parse trimesh() arguments into a canonical PatchTrace.
|
|
82
|
+
*
|
|
83
|
+
* trimesh draws a triangular mesh and (per the MATLAB docs) returns a patch
|
|
84
|
+
* object, so it maps onto the PatchTrace model: the connectivity matrix T
|
|
85
|
+
* supplies the faces (one triangle per row, 1-based vertex indices) and the
|
|
86
|
+
* x/y[/z] vectors supply the vertices.
|
|
87
|
+
*
|
|
88
|
+
* Supported forms:
|
|
89
|
+
* trimesh(T, x, y) — 2-D triangular mesh
|
|
90
|
+
* trimesh(T, x, y, z) — 3-D triangular mesh
|
|
91
|
+
* trimesh(T, x, y, z, c) — c is per-vertex color data
|
|
92
|
+
* trimesh(TO) — triangulation object (struct exposing
|
|
93
|
+
* ConnectivityList + Points)
|
|
94
|
+
* trimesh(___, Name, Value) — patch properties
|
|
95
|
+
* trimesh(ax, ___) — leading axes handle (ignored)
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseTriMeshArgs(args: RuntimeValue[]): PatchTrace;
|
|
80
98
|
/**
|
|
81
99
|
* Parse surf() arguments.
|
|
82
100
|
*
|
|
@@ -32,9 +32,27 @@ export declare class Runtime {
|
|
|
32
32
|
plotInstructions: PlotInstruction[];
|
|
33
33
|
variableValues: Record<string, RuntimeValue>;
|
|
34
34
|
holdState: boolean;
|
|
35
|
+
/** Figure-handle tracking for MATLAB-style `figure` allocation: `figure`
|
|
36
|
+
* with no argument creates a new figure (`maxFigureHandle + 1`). */
|
|
37
|
+
currentFigureHandle: number;
|
|
38
|
+
maxFigureHandle: number;
|
|
35
39
|
/** Monotonic id source for graphics handles whose trace can be live-updated
|
|
36
40
|
* via `set` / `update_trace` (e.g. lines returned by `line`). */
|
|
37
41
|
graphicsIdCounter: number;
|
|
42
|
+
/** Reverse channel for `uihtml` components (HTML → MATLAB). Maps a component
|
|
43
|
+
* id (the `uihtml` instruction's `id`) to the callback handles registered
|
|
44
|
+
* for it. When non-empty after a run, the host keeps this runtime alive so
|
|
45
|
+
* iframe events can re-enter the interpreter and invoke these handles.
|
|
46
|
+
* Handles are incref'd while stored (see registeruihtmlcallback). */
|
|
47
|
+
uihtmlCallbacks: Map<string, {
|
|
48
|
+
HTMLEventReceived?: RuntimeValue;
|
|
49
|
+
DataChanged?: RuntimeValue;
|
|
50
|
+
}>;
|
|
51
|
+
/** Hook invoked by `sendEventToHTMLSource(src, name, data)` to push an event
|
|
52
|
+
* from MATLAB back to a uihtml component's page. `dataJson` is the data
|
|
53
|
+
* already `jsonencode`d. Set from ExecOptions; the host forwards it to the
|
|
54
|
+
* iframe. */
|
|
55
|
+
onHtmlSourceEvent?: (compId: string, name: string, dataJson: string) => void;
|
|
38
56
|
tiledLayoutState: {
|
|
39
57
|
rows: number;
|
|
40
58
|
cols: number;
|
|
@@ -142,6 +160,10 @@ export declare class Runtime {
|
|
|
142
160
|
* every value adopted into the scope is decref'd. Used by `execStmt`
|
|
143
161
|
* to bound the lifetime of expression transients to one statement. */
|
|
144
162
|
withScope<T>(fn: () => T): T;
|
|
163
|
+
/** Register the implicit default figure (handle 1) the first time a graphics
|
|
164
|
+
* op runs without an explicit `figure`, so a later no-arg `figure` allocates
|
|
165
|
+
* a new handle instead of reusing 1 (MATLAB semantics). */
|
|
166
|
+
ensureCurrentFigure(): void;
|
|
145
167
|
private initBuiltins;
|
|
146
168
|
profileEnter(key: string): void;
|
|
147
169
|
profileLeave(): void;
|
|
@@ -73,6 +73,7 @@ export declare function plotCall(plotInstructions: PlotInstruction[], args: Runt
|
|
|
73
73
|
export declare function plot3Call(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
74
74
|
export declare function lineCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
75
75
|
export declare function patchCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
76
|
+
export declare function trimeshCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
76
77
|
export declare function fillCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
77
78
|
export declare function surfCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
78
79
|
export declare function surfaceCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uihtml reverse channel (HTML → MATLAB) for a finished run.
|
|
3
|
+
*
|
|
4
|
+
* When a script creates a `uihtml` component with a callback
|
|
5
|
+
* (HTMLEventReceivedFcn / DataChangedFcn), the run leaves entries in
|
|
6
|
+
* `rt.uihtmlCallbacks`. `executeCode` then builds a `UihtmlSession` and returns
|
|
7
|
+
* it so the host (the worker) can keep the interpreter alive and re-enter it
|
|
8
|
+
* when an event arrives from the iframe — mirroring MATLAB, where the script
|
|
9
|
+
* returns but its callbacks keep firing.
|
|
10
|
+
*
|
|
11
|
+
* Dispatch re-activates the run's own special-builtin closures (captured at
|
|
12
|
+
* end-of-run, NOT re-registered — re-registering would reset their counters)
|
|
13
|
+
* and pushes the runtime so `disp`, plotting, and `sendEventToHTMLSource`
|
|
14
|
+
* inside the callback reach this runtime. This mirrors executeCode's own
|
|
15
|
+
* save/restore of SPECIAL_BUILTIN_NAMES.
|
|
16
|
+
*/
|
|
17
|
+
import type { Runtime } from "./runtime.js";
|
|
18
|
+
import type { PlotInstruction } from "../../graphics/types.js";
|
|
19
|
+
import { type IBuiltin } from "../interpreter/builtins/types.js";
|
|
20
|
+
export interface UihtmlSession {
|
|
21
|
+
/** True while at least one component still has a registered callback. */
|
|
22
|
+
hasCallbacks(): boolean;
|
|
23
|
+
/** Dispatch an event from a component's page into MATLAB. `eventType` is
|
|
24
|
+
* "HTMLEventReceived" (JS `sendEventToMATLAB`) or "DataChanged" (JS set
|
|
25
|
+
* `htmlComponent.Data`). `payload.data` is the structured-clone'd JS value.
|
|
26
|
+
* New plot output is flushed via `onDrawnow`; outgoing
|
|
27
|
+
* `sendEventToHTMLSource` calls go through `rt.onHtmlSourceEvent`. */
|
|
28
|
+
dispatchEvent(compId: string, eventType: "HTMLEventReceived" | "DataChanged", payload: {
|
|
29
|
+
name?: string;
|
|
30
|
+
data: unknown;
|
|
31
|
+
}): void;
|
|
32
|
+
/** Release the retained callback handles (and their refs). */
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a session over a runtime that registered uihtml callbacks.
|
|
37
|
+
* `activeSpecials` is a snapshot of this runtime's special-builtin closures,
|
|
38
|
+
* captured at end-of-run while they are still installed globally.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createUihtmlSession(rt: Runtime, activeSpecials: Map<string, IBuiltin>, onDrawnow?: (plotInstructions: PlotInstruction[]) => void): UihtmlSession;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Numbl version, used for JIT disk cache invalidation. */
|
|
2
|
-
export declare const NUMBL_VERSION = "0.4.
|
|
2
|
+
export declare const NUMBL_VERSION = "0.4.6";
|