@gjsify/dom-elements 0.36.0 → 0.37.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/globals.mjs +3 -7
- package/lib/types/font-face.d.ts +3 -6
- package/lib/types/gst-time.d.ts +4 -9
- package/lib/types/html-canvas-element.d.ts +8 -18
- package/lib/types/image.d.ts +2 -9
- package/lib/types/intersection-observer.d.ts +2 -2
- package/lib/types/mutation-observer.d.ts +2 -3
- package/lib/types/notify-resize.d.ts +2 -7
- package/lib/types/register/window-event-bus.d.ts +11 -22
- package/lib/types/resize-observer.d.ts +7 -24
- package/lib/types/types/i-html-image-element.d.ts +3 -14
- package/lib/types/types/image-data.d.ts +4 -4
- package/package.json +7 -7
package/globals.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* resolver routes `@gjsify/dom-elements` here on `--app browser` because
|
|
6
|
-
* `package.json#gjsify.runtimes.browser === "native"`.
|
|
7
|
-
*
|
|
8
|
-
* NOT used on Node (`runtimes.node` is `"none"` — Node has no DOM).
|
|
2
|
+
* Native DOM globals for browser builds: the resolver routes `@gjsify/dom-elements` here on
|
|
3
|
+
* `--app browser` because `package.json#gjsify.runtimes.browser` is `"native"`. There is no Node
|
|
4
|
+
* counterpart — `runtimes.node` is `"none"`, Node having no DOM.
|
|
9
5
|
*/
|
|
10
6
|
|
|
11
7
|
export const Node = globalThis.Node;
|
package/lib/types/font-face.d.ts
CHANGED
|
@@ -15,13 +15,10 @@ export declare class FontFace {
|
|
|
15
15
|
load(): Promise<FontFace>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Tracks loaded FontFace objects and exposes them to consumers.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* yet exist when this class is defined at module load time. All event methods
|
|
23
|
-
* are provided as no-ops; consumers that call addEventListener('loadingdone')
|
|
24
|
-
* etc. will silently receive nothing.
|
|
20
|
+
* Does not extend EventTarget: the event methods are no-ops, so a consumer listening for
|
|
21
|
+
* 'loadingdone' silently receives nothing.
|
|
25
22
|
*/
|
|
26
23
|
export declare class FontFaceSet {
|
|
27
24
|
status: 'loading' | 'loaded';
|
package/lib/types/gst-time.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert seconds (number) to GStreamer nanoseconds (bigint).
|
|
3
|
-
* Rounds to the nearest nanosecond to avoid floating-point drift over
|
|
4
|
-
* repeated back-and-forth conversions.
|
|
5
|
-
*/
|
|
1
|
+
/** Seconds to GStreamer nanoseconds, rounded to avoid drift over repeated round-trips. */
|
|
6
2
|
export declare function secondsToGstTime(seconds: number): bigint;
|
|
7
3
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `gint64` return values in `query_position` / `query_duration`).
|
|
4
|
+
* GStreamer nanoseconds to seconds. Accepts `number` as well as `bigint` because the
|
|
5
|
+
* `@girs/gst-1.0` typings declare `gint64` returns as `number` (`query_position` /
|
|
6
|
+
* `query_duration`), while the runtime hands back a `bigint`.
|
|
12
7
|
*/
|
|
13
8
|
export declare function gstTimeToSeconds(nanoseconds: bigint | number): number;
|
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
import { HTMLElement } from './html-element.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* This is a DOM-spec-compliant stub. The GTK-backed implementation lives in
|
|
6
|
-
* `@gjsify/webgl` and extends this class, overriding `getContext()`.
|
|
3
|
+
* A DOM-spec-compliant canvas with no rendering of its own. `@gjsify/webgl` extends it with a
|
|
4
|
+
* `Gtk.GLArea`-backed `getContext()` override.
|
|
7
5
|
*
|
|
8
6
|
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement
|
|
9
7
|
*/
|
|
10
8
|
export declare class HTMLCanvasElement extends HTMLElement {
|
|
11
9
|
private static _contextFactories;
|
|
12
|
-
/**
|
|
13
|
-
* Register a rendering context factory for a given context type.
|
|
14
|
-
* Called by packages like @gjsify/canvas2d and @gjsify/webgl to plug in their implementations.
|
|
15
|
-
*/
|
|
16
10
|
static registerContextFactory(contextId: string, factory: (canvas: HTMLCanvasElement, options?: unknown) => unknown): void;
|
|
17
11
|
oncontextlost: ((ev: Event) => unknown) | null;
|
|
18
12
|
oncontextrestored: ((ev: Event) => unknown) | null;
|
|
19
13
|
onwebglcontextcreationerror: ((ev: Event) => unknown) | null;
|
|
20
14
|
onwebglcontextlost: ((ev: Event) => unknown) | null;
|
|
21
15
|
onwebglcontextrestored: ((ev: Event) => unknown) | null;
|
|
22
|
-
/**
|
|
16
|
+
/** Defaults to 300 when the attribute is absent, per spec. */
|
|
23
17
|
get width(): number;
|
|
24
18
|
set width(value: number);
|
|
25
|
-
/**
|
|
19
|
+
/** Defaults to 150 when the attribute is absent, per spec. */
|
|
26
20
|
get height(): number;
|
|
27
21
|
set height(value: number);
|
|
28
|
-
/**
|
|
29
|
-
* Returns a rendering context.
|
|
30
|
-
* Checks the static context factory registry for a matching factory.
|
|
31
|
-
* Subclasses (e.g. @gjsify/webgl) may override and fall through via super.getContext().
|
|
32
|
-
*/
|
|
22
|
+
/** `null` for any context type with no registered factory. */
|
|
33
23
|
getContext(contextId: string, options?: unknown): unknown;
|
|
34
|
-
/**
|
|
24
|
+
/** Empty string unless a 2D context is active — the pixels live in that context's surface. */
|
|
35
25
|
toDataURL(type?: string, quality?: unknown): string;
|
|
36
|
-
/**
|
|
26
|
+
/** Calls back with `null` when there is no 2D context to read pixels from. */
|
|
37
27
|
toBlob(callback: (blob: Blob | null) => void, type?: string, quality?: unknown): void;
|
|
38
|
-
/**
|
|
28
|
+
/** Stub: the returned object is not a usable MediaStream. */
|
|
39
29
|
captureStream(_frameRequestRate?: number): Record<string, never>;
|
|
40
30
|
}
|
package/lib/types/image.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { HTMLImageElement } from './html-image-element.js';
|
|
2
2
|
/**
|
|
3
|
-
* Image
|
|
3
|
+
* The `Image` constructor form of HTMLImageElement.
|
|
4
4
|
*
|
|
5
|
-
* Reference:
|
|
6
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image.
|
|
5
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image
|
|
7
6
|
*/
|
|
8
7
|
export default class Image extends HTMLImageElement {
|
|
9
|
-
/**
|
|
10
|
-
* Constructor.
|
|
11
|
-
*
|
|
12
|
-
* @param [width] Width.
|
|
13
|
-
* @param [height] Height.
|
|
14
|
-
*/
|
|
15
8
|
constructor(width?: number | null, height?: number | null);
|
|
16
9
|
}
|
|
17
10
|
export { HTMLImageElement, Image };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Element } from './element.js';
|
|
2
2
|
/**
|
|
3
|
-
* IntersectionObserver
|
|
4
|
-
*
|
|
3
|
+
* Tracks no intersections. It exists because many libraries check for `IntersectionObserver` and
|
|
4
|
+
* crash without it.
|
|
5
5
|
*
|
|
6
6
|
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
|
|
7
7
|
*/
|
|
@@ -9,9 +9,8 @@ interface MutationObserverOptions {
|
|
|
9
9
|
attributeFilter?: string[];
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Does not actually observe DOM mutations (no layout engine).
|
|
12
|
+
* Observes nothing — there is no layout engine to observe. It exists because many libraries check
|
|
13
|
+
* for `MutationObserver` and crash without it.
|
|
15
14
|
*
|
|
16
15
|
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
17
16
|
*/
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Element } from './element.js';
|
|
2
2
|
/**
|
|
3
|
-
* Notify every `ResizeObserver` subscribed to `target` — or to any
|
|
4
|
-
*
|
|
5
|
-
* changed. Called from framework bridges' GTK `resize` signal handlers.
|
|
6
|
-
*
|
|
7
|
-
* @param target the polyfill DOM element paired with the resized widget
|
|
8
|
-
* @param width the widget's new allocated width (CSS pixels)
|
|
9
|
-
* @param height the widget's new allocated height (CSS pixels)
|
|
3
|
+
* Notify every `ResizeObserver` subscribed to `target` — or to any ancestor of `target` —
|
|
4
|
+
* that the backing widget's allocation just changed. Dimensions are CSS pixels.
|
|
10
5
|
*/
|
|
11
6
|
export declare function notifyElementResize(target: Element, width: number, height: number): void;
|
|
@@ -7,29 +7,18 @@ export interface WindowEventBusHost {
|
|
|
7
7
|
dispatchEvent?: (event: unknown) => boolean;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Install the gjsify window-scope event bus (`__gjsify_globalEventTarget`) on
|
|
11
|
-
* `
|
|
12
|
-
* `dispatchEvent` through it.
|
|
10
|
+
* Install the gjsify window-scope event bus (`__gjsify_globalEventTarget`) on `host` and route
|
|
11
|
+
* `addEventListener` / `removeEventListener` / `dispatchEvent` through it.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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).
|
|
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.
|
|
27
19
|
*
|
|
28
|
-
* A pre-existing native surface is not discarded
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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.
|
|
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.
|
|
34
23
|
*/
|
|
35
24
|
export declare function installWindowEventBus(host: WindowEventBusHost): OurEventTarget;
|
|
@@ -28,22 +28,9 @@ export interface ResizeObserverOptions {
|
|
|
28
28
|
box?: 'content-box' | 'border-box' | 'device-pixel-content-box';
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* `ResizeObserver` polyfill. Subscribes to bridge-reported GTK widget
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* subscribers on the resized element and every ancestor.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```ts
|
|
38
|
-
* const observer = new ResizeObserver((entries) => {
|
|
39
|
-
* for (const entry of entries) {
|
|
40
|
-
* console.log(entry.target, entry.contentRect.width, entry.contentRect.height);
|
|
41
|
-
* }
|
|
42
|
-
* });
|
|
43
|
-
* observer.observe(canvas); // canvas paired with a Gtk.GLArea by WebGLBridge
|
|
44
|
-
* // resize the GTK widget → callback fires with the new dimensions
|
|
45
|
-
* observer.disconnect();
|
|
46
|
-
* ```
|
|
31
|
+
* `ResizeObserver` polyfill. Subscribes to bridge-reported GTK widget resizes through
|
|
32
|
+
* `Element._onResize()`; `notifyElementResize()` fires those subscribers on the resized element and
|
|
33
|
+
* every ancestor.
|
|
47
34
|
*/
|
|
48
35
|
export declare class ResizeObserver {
|
|
49
36
|
private readonly _callback;
|
|
@@ -51,14 +38,10 @@ export declare class ResizeObserver {
|
|
|
51
38
|
private _pending;
|
|
52
39
|
constructor(callback: ResizeObserverCallback);
|
|
53
40
|
/**
|
|
54
|
-
* Start observing `target`.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* `opts.box` is accepted for spec compatibility but does not change
|
|
60
|
-
* behaviour here — content-box, border-box, and device-pixel-content-box
|
|
61
|
-
* all map to the same single allocation reported by GTK.
|
|
41
|
+
* Start observing `target`. The spec's mandatory first observation of the current size is
|
|
42
|
+
* deferred to a microtask, so a consumer observing inside an init routine gets that measurement
|
|
43
|
+
* after its setup completes. `opts.box` is accepted for compatibility but changes nothing: all
|
|
44
|
+
* three box modes map to the single allocation GTK reports.
|
|
62
45
|
*/
|
|
63
46
|
observe(target: Element, _opts?: ResizeObserverOptions): void;
|
|
64
47
|
unobserve(target: Element): void;
|
|
@@ -2,8 +2,7 @@ import type { HTMLElement } from '@gjsify/dom-elements';
|
|
|
2
2
|
/**
|
|
3
3
|
* HTML Image Element.
|
|
4
4
|
*
|
|
5
|
-
* Reference:
|
|
6
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement.
|
|
5
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement
|
|
7
6
|
*/
|
|
8
7
|
export interface IHTMLImageElement extends HTMLElement {
|
|
9
8
|
alt: string;
|
|
@@ -24,18 +23,8 @@ export interface IHTMLImageElement extends HTMLElement {
|
|
|
24
23
|
width: number;
|
|
25
24
|
readonly x: number;
|
|
26
25
|
readonly y: number;
|
|
27
|
-
/**
|
|
28
|
-
* The decode() method of the HTMLImageElement interface returns a Promise that resolves when the image is decoded and it is safe to append the image to the DOM.
|
|
29
|
-
*
|
|
30
|
-
* @returns Promise.
|
|
31
|
-
*/
|
|
26
|
+
/** Resolves once the image is decoded and safe to append to the DOM. */
|
|
32
27
|
decode(): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Clones a node.
|
|
35
|
-
*
|
|
36
|
-
* @override
|
|
37
|
-
* @param [deep=false] "true" to clone deep.
|
|
38
|
-
* @returns Cloned node.
|
|
39
|
-
*/
|
|
28
|
+
/** @override */
|
|
40
29
|
cloneNode(deep?: boolean): IHTMLImageElement;
|
|
41
30
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PredefinedColorSpace } from './predefined-color-space.js';
|
|
2
|
-
/** The
|
|
2
|
+
/** The pixel data of an area of a `<canvas>`. */
|
|
3
3
|
export interface ImageData {
|
|
4
4
|
readonly colorSpace: PredefinedColorSpace;
|
|
5
|
-
/**
|
|
5
|
+
/** One-dimensional, RGBA order, integers 0-255. */
|
|
6
6
|
readonly data: Uint8ClampedArray<ArrayBuffer>;
|
|
7
|
-
/**
|
|
7
|
+
/** Pixels, not CSS units. */
|
|
8
8
|
readonly height: number;
|
|
9
|
-
/**
|
|
9
|
+
/** Pixels, not CSS units. */
|
|
10
10
|
readonly width: number;
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/dom-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.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,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.37.0",
|
|
75
|
+
"@gjsify/canvas2d-core": "^0.37.0",
|
|
76
|
+
"@gjsify/dom-events": "^0.37.0",
|
|
77
|
+
"@gjsify/fetch": "^0.37.0"
|
|
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.37.0",
|
|
82
|
+
"@gjsify/unit": "^0.37.0",
|
|
83
83
|
"@types/node": "^25.9.2",
|
|
84
84
|
"typescript": "^6.0.3"
|
|
85
85
|
},
|