@hypen-space/core 0.4.31 → 0.4.35
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/app.d.ts +73 -2
- package/dist/app.js +112 -9
- package/dist/app.js.map +6 -5
- package/dist/components/builtin.js +112 -9
- package/dist/components/builtin.js.map +6 -5
- package/dist/context.d.ts +8 -0
- package/dist/context.js +6 -2
- package/dist/context.js.map +3 -3
- package/dist/datasource.d.ts +168 -0
- package/dist/discovery.js +114 -9
- package/dist/discovery.js.map +7 -6
- package/dist/disposable.js +6 -2
- package/dist/disposable.js.map +2 -2
- package/dist/engine.browser.d.ts +15 -0
- package/dist/engine.browser.js +19 -2
- package/dist/engine.browser.js.map +3 -3
- package/dist/engine.d.ts +22 -0
- package/dist/engine.js +37 -3
- package/dist/engine.js.map +3 -3
- package/dist/events.js +6 -2
- package/dist/events.js.map +2 -2
- package/dist/index.browser.js +295 -179
- package/dist/index.browser.js.map +9 -8
- package/dist/index.d.ts +3 -1
- package/dist/index.js +298 -179
- package/dist/index.js.map +10 -9
- package/dist/loader.js +6 -2
- package/dist/loader.js.map +2 -2
- package/dist/logger.js +6 -2
- package/dist/logger.js.map +2 -2
- package/dist/plugin.js +6 -2
- package/dist/plugin.js.map +2 -2
- package/dist/remote/client.js +6 -2
- package/dist/remote/client.js.map +2 -2
- package/dist/remote/index.js +152 -11
- package/dist/remote/index.js.map +9 -8
- package/dist/remote/server.js +152 -11
- package/dist/remote/server.js.map +9 -8
- package/dist/renderer.js +6 -2
- package/dist/renderer.js.map +2 -2
- package/dist/resolver.js +6 -2
- package/dist/resolver.js.map +2 -2
- package/dist/router.d.ts +9 -0
- package/dist/router.js +186 -18
- package/dist/router.js.map +6 -5
- package/dist/state.js +13 -6
- package/dist/state.js.map +3 -3
- package/package.json +1 -1
- package/src/app.ts +121 -4
- package/src/context.ts +10 -2
- package/src/datasource.ts +252 -0
- package/src/discovery.ts +2 -0
- package/src/engine.browser.ts +30 -0
- package/src/engine.ts +56 -1
- package/src/index.ts +16 -0
- package/src/managed-router.ts +3 -0
- package/src/remote/server.ts +11 -2
- package/src/router.ts +36 -10
- package/src/state.ts +10 -3
- package/wasm-browser/README.md +10 -10
- package/wasm-browser/hypen_engine.d.ts +368 -131
- package/wasm-browser/hypen_engine.js +896 -645
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-browser/hypen_engine_bg.wasm.d.ts +20 -13
- package/wasm-browser/package.json +1 -1
- package/wasm-node/README.md +10 -10
- package/wasm-node/hypen_engine.d.ts +318 -89
- package/wasm-node/hypen_engine.js +832 -613
- package/wasm-node/hypen_engine_bg.wasm +0 -0
- package/wasm-node/hypen_engine_bg.wasm.d.ts +20 -13
- package/wasm-node/package.json +1 -1
|
@@ -1,122 +1,795 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./hypen_engine.d.ts" */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
export class WasmEngine {
|
|
59
|
+
__destroy_into_raw() {
|
|
60
|
+
const ptr = this.__wbg_ptr;
|
|
61
|
+
this.__wbg_ptr = 0;
|
|
62
|
+
WasmEngineFinalization.unregister(this);
|
|
63
|
+
return ptr;
|
|
8
64
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
24
461
|
}
|
|
25
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
462
|
}
|
|
463
|
+
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
27
464
|
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
return decodeText(ptr, len);
|
|
465
|
+
export function main() {
|
|
466
|
+
wasm.main();
|
|
31
467
|
}
|
|
32
468
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
469
|
+
/**
|
|
470
|
+
* Parse Hypen DSL source and return the AST as a pretty-printed JSON string.
|
|
471
|
+
*
|
|
472
|
+
* Useful for tooling, syntax highlighting, and debugging the parser output.
|
|
473
|
+
* @param {string} source
|
|
474
|
+
* @returns {string}
|
|
475
|
+
*/
|
|
476
|
+
export function parseToJson(source) {
|
|
477
|
+
let deferred3_0;
|
|
478
|
+
let deferred3_1;
|
|
479
|
+
try {
|
|
480
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
481
|
+
const len0 = WASM_VECTOR_LEN;
|
|
482
|
+
const ret = wasm.parseToJson(ptr0, len0);
|
|
483
|
+
var ptr2 = ret[0];
|
|
484
|
+
var len2 = ret[1];
|
|
485
|
+
if (ret[3]) {
|
|
486
|
+
ptr2 = 0; len2 = 0;
|
|
487
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
488
|
+
}
|
|
489
|
+
deferred3_0 = ptr2;
|
|
490
|
+
deferred3_1 = len2;
|
|
491
|
+
return getStringFromWasm0(ptr2, len2);
|
|
492
|
+
} finally {
|
|
493
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
45
494
|
}
|
|
46
495
|
}
|
|
47
496
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const code = arg.charCodeAt(offset);
|
|
67
|
-
if (code > 0x7F) break;
|
|
68
|
-
mem[ptr + offset] = code;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (offset !== len) {
|
|
72
|
-
if (offset !== 0) {
|
|
73
|
-
arg = arg.slice(offset);
|
|
497
|
+
/**
|
|
498
|
+
* Serialize a patches array to a pretty-printed JSON string.
|
|
499
|
+
*
|
|
500
|
+
* Intended for debugging and logging — not for production use.
|
|
501
|
+
* Accepts a JS array of patch objects and returns formatted JSON.
|
|
502
|
+
* @param {any} patches
|
|
503
|
+
* @returns {string}
|
|
504
|
+
*/
|
|
505
|
+
export function patchesToJson(patches) {
|
|
506
|
+
let deferred2_0;
|
|
507
|
+
let deferred2_1;
|
|
508
|
+
try {
|
|
509
|
+
const ret = wasm.patchesToJson(patches);
|
|
510
|
+
var ptr1 = ret[0];
|
|
511
|
+
var len1 = ret[1];
|
|
512
|
+
if (ret[3]) {
|
|
513
|
+
ptr1 = 0; len1 = 0;
|
|
514
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
74
515
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
WASM_VECTOR_LEN = offset;
|
|
84
|
-
return ptr;
|
|
516
|
+
deferred2_0 = ptr1;
|
|
517
|
+
deferred2_1 = len1;
|
|
518
|
+
return getStringFromWasm0(ptr1, len1);
|
|
519
|
+
} finally {
|
|
520
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
521
|
+
}
|
|
85
522
|
}
|
|
86
523
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
524
|
+
function __wbg_get_imports() {
|
|
525
|
+
const import0 = {
|
|
526
|
+
__proto__: null,
|
|
527
|
+
__wbg_Error_ecbf49c1b9d07c30: function(arg0, arg1) {
|
|
528
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
529
|
+
return ret;
|
|
530
|
+
},
|
|
531
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
532
|
+
const ret = String(arg1);
|
|
533
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
534
|
+
const len1 = WASM_VECTOR_LEN;
|
|
535
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
536
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
537
|
+
},
|
|
538
|
+
__wbg___wbindgen_bigint_get_as_i64_a4925bc53b16f3d6: function(arg0, arg1) {
|
|
539
|
+
const v = arg1;
|
|
540
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
541
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
542
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
543
|
+
},
|
|
544
|
+
__wbg___wbindgen_boolean_get_4a348b369b009243: function(arg0) {
|
|
545
|
+
const v = arg0;
|
|
546
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
547
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
548
|
+
},
|
|
549
|
+
__wbg___wbindgen_debug_string_43c7ccb034739216: function(arg0, arg1) {
|
|
550
|
+
const ret = debugString(arg1);
|
|
551
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
552
|
+
const len1 = WASM_VECTOR_LEN;
|
|
553
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
554
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
555
|
+
},
|
|
556
|
+
__wbg___wbindgen_in_035107858ad0083e: function(arg0, arg1) {
|
|
557
|
+
const ret = arg0 in arg1;
|
|
558
|
+
return ret;
|
|
559
|
+
},
|
|
560
|
+
__wbg___wbindgen_is_bigint_15e2d080220c7748: function(arg0) {
|
|
561
|
+
const ret = typeof(arg0) === 'bigint';
|
|
562
|
+
return ret;
|
|
563
|
+
},
|
|
564
|
+
__wbg___wbindgen_is_function_18bea6e84080c016: function(arg0) {
|
|
565
|
+
const ret = typeof(arg0) === 'function';
|
|
566
|
+
return ret;
|
|
567
|
+
},
|
|
568
|
+
__wbg___wbindgen_is_null_c5f5bb76436a9ab1: function(arg0) {
|
|
569
|
+
const ret = arg0 === null;
|
|
570
|
+
return ret;
|
|
571
|
+
},
|
|
572
|
+
__wbg___wbindgen_is_object_8d3fac158b36498d: function(arg0) {
|
|
573
|
+
const val = arg0;
|
|
574
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
575
|
+
return ret;
|
|
576
|
+
},
|
|
577
|
+
__wbg___wbindgen_is_string_4d5f2c5b2acf65b0: function(arg0) {
|
|
578
|
+
const ret = typeof(arg0) === 'string';
|
|
579
|
+
return ret;
|
|
580
|
+
},
|
|
581
|
+
__wbg___wbindgen_is_undefined_4a711ea9d2e1ef93: function(arg0) {
|
|
582
|
+
const ret = arg0 === undefined;
|
|
583
|
+
return ret;
|
|
584
|
+
},
|
|
585
|
+
__wbg___wbindgen_jsval_eq_65f99081d9ee8f4d: function(arg0, arg1) {
|
|
586
|
+
const ret = arg0 === arg1;
|
|
587
|
+
return ret;
|
|
588
|
+
},
|
|
589
|
+
__wbg___wbindgen_jsval_loose_eq_1a2067dfb025b5ec: function(arg0, arg1) {
|
|
590
|
+
const ret = arg0 == arg1;
|
|
591
|
+
return ret;
|
|
592
|
+
},
|
|
593
|
+
__wbg___wbindgen_number_get_eed4462ef92e1bed: function(arg0, arg1) {
|
|
594
|
+
const obj = arg1;
|
|
595
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
596
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
597
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
598
|
+
},
|
|
599
|
+
__wbg___wbindgen_string_get_d09f733449cbf7a2: function(arg0, arg1) {
|
|
600
|
+
const obj = arg1;
|
|
601
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
602
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
603
|
+
var len1 = WASM_VECTOR_LEN;
|
|
604
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
605
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
606
|
+
},
|
|
607
|
+
__wbg___wbindgen_throw_df03e93053e0f4bc: function(arg0, arg1) {
|
|
608
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
609
|
+
},
|
|
610
|
+
__wbg_call_2989817bf2a245b5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
611
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
612
|
+
return ret;
|
|
613
|
+
}, arguments); },
|
|
614
|
+
__wbg_call_85e5437fa1ab109d: function() { return handleError(function (arg0, arg1, arg2) {
|
|
615
|
+
const ret = arg0.call(arg1, arg2);
|
|
616
|
+
return ret;
|
|
617
|
+
}, arguments); },
|
|
618
|
+
__wbg_call_df7a43aecab856a8: function() { return handleError(function (arg0, arg1) {
|
|
619
|
+
const ret = arg0.call(arg1);
|
|
620
|
+
return ret;
|
|
621
|
+
}, arguments); },
|
|
622
|
+
__wbg_done_0ad70482cae88a68: function(arg0) {
|
|
623
|
+
const ret = arg0.done;
|
|
624
|
+
return ret;
|
|
625
|
+
},
|
|
626
|
+
__wbg_entries_d58050057c0390ac: function(arg0) {
|
|
627
|
+
const ret = Object.entries(arg0);
|
|
628
|
+
return ret;
|
|
629
|
+
},
|
|
630
|
+
__wbg_error_51679600615c775d: function(arg0) {
|
|
631
|
+
console.error(arg0);
|
|
632
|
+
},
|
|
633
|
+
__wbg_get_6f5cf69c8f3f094a: function() { return handleError(function (arg0, arg1) {
|
|
634
|
+
const ret = Reflect.get(arg0, arg1);
|
|
635
|
+
return ret;
|
|
636
|
+
}, arguments); },
|
|
637
|
+
__wbg_get_c40e2c3262995a8e: function(arg0, arg1) {
|
|
638
|
+
const ret = arg0[arg1 >>> 0];
|
|
639
|
+
return ret;
|
|
640
|
+
},
|
|
641
|
+
__wbg_get_d0e1306db90b68d9: function() { return handleError(function (arg0, arg1) {
|
|
642
|
+
const ret = Reflect.get(arg0, arg1);
|
|
643
|
+
return ret;
|
|
644
|
+
}, arguments); },
|
|
645
|
+
__wbg_get_unchecked_3de5bfaaea65f86b: function(arg0, arg1) {
|
|
646
|
+
const ret = arg0[arg1 >>> 0];
|
|
647
|
+
return ret;
|
|
648
|
+
},
|
|
649
|
+
__wbg_instanceof_ArrayBuffer_d8e4e51f1cf7287a: function(arg0) {
|
|
650
|
+
let result;
|
|
651
|
+
try {
|
|
652
|
+
result = arg0 instanceof ArrayBuffer;
|
|
653
|
+
} catch (_) {
|
|
654
|
+
result = false;
|
|
655
|
+
}
|
|
656
|
+
const ret = result;
|
|
657
|
+
return ret;
|
|
658
|
+
},
|
|
659
|
+
__wbg_instanceof_Map_53b6790994271123: function(arg0) {
|
|
660
|
+
let result;
|
|
661
|
+
try {
|
|
662
|
+
result = arg0 instanceof Map;
|
|
663
|
+
} catch (_) {
|
|
664
|
+
result = false;
|
|
665
|
+
}
|
|
666
|
+
const ret = result;
|
|
667
|
+
return ret;
|
|
668
|
+
},
|
|
669
|
+
__wbg_instanceof_Uint8Array_6e48d83da6091cc8: function(arg0) {
|
|
670
|
+
let result;
|
|
671
|
+
try {
|
|
672
|
+
result = arg0 instanceof Uint8Array;
|
|
673
|
+
} catch (_) {
|
|
674
|
+
result = false;
|
|
675
|
+
}
|
|
676
|
+
const ret = result;
|
|
677
|
+
return ret;
|
|
678
|
+
},
|
|
679
|
+
__wbg_isArray_2efa5973cef6ec32: function(arg0) {
|
|
680
|
+
const ret = Array.isArray(arg0);
|
|
681
|
+
return ret;
|
|
682
|
+
},
|
|
683
|
+
__wbg_isSafeInteger_6709fb28be12d738: function(arg0) {
|
|
684
|
+
const ret = Number.isSafeInteger(arg0);
|
|
685
|
+
return ret;
|
|
686
|
+
},
|
|
687
|
+
__wbg_iterator_e77d2b7575cca5a7: function() {
|
|
688
|
+
const ret = Symbol.iterator;
|
|
689
|
+
return ret;
|
|
690
|
+
},
|
|
691
|
+
__wbg_length_00dd7227fd4626ad: function(arg0) {
|
|
692
|
+
const ret = arg0.length;
|
|
693
|
+
return ret;
|
|
694
|
+
},
|
|
695
|
+
__wbg_length_5e07cf181b2745fb: function(arg0) {
|
|
696
|
+
const ret = arg0.length;
|
|
697
|
+
return ret;
|
|
698
|
+
},
|
|
699
|
+
__wbg_log_91f1dd1dfd5a4ae8: function(arg0) {
|
|
700
|
+
console.log(arg0);
|
|
701
|
+
},
|
|
702
|
+
__wbg_new_62f131e968c83d75: function() {
|
|
703
|
+
const ret = new Object();
|
|
704
|
+
return ret;
|
|
705
|
+
},
|
|
706
|
+
__wbg_new_66075f8c2ea6575e: function() {
|
|
707
|
+
const ret = new Array();
|
|
708
|
+
return ret;
|
|
709
|
+
},
|
|
710
|
+
__wbg_new_74eb411a4d7bd3f1: function() {
|
|
711
|
+
const ret = new Map();
|
|
712
|
+
return ret;
|
|
713
|
+
},
|
|
714
|
+
__wbg_new_a0479da6258a0d71: function(arg0) {
|
|
715
|
+
const ret = new Uint8Array(arg0);
|
|
716
|
+
return ret;
|
|
717
|
+
},
|
|
718
|
+
__wbg_next_5428439dfc1d0362: function() { return handleError(function (arg0) {
|
|
719
|
+
const ret = arg0.next();
|
|
720
|
+
return ret;
|
|
721
|
+
}, arguments); },
|
|
722
|
+
__wbg_next_d314789a105729f3: function(arg0) {
|
|
723
|
+
const ret = arg0.next;
|
|
724
|
+
return ret;
|
|
725
|
+
},
|
|
726
|
+
__wbg_prototypesetcall_d1a7133bc8d83aa9: function(arg0, arg1, arg2) {
|
|
727
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
728
|
+
},
|
|
729
|
+
__wbg_set_3ba5af57f57f831c: function(arg0, arg1, arg2) {
|
|
730
|
+
const ret = arg0.set(arg1, arg2);
|
|
731
|
+
return ret;
|
|
732
|
+
},
|
|
733
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
734
|
+
arg0[arg1] = arg2;
|
|
735
|
+
},
|
|
736
|
+
__wbg_set_7bf9e2df46e7632c: function(arg0, arg1, arg2) {
|
|
737
|
+
arg0[arg1 >>> 0] = arg2;
|
|
738
|
+
},
|
|
739
|
+
__wbg_set_8326741805409e83: function() { return handleError(function (arg0, arg1, arg2) {
|
|
740
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
741
|
+
return ret;
|
|
742
|
+
}, arguments); },
|
|
743
|
+
__wbg_value_414b42ce7b3eca22: function(arg0) {
|
|
744
|
+
const ret = arg0.value;
|
|
745
|
+
return ret;
|
|
746
|
+
},
|
|
747
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
748
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
749
|
+
const ret = arg0;
|
|
750
|
+
return ret;
|
|
751
|
+
},
|
|
752
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
753
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
754
|
+
const ret = arg0;
|
|
755
|
+
return ret;
|
|
756
|
+
},
|
|
757
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
758
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
759
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
760
|
+
return ret;
|
|
761
|
+
},
|
|
762
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
763
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
764
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
765
|
+
return ret;
|
|
766
|
+
},
|
|
767
|
+
__wbindgen_init_externref_table: function() {
|
|
768
|
+
const table = wasm.__wbindgen_externrefs;
|
|
769
|
+
const offset = table.grow(4);
|
|
770
|
+
table.set(0, undefined);
|
|
771
|
+
table.set(offset + 0, undefined);
|
|
772
|
+
table.set(offset + 1, null);
|
|
773
|
+
table.set(offset + 2, true);
|
|
774
|
+
table.set(offset + 3, false);
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
return {
|
|
778
|
+
__proto__: null,
|
|
779
|
+
"./hypen_engine_bg.js": import0,
|
|
780
|
+
};
|
|
94
781
|
}
|
|
95
782
|
|
|
783
|
+
const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
784
|
+
? { register: () => {}, unregister: () => {} }
|
|
785
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
786
|
+
|
|
96
787
|
function addToExternrefTable0(obj) {
|
|
97
788
|
const idx = wasm.__externref_table_alloc();
|
|
98
|
-
wasm.
|
|
789
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
99
790
|
return idx;
|
|
100
791
|
}
|
|
101
792
|
|
|
102
|
-
function handleError(f, args) {
|
|
103
|
-
try {
|
|
104
|
-
return f.apply(this, args);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
const idx = addToExternrefTable0(e);
|
|
107
|
-
wasm.__wbindgen_exn_store(idx);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
112
|
-
ptr = ptr >>> 0;
|
|
113
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function isLikeNone(x) {
|
|
117
|
-
return x === undefined || x === null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
793
|
function debugString(val) {
|
|
121
794
|
// primitive types
|
|
122
795
|
const type = typeof val;
|
|
@@ -182,591 +855,177 @@ function debugString(val) {
|
|
|
182
855
|
return className;
|
|
183
856
|
}
|
|
184
857
|
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return value;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
192
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
193
|
-
for (let i = 0; i < array.length; i++) {
|
|
194
|
-
const add = addToExternrefTable0(array[i]);
|
|
195
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
196
|
-
}
|
|
197
|
-
WASM_VECTOR_LEN = array.length;
|
|
198
|
-
return ptr;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Export patches as JSON string (for debugging)
|
|
202
|
-
* @param {any} patches
|
|
203
|
-
* @returns {string}
|
|
204
|
-
*/
|
|
205
|
-
export function patchesToJson(patches) {
|
|
206
|
-
let deferred2_0;
|
|
207
|
-
let deferred2_1;
|
|
208
|
-
try {
|
|
209
|
-
const ret = wasm.patchesToJson(patches);
|
|
210
|
-
var ptr1 = ret[0];
|
|
211
|
-
var len1 = ret[1];
|
|
212
|
-
if (ret[3]) {
|
|
213
|
-
ptr1 = 0; len1 = 0;
|
|
214
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
215
|
-
}
|
|
216
|
-
deferred2_0 = ptr1;
|
|
217
|
-
deferred2_1 = len1;
|
|
218
|
-
return getStringFromWasm0(ptr1, len1);
|
|
219
|
-
} finally {
|
|
220
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
221
|
-
}
|
|
858
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
859
|
+
ptr = ptr >>> 0;
|
|
860
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
222
861
|
}
|
|
223
862
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
*/
|
|
229
|
-
export function parseToJson(source) {
|
|
230
|
-
let deferred3_0;
|
|
231
|
-
let deferred3_1;
|
|
232
|
-
try {
|
|
233
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
-
const len0 = WASM_VECTOR_LEN;
|
|
235
|
-
const ret = wasm.parseToJson(ptr0, len0);
|
|
236
|
-
var ptr2 = ret[0];
|
|
237
|
-
var len2 = ret[1];
|
|
238
|
-
if (ret[3]) {
|
|
239
|
-
ptr2 = 0; len2 = 0;
|
|
240
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
241
|
-
}
|
|
242
|
-
deferred3_0 = ptr2;
|
|
243
|
-
deferred3_1 = len2;
|
|
244
|
-
return getStringFromWasm0(ptr2, len2);
|
|
245
|
-
} finally {
|
|
246
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
863
|
+
let cachedDataViewMemory0 = null;
|
|
864
|
+
function getDataViewMemory0() {
|
|
865
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
866
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
247
867
|
}
|
|
868
|
+
return cachedDataViewMemory0;
|
|
248
869
|
}
|
|
249
870
|
|
|
250
|
-
|
|
251
|
-
|
|
871
|
+
function getStringFromWasm0(ptr, len) {
|
|
872
|
+
ptr = ptr >>> 0;
|
|
873
|
+
return decodeText(ptr, len);
|
|
252
874
|
}
|
|
253
875
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
* WASM-exported engine instance for JavaScript runtimes
|
|
259
|
-
* Uses Rc<RefCell<>> instead of Send+Sync for WASM single-threaded environment
|
|
260
|
-
*/
|
|
261
|
-
export class WasmEngine {
|
|
262
|
-
|
|
263
|
-
__destroy_into_raw() {
|
|
264
|
-
const ptr = this.__wbg_ptr;
|
|
265
|
-
this.__wbg_ptr = 0;
|
|
266
|
-
WasmEngineFinalization.unregister(this);
|
|
267
|
-
return ptr;
|
|
876
|
+
let cachedUint8ArrayMemory0 = null;
|
|
877
|
+
function getUint8ArrayMemory0() {
|
|
878
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
879
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
268
880
|
}
|
|
881
|
+
return cachedUint8ArrayMemory0;
|
|
882
|
+
}
|
|
269
883
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
*/
|
|
277
|
-
constructor() {
|
|
278
|
-
const ret = wasm.wasmengine_new();
|
|
279
|
-
this.__wbg_ptr = ret >>> 0;
|
|
280
|
-
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
281
|
-
return this;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Parse and render Hypen DSL source code
|
|
285
|
-
* Supports documents with import statements - imports are resolved via the component resolver
|
|
286
|
-
* @param {string} source
|
|
287
|
-
*/
|
|
288
|
-
renderSource(source) {
|
|
289
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
290
|
-
const len0 = WASM_VECTOR_LEN;
|
|
291
|
-
const ret = wasm.wasmengine_renderSource(this.__wbg_ptr, ptr0, len0);
|
|
292
|
-
if (ret[1]) {
|
|
293
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Set the render callback that receives patches
|
|
298
|
-
* @param {Function} callback
|
|
299
|
-
*/
|
|
300
|
-
setRenderCallback(callback) {
|
|
301
|
-
wasm.wasmengine_setRenderCallback(this.__wbg_ptr, callback);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Set the component resolver callback
|
|
305
|
-
* The resolver receives (componentName, contextPath) and should return
|
|
306
|
-
* { source: string, path: string } or null
|
|
307
|
-
*
|
|
308
|
-
* contextPath is the path of the component that's referencing this component
|
|
309
|
-
* The returned path should be the resolved absolute path to the component file
|
|
310
|
-
* @param {Function} resolver
|
|
311
|
-
*/
|
|
312
|
-
setComponentResolver(resolver) {
|
|
313
|
-
wasm.wasmengine_setComponentResolver(this.__wbg_ptr, resolver);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Register a primitive element (like Text, Button, etc.) to skip component resolution
|
|
317
|
-
* This prevents unnecessary resolver calls for built-in DOM elements
|
|
318
|
-
* @param {string} name
|
|
319
|
-
*/
|
|
320
|
-
registerPrimitive(name) {
|
|
321
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
322
|
-
const len0 = WASM_VECTOR_LEN;
|
|
323
|
-
wasm.wasmengine_registerPrimitive(this.__wbg_ptr, ptr0, len0);
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Render a component source (for lazy loading routes)
|
|
327
|
-
* This allows rendering a component on-demand
|
|
328
|
-
* @param {string} source
|
|
329
|
-
*/
|
|
330
|
-
renderLazyComponent(source) {
|
|
331
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
332
|
-
const len0 = WASM_VECTOR_LEN;
|
|
333
|
-
const ret = wasm.wasmengine_renderLazyComponent(this.__wbg_ptr, ptr0, len0);
|
|
334
|
-
if (ret[1]) {
|
|
335
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Render a component into a specific parent node (subtree rendering)
|
|
340
|
-
* This is used for lazy routing where components are rendered on-demand into route containers
|
|
341
|
-
*
|
|
342
|
-
* # Arguments
|
|
343
|
-
* * `source` - The Hypen DSL source to parse and render
|
|
344
|
-
* * `parent_node_id_str` - The serialized node ID string of the parent element
|
|
345
|
-
* * `state_js` - The state to use for rendering (as JsValue)
|
|
346
|
-
* @param {string} source
|
|
347
|
-
* @param {string} parent_node_id_str
|
|
348
|
-
* @param {any} state_js
|
|
349
|
-
*/
|
|
350
|
-
renderInto(source, parent_node_id_str, state_js) {
|
|
351
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
352
|
-
const len0 = WASM_VECTOR_LEN;
|
|
353
|
-
const ptr1 = passStringToWasm0(parent_node_id_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
354
|
-
const len1 = WASM_VECTOR_LEN;
|
|
355
|
-
const ret = wasm.wasmengine_renderInto(this.__wbg_ptr, ptr0, len0, ptr1, len1, state_js);
|
|
356
|
-
if (ret[1]) {
|
|
357
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Update state from JavaScript
|
|
362
|
-
* @param {any} state_patch
|
|
363
|
-
*/
|
|
364
|
-
updateState(state_patch) {
|
|
365
|
-
const ret = wasm.wasmengine_updateState(this.__wbg_ptr, state_patch);
|
|
366
|
-
if (ret[1]) {
|
|
367
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Update state using sparse path-value pairs
|
|
372
|
-
* More efficient than updateState for large state objects when only a few paths changed
|
|
373
|
-
*
|
|
374
|
-
* # Arguments
|
|
375
|
-
* * `paths_js` - Array of changed paths (e.g., ["user.name", "count"])
|
|
376
|
-
* * `values_js` - Object mapping paths to their new values (e.g., { "user.name": "Bob", "count": 42 })
|
|
377
|
-
* @param {any} paths_js
|
|
378
|
-
* @param {any} values_js
|
|
379
|
-
*/
|
|
380
|
-
updateStateSparse(paths_js, values_js) {
|
|
381
|
-
const ret = wasm.wasmengine_updateStateSparse(this.__wbg_ptr, paths_js, values_js);
|
|
382
|
-
if (ret[1]) {
|
|
383
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Dispatch an action
|
|
388
|
-
* @param {string} name
|
|
389
|
-
* @param {any} payload
|
|
390
|
-
*/
|
|
391
|
-
dispatchAction(name, payload) {
|
|
392
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
-
const len0 = WASM_VECTOR_LEN;
|
|
394
|
-
const ret = wasm.wasmengine_dispatchAction(this.__wbg_ptr, ptr0, len0, payload);
|
|
395
|
-
if (ret[1]) {
|
|
396
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Register an action handler
|
|
401
|
-
* @param {string} action_name
|
|
402
|
-
* @param {Function} handler
|
|
403
|
-
*/
|
|
404
|
-
onAction(action_name, handler) {
|
|
405
|
-
const ptr0 = passStringToWasm0(action_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
|
-
const len0 = WASM_VECTOR_LEN;
|
|
407
|
-
wasm.wasmengine_onAction(this.__wbg_ptr, ptr0, len0, handler);
|
|
884
|
+
function handleError(f, args) {
|
|
885
|
+
try {
|
|
886
|
+
return f.apply(this, args);
|
|
887
|
+
} catch (e) {
|
|
888
|
+
const idx = addToExternrefTable0(e);
|
|
889
|
+
wasm.__wbindgen_exn_store(idx);
|
|
408
890
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
function isLikeNone(x) {
|
|
894
|
+
return x === undefined || x === null;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
898
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
899
|
+
for (let i = 0; i < array.length; i++) {
|
|
900
|
+
const add = addToExternrefTable0(array[i]);
|
|
901
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
414
902
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const ret = wasm.wasmengine_debugParseComponent(this.__wbg_ptr, ptr0, len0);
|
|
427
|
-
var ptr2 = ret[0];
|
|
428
|
-
var len2 = ret[1];
|
|
429
|
-
if (ret[3]) {
|
|
430
|
-
ptr2 = 0; len2 = 0;
|
|
431
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
432
|
-
}
|
|
433
|
-
deferred3_0 = ptr2;
|
|
434
|
-
deferred3_1 = len2;
|
|
435
|
-
return getStringFromWasm0(ptr2, len2);
|
|
436
|
-
} finally {
|
|
437
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
438
|
-
}
|
|
903
|
+
WASM_VECTOR_LEN = array.length;
|
|
904
|
+
return ptr;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
908
|
+
if (realloc === undefined) {
|
|
909
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
910
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
911
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
912
|
+
WASM_VECTOR_LEN = buf.length;
|
|
913
|
+
return ptr;
|
|
439
914
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
915
|
+
|
|
916
|
+
let len = arg.length;
|
|
917
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
918
|
+
|
|
919
|
+
const mem = getUint8ArrayMemory0();
|
|
920
|
+
|
|
921
|
+
let offset = 0;
|
|
922
|
+
|
|
923
|
+
for (; offset < len; offset++) {
|
|
924
|
+
const code = arg.charCodeAt(offset);
|
|
925
|
+
if (code > 0x7F) break;
|
|
926
|
+
mem[ptr + offset] = code;
|
|
927
|
+
}
|
|
928
|
+
if (offset !== len) {
|
|
929
|
+
if (offset !== 0) {
|
|
930
|
+
arg = arg.slice(offset);
|
|
457
931
|
}
|
|
932
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
933
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
934
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
935
|
+
|
|
936
|
+
offset += ret.written;
|
|
937
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
458
938
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
939
|
+
|
|
940
|
+
WASM_VECTOR_LEN = offset;
|
|
941
|
+
return ptr;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function takeFromExternrefTable0(idx) {
|
|
945
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
946
|
+
wasm.__externref_table_dealloc(idx);
|
|
947
|
+
return value;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
951
|
+
cachedTextDecoder.decode();
|
|
952
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
953
|
+
let numBytesDecoded = 0;
|
|
954
|
+
function decodeText(ptr, len) {
|
|
955
|
+
numBytesDecoded += len;
|
|
956
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
957
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
958
|
+
cachedTextDecoder.decode();
|
|
959
|
+
numBytesDecoded = len;
|
|
466
960
|
}
|
|
961
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
467
962
|
}
|
|
468
|
-
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
469
963
|
|
|
470
|
-
const
|
|
964
|
+
const cachedTextEncoder = new TextEncoder();
|
|
965
|
+
|
|
966
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
967
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
968
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
969
|
+
view.set(buf);
|
|
970
|
+
return {
|
|
971
|
+
read: arg.length,
|
|
972
|
+
written: buf.length
|
|
973
|
+
};
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
let WASM_VECTOR_LEN = 0;
|
|
978
|
+
|
|
979
|
+
let wasmModule, wasm;
|
|
980
|
+
function __wbg_finalize_init(instance, module) {
|
|
981
|
+
wasm = instance.exports;
|
|
982
|
+
wasmModule = module;
|
|
983
|
+
cachedDataViewMemory0 = null;
|
|
984
|
+
cachedUint8ArrayMemory0 = null;
|
|
985
|
+
wasm.__wbindgen_start();
|
|
986
|
+
return wasm;
|
|
987
|
+
}
|
|
471
988
|
|
|
472
989
|
async function __wbg_load(module, imports) {
|
|
473
990
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
474
991
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
475
992
|
try {
|
|
476
993
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
477
|
-
|
|
478
994
|
} catch (e) {
|
|
479
|
-
const validResponse = module.ok &&
|
|
995
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
480
996
|
|
|
481
997
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
482
998
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
483
999
|
|
|
484
|
-
} else {
|
|
485
|
-
throw e;
|
|
486
|
-
}
|
|
1000
|
+
} else { throw e; }
|
|
487
1001
|
}
|
|
488
1002
|
}
|
|
489
1003
|
|
|
490
1004
|
const bytes = await module.arrayBuffer();
|
|
491
1005
|
return await WebAssembly.instantiate(bytes, imports);
|
|
492
|
-
|
|
493
1006
|
} else {
|
|
494
1007
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
495
1008
|
|
|
496
1009
|
if (instance instanceof WebAssembly.Instance) {
|
|
497
1010
|
return { instance, module };
|
|
498
|
-
|
|
499
1011
|
} else {
|
|
500
1012
|
return instance;
|
|
501
1013
|
}
|
|
502
1014
|
}
|
|
503
|
-
}
|
|
504
1015
|
|
|
505
|
-
function
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
509
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
510
|
-
return ret;
|
|
511
|
-
};
|
|
512
|
-
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
513
|
-
const ret = String(arg1);
|
|
514
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
515
|
-
const len1 = WASM_VECTOR_LEN;
|
|
516
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
517
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
518
|
-
};
|
|
519
|
-
imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
|
|
520
|
-
const ret = arg0.call(arg1);
|
|
521
|
-
return ret;
|
|
522
|
-
}, arguments) };
|
|
523
|
-
imports.wbg.__wbg_call_641db1bb5db5a579 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
524
|
-
const ret = arg0.call(arg1, arg2, arg3);
|
|
525
|
-
return ret;
|
|
526
|
-
}, arguments) };
|
|
527
|
-
imports.wbg.__wbg_call_a5400b25a865cfd8 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
528
|
-
const ret = arg0.call(arg1, arg2);
|
|
529
|
-
return ret;
|
|
530
|
-
}, arguments) };
|
|
531
|
-
imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
|
|
532
|
-
const ret = arg0.done;
|
|
533
|
-
return ret;
|
|
534
|
-
};
|
|
535
|
-
imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
|
|
536
|
-
const ret = Object.entries(arg0);
|
|
537
|
-
return ret;
|
|
538
|
-
};
|
|
539
|
-
imports.wbg.__wbg_error_99981e16d476aa5c = function(arg0) {
|
|
540
|
-
console.error(arg0);
|
|
541
|
-
};
|
|
542
|
-
imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
|
|
543
|
-
const ret = arg0[arg1 >>> 0];
|
|
544
|
-
return ret;
|
|
545
|
-
};
|
|
546
|
-
imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
|
|
547
|
-
const ret = Reflect.get(arg0, arg1);
|
|
548
|
-
return ret;
|
|
549
|
-
}, arguments) };
|
|
550
|
-
imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
|
|
551
|
-
let result;
|
|
552
|
-
try {
|
|
553
|
-
result = arg0 instanceof ArrayBuffer;
|
|
554
|
-
} catch (_) {
|
|
555
|
-
result = false;
|
|
556
|
-
}
|
|
557
|
-
const ret = result;
|
|
558
|
-
return ret;
|
|
559
|
-
};
|
|
560
|
-
imports.wbg.__wbg_instanceof_Map_ebb01a5b6b5ffd0b = function(arg0) {
|
|
561
|
-
let result;
|
|
562
|
-
try {
|
|
563
|
-
result = arg0 instanceof Map;
|
|
564
|
-
} catch (_) {
|
|
565
|
-
result = false;
|
|
566
|
-
}
|
|
567
|
-
const ret = result;
|
|
568
|
-
return ret;
|
|
569
|
-
};
|
|
570
|
-
imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
|
|
571
|
-
let result;
|
|
572
|
-
try {
|
|
573
|
-
result = arg0 instanceof Uint8Array;
|
|
574
|
-
} catch (_) {
|
|
575
|
-
result = false;
|
|
1016
|
+
function expectedResponseType(type) {
|
|
1017
|
+
switch (type) {
|
|
1018
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
576
1019
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
};
|
|
580
|
-
imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
|
|
581
|
-
const ret = Array.isArray(arg0);
|
|
582
|
-
return ret;
|
|
583
|
-
};
|
|
584
|
-
imports.wbg.__wbg_isSafeInteger_1c0d1af5542e102a = function(arg0) {
|
|
585
|
-
const ret = Number.isSafeInteger(arg0);
|
|
586
|
-
return ret;
|
|
587
|
-
};
|
|
588
|
-
imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
|
|
589
|
-
const ret = Symbol.iterator;
|
|
590
|
-
return ret;
|
|
591
|
-
};
|
|
592
|
-
imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
|
|
593
|
-
const ret = arg0.length;
|
|
594
|
-
return ret;
|
|
595
|
-
};
|
|
596
|
-
imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
597
|
-
const ret = arg0.length;
|
|
598
|
-
return ret;
|
|
599
|
-
};
|
|
600
|
-
imports.wbg.__wbg_log_6c7b5f4f00b8ce3f = function(arg0) {
|
|
601
|
-
console.log(arg0);
|
|
602
|
-
};
|
|
603
|
-
imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
|
|
604
|
-
const ret = new Object();
|
|
605
|
-
return ret;
|
|
606
|
-
};
|
|
607
|
-
imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
|
|
608
|
-
const ret = new Array();
|
|
609
|
-
return ret;
|
|
610
|
-
};
|
|
611
|
-
imports.wbg.__wbg_new_2ff1f68f3676ea53 = function() {
|
|
612
|
-
const ret = new Map();
|
|
613
|
-
return ret;
|
|
614
|
-
};
|
|
615
|
-
imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
616
|
-
const ret = new Uint8Array(arg0);
|
|
617
|
-
return ret;
|
|
618
|
-
};
|
|
619
|
-
imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
|
|
620
|
-
const ret = arg0.next;
|
|
621
|
-
return ret;
|
|
622
|
-
};
|
|
623
|
-
imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
|
|
624
|
-
const ret = arg0.next();
|
|
625
|
-
return ret;
|
|
626
|
-
}, arguments) };
|
|
627
|
-
imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
628
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
629
|
-
};
|
|
630
|
-
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
631
|
-
arg0[arg1] = arg2;
|
|
632
|
-
};
|
|
633
|
-
imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
|
|
634
|
-
arg0[arg1 >>> 0] = arg2;
|
|
635
|
-
};
|
|
636
|
-
imports.wbg.__wbg_set_b7f1cf4fae26fe2a = function(arg0, arg1, arg2) {
|
|
637
|
-
const ret = arg0.set(arg1, arg2);
|
|
638
|
-
return ret;
|
|
639
|
-
};
|
|
640
|
-
imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
|
|
641
|
-
const ret = arg0.value;
|
|
642
|
-
return ret;
|
|
643
|
-
};
|
|
644
|
-
imports.wbg.__wbg_wbindgenbigintgetasi64_ac743ece6ab9bba1 = function(arg0, arg1) {
|
|
645
|
-
const v = arg1;
|
|
646
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
647
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
648
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
649
|
-
};
|
|
650
|
-
imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
|
|
651
|
-
const v = arg0;
|
|
652
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
653
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
654
|
-
};
|
|
655
|
-
imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
|
|
656
|
-
const ret = debugString(arg1);
|
|
657
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
658
|
-
const len1 = WASM_VECTOR_LEN;
|
|
659
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
660
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
661
|
-
};
|
|
662
|
-
imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
|
|
663
|
-
const ret = arg0 in arg1;
|
|
664
|
-
return ret;
|
|
665
|
-
};
|
|
666
|
-
imports.wbg.__wbg_wbindgenisbigint_ecb90cc08a5a9154 = function(arg0) {
|
|
667
|
-
const ret = typeof(arg0) === 'bigint';
|
|
668
|
-
return ret;
|
|
669
|
-
};
|
|
670
|
-
imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
|
|
671
|
-
const ret = typeof(arg0) === 'function';
|
|
672
|
-
return ret;
|
|
673
|
-
};
|
|
674
|
-
imports.wbg.__wbg_wbindgenisnull_f3037694abe4d97a = function(arg0) {
|
|
675
|
-
const ret = arg0 === null;
|
|
676
|
-
return ret;
|
|
677
|
-
};
|
|
678
|
-
imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
679
|
-
const val = arg0;
|
|
680
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
681
|
-
return ret;
|
|
682
|
-
};
|
|
683
|
-
imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
|
|
684
|
-
const ret = typeof(arg0) === 'string';
|
|
685
|
-
return ret;
|
|
686
|
-
};
|
|
687
|
-
imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
688
|
-
const ret = arg0 === undefined;
|
|
689
|
-
return ret;
|
|
690
|
-
};
|
|
691
|
-
imports.wbg.__wbg_wbindgenjsvaleq_e6f2ad59ccae1b58 = function(arg0, arg1) {
|
|
692
|
-
const ret = arg0 === arg1;
|
|
693
|
-
return ret;
|
|
694
|
-
};
|
|
695
|
-
imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
|
|
696
|
-
const ret = arg0 == arg1;
|
|
697
|
-
return ret;
|
|
698
|
-
};
|
|
699
|
-
imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
700
|
-
const obj = arg1;
|
|
701
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
702
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
703
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
704
|
-
};
|
|
705
|
-
imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
706
|
-
const obj = arg1;
|
|
707
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
708
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
709
|
-
var len1 = WASM_VECTOR_LEN;
|
|
710
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
711
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
712
|
-
};
|
|
713
|
-
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
714
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
715
|
-
};
|
|
716
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
717
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
718
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
719
|
-
return ret;
|
|
720
|
-
};
|
|
721
|
-
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
722
|
-
// Cast intrinsic for `U64 -> Externref`.
|
|
723
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
724
|
-
return ret;
|
|
725
|
-
};
|
|
726
|
-
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
727
|
-
// Cast intrinsic for `I64 -> Externref`.
|
|
728
|
-
const ret = arg0;
|
|
729
|
-
return ret;
|
|
730
|
-
};
|
|
731
|
-
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
732
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
733
|
-
const ret = arg0;
|
|
734
|
-
return ret;
|
|
735
|
-
};
|
|
736
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
737
|
-
const table = wasm.__wbindgen_export_4;
|
|
738
|
-
const offset = table.grow(4);
|
|
739
|
-
table.set(0, undefined);
|
|
740
|
-
table.set(offset + 0, undefined);
|
|
741
|
-
table.set(offset + 1, null);
|
|
742
|
-
table.set(offset + 2, true);
|
|
743
|
-
table.set(offset + 3, false);
|
|
744
|
-
;
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
return imports;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
function __wbg_init_memory(imports, memory) {
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
function __wbg_finalize_init(instance, module) {
|
|
755
|
-
wasm = instance.exports;
|
|
756
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
757
|
-
cachedDataViewMemory0 = null;
|
|
758
|
-
cachedUint8ArrayMemory0 = null;
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
wasm.__wbindgen_start();
|
|
762
|
-
return wasm;
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
763
1022
|
}
|
|
764
1023
|
|
|
765
1024
|
function initSync(module) {
|
|
766
1025
|
if (wasm !== undefined) return wasm;
|
|
767
1026
|
|
|
768
1027
|
|
|
769
|
-
if (
|
|
1028
|
+
if (module !== undefined) {
|
|
770
1029
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
771
1030
|
({module} = module)
|
|
772
1031
|
} else {
|
|
@@ -775,15 +1034,10 @@ function initSync(module) {
|
|
|
775
1034
|
}
|
|
776
1035
|
|
|
777
1036
|
const imports = __wbg_get_imports();
|
|
778
|
-
|
|
779
|
-
__wbg_init_memory(imports);
|
|
780
|
-
|
|
781
1037
|
if (!(module instanceof WebAssembly.Module)) {
|
|
782
1038
|
module = new WebAssembly.Module(module);
|
|
783
1039
|
}
|
|
784
|
-
|
|
785
1040
|
const instance = new WebAssembly.Instance(module, imports);
|
|
786
|
-
|
|
787
1041
|
return __wbg_finalize_init(instance, module);
|
|
788
1042
|
}
|
|
789
1043
|
|
|
@@ -791,7 +1045,7 @@ async function __wbg_init(module_or_path) {
|
|
|
791
1045
|
if (wasm !== undefined) return wasm;
|
|
792
1046
|
|
|
793
1047
|
|
|
794
|
-
if (
|
|
1048
|
+
if (module_or_path !== undefined) {
|
|
795
1049
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
796
1050
|
({module_or_path} = module_or_path)
|
|
797
1051
|
} else {
|
|
@@ -799,7 +1053,7 @@ async function __wbg_init(module_or_path) {
|
|
|
799
1053
|
}
|
|
800
1054
|
}
|
|
801
1055
|
|
|
802
|
-
if (
|
|
1056
|
+
if (module_or_path === undefined) {
|
|
803
1057
|
module_or_path = new URL('hypen_engine_bg.wasm', import.meta.url);
|
|
804
1058
|
}
|
|
805
1059
|
const imports = __wbg_get_imports();
|
|
@@ -808,12 +1062,9 @@ async function __wbg_init(module_or_path) {
|
|
|
808
1062
|
module_or_path = fetch(module_or_path);
|
|
809
1063
|
}
|
|
810
1064
|
|
|
811
|
-
__wbg_init_memory(imports);
|
|
812
|
-
|
|
813
1065
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
814
1066
|
|
|
815
1067
|
return __wbg_finalize_init(instance, module);
|
|
816
1068
|
}
|
|
817
1069
|
|
|
818
|
-
export { initSync };
|
|
819
|
-
export default __wbg_init;
|
|
1070
|
+
export { initSync, __wbg_init as default };
|