@gjsify/dom-elements 0.52.0 → 0.54.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.
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";var FontFace=class{constructor(e,t,n){this.status=`unloaded`,this.display=`auto`,this.style=`normal`,this.weight=`normal`,this.stretch=`normal`,this.unicodeRange=`U+0-10FFFF`,this.variant=`normal`,this.featureSettings=`normal`,this.family=e,this.source=typeof t==`string`?t:`[binary]`,this.loaded=Promise.resolve(this)}_extractFilePath(){let e=this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);return e?e[1].replace(/^file:\/\//,``):null}async load(){this.status=`loading`;let e=this._extractFilePath();if(e)try{let{default:t}=await import(`gi://PangoCairo?version=1.0`);t.font_map_get_default().add_font_file(e)}catch{}return this.status=`loaded`,this}},FontFaceSet=class{constructor(){this.status=`loaded`,this.ready=Promise.resolve(this),this._faces=new Set}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}add(e){return this._faces.add(e),this}delete(e){return this._faces.delete(e)}clear(){this._faces.clear()}has(e){return this._faces.has(e)}check(e,t){return!1}load(e,t){return Promise.resolve([])}forEach(e){this._faces.forEach(t=>e(t,t,this))}values(){return this._faces.values()}keys(){return this._faces.values()}entries(){return Array.from(this._faces).map(e=>[e,e])[Symbol.iterator]()}[Symbol.iterator](){return this._faces[Symbol.iterator]()}get size(){return this._faces.size}};export{FontFace,FontFaceSet};
1
+ import"./_virtual/_rolldown/runtime.js";import{fontMapHasFamily as e,registerFontFaces as t}from"@gjsify/utils/font-map";var FontFace=class{constructor(e,t,n){this.status=`unloaded`,this.display=`auto`,this.style=`normal`,this.weight=`normal`,this.stretch=`normal`,this.unicodeRange=`U+0-10FFFF`,this.variant=`normal`,this.featureSettings=`normal`,this.family=e,this.source=typeof t==`string`?t:`[binary]`,this.loaded=Promise.resolve(this)}_extractFilePath(){let e=this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);return e?e[1].replace(/^file:\/\//,``):null}async load(){this.status=`loading`;let e=this._extractFilePath();if(e){let n=t([e]);n.available&&reportRegistration(this.family,n)}return this.status=`loaded`,this}};function reportRegistration(t,n){for(let e of n.failed)console.warn(`FontFace.load: ${e.path} could not be read as a font (${e.message}), so text asking for "${t}" will render in a substituted one.`);for(let e of n.declined)console.warn(`FontFace.load: no font map in this process would take ${e} — Pango answers a family it does not hold with the default sans, and nothing else says so. A shipped .app reaches its faces through ATSApplicationFontsPath; a bare \`gjsify run\` needs initFonts() first.`);for(let e of n.unreachable)console.warn(`FontFace.load: ${e} is registered and "${t}" is a family this font map holds, but text asking for it will still render in a substituted one: the map had already resolved that family to the fallback, and that cached answer cannot be asked again. Register the face before anything lays text out.`);n.registered.length!==0&&n.map!==void 0&&(e(n.map,t)||console.warn(`FontFace.load: ${n.registered[0]} is registered, but "${t}" is not a family on the font map — it may be registered under a different name, and text asking for it will render in a substituted one.`))}var FontFaceSet=class{constructor(){this.status=`loaded`,this.ready=Promise.resolve(this),this._faces=new Set}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}add(e){return this._faces.add(e),this}delete(e){return this._faces.delete(e)}clear(){this._faces.clear()}has(e){return this._faces.has(e)}check(e,t){return!1}load(e,t){return Promise.resolve([])}forEach(e){this._faces.forEach(t=>e(t,t,this))}values(){return this._faces.values()}keys(){return this._faces.values()}entries(){return Array.from(this._faces).map(e=>[e,e])[Symbol.iterator]()}[Symbol.iterator](){return this._faces[Symbol.iterator]()}get size(){return this._faces.size}};export{FontFace,FontFaceSet};
@@ -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{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{static[Symbol.hasInstance](e){return e===globalThis}};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});
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"@gjsify/dom-events/register/global-event-target";a(`Text`,t),a(`Comment`,e),a(`DocumentFragment`,n),a(`DOMTokenList`,i),a(`document`,r),o(`self`,globalThis);var Window=class{static[Symbol.hasInstance](e){return e===globalThis}};o(`Window`,Window),o(`window`,globalThis),o(`focus`,()=>{}),o(`blur`,()=>{}),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});
@@ -1 +1 @@
1
- globalThis.navigator===void 0&&(globalThis.navigator={});
1
+ import"@gjsify/node-globals/register/navigator";
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -1 +1 @@
1
- export {};
1
+ import '@gjsify/dom-events/register/global-event-target';
@@ -1 +1 @@
1
- export {};
1
+ import '@gjsify/node-globals/register/navigator';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/dom-elements",
3
- "version": "0.52.0",
3
+ "version": "0.54.0",
4
4
  "description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -71,16 +71,20 @@
