@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.
- package/lib/esm/_virtual/_rolldown/runtime.js +18 -0
- package/lib/esm/attr.js +37 -30
- package/lib/esm/character-data.js +61 -54
- package/lib/esm/comment.js +26 -19
- package/lib/esm/document-fragment.js +116 -109
- package/lib/esm/document.js +75 -81
- package/lib/esm/dom-matrix.js +158 -123
- package/lib/esm/dom-token-list.js +114 -108
- package/lib/esm/element.js +244 -246
- package/lib/esm/font-face.js +94 -89
- package/lib/esm/gst-time.js +17 -6
- package/lib/esm/html-canvas-element.js +82 -75
- package/lib/esm/html-element.js +424 -424
- package/lib/esm/html-image-element.js +226 -225
- package/lib/esm/html-media-element.js +117 -114
- package/lib/esm/html-video-element.js +110 -108
- package/lib/esm/image.js +27 -21
- package/lib/esm/index.js +13 -45
- package/lib/esm/intersection-observer.js +22 -18
- package/lib/esm/location-stub.js +25 -23
- package/lib/esm/match-media.js +18 -19
- package/lib/esm/mutation-observer.js +18 -13
- package/lib/esm/named-node-map.js +121 -121
- package/lib/esm/namespace-uri.js +9 -8
- package/lib/esm/node-list.js +39 -33
- package/lib/esm/node-type.js +13 -12
- package/lib/esm/node.js +241 -246
- package/lib/esm/property-symbol.js +36 -30
- package/lib/esm/register/canvas.js +11 -7
- package/lib/esm/register/document.js +19 -18
- package/lib/esm/register/font-face.js +10 -6
- package/lib/esm/register/helpers.js +14 -12
- package/lib/esm/register/image.js +4 -0
- package/lib/esm/register/location.js +4 -0
- package/lib/esm/register/match-media.js +4 -0
- package/lib/esm/register/navigator.js +4 -1
- package/lib/esm/register/observers.js +5 -1
- package/lib/esm/resize-observer.js +15 -12
- package/lib/esm/text.js +56 -49
- package/lib/esm/types/index.js +3 -3
- package/package.json +11 -11
package/lib/esm/dom-matrix.js
CHANGED
|
@@ -1,124 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
//#region src/dom-matrix.ts
|
|
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
|
+
}
|
|
124
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,109 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
//#region src/dom-token-list.ts
|
|
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
|
+
}
|
|
109
112
|
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { DOMTokenList };
|