@gjsify/dom-elements 0.3.16 → 0.3.17

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 (43) hide show
  1. package/lib/esm/_virtual/_rolldown/runtime.js +1 -18
  2. package/lib/esm/attr.js +1 -38
  3. package/lib/esm/character-data.js +1 -63
  4. package/lib/esm/comment.js +1 -28
  5. package/lib/esm/document-fragment.js +1 -119
  6. package/lib/esm/document.js +1 -82
  7. package/lib/esm/dom-matrix.js +1 -159
  8. package/lib/esm/dom-token-list.js +1 -115
  9. package/lib/esm/element.js +1 -247
  10. package/lib/esm/font-face.js +1 -95
  11. package/lib/esm/gst-time.js +1 -22
  12. package/lib/esm/html-canvas-element.js +1 -84
  13. package/lib/esm/html-element.js +1 -426
  14. package/lib/esm/html-image-element.js +1 -231
  15. package/lib/esm/html-media-element.js +1 -128
  16. package/lib/esm/html-video-element.js +1 -120
  17. package/lib/esm/image.js +1 -29
  18. package/lib/esm/index.js +1 -29
  19. package/lib/esm/intersection-observer.js +1 -23
  20. package/lib/esm/location-stub.js +1 -27
  21. package/lib/esm/match-media.js +1 -21
  22. package/lib/esm/mutation-observer.js +1 -19
  23. package/lib/esm/named-node-map.js +1 -124
  24. package/lib/esm/namespace-uri.js +1 -11
  25. package/lib/esm/node-list.js +1 -40
  26. package/lib/esm/node-type.js +1 -15
  27. package/lib/esm/node.js +1 -244
  28. package/lib/esm/property-symbol.js +1 -36
  29. package/lib/esm/register/canvas.js +1 -20
  30. package/lib/esm/register/document.js +1 -41
  31. package/lib/esm/register/font-face.js +1 -18
  32. package/lib/esm/register/helpers.js +1 -18
  33. package/lib/esm/register/image.js +1 -9
  34. package/lib/esm/register/location.js +1 -7
  35. package/lib/esm/register/match-media.js +1 -7
  36. package/lib/esm/register/navigator.js +1 -6
  37. package/lib/esm/register/observers.js +1 -11
  38. package/lib/esm/register.js +1 -8
  39. package/lib/esm/resize-observer.js +1 -16
  40. package/lib/esm/text.js +1 -58
  41. package/lib/esm/types/index.js +1 -3
  42. package/package.json +12 -12
  43. package/tsconfig.tsbuildinfo +1 -1
