@gjsify/dom-elements 0.3.13 → 0.3.15

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 (41) hide show
  1. package/lib/esm/_virtual/_rolldown/runtime.js +18 -0
  2. package/lib/esm/attr.js +37 -30
  3. package/lib/esm/character-data.js +61 -54
  4. package/lib/esm/comment.js +26 -19
  5. package/lib/esm/document-fragment.js +116 -109
  6. package/lib/esm/document.js +75 -81
  7. package/lib/esm/dom-matrix.js +158 -123
  8. package/lib/esm/dom-token-list.js +114 -108
  9. package/lib/esm/element.js +244 -246
  10. package/lib/esm/font-face.js +94 -89
  11. package/lib/esm/gst-time.js +17 -6
  12. package/lib/esm/html-canvas-element.js +82 -75
  13. package/lib/esm/html-element.js +424 -424
  14. package/lib/esm/html-image-element.js +226 -225
  15. package/lib/esm/html-media-element.js +117 -114
  16. package/lib/esm/html-video-element.js +110 -108
  17. package/lib/esm/image.js +27 -21
  18. package/lib/esm/index.js +13 -45
  19. package/lib/esm/intersection-observer.js +22 -18
  20. package/lib/esm/location-stub.js +25 -23
  21. package/lib/esm/match-media.js +18 -19
  22. package/lib/esm/mutation-observer.js +18 -13
  23. package/lib/esm/named-node-map.js +121 -121
  24. package/lib/esm/namespace-uri.js +9 -8
  25. package/lib/esm/node-list.js +39 -33
  26. package/lib/esm/node-type.js +13 -12
  27. package/lib/esm/node.js +241 -246
  28. package/lib/esm/property-symbol.js +36 -30
  29. package/lib/esm/register/canvas.js +11 -7
  30. package/lib/esm/register/document.js +19 -18
  31. package/lib/esm/register/font-face.js +10 -6
  32. package/lib/esm/register/helpers.js +14 -12
  33. package/lib/esm/register/image.js +4 -0
  34. package/lib/esm/register/location.js +4 -0
  35. package/lib/esm/register/match-media.js +4 -0
  36. package/lib/esm/register/navigator.js +4 -1
  37. package/lib/esm/register/observers.js +5 -1
  38. package/lib/esm/resize-observer.js +15 -12
  39. package/lib/esm/text.js +56 -49
  40. package/lib/esm/types/index.js +3 -3
  41. package/package.json +11 -11
@@ -1,5 +1,7 @@
1
- import { Event } from "@gjsify/dom-events";
2
1
  import { HTMLElement } from "./html-element.js";
2
+ import { Event } from "@gjsify/dom-events";
3
+
4
+ //#region src/html-media-element.ts
3
5
  const HAVE_NOTHING = 0;
4
6
  const HAVE_METADATA = 1;
5
7
  const HAVE_CURRENT_DATA = 2;
@@ -9,117 +11,118 @@ const NETWORK_EMPTY = 0;
9
11
  const NETWORK_IDLE = 1;
10
12
  const NETWORK_LOADING = 2;
11
13
  const NETWORK_NO_SOURCE = 3;
