wrec 0.31.1 → 0.31.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.
|
@@ -167,7 +167,7 @@ var f = () => /* @__PURE__ */ new Map(), p = new Set([
|
|
|
167
167
|
whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
|
|
168
168
|
}, g = class extends Error {}, _ = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, v = "a-zA-Z_$", y = `[${v}][${v + "0-9"}]*`, b = RegExp(`this\\.(${y})\\s*\\(`, "g"), x = /<!--\s*(.*?)\s*-->/, S = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, C = RegExp(`^this\\.${y}$`), w = RegExp(`this\\.${y}(\\.${y})*`, "g"), T = RegExp(`this\\.${y}(\\.${y})*`), E = 5;
|
|
169
169
|
function D(e) {
|
|
170
|
-
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof
|
|
170
|
+
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof K;
|
|
171
171
|
}
|
|
172
172
|
function O(e, t, n) {
|
|
173
173
|
let r = document.createElement(e);
|
|
@@ -195,42 +195,50 @@ function F(e) {
|
|
|
195
195
|
return t === "string" || t === "number" || t === "boolean";
|
|
196
196
|
}
|
|
197
197
|
function I(e) {
|
|
198
|
-
return e.
|
|
198
|
+
return e instanceof HTMLInputElement && e.type === "radio";
|
|
199
199
|
}
|
|
200
200
|
function L(e) {
|
|
201
|
+
return e.localName === "textarea";
|
|
202
|
+
}
|
|
203
|
+
function R(e) {
|
|
201
204
|
let { localName: t } = e;
|
|
202
205
|
return t === "input" || t === "select";
|
|
203
206
|
}
|
|
204
|
-
var
|
|
205
|
-
function
|
|
207
|
+
var z = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
208
|
+
function B(e, t, n, r) {
|
|
206
209
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
207
210
|
}
|
|
208
|
-
function
|
|
211
|
+
function V(e) {
|
|
209
212
|
let t = Number(e);
|
|
210
213
|
if (isNaN(t)) throw new g(`can't convert "${e}" to a number`);
|
|
211
214
|
return t;
|
|
212
215
|
}
|
|
213
|
-
function
|
|
214
|
-
let [r
|
|
216
|
+
function H(e, t, n) {
|
|
217
|
+
let [r] = t.split(":");
|
|
218
|
+
if (r === "checked" && I(e) && typeof n == "string") {
|
|
219
|
+
let t = e.value === n;
|
|
220
|
+
t ? e.setAttribute(r, r) : e.removeAttribute(r), e.checked = t;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
215
223
|
if (F(n)) if (typeof n == "boolean") {
|
|
216
224
|
n ? e.setAttribute(r, r) : e.removeAttribute(r);
|
|
217
|
-
let t =
|
|
225
|
+
let t = K.getPropName(r);
|
|
218
226
|
e[t] = n;
|
|
219
227
|
} else {
|
|
220
228
|
let i = e.getAttribute(t), a = String(n);
|
|
221
|
-
i !== a && (e.setAttribute(r, a), r === "value" &&
|
|
229
|
+
i !== a && (e.setAttribute(r, a), r === "value" && R(e) && (e.value = a));
|
|
222
230
|
}
|
|
223
231
|
else {
|
|
224
|
-
let r =
|
|
232
|
+
let r = K.getPropName(t);
|
|
225
233
|
e[r] = n;
|
|
226
234
|
}
|
|
227
235
|
}
|
|
228
|
-
function
|
|
229
|
-
let [r
|
|
230
|
-
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (
|
|
236
|
+
function U(e, t, n) {
|
|
237
|
+
let [r] = t.split(":");
|
|
238
|
+
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (H(e, r, n), r === "value" && R(e) && (e.value = n));
|
|
231
239
|
}
|
|
232
|
-
var
|
|
233
|
-
async function
|
|
240
|
+
var W = (e) => typeof e == "string" ? [e] : e;
|
|
241
|
+
async function G(e) {
|
|
234
242
|
let t = /* @__PURE__ */ new Set();
|
|
235
243
|
for (let n of j(e.content)) {
|
|
236
244
|
let { localName: e } = n;
|
|
@@ -246,7 +254,7 @@ async function W(e) {
|
|
|
246
254
|
}
|
|
247
255
|
return Promise.all([...t].map(async (e) => Promise.race([h.whenDefined(e), n(e)])));
|
|
248
256
|
}
|
|
249
|
-
var
|
|
257
|
+
var K = class e extends m {
|
|
250
258
|
static {
|
|
251
259
|
this.attrToPropMap = /* @__PURE__ */ new Map();
|
|
252
260
|
}
|
|
@@ -319,7 +327,7 @@ var G = class e extends m {
|
|
|
319
327
|
}
|
|
320
328
|
async #d() {
|
|
321
329
|
let e = this.#n, { template: t } = e;
|
|
322
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
330
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await G(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
323
331
|
}
|
|
324
332
|
static buildHTML() {
|
|
325
333
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
@@ -357,7 +365,7 @@ var G = class e extends m {
|
|
|
357
365
|
return this[u];
|
|
358
366
|
},
|
|
359
367
|
set(e) {
|
|
360
|
-
n.computed && !this.#t.has(t) && this.#F(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e =
|
|
368
|
+
n.computed && !this.#t.has(t) && this.#F(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = V(e));
|
|
361
369
|
let r = this[u];
|
|
362
370
|
if (e === r) return;
|
|
363
371
|
this.#q(t, c, e), this[u] = e;
|
|
@@ -404,12 +412,12 @@ var G = class e extends m {
|
|
|
404
412
|
let i = this[a];
|
|
405
413
|
i === void 0 && this.#I(t, r, a);
|
|
406
414
|
let [o, s] = r.split(":"), c = e.getPropName(o);
|
|
407
|
-
if (o === "checked"
|
|
415
|
+
if (o === "checked") {
|
|
408
416
|
let { type: e } = this.#n.properties[a];
|
|
409
|
-
e !== Boolean && this.#F(t, r, `refers to property "${a}" whose type is not Boolean`);
|
|
417
|
+
P(t) && e !== Boolean && this.#F(t, r, `refers to property "${a}" whose type is not Boolean`), I(t) && e !== String && this.#F(t, r, `refers to property "${a}" whose type is not String`);
|
|
410
418
|
}
|
|
411
419
|
let l = this.#T(a);
|
|
412
|
-
n && t.#T(c) || (t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#F(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
420
|
+
n && t.#T(c) || (o === "checked" && I(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#F(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
413
421
|
}
|
|
414
422
|
this.#N(i, t, r);
|
|
415
423
|
}
|
|
@@ -426,7 +434,7 @@ var G = class e extends m {
|
|
|
426
434
|
if (t instanceof HTMLElement) this.#V(t, e);
|
|
427
435
|
else if (!(t instanceof CSSStyleRule)) {
|
|
428
436
|
let { element: n, attrName: r } = t;
|
|
429
|
-
n instanceof CSSStyleRule ? n.style.setProperty(r, e) :
|
|
437
|
+
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : U(n, r, e);
|
|
430
438
|
}
|
|
431
439
|
}
|
|
432
440
|
if (r.size > 0) {
|
|
@@ -452,7 +460,7 @@ var G = class e extends m {
|
|
|
452
460
|
}
|
|
453
461
|
} else {
|
|
454
462
|
let t = "";
|
|
455
|
-
if (
|
|
463
|
+
if (L(e)) {
|
|
456
464
|
this.#N(e.textContent, e);
|
|
457
465
|
let n = e.textContent?.match(x);
|
|
458
466
|
n && (t = n[1]);
|
|
@@ -462,7 +470,7 @@ var G = class e extends m {
|
|
|
462
470
|
}
|
|
463
471
|
if (t) {
|
|
464
472
|
let n = this.#O(e, t);
|
|
465
|
-
n &&
|
|
473
|
+
n && L(e) ? e.textContent = this[n] : this.#N(t, e);
|
|
466
474
|
}
|
|
467
475
|
}
|
|
468
476
|
}
|
|
@@ -548,20 +556,15 @@ var G = class e extends m {
|
|
|
548
556
|
if (n.length !== 1) return;
|
|
549
557
|
let [r] = n;
|
|
550
558
|
if (!C.test(r)) return;
|
|
551
|
-
let i = P(e), a =
|
|
552
|
-
if (!(
|
|
553
|
-
|
|
554
|
-
let
|
|
555
|
-
e.addEventListener(
|
|
559
|
+
let i = P(e), a = I(e), o = R(e) || L(e), [s, c] = (t ?? "").split(":");
|
|
560
|
+
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || L(e))) return;
|
|
561
|
+
c ? e["on" + c] === void 0 && this.#F(e, t, "refers to an unsupported event name") : c = "change";
|
|
562
|
+
let l = M(r);
|
|
563
|
+
e.addEventListener(c, (e) => {
|
|
556
564
|
let { target: t } = e;
|
|
557
565
|
if (!t) return;
|
|
558
|
-
let { type: n } = this.#n.properties[
|
|
559
|
-
|
|
560
|
-
else {
|
|
561
|
-
let e = t.value;
|
|
562
|
-
this[c] = n === Number ? B(e) : e;
|
|
563
|
-
}
|
|
564
|
-
this.#k(c);
|
|
566
|
+
let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
|
|
567
|
+
s === "checked" ? i ? this[l] = r.checked : a && r.checked && (this[l] = o) : this[l] = n === Number ? V(o) : o, this.#k(l);
|
|
565
568
|
});
|
|
566
569
|
}
|
|
567
570
|
#C(e) {
|
|
@@ -620,7 +623,7 @@ var G = class e extends m {
|
|
|
620
623
|
for (let t of a.matchAll(b)) {
|
|
621
624
|
let r = t[1];
|
|
622
625
|
if (typeof this[r] != "function") throw new g(`property ${e} computed calls non-method ${r}`);
|
|
623
|
-
for (let [e, t] of Object.entries(n.properties))
|
|
626
|
+
for (let [e, t] of Object.entries(n.properties)) W(t.usedBy)?.includes(r) && i(e, a);
|
|
624
627
|
}
|
|
625
628
|
}
|
|
626
629
|
#M(e, t) {
|
|
@@ -636,7 +639,7 @@ var G = class e extends m {
|
|
|
636
639
|
let r = this.#G(t, n, e);
|
|
637
640
|
if (!r) {
|
|
638
641
|
let r = e.replaceAll("this..", "this.");
|
|
639
|
-
n ?
|
|
642
|
+
n ? U(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
640
643
|
return;
|
|
641
644
|
}
|
|
642
645
|
let i = this.#n;
|
|
@@ -656,7 +659,7 @@ var G = class e extends m {
|
|
|
656
659
|
attrName: n
|
|
657
660
|
} : t), t instanceof HTMLElement && this.#S(t, n, r);
|
|
658
661
|
let o = this.#v(e);
|
|
659
|
-
n ?
|
|
662
|
+
n ? U(t, n, o) : this.#V(t, o);
|
|
660
663
|
}
|
|
661
664
|
#P(e, t) {
|
|
662
665
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
@@ -692,7 +695,7 @@ var G = class e extends m {
|
|
|
692
695
|
}
|
|
693
696
|
return n;
|
|
694
697
|
}
|
|
695
|
-
if (i === Number) return
|
|
698
|
+
if (i === Number) return V(n);
|
|
696
699
|
if (i === Boolean) {
|
|
697
700
|
if (n === "true") return !0;
|
|
698
701
|
if (n === "false" || n === "null") return !1;
|
|
@@ -701,7 +704,7 @@ var G = class e extends m {
|
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
706
|
#z(e, t, n, r) {
|
|
704
|
-
F(n) && !this.#T(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#L(e, r)) &&
|
|
707
|
+
F(n) && !this.#T(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#L(e, r)) && H(this, r || e, n);
|
|
705
708
|
}
|
|
706
709
|
#B(e) {
|
|
707
710
|
for (let [t, n] of this.#x([e])) this.#M(t, this.#v(n));
|
|
@@ -713,7 +716,7 @@ var G = class e extends m {
|
|
|
713
716
|
let r = typeof t;
|
|
714
717
|
r !== "string" && r !== "number" && this.#F(e, void 0, " computed content is not a string or number");
|
|
715
718
|
let i = String(t);
|
|
716
|
-
e instanceof HTMLElement &&
|
|
719
|
+
e instanceof HTMLElement && L(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#J(e), this.#E(e)) : n && (e.textContent = i);
|
|
717
720
|
}
|
|
718
721
|
#H(e, t) {
|
|
719
722
|
let n = this.#c.get(e);
|
|
@@ -738,7 +741,7 @@ var G = class e extends m {
|
|
|
738
741
|
}
|
|
739
742
|
let { properties: n, propToExprsMap: r } = e;
|
|
740
743
|
for (let [i, a] of Object.entries(n)) {
|
|
741
|
-
let n =
|
|
744
|
+
let n = W(a.usedBy);
|
|
742
745
|
if (!n) continue;
|
|
743
746
|
e.methodToExprsMap || t.call(this);
|
|
744
747
|
let { methodToExprsMap: o } = e, s = r.get(i);
|
|
@@ -839,7 +842,7 @@ var G = class e extends m {
|
|
|
839
842
|
}
|
|
840
843
|
}
|
|
841
844
|
};
|
|
842
|
-
function
|
|
845
|
+
function q(e, ...t) {
|
|
843
846
|
let n = N(e, t);
|
|
844
847
|
for (;;) {
|
|
845
848
|
let e = _.exec(n);
|
|
@@ -850,24 +853,24 @@ function K(e, ...t) {
|
|
|
850
853
|
if (!r.startsWith("--")) {
|
|
851
854
|
let i = `--${r}: ${t};
|
|
852
855
|
${r}: var(--${r})`;
|
|
853
|
-
n =
|
|
856
|
+
n = B(n, e.index, e[0].length, i);
|
|
854
857
|
}
|
|
855
858
|
}
|
|
856
859
|
}
|
|
857
860
|
return n;
|
|
858
861
|
}
|
|
859
|
-
function
|
|
862
|
+
function J(e, ...t) {
|
|
860
863
|
let n = N(e, t);
|
|
861
864
|
for (;;) {
|
|
862
865
|
let e = S.exec(n);
|
|
863
866
|
if (!e || e[1] === "style") break;
|
|
864
|
-
let t =
|
|
867
|
+
let t = z(e[2]);
|
|
865
868
|
if (T.test(t)) {
|
|
866
869
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
867
|
-
n =
|
|
870
|
+
n = B(n, i, t.length, r);
|
|
868
871
|
}
|
|
869
872
|
}
|
|
870
873
|
return n;
|
|
871
874
|
}
|
|
872
875
|
//#endregion
|
|
873
|
-
export { a,
|
|
876
|
+
export { a, J as i, O as n, q as r, K as t };
|
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-fWpfp5nc.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-fWpfp5nc.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|