@yodaos-pkg/ink 0.11.0 → 0.12.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 +47 -0
- package/index.d.ts +19 -0
- package/index.js +26 -0
- package/package.json +1 -1
- package/pkg/ink_web.d.ts +9 -5
- package/pkg/ink_web.js +56 -16
- package/pkg/ink_web_bg.wasm +0 -0
- package/pkg/ink_web_bg.wasm.d.ts +7 -5
package/README.md
CHANGED
|
@@ -208,6 +208,53 @@ Binds common DOM events to the current `InkView`.
|
|
|
208
208
|
- Returns a cleanup function
|
|
209
209
|
- Calling it removes every listener created by this binding call
|
|
210
210
|
|
|
211
|
+
### `view.dispatchVoiceWakeup(keyword, timestamp?)`
|
|
212
|
+
|
|
213
|
+
Dispatches a host voice wakeup event to the current Ink app/page.
|
|
214
|
+
|
|
215
|
+
**Parameters**
|
|
216
|
+
|
|
217
|
+
- `keyword: string`
|
|
218
|
+
- Required
|
|
219
|
+
- The wakeup keyword exposed to Ink as `event.keyword`
|
|
220
|
+
- `timestamp?: number`
|
|
221
|
+
- Optional
|
|
222
|
+
- Event timestamp in milliseconds
|
|
223
|
+
- Defaults to `Date.now()`
|
|
224
|
+
|
|
225
|
+
**What it does**
|
|
226
|
+
|
|
227
|
+
- Forwards a cancelable `voice.wakeup` event into the Ink runtime
|
|
228
|
+
- Reaches app/page listeners as `voicewakeup` / `onVoiceWakeup`
|
|
229
|
+
- Automatically triggers a render request
|
|
230
|
+
|
|
231
|
+
**Returns**
|
|
232
|
+
|
|
233
|
+
- `boolean`
|
|
234
|
+
- `true` when the event is not canceled
|
|
235
|
+
- `false` when Ink handles the event and calls `preventDefault()`
|
|
236
|
+
|
|
237
|
+
### `view.dispatchConnectivityEvent(status)`
|
|
238
|
+
|
|
239
|
+
Dispatches a host connectivity update to the current Ink app/page.
|
|
240
|
+
|
|
241
|
+
**Parameters**
|
|
242
|
+
|
|
243
|
+
- `status: 'online' | 'offline'`
|
|
244
|
+
- Required
|
|
245
|
+
- The connectivity state exposed to Ink as a `networkstatus` event
|
|
246
|
+
|
|
247
|
+
**What it does**
|
|
248
|
+
|
|
249
|
+
- Forwards a host connectivity update into the Ink runtime
|
|
250
|
+
- Reaches app/page listeners as `networkstatus` / `onNetworkStatus`
|
|
251
|
+
- Automatically triggers a render request
|
|
252
|
+
|
|
253
|
+
**Returns**
|
|
254
|
+
|
|
255
|
+
- `InkView`
|
|
256
|
+
- Returns the current instance so it can be chained
|
|
257
|
+
|
|
211
258
|
### `view.dispatchMessageEvent(dataOrJson, origin?, lastEventId?)`
|
|
212
259
|
|
|
213
260
|
Dispatches a one-shot host message to the current Ink page.
|
package/index.d.ts
CHANGED
|
@@ -69,6 +69,9 @@ export interface CreateInkViewOptions {
|
|
|
69
69
|
/** Cross-platform layout mode exposed by browser hosts. */
|
|
70
70
|
export type InkLayoutMode = 'bounded' | 'width-constrained-auto-height';
|
|
71
71
|
|
|
72
|
+
/** Connectivity states accepted by {@link InkView.dispatchConnectivityEvent}. */
|
|
73
|
+
export type InkConnectivityStatus = 'online' | 'offline';
|
|
74
|
+
|
|
72
75
|
/**
|
|
73
76
|
* Optional resize-time overrides applied atomically with the new viewport size.
|
|
74
77
|
*
|
|
@@ -736,6 +739,22 @@ export declare class InkView {
|
|
|
736
739
|
/** Forwards a keyboard/input event directly into the current Ink view. */
|
|
737
740
|
dispatchInput(eventType: string, code: string, timestamp?: number): this;
|
|
738
741
|
|
|
742
|
+
/**
|
|
743
|
+
* Dispatches a host voice wakeup event into the current Ink app/page.
|
|
744
|
+
*
|
|
745
|
+
* Returns `true` when the event is not canceled, including when the runtime
|
|
746
|
+
* skips dispatch because the view is non-interactive. Returns `false` when a
|
|
747
|
+
* dispatched cancelable event is prevented inside Ink.
|
|
748
|
+
*/
|
|
749
|
+
dispatchVoiceWakeup(keyword: string, timestamp?: number): boolean;
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Dispatches a host connectivity state change to the current Ink app/page.
|
|
753
|
+
*
|
|
754
|
+
* Ink maps this into `networkstatus` / `onNetworkStatus` listeners.
|
|
755
|
+
*/
|
|
756
|
+
dispatchConnectivityEvent(status: InkConnectivityStatus): this;
|
|
757
|
+
|
|
739
758
|
/**
|
|
740
759
|
* Dispatches a one-shot host message to the current Ink page.
|
|
741
760
|
*
|
package/index.js
CHANGED
|
@@ -326,6 +326,17 @@ function normalizeHostMessageMetadata(origin, lastEventId) {
|
|
|
326
326
|
return { origin, lastEventId };
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
function normalizeConnectivityStatus(status) {
|
|
330
|
+
if (typeof status !== 'string') {
|
|
331
|
+
throw new TypeError('`status` must be a string.');
|
|
332
|
+
}
|
|
333
|
+
const normalized = status.trim().toLowerCase();
|
|
334
|
+
if (normalized !== 'online' && normalized !== 'offline') {
|
|
335
|
+
throw new TypeError('`status` must be either `online` or `offline`.');
|
|
336
|
+
}
|
|
337
|
+
return normalized;
|
|
338
|
+
}
|
|
339
|
+
|
|
329
340
|
function normalizeHostMessagePayload(dataOrJson) {
|
|
330
341
|
if (typeof dataOrJson === 'string') {
|
|
331
342
|
try {
|
|
@@ -1711,6 +1722,21 @@ export class InkView {
|
|
|
1711
1722
|
return this;
|
|
1712
1723
|
}
|
|
1713
1724
|
|
|
1725
|
+
dispatchVoiceWakeup(keyword, timestamp = Date.now()) {
|
|
1726
|
+
if (typeof keyword !== 'string' || !keyword.trim()) {
|
|
1727
|
+
throw new TypeError('`keyword` must be a non-empty string.');
|
|
1728
|
+
}
|
|
1729
|
+
const handled = this.#rawView.dispatchVoiceWakeup(keyword, Number(timestamp));
|
|
1730
|
+
this.requestRender();
|
|
1731
|
+
return handled !== false;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
dispatchConnectivityEvent(status) {
|
|
1735
|
+
this.#rawView.dispatchConnectivityEvent(normalizeConnectivityStatus(status));
|
|
1736
|
+
this.requestRender();
|
|
1737
|
+
return this;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1714
1740
|
dispatchMessageEvent(dataOrJson, origin = 'host', lastEventId = '') {
|
|
1715
1741
|
const metadata = normalizeHostMessageMetadata(origin, lastEventId);
|
|
1716
1742
|
this.#rawView.dispatchMessageEvent(
|
package/package.json
CHANGED
package/pkg/ink_web.d.ts
CHANGED
|
@@ -24,10 +24,12 @@ export class InkWebView {
|
|
|
24
24
|
currentContentHeight(): number;
|
|
25
25
|
currentContentWidth(): number;
|
|
26
26
|
destroy(): void;
|
|
27
|
+
dispatchConnectivityEvent(status: string): void;
|
|
27
28
|
dispatchHostCapabilityEvent(event_json: string): void;
|
|
28
29
|
dispatchInput(event_type: string, code: string, timestamp: number): void;
|
|
29
30
|
dispatchMessageEvent(payload_json: string, origin: string, last_event_id: string): void;
|
|
30
31
|
dispatchPointer(event_type: string, x: number, y: number, id: number, button: number, delta_x: number, delta_y: number): void;
|
|
32
|
+
dispatchVoiceWakeup(keyword: string, timestamp: number): boolean;
|
|
31
33
|
focus(): void;
|
|
32
34
|
isInteractive(): boolean;
|
|
33
35
|
isRunning(): boolean;
|
|
@@ -68,10 +70,12 @@ export interface InitOutput {
|
|
|
68
70
|
readonly inkwebview_currentContentHeight: (a: number) => number;
|
|
69
71
|
readonly inkwebview_currentContentWidth: (a: number) => number;
|
|
70
72
|
readonly inkwebview_destroy: (a: number) => void;
|
|
73
|
+
readonly inkwebview_dispatchConnectivityEvent: (a: number, b: number, c: number, d: number) => void;
|
|
71
74
|
readonly inkwebview_dispatchHostCapabilityEvent: (a: number, b: number, c: number, d: number) => void;
|
|
72
75
|
readonly inkwebview_dispatchInput: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
73
76
|
readonly inkwebview_dispatchMessageEvent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
74
77
|
readonly inkwebview_dispatchPointer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
78
|
+
readonly inkwebview_dispatchVoiceWakeup: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
75
79
|
readonly inkwebview_focus: (a: number) => void;
|
|
76
80
|
readonly inkwebview_isInteractive: (a: number) => number;
|
|
77
81
|
readonly inkwebview_isRunning: (a: number) => number;
|
|
@@ -86,11 +90,11 @@ export interface InitOutput {
|
|
|
86
90
|
readonly inkwebview_setLayoutMode: (a: number, b: number, c: number) => void;
|
|
87
91
|
readonly inkwebview_setViewport: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
88
92
|
readonly start: () => void;
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
93
|
-
readonly
|
|
93
|
+
readonly __wasm_bindgen_func_elem_10267: (a: number, b: number) => void;
|
|
94
|
+
readonly __wasm_bindgen_func_elem_14723: (a: number, b: number) => void;
|
|
95
|
+
readonly __wasm_bindgen_func_elem_10386: (a: number, b: number, c: number) => void;
|
|
96
|
+
readonly __wasm_bindgen_func_elem_14724: (a: number, b: number, c: number) => void;
|
|
97
|
+
readonly __wasm_bindgen_func_elem_10385: (a: number, b: number) => void;
|
|
94
98
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
95
99
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
96
100
|
readonly __wbindgen_export3: (a: number) => void;
|
package/pkg/ink_web.js
CHANGED
|
@@ -164,6 +164,24 @@ export class InkWebView {
|
|
|
164
164
|
destroy() {
|
|
165
165
|
wasm.inkwebview_destroy(this.__wbg_ptr);
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* @param {string} status
|
|
169
|
+
*/
|
|
170
|
+
dispatchConnectivityEvent(status) {
|
|
171
|
+
try {
|
|
172
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
173
|
+
const ptr0 = passStringToWasm0(status, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
wasm.inkwebview_dispatchConnectivityEvent(retptr, this.__wbg_ptr, ptr0, len0);
|
|
176
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
177
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
178
|
+
if (r1) {
|
|
179
|
+
throw takeObject(r0);
|
|
180
|
+
}
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
167
185
|
/**
|
|
168
186
|
* @param {string} event_json
|
|
169
187
|
*/
|
|
@@ -252,6 +270,28 @@ export class InkWebView {
|
|
|
252
270
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
253
271
|
}
|
|
254
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* @param {string} keyword
|
|
275
|
+
* @param {number} timestamp
|
|
276
|
+
* @returns {boolean}
|
|
277
|
+
*/
|
|
278
|
+
dispatchVoiceWakeup(keyword, timestamp) {
|
|
279
|
+
try {
|
|
280
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
281
|
+
const ptr0 = passStringToWasm0(keyword, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
283
|
+
wasm.inkwebview_dispatchVoiceWakeup(retptr, this.__wbg_ptr, ptr0, len0, timestamp);
|
|
284
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
285
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
286
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
287
|
+
if (r2) {
|
|
288
|
+
throw takeObject(r1);
|
|
289
|
+
}
|
|
290
|
+
return r0 !== 0;
|
|
291
|
+
} finally {
|
|
292
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
255
295
|
focus() {
|
|
256
296
|
wasm.inkwebview_focus(this.__wbg_ptr);
|
|
257
297
|
}
|
|
@@ -1233,28 +1273,28 @@ function __wbg_get_imports() {
|
|
|
1233
1273
|
return ret;
|
|
1234
1274
|
},
|
|
1235
1275
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1236
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1237
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1276
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 2719, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 2695, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1277
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_10267, __wasm_bindgen_func_elem_10386);
|
|
1238
1278
|
return addHeapObject(ret);
|
|
1239
1279
|
},
|
|
1240
1280
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1241
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1242
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1281
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 2719, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2695, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1282
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_10267, __wasm_bindgen_func_elem_10386);
|
|
1243
1283
|
return addHeapObject(ret);
|
|
1244
1284
|
},
|
|
1245
1285
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1246
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1247
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1286
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 2719, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 2695, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1287
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_10267, __wasm_bindgen_func_elem_10386);
|
|
1248
1288
|
return addHeapObject(ret);
|
|
1249
1289
|
},
|
|
1250
1290
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
1251
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1252
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1291
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 2719, function: Function { arguments: [], shim_idx: 2720, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1292
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_10267, __wasm_bindgen_func_elem_10385);
|
|
1253
1293
|
return addHeapObject(ret);
|
|
1254
1294
|
},
|
|
1255
1295
|
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
1256
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1257
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1296
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3639, function: Function { arguments: [Externref], shim_idx: 3640, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1297
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_14723, __wasm_bindgen_func_elem_14724);
|
|
1258
1298
|
return addHeapObject(ret);
|
|
1259
1299
|
},
|
|
1260
1300
|
__wbindgen_cast_0000000000000006: function(arg0) {
|
|
@@ -1311,16 +1351,16 @@ function __wbg_get_imports() {
|
|
|
1311
1351
|
};
|
|
1312
1352
|
}
|
|
1313
1353
|
|
|
1314
|
-
function
|
|
1315
|
-
wasm.
|
|
1354
|
+
function __wasm_bindgen_func_elem_10385(arg0, arg1) {
|
|
1355
|
+
wasm.__wasm_bindgen_func_elem_10385(arg0, arg1);
|
|
1316
1356
|
}
|
|
1317
1357
|
|
|
1318
|
-
function
|
|
1319
|
-
wasm.
|
|
1358
|
+
function __wasm_bindgen_func_elem_10386(arg0, arg1, arg2) {
|
|
1359
|
+
wasm.__wasm_bindgen_func_elem_10386(arg0, arg1, addHeapObject(arg2));
|
|
1320
1360
|
}
|
|
1321
1361
|
|
|
1322
|
-
function
|
|
1323
|
-
wasm.
|
|
1362
|
+
function __wasm_bindgen_func_elem_14724(arg0, arg1, arg2) {
|
|
1363
|
+
wasm.__wasm_bindgen_func_elem_14724(arg0, arg1, addHeapObject(arg2));
|
|
1324
1364
|
}
|
|
1325
1365
|
|
|
1326
1366
|
|
package/pkg/ink_web_bg.wasm
CHANGED
|
Binary file
|
package/pkg/ink_web_bg.wasm.d.ts
CHANGED
|
@@ -18,10 +18,12 @@ export const inkwebview_currentClosedSource: (a: number, b: number) => void;
|
|
|
18
18
|
export const inkwebview_currentContentHeight: (a: number) => number;
|
|
19
19
|
export const inkwebview_currentContentWidth: (a: number) => number;
|
|
20
20
|
export const inkwebview_destroy: (a: number) => void;
|
|
21
|
+
export const inkwebview_dispatchConnectivityEvent: (a: number, b: number, c: number, d: number) => void;
|
|
21
22
|
export const inkwebview_dispatchHostCapabilityEvent: (a: number, b: number, c: number, d: number) => void;
|
|
22
23
|
export const inkwebview_dispatchInput: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
23
24
|
export const inkwebview_dispatchMessageEvent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
24
25
|
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;
|
|
26
|
+
export const inkwebview_dispatchVoiceWakeup: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
25
27
|
export const inkwebview_focus: (a: number) => void;
|
|
26
28
|
export const inkwebview_isInteractive: (a: number) => number;
|
|
27
29
|
export const inkwebview_isRunning: (a: number) => number;
|
|
@@ -36,11 +38,11 @@ export const inkwebview_setInteractive: (a: number, b: number) => void;
|
|
|
36
38
|
export const inkwebview_setLayoutMode: (a: number, b: number, c: number) => void;
|
|
37
39
|
export const inkwebview_setViewport: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
38
40
|
export const start: () => void;
|
|
39
|
-
export const
|
|
40
|
-
export const
|
|
41
|
-
export const
|
|
42
|
-
export const
|
|
43
|
-
export const
|
|
41
|
+
export const __wasm_bindgen_func_elem_10267: (a: number, b: number) => void;
|
|
42
|
+
export const __wasm_bindgen_func_elem_14723: (a: number, b: number) => void;
|
|
43
|
+
export const __wasm_bindgen_func_elem_10386: (a: number, b: number, c: number) => void;
|
|
44
|
+
export const __wasm_bindgen_func_elem_14724: (a: number, b: number, c: number) => void;
|
|
45
|
+
export const __wasm_bindgen_func_elem_10385: (a: number, b: number) => void;
|
|
44
46
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
45
47
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
46
48
|
export const __wbindgen_export3: (a: number) => void;
|