@yodaos-pkg/ink 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -176,6 +176,94 @@ Binds common DOM events to the current `InkView`.
176
176
  - Returns a cleanup function
177
177
  - Calling it removes every listener created by this binding call
178
178
 
179
+ ### `view.dispatchMessageEvent(dataOrJson, origin?, lastEventId?)`
180
+
181
+ Dispatches a one-shot host message to the current Ink page.
182
+
183
+ **Parameters**
184
+
185
+ - `dataOrJson: unknown`
186
+ - Required
187
+ - Accepts either a structured JSON-serializable value or a raw JSON string
188
+ - `origin?: string`
189
+ - Optional
190
+ - The host-defined origin exposed as `event.origin`
191
+ - Defaults to `'host'`
192
+ - `lastEventId?: string`
193
+ - Optional
194
+ - The host-defined message identifier exposed as `event.lastEventId`
195
+ - Defaults to `''`
196
+
197
+ **What it does**
198
+
199
+ - If `dataOrJson` is a string, parses it as raw JSON first
200
+ - Otherwise serializes the structured value directly
201
+ - Dispatches the resulting payload as a DOM-style `MessageEvent`
202
+ - Automatically triggers a render request
203
+
204
+ **Returns**
205
+
206
+ - `InkView`
207
+ - Returns the current instance so it can be chained
208
+
209
+ **Throws**
210
+
211
+ - `Error`
212
+ - If a string input is not valid JSON
213
+ - `TypeError`
214
+ - If a structured input cannot be serialized into JSON
215
+
216
+ ### `view.createMessageStream(origin?, lastEventId?)`
217
+
218
+ Creates a host-controlled JSON message stream for the current Ink page.
219
+
220
+ **Parameters**
221
+
222
+ - `origin?: string`
223
+ - Optional
224
+ - The host-defined origin propagated to stream events
225
+ - Defaults to `'host'`
226
+ - `lastEventId?: string`
227
+ - Optional
228
+ - The host-defined message identifier propagated to stream events
229
+ - Defaults to `''`
230
+
231
+ **What it does**
232
+
233
+ - Creates a progressive JSON stream owned by the browser host
234
+ - Lets the host call `write(chunk)` repeatedly
235
+ - Lets the host call `close()` when the stream is complete
236
+ - Delivers a runtime-side `MessageStream` object through `onMessage(event)`
237
+
238
+ **Returns**
239
+
240
+ - `InkHostMessageStream`
241
+ - A small host-side stream handle with `write(chunk)` and `close()`
242
+
243
+ ### `InkHostMessageStream.write(chunk)`
244
+
245
+ Appends the next JSON text chunk to the stream.
246
+
247
+ **Parameters**
248
+
249
+ - `chunk: string`
250
+ - Required
251
+ - The next JSON text fragment to append
252
+
253
+ **Throws**
254
+
255
+ - `Error`
256
+ - If the stream has already been closed
257
+
258
+ ### `InkHostMessageStream.close()`
259
+
260
+ Closes the host stream.
261
+
262
+ **What it does**
263
+
264
+ - Ends the stream inside the Ink runtime
265
+ - Is safe to call more than once
266
+
179
267
  ### `view.openBundle(options)`
180
268
 
181
269
  Opens an Ink bundle that already exists in memory.
@@ -328,6 +416,70 @@ Destroys the current `InkView` and releases its resources.
328
416
 
329
417
  - `void`
330
418
 
