@gjsify/dom-elements 0.3.15 → 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
package/lib/esm/node.js CHANGED
@@ -1,244 +1 @@
1
- import { childNodesList, elementChildren, isConnected, nodeType, parentNode } from "./property-symbol.js";
2
- import { NodeType } from "./node-type.js";
3
- import { NodeList } from "./node-list.js";
4
- import { EventTarget } from "@gjsify/dom-events";
5
-
6
- //#region src/node.ts
7
- let _PS$nodeType, _PS$parentNode, _PS$childNodesList, _PS$elementChildren, _PS$isConnected;
8
- /**
9
- * DOM Node base class.
10
- *
11
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/Node
12
- */
13
- var Node = class Node extends EventTarget {
14
- constructor(..._args) {
15
- super(..._args);
16
- this.ELEMENT_NODE = NodeType.ELEMENT_NODE;
17
- this.ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE;
18
- this.TEXT_NODE = NodeType.TEXT_NODE;
19
- this.CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE;
20
- this.PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE;
21
- this.COMMENT_NODE = NodeType.COMMENT_NODE;
22
- this.DOCUMENT_NODE = NodeType.DOCUMENT_NODE;
23
- this.DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE;
24
- this.DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE;
25
- this[_PS$nodeType] = NodeType.ELEMENT_NODE;
26
- this[_PS$parentNode] = null;
27
- this[_PS$childNodesList] = [];
28
- this[_PS$elementChildren] = [];
29
- this[_PS$isConnected] = false;
30
- }
31
- static {
32
- this.ELEMENT_NODE = NodeType.ELEMENT_NODE;
33
- }
34
- static {
35
- this.ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE;
36
- }
37
- static {
38
- this.TEXT_NODE = NodeType.TEXT_NODE;
39
- }
40
- static {
41
- this.CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE;
42
- }
43
- static {
44
- this.PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE;
45
- }
46
- static {
47
- this.COMMENT_NODE = NodeType.COMMENT_NODE;
48
- }
49
- static {
50
- this.DOCUMENT_NODE = NodeType.DOCUMENT_NODE;
51
- }
52
- static {
53
- this.DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE;
54
- }
55
- static {
56
- this.DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE;
57
- }
58
- static {
59
- this.DOCUMENT_POSITION_DISCONNECTED = 1;
60
- }
61
- static {
62
- this.DOCUMENT_POSITION_PRECEDING = 2;
63
- }
64
- static {
65
- this.DOCUMENT_POSITION_FOLLOWING = 4;
66
- }
67
- static {
68
- this.DOCUMENT_POSITION_CONTAINS = 8;
69
- }
70
- static {
71
- this.DOCUMENT_POSITION_CONTAINED_BY = 16;
72
- }
73
- static {
74
- this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
75
- }
76
- get nodeType() {
77
- return this[nodeType];
78
- }
79
- get nodeName() {
80
- return "";
81
- }
82
- get parentNode() {
83
- return this[parentNode];
84
- }
85
- get parentElement() {
86
- const parent = this[parentNode];
87
- return parent && parent[nodeType] === NodeType.ELEMENT_NODE ? parent : null;
88
- }
89
- get childNodes() {
90
- return new NodeList(this[childNodesList]);
91
- }
92
- get firstChild() {
93
- return this[childNodesList][0] ?? null;
94
- }
95
- get lastChild() {
96
- const children = this[childNodesList];
97
- return children[children.length - 1] ?? null;
98
- }
99
- get previousSibling() {
100
- const parent = this[parentNode];
101
- if (!parent) return null;
102
- const siblings = parent[childNodesList];
103
- const idx = siblings.indexOf(this);
104
- return idx > 0 ? siblings[idx - 1] : null;
105
- }
106
- get nextSibling() {
107
- const parent = this[parentNode];
108
- if (!parent) return null;
109
- const siblings = parent[childNodesList];
110
- const idx = siblings.indexOf(this);
111
- return idx !== -1 && idx < siblings.length - 1 ? siblings[idx + 1] : null;
112
- }
113
- get textContent() {
114
- return null;
115
- }
116
- set textContent(_value) {}
117
- get nodeValue() {
118
- return null;
119
- }
120
- set nodeValue(_value) {}
121
- get ownerDocument() {
122
- let root = this;
123
- while (root[parentNode]) {
124
- root = root[parentNode];
125
- }
126
- const doc = globalThis.document;
127
- return root === doc ? doc : null;
128
- }
129
- get isConnected() {
130
- return this[isConnected];
131
- }
132
- hasChildNodes() {
133
- return this[childNodesList].length > 0;
134
- }
135
- contains(other) {
136
- if (other === null) return false;
137
- if (other === this) return true;
138
- let node = other;
139
- while (node) {
140
- if (node === this) return true;
141
- node = node[parentNode];
142
- }
143
- return false;
144
- }
145
- getRootNode() {
146
- let node = this;
147
- while (node[parentNode]) {
148
- node = node[parentNode];
149
- }
150
- return node;
151
- }
152
- appendChild(node) {
153
- if (node[parentNode]) {
154
- node[parentNode].removeChild(node);
155
- }
156
- node[parentNode] = this;
157
- this[childNodesList].push(node);
158
- if (node[nodeType] === NodeType.ELEMENT_NODE) {
159
- this[elementChildren].push(node);
160
- }
161
- return node;
162
- }
163
- removeChild(node) {
164
- const children = this[childNodesList];
165
- const idx = children.indexOf(node);
166
- if (idx === -1) {
167
- throw new DOMException("Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.", "NotFoundError");
168
- }
169
- children.splice(idx, 1);
170
- node[parentNode] = null;
171
- if (node[nodeType] === NodeType.ELEMENT_NODE) {
172
- const elemIdx = this[elementChildren].indexOf(node);
173
- if (elemIdx !== -1) {
174
- this[elementChildren].splice(elemIdx, 1);
175
- }
176
- }
177
- return node;
178
- }
179
- insertBefore(newNode, referenceNode) {
180
- if (referenceNode === null) {
181
- return this.appendChild(newNode);
182
- }
183
- const children = this[childNodesList];
184
- const refIdx = children.indexOf(referenceNode);
185
- if (refIdx === -1) {
186
- throw new DOMException("Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.", "NotFoundError");
187
- }
188
- if (newNode[parentNode]) {
189
- newNode[parentNode].removeChild(newNode);
190
- }
191
- newNode[parentNode] = this;
192
- children.splice(refIdx, 0, newNode);
193
- if (newNode[nodeType] === NodeType.ELEMENT_NODE) {
194
- const elemChildren = this[elementChildren];
195
- let elemIdx = elemChildren.length;
196
- for (let i = refIdx; i < children.length; i++) {
197
- if (children[i][nodeType] === NodeType.ELEMENT_NODE && children[i] !== newNode) {
198
- elemIdx = elemChildren.indexOf(children[i]);
199
- break;
200
- }
201
- }
202
- elemChildren.splice(elemIdx, 0, newNode);
203
- }
204
- return newNode;
205
- }
206
- replaceChild(newChild, oldChild) {
207
- this.insertBefore(newChild, oldChild);
208
- this.removeChild(oldChild);
209
- return oldChild;
210
- }
211
- cloneNode(deep = false) {
212
- const clone = new this.constructor();
213
- clone[nodeType] = this[nodeType];
214
- if (deep) {
215
- for (const child of this[childNodesList]) {
216
- clone.appendChild(child.cloneNode(true));
217
- }
218
- }
219
- return clone;
220
- }
221
- /**
222
- * Override dispatchEvent to support event bubbling through the DOM tree.
223
- * After AT_TARGET phase, if event.bubbles is true, walk up the parentNode
224
- * chain and dispatch on each ancestor (BUBBLING_PHASE).
225
- */
226
- dispatchEvent(event) {
227
- const result = super.dispatchEvent(event);
228
- if (event.bubbles && !event.cancelBubble) {
229
- let parent = this[parentNode];
230
- while (parent) {
231
- Object.getPrototypeOf(Node.prototype).dispatchEvent.call(parent, event);
232
- if (event.cancelBubble) break;
233
- parent = parent[parentNode];
234
- }
235
- }
236
- return result;
237
- }
238
- get [(_PS$nodeType = nodeType, _PS$parentNode = parentNode, _PS$childNodesList = childNodesList, _PS$elementChildren = elementChildren, _PS$isConnected = isConnected, Symbol.toStringTag)]() {
239
- return "Node";
240
- }
241
- };
242
-
243
- //#endregion
244
- export { Node };
1
+ import{childNodesList as e,elementChildren as t,isConnected as n,nodeType as r,parentNode as i}from"./property-symbol.js";import{NodeType as a}from"./node-type.js";import{NodeList as o}from"./node-list.js";import{EventTarget as s}from"@gjsify/dom-events";let c,l,u,d,f;var p=class p extends s{constructor(...e){super(...e),this.ELEMENT_NODE=a.ELEMENT_NODE,this.ATTRIBUTE_NODE=a.ATTRIBUTE_NODE,this.TEXT_NODE=a.TEXT_NODE,this.CDATA_SECTION_NODE=a.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=a.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=a.COMMENT_NODE,this.DOCUMENT_NODE=a.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=a.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=a.DOCUMENT_FRAGMENT_NODE,this[c]=a.ELEMENT_NODE,this[l]=null,this[u]=[],this[d]=[],this[f]=!1}static{this.ELEMENT_NODE=a.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=a.ATTRIBUTE_NODE}static{this.TEXT_NODE=a.TEXT_NODE}static{this.CDATA_SECTION_NODE=a.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=a.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=a.COMMENT_NODE}static{this.DOCUMENT_NODE=a.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=a.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=a.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[r]}get nodeName(){return``}get parentNode(){return this[i]}get parentElement(){let e=this[i];return e&&e[r]===a.ELEMENT_NODE?e:null}get childNodes(){return new o(this[e])}get firstChild(){return this[e][0]??null}get lastChild(){let t=this[e];return t[t.length-1]??null}get previousSibling(){let t=this[i];if(!t)return null;let n=t[e],r=n.indexOf(this);return r>0?n[r-1]:null}get nextSibling(){let t=this[i];if(!t)return null;let n=t[e],r=n.indexOf(this);return r!==-1&&r<n.length-1?n[r+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[i];)e=e[i];let t=globalThis.document;return e===t?t:null}get isConnected(){return this[n]}hasChildNodes(){return this[e].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let t=e;for(;t;){if(t===this)return!0;t=t[i]}return!1}getRootNode(){let e=this;for(;e[i];)e=e[i];return e}appendChild(n){return n[i]&&n[i].removeChild(n),n[i]=this,this[e].push(n),n[r]===a.ELEMENT_NODE&&this[t].push(n),n}removeChild(n){let o=this[e],s=o.indexOf(n);if(s===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(o.splice(s,1),n[i]=null,n[r]===a.ELEMENT_NODE){let e=this[t].indexOf(n);e!==-1&&this[t].splice(e,1)}return n}insertBefore(n,o){if(o===null)return this.appendChild(n);let s=this[e],c=s.indexOf(o);if(c===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(n[i]&&n[i].removeChild(n),n[i]=this,s.splice(c,0,n),n[r]===a.ELEMENT_NODE){let e=this[t],i=e.length;for(let t=c;t<s.length;t++)if(s[t][r]===a.ELEMENT_NODE&&s[t]!==n){i=e.indexOf(s[t]);break}e.splice(i,0,n)}return n}replaceChild(e,t){return this.insertBefore(e,t),this.removeChild(t),t}cloneNode(t=!1){let n=new this.constructor;if(n[r]=this[r],t)for(let t of this[e])n.appendChild(t.cloneNode(!0));return n}dispatchEvent(e){let t=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let t=this[i];for(;t&&(Object.getPrototypeOf(p.prototype).dispatchEvent.call(t,e),!e.cancelBubble);)t=t[i]}return t}get[(c=r,l=i,u=e,d=t,f=n,Symbol.toStringTag)](){return`Node`}};export{p as Node};
@@ -1,36 +1 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
-
3
- //#region src/property-symbol.ts
4
- var property_symbol_exports = /* @__PURE__ */ __exportAll({
5
- attributes: () => attributes,
6
- childNodesList: () => childNodesList,
7
- elementChildren: () => elementChildren,
8
- isConnected: () => isConnected,
9
- localName: () => localName,
10
- name: () => name,
11
- namespaceURI: () => namespaceURI,
12
- nodeType: () => nodeType,
13
- ownerElement: () => ownerElement,
14
- parentNode: () => parentNode,
15
- prefix: () => prefix,
16
- propertyEventListeners: () => propertyEventListeners,
17
- tagName: () => tagName,
18
- value: () => value
19
- });
20
- const nodeType = Symbol("nodeType");
21
- const parentNode = Symbol("parentNode");
22
- const childNodesList = Symbol("childNodesList");
23
- const elementChildren = Symbol("elementChildren");
24
- const isConnected = Symbol("isConnected");
25
- const tagName = Symbol("tagName");
26
- const localName = Symbol("localName");
27
- const namespaceURI = Symbol("namespaceURI");
28
- const prefix = Symbol("prefix");
29
- const attributes = Symbol("attributes");
30
- const propertyEventListeners = Symbol("propertyEventListeners");
31
- const name = Symbol("name");
32
- const value = Symbol("value");
33
- const ownerElement = Symbol("ownerElement");
34
-
35
- //#endregion
36
- export { attributes, childNodesList, elementChildren, isConnected, localName, name, namespaceURI, nodeType, ownerElement, parentNode, prefix, propertyEventListeners, property_symbol_exports, tagName, value };
1
+ import{__exportAll as e}from"./_virtual/_rolldown/runtime.js";var t=e({attributes:()=>d,childNodesList:()=>i,elementChildren:()=>a,isConnected:()=>o,localName:()=>c,name:()=>p,namespaceURI:()=>l,nodeType:()=>n,ownerElement:()=>h,parentNode:()=>r,prefix:()=>u,propertyEventListeners:()=>f,tagName:()=>s,value:()=>m});const n=Symbol(`nodeType`),r=Symbol(`parentNode`),i=Symbol(`childNodesList`),a=Symbol(`elementChildren`),o=Symbol(`isConnected`),s=Symbol(`tagName`),c=Symbol(`localName`),l=Symbol(`namespaceURI`),u=Symbol(`prefix`),d=Symbol(`attributes`),f=Symbol(`propertyEventListeners`),p=Symbol(`name`),m=Symbol(`value`),h=Symbol(`ownerElement`);export{d as attributes,i as childNodesList,a as elementChildren,o as isConnected,c as localName,p as name,l as namespaceURI,n as nodeType,h as ownerElement,r as parentNode,u as prefix,f as propertyEventListeners,t as property_symbol_exports,s as tagName,m as value};
@@ -1,20 +1 @@
1
- import { HTMLCanvasElement } from "../html-canvas-element.js";
2
- import { DOMMatrix, DOMMatrixReadOnly } from "../dom-matrix.js";
3
- import { defineGlobal } from "./helpers.js";
4
- import { CanvasRenderingContext2D } from "@gjsify/canvas2d-core";
5
-
6
- //#region src/register/canvas.ts
7
- defineGlobal("HTMLCanvasElement", HTMLCanvasElement);
8
- defineGlobal("CanvasRenderingContext2D", CanvasRenderingContext2D);
9
- defineGlobal("DOMMatrix", DOMMatrix);
10
- defineGlobal("DOMMatrixReadOnly", DOMMatrixReadOnly);
11
- const CANVAS2D_KEY = Symbol.for("gjsify_canvas2d_context");
12
- HTMLCanvasElement.registerContextFactory("2d", (canvas, options) => {
13
- const existing = canvas[CANVAS2D_KEY];
14
- if (existing) return existing;
15
- const ctx = new CanvasRenderingContext2D(canvas, options);
16
- canvas[CANVAS2D_KEY] = ctx;
17
- return ctx;
18
- });
19
-
20
- //#endregion
1
+ import{HTMLCanvasElement as e}from"../html-canvas-element.js";import{DOMMatrix as t,DOMMatrixReadOnly as n}from"../dom-matrix.js";import{defineGlobal as r}from"./helpers.js";import{CanvasRenderingContext2D as i}from"@gjsify/canvas2d-core";r(`HTMLCanvasElement`,e),r(`CanvasRenderingContext2D`,i),r(`DOMMatrix`,t),r(`DOMMatrixReadOnly`,n);const a=Symbol.for(`gjsify_canvas2d_context`);e.registerContextFactory(`2d`,(e,t)=>{let n=e[a];if(n)return n;let r=new i(e,t);return e[a]=r,r});
@@ -1,41 +1 @@
1
- import { Comment } from "../comment.js";
2
- import { Text } from "../text.js";
3
- import { DocumentFragment } from "../document-fragment.js";
4
- import { document } from "../document.js";
5
- import { DOMTokenList } from "../dom-token-list.js";
6
- import { defineGlobal, defineGlobalIfMissing } from "./helpers.js";
7
- import { EventTarget } from "@gjsify/dom-events";
8
-
9
- //#region src/register/document.ts
10
- defineGlobal("Text", Text);
11
- defineGlobal("Comment", Comment);
12
- defineGlobal("DocumentFragment", DocumentFragment);
13
- defineGlobal("DOMTokenList", DOMTokenList);
14
- defineGlobal("document", document);
15
- defineGlobalIfMissing("self", globalThis);
16
- var Window = class {};
17
- defineGlobalIfMissing("Window", Window);
18
- defineGlobalIfMissing("window", globalThis);
19
- defineGlobalIfMissing("focus", () => {});
20
- defineGlobalIfMissing("blur", () => {});
21
- if (typeof globalThis.addEventListener !== "function") {
22
- const _globalEventTarget = new EventTarget();
23
- globalThis.__gjsify_globalEventTarget = _globalEventTarget;
24
- globalThis.addEventListener = (type, listener, options) => _globalEventTarget.addEventListener(type, listener, options);
25
- globalThis.removeEventListener = (type, listener, options) => _globalEventTarget.removeEventListener(type, listener, options);
26
- globalThis.dispatchEvent = (event) => _globalEventTarget.dispatchEvent(event);
27
- }
28
- defineGlobalIfMissing("devicePixelRatio", 1);
29
- defineGlobalIfMissing("scrollX", 0);
30
- defineGlobalIfMissing("scrollY", 0);
31
- defineGlobalIfMissing("pageXOffset", 0);
32
- defineGlobalIfMissing("pageYOffset", 0);
33
- defineGlobalIfMissing("alert", (...args) => console.error("alert:", ...args));
34
- if (typeof globalThis.top === "undefined") {
35
- Object.defineProperty(globalThis, "top", {
36
- get: () => globalThis,
37
- configurable: true
38
- });
39
- }
40
-
41
- //#endregion
1
+ 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{EventTarget as s}from"@gjsify/dom-events";if(a(`Text`,t),a(`Comment`,e),a(`DocumentFragment`,n),a(`DOMTokenList`,i),a(`document`,r),o(`self`,globalThis),o(`Window`,class{}),o(`window`,globalThis),o(`focus`,()=>{}),o(`blur`,()=>{}),typeof globalThis.addEventListener!=`function`){let e=new s;globalThis.__gjsify_globalEventTarget=e,globalThis.addEventListener=(t,n,r)=>e.addEventListener(t,n,r),globalThis.removeEventListener=(t,n,r)=>e.removeEventListener(t,n,r),globalThis.dispatchEvent=t=>e.dispatchEvent(t)}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,18 +1 @@
1
- import { FontFace, FontFaceSet } from "../font-face.js";
2
- import { defineGlobalIfMissing } from "./helpers.js";
3
-
4
- //#region src/register/font-face.ts
5
- defineGlobalIfMissing("FontFace", FontFace);
6
- if (typeof globalThis.FontFace === "undefined") {
7
- globalThis.FontFace = FontFace;
8
- }
9
- const _doc = globalThis.document;
10
- if (_doc && typeof _doc.fonts === "undefined") {
11
- Object.defineProperty(_doc, "fonts", {
12
- value: new FontFaceSet(),
13
- configurable: true,
14
- writable: true
15
- });
16
- }
17
-
18
- //#endregion
1
+ import{FontFace as e,FontFaceSet as t}from"../font-face.js";import{defineGlobalIfMissing as n}from"./helpers.js";n(`FontFace`,e),globalThis.FontFace===void 0&&(globalThis.FontFace=e);const r=globalThis.document;r&&r.fonts===void 0&&Object.defineProperty(r,`fonts`,{value:new t,configurable:!0,writable:!0});
@@ -1,18 +1 @@
1
- //#region src/register/helpers.ts
2
- /** Unconditionally expose a DOM class on `globalThis` (writable + configurable). */
3
- function defineGlobal(name, value) {
4
- Object.defineProperty(globalThis, name, {
5
- value,
6
- writable: true,
7
- configurable: true
8
- });
9
- }
10
- /** Only set the global if it hasn't already been defined. */
11
- function defineGlobalIfMissing(name, value) {
12
- if (typeof globalThis[name] === "undefined") {
13
- defineGlobal(name, value);
14
- }
15
- }
16
-
17
- //#endregion
18
- export { defineGlobal, defineGlobalIfMissing };
1
+ function e(e,t){Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}function t(t,n){globalThis[t]===void 0&&e(t,n)}export{e as defineGlobal,t as defineGlobalIfMissing};
@@ -1,9 +1 @@
1
- import { HTMLImageElement } from "../html-image-element.js";
2
- import { Image } from "../image.js";
3
- import { defineGlobal } from "./helpers.js";
4
-
5
- //#region src/register/image.ts
6
- defineGlobal("HTMLImageElement", HTMLImageElement);
7
- defineGlobal("Image", Image);
8
-
9
- //#endregion
1
+ import{HTMLImageElement as e}from"../html-image-element.js";import{Image as t}from"../image.js";import{defineGlobal as n}from"./helpers.js";n(`HTMLImageElement`,e),n(`Image`,t);
@@ -1,7 +1 @@
1
- import { location } from "../location-stub.js";
2
- import { defineGlobalIfMissing } from "./helpers.js";
3
-
4
- //#region src/register/location.ts
5
- defineGlobalIfMissing("location", location);
6
-
7
- //#endregion
1
+ import{location as e}from"../location-stub.js";import{defineGlobalIfMissing as t}from"./helpers.js";t(`location`,e);
@@ -1,7 +1 @@
1
- import { matchMedia } from "../match-media.js";
2
- import { defineGlobalIfMissing } from "./helpers.js";
3
-
4
- //#region src/register/match-media.ts
5
- defineGlobalIfMissing("matchMedia", matchMedia);
6
-
7
- //#endregion
1
+ import{matchMedia as e}from"../match-media.js";import{defineGlobalIfMissing as t}from"./helpers.js";t(`matchMedia`,e);
@@ -1,6 +1 @@
1
- //#region src/register/navigator.ts
2
- if (typeof globalThis.navigator === "undefined") {
3
- globalThis.navigator = {};
4
- }
5
-
6
- //#endregion
1
+ globalThis.navigator===void 0&&(globalThis.navigator={});
@@ -1,11 +1 @@
1
- import { MutationObserver } from "../mutation-observer.js";
2
- import { ResizeObserver } from "../resize-observer.js";
3
- import { IntersectionObserver } from "../intersection-observer.js";
4
- import { defineGlobal } from "./helpers.js";
5
-
6
- //#region src/register/observers.ts
7
- defineGlobal("MutationObserver", MutationObserver);
8
- defineGlobal("ResizeObserver", ResizeObserver);
9
- defineGlobal("IntersectionObserver", IntersectionObserver);
10
-
11
- //#endregion
1
+ import{MutationObserver as e}from"../mutation-observer.js";import{ResizeObserver as t}from"../resize-observer.js";import{IntersectionObserver as n}from"../intersection-observer.js";import{defineGlobal as r}from"./helpers.js";r(`MutationObserver`,e),r(`ResizeObserver`,t),r(`IntersectionObserver`,n);
@@ -1,8 +1 @@
1
- import "./register/document.js";
2
- import "./register/canvas.js";
3
- import "./register/image.js";
4
- import "./register/observers.js";
5
- import "./register/font-face.js";
6
- import "./register/match-media.js";
7
- import "./register/location.js";
8
- import "./register/navigator.js";
1
+ import"./register/document.js";import"./register/canvas.js";import"./register/image.js";import"./register/observers.js";import"./register/font-face.js";import"./register/match-media.js";import"./register/location.js";import"./register/navigator.js";
@@ -1,16 +1 @@
1
- //#region src/resize-observer.ts
2
- /**
3
- * ResizeObserver stub.
4
- * Many libraries check for ResizeObserver existence; this prevents crashes.
5
- *
6
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
7
- */
8
- var ResizeObserver = class {
9
- constructor(_callback) {}
10
- observe(_target) {}
11
- unobserve(_target) {}
12
- disconnect() {}
13
- };
14
-
15
- //#endregion
16
- export { ResizeObserver };
1
+ var e=class{constructor(e){}observe(e){}unobserve(e){}disconnect(){}};export{e as ResizeObserver};
package/lib/esm/text.js CHANGED
@@ -1,58 +1 @@
1
- import { nodeType } from "./property-symbol.js";
2
- import { NodeType } from "./node-type.js";
3
- import { CharacterData } from "./character-data.js";
4
-
5
- //#region src/text.ts
6
- /**
7
- * Text node.
8
- *
9
- * Reference: https://developer.mozilla.org/en-US/docs/Web/API/Text
10
- */
11
- var Text = class Text extends CharacterData {
12
- constructor(data = "") {
13
- super(data);
14
- this[nodeType] = NodeType.TEXT_NODE;
15
- }
16
- get nodeName() {
17
- return "#text";
18
- }
19
- /**
20
- * Returns the combined text of this node and all adjacent Text siblings.
21
- */
22
- get wholeText() {
23
- let text = this.data;
24
- let prev = this.previousSibling;
25
- while (prev && prev instanceof Text) {
26
- text = prev.data + text;
27
- prev = prev.previousSibling;
28
- }
29
- let next = this.nextSibling;
30
- while (next && next instanceof Text) {
31
- text += next.data;
32
- next = next.nextSibling;
33
- }
34
- return text;
35
- }
36
- /**
37
- * Splits the text node at the given offset, returning the new Text node
38
- * containing the text after the offset.
39
- */
40
- splitText(offset) {
41
- const newData = this.data.substring(offset);
42
- this.data = this.data.substring(0, offset);
43
- const newNode = new Text(newData);
44
- if (this.parentNode) {
45
- this.parentNode.insertBefore(newNode, this.nextSibling);
46
- }
47
- return newNode;
48
- }
49
- cloneNode(_deep = false) {
50
- return new Text(this.data);
51
- }
52
- get [Symbol.toStringTag]() {
53
- return "Text";
54
- }
55
- };
56
-
57
- //#endregion
58
- export { Text };
1
+ import{nodeType as e}from"./property-symbol.js";import{NodeType as t}from"./node-type.js";import{CharacterData as n}from"./character-data.js";var r=class r extends n{constructor(n=``){super(n),this[e]=t.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,t=this.previousSibling;for(;t&&t instanceof r;)e=t.data+e,t=t.previousSibling;let n=this.nextSibling;for(;n&&n instanceof r;)e+=n.data,n=n.nextSibling;return e}splitText(e){let t=this.data.substring(e);this.data=this.data.substring(0,e);let n=new r(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}cloneNode(e=!1){return new r(this.data)}get[Symbol.toStringTag](){return`Text`}};export{r as Text};
@@ -1,3 +1 @@
1
- import "./i-html-image-element.js";
2
- import "./image-data.js";
3
- import "./predefined-color-space.js";
1
+ import"./i-html-image-element.js";import"./image-data.js";import"./predefined-color-space.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/dom-elements",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -62,19 +62,19 @@
62
62
  "node"
63
63
  ],
64
64
  "dependencies": {
65
- "@girs/gdkpixbuf-2.0": "2.0.0-4.0.0-rc.9",
66
- "@girs/gjs": "4.0.0-rc.9",
67
- "@girs/glib-2.0": "2.88.0-4.0.0-rc.9",
68
- "@gjsify/abort-controller": "^0.3.15",
69
- "@gjsify/canvas2d-core": "^0.3.15",
70
- "@gjsify/dom-events": "^0.3.15",
71
- "@gjsify/fetch": "^0.3.15"
65
+ "@girs/gdkpixbuf-2.0": "2.0.0-4.0.0-rc.14",
66
+ "@girs/gjs": "4.0.0-rc.14",
67
+ "@girs/glib-2.0": "2.88.0-4.0.0-rc.14",
68
+ "@gjsify/abort-controller": "^0.3.17",
69
+ "@gjsify/canvas2d-core": "^0.3.17",
70
+ "@gjsify/dom-events": "^0.3.17",
71
+ "@gjsify/fetch": "^0.3.17"
72
72
  },
73
73
  "devDependencies": {
74
- "@girs/gst-1.0": "1.28.1-4.0.0-rc.9",
75
- "@gjsify/cli": "^0.3.15",
76
- "@gjsify/unit": "^0.3.15",
77
- "@types/node": "^25.6.0",
74
+ "@girs/gst-1.0": "1.28.1-4.0.0-rc.14",
75
+ "@gjsify/cli": "^0.3.17",
76
+ "@gjsify/unit": "^0.3.17",
77
+ "@types/node": "^25.6.2",
78
78
  "typescript": "^6.0.3"
79
79
  }
80
80
  }