@microsoft/webui 0.0.25 → 0.0.27

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.
Files changed (54) hide show
  1. package/README.md +74 -30
  2. package/bin/webui +0 -0
  3. package/dist/index.d.ts +115 -42
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +62 -42
  6. package/dist/index.js.map +1 -1
  7. package/dist/install.js.map +1 -1
  8. package/dist/platform.js.map +1 -1
  9. package/dist/projection/adapters/esbuild.d.ts.map +1 -1
  10. package/dist/projection/adapters/esbuild.js +33 -8
  11. package/dist/projection/adapters/esbuild.js.map +1 -1
  12. package/dist/projection/compiler.d.ts.map +1 -1
  13. package/dist/projection/compiler.js +51 -86
  14. package/dist/projection/compiler.js.map +1 -1
  15. package/dist/projection/concurrency.d.ts +8 -0
  16. package/dist/projection/concurrency.d.ts.map +1 -0
  17. package/dist/projection/concurrency.js +44 -0
  18. package/dist/projection/concurrency.js.map +1 -0
  19. package/dist/projection/diagnostics.d.ts.map +1 -1
  20. package/dist/projection/diagnostics.js.map +1 -1
  21. package/dist/projection/fixtures/conformance.d.ts +1 -1
  22. package/dist/projection/fixtures/conformance.js +1 -1
  23. package/dist/projection/fixtures/conformance.js.map +1 -1
  24. package/dist/projection/index.d.ts +1 -1
  25. package/dist/projection/loader.d.ts.map +1 -1
  26. package/dist/projection/loader.js +13 -1
  27. package/dist/projection/loader.js.map +1 -1
  28. package/dist/projection/typescript-api.d.ts +17 -0
  29. package/dist/projection/typescript-api.d.ts.map +1 -0
  30. package/dist/projection/typescript-api.js +185 -0
  31. package/dist/projection/typescript-api.js.map +1 -0
  32. package/dist/projection/typescript-version.d.ts +4 -0
  33. package/dist/projection/typescript-version.d.ts.map +1 -0
  34. package/dist/projection/typescript-version.js +76 -0
  35. package/dist/projection/typescript-version.js.map +1 -0
  36. package/package.json +10 -9
  37. package/wasm/all/README.md +37 -1
  38. package/wasm/all/package.json +1 -1
  39. package/wasm/all/webui_wasm_all.d.ts +34 -38
  40. package/wasm/all/webui_wasm_all.js +78 -97
  41. package/wasm/all/webui_wasm_all_bg.wasm +0 -0
  42. package/wasm/all/webui_wasm_all_bg.wasm.d.ts +4 -7
  43. package/wasm/handler/README.md +37 -1
  44. package/wasm/handler/package.json +1 -1
  45. package/wasm/handler/webui_wasm_handler.d.ts +29 -36
  46. package/wasm/handler/webui_wasm_handler.js +68 -93
  47. package/wasm/handler/webui_wasm_handler_bg.wasm +0 -0
  48. package/wasm/handler/webui_wasm_handler_bg.wasm.d.ts +3 -6
  49. package/wasm/parser/README.md +37 -1
  50. package/wasm/parser/package.json +1 -1
  51. package/wasm/parser/webui_wasm_parser.d.ts +5 -2
  52. package/wasm/parser/webui_wasm_parser.js +10 -4
  53. package/wasm/parser/webui_wasm_parser_bg.wasm +0 -0
  54. package/wasm/parser/webui_wasm_parser_bg.wasm.d.ts +1 -1