@@ -1,128 +1 @@
1
- import { HTMLElement } from "./html-element.js";
2
- import { Event } from "@gjsify/dom-events";
3
-
4
- //#region src/html-media-element.ts
5
- const HAVE_NOTHING = 0;
6
- const HAVE_METADATA = 1;
7
- const HAVE_CURRENT_DATA = 2;
8
- const HAVE_FUTURE_DATA = 3;
9
- const HAVE_ENOUGH_DATA = 4;
10
- const NETWORK_EMPTY = 0;
11
- const NETWORK_IDLE = 1;
12
- const NETWORK_LOADING = 2;
13
- const NETWORK_NO_SOURCE = 3;
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
- };
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
+ import{HTMLElement as e}from"./html-element.js";import{Event as t}from"@gjsify/dom-events";const n=0,r=1,i=2,a=3,o=4,s=0,c=1,l=2,u=3;var d=class extends e{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new t(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new t(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new t(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new t(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new t(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};export{i as HAVE_CURRENT_DATA,o as HAVE_ENOUGH_DATA,a as HAVE_FUTURE_DATA,r as HAVE_METADATA,n as HAVE_NOTHING,d as HTMLMediaElement,s as NETWORK_EMPTY,c as NETWORK_IDLE,l as NETWORK_LOADING,u as NETWORK_NO_SOURCE};
@@ -1,120 +1 @@
1
- import { localName, namespaceURI, tagName } from "./property-symbol.js";
2
- import { NamespaceURI } from "./namespace-uri.js";
3
- import { HTMLMediaElement } from "./html-media-element.js";
4
- import { gstTimeToSeconds, secondsToGstTime } from "./gst-time.js";
5
- import { Event } from "@gjsify/dom-events";
6
-
7
- //#region src/html-video-element.ts
8
- const GST_STATE_PLAYING = 4;
9
- const GST_STATE_PAUSED = 3;
10
- const GST_FORMAT_TIME = 3;
11
- const GST_SEEK_FLAG_FLUSH = 1;
12
- const GST_SEEK_FLAG_KEY_UNIT = 4;
13
- const GST_SEEK_TYPE_SET = 1;
14
- const GST_SEEK_TYPE_NONE = 0;
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
- }
117
- };
118
-
119
- //#endregion
120
- export { HTMLVideoElement };
1
+ import{localName as e,namespaceURI as t,tagName as n}from"./property-symbol.js";import{NamespaceURI as r}from"./namespace-uri.js";import{HTMLMediaElement as i}from"./html-media-element.js";import{gstTimeToSeconds as a,secondsToGstTime as o}from"./gst-time.js";import{Event as s}from"@gjsify/dom-events";var c=class extends i{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[n]=`VIDEO`,this[e]=`video`,this[t]=r.html;let i=this;Object.defineProperty(this,`paused`,{get(){if(!i._pipeline)return!0;let[,e]=i._pipeline.get_state(0n);return e!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,`currentTime`,{get(){if(!i._pipeline)return 0;let[e,t]=i._pipeline.query_position(3);return e?a(t):0},set(e){i._pipeline?.seek(1,3,5,1,o(e),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,`duration`,{get(){if(!i._pipeline)return NaN;let[e,t]=i._pipeline.query_duration(3);return e&&Number(t)>0?a(t):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,`volume`,{get(){return i._playbin()?.volume??1},set(e){let t=i._playbin();t&&(t.volume=Math.max(0,Math.min(1,e)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,`muted`,{get(){return i._playbin()?.mute??!1},set(e){let t=i._playbin();t&&(t.mute=e)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new s(`play`)),this.dispatchEvent(new s(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new s(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};export{c as HTMLVideoElement};
package/lib/esm/image.js CHANGED
@@ -1,29 +1 @@
1
- import { HTMLImageElement } from "./html-image-element.js";
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
- }
26
- };
27
-
28
- //#endregion
29
- export { HTMLImageElement, Image, Image as default };
1
+ import{HTMLImageElement as e}from"./html-image-element.js";var t=class extends e{constructor(e=null,t=null){super(),e!==null&&(this.width=e),t!==null&&(this.height=t)}};export{e as HTMLImageElement,t as Image,t as default};
package/lib/esm/index.js CHANGED
@@ -1,29 +1 @@
1
- import { property_symbol_exports } from "./property-symbol.js";
2
- import { Attr } from "./attr.js";
3
- import { NodeType } from "./node-type.js";
4
- import { NodeList } from "./node-list.js";
5
- import { Node } from "./node.js";
6
- import { CharacterData } from "./character-data.js";
7
- import { Comment } from "./comment.js";
8
- import { Text } from "./text.js";
9
- import { DocumentFragment } from "./document-fragment.js";
10
- import { NamespaceURI } from "./namespace-uri.js";
11
- import { NamedNodeMap } from "./named-node-map.js";
12
- import { Element } from "./element.js";
13
- import { CSSStyleDeclaration, HTMLElement } from "./html-element.js";
14
- import { HTMLImageElement } from "./html-image-element.js";
15
- import { HTMLMediaElement } from "./html-media-element.js";
16
- import { HTMLVideoElement } from "./html-video-element.js";
17
- import { HTMLCanvasElement } from "./html-canvas-element.js";
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";
23
- import { MutationObserver } from "./mutation-observer.js";
24
- import { ResizeObserver } from "./resize-observer.js";
25
- import { IntersectionObserver } from "./intersection-observer.js";
26
- import { MediaQueryList, matchMedia } from "./match-media.js";
27
- import { location } from "./location-stub.js";
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
+ import{property_symbol_exports as e}from"./property-symbol.js";import{Attr as t}from"./attr.js";import{NodeType as n}from"./node-type.js";import{NodeList as r}from"./node-list.js";import{Node as i}from"./node.js";import{CharacterData as a}from"./character-data.js";import{Comment as o}from"./comment.js";import{Text as s}from"./text.js";import{DocumentFragment as c}from"./document-fragment.js";import{NamespaceURI as l}from"./namespace-uri.js";import{NamedNodeMap as u}from"./named-node-map.js";import{Element as d}from"./element.js";import{CSSStyleDeclaration as f,HTMLElement as p}from"./html-element.js";import{HTMLImageElement as m}from"./html-image-element.js";import{HTMLMediaElement as h}from"./html-media-element.js";import{HTMLVideoElement as g}from"./html-video-element.js";import{HTMLCanvasElement as _}from"./html-canvas-element.js";import{Document as v,document as y}from"./document.js";import{DOMMatrix as b,DOMMatrixReadOnly as x}from"./dom-matrix.js";import{DOMTokenList as S}from"./dom-token-list.js";import{FontFace as C,FontFaceSet as w}from"./font-face.js";import{Image as T}from"./image.js";import{MutationObserver as E}from"./mutation-observer.js";import{ResizeObserver as D}from"./resize-observer.js";import{IntersectionObserver as O}from"./intersection-observer.js";import{MediaQueryList as k,matchMedia as A}from"./match-media.js";import{location as j}from"./location-stub.js";export{t as Attr,f as CSSStyleDeclaration,a as CharacterData,o as Comment,b as DOMMatrix,x as DOMMatrixReadOnly,S as DOMTokenList,v as Document,c as DocumentFragment,d as Element,C as FontFace,w as FontFaceSet,_ as HTMLCanvasElement,p as HTMLElement,m as HTMLImageElement,h as HTMLMediaElement,g as HTMLVideoElement,T as Image,O as IntersectionObserver,k as MediaQueryList,E as MutationObserver,u as NamedNodeMap,l as NamespaceURI,i as Node,r as NodeList,n as NodeType,e as PropertySymbol,D as ResizeObserver,s as Text,y as document,j as location,A as matchMedia};
@@ -1,23 +1 @@
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
- }
20
- };
21
-
22
- //#endregion
23
- export { IntersectionObserver };
1
+ var e=class{constructor(e,t){this.root=t?.root??null,this.rootMargin=t?.rootMargin??`0px`,this.thresholds=Array.isArray(t?.threshold)?t.threshold:[t?.threshold??0]}observe(e){}unobserve(e){}disconnect(){}takeRecords(){return[]}};export{e as IntersectionObserver};
@@ -1,27 +1 @@
1
- //#region src/location-stub.ts
2
- const location = {
3
- href: "file://",
4
- origin: "file://",
5
- protocol: "file:",
6
- host: "",
7
- hostname: "",
8
- port: "",
9
- pathname: "/",
10
- search: "",
11
- hash: "",
12
- assign(_url) {},
13
- replace(_url) {},
14
- reload() {},
15
- toString() {
16
- return this.href;
17
- },
18
- ancestorOrigins: {
19
- length: 0,
20
- item: () => null,
21
- contains: () => false,
22
- [Symbol.iterator]: function* () {}
23
- }
24
- };
25
-
26
- //#endregion
27
- export { location };
1
+ const e={href:`file://`,origin:`file://`,protocol:`file:`,host:``,hostname:``,port:``,pathname:`/`,search:``,hash:``,assign(e){},replace(e){},reload(){},toString(){return this.href},ancestorOrigins:{length:0,item:()=>null,contains:()=>!1,[Symbol.iterator]:function*(){}}};export{e as location};
@@ -1,21 +1 @@
1
- import { EventTarget } from "@gjsify/dom-events";
2
-
3
- //#region src/match-media.ts
4
- var MediaQueryList = class extends EventTarget {
5
- constructor(query) {
6
- super();
7
- this.onchange = null;
8
- this.media = query;
9
- this.matches = false;
10
- }
11
- /** @deprecated Use addEventListener('change', ...) */
12
- addListener(_listener) {}
13
- /** @deprecated Use removeEventListener('change', ...) */
14
- removeListener(_listener) {}
15
- };
16
- function matchMedia(query) {
17
- return new MediaQueryList(query);
18
- }
19
-
20
- //#endregion
21
- export { MediaQueryList, matchMedia };
1
+ import{EventTarget as e}from"@gjsify/dom-events";var t=class extends e{constructor(e){super(),this.onchange=null,this.media=e,this.matches=!1}addListener(e){}removeListener(e){}};function n(e){return new t(e)}export{t as MediaQueryList,n as matchMedia};
@@ -1,19 +1 @@
1
- //#region src/mutation-observer.ts
2
- /**
3
- * MutationObserver stub.
4
- * Many libraries check for MutationObserver existence; this prevents crashes.
5
- * Does not actually observe DOM mutations (no layout engine).
6
- *
7
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
8
- */
9
- var MutationObserver = class {
10
- constructor(_callback) {}
11
- observe(_target, _options) {}
12
- disconnect() {}
13
- takeRecords() {
14
- return [];
15
- }
16
- };
17
-
18
- //#endregion
19
- export { MutationObserver };
1
+ var e=class{constructor(e){}observe(e,t){}disconnect(){}takeRecords(){return[]}};export{e as MutationObserver};
@@ -1,124 +1 @@
1
- import { Attr } from "./attr.js";
2
- import { NamespaceURI } from "./namespace-uri.js";
3
-
4
- //#region src/named-node-map.ts
5
- /**
6
- * Simplified NamedNodeMap for attribute storage.
7
- *
8
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap
9
- */
10
- var NamedNodeMap = class {
11
- constructor(ownerElement) {
12
- this._items = [];
13
- this._ownerElement = ownerElement;
14
- }
15
- get length() {
16
- return this._items.length;
17
- }
18
- item(index) {
19
- return this._items[index] ?? null;
20
- }
21
- getNamedItem(qualifiedName) {
22
- return this._findByName(qualifiedName);
23
- }
24
- getNamedItemNS(namespace, localName) {
25
- const ns = namespace === "" ? null : namespace;
26
- for (const attr of this._items) {
27
- if (attr.namespaceURI === ns && attr.localName === localName) {
28
- return attr;
29
- }
30
- }
31
- return null;
32
- }
33
- setNamedItem(attr) {
34
- return this._setAttr(attr);
35
- }
36
- setNamedItemNS(attr) {
37
- return this._setAttr(attr);
38
- }
39
- removeNamedItem(qualifiedName) {
40
- const existing = this._findByName(qualifiedName);
41
- if (!existing) {
42
- throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${qualifiedName}' was found.`, "NotFoundError");
43
- }
44
- this._removeAttr(existing);
45
- return existing;
46
- }
47
- removeNamedItemNS(namespace, localName) {
48
- const existing = this.getNamedItemNS(namespace, localName);
49
- if (!existing) {
50
- throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${namespace}' and localName '${localName}' was found.`, "NotFoundError");
51
- }
52
- this._removeAttr(existing);
53
- return existing;
54
- }
55
- [Symbol.iterator]() {
56
- return this._items[Symbol.iterator]();
57
- }
58
- get [Symbol.toStringTag]() {
59
- return "NamedNodeMap";
60
- }
61
- /** @internal Add or replace an attribute by name. */
62
- _setNamedItem(name, value, namespaceURI = null, prefix = null) {
63
- const existing = namespaceURI !== null ? this.getNamedItemNS(namespaceURI, name.includes(":") ? name.split(":")[1] : name) : this._findByName(name);
64
- if (existing) {
65
- existing.value = value;
66
- } else {
67
- const attr = new Attr(name, value, namespaceURI, prefix, this._ownerElement);
68
- this._items.push(attr);
69
- }
70
- }
71
- /** @internal Remove an attribute by name. Returns true if removed. */
72
- _removeNamedItem(name) {
73
- const existing = this._findByName(name);
74
- if (existing) {
75
- this._removeAttr(existing);
76
- return true;
77
- }
78
- return false;
79
- }
80
- /** @internal Remove an attribute by namespace + localName. Returns true if removed. */
81
- _removeNamedItemNS(namespace, localName) {
82
- const existing = this.getNamedItemNS(namespace, localName);
83
- if (existing) {
84
- this._removeAttr(existing);
85
- return true;
86
- }
87
- return false;
88
- }
89
- _findByName(qualifiedName) {
90
- const isHTML = this._ownerElement.namespaceURI === NamespaceURI.html;
91
- const searchName = isHTML ? qualifiedName.toLowerCase() : qualifiedName;
92
- for (const attr of this._items) {
93
- const attrName = isHTML ? attr.name.toLowerCase() : attr.name;
94
- if (attrName === searchName) {
95
- return attr;
96
- }
97
- }
98
- return null;
99
- }
100
- _setAttr(attr) {
101
- let existing = null;
102
- if (attr.namespaceURI !== null) {
103
- existing = this.getNamedItemNS(attr.namespaceURI, attr.localName);
104
- } else {
105
- existing = this._findByName(attr.name);
106
- }
107
- if (existing) {
108
- const oldAttr = new Attr(existing.name, existing.value, existing.namespaceURI, existing.prefix, existing.ownerElement);
109
- existing.value = attr.value;
110
- return oldAttr;
111
- }
112
- this._items.push(attr);
113
- return null;
114
- }
115
- _removeAttr(attr) {
116
- const idx = this._items.indexOf(attr);
117
- if (idx !== -1) {
118
- this._items.splice(idx, 1);
119
- }
120
- }
121
- };
122
-
123
- //#endregion
124
- export { NamedNodeMap };
1
+ import{Attr as e}from"./attr.js";import{NamespaceURI as t}from"./namespace-uri.js";var n=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,t){let n=e===``?null:e;for(let e of this._items)if(e.namespaceURI===n&&e.localName===t)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let t=this._findByName(e);if(!t)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(t),t}removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);if(!n)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${t}' was found.`,`NotFoundError`);return this._removeAttr(n),n}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(t,n,r=null,i=null){let a=r===null?this._findByName(t):this.getNamedItemNS(r,t.includes(`:`)?t.split(`:`)[1]:t);if(a)a.value=n;else{let a=new e(t,n,r,i,this._ownerElement);this._items.push(a)}}_removeNamedItem(e){let t=this._findByName(e);return t?(this._removeAttr(t),!0):!1}_removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);return n?(this._removeAttr(n),!0):!1}_findByName(e){let n=this._ownerElement.namespaceURI===t.html,r=n?e.toLowerCase():e;for(let e of this._items)if((n?e.name.toLowerCase():e.name)===r)return e;return null}_setAttr(t){let n=null;if(n=t.namespaceURI===null?this._findByName(t.name):this.getNamedItemNS(t.namespaceURI,t.localName),n){let r=new e(n.name,n.value,n.namespaceURI,n.prefix,n.ownerElement);return n.value=t.value,r}return this._items.push(t),null}_removeAttr(e){let t=this._items.indexOf(e);t!==-1&&this._items.splice(t,1)}};export{n as NamedNodeMap};
@@ -1,11 +1 @@
1
- //#region src/namespace-uri.ts
2
- const NamespaceURI = {
3
- html: "http://www.w3.org/1999/xhtml",
4
- svg: "http://www.w3.org/2000/svg",
5
- mathML: "http://www.w3.org/1998/Math/MathML",
6
- xml: "http://www.w3.org/XML/1998/namespace",
7
- xmlns: "http://www.w3.org/2000/xmlns/"
8
- };
9
-
10
- //#endregion
11
- export { NamespaceURI };
1
+ const e={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};export{e as NamespaceURI};
@@ -1,40 +1 @@
1
- //#region src/node-list.ts
2
- /**
3
- * Minimal NodeList backed by an external array.
4
- *
5
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/NodeList
6
- */
7
- var NodeList = class {
8
- constructor(items) {
9
- this._items = items;
10
- }
11
- get length() {
12
- return this._items.length;
13
- }
14
- item(index) {
15
- return this._items[index] ?? null;
16
- }
17
- forEach(callback, thisArg) {
18
- for (let i = 0; i < this._items.length; i++) {
19
- callback.call(thisArg, this._items[i], i, this);
20
- }
21
- }
22
- entries() {
23
- return this._items.entries();
24
- }
25
- keys() {
26
- return this._items.keys();
27
- }
28
- values() {
29
- return this._items.values();
30
- }
31
- [Symbol.iterator]() {
32
- return this._items[Symbol.iterator]();
33
- }
34
- get [Symbol.toStringTag]() {
35
- return "NodeList";
36
- }
37
- };
38
-
39
- //#endregion
40
- export { NodeList };
1
+ var e=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,t){for(let n=0;n<this._items.length;n++)e.call(t,this._items[n],n,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};export{e as NodeList};
@@ -1,15 +1 @@
1
- //#region src/node-type.ts
2
- const NodeType = {
3
- ELEMENT_NODE: 1,
4
- ATTRIBUTE_NODE: 2,
5
- TEXT_NODE: 3,
6
- CDATA_SECTION_NODE: 4,
7
- PROCESSING_INSTRUCTION_NODE: 7,
8
- COMMENT_NODE: 8,
9
- DOCUMENT_NODE: 9,
10
- DOCUMENT_TYPE_NODE: 10,
11
- DOCUMENT_FRAGMENT_NODE: 11
12
- };
13
-
14
- //#endregion
15
- export { NodeType };
1
+ const e={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};export{e as NodeType};