419
+ ## Host Message Example
420
+
421
+ Use `dispatchMessageEvent()` when the full payload is already available:
422
+
423
+ ```js
424
+ view.dispatchMessageEvent(
425
+ { type: 'hello', value: 1 },
426
+ 'browser-host',
427
+ 'msg-1',
428
+ );
429
+
430
+ view.dispatchMessageEvent(
431
+ '{"type":"hello","value":2}',
432
+ 'browser-host',
433
+ 'msg-2',
434
+ );
435
+ ```
436
+
437
+ Inside the Ink page:
438
+
439
+ ```js
440
+ export default Page({
441
+ onMessage(event) {
442
+ console.log('message data:', event.data);
443
+ console.log('origin:', event.origin);
444
+ console.log('lastEventId:', event.lastEventId);
445
+ },
446
+ });
447
+ ```
448
+
449
+ ## Host Message Stream Example
450
+
451
+ Use `createMessageStream()` when JSON arrives progressively:
452
+
453
+ ```js
454
+ const stream = view.createMessageStream('browser-host', 'stream-1');
455
+ stream.write('{"delta":"hel"');
456
+ stream.write('lo"}{"done":true}');
457
+ stream.close();
458
+ ```
459
+
460
+ Inside the Ink page:
461
+
462
+ ```js
463
+ export default Page({
464
+ onMessage(event) {
465
+ if (!(event.data instanceof MessageStream)) {
466
+ return;
467
+ }
468
+
469
+ const stream = event.data;
470
+ stream.addEventListener('token', (tokenEvent) => {
471
+ console.log('token:', tokenEvent.token);
472
+ });
473
+ stream.addEventListener('error', (errorEvent) => {
474
+ console.error('stream error:', errorEvent.error);
475
+ });
476
+ stream.addEventListener('end', () => {
477
+ console.log('stream finished');
478
+ });
479
+ },
480
+ });
481
+ ```
482
+
331
483
  ## Plain JavaScript Integration
332
484
 
333
485
  This is the most direct way to integrate Ink into a plain JavaScript app.
package/index.d.ts CHANGED
@@ -64,6 +64,18 @@ export interface OpenBundleOptions {
64
64
  query?: string | Record<string, unknown> | null;
65
65
  }
66
66
 
67
+ /**
68
+ * Opens a runtime-owned builtin app through a path such as `ink://launchers`.
69
+ */
70
+ export interface OpenPathOptions {
71
+ /** Runtime path to open, typically using the `ink://` scheme for builtin apps. */
72
+ path: string;
73
+ /** Optional initial page route. */
74
+ initialPage?: string | null;
75
+ /** Optional launch query string or structured query object. */
76
+ query?: string | Record<string, unknown> | null;
77
+ }
78
+
67
79
  /**
68
80
  * Base options for loading a bundle from a VFS-style HTTP endpoint.
69
81
  */
@@ -169,6 +181,20 @@ export interface BindDomEventsOptions {
169
181
  preventWheelDefault?: boolean;
170
182
  }
171
183
 
184
+ /**
185
+ * Host-controlled message stream returned by {@link InkView.createMessageStream}.
186
+ *
187
+ * Chunks are UTF-8 JSON text fragments consumed incrementally by the Ink
188
+ * runtime. JavaScript inside Ink receives a runtime-side `MessageStream`
189
+ * object through `onMessage(event)`.
190
+ */
191
+ export interface InkHostMessageStream {
192
+ /** Appends the next JSON text chunk to the stream. */
193
+ write(chunk: string): void;
194
+ /** Closes the stream and emits terminal events inside the Ink runtime. */
195
+ close(): void;
196
+ }
197
+
172
198
  /**
173
199
  * Initializes the browser SDK and ensures the wasm runtime is ready to create
174
200
  * views. Most applications can use {@link InkView.create} or
@@ -260,6 +286,19 @@ export declare class InkView {
260
286
  */
261
287
  bindDomEvents(options?: BindDomEventsOptions): () => void;
262
288
 
289
+ /**
290
+ * Opens a runtime path such as `ink://launchers`.
291
+ *
292
+ * On web/wasm this currently targets runtime-owned builtin apps. Browser
293
+ * hosts should continue to use {@link openBundle} or {@link openFromVfs}
294
+ * when they own the bundle contents directly.
295
+ */
296
+ open(
297
+ path: string,
298
+ initialPage?: string | null,
299
+ query?: string | Record<string, unknown> | null,
300
+ ): this;
301
+
263
302
  /**
264
303
  * Opens an already-materialized application bundle.
265
304
  *
@@ -314,6 +353,24 @@ export declare class InkView {
314
353
  */
