@gjsify/dom-elements 0.24.2 → 0.25.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{Comment as e}from"../comment.js";import{Text as t}from"../text.js";import{DocumentFragment as n}from"../document-fragment.js";import{document as r}from"../document.js";import{DOMTokenList as i}from"../dom-token-list.js";import{defineGlobal as a,defineGlobalIfMissing as o}from"./helpers.js";import{
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Comment as e}from"../comment.js";import{Text as t}from"../text.js";import{DocumentFragment as n}from"../document-fragment.js";import{document as r}from"../document.js";import{DOMTokenList as i}from"../dom-token-list.js";import{defineGlobal as a,defineGlobalIfMissing as o}from"./helpers.js";import{installWindowEventBus as s}from"./window-event-bus.js";a(`Text`,t),a(`Comment`,e),a(`DocumentFragment`,n),a(`DOMTokenList`,i),a(`document`,r),o(`self`,globalThis);var Window=class{};o(`Window`,Window),o(`window`,globalThis),o(`focus`,()=>{}),o(`blur`,()=>{}),s(globalThis),o(`devicePixelRatio`,1),o(`scrollX`,0),o(`scrollY`,0),o(`pageXOffset`,0),o(`pageYOffset`,0),o(`alert`,(...e)=>console.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{EventTarget as e}from"@gjsify/dom-events";function installWindowEventBus(t){if(t.__gjsify_globalEventTarget)return t.__gjsify_globalEventTarget;let n=new e,r=typeof t.addEventListener==`function`?t.addEventListener.bind(t):null,i=typeof t.removeEventListener==`function`?t.removeEventListener.bind(t):null;t.__gjsify_globalEventTarget=n;let define=(e,n)=>Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0});return define(`addEventListener`,(e,t,i)=>{n.addEventListener(e,t,i),r?.(e,t,i)}),define(`removeEventListener`,(e,t,r)=>{n.removeEventListener(e,t,r),i?.(e,t,r)}),define(`dispatchEvent`,e=>n.dispatchEvent(e)),n}export{installWindowEventBus};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventTarget as OurEventTarget } from '@gjsify/dom-events';
|
|
2
|
+
/** Structural view of the window-scope event-target surface on a global-like host. */
|
|
3
|
+
export interface WindowEventBusHost {
|
|
4
|
+
__gjsify_globalEventTarget?: OurEventTarget;
|
|
5
|
+
addEventListener?: (type: string, listener: unknown, options?: unknown) => void;
|
|
6
|
+
removeEventListener?: (type: string, listener: unknown, options?: unknown) => void;
|
|
7
|
+
dispatchEvent?: (event: unknown) => boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Install the gjsify window-scope event bus (`__gjsify_globalEventTarget`) on
|
|
11
|
+
* `host` and route `addEventListener` / `removeEventListener` /
|
|
12
|
+
* `dispatchEvent` through it.
|
|
13
|
+
*
|
|
14
|
+
* UNCONDITIONAL BY DESIGN (idempotent via the singleton check): loading this
|
|
15
|
+
* register declares a GTK-hosted DOM environment, so the window-scope bus MUST
|
|
16
|
+
* be the same object the GTK→DOM event-bridge dispatches on
|
|
17
|
+
* (`@gjsify/event-bridge` `attachEventControllers()` → `getGlobalEventTarget()`),
|
|
18
|
+
* or window-level input is lost. Bun and Deno ship a NATIVE
|
|
19
|
+
* `globalThis.addEventListener` (GJS and Node do not) — the previous
|
|
20
|
+
* "only install when missing" guard therefore SPLIT the bus on those runtimes:
|
|
21
|
+
* app listeners (e.g. Excalibur `Keyboard.init`'s 'keydown'/'keyup'/'blur')
|
|
22
|
+
* registered on the native runtime EventTarget while the event-bridge
|
|
23
|
+
* dispatched into the never-installed gjsify bus — keyboard input silently
|
|
24
|
+
* dead on bun/deno while the identical bundle worked on gjs/node (measured on
|
|
25
|
+
* showcases/dom/excalibur-jelly-jumper: focus + controller attachment healthy,
|
|
26
|
+
* `__gjsify_globalEventTarget` undefined, Excalibur received no keys).
|
|
27
|
+
*
|
|
28
|
+
* A pre-existing native surface is not discarded: registrations are ALSO
|
|
29
|
+
* forwarded to it, so genuinely native runtime events (Deno's 'unload' /
|
|
30
|
+
* 'beforeunload', bun's 'error') still reach listeners registered through the
|
|
31
|
+
* window surface. Dispatches go to the gjsify bus only — each event type fires
|
|
32
|
+
* from exactly one side (the runtime never fires DOM input events globally),
|
|
33
|
+
* so nothing double-fires.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installWindowEventBus(host: WindowEventBusHost): OurEventTarget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/dom-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"@girs/gdkpixbuf-2.0": "^4.1.0",
|
|
72
72
|
"@girs/gjs": "^4.1.0",
|
|
73
73
|
"@girs/glib-2.0": "^4.1.0",
|
|
74
|
-
"@gjsify/abort-controller": "^0.
|
|
75
|
-
"@gjsify/canvas2d-core": "^0.
|
|
76
|
-
"@gjsify/dom-events": "^0.
|
|
77
|
-
"@gjsify/fetch": "^0.
|
|
74
|
+
"@gjsify/abort-controller": "^0.25.1",
|
|
75
|
+
"@gjsify/canvas2d-core": "^0.25.1",
|
|
76
|
+
"@gjsify/dom-events": "^0.25.1",
|
|
77
|
+
"@gjsify/fetch": "^0.25.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@girs/gst-1.0": "^4.1.0",
|
|
81
|
-
"@gjsify/cli": "^0.
|
|
82
|
-
"@gjsify/unit": "^0.
|
|
81
|
+
"@gjsify/cli": "^0.25.1",
|
|
82
|
+
"@gjsify/unit": "^0.25.1",
|
|
83
83
|
"@types/node": "^25.9.2",
|
|
84
84
|
"typescript": "^6.0.3"
|
|
85
85
|
},
|