@native-dom/runtime 0.0.2
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/LICENSE +22 -0
- package/README.md +44 -0
- package/dist/attributes.d.ts +20 -0
- package/dist/attributes.d.ts.map +1 -0
- package/dist/attributes.js +145 -0
- package/dist/attributes.js.map +1 -0
- package/dist/css.d.ts +139 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +573 -0
- package/dist/css.js.map +1 -0
- package/dist/custom-elements.d.ts +22 -0
- package/dist/custom-elements.d.ts.map +1 -0
- package/dist/custom-elements.js +62 -0
- package/dist/custom-elements.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-init.d.ts +93 -0
- package/dist/event-init.d.ts.map +1 -0
- package/dist/event-init.js +2 -0
- package/dist/event-init.js.map +1 -0
- package/dist/events.d.ts +164 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +470 -0
- package/dist/events.js.map +1 -0
- package/dist/geometry.d.ts +46 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +73 -0
- package/dist/geometry.js.map +1 -0
- package/dist/history.d.ts +16 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +64 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +824 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3685 -0
- package/dist/index.js.map +1 -0
- package/dist/observers.d.ts +49 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +59 -0
- package/dist/observers.js.map +1 -0
- package/dist/platform.d.ts +77 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +216 -0
- package/dist/platform.js.map +1 -0
- package/dist/stats.d.ts +33 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +105 -0
- package/dist/stats.js.map +1 -0
- package/package.json +51 -0
package/dist/css.js
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { DOMException } from "./errors.js";
|
|
2
|
+
export class CSSStyleDeclaration {
|
|
3
|
+
parentRule = null;
|
|
4
|
+
#properties = new Map();
|
|
5
|
+
#element;
|
|
6
|
+
#outlineNone = false;
|
|
7
|
+
constructor(cssText = "", element = null) {
|
|
8
|
+
this.#element = element;
|
|
9
|
+
this.cssText = cssText;
|
|
10
|
+
}
|
|
11
|
+
get cssText() {
|
|
12
|
+
return this.#orderedProperties()
|
|
13
|
+
.map(([name, value]) => `${name}: ${value};`)
|
|
14
|
+
.join(" ");
|
|
15
|
+
}
|
|
16
|
+
set cssText(value) {
|
|
17
|
+
this.#properties.clear();
|
|
18
|
+
this.#outlineNone = false;
|
|
19
|
+
for (const declaration of value.split(";")) {
|
|
20
|
+
const [name, ...rest] = declaration.split(":");
|
|
21
|
+
if (!name || rest.length === 0) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
this.#properties.set(normalizeStyleName(name), rest.join(":").trim());
|
|
25
|
+
}
|
|
26
|
+
this.#sync();
|
|
27
|
+
}
|
|
28
|
+
get length() {
|
|
29
|
+
return this.#orderedProperties().length;
|
|
30
|
+
}
|
|
31
|
+
get display() {
|
|
32
|
+
return this.getPropertyValue("display");
|
|
33
|
+
}
|
|
34
|
+
set display(value) {
|
|
35
|
+
this.setProperty("display", value);
|
|
36
|
+
}
|
|
37
|
+
get flexDirection() {
|
|
38
|
+
return this.getPropertyValue("flex-direction");
|
|
39
|
+
}
|
|
40
|
+
set flexDirection(value) {
|
|
41
|
+
this.setProperty("flex-direction", value);
|
|
42
|
+
}
|
|
43
|
+
get backgroundColor() {
|
|
44
|
+
return this.getPropertyValue("background-color");
|
|
45
|
+
}
|
|
46
|
+
set backgroundColor(value) {
|
|
47
|
+
this.setProperty("background-color", value);
|
|
48
|
+
}
|
|
49
|
+
get color() {
|
|
50
|
+
return this.getPropertyValue("color");
|
|
51
|
+
}
|
|
52
|
+
set color(value) {
|
|
53
|
+
this.setProperty("color", value);
|
|
54
|
+
}
|
|
55
|
+
get visibility() {
|
|
56
|
+
return this.getPropertyValue("visibility");
|
|
57
|
+
}
|
|
58
|
+
set visibility(value) {
|
|
59
|
+
this.setProperty("visibility", value);
|
|
60
|
+
}
|
|
61
|
+
get pointerEvents() {
|
|
62
|
+
return this.getPropertyValue("pointer-events");
|
|
63
|
+
}
|
|
64
|
+
set pointerEvents(value) {
|
|
65
|
+
this.setProperty("pointer-events", value);
|
|
66
|
+
}
|
|
67
|
+
get opacity() {
|
|
68
|
+
return this.getPropertyValue("opacity");
|
|
69
|
+
}
|
|
70
|
+
set opacity(value) {
|
|
71
|
+
this.setProperty("opacity", value);
|
|
72
|
+
}
|
|
73
|
+
get outlineColor() {
|
|
74
|
+
return this.getPropertyValue("outline-color");
|
|
75
|
+
}
|
|
76
|
+
set outlineColor(value) {
|
|
77
|
+
this.setProperty("outline-color", value);
|
|
78
|
+
}
|
|
79
|
+
get outlineStyle() {
|
|
80
|
+
return this.getPropertyValue("outline-style");
|
|
81
|
+
}
|
|
82
|
+
set outlineStyle(value) {
|
|
83
|
+
this.setProperty("outline-style", value);
|
|
84
|
+
}
|
|
85
|
+
get outlineWidth() {
|
|
86
|
+
return this.getPropertyValue("outline-width");
|
|
87
|
+
}
|
|
88
|
+
set outlineWidth(value) {
|
|
89
|
+
this.setProperty("outline-width", value);
|
|
90
|
+
}
|
|
91
|
+
get outline() {
|
|
92
|
+
return this.getPropertyValue("outline");
|
|
93
|
+
}
|
|
94
|
+
set outline(value) {
|
|
95
|
+
if (String(value).trim() === "none") {
|
|
96
|
+
this.#properties.delete("outline");
|
|
97
|
+
this.#properties.delete("outline-color");
|
|
98
|
+
this.#properties.delete("outline-style");
|
|
99
|
+
this.#properties.delete("outline-width");
|
|
100
|
+
this.#outlineNone = true;
|
|
101
|
+
this.#sync();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.setProperty("outline", value);
|
|
105
|
+
}
|
|
106
|
+
get animation() {
|
|
107
|
+
return this.getPropertyValue("animation");
|
|
108
|
+
}
|
|
109
|
+
set animation(value) {
|
|
110
|
+
this.setProperty("animation", value);
|
|
111
|
+
}
|
|
112
|
+
get content() {
|
|
113
|
+
return this.getPropertyValue("content");
|
|
114
|
+
}
|
|
115
|
+
set content(value) {
|
|
116
|
+
this.setProperty("content", value);
|
|
117
|
+
}
|
|
118
|
+
get width() {
|
|
119
|
+
return this.getPropertyValue("width");
|
|
120
|
+
}
|
|
121
|
+
set width(value) {
|
|
122
|
+
this.setProperty("width", value);
|
|
123
|
+
}
|
|
124
|
+
get inlineSize() {
|
|
125
|
+
return this.getPropertyValue("inline-size");
|
|
126
|
+
}
|
|
127
|
+
set inlineSize(value) {
|
|
128
|
+
this.setProperty("inline-size", value);
|
|
129
|
+
}
|
|
130
|
+
get minWidth() {
|
|
131
|
+
return this.getPropertyValue("min-width");
|
|
132
|
+
}
|
|
133
|
+
set minWidth(value) {
|
|
134
|
+
this.setProperty("min-width", value);
|
|
135
|
+
}
|
|
136
|
+
get height() {
|
|
137
|
+
return this.getPropertyValue("height");
|
|
138
|
+
}
|
|
139
|
+
set height(value) {
|
|
140
|
+
this.setProperty("height", value);
|
|
141
|
+
}
|
|
142
|
+
get blockSize() {
|
|
143
|
+
return this.getPropertyValue("block-size");
|
|
144
|
+
}
|
|
145
|
+
set blockSize(value) {
|
|
146
|
+
this.setProperty("block-size", value);
|
|
147
|
+
}
|
|
148
|
+
get border() {
|
|
149
|
+
return this.getPropertyValue("border");
|
|
150
|
+
}
|
|
151
|
+
set border(value) {
|
|
152
|
+
this.setProperty("border", value);
|
|
153
|
+
}
|
|
154
|
+
get clip() {
|
|
155
|
+
return this.getPropertyValue("clip");
|
|
156
|
+
}
|
|
157
|
+
set clip(value) {
|
|
158
|
+
this.setProperty("clip", value);
|
|
159
|
+
}
|
|
160
|
+
get clipPath() {
|
|
161
|
+
return this.getPropertyValue("clip-path");
|
|
162
|
+
}
|
|
163
|
+
set clipPath(value) {
|
|
164
|
+
this.setProperty("clip-path", value);
|
|
165
|
+
}
|
|
166
|
+
get caretColor() {
|
|
167
|
+
return this.getPropertyValue("caret-color");
|
|
168
|
+
}
|
|
169
|
+
set caretColor(value) {
|
|
170
|
+
this.setProperty("caret-color", value);
|
|
171
|
+
}
|
|
172
|
+
get margin() {
|
|
173
|
+
return this.getPropertyValue("margin");
|
|
174
|
+
}
|
|
175
|
+
set margin(value) {
|
|
176
|
+
this.setProperty("margin", value);
|
|
177
|
+
}
|
|
178
|
+
get overflow() {
|
|
179
|
+
return this.getPropertyValue("overflow");
|
|
180
|
+
}
|
|
181
|
+
set overflow(value) {
|
|
182
|
+
this.setProperty("overflow", value);
|
|
183
|
+
}
|
|
184
|
+
get padding() {
|
|
185
|
+
return this.getPropertyValue("padding");
|
|
186
|
+
}
|
|
187
|
+
set padding(value) {
|
|
188
|
+
this.setProperty("padding", value);
|
|
189
|
+
}
|
|
190
|
+
get whiteSpace() {
|
|
191
|
+
return this.getPropertyValue("white-space");
|
|
192
|
+
}
|
|
193
|
+
set whiteSpace(value) {
|
|
194
|
+
this.setProperty("white-space", value);
|
|
195
|
+
}
|
|
196
|
+
get wordWrap() {
|
|
197
|
+
return this.getPropertyValue("word-wrap");
|
|
198
|
+
}
|
|
199
|
+
set wordWrap(value) {
|
|
200
|
+
this.setProperty("word-wrap", value);
|
|
201
|
+
}
|
|
202
|
+
get transitionDuration() {
|
|
203
|
+
return this.getPropertyValue("transition-duration");
|
|
204
|
+
}
|
|
205
|
+
set transitionDuration(value) {
|
|
206
|
+
this.setProperty("transition-duration", value);
|
|
207
|
+
}
|
|
208
|
+
get animationDuration() {
|
|
209
|
+
return this.getPropertyValue("animation-duration");
|
|
210
|
+
}
|
|
211
|
+
set animationDuration(value) {
|
|
212
|
+
this.setProperty("animation-duration", value);
|
|
213
|
+
}
|
|
214
|
+
get animationName() {
|
|
215
|
+
return this.getPropertyValue("animation-name");
|
|
216
|
+
}
|
|
217
|
+
set animationName(value) {
|
|
218
|
+
this.setProperty("animation-name", value);
|
|
219
|
+
}
|
|
220
|
+
get top() {
|
|
221
|
+
return this.getPropertyValue("top");
|
|
222
|
+
}
|
|
223
|
+
set top(value) {
|
|
224
|
+
this.setProperty("top", value);
|
|
225
|
+
}
|
|
226
|
+
get right() {
|
|
227
|
+
return this.getPropertyValue("right");
|
|
228
|
+
}
|
|
229
|
+
set right(value) {
|
|
230
|
+
this.setProperty("right", value);
|
|
231
|
+
}
|
|
232
|
+
get bottom() {
|
|
233
|
+
return this.getPropertyValue("bottom");
|
|
234
|
+
}
|
|
235
|
+
set bottom(value) {
|
|
236
|
+
this.setProperty("bottom", value);
|
|
237
|
+
}
|
|
238
|
+
get left() {
|
|
239
|
+
return this.getPropertyValue("left");
|
|
240
|
+
}
|
|
241
|
+
set left(value) {
|
|
242
|
+
this.setProperty("left", value);
|
|
243
|
+
}
|
|
244
|
+
get position() {
|
|
245
|
+
return this.getPropertyValue("position");
|
|
246
|
+
}
|
|
247
|
+
set position(value) {
|
|
248
|
+
this.setProperty("position", value);
|
|
249
|
+
}
|
|
250
|
+
get transform() {
|
|
251
|
+
return this.getPropertyValue("transform");
|
|
252
|
+
}
|
|
253
|
+
set transform(value) {
|
|
254
|
+
this.setProperty("transform", value);
|
|
255
|
+
}
|
|
256
|
+
get transformOrigin() {
|
|
257
|
+
return this.getPropertyValue("transform-origin");
|
|
258
|
+
}
|
|
259
|
+
set transformOrigin(value) {
|
|
260
|
+
this.setProperty("transform-origin", value);
|
|
261
|
+
}
|
|
262
|
+
get WebkitTransform() {
|
|
263
|
+
return this.getPropertyValue("WebkitTransform");
|
|
264
|
+
}
|
|
265
|
+
set WebkitTransform(value) {
|
|
266
|
+
this.setProperty("WebkitTransform", value);
|
|
267
|
+
}
|
|
268
|
+
get MozTransform() {
|
|
269
|
+
return this.getPropertyValue("MozTransform");
|
|
270
|
+
}
|
|
271
|
+
set MozTransform(value) {
|
|
272
|
+
this.setProperty("MozTransform", value);
|
|
273
|
+
}
|
|
274
|
+
get msTransform() {
|
|
275
|
+
return this.getPropertyValue("msTransform");
|
|
276
|
+
}
|
|
277
|
+
set msTransform(value) {
|
|
278
|
+
this.setProperty("msTransform", value);
|
|
279
|
+
}
|
|
280
|
+
get OTransform() {
|
|
281
|
+
return this.getPropertyValue("OTransform");
|
|
282
|
+
}
|
|
283
|
+
set OTransform(value) {
|
|
284
|
+
this.setProperty("OTransform", value);
|
|
285
|
+
}
|
|
286
|
+
get boxSizing() {
|
|
287
|
+
return this.getPropertyValue("boxSizing");
|
|
288
|
+
}
|
|
289
|
+
set boxSizing(value) {
|
|
290
|
+
this.setProperty("boxSizing", value);
|
|
291
|
+
}
|
|
292
|
+
get zIndex() {
|
|
293
|
+
return this.getPropertyValue("zIndex");
|
|
294
|
+
}
|
|
295
|
+
set zIndex(value) {
|
|
296
|
+
this.setProperty("zIndex", value);
|
|
297
|
+
}
|
|
298
|
+
get touchAction() {
|
|
299
|
+
return this.getPropertyValue("touchAction");
|
|
300
|
+
}
|
|
301
|
+
set touchAction(value) {
|
|
302
|
+
this.setProperty("touchAction", value);
|
|
303
|
+
}
|
|
304
|
+
get userSelect() {
|
|
305
|
+
return this.getPropertyValue("userSelect");
|
|
306
|
+
}
|
|
307
|
+
set userSelect(value) {
|
|
308
|
+
this.setProperty("userSelect", value);
|
|
309
|
+
}
|
|
310
|
+
item(index) {
|
|
311
|
+
return this.#orderedProperties()[index]?.[0] ?? "";
|
|
312
|
+
}
|
|
313
|
+
getPropertyValue(name) {
|
|
314
|
+
const normalized = normalizeStyleName(name);
|
|
315
|
+
if (this.#outlineNone) {
|
|
316
|
+
if (normalized === "outline-color" || normalized === "outline-style") {
|
|
317
|
+
return "none";
|
|
318
|
+
}
|
|
319
|
+
if (normalized === "outline-width") {
|
|
320
|
+
return "initial";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return this.#properties.get(normalized) ?? "";
|
|
324
|
+
}
|
|
325
|
+
setProperty(name, value) {
|
|
326
|
+
const normalized = normalizeStyleName(name);
|
|
327
|
+
if (normalized === "outline" && String(value).trim() === "none") {
|
|
328
|
+
this.outline = "none";
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (isOutlineProperty(normalized)) {
|
|
332
|
+
this.#outlineNone = false;
|
|
333
|
+
}
|
|
334
|
+
if (value == null || String(value).trim() === "") {
|
|
335
|
+
this.#properties.delete(normalized);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
this.#properties.set(normalized, normalizeStyleValue(normalized, value));
|
|
339
|
+
}
|
|
340
|
+
this.#sync();
|
|
341
|
+
}
|
|
342
|
+
removeProperty(name) {
|
|
343
|
+
const normalized = normalizeStyleName(name);
|
|
344
|
+
const previous = this.getPropertyValue(normalized);
|
|
345
|
+
if (isOutlineProperty(normalized)) {
|
|
346
|
+
this.#outlineNone = false;
|
|
347
|
+
}
|
|
348
|
+
this.#properties.delete(normalized);
|
|
349
|
+
this.#sync();
|
|
350
|
+
return previous;
|
|
351
|
+
}
|
|
352
|
+
#orderedProperties() {
|
|
353
|
+
const entries = [...this.#properties];
|
|
354
|
+
if (this.#outlineNone) {
|
|
355
|
+
entries.push(["outline-color", "none"]);
|
|
356
|
+
entries.push(["outline-style", "none"]);
|
|
357
|
+
entries.push(["outline-width", "initial"]);
|
|
358
|
+
}
|
|
359
|
+
return entries;
|
|
360
|
+
}
|
|
361
|
+
#sync() {
|
|
362
|
+
if (this.#element) {
|
|
363
|
+
const cssText = this.cssText;
|
|
364
|
+
if (cssText) {
|
|
365
|
+
this.#element.setAttribute("style", cssText);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
this.#element.removeAttribute("style");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
export class CSSRule {
|
|
374
|
+
static STYLE_RULE = 1;
|
|
375
|
+
static MEDIA_RULE = 4;
|
|
376
|
+
type;
|
|
377
|
+
parentRule = null;
|
|
378
|
+
parentStyleSheet = null;
|
|
379
|
+
constructor(type) {
|
|
380
|
+
this.type = type;
|
|
381
|
+
}
|
|
382
|
+
get cssText() {
|
|
383
|
+
return "";
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
export class CSSStyleRule extends CSSRule {
|
|
387
|
+
selectorText;
|
|
388
|
+
style;
|
|
389
|
+
constructor(selectorText, styleText) {
|
|
390
|
+
super(CSSRule.STYLE_RULE);
|
|
391
|
+
this.selectorText = selectorText.trim();
|
|
392
|
+
this.style = new CSSStyleDeclaration(styleText);
|
|
393
|
+
this.style.parentRule = this;
|
|
394
|
+
}
|
|
395
|
+
get cssText() {
|
|
396
|
+
const declarations = this.style.cssText;
|
|
397
|
+
return `${this.selectorText} {${declarations ? ` ${declarations} ` : " "}}`;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
export class CSSMediaRule extends CSSRule {
|
|
401
|
+
conditionText;
|
|
402
|
+
cssRules = [];
|
|
403
|
+
media;
|
|
404
|
+
constructor(conditionText, rules = []) {
|
|
405
|
+
super(CSSRule.MEDIA_RULE);
|
|
406
|
+
this.conditionText = conditionText.trim();
|
|
407
|
+
this.media = Object.assign([this.conditionText], { mediaText: this.conditionText });
|
|
408
|
+
for (const rule of rules) {
|
|
409
|
+
rule.parentRule = this;
|
|
410
|
+
this.cssRules.push(rule);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
get cssText() {
|
|
414
|
+
const inner = this.cssRules.map((rule) => ` ${rule.cssText}`).join("\n");
|
|
415
|
+
return `@media ${this.conditionText} {\n${inner}\n}`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
export class CSSStyleSheet {
|
|
419
|
+
cssRules = [];
|
|
420
|
+
disabled = false;
|
|
421
|
+
href = null;
|
|
422
|
+
ownerRule = null;
|
|
423
|
+
title = null;
|
|
424
|
+
constructor(cssText = "") {
|
|
425
|
+
if (cssText) {
|
|
426
|
+
this.replaceSync(cssText);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
insertRule(ruleText, index = this.cssRules.length) {
|
|
430
|
+
const normalizedIndex = Number(index);
|
|
431
|
+
if (!Number.isInteger(normalizedIndex) ||
|
|
432
|
+
normalizedIndex < 0 ||
|
|
433
|
+
normalizedIndex > this.cssRules.length) {
|
|
434
|
+
throw new DOMException("The index provided is outside the rule list.", "IndexSizeError");
|
|
435
|
+
}
|
|
436
|
+
const rules = parseCssRules(String(ruleText), this);
|
|
437
|
+
if (rules.length !== 1) {
|
|
438
|
+
throw new DOMException(`Failed to parse the rule '${String(ruleText)}'.`, "SyntaxError");
|
|
439
|
+
}
|
|
440
|
+
this.cssRules.splice(normalizedIndex, 0, rules[0]);
|
|
441
|
+
return normalizedIndex;
|
|
442
|
+
}
|
|
443
|
+
deleteRule(index = 0) {
|
|
444
|
+
const normalizedIndex = Number(index);
|
|
445
|
+
if (Number.isInteger(normalizedIndex) &&
|
|
446
|
+
normalizedIndex >= 0 &&
|
|
447
|
+
normalizedIndex < this.cssRules.length) {
|
|
448
|
+
this.cssRules.splice(normalizedIndex, 1);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
replaceSync(cssText) {
|
|
452
|
+
this.cssRules.splice(0, this.cssRules.length, ...parseCssRules(String(cssText), this));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function parseCssRules(cssText, sheet) {
|
|
456
|
+
const rules = [];
|
|
457
|
+
const source = stripCssComments(cssText);
|
|
458
|
+
let cursor = 0;
|
|
459
|
+
while (cursor < source.length) {
|
|
460
|
+
while (/\s/.test(source[cursor] ?? "")) {
|
|
461
|
+
cursor++;
|
|
462
|
+
}
|
|
463
|
+
if (cursor >= source.length) {
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
const openBrace = source.indexOf("{", cursor);
|
|
467
|
+
if (openBrace === -1) {
|
|
468
|
+
throw new DOMException(`Failed to parse the rule '${cssText}'.`, "SyntaxError");
|
|
469
|
+
}
|
|
470
|
+
const closeBrace = findMatchingCssBrace(source, openBrace);
|
|
471
|
+
if (closeBrace === -1) {
|
|
472
|
+
throw new DOMException(`Failed to parse the rule '${cssText}'.`, "SyntaxError");
|
|
473
|
+
}
|
|
474
|
+
const prelude = source.slice(cursor, openBrace).trim();
|
|
475
|
+
const block = source.slice(openBrace + 1, closeBrace).trim();
|
|
476
|
+
const rule = createCssRule(prelude, block, sheet, cssText);
|
|
477
|
+
rules.push(rule);
|
|
478
|
+
cursor = closeBrace + 1;
|
|
479
|
+
}
|
|
480
|
+
return rules;
|
|
481
|
+
}
|
|
482
|
+
function createCssRule(prelude, block, sheet, sourceText) {
|
|
483
|
+
if (!prelude) {
|
|
484
|
+
throw new DOMException(`Failed to parse the rule '${sourceText}'.`, "SyntaxError");
|
|
485
|
+
}
|
|
486
|
+
if (prelude.toLowerCase().startsWith("@media ")) {
|
|
487
|
+
const mediaRule = new CSSMediaRule(prelude.slice(7), parseCssRules(block, sheet));
|
|
488
|
+
mediaRule.parentStyleSheet = sheet;
|
|
489
|
+
for (const child of mediaRule.cssRules) {
|
|
490
|
+
child.parentRule = mediaRule;
|
|
491
|
+
child.parentStyleSheet = sheet;
|
|
492
|
+
}
|
|
493
|
+
return mediaRule;
|
|
494
|
+
}
|
|
495
|
+
if (prelude.startsWith("@") || !block.includes(":")) {
|
|
496
|
+
throw new DOMException(`Failed to parse the rule '${sourceText}'.`, "SyntaxError");
|
|
497
|
+
}
|
|
498
|
+
const rule = new CSSStyleRule(prelude, block);
|
|
499
|
+
rule.parentStyleSheet = sheet;
|
|
500
|
+
return rule;
|
|
501
|
+
}
|
|
502
|
+
function findMatchingCssBrace(source, openBrace) {
|
|
503
|
+
let depth = 0;
|
|
504
|
+
let quote = null;
|
|
505
|
+
for (let index = openBrace; index < source.length; index++) {
|
|
506
|
+
const character = source[index];
|
|
507
|
+
if (quote) {
|
|
508
|
+
if (character === "\\" && index + 1 < source.length) {
|
|
509
|
+
index++;
|
|
510
|
+
}
|
|
511
|
+
else if (character === quote) {
|
|
512
|
+
quote = null;
|
|
513
|
+
}
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (character === "\"" || character === "'") {
|
|
517
|
+
quote = character;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
if (character === "{") {
|
|
521
|
+
depth++;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (character === "}") {
|
|
525
|
+
depth--;
|
|
526
|
+
if (depth === 0) {
|
|
527
|
+
return index;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return -1;
|
|
532
|
+
}
|
|
533
|
+
function stripCssComments(cssText) {
|
|
534
|
+
return cssText.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
535
|
+
}
|
|
536
|
+
function isOutlineProperty(name) {
|
|
537
|
+
return (name === "outline" ||
|
|
538
|
+
name === "outline-color" ||
|
|
539
|
+
name === "outline-style" ||
|
|
540
|
+
name === "outline-width");
|
|
541
|
+
}
|
|
542
|
+
function normalizeStyleName(name) {
|
|
543
|
+
return name
|
|
544
|
+
.trim()
|
|
545
|
+
.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`)
|
|
546
|
+
.toLowerCase();
|
|
547
|
+
}
|
|
548
|
+
const numericLengthProperties = new Set([
|
|
549
|
+
"block-size",
|
|
550
|
+
"border",
|
|
551
|
+
"bottom",
|
|
552
|
+
"height",
|
|
553
|
+
"inline-size",
|
|
554
|
+
"left",
|
|
555
|
+
"margin",
|
|
556
|
+
"min-width",
|
|
557
|
+
"padding",
|
|
558
|
+
"right",
|
|
559
|
+
"top",
|
|
560
|
+
"width"
|
|
561
|
+
]);
|
|
562
|
+
function normalizeStyleValue(name, value) {
|
|
563
|
+
if (typeof value === "number" && numericLengthProperties.has(name)) {
|
|
564
|
+
return `${value}px`;
|
|
565
|
+
}
|
|
566
|
+
if (typeof value === "string" &&
|
|
567
|
+
numericLengthProperties.has(name) &&
|
|
568
|
+
/^-?\d+(?:\.\d+)?$/.test(value.trim())) {
|
|
569
|
+
return `${value.trim()}px`;
|
|
570
|
+
}
|
|
571
|
+
return String(value).trim();
|
|
572
|
+
}
|
|
573
|
+
//# sourceMappingURL=css.js.map
|
package/dist/css.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,OAAO,mBAAmB;IAC9B,UAAU,GAAmB,IAAI,CAAC;IAEzB,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,QAAQ,CAAiB;IAClC,YAAY,GAAG,KAAK,CAAC;IAErB,YAAY,OAAO,GAAG,EAAE,EAAE,UAA0B,IAAI;QACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,kBAAkB,EAAE;aAC7B,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;aAC5C,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,KAAa;QACvB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,GAAG,CA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AC;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,OAAO;IACP,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AAEH,SAAS,mBAAmB,CAAC,IAAY,EAAE,KAAsB;IAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACnE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IACD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC;QACjC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EACtC,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLElement, Node } from "./index.js";
|
|
2
|
+
export type CustomElementConstructor = {
|
|
3
|
+
new (): HTMLElement;
|
|
4
|
+
observedAttributes?: readonly string[];
|
|
5
|
+
};
|
|
6
|
+
export interface CustomElementDefinition {
|
|
7
|
+
readonly constructor: CustomElementConstructor;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly observedAttributes: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export declare class CustomElementRegistry {
|
|
12
|
+
#private;
|
|
13
|
+
define(name: string, constructor: CustomElementConstructor): void;
|
|
14
|
+
get(name: string): CustomElementConstructor | undefined;
|
|
15
|
+
getName(constructor: CustomElementConstructor): string | null;
|
|
16
|
+
whenDefined(name: string): Promise<void>;
|
|
17
|
+
upgrade(_root: Node): void;
|
|
18
|
+
_definitionFor(name: string): CustomElementDefinition | undefined;
|
|
19
|
+
_hasDefinitions(): boolean;
|
|
20
|
+
_version(): number;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=custom-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-elements.d.ts","sourceRoot":"","sources":["../src/custom-elements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,WAAW,CAAC;IACpB,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CAChD;AAED,qBAAa,qBAAqB;;IAMhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,wBAAwB,GAAG,IAAI;IAqBjE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAIvD,OAAO,CAAC,WAAW,EAAE,wBAAwB,GAAG,MAAM,GAAG,IAAI;IAI7D,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxC,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAE1B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;IAIjE,eAAe,IAAI,OAAO;IAI1B,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DOMException } from "./errors.js";
|
|
2
|
+
export class CustomElementRegistry {
|
|
3
|
+
#definitions = new Map();
|
|
4
|
+
#constructorNames = new Map();
|
|
5
|
+
#whenDefined = new Map();
|
|
6
|
+
#version = 0;
|
|
7
|
+
define(name, constructor) {
|
|
8
|
+
const normalizedName = validateCustomElementName(name);
|
|
9
|
+
if (this.#definitions.has(normalizedName) || this.#constructorNames.has(constructor)) {
|
|
10
|
+
throw new DOMException(`The custom element "${normalizedName}" has already been defined.`, "DOMException");
|
|
11
|
+
}
|
|
12
|
+
const definition = {
|
|
13
|
+
constructor,
|
|
14
|
+
name: normalizedName,
|
|
15
|
+
observedAttributes: [...(constructor.observedAttributes ?? [])].map((attribute) => String(attribute).toLowerCase())
|
|
16
|
+
};
|
|
17
|
+
this.#definitions.set(normalizedName, definition);
|
|
18
|
+
this.#constructorNames.set(constructor, normalizedName);
|
|
19
|
+
this.#version++;
|
|
20
|
+
this.#whenDefined.get(normalizedName)?.resolve();
|
|
21
|
+
}
|
|
22
|
+
get(name) {
|
|
23
|
+
return this.#definitions.get(String(name).toLowerCase())?.constructor;
|
|
24
|
+
}
|
|
25
|
+
getName(constructor) {
|
|
26
|
+
return this.#constructorNames.get(constructor) ?? null;
|
|
27
|
+
}
|
|
28
|
+
whenDefined(name) {
|
|
29
|
+
const normalizedName = validateCustomElementName(name);
|
|
30
|
+
if (this.#definitions.has(normalizedName)) {
|
|
31
|
+
return Promise.resolve();
|
|
32
|
+
}
|
|
33
|
+
let pending = this.#whenDefined.get(normalizedName);
|
|
34
|
+
if (!pending) {
|
|
35
|
+
let resolve;
|
|
36
|
+
const promise = new Promise((resolver) => {
|
|
37
|
+
resolve = resolver;
|
|
38
|
+
});
|
|
39
|
+
pending = { promise, resolve };
|
|
40
|
+
this.#whenDefined.set(normalizedName, pending);
|
|
41
|
+
}
|
|
42
|
+
return pending.promise;
|
|
43
|
+
}
|
|
44
|
+
upgrade(_root) { }
|
|
45
|
+
_definitionFor(name) {
|
|
46
|
+
return this.#definitions.get(String(name).toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
_hasDefinitions() {
|
|
49
|
+
return this.#definitions.size > 0;
|
|
50
|
+
}
|
|
51
|
+
_version() {
|
|
52
|
+
return this.#version;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function validateCustomElementName(name) {
|
|
56
|
+
const normalizedName = String(name).toLowerCase();
|
|
57
|
+
if (!/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(normalizedName)) {
|
|
58
|
+
throw new DOMException(`"${name}" is not a valid custom element name.`, "SyntaxError");
|
|
59
|
+
}
|
|
60
|
+
return normalizedName;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=custom-elements.js.map
|