wrec 0.27.1 → 0.28.0
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/dist/{wrec-TaEXMJIq.js → wrec-S6tBBntE.js} +140 -146
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.es.js +1 -1
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ var r = typeof window < "u" && window.document !== void 0, i = class extends Err
|
|
|
28
28
|
static #e = /* @__PURE__ */ new Map();
|
|
29
29
|
static {
|
|
30
30
|
r && window.addEventListener("beforeunload", () => {
|
|
31
|
-
for (let [e, t] of this.#e.entries()) if (t.#
|
|
31
|
+
for (let [e, t] of this.#e.entries()) if (t.#i) {
|
|
32
32
|
let r = n(t);
|
|
33
33
|
sessionStorage.setItem("wrec-state-" + e, JSON.stringify(r));
|
|
34
34
|
}
|
|
@@ -39,74 +39,55 @@ var r = typeof window < "u" && window.document !== void 0, i = class extends Err
|
|
|
39
39
|
}
|
|
40
40
|
#t = [];
|
|
41
41
|
#n = Symbol("objectId");
|
|
42
|
-
#r
|
|
42
|
+
#r;
|
|
43
43
|
#i;
|
|
44
44
|
#a;
|
|
45
|
-
#o;
|
|
46
45
|
constructor(n, a, o) {
|
|
47
46
|
if (!n) throw new i("name cannot be empty");
|
|
48
47
|
if (e.#e.has(n)) throw new i(`WrecState with name "${n}" already exists`);
|
|
49
|
-
if (this.#
|
|
48
|
+
if (this.#r = n, this.#i = a, this.#a = t({}, this.#o.bind(this)), a && r) {
|
|
50
49
|
let e = sessionStorage.getItem("wrec-state-" + n), t = e ? JSON.parse(e) : void 0;
|
|
51
50
|
t && (o = t);
|
|
52
51
|
}
|
|
53
52
|
if (o) for (let [e, t] of Object.entries(o)) this.addProperty(e, t);
|
|
54
53
|
e.#e.set(n, this);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let { propertyMap: e } = n;
|
|
60
|
-
for (let [n, r] of Object.entries(t)) e[n] = r;
|
|
61
|
-
} else this.#r.push({
|
|
62
|
-
listenerRef: new WeakRef(e),
|
|
63
|
-
propertyMap: t
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
addChangeCallback(e, t = []) {
|
|
67
|
-
if (this.#t.some((t) => t.callback === e)) throw new i("WrecState addChangedCallback was passed a callback that was already added");
|
|
68
|
-
this.#t.push({
|
|
55
|
+
subscribe(e, t = []) {
|
|
56
|
+
if (this.#t.some((t) => t.callback === e)) throw new i("WrecState subscribe was passed a callback that was already added");
|
|
57
|
+
let n = {
|
|
69
58
|
callback: e,
|
|
70
59
|
statePaths: t
|
|
71
|
-
}
|
|
60
|
+
};
|
|
61
|
+
return this.#t.push(n), () => {
|
|
62
|
+
this.#t = this.#t.filter((e) => e !== n);
|
|
63
|
+
};
|
|
72
64
|
}
|
|
73
65
|
addProperty(e, t) {
|
|
74
66
|
Object.defineProperty(this, e, {
|
|
75
67
|
enumerable: !0,
|
|
76
68
|
get() {
|
|
77
|
-
return this.#
|
|
69
|
+
return this.#a[e];
|
|
78
70
|
},
|
|
79
71
|
set(t) {
|
|
80
|
-
this.#
|
|
72
|
+
this.#a[e] = t;
|
|
81
73
|
}
|
|
82
|
-
}), this.#
|
|
74
|
+
}), this.#a[e] = t;
|
|
83
75
|
}
|
|
84
76
|
get id() {
|
|
85
77
|
return this.#n;
|
|
86
78
|
}
|
|
87
79
|
log() {
|
|
88
|
-
console.log("WrecState:", this.#
|
|
89
|
-
for (let [e, t] of Object.entries(this.#
|
|
90
|
-
}
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let { propertyMap: r } = a, i = Object.keys(r);
|
|
100
|
-
(i.length === 0 || i.includes(e)) && o.changed(e, r[e], n, t, this);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
this.#r = this.#r.filter((e) => !i.has(e));
|
|
104
|
-
}
|
|
105
|
-
removeChangeCallback(e) {
|
|
106
|
-
this.#t = this.#t.filter((t) => t.callback !== e);
|
|
107
|
-
}
|
|
108
|
-
removeListener(e) {
|
|
109
|
-
this.#r = this.#r.filter((t) => t.listenerRef.deref() !== e);
|
|
80
|
+
console.log("WrecState:", this.#r);
|
|
81
|
+
for (let [e, t] of Object.entries(this.#a)) console.log(` ${e} = ${JSON.stringify(t)}`);
|
|
82
|
+
}
|
|
83
|
+
#o(e, t, n) {
|
|
84
|
+
let r = {
|
|
85
|
+
state: this,
|
|
86
|
+
statePath: e,
|
|
87
|
+
oldValue: t,
|
|
88
|
+
newValue: n
|
|
89
|
+
};
|
|
90
|
+
for (let { callback: t, statePaths: n } of this.#t) (n.length === 0 || n.includes(e)) && t(r);
|
|
110
91
|
}
|
|
111
92
|
};
|
|
112
93
|
r && process.env.NODE_ENV === "development" && (window.WrecState = a);
|
|
@@ -297,6 +278,7 @@ var U = class e extends p {
|
|
|
297
278
|
#s = null;
|
|
298
279
|
#c = /* @__PURE__ */ new Map();
|
|
299
280
|
#l = /* @__PURE__ */ new Map();
|
|
281
|
+
#u = /* @__PURE__ */ new Map();
|
|
300
282
|
static define(e) {
|
|
301
283
|
if (this.elementName = e, m.get(e)) throw new h(`custom element ${e} is already defined`);
|
|
302
284
|
m.define(e, this);
|
|
@@ -304,13 +286,13 @@ var U = class e extends p {
|
|
|
304
286
|
constructor() {
|
|
305
287
|
super(), this.attachShadow({ mode: "open" });
|
|
306
288
|
let e = this.#n;
|
|
307
|
-
this.#
|
|
289
|
+
this.#x("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#x("properties") || (e.properties = {}), this.#x("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#x("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#x("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map());
|
|
308
290
|
}
|
|
309
291
|
attributeChangedCallback(t, n, r) {
|
|
310
|
-
t === "disabled" && this.#
|
|
292
|
+
t === "disabled" && this.#h();
|
|
311
293
|
let i = e.getPropName(t);
|
|
312
|
-
if (!this.#
|
|
313
|
-
let e = this.#
|
|
294
|
+
if (!this.#C(i) && this.#S(i)) {
|
|
295
|
+
let e = this.#F(i, r);
|
|
314
296
|
this[i] = e;
|
|
315
297
|
let t = this.#i[i];
|
|
316
298
|
t && this.setFormValue(t, String(e));
|
|
@@ -331,21 +313,21 @@ var U = class e extends p {
|
|
|
331
313
|
}
|
|
332
314
|
for (let e of i) {
|
|
333
315
|
let r = a[e];
|
|
334
|
-
this.#
|
|
316
|
+
this.#k(e, this.#v(r));
|
|
335
317
|
let i = t.get(e) ?? [];
|
|
336
318
|
for (let e of i) n.add(e);
|
|
337
319
|
}
|
|
338
320
|
for (;;) {
|
|
339
321
|
let e = !1;
|
|
340
322
|
for (let t of i) {
|
|
341
|
-
let n = a[t], r = this.#
|
|
342
|
-
JSON.stringify(r) !== JSON.stringify(i) && (this.#
|
|
323
|
+
let n = a[t], r = this.#v(n), i = this[t];
|
|
324
|
+
JSON.stringify(r) !== JSON.stringify(i) && (this.#k(t, r), e = !0);
|
|
343
325
|
}
|
|
344
326
|
if (!e) break;
|
|
345
327
|
}
|
|
346
|
-
this.#
|
|
328
|
+
this.#_([...n]), this.#e = !1;
|
|
347
329
|
}
|
|
348
|
-
async #
|
|
330
|
+
async #d() {
|
|
349
331
|
let e = this.#n, { template: t } = e;
|
|
350
332
|
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await H(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
351
333
|
}
|
|
@@ -360,36 +342,36 @@ var U = class e extends p {
|
|
|
360
342
|
this[t] = n;
|
|
361
343
|
}
|
|
362
344
|
async connectedCallback() {
|
|
363
|
-
this.#
|
|
345
|
+
this.#V(), this.#p(), await this.#d(), this.hasAttribute("disabled") && this.#h(), this.#G(this.shadowRoot), this.#w(this.shadowRoot), this.#B(), this.#f(), this.ready();
|
|
364
346
|
}
|
|
365
|
-
#
|
|
347
|
+
#f() {
|
|
366
348
|
let { properties: e } = this.#n;
|
|
367
|
-
for (let [t, { computed: n }] of Object.entries(e)) n && this.#
|
|
349
|
+
for (let [t, { computed: n }] of Object.entries(e)) n && this.#k(t, this.#v(n));
|
|
368
350
|
}
|
|
369
|
-
#
|
|
351
|
+
#p() {
|
|
370
352
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
371
|
-
for (let [n, r] of Object.entries(t)) r.computed || this.#
|
|
372
|
-
for (let [n, r] of Object.entries(t)) r.computed && this.#
|
|
353
|
+
for (let [n, r] of Object.entries(t)) r.computed || this.#m(n, r, e);
|
|
354
|
+
for (let [n, r] of Object.entries(t)) r.computed && this.#m(n, r, e);
|
|
373
355
|
}
|
|
374
|
-
#
|
|
356
|
+
#m(t, n, r) {
|
|
375
357
|
if (t === "class" || t === "style") throw new h(`"${t}" is a reserved property`);
|
|
376
358
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
377
|
-
n.required && !a && this.#
|
|
359
|
+
n.required && !a && this.#M(this, i, "is a required attribute");
|
|
378
360
|
let o = n.value;
|
|
379
361
|
this.hasOwnProperty(t) && (o = this[t], delete this[t]);
|
|
380
|
-
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#
|
|
381
|
-
this[u] = l, n.computed && this.#
|
|
362
|
+
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#P(t, i) : o ?? O(n), u = "#" + t;
|
|
363
|
+
this[u] = l, n.computed && this.#O(t, n), Object.defineProperty(this, t, {
|
|
382
364
|
enumerable: !0,
|
|
383
365
|
get() {
|
|
384
366
|
return this[u];
|
|
385
367
|
},
|
|
386
368
|
set(e) {
|
|
387
|
-
n.computed && !this.#t.has(t) && this.#
|
|
369
|
+
n.computed && !this.#t.has(t) && this.#M(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = R(e));
|
|
388
370
|
let r = this[u];
|
|
389
371
|
if (e === r) return;
|
|
390
|
-
this.#
|
|
372
|
+
this.#W(t, c, e), this[u] = e;
|
|
391
373
|
let a = this.#l.get(t);
|
|
392
|
-
a && s(a.state, a.stateProp, e), this.#
|
|
374
|
+
a && s(a.state, a.stateProp, e), this.#I(t, c, e, i), this.#e || (this.#L(t), this.#D(t)), this.#z(t, e);
|
|
393
375
|
let o = this.#i[t];
|
|
394
376
|
o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
|
|
395
377
|
tagName: this.localName,
|
|
@@ -400,13 +382,13 @@ var U = class e extends p {
|
|
|
400
382
|
}
|
|
401
383
|
});
|
|
402
384
|
}
|
|
403
|
-
#
|
|
385
|
+
#h() {
|
|
404
386
|
let e = this.hasAttribute("disabled"), t = A(this.shadowRoot);
|
|
405
387
|
for (let n of t) E(n) && (n.disabled = e);
|
|
406
388
|
}
|
|
407
389
|
disconnectedCallback() {
|
|
408
|
-
for (let {
|
|
409
|
-
this.#r.clear(), this.#o.clear(), this.#c.clear(), this.#l.clear();
|
|
390
|
+
for (let { unsubscribe: e } of this.#u.values()) e();
|
|
391
|
+
this.#r.clear(), this.#o.clear(), this.#c.clear(), this.#l.clear(), this.#u.clear();
|
|
410
392
|
}
|
|
411
393
|
dispatch(e, t) {
|
|
412
394
|
this.dispatchEvent(new CustomEvent(e, {
|
|
@@ -418,34 +400,34 @@ var U = class e extends p {
|
|
|
418
400
|
displayIfSet(e, t = "block") {
|
|
419
401
|
return `display: ${e == null ? "none" : t}`;
|
|
420
402
|
}
|
|
421
|
-
#
|
|
403
|
+
#g(t) {
|
|
422
404
|
let n = t instanceof e;
|
|
423
405
|
for (let r of t.getAttributeNames()) {
|
|
424
406
|
let i = t.getAttribute(r);
|
|
425
407
|
if (r === "ref") {
|
|
426
|
-
this.#
|
|
408
|
+
this.#j(t, i);
|
|
427
409
|
continue;
|
|
428
410
|
}
|
|
429
|
-
let a = this.#
|
|
411
|
+
let a = this.#E(t, i);
|
|
430
412
|
if (a) {
|
|
431
413
|
let i = this[a];
|
|
432
|
-
i === void 0 && this.#
|
|
433
|
-
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#
|
|
434
|
-
n && t.#
|
|
414
|
+
i === void 0 && this.#N(t, r, a);
|
|
415
|
+
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#C(a);
|
|
416
|
+
n && t.#C(c) || (t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#M(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
435
417
|
}
|
|
436
|
-
this.#
|
|
418
|
+
this.#A(i, t, r);
|
|
437
419
|
}
|
|
438
420
|
}
|
|
439
|
-
#
|
|
421
|
+
#_(e) {
|
|
440
422
|
for (let t of e) {
|
|
441
|
-
let e = this.#
|
|
423
|
+
let e = this.#v(t), n = this.#r.get(t) ?? [], r = /* @__PURE__ */ new Set();
|
|
442
424
|
for (let t of n) {
|
|
443
425
|
let n = t instanceof HTMLElement || t instanceof CSSStyleRule ? t : t.element;
|
|
444
426
|
if (n instanceof HTMLElement && !n.isConnected) {
|
|
445
427
|
r.add(t);
|
|
446
428
|
continue;
|
|
447
429
|
}
|
|
448
|
-
if (t instanceof HTMLElement) this.#
|
|
430
|
+
if (t instanceof HTMLElement) this.#R(t, e);
|
|
449
431
|
else if (!(t instanceof CSSStyleRule)) {
|
|
450
432
|
let { element: n, attrName: r } = t;
|
|
451
433
|
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : B(n, r, e);
|
|
@@ -457,11 +439,11 @@ var U = class e extends p {
|
|
|
457
439
|
}
|
|
458
440
|
}
|
|
459
441
|
}
|
|
460
|
-
#
|
|
442
|
+
#v(e) {
|
|
461
443
|
let { context: t } = this.#n;
|
|
462
444
|
return Function("context", `const {${Object.keys(t).join(",")}} = context; return ${e};`).call(this, t);
|
|
463
445
|
}
|
|
464
|
-
#
|
|
446
|
+
#y(e) {
|
|
465
447
|
let { localName: t } = e;
|
|
466
448
|
if (t === "style") {
|
|
467
449
|
let { sheet: t } = e, n = t?.cssRules ?? [], r = Array.from(n);
|
|
@@ -469,13 +451,13 @@ var U = class e extends p {
|
|
|
469
451
|
let t = Array.from(e.style);
|
|
470
452
|
for (let n of t) if (n.startsWith("--")) {
|
|
471
453
|
let t = e.style.getPropertyValue(n);
|
|
472
|
-
this.#
|
|
454
|
+
this.#A(t, e, n);
|
|
473
455
|
}
|
|
474
456
|
}
|
|
475
457
|
} else {
|
|
476
458
|
let t = "";
|
|
477
459
|
if (P(e)) {
|
|
478
|
-
this.#
|
|
460
|
+
this.#A(e.textContent, e);
|
|
479
461
|
let n = e.textContent?.match(b);
|
|
480
462
|
n && (t = n[1]);
|
|
481
463
|
} else {
|
|
@@ -483,8 +465,8 @@ var U = class e extends p {
|
|
|
483
465
|
n && (t = n.textContent?.trim() ?? "");
|
|
484
466
|
}
|
|
485
467
|
if (t) {
|
|
486
|
-
let n = this.#
|
|
487
|
-
n && P(e) ? e.textContent = this[n] : this.#
|
|
468
|
+
let n = this.#E(e, t);
|
|
469
|
+
n && P(e) ? e.textContent = this[n] : this.#A(t, e);
|
|
488
470
|
}
|
|
489
471
|
}
|
|
490
472
|
}
|
|
@@ -492,7 +474,7 @@ var U = class e extends p {
|
|
|
492
474
|
let e = this.getAttribute("form-assoc");
|
|
493
475
|
if (!e) {
|
|
494
476
|
let t = this.getAttribute("name");
|
|
495
|
-
if (t) if (this.#
|
|
477
|
+
if (t) if (this.#S("value")) e = `value:${t}`;
|
|
496
478
|
else return;
|
|
497
479
|
else return;
|
|
498
480
|
}
|
|
@@ -513,7 +495,7 @@ var U = class e extends p {
|
|
|
513
495
|
let e = this.#o;
|
|
514
496
|
for (let t of Object.keys(e)) {
|
|
515
497
|
let n = e[t];
|
|
516
|
-
S.test(n) && (n = this.#
|
|
498
|
+
S.test(n) && (n = this.#v(n)), this[t] = n;
|
|
517
499
|
}
|
|
518
500
|
}
|
|
519
501
|
static getAttrName(e) {
|
|
@@ -524,55 +506,55 @@ var U = class e extends p {
|
|
|
524
506
|
let t = this.attrToPropMap.get(e);
|
|
525
507
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
526
508
|
}
|
|
527
|
-
#
|
|
509
|
+
#b(e, t, n) {
|
|
528
510
|
if (n.length !== 1) return;
|
|
529
511
|
let [r] = n;
|
|
530
512
|
if (!S.test(r)) return;
|
|
531
513
|
let i = F(e) || P(e), [a, o] = (t ?? "").split(":");
|
|
532
514
|
if (!(i && a === "value" || P(e))) return;
|
|
533
|
-
o ? e["on" + o] === void 0 && this.#
|
|
515
|
+
o ? e["on" + o] === void 0 && this.#M(e, t, "refers to an unsupported event name") : o = "change";
|
|
534
516
|
let s = j(r);
|
|
535
517
|
e.addEventListener(o, (e) => {
|
|
536
518
|
let { target: t } = e;
|
|
537
519
|
if (!t) return;
|
|
538
520
|
let n = t.value, { type: r } = this.#n.properties[s];
|
|
539
|
-
this[s] = r === Number ? R(n) : n, this.#
|
|
521
|
+
this[s] = r === Number ? R(n) : n, this.#D(s);
|
|
540
522
|
});
|
|
541
523
|
}
|
|
542
|
-
#
|
|
524
|
+
#x(e) {
|
|
543
525
|
return Object.hasOwn(this.#n, e);
|
|
544
526
|
}
|
|
545
|
-
#
|
|
527
|
+
#S(e) {
|
|
546
528
|
return !!this.#n.properties[e];
|
|
547
529
|
}
|
|
548
|
-
#
|
|
530
|
+
#C(e) {
|
|
549
531
|
return !!this.#n.properties[e]?.computed;
|
|
550
532
|
}
|
|
551
|
-
#
|
|
533
|
+
#w(e) {
|
|
552
534
|
let t = Array.from(e.querySelectorAll("*"));
|
|
553
|
-
for (let e of t) this.#
|
|
535
|
+
for (let e of t) this.#g(e), e.firstElementChild || this.#y(e);
|
|
554
536
|
}
|
|
555
|
-
#
|
|
537
|
+
#T() {
|
|
556
538
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
557
539
|
let e = this.#n.name;
|
|
558
|
-
this.#
|
|
540
|
+
this.#M(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
559
541
|
}
|
|
560
542
|
static get observedAttributes() {
|
|
561
543
|
let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
|
|
562
544
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
563
545
|
}
|
|
564
546
|
propertyChangedCallback(e, t, n) {}
|
|
565
|
-
#
|
|
547
|
+
#E(e, t) {
|
|
566
548
|
if (!t || !S.test(t)) return;
|
|
567
549
|
let n = j(t);
|
|
568
|
-
return this[n] === void 0 && this.#
|
|
550
|
+
return this[n] === void 0 && this.#N(e, "", n), n;
|
|
569
551
|
}
|
|
570
|
-
#
|
|
552
|
+
#D(e) {
|
|
571
553
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
572
|
-
this.#
|
|
554
|
+
this.#_(t);
|
|
573
555
|
}
|
|
574
556
|
ready() {}
|
|
575
|
-
#
|
|
557
|
+
#O(e, t) {
|
|
576
558
|
let n = this.#n, r = n.propToComputedMap;
|
|
577
559
|
function i(t, n) {
|
|
578
560
|
let i = r.get(t);
|
|
@@ -581,7 +563,7 @@ var U = class e extends p {
|
|
|
581
563
|
let { computed: a } = t, o = a.match(C) || [];
|
|
582
564
|
for (let t of o) {
|
|
583
565
|
let n = j(t);
|
|
584
|
-
this[n] === void 0 && this.#
|
|
566
|
+
this[n] === void 0 && this.#N(null, e, n), typeof this[n] != "function" && i(n, a);
|
|
585
567
|
}
|
|
586
568
|
for (let t of a.matchAll(y)) {
|
|
587
569
|
let r = t[1];
|
|
@@ -589,7 +571,7 @@ var U = class e extends p {
|
|
|
589
571
|
for (let [e, t] of Object.entries(n.properties)) V(t.usedBy)?.includes(r) && i(e, a);
|
|
590
572
|
}
|
|
591
573
|
}
|
|
592
|
-
#
|
|
574
|
+
#k(e, t) {
|
|
593
575
|
this.#t.add(e);
|
|
594
576
|
try {
|
|
595
577
|
this[e] = t;
|
|
@@ -597,9 +579,9 @@ var U = class e extends p {
|
|
|
597
579
|
this.#t.delete(e);
|
|
598
580
|
}
|
|
599
581
|
}
|
|
600
|
-
#
|
|
582
|
+
#A(e, t, n = void 0) {
|
|
601
583
|
if (!e) return;
|
|
602
|
-
let r = this.#
|
|
584
|
+
let r = this.#H(t, n, e);
|
|
603
585
|
if (!r) {
|
|
604
586
|
let r = e.replaceAll("this..", "this.");
|
|
605
587
|
n ? B(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
@@ -620,13 +602,13 @@ var U = class e extends p {
|
|
|
620
602
|
a || (a = [], this.#r.set(e, a)), a.push(n ? {
|
|
621
603
|
element: t,
|
|
622
604
|
attrName: n
|
|
623
|
-
} : t), t instanceof HTMLElement && this.#
|
|
624
|
-
let o = this.#
|
|
625
|
-
n ? B(t, n, o) : this.#
|
|
605
|
+
} : t), t instanceof HTMLElement && this.#b(t, n, r);
|
|
606
|
+
let o = this.#v(e);
|
|
607
|
+
n ? B(t, n, o) : this.#R(t, o);
|
|
626
608
|
}
|
|
627
|
-
#
|
|
609
|
+
#j(e, t) {
|
|
628
610
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
629
|
-
r || this.#
|
|
611
|
+
r || this.#N(e, "ref", n), r.type !== p && this.#M(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#M(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
|
|
630
612
|
}
|
|
631
613
|
setAttributeSafe(e, t) {
|
|
632
614
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
@@ -637,24 +619,24 @@ var U = class e extends p {
|
|
|
637
619
|
static ssr(e = {}) {
|
|
638
620
|
throw new h("SSR is not available in the browser build.");
|
|
639
621
|
}
|
|
640
|
-
#
|
|
622
|
+
#M(e, t, n) {
|
|
641
623
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
642
624
|
throw new h(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
643
625
|
}
|
|
644
|
-
#
|
|
645
|
-
this.#
|
|
626
|
+
#N(e, t, n) {
|
|
627
|
+
this.#M(e, t, `refers to missing property "${n}"`);
|
|
646
628
|
}
|
|
647
|
-
#
|
|
648
|
-
return this.#
|
|
629
|
+
#P(e, t) {
|
|
630
|
+
return this.#F(e, this.getAttribute(t));
|
|
649
631
|
}
|
|
650
|
-
#
|
|
632
|
+
#F(t, n) {
|
|
651
633
|
if (n?.match(C)) return n;
|
|
652
634
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
653
|
-
if (i || this.#
|
|
635
|
+
if (i || this.#M(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : O(r);
|
|
654
636
|
if (i === String) {
|
|
655
637
|
if (a && !a.includes(n)) {
|
|
656
638
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
657
|
-
this.#
|
|
639
|
+
this.#M(null, t, `must be one of ${e}`);
|
|
658
640
|
}
|
|
659
641
|
return n;
|
|
660
642
|
}
|
|
@@ -663,26 +645,26 @@ var U = class e extends p {
|
|
|
663
645
|
if (n === "true") return !0;
|
|
664
646
|
if (n === "false" || n === "null") return !1;
|
|
665
647
|
let r = e.getAttrName(t);
|
|
666
|
-
return n && n !== r && this.#
|
|
648
|
+
return n && n !== r && this.#M(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
667
649
|
}
|
|
668
650
|
}
|
|
669
|
-
#
|
|
670
|
-
N(n) && !this.#
|
|
651
|
+
#I(e, t, n, r) {
|
|
652
|
+
N(n) && !this.#C(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#P(e, r)) && z(this, r || e, n);
|
|
671
653
|
}
|
|
672
|
-
#
|
|
654
|
+
#L(e) {
|
|
673
655
|
let t = this.#n.propToComputedMap.get(e) || [];
|
|
674
|
-
for (let [e, n] of t) this.#
|
|
656
|
+
for (let [e, n] of t) this.#k(e, this.#v(n));
|
|
675
657
|
}
|
|
676
|
-
#
|
|
658
|
+
#R(e, t) {
|
|
677
659
|
if (t === void 0) return;
|
|
678
660
|
let n = e instanceof HTMLElement;
|
|
679
661
|
Array.isArray(t) && (t = t.join(""));
|
|
680
662
|
let r = typeof t;
|
|
681
|
-
r !== "string" && r !== "number" && this.#
|
|
663
|
+
r !== "string" && r !== "number" && this.#M(e, void 0, " computed content is not a string or number");
|
|
682
664
|
let i = String(t);
|
|
683
|
-
e instanceof HTMLElement && P(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#
|
|
665
|
+
e instanceof HTMLElement && P(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#G(e), this.#w(e)) : n && (e.textContent = i);
|
|
684
666
|
}
|
|
685
|
-
#
|
|
667
|
+
#z(e, t) {
|
|
686
668
|
let n = this.#c.get(e);
|
|
687
669
|
if (!n) return;
|
|
688
670
|
let r = this.getRootNode();
|
|
@@ -692,7 +674,7 @@ var U = class e extends p {
|
|
|
692
674
|
let a = i;
|
|
693
675
|
a[n] = t;
|
|
694
676
|
}
|
|
695
|
-
#
|
|
677
|
+
#B() {
|
|
696
678
|
let e = this.#n;
|
|
697
679
|
function t() {
|
|
698
680
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -722,60 +704,72 @@ var U = class e extends p {
|
|
|
722
704
|
t = {};
|
|
723
705
|
for (let n of Object.keys(e)) t[n] = n;
|
|
724
706
|
}
|
|
725
|
-
this.#
|
|
726
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
707
|
+
this.#U(e, t);
|
|
708
|
+
for (let [n, r] of Object.entries(t)) if (this.#S(r)) {
|
|
727
709
|
let t = o(e, n);
|
|
728
710
|
t !== void 0 && (this[r] = t), this.#l.set(r, {
|
|
729
711
|
state: e,
|
|
730
712
|
stateProp: n
|
|
731
713
|
});
|
|
732
714
|
}
|
|
733
|
-
|
|
715
|
+
let n = this.#u.get(e), r = {
|
|
716
|
+
...n?.map,
|
|
717
|
+
...t
|
|
718
|
+
};
|
|
719
|
+
n?.unsubscribe();
|
|
720
|
+
let i = e.subscribe(({ statePath: e, newValue: t }) => {
|
|
721
|
+
let n = r[e];
|
|
722
|
+
n && (this[n] = t);
|
|
723
|
+
}, Object.keys(r));
|
|
724
|
+
this.#u.set(e, {
|
|
725
|
+
map: r,
|
|
726
|
+
unsubscribe: i
|
|
727
|
+
});
|
|
734
728
|
}
|
|
735
|
-
#
|
|
729
|
+
#V() {
|
|
736
730
|
let t = new Set(Object.keys(this.#n.properties));
|
|
737
731
|
for (let n of this.getAttributeNames()) if (!f.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
738
732
|
if (n === "form-assoc") {
|
|
739
|
-
this.#
|
|
733
|
+
this.#T();
|
|
740
734
|
continue;
|
|
741
735
|
}
|
|
742
736
|
if (!t.has(e.getPropName(n))) {
|
|
743
737
|
if (n === "name") {
|
|
744
|
-
this.#
|
|
738
|
+
this.#T();
|
|
745
739
|
continue;
|
|
746
740
|
}
|
|
747
|
-
this.#
|
|
741
|
+
this.#M(null, n, "is not a supported attribute");
|
|
748
742
|
}
|
|
749
743
|
}
|
|
750
744
|
}
|
|
751
|
-
#
|
|
745
|
+
#H(e, t, n) {
|
|
752
746
|
let r = n.match(C);
|
|
753
747
|
if (r) return r.forEach((n) => {
|
|
754
748
|
let r = j(n);
|
|
755
|
-
this[r] === void 0 && this.#
|
|
749
|
+
this[r] === void 0 && this.#N(e, t, r);
|
|
756
750
|
}), r;
|
|
757
751
|
}
|
|
758
|
-
#
|
|
752
|
+
#U(e, t) {
|
|
759
753
|
for (let [n, r] of Object.entries(t)) {
|
|
760
754
|
let t = o(e, n);
|
|
761
|
-
t === void 0 && this.#
|
|
755
|
+
t === void 0 && this.#M(this, void 0, `invalid state path "${n}"`), t = this[r], this.#S(r) || this.#M(null, r, "refers to missing property in useState map");
|
|
762
756
|
}
|
|
763
757
|
}
|
|
764
|
-
#
|
|
758
|
+
#W(e, t, n) {
|
|
765
759
|
let { values: r } = this.#n.properties[e];
|
|
766
760
|
if (r) {
|
|
767
761
|
let i;
|
|
768
|
-
t === String ? typeof n == "string" ? r.includes(n) || (i = `must be one of ${r.map((e) => `"${e}"`).join(", ")}`) : i = `value is a ${typeof n}, but type is String` : i = "declares allowed values, but its type is not String", i && this.#
|
|
762
|
+
t === String ? typeof n == "string" ? r.includes(n) || (i = `must be one of ${r.map((e) => `"${e}"`).join(", ")}`) : i = `value is a ${typeof n}, but type is String` : i = "declares allowed values, but its type is not String", i && this.#M(null, e, i);
|
|
769
763
|
}
|
|
770
764
|
if (n instanceof t) return;
|
|
771
765
|
let i = typeof n;
|
|
772
766
|
if (i === "object") {
|
|
773
767
|
let { constructor: r } = n;
|
|
774
|
-
i = r.name, r !== t && this.#
|
|
768
|
+
i = r.name, r !== t && this.#M(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
775
769
|
}
|
|
776
|
-
i !== t.name.toLowerCase() && this.#
|
|
770
|
+
i !== t.name.toLowerCase() && this.#M(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
777
771
|
}
|
|
778
|
-
#
|
|
772
|
+
#G(e) {
|
|
779
773
|
let t = Array.from(e.querySelectorAll("*"));
|
|
780
774
|
for (let e of t) {
|
|
781
775
|
let t = [];
|
|
@@ -785,9 +779,9 @@ var U = class e extends p {
|
|
|
785
779
|
let i = r.slice(2);
|
|
786
780
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
787
781
|
let a = n.value;
|
|
788
|
-
this.#
|
|
782
|
+
this.#H(e, r, a);
|
|
789
783
|
let o;
|
|
790
|
-
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#
|
|
784
|
+
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#H(e, r, a), o = () => this.#v(a)), e.addEventListener(i, o), t.push(r);
|
|
791
785
|
}
|
|
792
786
|
}
|
|
793
787
|
for (let n of t) e.removeAttribute(n);
|
package/dist/wrec-ssr.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./wrec-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-S6tBBntE.js";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var a = Object.defineProperty, o = Object.getOwnPropertyDescriptor, s = Object.getOwnPropertyNames, c = Object.prototype.hasOwnProperty, l = (e, t) => () => (e && (t = e(e = 0)), t), u = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), d = (e, t) => {
|
|
4
4
|
let n = {};
|
package/dist/wrec.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./wrec-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-S6tBBntE.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|