12
- class HTMLMediaElement extends HTMLElement {
13
- constructor() {
14
- super(...arguments);
15
- // -- Source --
16
- this._src = "";
17
- this._srcObject = null;
18
- // -- Playback state --
19
- this.currentTime = 0;
20
- this.duration = NaN;
21
- this.paused = true;
22
- this.ended = false;
23
- this.volume = 1;
24
- this.muted = false;
25
- this.defaultMuted = false;
26
- this.loop = false;
27
- this.autoplay = false;
28
- this.preload = "";
29
- this.playbackRate = 1;
30
- this.defaultPlaybackRate = 1;
31
- // -- Readiness --
32
- this.readyState = HAVE_NOTHING;
33
- this.networkState = NETWORK_EMPTY;
34
- }
35
- // -- Buffered/seekable stubs --
36
- get buffered() {
37
- return { length: 0, start: () => 0, end: () => 0 };
38
- }
39
- get seekable() {
40
- return { length: 0, start: () => 0, end: () => 0 };
41
- }
42
- get played() {
43
- return { length: 0, start: () => 0, end: () => 0 };
44
- }
45
- // -- src property --
46
- get src() {
47
- return this._src;
48
- }
49
- set src(value) {
50
- this._src = value;
51
- this._srcObject = null;
52
- this.dispatchEvent(new Event("srcchange"));
53
- }
54
- // -- srcObject property (MediaStream) --
55
- get srcObject() {
56
- return this._srcObject;
57
- }
58
- set srcObject(stream) {
59
- this._srcObject = stream;
60
- this._src = "";
61
- this.dispatchEvent(new Event("srcobjectchange"));
62
- }
63
- // -- Playback control --
64
- play() {
65
- this.paused = false;
66
- this.ended = false;
67
- this.dispatchEvent(new Event("play"));
68
- return Promise.resolve();
69
- }
70
- pause() {
71
- this.paused = true;
72
- this.dispatchEvent(new Event("pause"));
73
- }
74
- load() {
75
- this.readyState = HAVE_NOTHING;
76
- this.networkState = NETWORK_LOADING;
77
- this.dispatchEvent(new Event("loadstart"));
78
- }
79
- canPlayType(_type) {
80
- return "";
81
- }
82
- static {
83
- // -- Static constants --
84
- this.HAVE_NOTHING = HAVE_NOTHING;
85
- }
86
- static {
87
- this.HAVE_METADATA = HAVE_METADATA;
88
- }
89
- static {
90
- this.HAVE_CURRENT_DATA = HAVE_CURRENT_DATA;
91
- }
92
- static {
93
- this.HAVE_FUTURE_DATA = HAVE_FUTURE_DATA;
94
- }
95
- static {
96
- this.HAVE_ENOUGH_DATA = HAVE_ENOUGH_DATA;
97
- }
98
- static {
99
- this.NETWORK_EMPTY = NETWORK_EMPTY;
100
- }
101
- static {
102
- this.NETWORK_IDLE = NETWORK_IDLE;
103
- }
104
- static {
105
- this.NETWORK_LOADING = NETWORK_LOADING;
106
- }
107
- static {
108
- this.NETWORK_NO_SOURCE = NETWORK_NO_SOURCE;
109
- }
110
- get [Symbol.toStringTag]() {
111
- return "HTMLMediaElement";
112
- }
113
- }
114
- export {
115
- HAVE_CURRENT_DATA,
116
- HAVE_ENOUGH_DATA,
117
- HAVE_FUTURE_DATA,
118
- HAVE_METADATA,
119
- HAVE_NOTHING,
120
- HTMLMediaElement,
121
- NETWORK_EMPTY,
122
- NETWORK_IDLE,
123
- NETWORK_LOADING,
124
- NETWORK_NO_SOURCE
14
+ /**
15
+ * Base class for media elements (video, audio).
16
+ *
17
+ * Stores media state and dispatches DOM events. Pipeline construction is
18
+ * delegated to the bridge container via internal events.
19
+ */
20
+ var HTMLMediaElement = class extends HTMLElement {
21
+ constructor(..._args) {
22
+ super(..._args);
23
+ this._src = "";
24
+ this._srcObject = null;
25
+ this.currentTime = 0;
26
+ this.duration = NaN;
27
+ this.paused = true;
28
+ this.ended = false;
29
+ this.volume = 1;
30
+ this.muted = false;
31
+ this.defaultMuted = false;
32
+ this.loop = false;
33
+ this.autoplay = false;
34
+ this.preload = "";
35
+ this.playbackRate = 1;
36
+ this.defaultPlaybackRate = 1;
37
+ this.readyState = 0;
38
+ this.networkState = 0;
39
+ }
40
+ get buffered() {
41
+ return {
42
+ length: 0,
43
+ start: () => 0,
44
+ end: () => 0
45
+ };
46
+ }
47
+ get seekable() {
48
+ return {
49
+ length: 0,
50
+ start: () => 0,
51
+ end: () => 0
52
+ };
53
+ }
54
+ get played() {
55
+ return {
56
+ length: 0,
57
+ start: () => 0,
58
+ end: () => 0
59
+ };
60
+ }
61
+ get src() {
62
+ return this._src;
63
+ }
64
+ set src(value) {
65
+ this._src = value;
66
+ this._srcObject = null;
67
+ this.dispatchEvent(new Event("srcchange"));
68
+ }
69
+ get srcObject() {
70
+ return this._srcObject;
71
+ }
72
+ set srcObject(stream) {
73
+ this._srcObject = stream;
74
+ this._src = "";
75
+ this.dispatchEvent(new Event("srcobjectchange"));
76
+ }
77
+ play() {
78
+ this.paused = false;
79
+ this.ended = false;
80
+ this.dispatchEvent(new Event("play"));
81
+ return Promise.resolve();
82
+ }
83
+ pause() {
84
+ this.paused = true;
85
+ this.dispatchEvent(new Event("pause"));
86
+ }
87
+ load() {
88
+ this.readyState = 0;
89
+ this.networkState = 2;
90
+ this.dispatchEvent(new Event("loadstart"));
91
+ }
92
+ canPlayType(_type) {
93
+ return "";
94
+ }
95
+ static {
96
+ this.HAVE_NOTHING = 0;
97
+ }
98
+ static {
99
+ this.HAVE_METADATA = 1;
100
+ }
101
+ static {
102
+ this.HAVE_CURRENT_DATA = 2;
103
+ }
104
+ static {
105
+ this.HAVE_FUTURE_DATA = 3;
106
+ }
107
+ static {
108
+ this.HAVE_ENOUGH_DATA = 4;
109
+ }
110
+ static {
111
+ this.NETWORK_EMPTY = 0;
112
+ }
113
+ static {
114
+ this.NETWORK_IDLE = 1;
115
+ }
116
+ static {
117
+ this.NETWORK_LOADING = 2;
118
+ }
119
+ static {
120
+ this.NETWORK_NO_SOURCE = 3;
121
+ }
122
+ get [Symbol.toStringTag]() {
123
+ return "HTMLMediaElement";
124
+ }
125
125
  };
126
+
127
+ //#endregion
128
+ export { HAVE_CURRENT_DATA, HAVE_ENOUGH_DATA, HAVE_FUTURE_DATA, HAVE_METADATA, HAVE_NOTHING, HTMLMediaElement, NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE };
@@ -1,8 +1,10 @@
1
+ import { localName, namespaceURI, tagName } from "./property-symbol.js";
2
+ import { NamespaceURI } from "./namespace-uri.js";
1
3
  import { HTMLMediaElement } from "./html-media-element.js";
4
+ import { gstTimeToSeconds, secondsToGstTime } from "./gst-time.js";
2
5
  import { Event } from "@gjsify/dom-events";
3
- import * as PropertySymbol from "./property-symbol.js";
4
- import { NamespaceURI } from "./namespace-uri.js";
5
- import { secondsToGstTime, gstTimeToSeconds } from "./gst-time.js";
6
+
7
+ //#region src/html-video-element.ts
6
8
  const GST_STATE_PLAYING = 4;
7
9
  const GST_STATE_PAUSED = 3;
8
10
  const GST_FORMAT_TIME = 3;
@@ -10,109 +12,109 @@ const GST_SEEK_FLAG_FLUSH = 1;
10
12
  const GST_SEEK_FLAG_KEY_UNIT = 4;
11
13
  const GST_SEEK_TYPE_SET = 1;
12
14
  const GST_SEEK_TYPE_NONE = 0;
13
- class HTMLVideoElement extends HTMLMediaElement {
14
- constructor() {
15
- super();
16
- /** Set by VideoBridge after every pipeline swap. Null when no media is loaded. */
17
- this._pipeline = null;
18
- this._videoWidth = 0;
19
- this._videoHeight = 0;
20
- this.poster = "";
21
- this[PropertySymbol.tagName] = "VIDEO";
22
- this[PropertySymbol.localName] = "video";
23
- this[PropertySymbol.namespaceURI] = NamespaceURI.html;
24
- const self = this;
25
- Object.defineProperty(this, "paused", {
26
- get() {
27
- if (!self._pipeline) return true;
28
- const [, state] = self._pipeline.get_state(0n);
29
- return state !== GST_STATE_PLAYING;
30
- },
31
- configurable: true,
32
- enumerable: true
33
- });
34
- Object.defineProperty(this, "currentTime", {
35
- get() {
36
- if (!self._pipeline) return 0;
37
- const [ok, pos] = self._pipeline.query_position(GST_FORMAT_TIME);
38
- return ok ? gstTimeToSeconds(pos) : 0;
39
- },
40
- set(seconds) {
41
- self._pipeline?.seek(
42
- 1,
43
- GST_FORMAT_TIME,
44
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
45
- GST_SEEK_TYPE_SET,
46
- secondsToGstTime(seconds),
47
- GST_SEEK_TYPE_NONE,
48
- -1n
49
- );
50
- },
51
- configurable: true,
52
- enumerable: true
53
- });
54
- Object.defineProperty(this, "duration", {
55
- get() {
56
- if (!self._pipeline) return NaN;
57
- const [ok, dur] = self._pipeline.query_duration(GST_FORMAT_TIME);
58
- return ok && Number(dur) > 0 ? gstTimeToSeconds(dur) : NaN;
59
- },
60
- configurable: true,
61
- enumerable: true
62
- });
63
- Object.defineProperty(this, "volume", {
64
- get() {
65
- return self._playbin()?.volume ?? 1;
66
- },
67
- set(v) {
68
- const pb = self._playbin();
69
- if (pb) pb.volume = Math.max(0, Math.min(1, v));
70
- },
71
- configurable: true,
72
- enumerable: true
73
- });
74
- Object.defineProperty(this, "muted", {
75
- get() {
76
- return self._playbin()?.mute ?? false;
77
- },
78
- set(v) {
79
- const pb = self._playbin();
80
- if (pb) pb.mute = v;
81
- },
82
- configurable: true,
83
- enumerable: true
84
- });
85
- }
86
- async play() {
87
- this._pipeline?.set_state(GST_STATE_PLAYING);
88
- this.dispatchEvent(new Event("play"));
89
- this.dispatchEvent(new Event("playing"));
90
- }
91
- pause() {
92
- this._pipeline?.set_state(GST_STATE_PAUSED);
93
- this.dispatchEvent(new Event("pause"));
94
- }
95
- /** Intrinsic width of the video (set by bridge when media metadata loads). */
96
- get videoWidth() {
97
- return this._videoWidth;
98
- }
99
- set videoWidth(value) {
100
- this._videoWidth = value;
101
- }
102
- /** Intrinsic height of the video (set by bridge when media metadata loads). */
103
- get videoHeight() {
104
- return this._videoHeight;
105
- }
106
- set videoHeight(value) {
107
- this._videoHeight = value;
108
- }
109
- get [Symbol.toStringTag]() {
110
- return "HTMLVideoElement";
111
- }
112
- _playbin() {
113
- return this._pipeline?.get_by_name("playbin") ?? null;
114
- }
115
- }
116
- export {
117
- HTMLVideoElement
15
+ /**
16
+ * HTML Video Element.
17
+ *
18
+ * Dispatches 'srcobjectchange' when srcObject is set and 'srcchange' when src is set
19
+ * bridge containers listen for these to wire up / tear down their pipelines.
20
+ *
21
+ * When a GStreamer pipeline is attached via `_pipeline`, play/pause/seek/volume
22
+ * delegate to it. Without a pipeline the element behaves as a pure DOM stub.
23
+ */
24
+ var HTMLVideoElement = class extends HTMLMediaElement {
25
+ constructor() {
26
+ super();
27
+ this._pipeline = null;
28
+ this._videoWidth = 0;
29
+ this._videoHeight = 0;
30
+ this.poster = "";
31
+ this[tagName] = "VIDEO";
32
+ this[localName] = "video";
33
+ this[namespaceURI] = NamespaceURI.html;
34
+ const self = this;
35
+ Object.defineProperty(this, "paused", {
36
+ get() {
37
+ if (!self._pipeline) return true;
38
+ const [, state] = self._pipeline.get_state(0n);
39
+ return state !== GST_STATE_PLAYING;
40
+ },
41
+ configurable: true,
42
+ enumerable: true
43
+ });
44
+ Object.defineProperty(this, "currentTime", {
45
+ get() {
46
+ if (!self._pipeline) return 0;
47
+ const [ok, pos] = self._pipeline.query_position(GST_FORMAT_TIME);
48
+ return ok ? gstTimeToSeconds(pos) : 0;
49
+ },
50
+ set(seconds) {
51
+ self._pipeline?.seek(1, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, GST_SEEK_TYPE_SET, secondsToGstTime(seconds), GST_SEEK_TYPE_NONE, -1n);
52
+ },
53
+ configurable: true,
54
+ enumerable: true
55
+ });
56
+ Object.defineProperty(this, "duration", {
57
+ get() {
58
+ if (!self._pipeline) return NaN;
59
+ const [ok, dur] = self._pipeline.query_duration(GST_FORMAT_TIME);
60
+ return ok && Number(dur) > 0 ? gstTimeToSeconds(dur) : NaN;
61
+ },
62
+ configurable: true,
63
+ enumerable: true
64
+ });
65
+ Object.defineProperty(this, "volume", {
66
+ get() {
67
+ return self._playbin()?.volume ?? 1;
68
+ },
69
+ set(v) {
70
+ const pb = self._playbin();
71
+ if (pb) pb.volume = Math.max(0, Math.min(1, v));
72
+ },
73
+ configurable: true,
74
+ enumerable: true
75
+ });
76
+ Object.defineProperty(this, "muted", {
77
+ get() {
78
+ return self._playbin()?.mute ?? false;
79
+ },
80
+ set(v) {
81
+ const pb = self._playbin();
82
+ if (pb) pb.mute = v;
83
+ },
84
+ configurable: true,
85
+ enumerable: true
86
+ });
87
+ }
88
+ async play() {
89
+ this._pipeline?.set_state(GST_STATE_PLAYING);
90
+ this.dispatchEvent(new Event("play"));
91
+ this.dispatchEvent(new Event("playing"));
92
+ }
93
+ pause() {
94
+ this._pipeline?.set_state(GST_STATE_PAUSED);
95
+ this.dispatchEvent(new Event("pause"));
96
+ }
97
+ /** Intrinsic width of the video (set by bridge when media metadata loads). */
98
+ get videoWidth() {
99
+ return this._videoWidth;
100
+ }
101
+ set videoWidth(value) {
102
+ this._videoWidth = value;
103
+ }
104
+ /** Intrinsic height of the video (set by bridge when media metadata loads). */
105
+ get videoHeight() {
106
+ return this._videoHeight;
107
+ }
108
+ set videoHeight(value) {
109
+ this._videoHeight = value;
110
+ }
111
+ get [Symbol.toStringTag]() {
112
+ return "HTMLVideoElement";
113
+ }
114
+ _playbin() {
115
+ return this._pipeline?.get_by_name("playbin") ?? null;
116
+ }
118
117
  };
118
+
119
+ //#endregion
120
+ export { HTMLVideoElement };
package/lib/esm/image.js CHANGED
@@ -1,23 +1,29 @@
1
1
  import { HTMLImageElement } from "./html-image-element.js";
2
- class Image extends HTMLImageElement {
3
- /**
4
- * Constructor.
5
- *
6
- * @param [width] Width.
7
- * @param [height] Height.
8
- */
9
- constructor(width = null, height = null) {
10
- super();
11
- if (width !== null) {
12
- this.width = width;
13
- }
14
- if (height !== null) {
15
- this.height = height;
16
- }
17
- }
18
- }
19
- export {
20
- HTMLImageElement,
21
- Image,
22
- Image as default
2
+
3
+ //#region src/image.ts
4
+ /**
5
+ * Image as constructor.
6
+ *
7
+ * Reference:
8
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image.
9
+ */
10
+ var Image = class extends HTMLImageElement {
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @param [width] Width.
15
+ * @param [height] Height.
16
+ */
17
+ constructor(width = null, height = null) {
18
+ super();
19
+ if (width !== null) {
20
+ this.width = width;
21
+ }
22
+ if (height !== null) {
23
+ this.height = height;
24
+ }
25
+ }
23
26
  };
27
+
28
+ //#endregion
29
+ export { HTMLImageElement, Image, Image as default };
package/lib/esm/index.js CHANGED
@@ -1,61 +1,29 @@
1
+ import { property_symbol_exports } from "./property-symbol.js";
1
2
  import { Attr } from "./attr.js";
2
- import { NamedNodeMap } from "./named-node-map.js";
3
+ import { NodeType } from "./node-type.js";
3
4
  import { NodeList } from "./node-list.js";
4
5
  import { Node } from "./node.js";
5
6
  import { CharacterData } from "./character-data.js";
6
- import { Text } from "./text.js";
7
7
  import { Comment } from "./comment.js";
8
+ import { Text } from "./text.js";
8
9
  import { DocumentFragment } from "./document-fragment.js";
9
- import { DOMTokenList } from "./dom-token-list.js";
10
+ import { NamespaceURI } from "./namespace-uri.js";
11
+ import { NamedNodeMap } from "./named-node-map.js";
10
12
  import { Element } from "./element.js";
11
- import { HTMLElement, CSSStyleDeclaration } from "./html-element.js";
12
- import { HTMLCanvasElement } from "./html-canvas-element.js";
13
+ import { CSSStyleDeclaration, HTMLElement } from "./html-element.js";
13
14
  import { HTMLImageElement } from "./html-image-element.js";
14
15
  import { HTMLMediaElement } from "./html-media-element.js";
15
16
  import { HTMLVideoElement } from "./html-video-element.js";
16
- import { Image } from "./image.js";
17
+ import { HTMLCanvasElement } from "./html-canvas-element.js";
17
18
  import { Document, document } from "./document.js";
19
+ import { DOMMatrix, DOMMatrixReadOnly } from "./dom-matrix.js";
20
+ import { DOMTokenList } from "./dom-token-list.js";
21
+ import { FontFace, FontFaceSet } from "./font-face.js";
22
+ import { Image } from "./image.js";
18
23
  import { MutationObserver } from "./mutation-observer.js";
19
24
  import { ResizeObserver } from "./resize-observer.js";
20
25
  import { IntersectionObserver } from "./intersection-observer.js";
21
- import { NodeType } from "./node-type.js";
22
- import { NamespaceURI } from "./namespace-uri.js";
23
- import * as PropertySymbol from "./property-symbol.js";
24
- import { FontFace, FontFaceSet } from "./font-face.js";
25
26
  import { MediaQueryList, matchMedia } from "./match-media.js";
26
27
  import { location } from "./location-stub.js";
27
- import { DOMMatrix, DOMMatrixReadOnly } from "./dom-matrix.js";
28
- export {
29
- Attr,
30
- CSSStyleDeclaration,
31
- CharacterData,
32
- Comment,
33
- DOMMatrix,
34
- DOMMatrixReadOnly,
35
- DOMTokenList,
36
- Document,
37
- DocumentFragment,
38
- Element,
39
- FontFace,
40
- FontFaceSet,
41
- HTMLCanvasElement,
42
- HTMLElement,
43
- HTMLImageElement,
44
- HTMLMediaElement,
45
- HTMLVideoElement,
46
- Image,
47
- IntersectionObserver,
48
- MediaQueryList,
49
- MutationObserver,
50
- NamedNodeMap,
51
- NamespaceURI,
52
- Node,
53
- NodeList,
54
- NodeType,
55
- PropertySymbol,
56
- ResizeObserver,
57
- Text,
58
- document,
59
- location,
60
- matchMedia
61
- };
28
+
29
+ export { Attr, CSSStyleDeclaration, CharacterData, Comment, DOMMatrix, DOMMatrixReadOnly, DOMTokenList, Document, DocumentFragment, Element, FontFace, FontFaceSet, HTMLCanvasElement, HTMLElement, HTMLImageElement, HTMLMediaElement, HTMLVideoElement, Image, IntersectionObserver, MediaQueryList, MutationObserver, NamedNodeMap, NamespaceURI, Node, NodeList, NodeType, property_symbol_exports as PropertySymbol, ResizeObserver, Text, document, location, matchMedia };
@@ -1,19 +1,23 @@
1
- class IntersectionObserver {
2
- constructor(_callback, options) {
3
- this.root = options?.root ?? null;
4
- this.rootMargin = options?.rootMargin ?? "0px";
5
- this.thresholds = Array.isArray(options?.threshold) ? options.threshold : [options?.threshold ?? 0];
6
- }
7
- observe(_target) {
8
- }
9
- unobserve(_target) {
10
- }
11
- disconnect() {
12
- }
13
- takeRecords() {
14
- return [];
15
- }
16
- }
17
- export {
18
- IntersectionObserver
1
+ //#region src/intersection-observer.ts
2
+ /**
3
+ * IntersectionObserver stub.
4
+ * Many libraries check for IntersectionObserver existence; this prevents crashes.
5
+ *
6
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
7
+ */
8
+ var IntersectionObserver = class {
9
+ constructor(_callback, options) {
10
+ this.root = options?.root ?? null;
11
+ this.rootMargin = options?.rootMargin ?? "0px";
12
+ this.thresholds = Array.isArray(options?.threshold) ? options.threshold : [options?.threshold ?? 0];
13
+ }
14
+ observe(_target) {}
15
+ unobserve(_target) {}
16
+ disconnect() {}
17
+ takeRecords() {
18
+ return [];
19
+ }
19
20
  };
21
+
22
+ //#endregion
23
+ export { IntersectionObserver };