71
71
  "@girs/gdkpixbuf-2.0": "5.4.0",
72
72
  "@girs/gjs": "5.4.0",
73
73
  "@girs/glib-2.0": "5.4.0",
74
- "@gjsify/abort-controller": "^0.52.0",
75
- "@gjsify/canvas2d-core": "^0.52.0",
76
- "@gjsify/dom-events": "^0.52.0",
77
- "@gjsify/domparser": "^0.52.0",
78
- "@gjsify/fetch": "^0.52.0"
74
+ "@gjsify/abort-controller": "^0.54.0",
75
+ "@gjsify/canvas2d-core": "^0.54.0",
76
+ "@gjsify/dom-events": "^0.54.0",
77
+ "@gjsify/domparser": "^0.54.0",
78
+ "@gjsify/fetch": "^0.54.0",
79
+ "@gjsify/node-globals": "^0.54.0",
80
+ "@gjsify/utils": "^0.54.0"
79
81
  },
80
82
  "devDependencies": {
81
83
  "@girs/gst-1.0": "5.4.0",
82
- "@gjsify/cli": "^0.52.0",
83
- "@gjsify/unit": "^0.52.0",
84
+ "@girs/pango-1.0": "5.4.0",
85
+ "@girs/pangocairo-1.0": "5.4.0",
86
+ "@gjsify/cli": "^0.54.0",
87
+ "@gjsify/unit": "^0.54.0",
84
88
  "@types/node": "^25.9.2",
85
89
  "typescript": "^6.0.3"
86
90
  },
@@ -1 +0,0 @@
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};
@@ -1,24 +0,0 @@
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 `host` and route
11
- * `addEventListener` / `removeEventListener` / `dispatchEvent` through it.
12
- *
13
- * Installs unconditionally, because the bus must be the same object the GTK→DOM bridge dispatches
14
- * on (`@gjsify/event-bridge` `attachEventControllers()` → `getGlobalEventTarget()`) or window-level
15
- * input is lost. Bun and Deno ship a native `globalThis.addEventListener` where GJS and Node do
16
- * not, so an install-only-when-missing guard split the bus there: Excalibur's `Keyboard.init`
17
- * listeners sat on the native EventTarget while the bridge dispatched into a never-installed gjsify
18
- * bus, leaving keyboard input dead on bun/deno with the identical bundle working on gjs/node.
19
- *
20
- * A pre-existing native surface is not discarded — registrations are forwarded to it too, so
21
- * genuinely native events (Deno's 'unload', bun's 'error') still arrive. Dispatch goes to the
22
- * gjsify bus only; the runtime never fires DOM input events globally, so nothing double-fires.
23
- */
24
- export declare function installWindowEventBus(host: WindowEventBusHost): OurEventTarget;