@hypen-space/core 0.4.37 → 0.4.39
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 +13 -14
- package/dist/app.js +304 -227
- package/dist/app.js.map +5 -5
- package/dist/components/builtin.d.ts +17 -0
- package/dist/components/builtin.js +336 -256
- package/dist/components/builtin.js.map +6 -6
- package/dist/context.d.ts +11 -20
- package/dist/context.js +69 -101
- package/dist/context.js.map +3 -3
- package/dist/datasource.js +80 -0
- package/dist/datasource.js.map +10 -0
- package/dist/disposable.js +60 -63
- package/dist/disposable.js.map +2 -2
- package/dist/events.js +60 -63
- package/dist/events.js.map +2 -2
- package/dist/hypen.js +78 -0
- package/dist/hypen.js.map +10 -0
- package/dist/index.browser.d.ts +2 -1
- package/dist/index.browser.js +327 -281
- package/dist/index.browser.js.map +7 -8
- package/dist/index.d.ts +0 -3
- package/dist/index.js +547 -246
- package/dist/index.js.map +9 -9
- package/dist/logger.js +60 -64
- package/dist/logger.js.map +2 -2
- package/dist/remote/client.js +258 -158
- package/dist/remote/client.js.map +6 -6
- package/dist/remote/index.d.ts +6 -5
- package/dist/remote/index.js +255 -1985
- package/dist/remote/index.js.map +6 -13
- package/dist/remote/session.js +151 -0
- package/dist/remote/session.js.map +10 -0
- package/dist/renderer.js +60 -63
- package/dist/renderer.js.map +2 -2
- package/dist/result.js +235 -0
- package/dist/result.js.map +10 -0
- package/dist/retry.js +344 -0
- package/dist/retry.js.map +11 -0
- package/dist/router.js +62 -70
- package/dist/router.js.map +2 -2
- package/dist/state.js +3 -8
- package/dist/state.js.map +2 -2
- package/package.json +11 -56
- package/src/components/builtin.ts +78 -56
- package/src/context.ts +22 -65
- package/src/index.browser.ts +5 -4
- package/src/index.ts +10 -23
- package/src/remote/index.ts +9 -5
- package/src/result.ts +11 -0
- package/dist/discovery.d.ts +0 -90
- package/dist/discovery.js +0 -1334
- package/dist/discovery.js.map +0 -15
- package/dist/engine.browser.d.ts +0 -116
- package/dist/engine.browser.js +0 -479
- package/dist/engine.browser.js.map +0 -12
- package/dist/engine.d.ts +0 -107
- package/dist/engine.js +0 -543
- package/dist/engine.js.map +0 -12
- package/dist/loader.d.ts +0 -51
- package/dist/loader.js +0 -292
- package/dist/loader.js.map +0 -11
- package/dist/plugin.d.ts +0 -39
- package/dist/plugin.js +0 -685
- package/dist/plugin.js.map +0 -12
- package/dist/remote/server.d.ts +0 -188
- package/dist/remote/server.js +0 -2270
- package/dist/remote/server.js.map +0 -19
- package/src/discovery.ts +0 -527
- package/src/engine.browser.ts +0 -302
- package/src/engine.ts +0 -282
- package/src/loader.ts +0 -136
- package/src/plugin.ts +0 -220
- package/src/remote/server.ts +0 -879
- package/wasm-browser/README.md +0 -594
- package/wasm-browser/hypen_engine.d.ts +0 -389
- package/wasm-browser/hypen_engine.js +0 -1070
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-browser/hypen_engine_bg.wasm.d.ts +0 -37
- package/wasm-browser/package.json +0 -24
- package/wasm-node/README.md +0 -594
- package/wasm-node/hypen_engine.d.ts +0 -327
- package/wasm-node/hypen_engine.js +0 -979
- package/wasm-node/hypen_engine_bg.wasm +0 -0
- package/wasm-node/hypen_engine_bg.wasm.d.ts +0 -37
- package/wasm-node/package.json +0 -22
|
@@ -1,979 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./hypen_engine.d.ts" */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The main Hypen engine interface for JavaScript/WASM runtimes.
|
|
5
|
-
*
|
|
6
|
-
* `WasmEngine` manages the full lifecycle of a Hypen UI: parsing DSL source,
|
|
7
|
-
* maintaining the virtual tree, tracking reactive dependencies, and emitting
|
|
8
|
-
* minimal patches when state changes. It runs in a single-threaded WASM
|
|
9
|
-
* environment (browsers, Node.js, Bun, Deno).
|
|
10
|
-
*
|
|
11
|
-
* # Quick Start
|
|
12
|
-
*
|
|
13
|
-
* ```js
|
|
14
|
-
* import { WasmEngine } from "@hypen-space/core";
|
|
15
|
-
*
|
|
16
|
-
* const engine = new WasmEngine();
|
|
17
|
-
*
|
|
18
|
-
* // 1. Register primitives so the engine doesn't try to resolve them as components
|
|
19
|
-
* engine.registerPrimitive("Text");
|
|
20
|
-
* engine.registerPrimitive("Column");
|
|
21
|
-
*
|
|
22
|
-
* // 2. Receive patches via callback
|
|
23
|
-
* engine.setRenderCallback((patches) => {
|
|
24
|
-
* for (const patch of patches) {
|
|
25
|
-
* applyPatch(patch); // Create, SetProp, Insert, Remove, etc.
|
|
26
|
-
* }
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // 3. Optionally set up a module for stateful UI
|
|
30
|
-
* engine.setModule("Counter", ["increment"], ["count"], { count: 0 });
|
|
31
|
-
*
|
|
32
|
-
* // 4. Render DSL source — patches are emitted via the callback
|
|
33
|
-
* engine.renderSource('Column { Text("Count: ${state.count}") }');
|
|
34
|
-
*
|
|
35
|
-
* // 5. Update state — only affected nodes are re-rendered
|
|
36
|
-
* engine.updateState({ count: 1 });
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* # Patch Protocol
|
|
40
|
-
*
|
|
41
|
-
* All UI mutations are expressed as [`Patch`] values emitted through the render
|
|
42
|
-
* callback. Patches use camelCase field names for direct JavaScript consumption.
|
|
43
|
-
* See [`Patch`] for the full variant list and field documentation.
|
|
44
|
-
*
|
|
45
|
-
* # Component Resolution
|
|
46
|
-
*
|
|
47
|
-
* Custom components (anything not registered as a primitive) are resolved lazily
|
|
48
|
-
* via the component resolver callback set with [`set_component_resolver`]. The
|
|
49
|
-
* resolver receives `(componentName, contextPath)` and should return
|
|
50
|
-
* `{ source: string, path: string }` or `null`.
|
|
51
|
-
*
|
|
52
|
-
* # Revision Tracking
|
|
53
|
-
*
|
|
54
|
-
* Every render cycle (initial render or state update that produces patches)
|
|
55
|
-
* increments the revision counter. Use [`get_revision`] to detect stale state
|
|
56
|
-
* in async workflows.
|
|
57
|
-
*/
|
|
58
|
-
class WasmEngine {
|
|
59
|
-
__destroy_into_raw() {
|
|
60
|
-
const ptr = this.__wbg_ptr;
|
|
61
|
-
this.__wbg_ptr = 0;
|
|
62
|
-
WasmEngineFinalization.unregister(this);
|
|
63
|
-
return ptr;
|
|
64
|
-
}
|
|
65
|
-
free() {
|
|
66
|
-
const ptr = this.__destroy_into_raw();
|
|
67
|
-
wasm.__wbg_wasmengine_free(ptr, 0);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Remove all nodes from the instance tree without emitting Remove patches.
|
|
71
|
-
*
|
|
72
|
-
* Use this when tearing down the UI entirely (e.g. navigating away or
|
|
73
|
-
* switching samples). The renderer is responsible for clearing its own
|
|
74
|
-
* DOM/canvas state separately.
|
|
75
|
-
*/
|
|
76
|
-
clearTree() {
|
|
77
|
-
wasm.wasmengine_clearTree(this.__wbg_ptr);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Return a JSON snapshot of the active module's current state.
|
|
81
|
-
*
|
|
82
|
-
* Returns `null` (as a `JsValue`) if no module is set.
|
|
83
|
-
* Useful for debugging and DevTools integration.
|
|
84
|
-
* @returns {any}
|
|
85
|
-
*/
|
|
86
|
-
currentState() {
|
|
87
|
-
const ret = wasm.wasmengine_currentState(this.__wbg_ptr);
|
|
88
|
-
return ret;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Parse a component and return a human-readable debug string.
|
|
92
|
-
*
|
|
93
|
-
* Intended for development tooling only — the output format is not stable.
|
|
94
|
-
* @param {string} source
|
|
95
|
-
* @returns {string}
|
|
96
|
-
*/
|
|
97
|
-
debugParseComponent(source) {
|
|
98
|
-
let deferred3_0;
|
|
99
|
-
let deferred3_1;
|
|
100
|
-
try {
|
|
101
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
-
const len0 = WASM_VECTOR_LEN;
|
|
103
|
-
const ret = wasm.wasmengine_debugParseComponent(this.__wbg_ptr, ptr0, len0);
|
|
104
|
-
var ptr2 = ret[0];
|
|
105
|
-
var len2 = ret[1];
|
|
106
|
-
if (ret[3]) {
|
|
107
|
-
ptr2 = 0; len2 = 0;
|
|
108
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
109
|
-
}
|
|
110
|
-
deferred3_0 = ptr2;
|
|
111
|
-
deferred3_1 = len2;
|
|
112
|
-
return getStringFromWasm0(ptr2, len2);
|
|
113
|
-
} finally {
|
|
114
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Dispatch a named action, invoking the registered handler (if any).
|
|
119
|
-
*
|
|
120
|
-
* Actions are the primary way UI events flow from the renderer back to
|
|
121
|
-
* application logic. In Hypen DSL, buttons reference actions like
|
|
122
|
-
* `Button("@actions.submit")` — the renderer maps clicks to
|
|
123
|
-
* `engine.dispatchAction("submit", payload)`.
|
|
124
|
-
*
|
|
125
|
-
* # Arguments
|
|
126
|
-
* * `name` — Action name (e.g. `"submit"`, `"increment"`)
|
|
127
|
-
* * `payload` — Optional JS value passed to the handler. `null`/`undefined` are treated as no payload.
|
|
128
|
-
*
|
|
129
|
-
* # Errors
|
|
130
|
-
*
|
|
131
|
-
* Returns an error if the payload cannot be deserialized. Does **not** error
|
|
132
|
-
* if no handler is registered (the action is silently dropped).
|
|
133
|
-
* @param {string} name
|
|
134
|
-
* @param {any} payload
|
|
135
|
-
*/
|
|
136
|
-
dispatchAction(name, payload) {
|
|
137
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
-
const len0 = WASM_VECTOR_LEN;
|
|
139
|
-
const ret = wasm.wasmengine_dispatchAction(this.__wbg_ptr, ptr0, len0, payload);
|
|
140
|
-
if (ret[1]) {
|
|
141
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get the current revision number.
|
|
146
|
-
*
|
|
147
|
-
* Starts at 0 and increments by 1 for each render cycle that produces
|
|
148
|
-
* patches. Useful for cache invalidation and detecting stale async results.
|
|
149
|
-
* @returns {bigint}
|
|
150
|
-
*/
|
|
151
|
-
getRevision() {
|
|
152
|
-
const ret = wasm.wasmengine_getRevision(this.__wbg_ptr);
|
|
153
|
-
return BigInt.asUintN(64, ret);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create a new engine instance with an empty tree and no module.
|
|
157
|
-
*
|
|
158
|
-
* After construction, you typically:
|
|
159
|
-
* 1. Register primitives with [`register_primitive`]
|
|
160
|
-
* 2. Set a render callback with [`set_render_callback`]
|
|
161
|
-
* 3. Optionally set a component resolver with [`set_component_resolver`]
|
|
162
|
-
* 4. Optionally initialize a module with [`set_module`]
|
|
163
|
-
* 5. Render source with [`render_source`]
|
|
164
|
-
*/
|
|
165
|
-
constructor() {
|
|
166
|
-
const ret = wasm.wasmengine_new();
|
|
167
|
-
this.__wbg_ptr = ret >>> 0;
|
|
168
|
-
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Register a JavaScript function as the handler for a named action.
|
|
173
|
-
*
|
|
174
|
-
* When [`dispatch_action`] is called with a matching name, the handler
|
|
175
|
-
* receives a serialized [`Action`] object with `{ name, payload }`.
|
|
176
|
-
*
|
|
177
|
-
* Registering a handler for the same name replaces the previous one.
|
|
178
|
-
* @param {string} action_name
|
|
179
|
-
* @param {Function} handler
|
|
180
|
-
*/
|
|
181
|
-
onAction(action_name, handler) {
|
|
182
|
-
const ptr0 = passStringToWasm0(action_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
183
|
-
const len0 = WASM_VECTOR_LEN;
|
|
184
|
-
wasm.wasmengine_onAction(this.__wbg_ptr, ptr0, len0, handler);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Register a handler for data source actions.
|
|
188
|
-
*
|
|
189
|
-
* When [`dispatch_action`] is called with a name like `"spacetime.sendMessage"`
|
|
190
|
-
* and no explicit action handler is registered for that name, the engine checks
|
|
191
|
-
* if the prefix (`"spacetime"`) is a registered data source. If so, it calls
|
|
192
|
-
* this handler with `{ provider, method, payload }`.
|
|
193
|
-
*
|
|
194
|
-
* This enables `@actions.spacetime.sendMessage` in DSL to automatically route
|
|
195
|
-
* to the appropriate data source plugin without manual handler registration.
|
|
196
|
-
* @param {Function} handler
|
|
197
|
-
*/
|
|
198
|
-
onDataSourceAction(handler) {
|
|
199
|
-
wasm.wasmengine_onDataSourceAction(this.__wbg_ptr, handler);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Register a primitive element (like Text, Button, etc.) to skip component resolution
|
|
203
|
-
* This prevents unnecessary resolver calls for built-in DOM elements
|
|
204
|
-
* @param {string} name
|
|
205
|
-
*/
|
|
206
|
-
registerPrimitive(name) {
|
|
207
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
-
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
wasm.wasmengine_registerPrimitive(this.__wbg_ptr, ptr0, len0);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Remove a data source context entirely.
|
|
213
|
-
*
|
|
214
|
-
* Drops the provider's state and re-renders bound nodes (they resolve to `null`).
|
|
215
|
-
* @param {string} name
|
|
216
|
-
*/
|
|
217
|
-
removeContext(name) {
|
|
218
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
219
|
-
const len0 = WASM_VECTOR_LEN;
|
|
220
|
-
wasm.wasmengine_removeContext(this.__wbg_ptr, ptr0, len0);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Render a component into a specific parent node (subtree rendering)
|
|
224
|
-
* This is used for lazy routing where components are rendered on-demand into route containers
|
|
225
|
-
*
|
|
226
|
-
* # Arguments
|
|
227
|
-
* * `source` - The Hypen DSL source to parse and render
|
|
228
|
-
* * `parent_node_id_str` - The serialized node ID string of the parent element
|
|
229
|
-
* * `state_js` - The state to use for rendering (as JsValue)
|
|
230
|
-
* @param {string} source
|
|
231
|
-
* @param {string} parent_node_id_str
|
|
232
|
-
* @param {any} state_js
|
|
233
|
-
*/
|
|
234
|
-
renderInto(source, parent_node_id_str, state_js) {
|
|
235
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
236
|
-
const len0 = WASM_VECTOR_LEN;
|
|
237
|
-
const ptr1 = passStringToWasm0(parent_node_id_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
|
-
const len1 = WASM_VECTOR_LEN;
|
|
239
|
-
const ret = wasm.wasmengine_renderInto(this.__wbg_ptr, ptr0, len0, ptr1, len1, state_js);
|
|
240
|
-
if (ret[1]) {
|
|
241
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Render a component source on-demand (for lazy-loaded routes).
|
|
246
|
-
*
|
|
247
|
-
* Equivalent to calling [`render_source`] — the source is parsed as a full
|
|
248
|
-
* document and replaces the current tree.
|
|
249
|
-
* @param {string} source
|
|
250
|
-
*/
|
|
251
|
-
renderLazyComponent(source) {
|
|
252
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
253
|
-
const len0 = WASM_VECTOR_LEN;
|
|
254
|
-
const ret = wasm.wasmengine_renderLazyComponent(this.__wbg_ptr, ptr0, len0);
|
|
255
|
-
if (ret[1]) {
|
|
256
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Parse and render Hypen DSL source code, emitting patches via the render callback.
|
|
261
|
-
*
|
|
262
|
-
* Supports full document syntax including `import` statements. Imports are
|
|
263
|
-
* resolved synchronously through the component resolver callback (if set).
|
|
264
|
-
*
|
|
265
|
-
* This performs a **full reconciliation** — the existing tree is diffed against
|
|
266
|
-
* the new IR and minimal patches are emitted. Calling this multiple times with
|
|
267
|
-
* different source replaces the previous UI.
|
|
268
|
-
*
|
|
269
|
-
* # Errors
|
|
270
|
-
*
|
|
271
|
-
* Returns a `JsValue` string error if the source fails to parse.
|
|
272
|
-
* @param {string} source
|
|
273
|
-
*/
|
|
274
|
-
renderSource(source) {
|
|
275
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
-
const len0 = WASM_VECTOR_LEN;
|
|
277
|
-
const ret = wasm.wasmengine_renderSource(this.__wbg_ptr, ptr0, len0);
|
|
278
|
-
if (ret[1]) {
|
|
279
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Fully reset the engine to its initial empty state.
|
|
284
|
-
*
|
|
285
|
-
* Clears the tree, module, dependencies, scheduler, action handlers,
|
|
286
|
-
* component registry, and resets the revision to 0. The render callback
|
|
287
|
-
* and component resolver are preserved.
|
|
288
|
-
*/
|
|
289
|
-
reset() {
|
|
290
|
-
wasm.wasmengine_reset(this.__wbg_ptr);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Set the component resolver callback
|
|
294
|
-
* The resolver receives (componentName, contextPath) and should return
|
|
295
|
-
* { source: string, path: string } or null
|
|
296
|
-
*
|
|
297
|
-
* contextPath is the path of the component that's referencing this component
|
|
298
|
-
* The returned path should be the resolved absolute path to the component file
|
|
299
|
-
* @param {Function} resolver
|
|
300
|
-
*/
|
|
301
|
-
setComponentResolver(resolver) {
|
|
302
|
-
wasm.wasmengine_setComponentResolver(this.__wbg_ptr, resolver);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Set (or replace) a named data source context.
|
|
306
|
-
*
|
|
307
|
-
* Registers the provider in the dependency graph (if not already known),
|
|
308
|
-
* stores the data, and re-renders every node bound to `$name.*`.
|
|
309
|
-
* Sparse merging (if needed) should happen at the SDK layer before
|
|
310
|
-
* calling this method with the merged object.
|
|
311
|
-
*
|
|
312
|
-
* # Example (JS)
|
|
313
|
-
* ```js
|
|
314
|
-
* engine.setContext("spacetime", {
|
|
315
|
-
* message: [{ id: 1, text: "Hello" }, { id: 2, text: "World" }],
|
|
316
|
-
* user: [{ id: 1, name: "Alice", online: true }]
|
|
317
|
-
* });
|
|
318
|
-
* ```
|
|
319
|
-
* @param {string} name
|
|
320
|
-
* @param {any} data_js
|
|
321
|
-
*/
|
|
322
|
-
setContext(name, data_js) {
|
|
323
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
324
|
-
const len0 = WASM_VECTOR_LEN;
|
|
325
|
-
const ret = wasm.wasmengine_setContext(this.__wbg_ptr, ptr0, len0, data_js);
|
|
326
|
-
if (ret[1]) {
|
|
327
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Initialize (or replace) the active module with the given configuration.
|
|
332
|
-
*
|
|
333
|
-
* A module provides stateful context for `${state.xxx}` bindings in the DSL.
|
|
334
|
-
* Only one module is active at a time — calling this again replaces it.
|
|
335
|
-
*
|
|
336
|
-
* # Arguments
|
|
337
|
-
* * `name` — Module identifier (e.g. `"Counter"`, `"ProfilePage"`)
|
|
338
|
-
* * `actions` — List of action names this module handles
|
|
339
|
-
* * `state_keys` — List of top-level state keys (used for validation)
|
|
340
|
-
* * `initial_state` — The starting state as a JS object
|
|
341
|
-
*
|
|
342
|
-
* # Errors
|
|
343
|
-
*
|
|
344
|
-
* Returns an error if `initial_state` cannot be deserialized as JSON.
|
|
345
|
-
* @param {string} name
|
|
346
|
-
* @param {string[]} actions
|
|
347
|
-
* @param {string[]} state_keys
|
|
348
|
-
* @param {any} initial_state
|
|
349
|
-
*/
|
|
350
|
-
setModule(name, actions, state_keys, initial_state) {
|
|
351
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
352
|
-
const len0 = WASM_VECTOR_LEN;
|
|
353
|
-
const ptr1 = passArrayJsValueToWasm0(actions, wasm.__wbindgen_malloc);
|
|
354
|
-
const len1 = WASM_VECTOR_LEN;
|
|
355
|
-
const ptr2 = passArrayJsValueToWasm0(state_keys, wasm.__wbindgen_malloc);
|
|
356
|
-
const len2 = WASM_VECTOR_LEN;
|
|
357
|
-
const ret = wasm.wasmengine_setModule(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, initial_state);
|
|
358
|
-
if (ret[1]) {
|
|
359
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Set the callback that receives UI patches after each render cycle.
|
|
364
|
-
*
|
|
365
|
-
* The callback is invoked with a single argument: a JavaScript array of
|
|
366
|
-
* [`Patch`] objects. Each patch describes one atomic DOM operation (Create,
|
|
367
|
-
* SetProp, SetText, Insert, Move, Remove, RemoveProp).
|
|
368
|
-
*
|
|
369
|
-
* The callback is called synchronously during `renderSource()`, `updateState()`,
|
|
370
|
-
* `updateStateSparse()`, and `renderInto()`.
|
|
371
|
-
*
|
|
372
|
-
* # Example (JS)
|
|
373
|
-
* ```js
|
|
374
|
-
* engine.setRenderCallback((patches) => {
|
|
375
|
-
* for (const p of patches) {
|
|
376
|
-
* switch (p.type) {
|
|
377
|
-
* case "create": createElement(p.id, p.elementType, p.props); break;
|
|
378
|
-
* case "setProp": setProperty(p.id, p.name, p.value); break;
|
|
379
|
-
* case "insert": insertChild(p.parentId, p.id, p.beforeId); break;
|
|
380
|
-
* // ...
|
|
381
|
-
* }
|
|
382
|
-
* }
|
|
383
|
-
* });
|
|
384
|
-
* ```
|
|
385
|
-
* @param {Function} callback
|
|
386
|
-
*/
|
|
387
|
-
setRenderCallback(callback) {
|
|
388
|
-
wasm.wasmengine_setRenderCallback(this.__wbg_ptr, callback);
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Return the total number of nodes currently in the instance tree.
|
|
392
|
-
*
|
|
393
|
-
* Useful for debugging, performance monitoring, and DevTools.
|
|
394
|
-
* @returns {number}
|
|
395
|
-
*/
|
|
396
|
-
treeSize() {
|
|
397
|
-
const ret = wasm.wasmengine_treeSize(this.__wbg_ptr);
|
|
398
|
-
return ret >>> 0;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Apply a state patch and re-render affected nodes.
|
|
402
|
-
*
|
|
403
|
-
* The `state_patch` is a JavaScript object whose keys are merged into the
|
|
404
|
-
* current module state (deep merge). Only nodes whose bindings reference
|
|
405
|
-
* changed paths are re-rendered, producing minimal patches.
|
|
406
|
-
*
|
|
407
|
-
* # Example (JS)
|
|
408
|
-
* ```js
|
|
409
|
-
* // Updates state.user.name and state.count, re-renders bound nodes
|
|
410
|
-
* engine.updateState({ user: { name: "Bob" }, count: 42 });
|
|
411
|
-
* ```
|
|
412
|
-
*
|
|
413
|
-
* # Errors
|
|
414
|
-
*
|
|
415
|
-
* Returns an error if `state_patch` cannot be deserialized as JSON.
|
|
416
|
-
* @param {any} state_patch
|
|
417
|
-
*/
|
|
418
|
-
updateState(state_patch) {
|
|
419
|
-
const ret = wasm.wasmengine_updateState(this.__wbg_ptr, state_patch);
|
|
420
|
-
if (ret[1]) {
|
|
421
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Apply a sparse state update using explicit path-value pairs.
|
|
426
|
-
*
|
|
427
|
-
* More efficient than [`update_state`] for large state objects when only a
|
|
428
|
-
* few deeply-nested paths changed, because it avoids a full deep-merge.
|
|
429
|
-
*
|
|
430
|
-
* # Arguments
|
|
431
|
-
* * `paths_js` — JS array of dot-separated paths that changed (e.g. `["user.name", "count"]`)
|
|
432
|
-
* * `values_js` — JS object mapping each path to its new value (e.g. `{ "user.name": "Bob", "count": 42 }`)
|
|
433
|
-
*
|
|
434
|
-
* # Errors
|
|
435
|
-
*
|
|
436
|
-
* Returns an error if either argument cannot be deserialized.
|
|
437
|
-
* @param {any} paths_js
|
|
438
|
-
* @param {any} values_js
|
|
439
|
-
*/
|
|
440
|
-
updateStateSparse(paths_js, values_js) {
|
|
441
|
-
const ret = wasm.wasmengine_updateStateSparse(this.__wbg_ptr, paths_js, values_js);
|
|
442
|
-
if (ret[1]) {
|
|
443
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Validate that the engine is in a consistent state.
|
|
448
|
-
*
|
|
449
|
-
* Checks that:
|
|
450
|
-
* - All child references point to existing nodes
|
|
451
|
-
* - All parent back-references are correct
|
|
452
|
-
* - The root node (if any) exists in the tree
|
|
453
|
-
*
|
|
454
|
-
* Returns `null` if valid, or a string describing the first inconsistency found.
|
|
455
|
-
* Intended for testing and debugging only — not for production hot paths.
|
|
456
|
-
* @returns {any}
|
|
457
|
-
*/
|
|
458
|
-
validate() {
|
|
459
|
-
const ret = wasm.wasmengine_validate(this.__wbg_ptr);
|
|
460
|
-
return ret;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
464
|
-
exports.WasmEngine = WasmEngine;
|
|
465
|
-
|
|
466
|
-
function main() {
|
|
467
|
-
wasm.main();
|
|
468
|
-
}
|
|
469
|
-
exports.main = main;
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Parse Hypen DSL source and return the AST as a pretty-printed JSON string.
|
|
473
|
-
*
|
|
474
|
-
* Useful for tooling, syntax highlighting, and debugging the parser output.
|
|
475
|
-
* @param {string} source
|
|
476
|
-
* @returns {string}
|
|
477
|
-
*/
|
|
478
|
-
function parseToJson(source) {
|
|
479
|
-
let deferred3_0;
|
|
480
|
-
let deferred3_1;
|
|
481
|
-
try {
|
|
482
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
483
|
-
const len0 = WASM_VECTOR_LEN;
|
|
484
|
-
const ret = wasm.parseToJson(ptr0, len0);
|
|
485
|
-
var ptr2 = ret[0];
|
|
486
|
-
var len2 = ret[1];
|
|
487
|
-
if (ret[3]) {
|
|
488
|
-
ptr2 = 0; len2 = 0;
|
|
489
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
490
|
-
}
|
|
491
|
-
deferred3_0 = ptr2;
|
|
492
|
-
deferred3_1 = len2;
|
|
493
|
-
return getStringFromWasm0(ptr2, len2);
|
|
494
|
-
} finally {
|
|
495
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
exports.parseToJson = parseToJson;
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Serialize a patches array to a pretty-printed JSON string.
|
|
502
|
-
*
|
|
503
|
-
* Intended for debugging and logging — not for production use.
|
|
504
|
-
* Accepts a JS array of patch objects and returns formatted JSON.
|
|
505
|
-
* @param {any} patches
|
|
506
|
-
* @returns {string}
|
|
507
|
-
*/
|
|
508
|
-
function patchesToJson(patches) {
|
|
509
|
-
let deferred2_0;
|
|
510
|
-
let deferred2_1;
|
|
511
|
-
try {
|
|
512
|
-
const ret = wasm.patchesToJson(patches);
|
|
513
|
-
var ptr1 = ret[0];
|
|
514
|
-
var len1 = ret[1];
|
|
515
|
-
if (ret[3]) {
|
|
516
|
-
ptr1 = 0; len1 = 0;
|
|
517
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
518
|
-
}
|
|
519
|
-
deferred2_0 = ptr1;
|
|
520
|
-
deferred2_1 = len1;
|
|
521
|
-
return getStringFromWasm0(ptr1, len1);
|
|
522
|
-
} finally {
|
|
523
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
exports.patchesToJson = patchesToJson;
|
|
527
|
-
|
|
528
|
-
function __wbg_get_imports() {
|
|
529
|
-
const import0 = {
|
|
530
|
-
__proto__: null,
|
|
531
|
-
__wbg_Error_ecbf49c1b9d07c30: function(arg0, arg1) {
|
|
532
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
533
|
-
return ret;
|
|
534
|
-
},
|
|
535
|
-
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
536
|
-
const ret = String(arg1);
|
|
537
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
538
|
-
const len1 = WASM_VECTOR_LEN;
|
|
539
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
540
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
541
|
-
},
|
|
542
|
-
__wbg___wbindgen_bigint_get_as_i64_a4925bc53b16f3d6: function(arg0, arg1) {
|
|
543
|
-
const v = arg1;
|
|
544
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
545
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
546
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
547
|
-
},
|
|
548
|
-
__wbg___wbindgen_boolean_get_4a348b369b009243: function(arg0) {
|
|
549
|
-
const v = arg0;
|
|
550
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
551
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
552
|
-
},
|
|
553
|
-
__wbg___wbindgen_debug_string_43c7ccb034739216: function(arg0, arg1) {
|
|
554
|
-
const ret = debugString(arg1);
|
|
555
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
556
|
-
const len1 = WASM_VECTOR_LEN;
|
|
557
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
558
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
559
|
-
},
|
|
560
|
-
__wbg___wbindgen_in_035107858ad0083e: function(arg0, arg1) {
|
|
561
|
-
const ret = arg0 in arg1;
|
|
562
|
-
return ret;
|
|
563
|
-
},
|
|
564
|
-
__wbg___wbindgen_is_bigint_15e2d080220c7748: function(arg0) {
|
|
565
|
-
const ret = typeof(arg0) === 'bigint';
|
|
566
|
-
return ret;
|
|
567
|
-
},
|
|
568
|
-
__wbg___wbindgen_is_function_18bea6e84080c016: function(arg0) {
|
|
569
|
-
const ret = typeof(arg0) === 'function';
|
|
570
|
-
return ret;
|
|
571
|
-
},
|
|
572
|
-
__wbg___wbindgen_is_null_c5f5bb76436a9ab1: function(arg0) {
|
|
573
|
-
const ret = arg0 === null;
|
|
574
|
-
return ret;
|
|
575
|
-
},
|
|
576
|
-
__wbg___wbindgen_is_object_8d3fac158b36498d: function(arg0) {
|
|
577
|
-
const val = arg0;
|
|
578
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
579
|
-
return ret;
|
|
580
|
-
},
|
|
581
|
-
__wbg___wbindgen_is_string_4d5f2c5b2acf65b0: function(arg0) {
|
|
582
|
-
const ret = typeof(arg0) === 'string';
|
|
583
|
-
return ret;
|
|
584
|
-
},
|
|
585
|
-
__wbg___wbindgen_is_undefined_4a711ea9d2e1ef93: function(arg0) {
|
|
586
|
-
const ret = arg0 === undefined;
|
|
587
|
-
return ret;
|
|
588
|
-
},
|
|
589
|
-
__wbg___wbindgen_jsval_eq_65f99081d9ee8f4d: function(arg0, arg1) {
|
|
590
|
-
const ret = arg0 === arg1;
|
|
591
|
-
return ret;
|
|
592
|
-
},
|
|
593
|
-
__wbg___wbindgen_jsval_loose_eq_1a2067dfb025b5ec: function(arg0, arg1) {
|
|
594
|
-
const ret = arg0 == arg1;
|
|
595
|
-
return ret;
|
|
596
|
-
},
|
|
597
|
-
__wbg___wbindgen_number_get_eed4462ef92e1bed: function(arg0, arg1) {
|
|
598
|
-
const obj = arg1;
|
|
599
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
600
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
601
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
602
|
-
},
|
|
603
|
-
__wbg___wbindgen_string_get_d09f733449cbf7a2: function(arg0, arg1) {
|
|
604
|
-
const obj = arg1;
|
|
605
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
606
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
607
|
-
var len1 = WASM_VECTOR_LEN;
|
|
608
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
609
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
610
|
-
},
|
|
611
|
-
__wbg___wbindgen_throw_df03e93053e0f4bc: function(arg0, arg1) {
|
|
612
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
613
|
-
},
|
|
614
|
-
__wbg_call_2989817bf2a245b5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
615
|
-
const ret = arg0.call(arg1, arg2, arg3);
|
|
616
|
-
return ret;
|
|
617
|
-
}, arguments); },
|
|
618
|
-
__wbg_call_85e5437fa1ab109d: function() { return handleError(function (arg0, arg1, arg2) {
|
|
619
|
-
const ret = arg0.call(arg1, arg2);
|
|
620
|
-
return ret;
|
|
621
|
-
}, arguments); },
|
|
622
|
-
__wbg_call_df7a43aecab856a8: function() { return handleError(function (arg0, arg1) {
|
|
623
|
-
const ret = arg0.call(arg1);
|
|
624
|
-
return ret;
|
|
625
|
-
}, arguments); },
|
|
626
|
-
__wbg_done_0ad70482cae88a68: function(arg0) {
|
|
627
|
-
const ret = arg0.done;
|
|
628
|
-
return ret;
|
|
629
|
-
},
|
|
630
|
-
__wbg_entries_d58050057c0390ac: function(arg0) {
|
|
631
|
-
const ret = Object.entries(arg0);
|
|
632
|
-
return ret;
|
|
633
|
-
},
|
|
634
|
-
__wbg_error_51679600615c775d: function(arg0) {
|
|
635
|
-
console.error(arg0);
|
|
636
|
-
},
|
|
637
|
-
__wbg_get_6f5cf69c8f3f094a: function() { return handleError(function (arg0, arg1) {
|
|
638
|
-
const ret = Reflect.get(arg0, arg1);
|
|
639
|
-
return ret;
|
|
640
|
-
}, arguments); },
|
|
641
|
-
__wbg_get_c40e2c3262995a8e: function(arg0, arg1) {
|
|
642
|
-
const ret = arg0[arg1 >>> 0];
|
|
643
|
-
return ret;
|
|
644
|
-
},
|
|
645
|
-
__wbg_get_d0e1306db90b68d9: function() { return handleError(function (arg0, arg1) {
|
|
646
|
-
const ret = Reflect.get(arg0, arg1);
|
|
647
|
-
return ret;
|
|
648
|
-
}, arguments); },
|
|
649
|
-
__wbg_get_unchecked_3de5bfaaea65f86b: function(arg0, arg1) {
|
|
650
|
-
const ret = arg0[arg1 >>> 0];
|
|
651
|
-
return ret;
|
|
652
|
-
},
|
|
653
|
-
__wbg_instanceof_ArrayBuffer_d8e4e51f1cf7287a: function(arg0) {
|
|
654
|
-
let result;
|
|
655
|
-
try {
|
|
656
|
-
result = arg0 instanceof ArrayBuffer;
|
|
657
|
-
} catch (_) {
|
|
658
|
-
result = false;
|
|
659
|
-
}
|
|
660
|
-
const ret = result;
|
|
661
|
-
return ret;
|
|
662
|
-
},
|
|
663
|
-
__wbg_instanceof_Map_53b6790994271123: function(arg0) {
|
|
664
|
-
let result;
|
|
665
|
-
try {
|
|
666
|
-
result = arg0 instanceof Map;
|
|
667
|
-
} catch (_) {
|
|
668
|
-
result = false;
|
|
669
|
-
}
|
|
670
|
-
const ret = result;
|
|
671
|
-
return ret;
|
|
672
|
-
},
|
|
673
|
-
__wbg_instanceof_Uint8Array_6e48d83da6091cc8: function(arg0) {
|
|
674
|
-
let result;
|
|
675
|
-
try {
|
|
676
|
-
result = arg0 instanceof Uint8Array;
|
|
677
|
-
} catch (_) {
|
|
678
|
-
result = false;
|
|
679
|
-
}
|
|
680
|
-
const ret = result;
|
|
681
|
-
return ret;
|
|
682
|
-
},
|
|
683
|
-
__wbg_isArray_2efa5973cef6ec32: function(arg0) {
|
|
684
|
-
const ret = Array.isArray(arg0);
|
|
685
|
-
return ret;
|
|
686
|
-
},
|
|
687
|
-
__wbg_isSafeInteger_6709fb28be12d738: function(arg0) {
|
|
688
|
-
const ret = Number.isSafeInteger(arg0);
|
|
689
|
-
return ret;
|
|
690
|
-
},
|
|
691
|
-
__wbg_iterator_e77d2b7575cca5a7: function() {
|
|
692
|
-
const ret = Symbol.iterator;
|
|
693
|
-
return ret;
|
|
694
|
-
},
|
|
695
|
-
__wbg_length_00dd7227fd4626ad: function(arg0) {
|
|
696
|
-
const ret = arg0.length;
|
|
697
|
-
return ret;
|
|
698
|
-
},
|
|
699
|
-
__wbg_length_5e07cf181b2745fb: function(arg0) {
|
|
700
|
-
const ret = arg0.length;
|
|
701
|
-
return ret;
|
|
702
|
-
},
|
|
703
|
-
__wbg_log_91f1dd1dfd5a4ae8: function(arg0) {
|
|
704
|
-
console.log(arg0);
|
|
705
|
-
},
|
|
706
|
-
__wbg_new_62f131e968c83d75: function() {
|
|
707
|
-
const ret = new Object();
|
|
708
|
-
return ret;
|
|
709
|
-
},
|
|
710
|
-
__wbg_new_66075f8c2ea6575e: function() {
|
|
711
|
-
const ret = new Array();
|
|
712
|
-
return ret;
|
|
713
|
-
},
|
|
714
|
-
__wbg_new_74eb411a4d7bd3f1: function() {
|
|
715
|
-
const ret = new Map();
|
|
716
|
-
return ret;
|
|
717
|
-
},
|
|
718
|
-
__wbg_new_a0479da6258a0d71: function(arg0) {
|
|
719
|
-
const ret = new Uint8Array(arg0);
|
|
720
|
-
return ret;
|
|
721
|
-
},
|
|
722
|
-
__wbg_next_5428439dfc1d0362: function() { return handleError(function (arg0) {
|
|
723
|
-
const ret = arg0.next();
|
|
724
|
-
return ret;
|
|
725
|
-
}, arguments); },
|
|
726
|
-
__wbg_next_d314789a105729f3: function(arg0) {
|
|
727
|
-
const ret = arg0.next;
|
|
728
|
-
return ret;
|
|
729
|
-
},
|
|
730
|
-
__wbg_prototypesetcall_d1a7133bc8d83aa9: function(arg0, arg1, arg2) {
|
|
731
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
732
|
-
},
|
|
733
|
-
__wbg_set_3ba5af57f57f831c: function(arg0, arg1, arg2) {
|
|
734
|
-
const ret = arg0.set(arg1, arg2);
|
|
735
|
-
return ret;
|
|
736
|
-
},
|
|
737
|
-
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
738
|
-
arg0[arg1] = arg2;
|
|
739
|
-
},
|
|
740
|
-
__wbg_set_7bf9e2df46e7632c: function(arg0, arg1, arg2) {
|
|
741
|
-
arg0[arg1 >>> 0] = arg2;
|
|
742
|
-
},
|
|
743
|
-
__wbg_set_8326741805409e83: function() { return handleError(function (arg0, arg1, arg2) {
|
|
744
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
745
|
-
return ret;
|
|
746
|
-
}, arguments); },
|
|
747
|
-
__wbg_value_414b42ce7b3eca22: function(arg0) {
|
|
748
|
-
const ret = arg0.value;
|
|
749
|
-
return ret;
|
|
750
|
-
},
|
|
751
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
752
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
753
|
-
const ret = arg0;
|
|
754
|
-
return ret;
|
|
755
|
-
},
|
|
756
|
-
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
757
|
-
// Cast intrinsic for `I64 -> Externref`.
|
|
758
|
-
const ret = arg0;
|
|
759
|
-
return ret;
|
|
760
|
-
},
|
|
761
|
-
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
762
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
763
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
764
|
-
return ret;
|
|
765
|
-
},
|
|
766
|
-
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
767
|
-
// Cast intrinsic for `U64 -> Externref`.
|
|
768
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
769
|
-
return ret;
|
|
770
|
-
},
|
|
771
|
-
__wbindgen_init_externref_table: function() {
|
|
772
|
-
const table = wasm.__wbindgen_externrefs;
|
|
773
|
-
const offset = table.grow(4);
|
|
774
|
-
table.set(0, undefined);
|
|
775
|
-
table.set(offset + 0, undefined);
|
|
776
|
-
table.set(offset + 1, null);
|
|
777
|
-
table.set(offset + 2, true);
|
|
778
|
-
table.set(offset + 3, false);
|
|
779
|
-
},
|
|
780
|
-
};
|
|
781
|
-
return {
|
|
782
|
-
__proto__: null,
|
|
783
|
-
"./hypen_engine_bg.js": import0,
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
788
|
-
? { register: () => {}, unregister: () => {} }
|
|
789
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
790
|
-
|
|
791
|
-
function addToExternrefTable0(obj) {
|
|
792
|
-
const idx = wasm.__externref_table_alloc();
|
|
793
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
794
|
-
return idx;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
function debugString(val) {
|
|
798
|
-
// primitive types
|
|
799
|
-
const type = typeof val;
|
|
800
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
801
|
-
return `${val}`;
|
|
802
|
-
}
|
|
803
|
-
if (type == 'string') {
|
|
804
|
-
return `"${val}"`;
|
|
805
|
-
}
|
|
806
|
-
if (type == 'symbol') {
|
|
807
|
-
const description = val.description;
|
|
808
|
-
if (description == null) {
|
|
809
|
-
return 'Symbol';
|
|
810
|
-
} else {
|
|
811
|
-
return `Symbol(${description})`;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
if (type == 'function') {
|
|
815
|
-
const name = val.name;
|
|
816
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
817
|
-
return `Function(${name})`;
|
|
818
|
-
} else {
|
|
819
|
-
return 'Function';
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
// objects
|
|
823
|
-
if (Array.isArray(val)) {
|
|
824
|
-
const length = val.length;
|
|
825
|
-
let debug = '[';
|
|
826
|
-
if (length > 0) {
|
|
827
|
-
debug += debugString(val[0]);
|
|
828
|
-
}
|
|
829
|
-
for(let i = 1; i < length; i++) {
|
|
830
|
-
debug += ', ' + debugString(val[i]);
|
|
831
|
-
}
|
|
832
|
-
debug += ']';
|
|
833
|
-
return debug;
|
|
834
|
-
}
|
|
835
|
-
// Test for built-in
|
|
836
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
837
|
-
let className;
|
|
838
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
839
|
-
className = builtInMatches[1];
|
|
840
|
-
} else {
|
|
841
|
-
// Failed to match the standard '[object ClassName]'
|
|
842
|
-
return toString.call(val);
|
|
843
|
-
}
|
|
844
|
-
if (className == 'Object') {
|
|
845
|
-
// we're a user defined class or Object
|
|
846
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
847
|
-
// easier than looping through ownProperties of `val`.
|
|
848
|
-
try {
|
|
849
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
850
|
-
} catch (_) {
|
|
851
|
-
return 'Object';
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
// errors
|
|
855
|
-
if (val instanceof Error) {
|
|
856
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
857
|
-
}
|
|
858
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
859
|
-
return className;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
863
|
-
ptr = ptr >>> 0;
|
|
864
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
let cachedDataViewMemory0 = null;
|
|
868
|
-
function getDataViewMemory0() {
|
|
869
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
870
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
871
|
-
}
|
|
872
|
-
return cachedDataViewMemory0;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
function getStringFromWasm0(ptr, len) {
|
|
876
|
-
ptr = ptr >>> 0;
|
|
877
|
-
return decodeText(ptr, len);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
let cachedUint8ArrayMemory0 = null;
|
|
881
|
-
function getUint8ArrayMemory0() {
|
|
882
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
883
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
884
|
-
}
|
|
885
|
-
return cachedUint8ArrayMemory0;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
function handleError(f, args) {
|
|
889
|
-
try {
|
|
890
|
-
return f.apply(this, args);
|
|
891
|
-
} catch (e) {
|
|
892
|
-
const idx = addToExternrefTable0(e);
|
|
893
|
-
wasm.__wbindgen_exn_store(idx);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
function isLikeNone(x) {
|
|
898
|
-
return x === undefined || x === null;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
902
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
903
|
-
for (let i = 0; i < array.length; i++) {
|
|
904
|
-
const add = addToExternrefTable0(array[i]);
|
|
905
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
906
|
-
}
|
|
907
|
-
WASM_VECTOR_LEN = array.length;
|
|
908
|
-
return ptr;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
912
|
-
if (realloc === undefined) {
|
|
913
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
914
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
915
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
916
|
-
WASM_VECTOR_LEN = buf.length;
|
|
917
|
-
return ptr;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
let len = arg.length;
|
|
921
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
922
|
-
|
|
923
|
-
const mem = getUint8ArrayMemory0();
|
|
924
|
-
|
|
925
|
-
let offset = 0;
|
|
926
|
-
|
|
927
|
-
for (; offset < len; offset++) {
|
|
928
|
-
const code = arg.charCodeAt(offset);
|
|
929
|
-
if (code > 0x7F) break;
|
|
930
|
-
mem[ptr + offset] = code;
|
|
931
|
-
}
|
|
932
|
-
if (offset !== len) {
|
|
933
|
-
if (offset !== 0) {
|
|
934
|
-
arg = arg.slice(offset);
|
|
935
|
-
}
|
|
936
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
937
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
938
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
939
|
-
|
|
940
|
-
offset += ret.written;
|
|
941
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
WASM_VECTOR_LEN = offset;
|
|
945
|
-
return ptr;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
function takeFromExternrefTable0(idx) {
|
|
949
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
950
|
-
wasm.__externref_table_dealloc(idx);
|
|
951
|
-
return value;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
955
|
-
cachedTextDecoder.decode();
|
|
956
|
-
function decodeText(ptr, len) {
|
|
957
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
const cachedTextEncoder = new TextEncoder();
|
|
961
|
-
|
|
962
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
963
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
964
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
965
|
-
view.set(buf);
|
|
966
|
-
return {
|
|
967
|
-
read: arg.length,
|
|
968
|
-
written: buf.length
|
|
969
|
-
};
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
let WASM_VECTOR_LEN = 0;
|
|
974
|
-
|
|
975
|
-
const wasmPath = `${__dirname}/hypen_engine_bg.wasm`;
|
|
976
|
-
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
977
|
-
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
978
|
-
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
979
|
-
wasm.__wbindgen_start();
|