315
354
  notifyUserInteraction(): this;
316
355
 
356
+ /**
357
+ * Dispatches a one-shot host message to the current Ink page.
358
+ *
359
+ * When `dataOrJson` is a string, the SDK parses it as raw JSON first so the
360
+ * browser behavior matches Android's `dispatchMessageEvent(json, ...)`
361
+ * overload. Otherwise the value is serialized directly as the message
362
+ * payload.
363
+ */
364
+ dispatchMessageEvent(dataOrJson: unknown, origin?: string, lastEventId?: string): this;
365
+
366
+ /**
367
+ * Creates a host-controlled JSON message stream for the current Ink page.
368
+ *
369
+ * The returned handle accepts `write(chunk)` and `close()`, while the Ink
370
+ * page receives a runtime-side `MessageStream` object through `onMessage`.
371
+ */
372
+ createMessageStream(origin?: string, lastEventId?: string): InkHostMessageStream;
373
+
317
374
  /**
318
375
  * Performs one render pass immediately.
319
376
  *
package/index.js CHANGED
@@ -278,6 +278,70 @@ function ensureAnimationFrameApi() {
278
278
  };
279
279
  }
280
280
 
281
+ function normalizeHostMessageMetadata(origin, lastEventId) {
282
+ if (typeof origin !== 'string') {
283
+ throw new TypeError('`origin` must be a string.');
284
+ }
285
+ if (typeof lastEventId !== 'string') {
286
+ throw new TypeError('`lastEventId` must be a string.');
287
+ }
288
+ return { origin, lastEventId };
289
+ }
290
+
291
+ function normalizeHostMessagePayload(dataOrJson) {
292
+ if (typeof dataOrJson === 'string') {
293
+ try {
294
+ return JSON.parse(dataOrJson);
295
+ } catch {
296
+ throw new Error('dispatchMessageEvent(json) requires valid JSON');
297
+ }
298
+ }
299
+ return dataOrJson;
300
+ }
301
+
302
+ function serializeHostMessagePayload(dataOrJson) {
303
+ const payload = normalizeHostMessagePayload(dataOrJson);
304
+ let payloadJson;
305
+ try {
306
+ payloadJson = JSON.stringify(payload);
307
+ } catch {
308
+ throw new TypeError('dispatchMessageEvent(data) requires a JSON-serializable value.');
309
+ }
310
+ if (typeof payloadJson !== 'string') {
311
+ throw new TypeError('dispatchMessageEvent(data) requires a JSON-serializable value.');
312
+ }
313
+ return payloadJson;
314
+ }
315
+
316
+ class InkHostMessageStream {
317
+ #rawStream;
318
+ #requestRender;
319
+ #closed;
320
+
321
+ constructor(rawStream, requestRender) {
322
+ this.#rawStream = rawStream;
323
+ this.#requestRender = requestRender;
324
+ this.#closed = false;
325
+ }
326
+
327
+ write(chunk) {
328
+ if (typeof chunk !== 'string') {
329
+ throw new TypeError('`chunk` must be a string.');
330
+ }
331
+ this.#rawStream.write(chunk);
332
+ this.#requestRender();
333
+ }
334
+
335
+ close() {
336
+ if (this.#closed) {
337
+ return;
338
+ }
339
+ this.#rawStream.close();
340
+ this.#closed = true;
341
+ this.#requestRender();
342
+ }
343
+ }
344
+
281
345
  export async function initInk(options = {}) {
282
346
  if (options.requestInterceptor) {
283
347
  setInkRequestInterceptor(options.requestInterceptor);
@@ -331,6 +395,7 @@ export class InkView {
331
395
  #animationFrameApi;
332
396
  #frameHandle;
333
397
  #autoRender;
398
+ #destroyed;
334
399
  #domCleanup;
335
400
 
336
401
  constructor(rawView, options = {}) {
@@ -339,6 +404,7 @@ export class InkView {
339
404
  this.#animationFrameApi = ensureAnimationFrameApi();
340
405
  this.#frameHandle = null;
341
406
  this.#autoRender = false;
407
+ this.#destroyed = false;
342
408
  this.#domCleanup = null;
343
409
  }
344
410
 
@@ -503,6 +569,16 @@ export class InkView {
503
569
  return this;
504
570
  }
505
571
 
572
+ open(path, initialPage = null, query = null) {
573
+ if (typeof path !== 'string' || !path.trim()) {
574
+ throw new Error('`path` must be a non-empty string.');
575
+ }
576
+
577
+ this.#rawView.open(path.trim(), initialPage, serializeQuery(query));
578
+ this.requestRender();
579
+ return this;
580
+ }
581
+
506
582
  async openFromVfs({
507
583
  appId,
508
584
  baseUrl,
@@ -560,7 +636,29 @@ export class InkView {
560
636
  return this;
561
637
  }
562
638
 
639
+ dispatchMessageEvent(dataOrJson, origin = 'host', lastEventId = '') {
640
+ const metadata = normalizeHostMessageMetadata(origin, lastEventId);
641
+ this.#rawView.dispatchMessageEvent(
642
+ serializeHostMessagePayload(dataOrJson),
643
+ metadata.origin,
644
+ metadata.lastEventId,
645
+ );
646
+ this.requestRender();
647
+ return this;
648
+ }
649
+
650
+ createMessageStream(origin = 'host', lastEventId = '') {
651
+ const metadata = normalizeHostMessageMetadata(origin, lastEventId);
652
+ return new InkHostMessageStream(
653
+ this.#rawView.createMessageStream(metadata.origin, metadata.lastEventId),
654
+ () => this.requestRender(),
655
+ );
656
+ }
657
+
563
658
  render() {
659
+ if (this.#destroyed) {
660
+ return false;
661
+ }
564
662
  const hasMoreWork = Boolean(this.#rawView.render());
565
663
  if (hasMoreWork || this.#autoRender) {
566
664
  this.requestRender();
@@ -569,6 +667,9 @@ export class InkView {
569
667
  }
570
668
 
571
669
  requestRender() {
670
+ if (this.#destroyed) {
671
+ return this;
672
+ }
572
673
  if (this.#frameHandle != null) {
573
674
  return this;
574
675
  }
@@ -600,6 +701,10 @@ export class InkView {
600
701
  }
601
702
 
602
703
  destroy() {
704
+ if (this.#destroyed) {
705
+ return;
706
+ }
707
+ this.#destroyed = true;
603
708
  this.stopRendering();
604
709
  if (this.#domCleanup) {
605
710
  this.#domCleanup();
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "access": "public",
11
11
  "registry": "https://registry.npmjs.com/"
12
12
  },
13
- "version": "0.6.0",
13
+ "version": "0.7.0",
14
14
  "type": "module",
15
15
  "main": "index.js",
16
16
  "types": "index.d.ts",
package/pkg/ink_web.d.ts CHANGED
@@ -1,19 +1,30 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export class InkWebMessageStream {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ close(): void;
9
+ write(chunk: string): void;
10
+ }
11
+
4
12
  export class InkWebView {
5
13
  free(): void;
6
14
  [Symbol.dispose](): void;
7
15
  bindCanvas(canvas: HTMLCanvasElement): void;
8
16
  blur(): void;
17
+ createMessageStream(origin: string, last_event_id: string): InkWebMessageStream;
9
18
  destroy(): void;
10
19
  dispatchInput(event_type: string, code: string, timestamp: number): void;
20
+ dispatchMessageEvent(payload_json: string, origin: string, last_event_id: string): void;
11
21
  dispatchPointer(event_type: string, x: number, y: number, id: number, button: number, delta_x: number, delta_y: number): void;
12
22
  focus(): void;
13
23
  isInteractive(): boolean;
14
24
  isRunning(): boolean;
15
25
  constructor(width: number, height: number, scale_factor: number);
16
26
  notifyUserInteraction(): void;
27
+ open(path: string, initial_page?: string | null, query_json?: string | null): void;
17
28
  openBundle(app_id: string, files: Map<any, any>, initial_page?: string | null, query_json?: string | null): void;
18
29
  render(): boolean;
19
30
  resize(width: number, height: number, scale_factor: number): void;
@@ -28,28 +39,34 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
28
39
 
29
40
  export interface InitOutput {
30
41
  readonly memory: WebAssembly.Memory;
42
+ readonly __wbg_inkwebmessagestream_free: (a: number, b: number) => void;
31
43
  readonly __wbg_inkwebview_free: (a: number, b: number) => void;
32
44
  readonly get_version: (a: number) => void;
45
+ readonly inkwebmessagestream_close: (a: number) => void;
46
+ readonly inkwebmessagestream_write: (a: number, b: number, c: number, d: number) => void;
33
47
  readonly inkwebview_bindCanvas: (a: number, b: number, c: number) => void;
34
48
  readonly inkwebview_blur: (a: number) => void;
49
+ readonly inkwebview_createMessageStream: (a: number, b: number, c: number, d: number, e: number) => number;
35
50
  readonly inkwebview_destroy: (a: number) => void;
36
51
  readonly inkwebview_dispatchInput: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
52
+ readonly inkwebview_dispatchMessageEvent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
37
53
  readonly inkwebview_dispatchPointer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
38
54
  readonly inkwebview_focus: (a: number) => void;
39
55
  readonly inkwebview_isInteractive: (a: number) => number;
40
56
  readonly inkwebview_isRunning: (a: number) => number;
41
57
  readonly inkwebview_new: (a: number, b: number, c: number) => number;
42
58
  readonly inkwebview_notifyUserInteraction: (a: number) => void;
59
+ readonly inkwebview_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
43
60
  readonly inkwebview_openBundle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
44
61
  readonly inkwebview_render: (a: number, b: number) => void;
45
62
  readonly inkwebview_resize: (a: number, b: number, c: number, d: number) => void;
46
63
  readonly inkwebview_setInteractive: (a: number, b: number) => void;
47
64
  readonly main: () => void;
48
- readonly __wasm_bindgen_func_elem_9121: (a: number, b: number) => void;
49
- readonly __wasm_bindgen_func_elem_13334: (a: number, b: number) => void;
50
- readonly __wasm_bindgen_func_elem_9385: (a: number, b: number, c: number) => void;
51
- readonly __wasm_bindgen_func_elem_13335: (a: number, b: number, c: number) => void;
52
- readonly __wasm_bindgen_func_elem_9383: (a: number, b: number) => void;
65
+ readonly __wasm_bindgen_func_elem_9251: (a: number, b: number) => void;
66
+ readonly __wasm_bindgen_func_elem_13498: (a: number, b: number) => void;
67
+ readonly __wasm_bindgen_func_elem_9547: (a: number, b: number, c: number) => void;
68
+ readonly __wasm_bindgen_func_elem_13499: (a: number, b: number, c: number) => void;
69
+ readonly __wasm_bindgen_func_elem_9546: (a: number, b: number) => void;
53
70
  readonly __wbindgen_export: (a: number, b: number) => number;
54
71
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
55
72
  readonly __wbindgen_export3: (a: number) => void;
package/pkg/ink_web.js CHANGED
@@ -1,5 +1,47 @@
1
1
  /* @ts-self-types="./ink_web.d.ts" */