@@ -15,10 +15,46 @@ WebAssembly bindings for the [WebUI](https://github.com/microsoft/webui) framewo
15
15
  The default feature is `all`, which powers the online playground. Consumers that only need to render prebuilt protobuf protocol bytes should use the handler bundle to avoid shipping parser code.
16
16
 
17
17
  Construct `Protocol` once from protocol bytes. It exposes `render`,
18
- `renderStream`, `renderPartial`, `renderComponentTemplates`, and `tokens`.
18
+ `renderStream`, `renderPartial`, `renderComponentTemplates`, `tokens`, and
19
+ `streamResponse`.
19
20
  Streaming callbacks are coalesced around a 16 KiB target before crossing into
20
21
  JavaScript.
21
22
 
23
+ `Protocol.streamResponse(entry, requestPath, options)` returns a host-driven
24
+ `StreamingSession`. State and patch arguments are JSON strings. `start`,
25
+ `resume`, and `advance` return:
26
+
27
+ ```js
28
+ {
29
+ bytes: Uint8Array,
30
+ done: boolean,
31
+ boundary?: { instanceId, declarationId, owner, name, key }
32
+ }
33
+ ```
34
+
35
+ | Method | Result |
36
+ |---|---|
37
+ | `start(stateJson)` | Shell bytes through the first descriptor or terminal |
38
+ | `resume(instanceId, stateJson, mode)` | Only the pending occurrence's bytes through its checkpoint |
39
+ | `advance()` | Following parent bytes through the next descriptor or terminal |
40
+ | `update(instanceId, patchJson)` | Projected state bytes for an updatable occurrence |
41
+
42
+ A descriptor means call `resume`; no descriptor with `done: false` means call
43
+ `advance`; `done: true` means complete. Boundary-only `resume` lets the host
44
+ enqueue the checkpoint immediately. `advance` renders following parent or tail
45
+ bytes, so no sibling boundary workaround is needed.
46
+
47
+ `mode` is `"final"` (the default) or `"updatable"`. A committed updatable
48
+ occurrence accepts `update(instanceId, patch)`, including between its `resume`
49
+ and `advance`, and returns a `Uint8Array`. Optional boundary keys preserve JSON
50
+ identity: string keys are JavaScript strings and finite numeric keys are
51
+ JavaScript numbers. A key is required when one component-owned declaration is
52
+ reached from multiple static callsites in one entry traversal. Boundaries are
53
+ discovered through entries, reusable components, runtime branches, and selected
54
+ routes. A boundary-bearing subtree under `<for>` fails with
55
+ `boundary-in-repeat`; one boundary may wrap the whole `<for>`. The step with
56
+ `done: true` already contains terminal and document-tail bytes.
57
+
22
58
  ## Building
23
59
 
24
60
  ```bash
@@ -5,7 +5,7 @@
5
5
  "Microsoft Edge"
6
6
  ],
7
7
  "description": "WebAssembly bindings for WebUI framework — powers the online playground",
8
- "version": "0.0.25",
8
+ "version": "0.0.27",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -42,19 +42,26 @@ export class Protocol {
42
42
  }
43
43
 
44
44
  /**
45
- * A progressive HTML response driven one chunk at a time from JavaScript.
45
+ * A progressive HTML response driven one semantic step at a time from JavaScript.
46
46
  *
47
- * Every method returns the UTF-8 bytes it produced. Write them to the
48
- * response and apply the host's own backpressure; the session holds no
49
- * transport and never blocks on one.
47
+ * `start()`, `resume()`, and `advance()` return
48
+ * `{ bytes, done, boundary? }`, where `bytes` is a `Uint8Array` and a boundary is
49
+ * `{ instanceId, declarationId, owner, name, key }`. Boundary keys retain
50
+ * their authored JSON type: strings are JavaScript strings and finite numbers
51
+ * are JavaScript numbers.
50
52
  *
51
53
  * ```js
52
54
  * const session = protocol.streamResponse('index.html', '/');
53
- * const weather = session.boundary('weather-shell');
54
- * controller.enqueue(session.writeShell(shellState));
55
- * controller.enqueue(session.writeBoundary(weather, weatherState, 'updatable'));
56
- * controller.enqueue(session.update(weather, forecast));
57
- * controller.enqueue(session.finish(tailState));
55
+ * let step = session.start(JSON.stringify(shellState));
56
+ * controller.enqueue(step.bytes);
57
+ * while (!step.done) {
58
+ * const { instanceId, name, key } = step.boundary;
59
+ * const state = await loadBoundary(name, key);
60
+ * step = session.resume(instanceId, JSON.stringify(state), 'updatable');
61
+ * controller.enqueue(step.bytes);
62
+ * step = session.advance();
63
+ * controller.enqueue(step.bytes);
64
+ * }
58
65
  * ```
59
66
  */
60
67
  export class StreamingSession {
@@ -62,46 +69,38 @@ export class StreamingSession {
62
69
  free(): void;
63
70
  [Symbol.dispose](): void;
64
71
  /**
65
- * Resolve an authored boundary name to a stable integer handle.
72
+ * Write the parent bytes after the committed occurrence.
66
73
  *
67
- * Resolve once outside the write loop; the handle costs nothing to reuse.
74
+ * Valid only after `resume()`. Returns the next boundary occurrence or
75
+ * completes the document tail.
68
76
  */
69
- boundary(name: string): number;
77
+ advance(): object;
70
78
  /**
71
- * Render the document tail and emit the terminal record.
72
- */
73
- finish(state_json: string): Uint8Array;
74
- /**
75
- * Push a projected state patch to a committed updatable boundary.
76
- */
77
- update(boundary: number, state_json: string): Uint8Array;
78
- /**
79
- * Render and commit the next boundary in declaration order.
79
+ * Commit the pending occurrence through its checkpoint, then stop.
80
80
  *
81
81
  * `mode` is `"final"` (default) or `"updatable"`. Only updatable
82
82
  * boundaries accept later `update()` calls.
83
83
  */
84
- writeBoundary(boundary: number, state_json: string, mode?: string | null): Uint8Array;
84
+ resume(instance_id: number, state_json: string, mode?: string | null): object;
85
85
  /**
86
- * Render everything before the first boundary.
86
+ * Render until the first runtime boundary occurrence or terminal.
87
87
  */
88
- writeShell(state_json: string): Uint8Array;
88
+ start(state_json: string): object;
89
89
  /**
90
- * Number of compile-time boundaries declared by this entry.
91
- */
92
- readonly boundaryCount: number;
93
- /**
94
- * Whether the terminal record has been written.
90
+ * Push a projected state patch to a committed updatable boundary.
95
91
  */
96
- readonly finished: boolean;
92
+ update(instance_id: number, patch_json: string): Uint8Array;
97
93
  }
98
94
 
99
95
  /**
100
96
  * Build protocol protobuf bytes from virtual files without rendering.
101
97
  *
98
+ * `dom` accepts `"shadow"` (default) or `"light"` for unwrapped components;
99
+ * authored open Shadow roots remain Shadow in either mode.
100
+ *
102
101
  * Returns the serialized `WebUIProtocol` as protobuf bytes.
103
102
  */
104
- export function build_protocol(files: any, entry: string, projection_manifests?: any | null): Uint8Array;
103
+ export function build_protocol(files: any, entry: string, projection_manifests?: any | null, dom?: string | null): Uint8Array;
105
104
 
106
105
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
107
106
 
@@ -109,7 +108,7 @@ export interface InitOutput {
109
108
  readonly memory: WebAssembly.Memory;
110
109
  readonly __wbg_protocol_free: (a: number, b: number) => void;
111
110
  readonly __wbg_streamingsession_free: (a: number, b: number) => void;
112
- readonly build_protocol: (a: number, b: number, c: number, d: number, e: number) => void;
111
+ readonly build_protocol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
113
112
  readonly protocol_new: (a: number, b: number, c: number, d: number, e: number) => void;
114
113
  readonly protocol_render: (a: number, b: number, c: number, d: number, e: number) => void;
115
114
  readonly protocol_renderComponentTemplates: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -117,13 +116,10 @@ export interface InitOutput {
117
116
  readonly protocol_renderStream: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
118
117
  readonly protocol_streamResponse: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
119
118
  readonly protocol_tokens: (a: number, b: number) => void;
120
- readonly streamingsession_boundary: (a: number, b: number, c: number, d: number) => void;
121
- readonly streamingsession_boundaryCount: (a: number) => number;
122
- readonly streamingsession_finish: (a: number, b: number, c: number, d: number) => void;
123
- readonly streamingsession_finished: (a: number) => number;
119
+ readonly streamingsession_advance: (a: number, b: number) => void;
120
+ readonly streamingsession_resume: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
121
+ readonly streamingsession_start: (a: number, b: number, c: number, d: number) => void;
124
122
  readonly streamingsession_update: (a: number, b: number, c: number, d: number, e: number) => void;
125
- readonly streamingsession_writeBoundary: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
126
- readonly streamingsession_writeShell: (a: number, b: number, c: number, d: number) => void;
127
123
  readonly __wbindgen_export: (a: number, b: number) => number;
128
124
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
129
125
  readonly __wbindgen_export3: (a: number) => void;
@@ -219,19 +219,26 @@ export class Protocol {
219
219
  if (Symbol.dispose) Protocol.prototype[Symbol.dispose] = Protocol.prototype.free;
220
220
 
221
221
  /**
222
- * A progressive HTML response driven one chunk at a time from JavaScript.
222
+ * A progressive HTML response driven one semantic step at a time from JavaScript.
223
223
  *
224
- * Every method returns the UTF-8 bytes it produced. Write them to the
225
- * response and apply the host's own backpressure; the session holds no
226
- * transport and never blocks on one.
224
+ * `start()`, `resume()`, and `advance()` return
225
+ * `{ bytes, done, boundary? }`, where `bytes` is a `Uint8Array` and a boundary is
226
+ * `{ instanceId, declarationId, owner, name, key }`. Boundary keys retain
227
+ * their authored JSON type: strings are JavaScript strings and finite numbers
228
+ * are JavaScript numbers.
227
229
  *
228
230
  * ```js
229
231
  * const session = protocol.streamResponse('index.html', '/');
230
- * const weather = session.boundary('weather-shell');
231
- * controller.enqueue(session.writeShell(shellState));
232
- * controller.enqueue(session.writeBoundary(weather, weatherState, 'updatable'));
233
- * controller.enqueue(session.update(weather, forecast));
234
- * controller.enqueue(session.finish(tailState));
232
+ * let step = session.start(JSON.stringify(shellState));
233
+ * controller.enqueue(step.bytes);
234
+ * while (!step.done) {
235
+ * const { instanceId, name, key } = step.boundary;
236
+ * const state = await loadBoundary(name, key);
237
+ * step = session.resume(instanceId, JSON.stringify(state), 'updatable');
238
+ * controller.enqueue(step.bytes);
239
+ * step = session.advance();
240
+ * controller.enqueue(step.bytes);
241
+ * }
235
242
  * ```
236
243
  */
237
244
  export class StreamingSession {
@@ -252,139 +259,90 @@ export class StreamingSession {
252
259
  wasm.__wbg_streamingsession_free(ptr, 0);
253
260
  }
254
261
  /**
255
- * Resolve an authored boundary name to a stable integer handle.
262
+ * Write the parent bytes after the committed occurrence.
256
263
  *
257
- * Resolve once outside the write loop; the handle costs nothing to reuse.
258
- * @param {string} name
259
- * @returns {number}
264
+ * Valid only after `resume()`. Returns the next boundary occurrence or
265
+ * completes the document tail.
266
+ * @returns {object}
260
267
  */
261
- boundary(name) {
268
+ advance() {
262
269
  try {
263
270
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
264
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
265
- const len0 = WASM_VECTOR_LEN;
266
- wasm.streamingsession_boundary(retptr, this.__wbg_ptr, ptr0, len0);
271
+ wasm.streamingsession_advance(retptr, this.__wbg_ptr);
267
272
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
268
273
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
269
274
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
270
275
  if (r2) {
271
276
  throw takeObject(r1);
272
277
  }
273
- return r0 >>> 0;
274
- } finally {
275
- wasm.__wbindgen_add_to_stack_pointer(16);
276
- }
277
- }
278
- /**
279
- * Number of compile-time boundaries declared by this entry.
280
- * @returns {number}
281
- */
282
- get boundaryCount() {
283
- const ret = wasm.streamingsession_boundaryCount(this.__wbg_ptr);
284
- return ret >>> 0;
285
- }
286
- /**
287
- * Render the document tail and emit the terminal record.
288
- * @param {string} state_json
289
- * @returns {Uint8Array}
290
- */
291
- finish(state_json) {
292
- try {
293
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
294
- const ptr0 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
295
- const len0 = WASM_VECTOR_LEN;
296
- wasm.streamingsession_finish(retptr, this.__wbg_ptr, ptr0, len0);
297
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
298
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
299
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
300
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
301
- if (r3) {
302
- throw takeObject(r2);
303
- }
304
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
305
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
306
- return v2;
278
+ return takeObject(r0);
307
279
  } finally {
308
280
  wasm.__wbindgen_add_to_stack_pointer(16);
309
281
  }
310
282
  }
311
283
  /**
312
- * Whether the terminal record has been written.
313
- * @returns {boolean}
314
- */
315
- get finished() {
316
- const ret = wasm.streamingsession_finished(this.__wbg_ptr);
317
- return ret !== 0;
318
- }
319
- /**
320
- * Push a projected state patch to a committed updatable boundary.
321
- * @param {number} boundary
284
+ * Commit the pending occurrence through its checkpoint, then stop.
285
+ *
286
+ * `mode` is `"final"` (default) or `"updatable"`. Only updatable
287
+ * boundaries accept later `update()` calls.
288
+ * @param {number} instance_id
322
289
  * @param {string} state_json
323
- * @returns {Uint8Array}
290
+ * @param {string | null} [mode]
291
+ * @returns {object}
324
292
  */
325
- update(boundary, state_json) {
293
+ resume(instance_id, state_json, mode) {
326
294
  try {
327
295
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
328
296
  const ptr0 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
329
297
  const len0 = WASM_VECTOR_LEN;
330
- wasm.streamingsession_update(retptr, this.__wbg_ptr, boundary, ptr0, len0);
298
+ var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
299
+ var len1 = WASM_VECTOR_LEN;
300
+ wasm.streamingsession_resume(retptr, this.__wbg_ptr, instance_id, ptr0, len0, ptr1, len1);
331
301
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
332
302
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
333
303
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
334
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
335
- if (r3) {
336
- throw takeObject(r2);
304
+ if (r2) {
305
+ throw takeObject(r1);
337
306
  }
338
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
339
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
340
- return v2;
307
+ return takeObject(r0);
341
308
  } finally {
342
309
  wasm.__wbindgen_add_to_stack_pointer(16);
343
310
  }
344
311
  }
345
312
  /**
346
- * Render and commit the next boundary in declaration order.
347
- *
348
- * `mode` is `"final"` (default) or `"updatable"`. Only updatable
349
- * boundaries accept later `update()` calls.
350
- * @param {number} boundary
313
+ * Render until the first runtime boundary occurrence or terminal.
351
314
  * @param {string} state_json
352
- * @param {string | null} [mode]
353
- * @returns {Uint8Array}
315
+ * @returns {object}
354
316
  */
355
- writeBoundary(boundary, state_json, mode) {
317
+ start(state_json) {
356
318
  try {
357
319
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
358
320
  const ptr0 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
359
321
  const len0 = WASM_VECTOR_LEN;
360
- var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
361
- var len1 = WASM_VECTOR_LEN;
362
- wasm.streamingsession_writeBoundary(retptr, this.__wbg_ptr, boundary, ptr0, len0, ptr1, len1);
322
+ wasm.streamingsession_start(retptr, this.__wbg_ptr, ptr0, len0);
363
323
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
364
324
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
365
325
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
366
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
367
- if (r3) {
368
- throw takeObject(r2);
326
+ if (r2) {
327
+ throw takeObject(r1);
369
328
  }
370
- var v3 = getArrayU8FromWasm0(r0, r1).slice();
371
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
372
- return v3;
329
+ return takeObject(r0);
373
330
  } finally {
374
331
  wasm.__wbindgen_add_to_stack_pointer(16);
375
332
  }
376
333
  }
377
334
  /**
378
- * Render everything before the first boundary.
379
- * @param {string} state_json
335
+ * Push a projected state patch to a committed updatable boundary.
336
+ * @param {number} instance_id
337
+ * @param {string} patch_json
380
338
  * @returns {Uint8Array}
381
339
  */
382
- writeShell(state_json) {
340
+ update(instance_id, patch_json) {
383
341
  try {
384
342
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
385
- const ptr0 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
343
+ const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
386
344
  const len0 = WASM_VECTOR_LEN;
387
- wasm.streamingsession_writeShell(retptr, this.__wbg_ptr, ptr0, len0);
345
+ wasm.streamingsession_update(retptr, this.__wbg_ptr, instance_id, ptr0, len0);
388
346
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
389
347
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
390
348
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -405,18 +363,24 @@ if (Symbol.dispose) StreamingSession.prototype[Symbol.dispose] = StreamingSessio
405
363
  /**
406
364
  * Build protocol protobuf bytes from virtual files without rendering.
407
365
  *
366
+ * `dom` accepts `"shadow"` (default) or `"light"` for unwrapped components;
367
+ * authored open Shadow roots remain Shadow in either mode.
368
+ *
408
369
  * Returns the serialized `WebUIProtocol` as protobuf bytes.
409
370
  * @param {any} files
410
371
  * @param {string} entry
411
372
  * @param {any | null} [projection_manifests]
373
+ * @param {string | null} [dom]
412
374
  * @returns {Uint8Array}
413
375
  */
414
- export function build_protocol(files, entry, projection_manifests) {
376
+ export function build_protocol(files, entry, projection_manifests, dom) {
415
377
  try {
416
378
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
417
379
  const ptr0 = passStringToWasm0(entry, wasm.__wbindgen_export, wasm.__wbindgen_export2);
418
380
  const len0 = WASM_VECTOR_LEN;
419
- wasm.build_protocol(retptr, addHeapObject(files), ptr0, len0, isLikeNone(projection_manifests) ? 0 : addHeapObject(projection_manifests));
381
+ var ptr1 = isLikeNone(dom) ? 0 : passStringToWasm0(dom, wasm.__wbindgen_export, wasm.__wbindgen_export2);
382
+ var len1 = WASM_VECTOR_LEN;
383
+ wasm.build_protocol(retptr, addHeapObject(files), ptr0, len0, isLikeNone(projection_manifests) ? 0 : addHeapObject(projection_manifests), ptr1, len1);
420
384
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
421
385
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
422
386
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -424,9 +388,9 @@ export function build_protocol(files, entry, projection_manifests) {
424
388
  if (r3) {
425
389
  throw takeObject(r2);
426
390
  }
427
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
391
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
428
392
  wasm.__wbindgen_export4(r0, r1 * 1, 1);
429
- return v2;
393
+ return v3;
430
394
  } finally {
431
395
  wasm.__wbindgen_add_to_stack_pointer(16);
432
396
  }
@@ -579,6 +543,14 @@ function __wbg_get_imports() {
579
543
  const ret = new Uint8Array(getObject(arg0));
580
544
  return addHeapObject(ret);
581
545
  },
546
+ __wbg_new_da52cf8fe3429cb2: function() {
547
+ const ret = new Object();
548
+ return addHeapObject(ret);
549
+ },
550
+ __wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
551
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
552
+ return addHeapObject(ret);
553
+ },
582
554
  __wbg_next_6dbf2c0ac8cde20f: function(arg0) {
583
555
  const ret = getObject(arg0).next;
584
556
  return addHeapObject(ret);
@@ -590,6 +562,10 @@ function __wbg_get_imports() {
590
562
  __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
591
563
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
592
564
  },
565
+ __wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
566
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
567
+ return ret;
568
+ }, arguments); },
593
569
  __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
594
570
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
595
571
  },
@@ -597,7 +573,12 @@ function __wbg_get_imports() {
597
573
  const ret = getObject(arg0).value;
598
574
  return addHeapObject(ret);
599
575
  },
600
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
576
+ __wbindgen_cast_0000000000000001: function(arg0) {
577
+ // Cast intrinsic for `F64 -> Externref`.
578
+ const ret = arg0;
579
+ return addHeapObject(ret);
580
+ },
581
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
601
582
  // Cast intrinsic for `Ref(String) -> Externref`.
602
583
  const ret = getStringFromWasm0(arg0, arg1);
603
584
  return addHeapObject(ret);
Binary file
@@ -3,7 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_protocol_free: (a: number, b: number) => void;
5
5
  export const __wbg_streamingsession_free: (a: number, b: number) => void;
6
- export const build_protocol: (a: number, b: number, c: number, d: number, e: number) => void;
6
+ export const build_protocol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
7
7
  export const protocol_new: (a: number, b: number, c: number, d: number, e: number) => void;
8
8
  export const protocol_render: (a: number, b: number, c: number, d: number, e: number) => void;
9
9
  export const protocol_renderComponentTemplates: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -11,13 +11,10 @@ export const protocol_renderPartial: (a: number, b: number, c: number, d: number
11
11
  export const protocol_renderStream: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
12
12
  export const protocol_streamResponse: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
13
13
  export const protocol_tokens: (a: number, b: number) => void;
14
- export const streamingsession_boundary: (a: number, b: number, c: number, d: number) => void;
15
- export const streamingsession_boundaryCount: (a: number) => number;
16
- export const streamingsession_finish: (a: number, b: number, c: number, d: number) => void;
17
- export const streamingsession_finished: (a: number) => number;
14
+ export const streamingsession_advance: (a: number, b: number) => void;
15
+ export const streamingsession_resume: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
16
+ export const streamingsession_start: (a: number, b: number, c: number, d: number) => void;
18
17
  export const streamingsession_update: (a: number, b: number, c: number, d: number, e: number) => void;
19
- export const streamingsession_writeBoundary: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
20
- export const streamingsession_writeShell: (a: number, b: number, c: number, d: number) => void;
21
18
  export const __wbindgen_export: (a: number, b: number) => number;
22
19
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
23
20
  export const __wbindgen_export3: (a: number) => void;
@@ -15,10 +15,46 @@ WebAssembly bindings for the [WebUI](https://github.com/microsoft/webui) framewo
15
15
  The default feature is `all`, which powers the online playground. Consumers that only need to render prebuilt protobuf protocol bytes should use the handler bundle to avoid shipping parser code.
16
16
 
17
17
  Construct `Protocol` once from protocol bytes. It exposes `render`,
18
- `renderStream`, `renderPartial`, `renderComponentTemplates`, and `tokens`.
18
+ `renderStream`, `renderPartial`, `renderComponentTemplates`, `tokens`, and
19
+ `streamResponse`.
19
20
  Streaming callbacks are coalesced around a 16 KiB target before crossing into
20
21
  JavaScript.
21
22
 
23
+ `Protocol.streamResponse(entry, requestPath, options)` returns a host-driven
24
+ `StreamingSession`. State and patch arguments are JSON strings. `start`,
25
+ `resume`, and `advance` return:
26
+
27
+ ```js
28
+ {
29
+ bytes: Uint8Array,
30
+ done: boolean,
31
+ boundary?: { instanceId, declarationId, owner, name, key }
32
+ }
33
+ ```
34
+
35
+ | Method | Result |
36
+ |---|---|
37
+ | `start(stateJson)` | Shell bytes through the first descriptor or terminal |
38
+ | `resume(instanceId, stateJson, mode)` | Only the pending occurrence's bytes through its checkpoint |
39
+ | `advance()` | Following parent bytes through the next descriptor or terminal |
40
+ | `update(instanceId, patchJson)` | Projected state bytes for an updatable occurrence |
41
+
42
+ A descriptor means call `resume`; no descriptor with `done: false` means call
43
+ `advance`; `done: true` means complete. Boundary-only `resume` lets the host
44
+ enqueue the checkpoint immediately. `advance` renders following parent or tail
45
+ bytes, so no sibling boundary workaround is needed.
46
+
47
+ `mode` is `"final"` (the default) or `"updatable"`. A committed updatable
48
+ occurrence accepts `update(instanceId, patch)`, including between its `resume`
49
+ and `advance`, and returns a `Uint8Array`. Optional boundary keys preserve JSON
50
+ identity: string keys are JavaScript strings and finite numeric keys are
51
+ JavaScript numbers. A key is required when one component-owned declaration is
52
+ reached from multiple static callsites in one entry traversal. Boundaries are
53
+ discovered through entries, reusable components, runtime branches, and selected
54
+ routes. A boundary-bearing subtree under `<for>` fails with
55
+ `boundary-in-repeat`; one boundary may wrap the whole `<for>`. The step with
56
+ `done: true` already contains terminal and document-tail bytes.
57
+
22
58
  ## Building
23
59
 
24
60
  ```bash
@@ -5,7 +5,7 @@
5
5
  "Microsoft Edge"
6
6
  ],
7
7
  "description": "WebAssembly bindings for WebUI framework — powers the online playground",
8
- "version": "0.0.25",
8
+ "version": "0.0.27",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",