@gjsify/dom-elements 0.4.0 → 0.4.3

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.
Files changed (53) hide show
  1. package/lib/types/location-stub.d.ts +1 -1
  2. package/package.json +78 -75
  3. package/src/attr.ts +0 -61
  4. package/src/character-data.ts +0 -79
  5. package/src/comment.ts +0 -31
  6. package/src/document-fragment.ts +0 -137
  7. package/src/document.ts +0 -103
  8. package/src/dom-matrix.ts +0 -109
  9. package/src/dom-token-list.ts +0 -140
  10. package/src/element.ts +0 -316
  11. package/src/font-face.ts +0 -97
  12. package/src/gst-time.ts +0 -26
  13. package/src/html-canvas-element.ts +0 -90
  14. package/src/html-element.ts +0 -502
  15. package/src/html-image-element.spec.ts +0 -285
  16. package/src/html-image-element.ts +0 -295
  17. package/src/html-media-element.ts +0 -123
  18. package/src/html-video-element.ts +0 -143
  19. package/src/image.ts +0 -31
  20. package/src/index.spec.ts +0 -914
  21. package/src/index.ts +0 -39
  22. package/src/intersection-observer.ts +0 -42
  23. package/src/location-stub.ts +0 -20
  24. package/src/match-media.ts +0 -32
  25. package/src/mutation-observer.ts +0 -39
  26. package/src/named-node-map.ts +0 -159
  27. package/src/namespace-uri.ts +0 -11
  28. package/src/node-list.ts +0 -52
  29. package/src/node-type.ts +0 -14
  30. package/src/node.ts +0 -280
  31. package/src/property-symbol.ts +0 -23
  32. package/src/register/canvas.ts +0 -23
  33. package/src/register/document.ts +0 -64
  34. package/src/register/font-face.ts +0 -18
  35. package/src/register/helpers.ts +0 -15
  36. package/src/register/image.ts +0 -8
  37. package/src/register/location.ts +0 -6
  38. package/src/register/match-media.ts +0 -6
  39. package/src/register/navigator.ts +0 -6
  40. package/src/register/observers.ts +0 -10
  41. package/src/register.spec.ts +0 -136
  42. package/src/register.ts +0 -13
  43. package/src/resize-observer.ts +0 -28
  44. package/src/stubs.spec.ts +0 -284
  45. package/src/test.browser.mts +0 -686
  46. package/src/test.mts +0 -9
  47. package/src/text.ts +0 -67
  48. package/src/types/i-html-image-element.ts +0 -44
  49. package/src/types/image-data.ts +0 -12
  50. package/src/types/index.ts +0 -3
  51. package/src/types/predefined-color-space.ts +0 -1
  52. package/tsconfig.json +0 -37
  53. package/tsconfig.tsbuildinfo +0 -1