2
2
 
3
+ export class InkWebMessageStream {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(InkWebMessageStream.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ InkWebMessageStreamFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ InkWebMessageStreamFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_inkwebmessagestream_free(ptr, 0);
20
+ }
21
+ close() {
22
+ wasm.inkwebmessagestream_close(this.__wbg_ptr);
23
+ }
24
+ /**
25
+ * @param {string} chunk
26
+ */
27
+ write(chunk) {
28
+ try {
29
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
30
+ const ptr0 = passStringToWasm0(chunk, wasm.__wbindgen_export, wasm.__wbindgen_export2);
31
+ const len0 = WASM_VECTOR_LEN;
32
+ wasm.inkwebmessagestream_write(retptr, this.__wbg_ptr, ptr0, len0);
33
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
34
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
35
+ if (r1) {
36
+ throw takeObject(r0);
37
+ }
38
+ } finally {
39
+ wasm.__wbindgen_add_to_stack_pointer(16);
40
+ }
41
+ }
42
+ }
43
+ if (Symbol.dispose) InkWebMessageStream.prototype[Symbol.dispose] = InkWebMessageStream.prototype.free;
44
+
3
45
  export class InkWebView {
4
46
  __destroy_into_raw() {
5
47
  const ptr = this.__wbg_ptr;
@@ -30,6 +72,19 @@ export class InkWebView {
30
72
  blur() {
31
73
  wasm.inkwebview_blur(this.__wbg_ptr);
32
74
  }
75
+ /**
76
+ * @param {string} origin
77
+ * @param {string} last_event_id
78
+ * @returns {InkWebMessageStream}
79
+ */
80
+ createMessageStream(origin, last_event_id) {
81
+ const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
82
+ const len0 = WASM_VECTOR_LEN;
83
+ const ptr1 = passStringToWasm0(last_event_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
84
+ const len1 = WASM_VECTOR_LEN;
85
+ const ret = wasm.inkwebview_createMessageStream(this.__wbg_ptr, ptr0, len0, ptr1, len1);
86
+ return InkWebMessageStream.__wrap(ret);
87
+ }
33
88
  destroy() {
34
89
  wasm.inkwebview_destroy(this.__wbg_ptr);
35
90
  }
@@ -55,6 +110,30 @@ export class InkWebView {
55
110
  wasm.__wbindgen_add_to_stack_pointer(16);
56
111
  }
57
112
  }
113
+ /**
114
+ * @param {string} payload_json
115
+ * @param {string} origin
116
+ * @param {string} last_event_id
117
+ */
118
+ dispatchMessageEvent(payload_json, origin, last_event_id) {
119
+ try {
120
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
121
+ const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
122
+ const len0 = WASM_VECTOR_LEN;
123
+ const ptr1 = passStringToWasm0(origin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
124
+ const len1 = WASM_VECTOR_LEN;
125
+ const ptr2 = passStringToWasm0(last_event_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
126
+ const len2 = WASM_VECTOR_LEN;
127
+ wasm.inkwebview_dispatchMessageEvent(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
128
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
129
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
130
+ if (r1) {
131
+ throw takeObject(r0);
132
+ }
133
+ } finally {
134
+ wasm.__wbindgen_add_to_stack_pointer(16);
135
+ }
136
+ }
58
137
  /**
59
138
  * @param {string} event_type
60
139
  * @param {number} x
@@ -110,6 +189,30 @@ export class InkWebView {
110
189
  notifyUserInteraction() {
111
190
  wasm.inkwebview_notifyUserInteraction(this.__wbg_ptr);
112
191
  }
192
+ /**
193
+ * @param {string} path
194
+ * @param {string | null} [initial_page]
195
+ * @param {string | null} [query_json]
196
+ */
197
+ open(path, initial_page, query_json) {
198
+ try {
199
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
200
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ var ptr1 = isLikeNone(initial_page) ? 0 : passStringToWasm0(initial_page, wasm.__wbindgen_export, wasm.__wbindgen_export2);
203
+ var len1 = WASM_VECTOR_LEN;
204
+ var ptr2 = isLikeNone(query_json) ? 0 : passStringToWasm0(query_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
205
+ var len2 = WASM_VECTOR_LEN;
206
+ wasm.inkwebview_open(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
207
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
208
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
209
+ if (r1) {
210
+ throw takeObject(r0);
211
+ }
212
+ } finally {
213
+ wasm.__wbindgen_add_to_stack_pointer(16);
214
+ }
215
+ }
113
216
  /**
114
217
  * @param {string} app_id
115
218
  * @param {Map<any, any>} files
@@ -748,6 +851,10 @@ function __wbg_get_imports() {
748
851
  const ret = getObject(arg0).read();
749
852
  return addHeapObject(ret);
750
853
  },
854
+ __wbg_readyState_1bb73ec7b8a54656: function(arg0) {
855
+ const ret = getObject(arg0).readyState;
856
+ return ret;
857
+ },
751
858
  __wbg_rect_967665357db991e9: function(arg0, arg1, arg2, arg3, arg4) {
752
859
  getObject(arg0).rect(arg1, arg2, arg3, arg4);
753
860
  },
@@ -980,28 +1087,28 @@ function __wbg_get_imports() {
980
1087
  return ret;
981
1088
  },
982
1089
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
983
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2469, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 2402, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
984
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9121, __wasm_bindgen_func_elem_9385);
1090
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2443, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 2403, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1091
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9251, __wasm_bindgen_func_elem_9547);
985
1092
  return addHeapObject(ret);
986
1093
  },
987
1094
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
988
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2469, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2402, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
989
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9121, __wasm_bindgen_func_elem_9385);
1095
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2443, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2403, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1096
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9251, __wasm_bindgen_func_elem_9547);
990
1097
  return addHeapObject(ret);
991
1098
  },
992
1099
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
993
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2469, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 2402, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
994
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9121, __wasm_bindgen_func_elem_9385);
1100
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2443, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 2403, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1101
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9251, __wasm_bindgen_func_elem_9547);
995
1102
  return addHeapObject(ret);
996
1103
  },
997
1104
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
998
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2469, function: Function { arguments: [], shim_idx: 2470, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
999
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9121, __wasm_bindgen_func_elem_9383);
1105
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2443, function: Function { arguments: [], shim_idx: 2445, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1106
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9251, __wasm_bindgen_func_elem_9546);
1000
1107
  return addHeapObject(ret);
1001
1108
  },
1002
1109
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
1003
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3378, function: Function { arguments: [Externref], shim_idx: 3379, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1004
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_13334, __wasm_bindgen_func_elem_13335);
1110
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3416, function: Function { arguments: [Externref], shim_idx: 3417, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1111
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_13498, __wasm_bindgen_func_elem_13499);
1005
1112
  return addHeapObject(ret);
1006
1113
  },
1007
1114
  __wbindgen_cast_0000000000000006: function(arg0) {
@@ -1058,20 +1165,23 @@ function __wbg_get_imports() {
1058
1165
  };
1059
1166
  }
1060
1167
 
1061
- function __wasm_bindgen_func_elem_9383(arg0, arg1) {
1062
- wasm.__wasm_bindgen_func_elem_9383(arg0, arg1);
1168
+ function __wasm_bindgen_func_elem_9546(arg0, arg1) {
1169
+ wasm.__wasm_bindgen_func_elem_9546(arg0, arg1);
1063
1170
  }
1064
1171
 
1065
- function __wasm_bindgen_func_elem_9385(arg0, arg1, arg2) {
1066
- wasm.__wasm_bindgen_func_elem_9385(arg0, arg1, addHeapObject(arg2));
1172
+ function __wasm_bindgen_func_elem_9547(arg0, arg1, arg2) {
1173
+ wasm.__wasm_bindgen_func_elem_9547(arg0, arg1, addHeapObject(arg2));
1067
1174
  }
1068
1175
 
1069
- function __wasm_bindgen_func_elem_13335(arg0, arg1, arg2) {
1070
- wasm.__wasm_bindgen_func_elem_13335(arg0, arg1, addHeapObject(arg2));
1176
+ function __wasm_bindgen_func_elem_13499(arg0, arg1, arg2) {
1177
+ wasm.__wasm_bindgen_func_elem_13499(arg0, arg1, addHeapObject(arg2));
1071
1178
  }
1072
1179
 
1073
1180
 
1074
1181
  const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
1182
+ const InkWebMessageStreamFinalization = (typeof FinalizationRegistry === 'undefined')
1183
+ ? { register: () => {}, unregister: () => {} }
1184
+ : new FinalizationRegistry(ptr => wasm.__wbg_inkwebmessagestream_free(ptr >>> 0, 1));
1075
1185
  const InkWebViewFinalization = (typeof FinalizationRegistry === 'undefined')
1076
1186
  ? { register: () => {}, unregister: () => {} }
1077
1187
  : new FinalizationRegistry(ptr => wasm.__wbg_inkwebview_free(ptr >>> 0, 1));
Binary file
@@ -1,28 +1,34 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_inkwebmessagestream_free: (a: number, b: number) => void;
4
5
  export const __wbg_inkwebview_free: (a: number, b: number) => void;
5
6
  export const get_version: (a: number) => void;
7
+ export const inkwebmessagestream_close: (a: number) => void;
8
+ export const inkwebmessagestream_write: (a: number, b: number, c: number, d: number) => void;
6
9
  export const inkwebview_bindCanvas: (a: number, b: number, c: number) => void;
7
10
  export const inkwebview_blur: (a: number) => void;
11
+ export const inkwebview_createMessageStream: (a: number, b: number, c: number, d: number, e: number) => number;
8
12
  export const inkwebview_destroy: (a: number) => void;
9
13
  export const inkwebview_dispatchInput: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
14
+ export const inkwebview_dispatchMessageEvent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
10
15
  export const inkwebview_dispatchPointer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
11
16
  export const inkwebview_focus: (a: number) => void;
12
17
  export const inkwebview_isInteractive: (a: number) => number;
13
18
  export const inkwebview_isRunning: (a: number) => number;
14
19
  export const inkwebview_new: (a: number, b: number, c: number) => number;
15
20
  export const inkwebview_notifyUserInteraction: (a: number) => void;
21
+ export const inkwebview_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
16
22
  export const inkwebview_openBundle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
17
23
  export const inkwebview_render: (a: number, b: number) => void;
18
24
  export const inkwebview_resize: (a: number, b: number, c: number, d: number) => void;
19
25
  export const inkwebview_setInteractive: (a: number, b: number) => void;
20
26
  export const main: () => void;
21
- export const __wasm_bindgen_func_elem_9121: (a: number, b: number) => void;
22
- export const __wasm_bindgen_func_elem_13334: (a: number, b: number) => void;
23
- export const __wasm_bindgen_func_elem_9385: (a: number, b: number, c: number) => void;
24
- export const __wasm_bindgen_func_elem_13335: (a: number, b: number, c: number) => void;
25
- export const __wasm_bindgen_func_elem_9383: (a: number, b: number) => void;
27
+ export const __wasm_bindgen_func_elem_9251: (a: number, b: number) => void;
28
+ export const __wasm_bindgen_func_elem_13498: (a: number, b: number) => void;
29
+ export const __wasm_bindgen_func_elem_9547: (a: number, b: number, c: number) => void;
30
+ export const __wasm_bindgen_func_elem_13499: (a: number, b: number, c: number) => void;
31
+ export const __wasm_bindgen_func_elem_9546: (a: number, b: number) => void;
26
32
  export const __wbindgen_export: (a: number, b: number) => number;
27
33
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
28
34
  export const __wbindgen_export3: (a: number) => void;