@gjsify/event-bridge 0.54.0 → 0.55.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 +27 -0
- package/lib/esm/key-map.js +1 -1
- package/lib/types/key-map.spec.d.ts +2 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -40,6 +40,33 @@ event stream because `EventControllerMotion` never fires for a finger, and touch
|
|
|
40
40
|
events carry every field a consumer needs to reconstruct pan and pinch, and `@gjsify/dom-events` has no
|
|
41
41
|
`TouchEvent`.
|
|
42
42
|
|
|
43
|
+
### Keyboard mapping (`key-map.ts`)
|
|
44
|
+
|
|
45
|
+
Three rules, each from a defect the plain mapping got wrong:
|
|
46
|
+
|
|
47
|
+
- **A keyval Gdk could not name becomes `key: 'Unidentified'`, `code: ''`** — never Gdk's spelling of it. Gdk answers
|
|
48
|
+
`"0xffffff"` for `GDK_KEY_VoidSymbol` (macOS) and `"U+0010"` for the `0x01000000` private range. Publishing either
|
|
49
|
+
invents a DOM key value, and because *every* unnamed key spells the same string it also folds distinct unidentifiable
|
|
50
|
+
keys into one entry for a consumer that keys held keys by `code` — Excalibur's `Keyboard` does, so a second one is
|
|
51
|
+
swallowed as a duplicate and the first release clears them all.
|
|
52
|
+
- **`code` is the physical position and does not move with a modifier.** Gdk names a shifted keyval after the shifted
|
|
53
|
+
character, so `SHIFTED_KEY_BASENAME` routes `less`→`comma`, `exclam`→`1`, `question`→`slash` and the rest; without it
|
|
54
|
+
Shift+Comma and Comma were two different codes for one key. `Gdk.keyval_to_lower` cannot bridge this — measured, it
|
|
55
|
+
folds letters only and returns `less`/`exclam` unchanged — so it is used only for the one case the tables miss, an
|
|
56
|
+
upper-case letter.
|
|
57
|
+
- **`key`/`location`** come from Gdk's own name table, with printable characters from `keyval_to_unicode`.
|
|
58
|
+
|
|
59
|
+
**macOS: with GTK 4.24.0 the arrow and navigation keys never reach the bridge — upgrade to 4.24.1.** Measured on
|
|
60
|
+
macOS / darwin-arm64 / Homebrew GTK 4.24.0 (`gdk_macos`), gjs 1.88.1: a `Gtk.EventControllerKey` on a
|
|
61
|
+
`PropagationPhase.CAPTURE` controller of the window — the earliest point inside GTK — records **zero** events for
|
|
62
|
+
←/→/↑/↓ and Home/End/PageUp/PageDown, while `a`, `space`, `Return`, `Escape` and every keypad key arrive with correct
|
|
63
|
+
keyvals. The cause is a GTK 4.24.0 regression, not the bridge: `_gdk_macos_display_translate` began with
|
|
64
|
+
`if ([nsevent modifierFlags] & NSEventModifierFlagFunction) return NULL;` (commit `f96ab216`, "do not translate events
|
|
65
|
+
that have the Fn (globe) modifier set"), and macOS flags every arrow/navigation key `Function | NumericPad`
|
|
66
|
+
(`0xa00000`, read from the `NSEvent`), whereas keypad keys carry `NumericPad` alone. GDK handed those key-downs
|
|
67
|
+
straight to AppKit (`doCommandBySelector:` → `moveLeft:`), so no `GdkEvent` was ever made. GTK 4.24.1 and `main` revert
|
|
68
|
+
it (`2a35813a`). Recorded in `status/upstream-patch-candidates.md`.
|
|
69
|
+
|
|
43
70
|
## Design
|
|
44
71
|
|
|
45
72
|
Two pointer sources, deliberately kept apart. Measured on a OnePlus 6T (postmarketOS, GTK 4.22, mutter 48) with
|
package/lib/esm/key-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import e from"gi://Gdk?version=4.0";const t={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},n={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`};function gdkKeyvalToKey(n){let r=e.keyval_name(n);if(r&&t[r])return t[r];let i=e.keyval_to_unicode(n);return i>0?String.fromCodePoint(i):r
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import e from"gi://Gdk?version=4.0";function isNumericGdkName(e){return/^0x[0-9a-f]+$/.test(e)||/^U\+[0-9a-f]{4,6}$/.test(e)}function isUnidentifiedKeyval(t,n){return t===e.KEY_VoidSymbol||n===null||isNumericGdkName(n)}const t={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},n={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`},r={exclam:`1`,at:`2`,numbersign:`3`,dollar:`4`,percent:`5`,asciicircum:`6`,ampersand:`7`,asterisk:`8`,parenleft:`9`,parenright:`0`,underscore:`minus`,plus:`equal`,braceleft:`bracketleft`,bar:`backslash`,braceright:`bracketright`,colon:`semicolon`,quotedbl:`apostrophe`,less:`comma`,greater:`period`,question:`slash`,asciitilde:`grave`},i={minus:`Minus`,equal:`Equal`,bracketleft:`BracketLeft`,bracketright:`BracketRight`,backslash:`Backslash`,semicolon:`Semicolon`,apostrophe:`Quote`,grave:`Backquote`,comma:`Comma`,period:`Period`,slash:`Slash`};function codeFromGdkName(e){if(n[e])return n[e];if(e.length===1&&e>=`a`&&e<=`z`)return`Key${e.toUpperCase()}`;if(e.length===1&&e>=`0`&&e<=`9`)return`Digit${e}`;if(i[e])return i[e];let t=r[e];return t?codeFromGdkName(t):null}function gdkKeyvalToKey(n){let r=e.keyval_name(n);if(isUnidentifiedKeyval(n,r))return`Unidentified`;if(r&&t[r])return t[r];let i=e.keyval_to_unicode(n);return i>0?String.fromCodePoint(i):r}function gdkKeyvalToCode(t){let n=e.keyval_name(t);if(isUnidentifiedKeyval(t,n))return``;let r=codeFromGdkName(n);if(r)return r;let i=e.keyval_to_lower(t);if(i!==t){let t=e.keyval_name(i),n=t===null?null:codeFromGdkName(t);if(n)return n}return``}function gdkKeyvalToLocation(t){let n=e.keyval_name(t);return n?n.startsWith(`KP_`)?3:n.endsWith(`_L`)?1:n.endsWith(`_R`)?2:0:0}export{gdkKeyvalToCode,gdkKeyvalToKey,gdkKeyvalToLocation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/event-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Bridge GTK event controllers to standard DOM events (MouseEvent, KeyboardEvent, etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@girs/glib-2.0": "5.4.0",
|
|
39
39
|
"@girs/graphene-1.0": "5.4.0",
|
|
40
40
|
"@girs/gtk-4.0": "5.4.0",
|
|
41
|
-
"@gjsify/dom-events": "^0.
|
|
41
|
+
"@gjsify/dom-events": "^0.55.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@gjsify/cli": "^0.
|
|
45
|
-
"@gjsify/unit": "^0.
|
|
44
|
+
"@gjsify/cli": "^0.55.0",
|
|
45
|
+
"@gjsify/unit": "^0.55.0",
|
|
46
46
|
"@types/node": "^25.9.2",
|
|
47
47
|
"typescript": "^6.0.3"
|
|
48
48
|
},
|