@yodaos-pkg/ink 0.15.0 → 0.15.1
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 +6 -2
- package/index.d.ts +43 -1
- package/index.js +16 -8
- package/package.json +1 -1
- package/pkg/ink_web.d.ts +4 -4
- package/pkg/ink_web.js +16 -16
- package/pkg/ink_web_bg.wasm +0 -0
- package/pkg/ink_web_bg.wasm.d.ts +4 -4
package/README.md
CHANGED
|
@@ -297,7 +297,11 @@ Binds common DOM events to the current `InkView`.
|
|
|
297
297
|
- The keyboard event target, defaulting to `window` when available
|
|
298
298
|
- `options.focusTarget?: HTMLElement | HTMLCanvasElement | null`
|
|
299
299
|
- Optional
|
|
300
|
-
- The target used for focus
|
|
300
|
+
- The target used for focus synchronization when `syncFocus` is enabled, defaulting to the canvas
|
|
301
|
+
- `options.syncFocus?: boolean`
|
|
302
|
+
- Optional
|
|
303
|
+
- Controls whether DOM `focus` / `blur` and click-to-focus are synchronized into Ink host focus
|
|
304
|
+
- Defaults to `false`
|
|
301
305
|
- `options.preventWheelDefault?: boolean`
|
|
302
306
|
- Optional
|
|
303
307
|
- Controls whether wheel default behavior is prevented
|
|
@@ -308,7 +312,7 @@ Binds common DOM events to the current `InkView`.
|
|
|
308
312
|
- Binds `pointerdown` / `pointermove` / `pointerup` / `pointercancel`
|
|
309
313
|
- Binds `wheel`
|
|
310
314
|
- Binds `keydown` / `keyup`
|
|
311
|
-
-
|
|
315
|
+
- Optionally binds `focus` / `blur` when `syncFocus` is enabled
|
|
312
316
|
- Automatically forwards these browser events into the Ink runtime
|
|
313
317
|
|
|
314
318
|
**Returns**
|
package/index.d.ts
CHANGED
|
@@ -310,8 +310,50 @@ export interface BindDomEventsOptions {
|
|
|
310
310
|
canvas?: HTMLCanvasElement;
|
|
311
311
|
/** Keyboard event target, typically `window`, `document`, or a focusable element. */
|
|
312
312
|
keyboardTarget?: EventTarget | null;
|
|
313
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* DOM element used as the focus signal source when `syncFocus` is enabled.
|
|
315
|
+
*
|
|
316
|
+
* When enabled, Ink listens to this element's native `focus` and `blur`
|
|
317
|
+
* events and forwards them to `inkView.focus()` and `inkView.blur()`.
|
|
318
|
+
* `pointerdown` on the canvas also attempts to call `focus()` on this target.
|
|
319
|
+
*
|
|
320
|
+
* This option is useful when the host does not want the canvas itself to be
|
|
321
|
+
* the browser-focused element. For example, a host may keep keyboard focus on
|
|
322
|
+
* an outer wrapper element while still rendering Ink inside a nested canvas.
|
|
323
|
+
*
|
|
324
|
+
* Important: this follows the target element's own `focus` / `blur` state,
|
|
325
|
+
* not a container-style "focus within" semantic. If focus moves from this
|
|
326
|
+
* element to another focusable node, such as an external `<input>`, Ink will
|
|
327
|
+
* observe that blur when `syncFocus` is enabled.
|
|
328
|
+
*
|
|
329
|
+
* Defaults to the currently bound canvas.
|
|
330
|
+
*/
|
|
314
331
|
focusTarget?: HTMLElement | HTMLCanvasElement | null;
|
|
332
|
+
/**
|
|
333
|
+
* Enables automatic synchronization from browser DOM focus to Ink host focus.
|
|
334
|
+
*
|
|
335
|
+
* When set to `true`, `bindDomEvents()` treats the browser focus state as the
|
|
336
|
+
* source of truth for host focus:
|
|
337
|
+
* - listens to `focusTarget`'s `focus` / `blur` events
|
|
338
|
+
* - calls `inkView.focus()` / `inkView.blur()` automatically
|
|
339
|
+
* - attempts click-to-focus on `pointerdown`
|
|
340
|
+
* - makes the `focusTarget` focusable with `tabindex="0"` when needed
|
|
341
|
+
*
|
|
342
|
+
* When set to `false`, `bindDomEvents()` still binds pointer, wheel, and
|
|
343
|
+
* keyboard events, but it does not change Ink host focus automatically. In
|
|
344
|
+
* that mode, the host should call `inkView.focus()` and `inkView.blur()`
|
|
345
|
+
* explicitly based on product-level lifecycle or visibility state.
|
|
346
|
+
*
|
|
347
|
+
* Recommended usage:
|
|
348
|
+
* - Use `true` only when the host really wants DOM focus to directly control
|
|
349
|
+
* Ink host focus.
|
|
350
|
+
* - Keep `false` when browser focus may temporarily move to another element,
|
|
351
|
+
* such as a sibling or external `<input>`, while the Ink instance should
|
|
352
|
+
* still remain host-focused.
|
|
353
|
+
*
|
|
354
|
+
* Defaults to `false`.
|
|
355
|
+
*/
|
|
356
|
+
syncFocus?: boolean;
|
|
315
357
|
/** Whether wheel events should call `preventDefault()` before forwarding. */
|
|
316
358
|
preventWheelDefault?: boolean;
|
|
317
359
|
}
|
package/index.js
CHANGED
|
@@ -1927,6 +1927,7 @@ export class InkView {
|
|
|
1927
1927
|
|
|
1928
1928
|
const keyboardTarget = options.keyboardTarget || globalThis.window || canvas;
|
|
1929
1929
|
const focusTarget = options.focusTarget || canvas;
|
|
1930
|
+
const syncFocus = options.syncFocus === true;
|
|
1930
1931
|
const listeners = [];
|
|
1931
1932
|
const addListener = (target, type, listener, listenerOptions) => {
|
|
1932
1933
|
if (!target || typeof target.addEventListener !== 'function') {
|
|
@@ -1936,7 +1937,12 @@ export class InkView {
|
|
|
1936
1937
|
listeners.push(() => target.removeEventListener(type, listener, listenerOptions));
|
|
1937
1938
|
};
|
|
1938
1939
|
|
|
1939
|
-
if (
|
|
1940
|
+
if (
|
|
1941
|
+
syncFocus &&
|
|
1942
|
+
focusTarget &&
|
|
1943
|
+
typeof focusTarget.setAttribute === 'function' &&
|
|
1944
|
+
focusTarget.tabIndex < 0
|
|
1945
|
+
) {
|
|
1940
1946
|
focusTarget.setAttribute('tabindex', '0');
|
|
1941
1947
|
}
|
|
1942
1948
|
|
|
@@ -1953,7 +1959,7 @@ export class InkView {
|
|
|
1953
1959
|
addListener(canvas, 'pointerdown', (event) => {
|
|
1954
1960
|
const { x, y } = getPointerPosition(canvas, event);
|
|
1955
1961
|
this.notifyUserInteraction();
|
|
1956
|
-
if (focusTarget && typeof focusTarget.focus === 'function') {
|
|
1962
|
+
if (syncFocus && focusTarget && typeof focusTarget.focus === 'function') {
|
|
1957
1963
|
focusTarget.focus();
|
|
1958
1964
|
}
|
|
1959
1965
|
this.#rawView.dispatchPointer(
|
|
@@ -2037,12 +2043,14 @@ export class InkView {
|
|
|
2037
2043
|
);
|
|
2038
2044
|
this.requestRender();
|
|
2039
2045
|
});
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
+
if (syncFocus) {
|
|
2047
|
+
addListener(focusTarget, 'focus', () => {
|
|
2048
|
+
this.focus();
|
|
2049
|
+
});
|
|
2050
|
+
addListener(focusTarget, 'blur', () => {
|
|
2051
|
+
this.blur();
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2046
2054
|
|
|
2047
2055
|
this.#domCleanup = () => {
|
|
2048
2056
|
for (const dispose of listeners.splice(0)) {
|
package/package.json
CHANGED
package/pkg/ink_web.d.ts
CHANGED
|
@@ -96,10 +96,10 @@ export interface InitOutput {
|
|
|
96
96
|
readonly inkwebview_setTarget: (a: number, b: number, c: number, d: number) => void;
|
|
97
97
|
readonly inkwebview_setViewport: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
98
98
|
readonly start: () => void;
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
99
|
+
readonly __wasm_bindgen_func_elem_14330: (a: number, b: number, c: number, d: number) => void;
|
|
100
|
+
readonly __wasm_bindgen_func_elem_13233: (a: number, b: number, c: number) => void;
|
|
101
|
+
readonly __wasm_bindgen_func_elem_13233_2: (a: number, b: number, c: number) => void;
|
|
102
|
+
readonly __wasm_bindgen_func_elem_13233_3: (a: number, b: number, c: number) => void;
|
|
103
103
|
readonly __wasm_bindgen_func_elem_13234: (a: number, b: number) => void;
|
|
104
104
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
105
105
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
package/pkg/ink_web.js
CHANGED
|
@@ -1370,26 +1370,26 @@ function __wbg_get_imports() {
|
|
|
1370
1370
|
},
|
|
1371
1371
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1372
1372
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3465, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1373
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1373
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_14330);
|
|
1374
1374
|
return addHeapObject(ret);
|
|
1375
1375
|
},
|
|
1376
1376
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1377
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx:
|
|
1378
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1377
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 3376, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1378
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_13233);
|
|
1379
1379
|
return addHeapObject(ret);
|
|
1380
1380
|
},
|
|
1381
1381
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1382
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx:
|
|
1383
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1382
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 3376, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1383
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_13233_2);
|
|
1384
1384
|
return addHeapObject(ret);
|
|
1385
1385
|
},
|
|
1386
1386
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
1387
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx:
|
|
1388
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1387
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 3376, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1388
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_13233_3);
|
|
1389
1389
|
return addHeapObject(ret);
|
|
1390
1390
|
},
|
|
1391
1391
|
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
1392
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
1392
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 3374, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1393
1393
|
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_13234);
|
|
1394
1394
|
return addHeapObject(ret);
|
|
1395
1395
|
},
|
|
@@ -1451,22 +1451,22 @@ function __wasm_bindgen_func_elem_13234(arg0, arg1) {
|
|
|
1451
1451
|
wasm.__wasm_bindgen_func_elem_13234(arg0, arg1);
|
|
1452
1452
|
}
|
|
1453
1453
|
|
|
1454
|
-
function
|
|
1455
|
-
wasm.
|
|
1454
|
+
function __wasm_bindgen_func_elem_13233(arg0, arg1, arg2) {
|
|
1455
|
+
wasm.__wasm_bindgen_func_elem_13233(arg0, arg1, addHeapObject(arg2));
|
|
1456
1456
|
}
|
|
1457
1457
|
|
|
1458
|
-
function
|
|
1459
|
-
wasm.
|
|
1458
|
+
function __wasm_bindgen_func_elem_13233_2(arg0, arg1, arg2) {
|
|
1459
|
+
wasm.__wasm_bindgen_func_elem_13233_2(arg0, arg1, addHeapObject(arg2));
|
|
1460
1460
|
}
|
|
1461
1461
|
|
|
1462
|
-
function
|
|
1463
|
-
wasm.
|
|
1462
|
+
function __wasm_bindgen_func_elem_13233_3(arg0, arg1, arg2) {
|
|
1463
|
+
wasm.__wasm_bindgen_func_elem_13233_3(arg0, arg1, addHeapObject(arg2));
|
|
1464
1464
|
}
|
|
1465
1465
|
|
|
1466
|
-
function
|
|
1466
|
+
function __wasm_bindgen_func_elem_14330(arg0, arg1, arg2) {
|
|
1467
1467
|
try {
|
|
1468
1468
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1469
|
-
wasm.
|
|
1469
|
+
wasm.__wasm_bindgen_func_elem_14330(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1470
1470
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1471
1471
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1472
1472
|
if (r1) {
|
package/pkg/ink_web_bg.wasm
CHANGED
|
Binary file
|
package/pkg/ink_web_bg.wasm.d.ts
CHANGED
|
@@ -41,10 +41,10 @@ export const inkwebview_setLayoutMode: (a: number, b: number, c: number) => void
|
|
|
41
41
|
export const inkwebview_setTarget: (a: number, b: number, c: number, d: number) => void;
|
|
42
42
|
export const inkwebview_setViewport: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
43
43
|
export const start: () => void;
|
|
44
|
-
export const
|
|
45
|
-
export const
|
|
46
|
-
export const
|
|
47
|
-
export const
|
|
44
|
+
export const __wasm_bindgen_func_elem_14330: (a: number, b: number, c: number, d: number) => void;
|
|
45
|
+
export const __wasm_bindgen_func_elem_13233: (a: number, b: number, c: number) => void;
|
|
46
|
+
export const __wasm_bindgen_func_elem_13233_2: (a: number, b: number, c: number) => void;
|
|
47
|
+
export const __wasm_bindgen_func_elem_13233_3: (a: number, b: number, c: number) => void;
|
|
48
48
|
export const __wasm_bindgen_func_elem_13234: (a: number, b: number) => void;
|
|
49
49
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
50
50
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|