@@ -1,143 +0,0 @@
1
- // HTMLVideoElement for GJS — video element with optional GStreamer pipeline wiring.
2
- // Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement
3
- //
4
- // The attached pipeline is set by VideoBridge after each swap. Types come from
5
- // a type-only Gst import so dom-elements has no runtime dependency on GStreamer
6
- // (mirrors the HTMLImageElement / GdkPixbuf split). Numeric enum values are
7
- // still used at runtime because pulling the Gst module eagerly would break the
8
- // "dom-elements works without gst-init" contract.
9
-
10
- import type Gst from '@girs/gst-1.0';
11
- import { HTMLMediaElement } from './html-media-element.js';
12
- import { Event } from '@gjsify/dom-events';
13
- import * as PropertySymbol from './property-symbol.js';
14
- import { NamespaceURI } from './namespace-uri.js';
15
- import { secondsToGstTime, gstTimeToSeconds } from './gst-time.js';
16
-
17
- // Gst.State / Gst.Format / Gst.SeekFlags / Gst.SeekType numeric values, hardcoded
18
- // to avoid a runtime `gi://Gst` import. Cross-checked against the GStreamer GIR.
19
- const GST_STATE_PLAYING = 4;
20
- const GST_STATE_PAUSED = 3;
21
- const GST_FORMAT_TIME = 3;
22
- const GST_SEEK_FLAG_FLUSH = 1;
23
- const GST_SEEK_FLAG_KEY_UNIT = 4;
24
- const GST_SEEK_TYPE_SET = 1;
25
- const GST_SEEK_TYPE_NONE = 0;
26
-
27
- type Playbin = Gst.Element & { volume?: number; mute?: boolean };
28
-
29
- /**
30
- * HTML Video Element.
31
- *
32
- * Dispatches 'srcobjectchange' when srcObject is set and 'srcchange' when src is set —
33
- * bridge containers listen for these to wire up / tear down their pipelines.
34
- *
35
- * When a GStreamer pipeline is attached via `_pipeline`, play/pause/seek/volume
36
- * delegate to it. Without a pipeline the element behaves as a pure DOM stub.
37
- */
38
- export class HTMLVideoElement extends HTMLMediaElement {
39
- /** Set by VideoBridge after every pipeline swap. Null when no media is loaded. */
40
- _pipeline: Gst.Pipeline | null = null;
41
-
42
- private _videoWidth = 0;
43
- private _videoHeight = 0;
44
- poster = '';
45
-
46
- constructor() {
47
- super();
48
- this[PropertySymbol.tagName] = 'VIDEO';
49
- this[PropertySymbol.localName] = 'video';
50
- this[PropertySymbol.namespaceURI] = NamespaceURI.html;
51
-
52
- // HTMLMediaElement defines paused/currentTime/duration/volume/muted as plain
53
- // fields. TypeScript forbids overriding a field with an accessor in the
54
- // subclass, so we install GStreamer-backed descriptors via defineProperty.
55
- const self = this;
56
-
57
- Object.defineProperty(this, 'paused', {
58
- get(): boolean {
59
- if (!self._pipeline) return true;
60
- const [, state] = self._pipeline.get_state(0n);
61
- return state !== GST_STATE_PLAYING;
62
- },
63
- configurable: true,
64
- enumerable: true,
65
- });
66
-
67
- Object.defineProperty(this, 'currentTime', {
68
- get(): number {
69
- if (!self._pipeline) return 0;
70
- const [ok, pos] = self._pipeline.query_position(GST_FORMAT_TIME);
71
- return ok ? gstTimeToSeconds(pos) : 0;
72
- },
73
- set(seconds: number) {
74
- self._pipeline?.seek(
75
- 1.0,
76
- GST_FORMAT_TIME,
77
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
78
- GST_SEEK_TYPE_SET,
79
- secondsToGstTime(seconds),
80
- GST_SEEK_TYPE_NONE,
81
- -1n,
82
- );
83
- },
84
- configurable: true,
85
- enumerable: true,
86
- });
87
-
88
- Object.defineProperty(this, 'duration', {
89
- get(): number {
90
- if (!self._pipeline) return NaN;
91
- const [ok, dur] = self._pipeline.query_duration(GST_FORMAT_TIME);
92
- return ok && Number(dur) > 0 ? gstTimeToSeconds(dur) : NaN;
93
- },
94
- configurable: true,
95
- enumerable: true,
96
- });
97
-
98
- Object.defineProperty(this, 'volume', {
99
- get(): number { return self._playbin()?.volume ?? 1.0; },
100
- set(v: number) {
101
- const pb = self._playbin();
102
- if (pb) pb.volume = Math.max(0, Math.min(1, v));
103
- },
104
- configurable: true,
105
- enumerable: true,
106
- });
107
-
108
- Object.defineProperty(this, 'muted', {
109
- get(): boolean { return self._playbin()?.mute ?? false; },
110
- set(v: boolean) {
111
- const pb = self._playbin();
112
- if (pb) pb.mute = v;
113
- },
114
- configurable: true,
115
- enumerable: true,
116
- });
117
- }
118
-
119
- override async play(): Promise<void> {
120
- this._pipeline?.set_state(GST_STATE_PLAYING);
121
- this.dispatchEvent(new Event('play'));
122
- this.dispatchEvent(new Event('playing'));
123
- }
124
-
125
- override pause(): void {
126
- this._pipeline?.set_state(GST_STATE_PAUSED);
127
- this.dispatchEvent(new Event('pause'));
128
- }
129
-
130
- /** Intrinsic width of the video (set by bridge when media metadata loads). */
131
- get videoWidth(): number { return this._videoWidth; }
132
- set videoWidth(value: number) { this._videoWidth = value; }
133
-
134
- /** Intrinsic height of the video (set by bridge when media metadata loads). */
135
- get videoHeight(): number { return this._videoHeight; }
136
- set videoHeight(value: number) { this._videoHeight = value; }
137
-
138
- get [Symbol.toStringTag](): string { return 'HTMLVideoElement'; }
139
-
140
- private _playbin(): Playbin | null {
141
- return (this._pipeline?.get_by_name('playbin') as Playbin | null) ?? null;
142
- }
143
- }
package/src/image.ts DELETED
@@ -1,31 +0,0 @@
1
- // HTMLImageElement Image constructor for GJS — original implementation using GdkPixbuf
2
-
3
- import { HTMLImageElement } from './html-image-element.js';
4
-
5
- /**
6
- * Image as constructor.
7
- *
8
- * Reference:
9
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image.
10
- */
11
- export default class Image extends HTMLImageElement {
12
- /**
13
- * Constructor.
14
- *
15
- * @param [width] Width.
16
- * @param [height] Height.
17
- */
18
- constructor(width: number | null = null, height: number | null = null) {
19
- super();
20
-
21
- if (width !== null) {
22
- this.width = width;
23
- }
24
-
25
- if (height !== null) {
26
- this.height = height;
27
- }
28
- }
29
- }
30
-
31
- export { HTMLImageElement, Image };