runmat 0.4.10-dev.5 → 0.4.10-dev.7
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 +31 -12
- package/artifacts/stdlib.snapshot +0 -0
- package/dist/generated/builtin-examples-catalog.d.ts.map +1 -1
- package/dist/generated/builtin-examples-catalog.js +1 -1
- package/dist/generated/builtin-examples-catalog.js.map +1 -1
- package/dist/generated/builtins/input.js +1 -1
- package/dist/generated/builtins/input.js.map +1 -1
- package/dist/generated/builtins/print.d.ts +4 -0
- package/dist/generated/builtins/print.d.ts.map +1 -0
- package/dist/generated/builtins/print.js +112 -0
- package/dist/generated/builtins/print.js.map +1 -0
- package/dist/generated/builtins/timeit.js +4 -4
- package/dist/generated/builtins/timeit.js.map +1 -1
- package/dist/generated/builtins-manifest.d.ts.map +1 -1
- package/dist/generated/builtins-manifest.js +20 -0
- package/dist/generated/builtins-manifest.js.map +1 -1
- package/dist/index.d.ts +48 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -38
- package/dist/index.js.map +1 -1
- package/dist/lsp/runmat_lsp.d.ts +13 -12
- package/dist/lsp/runmat_lsp.js +647 -26
- package/dist/lsp/runmat_lsp_bg.wasm +0 -0
- package/dist/lsp/runmat_lsp_bg.wasm.d.ts +8 -7
- package/dist/pkg-web/runmat_wasm_web.d.ts +30 -44
- package/dist/pkg-web/runmat_wasm_web.js +31 -84
- package/dist/pkg-web/runmat_wasm_web_bg.wasm +0 -0
- package/dist/pkg-web/runmat_wasm_web_bg.wasm.d.ts +29 -36
- package/dist/runtime/stdlib.snapshot +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,13 +126,33 @@ If you already have a telemetry/analytics identifier (e.g., the ID that the surr
|
|
|
126
126
|
|
|
127
127
|
Call `await session.memoryUsage()` to inspect the current WebAssembly heap. The method returns `{ bytes, pages }`, where `pages` are 64 KiB units. Hosts can poll this to detect runaway `memory.grow` usage and decide when to reset or dispose of sessions.
|
|
128
128
|
|
|
129
|
+
## Execution requests
|
|
130
|
+
|
|
131
|
+
RunMat now uses one explicit execution API: `executeRequest(request)`.
|
|
132
|
+
|
|
133
|
+
- REPL/snippet execution:
|
|
134
|
+
- `source: { kind: "text", name, text }`
|
|
135
|
+
- File/project execution through the configured filesystem provider:
|
|
136
|
+
- `source: { kind: "path", path }`
|
|
137
|
+
|
|
138
|
+
Examples:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
await session.executeRequest({
|
|
142
|
+
source: { kind: "text", name: "<repl>", text: "disp(1 + 1)" }
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await session.executeRequest({
|
|
146
|
+
source: { kind: "path", path: "src/main.m" }
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
129
150
|
## Execution streaming & interaction
|
|
130
151
|
|
|
131
|
-
- `subscribeStdout(listener)` / `unsubscribeStdout(id)` stream stdout/stderr events as they are emitted so hosts can drive an xterm pane without waiting for `
|
|
132
|
-
- `ExecuteResult.warnings` exposes structured `{ identifier, message }` entries pulled from MATLAB's warning store, `stdinEvents` captures every prompt/response emitted during the run for transcript panes
|
|
152
|
+
- `subscribeStdout(listener)` / `unsubscribeStdout(id)` stream stdout/stderr events as they are emitted so hosts can drive an xterm pane without waiting for `executeRequest()` to resolve. Every `ExecuteResult` also includes the buffered `stdout` array for easy logging or replay.
|
|
153
|
+
- `ExecuteResult.warnings` exposes structured `{ identifier, message }` entries pulled from MATLAB's warning store, and `stdinEvents` captures every prompt/response emitted during the run for transcript panes.
|
|
133
154
|
- Call `session.cancelExecution()` to cooperatively interrupt a long-running script (e.g., when users press the stop button). The runtime raises `ExecutionCancelled` error, matching desktop builds.
|
|
134
|
-
- `session.setInputHandler(handler)` registers a
|
|
135
|
-
- When a handler defers, `execute()` resolves with `stdinRequested` containing `{ id, request, waitingMs }`. Call `session.resumeInput(id, value)` once the UI collects the user's response (value follows the same shape as the input handler). `waitingMs` starts at zero and grows until the prompt is satisfied so UIs can show “still waiting…” nudges without forcing a timeout. Use `session.pendingStdinRequests()` to list outstanding prompts (useful when rehydrating a UI after refresh) — each entry carries the same `waitingMs` counter.
|
|
155
|
+
- `session.setInputHandler(handler)` registers a callback for MATLAB's `input`/`pause` prompts. Handlers receive `{ kind: "line" | "keyPress", prompt, echo }` and can return a string/number/boolean, `{ kind: "keyPress" }`, `{ error }` to reject the prompt, or a Promise of any of those values. `executeRequest()` awaits the handler before resolving.
|
|
136
156
|
|
|
137
157
|
## Workspace metadata & variable inspection
|
|
138
158
|
|
|
@@ -171,22 +191,22 @@ await initRunMat({ plotCanvas: canvas });
|
|
|
171
191
|
or attach one later via the exported helpers:
|
|
172
192
|
|
|
173
193
|
```ts
|
|
174
|
-
import {
|
|
194
|
+
import { createPlotSurface, destroyPlotSurface, plotRendererReady } from "@runmat/wasm";
|
|
175
195
|
|
|
176
|
-
await
|
|
196
|
+
const surfaceId = await createPlotSurface(canvas);
|
|
177
197
|
if (!await plotRendererReady()) {
|
|
178
198
|
console.warn("Plotting not initialized yet.");
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
// Later, when the canvas is unmounted:
|
|
182
|
-
await
|
|
202
|
+
await destroyPlotSurface(surfaceId);
|
|
183
203
|
```
|
|
184
204
|
|
|
185
205
|
Once the canvas is registered, calling `plot`, `scatter`, etc. from the RunMat REPL renders directly into that surface without any additional JS shims.
|
|
186
206
|
|
|
187
207
|
## Lifecycle
|
|
188
208
|
|
|
189
|
-
Each `RunMatSessionHandle` now exposes `session.dispose()`. Call it when tearing down the editor/REPL view so the runtime can cancel
|
|
209
|
+
Each `RunMatSessionHandle` now exposes `session.dispose()`. Call it when tearing down the editor/REPL view so the runtime can cancel active execution, release stdin handlers, and drop any registered plot canvases. The wrapper marks the instance as disposed and throws helpful errors if a host accidentally calls `executeRequest()` afterwards. `dispose()` is idempotent, so repeated calls are safe.
|
|
190
210
|
|
|
191
211
|
### Plotting performance knobs
|
|
192
212
|
|
|
@@ -199,13 +219,12 @@ These map directly to the runtime setters (`set_scatter_target_points`, `set_sur
|
|
|
199
219
|
|
|
200
220
|
### Multi-figure canvases & events
|
|
201
221
|
|
|
202
|
-
- `
|
|
203
|
-
- `
|
|
222
|
+
- `createPlotSurface(canvas)` allocates a renderer surface for a specific `<canvas>` and returns a stable `surfaceId`.
|
|
223
|
+
- `bindSurfaceToFigure(surfaceId, handle)` maps that surface to a MATLAB figure handle so multiple figures can render concurrently (e.g., tabs or split panes).
|
|
224
|
+
- `destroyPlotSurface(surfaceId)` detaches the surface and frees renderer resources when a tab/canvas is destroyed.
|
|
204
225
|
- `renderCurrentFigureScene(handle)` forces the renderer to redraw the most recent scene for that figure handle (handy after host-driven resizes or when reactivating a tab that stayed attached to an OffscreenCanvas).
|
|
205
226
|
- `onFigureEvent(listener)` registers a callback that now receives `FigureEvent { handle, kind, figure?: { layout, metadata, plots[] } }`. Metadata contains axis/grid flags, legend entries (including RGBA + plot kind), background/theme info, and optional labels. Plot descriptors enumerate every series (`kind`, `label`, `axesIndex`, `colorRgba`, `visible`). Pass `null` to unsubscribe.
|
|
206
227
|
|
|
207
|
-
The default `registerPlotCanvas` continues to serve the legacy single-canvas flow; hosts can mix both APIs as needed.
|
|
208
|
-
|
|
209
228
|
### Figure orchestration helpers
|
|
210
229
|
|
|
211
230
|
The wasm bindings now expose the same figure/axes controls that the MATLAB runtime uses so hosts can drive multi-tab canvases without issuing textual commands:
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-examples-catalog.d.ts","sourceRoot":"","sources":["../../src/generated/builtin-examples-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAEjE,eAAO,MAAM,sBAAsB,EAAE,0BAA0B,
|
|
1
|
+
{"version":3,"file":"builtin-examples-catalog.d.ts","sourceRoot":"","sources":["../../src/generated/builtin-examples-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAEjE,eAAO,MAAM,sBAAsB,EAAE,0BAA0B,EAAgjkmC,CAAC"}
|