@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.
- package/lib/esm/_virtual/_rolldown/runtime.js +1 -18
- package/lib/esm/attr.js +1 -38
- package/lib/esm/character-data.js +1 -63
- package/lib/esm/comment.js +1 -28
- package/lib/esm/document-fragment.js +1 -119
- package/lib/esm/document.js +1 -82
- package/lib/esm/dom-matrix.js +1 -159
- package/lib/esm/dom-token-list.js +1 -115
- package/lib/esm/element.js +1 -247
- package/lib/esm/font-face.js +1 -95
- package/lib/esm/gst-time.js +1 -22
- package/lib/esm/html-canvas-element.js +1 -84
- package/lib/esm/html-element.js +1 -426
- package/lib/esm/html-image-element.js +1 -231
- package/lib/esm/html-media-element.js +1 -128
- package/lib/esm/html-video-element.js +1 -120
- package/lib/esm/image.js +1 -29
- package/lib/esm/index.js +1 -29
- package/lib/esm/intersection-observer.js +1 -23
- package/lib/esm/location-stub.js +1 -27
- package/lib/esm/match-media.js +1 -21
- package/lib/esm/mutation-observer.js +1 -19
- package/lib/esm/named-node-map.js +1 -124
- package/lib/esm/namespace-uri.js +1 -11
- package/lib/esm/node-list.js +1 -40
- package/lib/esm/node-type.js +1 -15
- package/lib/esm/node.js +1 -244
- package/lib/esm/property-symbol.js +1 -36
- package/lib/esm/register/canvas.js +1 -20
- package/lib/esm/register/document.js +1 -41
- package/lib/esm/register/font-face.js +1 -18
- package/lib/esm/register/helpers.js +1 -18
- package/lib/esm/register/image.js +1 -9
- package/lib/esm/register/location.js +1 -7
- package/lib/esm/register/match-media.js +1 -7
- package/lib/esm/register/navigator.js +1 -6
- package/lib/esm/register/observers.js +1 -11
- package/lib/esm/register.js +1 -8
- package/lib/esm/resize-observer.js +1 -16
- package/lib/esm/text.js +1 -58
- package/lib/esm/types/index.js +1 -3
- package/package.json +12 -12
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!no_symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll };
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t as __exportAll};
|
package/lib/esm/attr.js
CHANGED
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/attr.ts
|
|
4
|
-
/**
|
|
5
|
-
* Represents a DOM attribute.
|
|
6
|
-
*
|
|
7
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Attr
|
|
8
|
-
*/
|
|
9
|
-
var Attr = class {
|
|
10
|
-
constructor(name$1, value$1, namespaceURI = null, prefix = null, ownerElement$1 = null) {
|
|
11
|
-
this.specified = true;
|
|
12
|
-
this[name] = name$1;
|
|
13
|
-
this[value] = value$1;
|
|
14
|
-
this[ownerElement] = ownerElement$1;
|
|
15
|
-
this.namespaceURI = namespaceURI;
|
|
16
|
-
this.prefix = prefix;
|
|
17
|
-
const colonIndex = name$1.indexOf(":");
|
|
18
|
-
this.localName = colonIndex !== -1 ? name$1.slice(colonIndex + 1) : name$1;
|
|
19
|
-
}
|
|
20
|
-
get name() {
|
|
21
|
-
return this[name];
|
|
22
|
-
}
|
|
23
|
-
get value() {
|
|
24
|
-
return this[value];
|
|
25
|
-
}
|
|
26
|
-
set value(value$2) {
|
|
27
|
-
this[value] = value$2;
|
|
28
|
-
}
|
|
29
|
-
get ownerElement() {
|
|
30
|
-
return this[ownerElement];
|
|
31
|
-
}
|
|
32
|
-
get [(name, value, ownerElement, Symbol.toStringTag)]() {
|
|
33
|
-
return "Attr";
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
export { Attr };
|
|
1
|
+
import{name as e,ownerElement as t,value as n}from"./property-symbol.js";var r=class{constructor(r,i,a=null,o=null,s=null){this.specified=!0,this[e]=r,this[n]=i,this[t]=s,this.namespaceURI=a,this.prefix=o;let c=r.indexOf(`:`);this.localName=c===-1?r:r.slice(c+1)}get name(){return this[e]}get value(){return this[n]}set value(e){this[n]=e}get ownerElement(){return this[t]}get[Symbol.toStringTag](){return`Attr`}};export{r as Attr};
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NodeType } from "./node-type.js";
|
|
3
|
-
import { Node } from "./node.js";
|
|
4
|
-
|
|
5
|
-
//#region src/character-data.ts
|
|
6
|
-
/**
|
|
7
|
-
* CharacterData base class for Text and Comment nodes.
|
|
8
|
-
*
|
|
9
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/CharacterData
|
|
10
|
-
*/
|
|
11
|
-
var CharacterData = class extends Node {
|
|
12
|
-
constructor(data = "") {
|
|
13
|
-
super();
|
|
14
|
-
this[nodeType] = NodeType.TEXT_NODE;
|
|
15
|
-
this._data = data;
|
|
16
|
-
}
|
|
17
|
-
get data() {
|
|
18
|
-
return this._data;
|
|
19
|
-
}
|
|
20
|
-
set data(value) {
|
|
21
|
-
this._data = value;
|
|
22
|
-
}
|
|
23
|
-
get textContent() {
|
|
24
|
-
return this._data;
|
|
25
|
-
}
|
|
26
|
-
set textContent(value) {
|
|
27
|
-
this._data = value;
|
|
28
|
-
}
|
|
29
|
-
get nodeValue() {
|
|
30
|
-
return this._data;
|
|
31
|
-
}
|
|
32
|
-
set nodeValue(value) {
|
|
33
|
-
this._data = value;
|
|
34
|
-
}
|
|
35
|
-
get length() {
|
|
36
|
-
return this._data.length;
|
|
37
|
-
}
|
|
38
|
-
appendData(data) {
|
|
39
|
-
this._data += data;
|
|
40
|
-
}
|
|
41
|
-
deleteData(offset, count) {
|
|
42
|
-
this._data = this._data.substring(0, offset) + this._data.substring(offset + count);
|
|
43
|
-
}
|
|
44
|
-
insertData(offset, data) {
|
|
45
|
-
this._data = this._data.substring(0, offset) + data + this._data.substring(offset);
|
|
46
|
-
}
|
|
47
|
-
replaceData(offset, count, data) {
|
|
48
|
-
this._data = this._data.substring(0, offset) + data + this._data.substring(offset + count);
|
|
49
|
-
}
|
|
50
|
-
substringData(offset, count) {
|
|
51
|
-
return this._data.substring(offset, offset + count);
|
|
52
|
-
}
|
|
53
|
-
cloneNode(_deep = false) {
|
|
54
|
-
const clone = new this.constructor(this._data);
|
|
55
|
-
return clone;
|
|
56
|
-
}
|
|
57
|
-
get [Symbol.toStringTag]() {
|
|
58
|
-
return "CharacterData";
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { CharacterData };
|
|
1
|
+
import{nodeType as e}from"./property-symbol.js";import{NodeType as t}from"./node-type.js";import{Node as n}from"./node.js";var r=class extends n{constructor(n=``){super(),this[e]=t.TEXT_NODE,this._data=n}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,t){this._data=this._data.substring(0,e)+this._data.substring(e+t)}insertData(e,t){this._data=this._data.substring(0,e)+t+this._data.substring(e)}replaceData(e,t,n){this._data=this._data.substring(0,e)+n+this._data.substring(e+t)}substringData(e,t){return this._data.substring(e,e+t)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}};export{r as CharacterData};
|
package/lib/esm/comment.js
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NodeType } from "./node-type.js";
|
|
3
|
-
import { CharacterData } from "./character-data.js";
|
|
4
|
-
|
|
5
|
-
//#region src/comment.ts
|
|
6
|
-
/**
|
|
7
|
-
* Comment node.
|
|
8
|
-
*
|
|
9
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Comment
|
|
10
|
-
*/
|
|
11
|
-
var Comment = class Comment extends CharacterData {
|
|
12
|
-
constructor(data = "") {
|
|
13
|
-
super(data);
|
|
14
|
-
this[nodeType] = NodeType.COMMENT_NODE;
|
|
15
|
-
}
|
|
16
|
-
get nodeName() {
|
|
17
|
-
return "#comment";
|
|
18
|
-
}
|
|
19
|
-
cloneNode(_deep = false) {
|
|
20
|
-
return new Comment(this.data);
|
|
21
|
-
}
|
|
22
|
-
get [Symbol.toStringTag]() {
|
|
23
|
-
return "Comment";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { Comment };
|
|
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.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new r(this.data)}get[Symbol.toStringTag](){return`Comment`}};export{r as Comment};
|
|
@@ -1,119 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NodeType } from "./node-type.js";
|
|
3
|
-
import { Node } from "./node.js";
|
|
4
|
-
import { Text } from "./text.js";
|
|
5
|
-
|
|
6
|
-
//#region src/document-fragment.ts
|
|
7
|
-
/**
|
|
8
|
-
* DocumentFragment.
|
|
9
|
-
*
|
|
10
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
|
11
|
-
*/
|
|
12
|
-
var DocumentFragment = class DocumentFragment extends Node {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this[nodeType] = NodeType.DOCUMENT_FRAGMENT_NODE;
|
|
16
|
-
}
|
|
17
|
-
get nodeName() {
|
|
18
|
-
return "#document-fragment";
|
|
19
|
-
}
|
|
20
|
-
/** Element children only (excludes text/comment nodes) */
|
|
21
|
-
get children() {
|
|
22
|
-
return this[elementChildren];
|
|
23
|
-
}
|
|
24
|
-
get childElementCount() {
|
|
25
|
-
return this[elementChildren].length;
|
|
26
|
-
}
|
|
27
|
-
get firstElementChild() {
|
|
28
|
-
return this[elementChildren][0] ?? null;
|
|
29
|
-
}
|
|
30
|
-
get lastElementChild() {
|
|
31
|
-
const children = this[elementChildren];
|
|
32
|
-
return children[children.length - 1] ?? null;
|
|
33
|
-
}
|
|
34
|
-
get textContent() {
|
|
35
|
-
let text = "";
|
|
36
|
-
for (const child of this.childNodes) {
|
|
37
|
-
if (child.textContent !== null) {
|
|
38
|
-
text += child.textContent;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
set textContent(value) {
|
|
44
|
-
while (this.firstChild) {
|
|
45
|
-
this.removeChild(this.firstChild);
|
|
46
|
-
}
|
|
47
|
-
if (value) {
|
|
48
|
-
this.appendChild(new Text(value));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Append nodes or strings to this fragment.
|
|
53
|
-
*/
|
|
54
|
-
append(...nodes) {
|
|
55
|
-
for (const node of nodes) {
|
|
56
|
-
if (typeof node === "string") {
|
|
57
|
-
this.appendChild(new Text(node));
|
|
58
|
-
} else {
|
|
59
|
-
this.appendChild(node);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Prepend nodes or strings to this fragment.
|
|
65
|
-
*/
|
|
66
|
-
prepend(...nodes) {
|
|
67
|
-
const firstChild = this.firstChild;
|
|
68
|
-
for (const node of nodes) {
|
|
69
|
-
if (typeof node === "string") {
|
|
70
|
-
this.insertBefore(new Text(node), firstChild);
|
|
71
|
-
} else {
|
|
72
|
-
this.insertBefore(node, firstChild);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Replace all children with the given nodes.
|
|
78
|
-
*/
|
|
79
|
-
replaceChildren(...nodes) {
|
|
80
|
-
while (this.firstChild) {
|
|
81
|
-
this.removeChild(this.firstChild);
|
|
82
|
-
}
|
|
83
|
-
this.append(...nodes);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Find an element by ID in this fragment's children.
|
|
87
|
-
*/
|
|
88
|
-
getElementById(id) {
|
|
89
|
-
for (const child of this.children) {
|
|
90
|
-
if (child.id === id) return child;
|
|
91
|
-
const found = this._findById(child, id);
|
|
92
|
-
if (found) return found;
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
_findById(element, id) {
|
|
97
|
-
for (const child of element.children) {
|
|
98
|
-
if (child.id === id) return child;
|
|
99
|
-
const found = this._findById(child, id);
|
|
100
|
-
if (found) return found;
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
cloneNode(deep = false) {
|
|
105
|
-
const clone = new DocumentFragment();
|
|
106
|
-
if (deep) {
|
|
107
|
-
for (const child of this.childNodes) {
|
|
108
|
-
clone.appendChild(child.cloneNode(true));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return clone;
|
|
112
|
-
}
|
|
113
|
-
get [Symbol.toStringTag]() {
|
|
114
|
-
return "DocumentFragment";
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { DocumentFragment };
|
|
1
|
+
import{elementChildren as e,nodeType as t}from"./property-symbol.js";import{NodeType as n}from"./node-type.js";import{Node as r}from"./node.js";import{Text as i}from"./text.js";var a=class a extends r{constructor(){super(),this[t]=n.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[e]}get childElementCount(){return this[e].length}get firstElementChild(){return this[e][0]??null}get lastElementChild(){let t=this[e];return t[t.length-1]??null}get textContent(){let e=``;for(let t of this.childNodes)t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new i(e))}append(...e){for(let t of e)typeof t==`string`?this.appendChild(new i(t)):this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)typeof n==`string`?this.insertBefore(new i(n),t):this.insertBefore(n,t)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let t of this.children){if(t.id===e)return t;let n=this._findById(t,e);if(n)return n}return null}_findById(e,t){for(let n of e.children){if(n.id===t)return n;let e=this._findById(n,t);if(e)return e}return null}cloneNode(e=!1){let t=new a;if(e)for(let e of this.childNodes)t.appendChild(e.cloneNode(!0));return t}get[Symbol.toStringTag](){return`DocumentFragment`}};export{a as DocumentFragment};
|
package/lib/esm/document.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Comment } from "./comment.js";
|
|
3
|
-
import { Text } from "./text.js";
|
|
4
|
-
import { DocumentFragment } from "./document-fragment.js";
|
|
5
|
-
import { HTMLElement } from "./html-element.js";
|
|
6
|
-
import { HTMLImageElement } from "./html-image-element.js";
|
|
7
|
-
import { HTMLVideoElement } from "./html-video-element.js";
|
|
8
|
-
import { HTMLCanvasElement } from "./html-canvas-element.js";
|
|
9
|
-
import { Event } from "@gjsify/dom-events";
|
|
10
|
-
|
|
11
|
-
//#region src/document.ts
|
|
12
|
-
var Document = class Document extends Node {
|
|
13
|
-
static {
|
|
14
|
-
this._elementFactories = new Map();
|
|
15
|
-
}
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this.body = new HTMLElement();
|
|
19
|
-
this.head = new HTMLElement();
|
|
20
|
-
this.documentElement = new HTMLElement();
|
|
21
|
-
this.appendChild(this.documentElement);
|
|
22
|
-
this.documentElement.appendChild(this.body);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Register a factory for a custom element tag name.
|
|
26
|
-
* Called as a side-effect by DOM packages to avoid circular dependencies.
|
|
27
|
-
*
|
|
28
|
-
* Example: `Document.registerElementFactory('iframe', () => new HTMLIFrameElement())`
|
|
29
|
-
*/
|
|
30
|
-
static registerElementFactory(tagName, factory) {
|
|
31
|
-
Document._elementFactories.set(tagName.toLowerCase(), factory);
|
|
32
|
-
}
|
|
33
|
-
createElementNS(_namespace, tagName) {
|
|
34
|
-
const tag = tagName.toLowerCase();
|
|
35
|
-
switch (tag) {
|
|
36
|
-
case "img": return new HTMLImageElement();
|
|
37
|
-
case "video": return new HTMLVideoElement();
|
|
38
|
-
case "canvas": return new HTMLCanvasElement();
|
|
39
|
-
default: {
|
|
40
|
-
const factory = Document._elementFactories.get(tag);
|
|
41
|
-
if (factory) return factory();
|
|
42
|
-
return new HTMLElement();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
createElement(tagName) {
|
|
47
|
-
return this.createElementNS("http://www.w3.org/1999/xhtml", tagName);
|
|
48
|
-
}
|
|
49
|
-
createTextNode(data) {
|
|
50
|
-
return new Text(data);
|
|
51
|
-
}
|
|
52
|
-
createComment(data) {
|
|
53
|
-
return new Comment(data);
|
|
54
|
-
}
|
|
55
|
-
createDocumentFragment() {
|
|
56
|
-
return new DocumentFragment();
|
|
57
|
-
}
|
|
58
|
-
createEvent(type) {
|
|
59
|
-
return new Event(type);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Find an element by ID. Searches body's descendants.
|
|
63
|
-
*/
|
|
64
|
-
getElementById(id) {
|
|
65
|
-
return this._findById(this.body, id);
|
|
66
|
-
}
|
|
67
|
-
_findById(element, id) {
|
|
68
|
-
if (element.id === id) return element;
|
|
69
|
-
for (const child of element.children) {
|
|
70
|
-
const found = this._findById(child, id);
|
|
71
|
-
if (found) return found;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
get [Symbol.toStringTag]() {
|
|
76
|
-
return "Document";
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const document = new Document();
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
|
-
export { Document, document };
|
|
1
|
+
import{Node as e}from"./node.js";import{Comment as t}from"./comment.js";import{Text as n}from"./text.js";import{DocumentFragment as r}from"./document-fragment.js";import{HTMLElement as i}from"./html-element.js";import{HTMLImageElement as a}from"./html-image-element.js";import{HTMLVideoElement as o}from"./html-video-element.js";import{HTMLCanvasElement as s}from"./html-canvas-element.js";import{Event as c}from"@gjsify/dom-events";var l=class l extends e{static{this._elementFactories=new Map}constructor(){super(),this.body=new i,this.head=new i,this.documentElement=new i,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,t){l._elementFactories.set(e.toLowerCase(),t)}createElementNS(e,t){let n=t.toLowerCase();switch(n){case`img`:return new a;case`video`:return new o;case`canvas`:return new s;default:{let e=l._elementFactories.get(n);return e?e():new i}}}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new n(e)}createComment(e){return new t(e)}createDocumentFragment(){return new r}createEvent(e){return new c(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,t){if(e.id===t)return e;for(let n of e.children){let e=this._findById(n,t);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};const u=new l;export{l as Document,u as document};
|
package/lib/esm/dom-matrix.js
CHANGED
|
@@ -1,159 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Minimal DOMMatrix implementation — supports 2D and 3D construction, plus
|
|
4
|
-
* 2D multiply/inverse/translate/scale operations used by Canvas 2D libraries
|
|
5
|
-
* like Excalibur. Full 3D math (4x4 multiply, inverse) is NOT implemented.
|
|
6
|
-
*/
|
|
7
|
-
var DOMMatrix = class DOMMatrix {
|
|
8
|
-
constructor(init) {
|
|
9
|
-
this.a = 1;
|
|
10
|
-
this.b = 0;
|
|
11
|
-
this.c = 0;
|
|
12
|
-
this.d = 1;
|
|
13
|
-
this.e = 0;
|
|
14
|
-
this.f = 0;
|
|
15
|
-
this.m11 = 1;
|
|
16
|
-
this.m12 = 0;
|
|
17
|
-
this.m13 = 0;
|
|
18
|
-
this.m14 = 0;
|
|
19
|
-
this.m21 = 0;
|
|
20
|
-
this.m22 = 1;
|
|
21
|
-
this.m23 = 0;
|
|
22
|
-
this.m24 = 0;
|
|
23
|
-
this.m31 = 0;
|
|
24
|
-
this.m32 = 0;
|
|
25
|
-
this.m33 = 1;
|
|
26
|
-
this.m34 = 0;
|
|
27
|
-
this.m41 = 0;
|
|
28
|
-
this.m42 = 0;
|
|
29
|
-
this.m43 = 0;
|
|
30
|
-
this.m44 = 1;
|
|
31
|
-
this.is2D = true;
|
|
32
|
-
this.isIdentity = true;
|
|
33
|
-
if (Array.isArray(init)) {
|
|
34
|
-
if (init.length === 6) {
|
|
35
|
-
this.a = this.m11 = init[0];
|
|
36
|
-
this.b = this.m12 = init[1];
|
|
37
|
-
this.c = this.m21 = init[2];
|
|
38
|
-
this.d = this.m22 = init[3];
|
|
39
|
-
this.e = this.m41 = init[4];
|
|
40
|
-
this.f = this.m42 = init[5];
|
|
41
|
-
this.is2D = true;
|
|
42
|
-
} else if (init.length === 16) {
|
|
43
|
-
this.m11 = init[0];
|
|
44
|
-
this.m12 = init[1];
|
|
45
|
-
this.m13 = init[2];
|
|
46
|
-
this.m14 = init[3];
|
|
47
|
-
this.m21 = init[4];
|
|
48
|
-
this.m22 = init[5];
|
|
49
|
-
this.m23 = init[6];
|
|
50
|
-
this.m24 = init[7];
|
|
51
|
-
this.m31 = init[8];
|
|
52
|
-
this.m32 = init[9];
|
|
53
|
-
this.m33 = init[10];
|
|
54
|
-
this.m34 = init[11];
|
|
55
|
-
this.m41 = init[12];
|
|
56
|
-
this.m42 = init[13];
|
|
57
|
-
this.m43 = init[14];
|
|
58
|
-
this.m44 = init[15];
|
|
59
|
-
this.a = this.m11;
|
|
60
|
-
this.b = this.m12;
|
|
61
|
-
this.c = this.m21;
|
|
62
|
-
this.d = this.m22;
|
|
63
|
-
this.e = this.m41;
|
|
64
|
-
this.f = this.m42;
|
|
65
|
-
this.is2D = false;
|
|
66
|
-
}
|
|
67
|
-
this.isIdentity = this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1 && this.e === 0 && this.f === 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Multiply this 2D matrix by another 2D matrix and return a new matrix.
|
|
72
|
-
* [a c e] [a' c' e'] [a*a'+c*b' a*c'+c*d' a*e'+c*f'+e]
|
|
73
|
-
* [b d f] [b' d' f'] = [b*a'+d*b' b*c'+d*d' b*e'+d*f'+f]
|
|
74
|
-
* [0 0 1] [0 0 1 ] [0 0 1 ]
|
|
75
|
-
*/
|
|
76
|
-
multiply(other) {
|
|
77
|
-
const a = this.a * other.a + this.c * other.b;
|
|
78
|
-
const b = this.b * other.a + this.d * other.b;
|
|
79
|
-
const c = this.a * other.c + this.c * other.d;
|
|
80
|
-
const d = this.b * other.c + this.d * other.d;
|
|
81
|
-
const e = this.a * other.e + this.c * other.f + this.e;
|
|
82
|
-
const f = this.b * other.e + this.d * other.f + this.f;
|
|
83
|
-
return new DOMMatrix([
|
|
84
|
-
a,
|
|
85
|
-
b,
|
|
86
|
-
c,
|
|
87
|
-
d,
|
|
88
|
-
e,
|
|
89
|
-
f
|
|
90
|
-
]);
|
|
91
|
-
}
|
|
92
|
-
/** In-place multiply; returns this. */
|
|
93
|
-
multiplySelf(other) {
|
|
94
|
-
const result = this.multiply(other);
|
|
95
|
-
this.a = result.a;
|
|
96
|
-
this.b = result.b;
|
|
97
|
-
this.c = result.c;
|
|
98
|
-
this.d = result.d;
|
|
99
|
-
this.e = result.e;
|
|
100
|
-
this.f = result.f;
|
|
101
|
-
this.m11 = this.a;
|
|
102
|
-
this.m12 = this.b;
|
|
103
|
-
this.m21 = this.c;
|
|
104
|
-
this.m22 = this.d;
|
|
105
|
-
this.m41 = this.e;
|
|
106
|
-
this.m42 = this.f;
|
|
107
|
-
this.isIdentity = false;
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
/** 2D inverse. Throws if non-invertible (det === 0). */
|
|
111
|
-
inverse() {
|
|
112
|
-
const det = this.a * this.d - this.b * this.c;
|
|
113
|
-
if (det === 0) return new DOMMatrix([
|
|
114
|
-
1,
|
|
115
|
-
0,
|
|
116
|
-
0,
|
|
117
|
-
1,
|
|
118
|
-
0,
|
|
119
|
-
0
|
|
120
|
-
]);
|
|
121
|
-
const invDet = 1 / det;
|
|
122
|
-
return new DOMMatrix([
|
|
123
|
-
this.d * invDet,
|
|
124
|
-
-this.b * invDet,
|
|
125
|
-
-this.c * invDet,
|
|
126
|
-
this.a * invDet,
|
|
127
|
-
(this.c * this.f - this.d * this.e) * invDet,
|
|
128
|
-
(this.b * this.e - this.a * this.f) * invDet
|
|
129
|
-
]);
|
|
130
|
-
}
|
|
131
|
-
translate(tx = 0, ty = 0) {
|
|
132
|
-
return this.multiply({
|
|
133
|
-
a: 1,
|
|
134
|
-
b: 0,
|
|
135
|
-
c: 0,
|
|
136
|
-
d: 1,
|
|
137
|
-
e: tx,
|
|
138
|
-
f: ty
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
scale(sx = 1, sy = sx) {
|
|
142
|
-
return this.multiply({
|
|
143
|
-
a: sx,
|
|
144
|
-
b: 0,
|
|
145
|
-
c: 0,
|
|
146
|
-
d: sy,
|
|
147
|
-
e: 0,
|
|
148
|
-
f: 0
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* DOMMatrixReadOnly alias — MDN specifies this as the immutable base class.
|
|
154
|
-
* We expose the same impl since consumers (Excalibur, three.js) rarely care.
|
|
155
|
-
*/
|
|
156
|
-
const DOMMatrixReadOnly = DOMMatrix;
|
|
157
|
-
|
|
158
|
-
//#endregion
|
|
159
|
-
export { DOMMatrix, DOMMatrixReadOnly };
|
|
1
|
+
var e=class e{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(t){return new e([this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f])}multiplySelf(e){let t=this.multiply(e);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let t=this.a*this.d-this.b*this.c;if(t===0)return new e([1,0,0,1,0,0]);let n=1/t;return new e([this.d*n,-this.b*n,-this.c*n,this.a*n,(this.c*this.f-this.d*this.e)*n,(this.b*this.e-this.a*this.f)*n])}translate(e=0,t=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:t})}scale(e=1,t=e){return this.multiply({a:e,b:0,c:0,d:t,e:0,f:0})}};const t=e;export{e as DOMMatrix,t as DOMMatrixReadOnly};
|
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* DOMTokenList — manages a set of space-separated tokens on an attribute.
|
|
4
|
-
*
|
|
5
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList
|
|
6
|
-
*/
|
|
7
|
-
var DOMTokenList = class {
|
|
8
|
-
constructor(ownerElement, attributeName) {
|
|
9
|
-
this._ownerElement = ownerElement;
|
|
10
|
-
this._attributeName = attributeName;
|
|
11
|
-
}
|
|
12
|
-
_getTokens() {
|
|
13
|
-
const value = this._ownerElement.getAttribute(this._attributeName);
|
|
14
|
-
if (!value) return [];
|
|
15
|
-
return value.split(/\s+/).filter((t) => t.length > 0);
|
|
16
|
-
}
|
|
17
|
-
_setTokens(tokens) {
|
|
18
|
-
const value = tokens.join(" ");
|
|
19
|
-
if (value) {
|
|
20
|
-
this._ownerElement.setAttribute(this._attributeName, value);
|
|
21
|
-
} else {
|
|
22
|
-
this._ownerElement.removeAttribute(this._attributeName);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
get length() {
|
|
26
|
-
return this._getTokens().length;
|
|
27
|
-
}
|
|
28
|
-
get value() {
|
|
29
|
-
return this._ownerElement.getAttribute(this._attributeName) ?? "";
|
|
30
|
-
}
|
|
31
|
-
set value(val) {
|
|
32
|
-
if (val) {
|
|
33
|
-
this._ownerElement.setAttribute(this._attributeName, val);
|
|
34
|
-
} else {
|
|
35
|
-
this._ownerElement.removeAttribute(this._attributeName);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
item(index) {
|
|
39
|
-
const tokens = this._getTokens();
|
|
40
|
-
return index >= 0 && index < tokens.length ? tokens[index] : null;
|
|
41
|
-
}
|
|
42
|
-
contains(token) {
|
|
43
|
-
return this._getTokens().includes(token);
|
|
44
|
-
}
|
|
45
|
-
add(...tokens) {
|
|
46
|
-
const current = this._getTokens();
|
|
47
|
-
for (const token of tokens) {
|
|
48
|
-
if (token && !current.includes(token)) {
|
|
49
|
-
current.push(token);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
this._setTokens(current);
|
|
53
|
-
}
|
|
54
|
-
remove(...tokens) {
|
|
55
|
-
const current = this._getTokens().filter((t) => !tokens.includes(t));
|
|
56
|
-
this._setTokens(current);
|
|
57
|
-
}
|
|
58
|
-
toggle(token, force) {
|
|
59
|
-
const has = this.contains(token);
|
|
60
|
-
if (force !== undefined) {
|
|
61
|
-
if (force) {
|
|
62
|
-
this.add(token);
|
|
63
|
-
return true;
|
|
64
|
-
} else {
|
|
65
|
-
this.remove(token);
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (has) {
|
|
70
|
-
this.remove(token);
|
|
71
|
-
return false;
|
|
72
|
-
} else {
|
|
73
|
-
this.add(token);
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
replace(token, newToken) {
|
|
78
|
-
const tokens = this._getTokens();
|
|
79
|
-
const idx = tokens.indexOf(token);
|
|
80
|
-
if (idx === -1) return false;
|
|
81
|
-
tokens[idx] = newToken;
|
|
82
|
-
this._setTokens(tokens);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
supports(_token) {
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
forEach(callback) {
|
|
89
|
-
const tokens = this._getTokens();
|
|
90
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
91
|
-
callback(tokens[i], i, this);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
keys() {
|
|
95
|
-
return this._getTokens().keys();
|
|
96
|
-
}
|
|
97
|
-
values() {
|
|
98
|
-
return this._getTokens().values();
|
|
99
|
-
}
|
|
100
|
-
entries() {
|
|
101
|
-
return this._getTokens().entries();
|
|
102
|
-
}
|
|
103
|
-
[Symbol.iterator]() {
|
|
104
|
-
return this._getTokens().values();
|
|
105
|
-
}
|
|
106
|
-
toString() {
|
|
107
|
-
return this.value;
|
|
108
|
-
}
|
|
109
|
-
get [Symbol.toStringTag]() {
|
|
110
|
-
return "DOMTokenList";
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
export { DOMTokenList };
|
|
1
|
+
var e=class{constructor(e,t){this._ownerElement=e,this._attributeName=t}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let t=e.join(` `);t?this._ownerElement.setAttribute(this._attributeName,t):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let t=this._getTokens();return e>=0&&e<t.length?t[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let t=this._getTokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._setTokens(t)}remove(...e){let t=this._getTokens().filter(t=>!e.includes(t));this._setTokens(t)}toggle(e,t){let n=this.contains(e);return t===void 0?n?(this.remove(e),!1):(this.add(e),!0):t?(this.add(e),!0):(this.remove(e),!1)}replace(e,t){let n=this._getTokens(),r=n.indexOf(e);return r===-1?!1:(n[r]=t,this._setTokens(n),!0)}supports(e){return!0}forEach(e){let t=this._getTokens();for(let n=0;n<t.length;n++)e(t[n],n,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};export{e as DOMTokenList};
|