wrec 0.39.5 → 0.40.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-1_q5NXuK.js → wrec-DHGadgxK.js} +173 -99
- package/dist/wrec-ssr.es.js +263 -262
- package/dist/wrec.es.js +2 -2
- package/package.json +1 -1
- package/scripts/lint.js +114 -29
|
@@ -139,8 +139,84 @@ function l(e, t, n) {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
|
+
//#region src/evaluation.ts
|
|
143
|
+
var u = "a-zA-Z_$", d = `[${u}][${u + "0-9"}]*`, f = RegExp(`this\\.(${d})\\s*\\(`, "g"), p = /<!--\s*(.*?)\s*-->/, m = RegExp(`^this\\.${d}$`), h = RegExp(`this\\.${d}(\\.${d})*`, "g"), g = RegExp(`this\\.${d}(\\.${d})*`);
|
|
144
|
+
function _(e, t) {
|
|
145
|
+
for (let [n, r] of Object.entries(t)) e[n] === void 0 && (e[n] = te(r));
|
|
146
|
+
}
|
|
147
|
+
function v(e, t) {
|
|
148
|
+
let n = Object.entries(t).filter(([e, t]) => !!t.computed).map(([e]) => e), r = new Set(n), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
149
|
+
for (let o of n) {
|
|
150
|
+
let n = t[o].computed, s = /* @__PURE__ */ new Set();
|
|
151
|
+
for (let r of n.matchAll(h)) {
|
|
152
|
+
let n = x(r[0]), i = re(n), a = !1;
|
|
153
|
+
for (let [e, n] of Object.entries(t)) S(n.usedBy)?.includes(i) && (s.add(e), a = !0);
|
|
154
|
+
!a && typeof e[n] != "function" && s.add(n);
|
|
155
|
+
}
|
|
156
|
+
for (let e of n.matchAll(f)) {
|
|
157
|
+
let n = e[1];
|
|
158
|
+
for (let [e, r] of Object.entries(t)) S(r.usedBy)?.includes(n) && s.add(e);
|
|
159
|
+
}
|
|
160
|
+
i.set(o, [...s].filter((e) => r.has(e)).sort()), a.set(o, n);
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
computedNames: n,
|
|
164
|
+
dependenciesMap: i,
|
|
165
|
+
expressions: a
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function ee(e, t) {
|
|
169
|
+
let { computedNames: n, dependenciesMap: r, expressions: i } = v(t, e.properties ?? {}), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = [];
|
|
170
|
+
for (let e of n) {
|
|
171
|
+
let t = r.get(e) ?? [];
|
|
172
|
+
o.set(e, t.length), t.length === 0 && s.push(e);
|
|
173
|
+
for (let n of t) {
|
|
174
|
+
let t = a.get(n) ?? [];
|
|
175
|
+
t.push(e), a.set(n, t);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
let c = [];
|
|
179
|
+
for (let e = 0; e < s.length; e++) {
|
|
180
|
+
let t = s[e];
|
|
181
|
+
c.push(t);
|
|
182
|
+
let n = a.get(t) ?? [];
|
|
183
|
+
for (let e of n) {
|
|
184
|
+
let t = o.get(e) - 1;
|
|
185
|
+
o.set(e, t), t === 0 && s.push(e);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (c.length !== n.length) {
|
|
189
|
+
let e = n.filter((e) => o.get(e) > 0).sort();
|
|
190
|
+
throw Error(`computed properties form a cycle: ${e.join(", ")}`);
|
|
191
|
+
}
|
|
192
|
+
let l = e.context ?? {};
|
|
193
|
+
for (let e of c) t[e] = b(i.get(e), t, l);
|
|
194
|
+
}
|
|
195
|
+
function te(e) {
|
|
196
|
+
return e.value === void 0 ? Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : y(e.type) : e.value;
|
|
197
|
+
}
|
|
198
|
+
function y(e) {
|
|
199
|
+
return e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
200
|
+
}
|
|
201
|
+
function b(e, t, n = {}) {
|
|
202
|
+
return Function("context", `const {${Object.keys(n).join(",")}} = context; return ${e};`).call(t, n);
|
|
203
|
+
}
|
|
204
|
+
function x(e) {
|
|
205
|
+
return e.substring(5).split(".")[0];
|
|
206
|
+
}
|
|
207
|
+
function ne(e, t = {}) {
|
|
208
|
+
let n = Object.create(e.prototype);
|
|
209
|
+
return Object.assign(n, t), _(n, e.properties ?? {}), ee(e, n), n;
|
|
210
|
+
}
|
|
211
|
+
function re(e) {
|
|
212
|
+
return `get ${e}`;
|
|
213
|
+
}
|
|
214
|
+
function S(e) {
|
|
215
|
+
return typeof e == "string" ? [e] : e;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
142
218
|
//#region src/sanitize-xss.ts
|
|
143
|
-
var
|
|
219
|
+
var ie = "__WREC", ae = "__", oe = "[A-Za-z_$][A-Za-z0-9_$]*", se = new Set([
|
|
144
220
|
"checked",
|
|
145
221
|
"colspan",
|
|
146
222
|
"disabled",
|
|
@@ -155,26 +231,26 @@ var u = "__WREC", d = "__", f = "[A-Za-z_$][A-Za-z0-9_$]*", p = new Set([
|
|
|
155
231
|
"type",
|
|
156
232
|
"value"
|
|
157
233
|
]);
|
|
158
|
-
function
|
|
159
|
-
return `${
|
|
234
|
+
function C(e, t) {
|
|
235
|
+
return `${ie}${e}_${t}${ae}`;
|
|
160
236
|
}
|
|
161
|
-
function
|
|
237
|
+
function w(e) {
|
|
162
238
|
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
163
239
|
}
|
|
164
|
-
function
|
|
240
|
+
function ce(e) {
|
|
165
241
|
let t = e.trim();
|
|
166
|
-
return t ? RegExp(`^${
|
|
242
|
+
return t ? RegExp(`^${oe}$`).test(t) ? !0 : t.startsWith("this.") : !1;
|
|
167
243
|
}
|
|
168
|
-
function
|
|
244
|
+
function T(t) {
|
|
169
245
|
let n = {
|
|
170
246
|
allowCommentTag: !0,
|
|
171
247
|
onTagAttr(e, t, n) {
|
|
172
|
-
if (t.startsWith("on")) return
|
|
173
|
-
if (t === "title" || t.startsWith("aria-") || t.startsWith("data-")) return `${t}="${
|
|
248
|
+
if (t.startsWith("on")) return ce(n) ? `${t}="${w(n)}"` : "";
|
|
249
|
+
if (t === "title" || t.startsWith("aria-") || t.startsWith("data-")) return `${t}="${w(n)}"`;
|
|
174
250
|
if (e === "a" && t === "href" && n.startsWith("javascript")) return "";
|
|
175
251
|
},
|
|
176
252
|
safeAttrValue(e, t, n) {
|
|
177
|
-
return t === "class" ||
|
|
253
|
+
return t === "class" || se.has(t) || e === "a" && t === "href" || e === "img" && t === "src" ? n : "";
|
|
178
254
|
},
|
|
179
255
|
stripIgnoreTagBody: [
|
|
180
256
|
"script",
|
|
@@ -221,7 +297,7 @@ function _(t) {
|
|
|
221
297
|
}
|
|
222
298
|
}, r = [], i = Date.now() + Math.floor(Math.random() * 1e6);
|
|
223
299
|
t = t.replace(/<!--[\s\S]*?-->/g, (e) => {
|
|
224
|
-
let t =
|
|
300
|
+
let t = C(i, r.length);
|
|
225
301
|
return r.push({
|
|
226
302
|
comment: e,
|
|
227
303
|
token: t
|
|
@@ -234,36 +310,36 @@ function _(t) {
|
|
|
234
310
|
}
|
|
235
311
|
//#endregion
|
|
236
312
|
//#region src/wrec.ts
|
|
237
|
-
var
|
|
313
|
+
var E = () => /* @__PURE__ */ new Map(), D = new Set([
|
|
238
314
|
"class",
|
|
239
315
|
"disabled",
|
|
240
316
|
"hidden",
|
|
241
317
|
"id",
|
|
242
318
|
"tabindex",
|
|
243
319
|
"title"
|
|
244
|
-
]),
|
|
320
|
+
]), O = globalThis.HTMLElement ?? class {}, k = globalThis.customElements ?? {
|
|
245
321
|
get: (e) => void 0,
|
|
246
322
|
getName: (e) => null,
|
|
247
323
|
define: () => {},
|
|
248
324
|
initialize: (e) => {},
|
|
249
325
|
upgrade: (e) => {},
|
|
250
326
|
whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
|
|
251
|
-
},
|
|
252
|
-
function
|
|
327
|
+
}, A = class extends Error {}, j = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, M = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g;
|
|
328
|
+
function N(e) {
|
|
253
329
|
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof $;
|
|
254
330
|
}
|
|
255
|
-
function
|
|
331
|
+
function P(e, t, n) {
|
|
256
332
|
let r = document.createElement(e);
|
|
257
333
|
if (t) for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
258
334
|
return n && (r.innerHTML = n), r;
|
|
259
335
|
}
|
|
260
|
-
var
|
|
261
|
-
function
|
|
336
|
+
var F = (e) => Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : I(e.type), I = (e) => e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
337
|
+
function L(e) {
|
|
262
338
|
let t = [], n = e.firstElementChild;
|
|
263
|
-
for (; n;) t.push(n), n.shadowRoot && t.push(...
|
|
339
|
+
for (; n;) t.push(n), n.shadowRoot && t.push(...L(n.shadowRoot)), n.firstElementChild && t.push(...L(n)), n = n.nextElementSibling;
|
|
264
340
|
return t;
|
|
265
341
|
}
|
|
266
|
-
function
|
|
342
|
+
function R(e, t) {
|
|
267
343
|
let n = e;
|
|
268
344
|
for (; n;) {
|
|
269
345
|
let e = Object.getOwnPropertyDescriptor(n, t);
|
|
@@ -271,59 +347,58 @@ function te(e, t) {
|
|
|
271
347
|
n = Object.getPrototypeOf(n);
|
|
272
348
|
}
|
|
273
349
|
}
|
|
274
|
-
|
|
275
|
-
function R(e) {
|
|
350
|
+
function z(e) {
|
|
276
351
|
return e.substring(4).trim();
|
|
277
352
|
}
|
|
278
|
-
function
|
|
353
|
+
function B(e, t) {
|
|
279
354
|
let n = e[0];
|
|
280
355
|
return t.forEach((t, r) => {
|
|
281
356
|
n += t + e[r + 1];
|
|
282
357
|
}), n;
|
|
283
358
|
}
|
|
284
|
-
function
|
|
359
|
+
function V(e) {
|
|
285
360
|
return e instanceof HTMLInputElement && e.type === "checkbox";
|
|
286
361
|
}
|
|
287
|
-
function
|
|
362
|
+
function H(e) {
|
|
288
363
|
return e.startsWith("get ");
|
|
289
364
|
}
|
|
290
|
-
function
|
|
365
|
+
function U(e) {
|
|
291
366
|
let t = typeof e;
|
|
292
367
|
return t === "string" || t === "number" || t === "boolean";
|
|
293
368
|
}
|
|
294
|
-
function
|
|
369
|
+
function W(e) {
|
|
295
370
|
return e instanceof HTMLInputElement && e.type === "radio";
|
|
296
371
|
}
|
|
297
|
-
function
|
|
372
|
+
function G(e) {
|
|
298
373
|
return e.localName === "textarea";
|
|
299
374
|
}
|
|
300
|
-
function
|
|
375
|
+
function K(e) {
|
|
301
376
|
let { localName: t } = e;
|
|
302
377
|
return t === "input" || t === "select";
|
|
303
378
|
}
|
|
304
|
-
var
|
|
379
|
+
var q = (e) => `get ${e}`, le = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
305
380
|
function J(e, t, n, r) {
|
|
306
381
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
307
382
|
}
|
|
308
383
|
function Y(e) {
|
|
309
384
|
let t = Number(e);
|
|
310
|
-
if (isNaN(t)) throw new
|
|
385
|
+
if (isNaN(t)) throw new A(`can't convert "${e}" to a number`);
|
|
311
386
|
return t;
|
|
312
387
|
}
|
|
313
388
|
function X(e, t, n) {
|
|
314
389
|
let [r] = t.split(":");
|
|
315
|
-
if (r === "checked" &&
|
|
390
|
+
if (r === "checked" && W(e) && typeof n == "string") {
|
|
316
391
|
let t = e.value === n;
|
|
317
392
|
t ? e.setAttribute(r, r) : e.removeAttribute(r), e.checked = t;
|
|
318
393
|
return;
|
|
319
394
|
}
|
|
320
|
-
if (
|
|
395
|
+
if (U(n)) if (typeof n == "boolean") {
|
|
321
396
|
n ? e.setAttribute(r, r) : e.removeAttribute(r);
|
|
322
397
|
let t = $.getPropName(r);
|
|
323
398
|
e[t] = n;
|
|
324
399
|
} else {
|
|
325
400
|
let i = e.getAttribute(t), a = String(n);
|
|
326
|
-
i !== a && (e.setAttribute(r, a), r === "value" &&
|
|
401
|
+
i !== a && (e.setAttribute(r, a), r === "value" && K(e) && (e.value = a));
|
|
327
402
|
}
|
|
328
403
|
else {
|
|
329
404
|
let r = $.getPropName(t);
|
|
@@ -332,12 +407,12 @@ function X(e, t, n) {
|
|
|
332
407
|
}
|
|
333
408
|
function Z(e, t, n) {
|
|
334
409
|
let [r] = t.split(":");
|
|
335
|
-
e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (X(e, r, n), r === "value" &&
|
|
410
|
+
e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (X(e, r, n), r === "value" && K(e) && e.value !== n && (e.value = n));
|
|
336
411
|
}
|
|
337
412
|
var Q = (e) => typeof e == "string" ? [e] : e;
|
|
338
|
-
async function
|
|
413
|
+
async function ue(e) {
|
|
339
414
|
let t = /* @__PURE__ */ new Set();
|
|
340
|
-
for (let n of
|
|
415
|
+
for (let n of L(e.content)) {
|
|
341
416
|
let { localName: e } = n;
|
|
342
417
|
e.includes("-") && t.add(e);
|
|
343
418
|
}
|
|
@@ -349,9 +424,9 @@ async function ne(e) {
|
|
|
349
424
|
}, 1e3);
|
|
350
425
|
});
|
|
351
426
|
}
|
|
352
|
-
return Promise.all([...t].map(async (e) => Promise.race([
|
|
427
|
+
return Promise.all([...t].map(async (e) => Promise.race([k.whenDefined(e), n(e)])));
|
|
353
428
|
}
|
|
354
|
-
var $ = class e extends
|
|
429
|
+
var $ = class e extends O {
|
|
355
430
|
static {
|
|
356
431
|
this.attrToPropMap = /* @__PURE__ */ new Map();
|
|
357
432
|
}
|
|
@@ -390,8 +465,8 @@ var $ = class e extends b {
|
|
|
390
465
|
#d = /* @__PURE__ */ new WeakSet();
|
|
391
466
|
#f = /* @__PURE__ */ new Map();
|
|
392
467
|
static define(e) {
|
|
393
|
-
if (this.elementName = e,
|
|
394
|
-
|
|
468
|
+
if (this.elementName = e, k.get(e)) throw new A(`custom element ${e} is already defined`);
|
|
469
|
+
k.define(e, this);
|
|
395
470
|
}
|
|
396
471
|
constructor() {
|
|
397
472
|
super(), this.attachShadow({ mode: "open" });
|
|
@@ -426,13 +501,13 @@ var $ = class e extends b {
|
|
|
426
501
|
}
|
|
427
502
|
async #p() {
|
|
428
503
|
let e = this.#n, { template: t } = e;
|
|
429
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
504
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await ue(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
430
505
|
}
|
|
431
506
|
static buildHTML() {
|
|
432
507
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
433
508
|
this.css && (e += this.css), e += "</style>\n";
|
|
434
509
|
let t = this.html.trim();
|
|
435
|
-
if (!t) throw new
|
|
510
|
+
if (!t) throw new A("static property html must be set");
|
|
436
511
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
437
512
|
}
|
|
438
513
|
changed(e, t, n) {
|
|
@@ -452,12 +527,12 @@ var $ = class e extends b {
|
|
|
452
527
|
this.#F();
|
|
453
528
|
}
|
|
454
529
|
#g(t, n, r) {
|
|
455
|
-
if (t === "class" || t === "style") throw new
|
|
530
|
+
if (t === "class" || t === "style") throw new A(`"${t}" is a reserved property`);
|
|
456
531
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
457
532
|
n.required && !a && this.#V(this, i, "is a required attribute");
|
|
458
533
|
let o = n.value;
|
|
459
534
|
this.hasOwnProperty(t) && (o = this.#T(t), this.#_(t));
|
|
460
|
-
let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ??
|
|
535
|
+
let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ?? F(n), u = "#" + t;
|
|
461
536
|
this.#R(u, this.#j(t, s, c)), Object.defineProperty(this, t, {
|
|
462
537
|
enumerable: !0,
|
|
463
538
|
get() {
|
|
@@ -484,8 +559,8 @@ var $ = class e extends b {
|
|
|
484
559
|
delete this[e];
|
|
485
560
|
}
|
|
486
561
|
#v() {
|
|
487
|
-
let t = this.hasAttribute("disabled"), n =
|
|
488
|
-
for (let r of n)
|
|
562
|
+
let t = this.hasAttribute("disabled"), n = L(this.shadowRoot);
|
|
563
|
+
for (let r of n) N(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
|
|
489
564
|
}
|
|
490
565
|
disconnectedCallback() {
|
|
491
566
|
for (let { unsubscribe: e } of this.#f.values()) e();
|
|
@@ -516,10 +591,10 @@ var $ = class e extends b {
|
|
|
516
591
|
let [o, s] = r.split(":"), c = e.getPropName(o);
|
|
517
592
|
if (o === "checked") {
|
|
518
593
|
let { type: e } = this.#n.properties[a];
|
|
519
|
-
|
|
594
|
+
V(t) && e !== Boolean && this.#V(t, r, `refers to property "${a}" whose type is not Boolean`), W(t) && e !== String && this.#V(t, r, `refers to property "${a}" whose type is not String`);
|
|
520
595
|
}
|
|
521
596
|
let l = this.#A(a);
|
|
522
|
-
n && t.#A(c) || (o === "checked" &&
|
|
597
|
+
n && t.#A(c) || (o === "checked" && W(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#V(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#T(a))) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
523
598
|
}
|
|
524
599
|
this.#z(i, t, r);
|
|
525
600
|
}
|
|
@@ -546,8 +621,7 @@ var $ = class e extends b {
|
|
|
546
621
|
}
|
|
547
622
|
}
|
|
548
623
|
#x(e) {
|
|
549
|
-
|
|
550
|
-
return Function("context", `const {${Object.keys(t).join(",")}} = context; return ${e};`).call(this, t);
|
|
624
|
+
return b(e, this, this.#n.context);
|
|
551
625
|
}
|
|
552
626
|
#S(e) {
|
|
553
627
|
let { localName: t } = e;
|
|
@@ -562,9 +636,9 @@ var $ = class e extends b {
|
|
|
562
636
|
}
|
|
563
637
|
} else {
|
|
564
638
|
let t = "";
|
|
565
|
-
if (
|
|
639
|
+
if (G(e)) {
|
|
566
640
|
this.#z(e.textContent, e);
|
|
567
|
-
let n = e.textContent?.match(
|
|
641
|
+
let n = e.textContent?.match(p);
|
|
568
642
|
n && (t = n[1]);
|
|
569
643
|
} else {
|
|
570
644
|
let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
|
|
@@ -572,7 +646,7 @@ var $ = class e extends b {
|
|
|
572
646
|
}
|
|
573
647
|
if (t) {
|
|
574
648
|
let n = this.#N(e, t);
|
|
575
|
-
n &&
|
|
649
|
+
n && G(e) ? e.textContent = this.#T(n) : this.#z(t, e);
|
|
576
650
|
}
|
|
577
651
|
}
|
|
578
652
|
}
|
|
@@ -592,7 +666,7 @@ var $ = class e extends b {
|
|
|
592
666
|
this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
|
|
593
667
|
for (let [e, n] of Object.entries(t)) {
|
|
594
668
|
let t = this.#T(e);
|
|
595
|
-
|
|
669
|
+
U(t) && this.setFormValue(n, String(t));
|
|
596
670
|
}
|
|
597
671
|
let r = Object.keys(this.#n.properties), i = this.#o;
|
|
598
672
|
for (let e of r) i[e] = this.#T(e);
|
|
@@ -601,7 +675,7 @@ var $ = class e extends b {
|
|
|
601
675
|
let e = this.#o;
|
|
602
676
|
for (let t of Object.keys(e)) {
|
|
603
677
|
let n = e[t];
|
|
604
|
-
|
|
678
|
+
m.test(n) && (n = this.#x(n)), this.#R(t, n);
|
|
605
679
|
}
|
|
606
680
|
}
|
|
607
681
|
static getAttrName(e) {
|
|
@@ -611,7 +685,7 @@ var $ = class e extends b {
|
|
|
611
685
|
#C() {
|
|
612
686
|
let e = this.#n, t = e.computedGraph;
|
|
613
687
|
if (t) return t;
|
|
614
|
-
let n =
|
|
688
|
+
let n = E(), r = E(), i = {};
|
|
615
689
|
for (let t of e.registeredComputedProps) n.set(t, []);
|
|
616
690
|
for (let [t, a] of e.propToComputedMap) for (let [o, s] of a) {
|
|
617
691
|
if (i[o] = s, !e.registeredComputedProps.has(o) || (n.has(o) || n.set(o, []), !e.registeredComputedProps.has(t))) continue;
|
|
@@ -647,7 +721,7 @@ var $ = class e extends b {
|
|
|
647
721
|
l.set(e, t), t === 0 && s.push(e);
|
|
648
722
|
}
|
|
649
723
|
}
|
|
650
|
-
if (c.length !== a.size) throw new
|
|
724
|
+
if (c.length !== a.size) throw new A(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
651
725
|
return c.map((e) => [e, r[e]]);
|
|
652
726
|
}
|
|
653
727
|
#T(e) {
|
|
@@ -664,11 +738,11 @@ var $ = class e extends b {
|
|
|
664
738
|
#D(e, t, n) {
|
|
665
739
|
if (n.length !== 1) return;
|
|
666
740
|
let [r] = n;
|
|
667
|
-
if (!
|
|
668
|
-
let i =
|
|
669
|
-
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" ||
|
|
741
|
+
if (!m.test(r)) return;
|
|
742
|
+
let i = V(e), a = W(e), o = K(e) || G(e), [s, c] = (t ?? "").split(":");
|
|
743
|
+
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || G(e))) return;
|
|
670
744
|
c ? e["on" + c] === void 0 && this.#V(e, t, "refers to an unsupported event name") : c = "change";
|
|
671
|
-
let l =
|
|
745
|
+
let l = x(r);
|
|
672
746
|
e.addEventListener(c, (e) => {
|
|
673
747
|
let { target: t } = e;
|
|
674
748
|
if (!t) return;
|
|
@@ -704,8 +778,8 @@ var $ = class e extends b {
|
|
|
704
778
|
}
|
|
705
779
|
propertyChangedCallback(e, t, n) {}
|
|
706
780
|
#N(e, t) {
|
|
707
|
-
if (!t || !
|
|
708
|
-
let n =
|
|
781
|
+
if (!t || !m.test(t)) return;
|
|
782
|
+
let n = x(t);
|
|
709
783
|
return this.#T(n) === void 0 && this.#H(e, "", n), n;
|
|
710
784
|
}
|
|
711
785
|
#P(e) {
|
|
@@ -729,16 +803,16 @@ var $ = class e extends b {
|
|
|
729
803
|
i || (i = [], r.set(t, i)), i.push([e, n]);
|
|
730
804
|
}
|
|
731
805
|
let a = t.computed;
|
|
732
|
-
for (let t of a.matchAll(
|
|
733
|
-
let r =
|
|
806
|
+
for (let t of a.matchAll(h)) {
|
|
807
|
+
let r = x(t[0]);
|
|
734
808
|
this.#T(r) === void 0 && this.#H(null, e, r);
|
|
735
|
-
let o =
|
|
809
|
+
let o = q(r), s = !1;
|
|
736
810
|
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(o) && (i(e, a), s = !0);
|
|
737
811
|
!s && typeof this.#T(r) != "function" && i(r, a);
|
|
738
812
|
}
|
|
739
|
-
for (let t of a.matchAll(
|
|
813
|
+
for (let t of a.matchAll(f)) {
|
|
740
814
|
let r = t[1];
|
|
741
|
-
if (typeof this.#T(r) != "function") throw new
|
|
815
|
+
if (typeof this.#T(r) != "function") throw new A(`property ${e} computed calls non-method ${r}`);
|
|
742
816
|
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(r) && i(e, a);
|
|
743
817
|
}
|
|
744
818
|
}
|
|
@@ -763,7 +837,7 @@ var $ = class e extends b {
|
|
|
763
837
|
}
|
|
764
838
|
let i = this.#n;
|
|
765
839
|
r.forEach((t) => {
|
|
766
|
-
let n =
|
|
840
|
+
let n = x(t);
|
|
767
841
|
if (typeof this.#T(n) == "function") return;
|
|
768
842
|
let r = i.propToExprsMap, a = r.get(n);
|
|
769
843
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
@@ -782,20 +856,20 @@ var $ = class e extends b {
|
|
|
782
856
|
}
|
|
783
857
|
#B(e, t) {
|
|
784
858
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
785
|
-
r || this.#H(e, "ref", n), r.type !==
|
|
859
|
+
r || this.#H(e, "ref", n), r.type !== O && this.#V(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#T(n) && this.#V(e, "ref", `is a duplicate reference to the property "${n}"`), this.#R(n, e), e.removeAttribute("ref");
|
|
786
860
|
}
|
|
787
861
|
setAttributeSafe(e, t) {
|
|
788
862
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
789
863
|
}
|
|
790
864
|
setFormValue(e, t) {
|
|
791
|
-
!this.#a || !
|
|
865
|
+
!this.#a || !U(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
|
|
792
866
|
}
|
|
793
867
|
static ssr(e = {}) {
|
|
794
|
-
throw new
|
|
868
|
+
throw new A("SSR is not available in the browser build.");
|
|
795
869
|
}
|
|
796
870
|
#V(e, t, n) {
|
|
797
871
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
798
|
-
throw new
|
|
872
|
+
throw new A(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
799
873
|
}
|
|
800
874
|
#H(e, t, n) {
|
|
801
875
|
this.#V(e, t, `refers to missing property "${n}"`);
|
|
@@ -804,9 +878,9 @@ var $ = class e extends b {
|
|
|
804
878
|
return this.#W(e, this.getAttribute(t));
|
|
805
879
|
}
|
|
806
880
|
#W(t, n) {
|
|
807
|
-
if (n?.match(
|
|
881
|
+
if (n?.match(h)) return n;
|
|
808
882
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
809
|
-
if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 :
|
|
883
|
+
if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : F(r);
|
|
810
884
|
if (i === String) {
|
|
811
885
|
if (a && !a.includes(n)) {
|
|
812
886
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
@@ -823,7 +897,7 @@ var $ = class e extends b {
|
|
|
823
897
|
}
|
|
824
898
|
}
|
|
825
899
|
#G(e, t, n, r) {
|
|
826
|
-
|
|
900
|
+
U(n) && !this.#A(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#U(e, r)) && X(this, r || e, n);
|
|
827
901
|
}
|
|
828
902
|
#K(e) {
|
|
829
903
|
for (let [t, n] of this.#w([e])) this.#L(t, this.#x(n));
|
|
@@ -835,9 +909,9 @@ var $ = class e extends b {
|
|
|
835
909
|
let r = typeof t;
|
|
836
910
|
r !== "string" && r !== "number" && this.#V(e, void 0, " computed content is not a string or number");
|
|
837
911
|
let i = String(t);
|
|
838
|
-
if (e instanceof HTMLElement &&
|
|
912
|
+
if (e instanceof HTMLElement && G(e)) e.value !== i && (e.value = i);
|
|
839
913
|
else if (n && r === "string" && i.trim().startsWith("<")) {
|
|
840
|
-
let t =
|
|
914
|
+
let t = T(i);
|
|
841
915
|
if (e.innerHTML === t) return;
|
|
842
916
|
e.innerHTML = t, this.#te(e), this.#M(e);
|
|
843
917
|
} else n && e.textContent !== i && (e.textContent = i);
|
|
@@ -857,12 +931,12 @@ var $ = class e extends b {
|
|
|
857
931
|
let r = e.get(t);
|
|
858
932
|
r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
|
|
859
933
|
}, n = () => {
|
|
860
|
-
let n =
|
|
934
|
+
let n = E();
|
|
861
935
|
e.methodToExprsMap = n;
|
|
862
936
|
let r = Array.from(this.#r.keys());
|
|
863
937
|
for (let e of r) {
|
|
864
|
-
for (let r of e.matchAll(
|
|
865
|
-
for (let r of e.matchAll(
|
|
938
|
+
for (let r of e.matchAll(f)) t(n, r[1], e);
|
|
939
|
+
for (let r of e.matchAll(h)) t(n, q(x(r[0])), e);
|
|
866
940
|
}
|
|
867
941
|
}, { properties: r, propToExprsMap: i } = e;
|
|
868
942
|
for (let [t, a] of Object.entries(r)) {
|
|
@@ -872,10 +946,10 @@ var $ = class e extends b {
|
|
|
872
946
|
let { methodToExprsMap: o } = e, s = i.get(t);
|
|
873
947
|
s || (s = [], i.set(t, s));
|
|
874
948
|
for (let e of r) {
|
|
875
|
-
if (
|
|
876
|
-
let n =
|
|
877
|
-
if (typeof
|
|
878
|
-
} else if (typeof this.#T(e) != "function") throw new
|
|
949
|
+
if (H(e)) {
|
|
950
|
+
let n = z(e);
|
|
951
|
+
if (typeof R(this, n)?.get != "function") throw new A(`property ${t} usedBy contains non-getter ${e}`);
|
|
952
|
+
} else if (typeof this.#T(e) != "function") throw new A(`property ${t} usedBy contains non-method ${e}`);
|
|
879
953
|
let n = o.get(e) || [];
|
|
880
954
|
for (let e of n) s.includes(e) || s.push(e);
|
|
881
955
|
}
|
|
@@ -917,7 +991,7 @@ var $ = class e extends b {
|
|
|
917
991
|
}
|
|
918
992
|
#X() {
|
|
919
993
|
let t = new Set(Object.keys(this.#n.properties));
|
|
920
|
-
for (let n of this.getAttributeNames()) if (!
|
|
994
|
+
for (let n of this.getAttributeNames()) if (!D.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
921
995
|
if (n === "form-assoc") {
|
|
922
996
|
this.#ee();
|
|
923
997
|
continue;
|
|
@@ -932,9 +1006,9 @@ var $ = class e extends b {
|
|
|
932
1006
|
}
|
|
933
1007
|
}
|
|
934
1008
|
#Z(e, t, n) {
|
|
935
|
-
let r = n.match(
|
|
1009
|
+
let r = n.match(h);
|
|
936
1010
|
if (r) return r.forEach((n) => {
|
|
937
|
-
let r =
|
|
1011
|
+
let r = x(n);
|
|
938
1012
|
this.#T(r) === void 0 && this.#H(e, t, r);
|
|
939
1013
|
}), r;
|
|
940
1014
|
}
|
|
@@ -982,13 +1056,13 @@ var $ = class e extends b {
|
|
|
982
1056
|
}
|
|
983
1057
|
}
|
|
984
1058
|
};
|
|
985
|
-
function
|
|
986
|
-
let n =
|
|
1059
|
+
function de(e, ...t) {
|
|
1060
|
+
let n = B(e, t);
|
|
987
1061
|
for (;;) {
|
|
988
|
-
let e =
|
|
1062
|
+
let e = j.exec(n);
|
|
989
1063
|
if (!e) break;
|
|
990
1064
|
let t = e[2];
|
|
991
|
-
if (
|
|
1065
|
+
if (g.test(t)) {
|
|
992
1066
|
let r = e[1];
|
|
993
1067
|
if (!r.startsWith("--")) {
|
|
994
1068
|
let i = `--${r}: ${t};
|
|
@@ -999,13 +1073,13 @@ function re(e, ...t) {
|
|
|
999
1073
|
}
|
|
1000
1074
|
return n;
|
|
1001
1075
|
}
|
|
1002
|
-
function
|
|
1003
|
-
let n =
|
|
1076
|
+
function fe(e, ...t) {
|
|
1077
|
+
let n = B(e, t);
|
|
1004
1078
|
for (;;) {
|
|
1005
|
-
let e =
|
|
1079
|
+
let e = M.exec(n);
|
|
1006
1080
|
if (!e || e[1] === "style") break;
|
|
1007
|
-
let t =
|
|
1008
|
-
if (
|
|
1081
|
+
let t = le(e[2]);
|
|
1082
|
+
if (g.test(t)) {
|
|
1009
1083
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
1010
1084
|
n = J(n, i, t.length, r);
|
|
1011
1085
|
}
|
|
@@ -1013,4 +1087,4 @@ function ie(e, ...t) {
|
|
|
1013
1087
|
return n;
|
|
1014
1088
|
}
|
|
1015
1089
|
//#endregion
|
|
1016
|
-
export { a,
|
|
1090
|
+
export { g as a, x as c, fe as i, ne as l, P as n, m as o, de as r, b as s, $ as t, a as u };
|