@gjsify/dom-elements 0.3.13 → 0.3.14

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,14 +1,18 @@
1
1
  import { FontFace, FontFaceSet } from "../font-face.js";
2
2
  import { defineGlobalIfMissing } from "./helpers.js";
3
+
4
+ //#region src/register/font-face.ts
3
5
  defineGlobalIfMissing("FontFace", FontFace);
4
6
  if (typeof globalThis.FontFace === "undefined") {
5
- globalThis.FontFace = FontFace;
7
+ globalThis.FontFace = FontFace;
6
8
  }
7
9
  const _doc = globalThis.document;
8
10
  if (_doc && typeof _doc.fonts === "undefined") {
9
- Object.defineProperty(_doc, "fonts", {
10
- value: new FontFaceSet(),
11
- configurable: true,
12
- writable: true
13
- });
11
+ Object.defineProperty(_doc, "fonts", {
12
+ value: new FontFaceSet(),
13
+ configurable: true,
14
+ writable: true
15
+ });
14
16
  }
17
+
18
+ //#endregion
@@ -1,16 +1,18 @@
1
+ //#region src/register/helpers.ts
2
+ /** Unconditionally expose a DOM class on `globalThis` (writable + configurable). */
1
3
  function defineGlobal(name, value) {
2
- Object.defineProperty(globalThis, name, {
3
- value,
4
- writable: true,
5
- configurable: true
6
- });
4
+ Object.defineProperty(globalThis, name, {
5
+ value,
6
+ writable: true,
7
+ configurable: true
8
+ });
7
9
  }
10
+ /** Only set the global if it hasn't already been defined. */
8
11
  function defineGlobalIfMissing(name, value) {
9
- if (typeof globalThis[name] === "undefined") {
10
- defineGlobal(name, value);
11
- }
12
+ if (typeof globalThis[name] === "undefined") {
13
+ defineGlobal(name, value);
14
+ }
12
15
  }
13
- export {
14
- defineGlobal,
15
- defineGlobalIfMissing
16
- };
16
+
17
+ //#endregion
18
+ export { defineGlobal, defineGlobalIfMissing };
@@ -1,5 +1,9 @@
1
1
  import { HTMLImageElement } from "../html-image-element.js";
2
2
  import { Image } from "../image.js";
3
3
  import { defineGlobal } from "./helpers.js";
4
+
5
+ //#region src/register/image.ts
4
6
  defineGlobal("HTMLImageElement", HTMLImageElement);
5
7
  defineGlobal("Image", Image);
8
+
9
+ //#endregion
@@ -1,3 +1,7 @@
1
1
  import { location } from "../location-stub.js";
2
2
  import { defineGlobalIfMissing } from "./helpers.js";
3
+
4
+ //#region src/register/location.ts
3
5
  defineGlobalIfMissing("location", location);
6
+
7
+ //#endregion
@@ -1,3 +1,7 @@
1
1
  import { matchMedia } from "../match-media.js";
2
2
  import { defineGlobalIfMissing } from "./helpers.js";
3
+
4
+ //#region src/register/match-media.ts
3
5
  defineGlobalIfMissing("matchMedia", matchMedia);
6
+
7
+ //#endregion
@@ -1,3 +1,6 @@
1
+ //#region src/register/navigator.ts
1
2
  if (typeof globalThis.navigator === "undefined") {
2
- globalThis.navigator = {};
3
+ globalThis.navigator = {};
3
4
  }
5
+
6
+ //#endregion
@@ -1,7 +1,11 @@
1
- import { IntersectionObserver } from "../intersection-observer.js";
2
1
  import { MutationObserver } from "../mutation-observer.js";
3
2
  import { ResizeObserver } from "../resize-observer.js";
3
+ import { IntersectionObserver } from "../intersection-observer.js";
4
4
  import { defineGlobal } from "./helpers.js";
5
+
6
+ //#region src/register/observers.ts
5
7
  defineGlobal("MutationObserver", MutationObserver);
6
8
  defineGlobal("ResizeObserver", ResizeObserver);
7
9
  defineGlobal("IntersectionObserver", IntersectionObserver);
10
+
11
+ //#endregion
@@ -1,13 +1,16 @@
1
- class ResizeObserver {
2
- constructor(_callback) {
3
- }
4
- observe(_target) {
5
- }
6
- unobserve(_target) {
7
- }
8
- disconnect() {
9
- }
10
- }
11
- export {
12
- ResizeObserver
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
13
  };
14
+
15
+ //#endregion
16
+ export { ResizeObserver };
package/lib/esm/text.js CHANGED
@@ -1,51 +1,58 @@
1
- import { CharacterData } from "./character-data.js";
1
+ import { nodeType } from "./property-symbol.js";
2
2
  import { NodeType } from "./node-type.js";
3
- import * as PS from "./property-symbol.js";
4
- class Text extends CharacterData {
5
- constructor(data = "") {
6
- super(data);
7
- this[PS.nodeType] = NodeType.TEXT_NODE;
8
- }
9
- get nodeName() {
10
- return "#text";
11
- }
12
- /**
13
- * Returns the combined text of this node and all adjacent Text siblings.
14
- */
15
- get wholeText() {
16
- let text = this.data;
17
- let prev = this.previousSibling;
18
- while (prev && prev instanceof Text) {
19
- text = prev.data + text;
20
- prev = prev.previousSibling;
21
- }
22
- let next = this.nextSibling;
23
- while (next && next instanceof Text) {
24
- text += next.data;
25
- next = next.nextSibling;
26
- }
27
- return text;
28
- }
29
- /**
30
- * Splits the text node at the given offset, returning the new Text node
31
- * containing the text after the offset.
32
- */
33
- splitText(offset) {
34
- const newData = this.data.substring(offset);
35
- this.data = this.data.substring(0, offset);
36
- const newNode = new Text(newData);
37
- if (this.parentNode) {
38
- this.parentNode.insertBefore(newNode, this.nextSibling);
39
- }
40
- return newNode;
41
- }
42
- cloneNode(_deep = false) {
43
- return new Text(this.data);
44
- }
45
- get [Symbol.toStringTag]() {
46
- return "Text";
47
- }
48
- }
49
- export {
50
- Text
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
+ }
51
55
  };
56
+
57
+ //#endregion
58
+ export { Text };
@@ -1,3 +1,3 @@
1
- export * from "./i-html-image-element.js";
2
- export * from "./image-data.js";
3
- export * from "./predefined-color-space.js";
1
+ import "./i-html-image-element.js";
2
+ import "./image-data.js";
3
+ 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.13",
3
+ "version": "0.3.14",
4
4
  "description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -62,18 +62,18 @@
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.13",
69
- "@gjsify/canvas2d-core": "^0.3.13",
70
- "@gjsify/dom-events": "^0.3.13",
71
- "@gjsify/fetch": "^0.3.13"
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.14",
69
+ "@gjsify/canvas2d-core": "^0.3.14",
70
+ "@gjsify/dom-events": "^0.3.14",
71
+ "@gjsify/fetch": "^0.3.14"
72
72
  },
73
73
  "devDependencies": {
74
- "@girs/gst-1.0": "^1.28.1-4.0.0-rc.9",
75
- "@gjsify/cli": "^0.3.13",
76
- "@gjsify/unit": "^0.3.13",
74
+ "@girs/gst-1.0": "1.28.1-4.0.0-rc.9",
75
+ "@gjsify/cli": "^0.3.14",
76
+ "@gjsify/unit": "^0.3.14",
77
77
  "@types/node": "^25.6.0",
78
78
  "typescript": "^6.0.3"
79
79
  }