wrec 0.29.1 → 0.29.3
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-DdxbuCnt.js → wrec-DEac2MyH.js} +206 -184
- package/dist/wrec-ssr.d.ts +3 -0
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.d.ts +3 -0
- package/dist/wrec.es.js +1 -1
- package/package.json +2 -2
- package/scripts/lint.js +7 -1
- package/scripts/used-by.js +282 -203
|
@@ -151,85 +151,85 @@ function d(t) {
|
|
|
151
151
|
}
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/wrec.ts
|
|
154
|
-
var f = new Set([
|
|
154
|
+
var f = () => /* @__PURE__ */ new Map(), p = new Set([
|
|
155
155
|
"class",
|
|
156
156
|
"disabled",
|
|
157
157
|
"hidden",
|
|
158
158
|
"id",
|
|
159
159
|
"tabindex",
|
|
160
160
|
"title"
|
|
161
|
-
]),
|
|
161
|
+
]), m = globalThis.HTMLElement ?? class {}, h = globalThis.customElements ?? {
|
|
162
162
|
get: (e) => void 0,
|
|
163
163
|
getName: (e) => null,
|
|
164
164
|
define: () => {},
|
|
165
165
|
initialize: (e) => {},
|
|
166
166
|
upgrade: (e) => {},
|
|
167
167
|
whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
|
|
168
|
-
},
|
|
169
|
-
function
|
|
170
|
-
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof
|
|
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
|
+
function D(e) {
|
|
170
|
+
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof W;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function O(e, t, n) {
|
|
173
173
|
let r = document.createElement(e);
|
|
174
174
|
if (t) for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
175
175
|
return n && (r.innerHTML = n), r;
|
|
176
176
|
}
|
|
177
|
-
var
|
|
178
|
-
function
|
|
177
|
+
var k = (e) => Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : A(e.type), A = (e) => e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
178
|
+
function j(e) {
|
|
179
179
|
let t = [], n = e.firstElementChild;
|
|
180
|
-
for (; n;) t.push(n), n.shadowRoot && t.push(...
|
|
180
|
+
for (; n;) t.push(n), n.shadowRoot && t.push(...j(n.shadowRoot)), n.firstElementChild && t.push(...j(n)), n = n.nextElementSibling;
|
|
181
181
|
return t;
|
|
182
182
|
}
|
|
183
|
-
var
|
|
184
|
-
function
|
|
183
|
+
var M = (e) => e.substring(E).split(".")[0];
|
|
184
|
+
function N(e, t) {
|
|
185
185
|
let n = e[0];
|
|
186
186
|
return t.forEach((t, r) => {
|
|
187
187
|
n += t + e[r + 1];
|
|
188
188
|
}), n;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function P(e) {
|
|
191
191
|
let t = typeof e;
|
|
192
192
|
return t === "string" || t === "number" || t === "boolean";
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function F(e) {
|
|
195
195
|
return e.localName === "textarea";
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function I(e) {
|
|
198
198
|
let { localName: t } = e;
|
|
199
199
|
return t === "input" || t === "select";
|
|
200
200
|
}
|
|
201
|
-
var
|
|
202
|
-
function
|
|
201
|
+
var L = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
202
|
+
function R(e, t, n, r) {
|
|
203
203
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function z(e) {
|
|
206
206
|
let t = Number(e);
|
|
207
|
-
if (isNaN(t)) throw new
|
|
207
|
+
if (isNaN(t)) throw new g(`can't convert "${e}" to a number`);
|
|
208
208
|
return t;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function B(e, t, n) {
|
|
211
211
|
let [r, i] = t.split(":");
|
|
212
|
-
if (
|
|
212
|
+
if (P(n)) if (typeof n == "boolean") {
|
|
213
213
|
n ? e.setAttribute(r, r) : e.removeAttribute(r);
|
|
214
|
-
let t =
|
|
214
|
+
let t = W.getPropName(r);
|
|
215
215
|
e[t] = n;
|
|
216
216
|
} else {
|
|
217
217
|
let i = e.getAttribute(t), a = String(n);
|
|
218
|
-
i !== a && (e.setAttribute(r, a), r === "value" &&
|
|
218
|
+
i !== a && (e.setAttribute(r, a), r === "value" && I(e) && (e.value = a));
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
221
|
-
let r =
|
|
221
|
+
let r = W.getPropName(t);
|
|
222
222
|
e[r] = n;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function V(e, t, n) {
|
|
226
226
|
let [r, i] = t.split(":");
|
|
227
|
-
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (
|
|
227
|
+
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (B(e, r, n), r === "value" && I(e) && (e.value = n));
|
|
228
228
|
}
|
|
229
|
-
var
|
|
230
|
-
async function
|
|
229
|
+
var H = (e) => typeof e == "string" ? [e] : e;
|
|
230
|
+
async function U(e) {
|
|
231
231
|
let t = /* @__PURE__ */ new Set();
|
|
232
|
-
for (let n of
|
|
232
|
+
for (let n of j(e.content)) {
|
|
233
233
|
let { localName: e } = n;
|
|
234
234
|
e.includes("-") && t.add(e);
|
|
235
235
|
}
|
|
@@ -241,9 +241,9 @@ async function H(e) {
|
|
|
241
241
|
}, 1e3);
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
return Promise.all([...t].map(async (e) => Promise.race([
|
|
244
|
+
return Promise.all([...t].map(async (e) => Promise.race([h.whenDefined(e), n(e)])));
|
|
245
245
|
}
|
|
246
|
-
var
|
|
246
|
+
var W = class e extends m {
|
|
247
247
|
static {
|
|
248
248
|
this.attrToPropMap = /* @__PURE__ */ new Map();
|
|
249
249
|
}
|
|
@@ -280,19 +280,19 @@ var U = class e extends p {
|
|
|
280
280
|
#l = /* @__PURE__ */ new Map();
|
|
281
281
|
#u = /* @__PURE__ */ new Map();
|
|
282
282
|
static define(e) {
|
|
283
|
-
if (this.elementName = e,
|
|
284
|
-
|
|
283
|
+
if (this.elementName = e, h.get(e)) throw new g(`custom element ${e} is already defined`);
|
|
284
|
+
h.define(e, this);
|
|
285
285
|
}
|
|
286
286
|
constructor() {
|
|
287
287
|
super(), this.attachShadow({ mode: "open" });
|
|
288
288
|
let e = this.#n;
|
|
289
|
-
this.#
|
|
289
|
+
this.#C("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#C("computedGraph") || (e.computedGraph = null), this.#C("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#C("properties") || (e.properties = {}), this.#C("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#C("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#C("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#C("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
|
|
290
290
|
}
|
|
291
291
|
attributeChangedCallback(t, n, r) {
|
|
292
292
|
t === "disabled" && this.#h();
|
|
293
293
|
let i = e.getPropName(t);
|
|
294
|
-
if (!this.#
|
|
295
|
-
let e = this.#
|
|
294
|
+
if (!this.#T(i) && this.#w(i)) {
|
|
295
|
+
let e = this.#R(i, r);
|
|
296
296
|
this[i] = e;
|
|
297
297
|
let t = this.#i[i];
|
|
298
298
|
t && this.setFormValue(t, String(e));
|
|
@@ -306,9 +306,9 @@ var U = class e extends p {
|
|
|
306
306
|
let e = t.get(r) ?? [];
|
|
307
307
|
for (let t of e) n.add(t);
|
|
308
308
|
}
|
|
309
|
-
let r = this.#
|
|
309
|
+
let r = this.#x(Object.keys(e));
|
|
310
310
|
for (let [e, i] of r) {
|
|
311
|
-
this.#
|
|
311
|
+
this.#M(e, this.#v(i));
|
|
312
312
|
let r = t.get(e) ?? [];
|
|
313
313
|
for (let e of r) n.add(e);
|
|
314
314
|
}
|
|
@@ -316,49 +316,50 @@ var U = class e extends p {
|
|
|
316
316
|
}
|
|
317
317
|
async #d() {
|
|
318
318
|
let e = this.#n, { template: t } = e;
|
|
319
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
319
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await U(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
320
320
|
}
|
|
321
321
|
static buildHTML() {
|
|
322
322
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
323
323
|
this.css && (e += this.css), e += "</style>\n";
|
|
324
324
|
let t = this.html.trim();
|
|
325
|
-
if (!t) throw new
|
|
325
|
+
if (!t) throw new g("static property html must be set");
|
|
326
326
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
327
327
|
}
|
|
328
328
|
changed(e, t, n) {
|
|
329
329
|
this[t] = n;
|
|
330
330
|
}
|
|
331
331
|
async connectedCallback() {
|
|
332
|
-
this.#
|
|
332
|
+
this.#W(), this.#p(), await this.#d(), this.hasAttribute("disabled") && this.#h(), this.#J(this.shadowRoot), this.#E(this.shadowRoot), this.#U(), this.#f(), this.ready();
|
|
333
333
|
}
|
|
334
334
|
#f() {
|
|
335
335
|
let { properties: e } = this.#n;
|
|
336
|
-
for (let [t, { computed: n }] of Object.entries(e)) n && this.#
|
|
336
|
+
for (let [t, { computed: n }] of Object.entries(e)) n && this.#M(t, this.#v(n));
|
|
337
337
|
}
|
|
338
338
|
#p() {
|
|
339
339
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
340
340
|
for (let [n, r] of Object.entries(t)) r.computed || this.#m(n, r, e);
|
|
341
341
|
for (let [n, r] of Object.entries(t)) r.computed && this.#m(n, r, e);
|
|
342
|
+
this.#A();
|
|
342
343
|
}
|
|
343
344
|
#m(t, n, r) {
|
|
344
|
-
if (t === "class" || t === "style") throw new
|
|
345
|
+
if (t === "class" || t === "style") throw new g(`"${t}" is a reserved property`);
|
|
345
346
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
346
|
-
n.required && !a && this.#
|
|
347
|
+
n.required && !a && this.#F(this, i, "is a required attribute");
|
|
347
348
|
let o = n.value;
|
|
348
349
|
this.hasOwnProperty(t) && (o = this[t], delete this[t]);
|
|
349
|
-
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#
|
|
350
|
-
this[u] = l,
|
|
350
|
+
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#L(t, i) : o ?? k(n), u = "#" + t;
|
|
351
|
+
this[u] = l, Object.defineProperty(this, t, {
|
|
351
352
|
enumerable: !0,
|
|
352
353
|
get() {
|
|
353
354
|
return this[u];
|
|
354
355
|
},
|
|
355
356
|
set(e) {
|
|
356
|
-
n.computed && !this.#t.has(t) && this.#
|
|
357
|
+
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 = z(e));
|
|
357
358
|
let r = this[u];
|
|
358
359
|
if (e === r) return;
|
|
359
|
-
this.#
|
|
360
|
+
this.#q(t, c, e), this[u] = e;
|
|
360
361
|
let a = this.#l.get(t);
|
|
361
|
-
a && s(a.state, a.stateProp, e), this.#
|
|
362
|
+
a && s(a.state, a.stateProp, e), this.#z(t, c, e, i), this.#e || (this.#B(t), this.#k(t)), this.#H(t, e);
|
|
362
363
|
let o = this.#i[t];
|
|
363
364
|
o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
|
|
364
365
|
tagName: this.localName,
|
|
@@ -370,8 +371,8 @@ var U = class e extends p {
|
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
373
|
#h() {
|
|
373
|
-
let e = this.hasAttribute("disabled"), t =
|
|
374
|
-
for (let n of t)
|
|
374
|
+
let e = this.hasAttribute("disabled"), t = j(this.shadowRoot);
|
|
375
|
+
for (let n of t) D(n) && (n.disabled = e);
|
|
375
376
|
}
|
|
376
377
|
disconnectedCallback() {
|
|
377
378
|
for (let { unsubscribe: e } of this.#u.values()) e();
|
|
@@ -392,17 +393,17 @@ var U = class e extends p {
|
|
|
392
393
|
for (let r of t.getAttributeNames()) {
|
|
393
394
|
let i = t.getAttribute(r);
|
|
394
395
|
if (r === "ref") {
|
|
395
|
-
this.#
|
|
396
|
+
this.#P(t, i);
|
|
396
397
|
continue;
|
|
397
398
|
}
|
|
398
|
-
let a = this.#
|
|
399
|
+
let a = this.#O(t, i);
|
|
399
400
|
if (a) {
|
|
400
401
|
let i = this[a];
|
|
401
|
-
i === void 0 && this.#
|
|
402
|
-
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#
|
|
403
|
-
n && t.#
|
|
402
|
+
i === void 0 && this.#I(t, r, a);
|
|
403
|
+
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#T(a);
|
|
404
|
+
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);
|
|
404
405
|
}
|
|
405
|
-
this.#
|
|
406
|
+
this.#N(i, t, r);
|
|
406
407
|
}
|
|
407
408
|
}
|
|
408
409
|
#_(e) {
|
|
@@ -414,10 +415,10 @@ var U = class e extends p {
|
|
|
414
415
|
r.add(t);
|
|
415
416
|
continue;
|
|
416
417
|
}
|
|
417
|
-
if (t instanceof HTMLElement) this.#
|
|
418
|
+
if (t instanceof HTMLElement) this.#V(t, e);
|
|
418
419
|
else if (!(t instanceof CSSStyleRule)) {
|
|
419
420
|
let { element: n, attrName: r } = t;
|
|
420
|
-
n instanceof CSSStyleRule ? n.style.setProperty(r, e) :
|
|
421
|
+
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : V(n, r, e);
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
424
|
if (r.size > 0) {
|
|
@@ -438,22 +439,22 @@ var U = class e extends p {
|
|
|
438
439
|
let t = Array.from(e.style);
|
|
439
440
|
for (let n of t) if (n.startsWith("--")) {
|
|
440
441
|
let t = e.style.getPropertyValue(n);
|
|
441
|
-
this.#
|
|
442
|
+
this.#N(t, e, n);
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
445
|
} else {
|
|
445
446
|
let t = "";
|
|
446
|
-
if (
|
|
447
|
-
this.#
|
|
448
|
-
let n = e.textContent?.match(
|
|
447
|
+
if (F(e)) {
|
|
448
|
+
this.#N(e.textContent, e);
|
|
449
|
+
let n = e.textContent?.match(x);
|
|
449
450
|
n && (t = n[1]);
|
|
450
451
|
} else {
|
|
451
452
|
let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
|
|
452
453
|
n && (t = n.textContent?.trim() ?? "");
|
|
453
454
|
}
|
|
454
455
|
if (t) {
|
|
455
|
-
let n = this.#
|
|
456
|
-
n &&
|
|
456
|
+
let n = this.#O(e, t);
|
|
457
|
+
n && F(e) ? e.textContent = this[n] : this.#N(t, e);
|
|
457
458
|
}
|
|
458
459
|
}
|
|
459
460
|
}
|
|
@@ -461,7 +462,7 @@ var U = class e extends p {
|
|
|
461
462
|
let e = this.getAttribute("form-assoc");
|
|
462
463
|
if (!e) {
|
|
463
464
|
let t = this.getAttribute("name");
|
|
464
|
-
if (t) if (this.#
|
|
465
|
+
if (t) if (this.#w("value")) e = `value:${t}`;
|
|
465
466
|
else return;
|
|
466
467
|
else return;
|
|
467
468
|
}
|
|
@@ -473,7 +474,7 @@ var U = class e extends p {
|
|
|
473
474
|
this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
|
|
474
475
|
for (let [e, n] of Object.entries(t)) {
|
|
475
476
|
let t = this[e];
|
|
476
|
-
|
|
477
|
+
P(t) && this.setFormValue(n, String(t));
|
|
477
478
|
}
|
|
478
479
|
let r = Object.keys(this.#n.properties), i = this.#o;
|
|
479
480
|
for (let e of r) i[e] = this[e];
|
|
@@ -482,113 +483,134 @@ var U = class e extends p {
|
|
|
482
483
|
let e = this.#o;
|
|
483
484
|
for (let t of Object.keys(e)) {
|
|
484
485
|
let n = e[t];
|
|
485
|
-
|
|
486
|
+
C.test(n) && (n = this.#v(n)), this[t] = n;
|
|
486
487
|
}
|
|
487
488
|
}
|
|
488
489
|
static getAttrName(e) {
|
|
489
490
|
let t = this.propToAttrMap.get(e);
|
|
490
491
|
return t || (t = e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), this.propToAttrMap.set(e, t)), t;
|
|
491
492
|
}
|
|
492
|
-
#b(
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
#b() {
|
|
494
|
+
let e = this.#n, t = e.computedGraph;
|
|
495
|
+
if (t) return t;
|
|
496
|
+
let n = f(), r = f(), i = {};
|
|
497
|
+
for (let t of e.registeredComputedProps) n.set(t, []);
|
|
498
|
+
for (let [t, a] of e.propToComputedMap) for (let [o, s] of a) {
|
|
499
|
+
if (i[o] = s, !e.registeredComputedProps.has(o) || (n.has(o) || n.set(o, []), !e.registeredComputedProps.has(t))) continue;
|
|
500
|
+
n.get(o).push(t);
|
|
501
|
+
let a = r.get(t);
|
|
502
|
+
a || (a = [], r.set(t, a)), a.push(o);
|
|
503
|
+
}
|
|
504
|
+
return t = {
|
|
505
|
+
computedToDependenciesMap: n,
|
|
506
|
+
computedToDependentsMap: r,
|
|
507
|
+
computedToExprMap: i
|
|
508
|
+
}, e.computedGraph = t, t;
|
|
509
|
+
}
|
|
510
|
+
#x(e) {
|
|
511
|
+
let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#b(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
|
|
512
|
+
for (let e = 0; e < o.length; e++) {
|
|
513
|
+
let t = o[e], n = i.get(t) || [];
|
|
514
|
+
for (let [e, t] of n) r[e] = t, a.has(e) || (a.add(e), o.push(e));
|
|
515
|
+
}
|
|
516
|
+
let s = [...a].filter((e) => (t.get(e) || []).filter((e) => a.has(e)).length === 0), c = [], l = /* @__PURE__ */ new Map();
|
|
517
|
+
for (let e of a) {
|
|
518
|
+
let n = t.get(e) || [], r = 0;
|
|
519
|
+
for (let e of n) a.has(e) && r++;
|
|
520
|
+
l.set(e, r);
|
|
497
521
|
}
|
|
498
|
-
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
499
|
-
for (let e of n) a.set(e, 0);
|
|
500
|
-
for (let e of n) {
|
|
501
|
-
let r = t.get(e) || [];
|
|
502
|
-
for (let [t] of r) {
|
|
503
|
-
if (!n.has(t)) continue;
|
|
504
|
-
a.set(t, a.get(t) + 1);
|
|
505
|
-
let r = o.get(e);
|
|
506
|
-
r || (r = [], o.set(e, r)), r.push(t);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
let s = [...n].filter((e) => a.get(e) === 0), c = [];
|
|
510
522
|
for (let e = 0; e < s.length; e++) {
|
|
511
523
|
let t = s[e];
|
|
512
524
|
c.push(t);
|
|
513
|
-
let
|
|
514
|
-
for (let e of
|
|
515
|
-
|
|
516
|
-
|
|
525
|
+
let r = n.get(t) || [];
|
|
526
|
+
for (let e of r) {
|
|
527
|
+
if (!a.has(e)) continue;
|
|
528
|
+
let t = l.get(e) - 1;
|
|
529
|
+
l.set(e, t), t === 0 && s.push(e);
|
|
517
530
|
}
|
|
518
531
|
}
|
|
519
|
-
if (c.length !==
|
|
532
|
+
if (c.length !== a.size) throw new g(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
520
533
|
return c.map((e) => [e, r[e]]);
|
|
521
534
|
}
|
|
522
535
|
static getPropName(e) {
|
|
523
536
|
let t = this.attrToPropMap.get(e);
|
|
524
537
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
525
538
|
}
|
|
526
|
-
#
|
|
539
|
+
#S(e, t, n) {
|
|
527
540
|
if (n.length !== 1) return;
|
|
528
541
|
let [r] = n;
|
|
529
|
-
if (!
|
|
530
|
-
let i =
|
|
531
|
-
if (!(i && a === "value" ||
|
|
532
|
-
o ? e["on" + o] === void 0 && this.#
|
|
533
|
-
let s =
|
|
542
|
+
if (!C.test(r)) return;
|
|
543
|
+
let i = I(e) || F(e), [a, o] = (t ?? "").split(":");
|
|
544
|
+
if (!(i && a === "value" || F(e))) return;
|
|
545
|
+
o ? e["on" + o] === void 0 && this.#F(e, t, "refers to an unsupported event name") : o = "change";
|
|
546
|
+
let s = M(r);
|
|
534
547
|
e.addEventListener(o, (e) => {
|
|
535
548
|
let { target: t } = e;
|
|
536
549
|
if (!t) return;
|
|
537
550
|
let n = t.value, { type: r } = this.#n.properties[s];
|
|
538
|
-
this[s] = r === Number ?
|
|
551
|
+
this[s] = r === Number ? z(n) : n, this.#k(s);
|
|
539
552
|
});
|
|
540
553
|
}
|
|
541
|
-
#
|
|
554
|
+
#C(e) {
|
|
542
555
|
return Object.hasOwn(this.#n, e);
|
|
543
556
|
}
|
|
544
|
-
#
|
|
557
|
+
#w(e) {
|
|
545
558
|
return !!this.#n.properties[e];
|
|
546
559
|
}
|
|
547
|
-
#
|
|
560
|
+
#T(e) {
|
|
548
561
|
return !!this.#n.properties[e]?.computed;
|
|
549
562
|
}
|
|
550
|
-
#
|
|
563
|
+
#E(e) {
|
|
551
564
|
let t = Array.from(e.querySelectorAll("*"));
|
|
552
565
|
for (let e of t) this.#g(e), e.firstElementChild || this.#y(e);
|
|
553
566
|
}
|
|
554
|
-
#
|
|
567
|
+
#D() {
|
|
555
568
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
556
569
|
let e = this.#n.name;
|
|
557
|
-
this.#
|
|
570
|
+
this.#F(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
558
571
|
}
|
|
559
572
|
static get observedAttributes() {
|
|
560
573
|
let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
|
|
561
574
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
562
575
|
}
|
|
563
576
|
propertyChangedCallback(e, t, n) {}
|
|
564
|
-
#
|
|
565
|
-
if (!t || !
|
|
566
|
-
let n =
|
|
567
|
-
return this[n] === void 0 && this.#
|
|
577
|
+
#O(e, t) {
|
|
578
|
+
if (!t || !C.test(t)) return;
|
|
579
|
+
let n = M(t);
|
|
580
|
+
return this[n] === void 0 && this.#I(e, "", n), n;
|
|
568
581
|
}
|
|
569
|
-
#
|
|
582
|
+
#k(e) {
|
|
570
583
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
571
584
|
this.#_(t);
|
|
572
585
|
}
|
|
573
586
|
ready() {}
|
|
574
|
-
#
|
|
575
|
-
let
|
|
587
|
+
#A() {
|
|
588
|
+
let e = this.#n;
|
|
589
|
+
if (!e.computedPropsRegistered) {
|
|
590
|
+
e.computedPropsRegistered = !0, e.computedGraph = null;
|
|
591
|
+
for (let [t, n] of Object.entries(e.properties)) n.computed && this.#j(t, n);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
#j(e, t) {
|
|
595
|
+
let n = this.#n;
|
|
596
|
+
n.registeredComputedProps.add(e);
|
|
597
|
+
let r = n.propToComputedMap;
|
|
576
598
|
function i(t, n) {
|
|
577
599
|
let i = r.get(t);
|
|
578
600
|
i || (i = [], r.set(t, i)), i.push([e, n]);
|
|
579
601
|
}
|
|
580
|
-
let
|
|
581
|
-
for (let t of
|
|
582
|
-
let n =
|
|
583
|
-
this[n] === void 0 && this.#
|
|
602
|
+
let a = t.computed;
|
|
603
|
+
for (let t of a.matchAll(w)) {
|
|
604
|
+
let n = M(t[0]);
|
|
605
|
+
this[n] === void 0 && this.#I(null, e, n), typeof this[n] != "function" && i(n, a);
|
|
584
606
|
}
|
|
585
|
-
for (let t of a.matchAll(
|
|
607
|
+
for (let t of a.matchAll(b)) {
|
|
586
608
|
let r = t[1];
|
|
587
|
-
if (typeof this[r] != "function") throw new
|
|
588
|
-
for (let [e, t] of Object.entries(n.properties))
|
|
609
|
+
if (typeof this[r] != "function") throw new g(`property ${e} computed calls non-method ${r}`);
|
|
610
|
+
for (let [e, t] of Object.entries(n.properties)) H(t.usedBy)?.includes(r) && i(e, a);
|
|
589
611
|
}
|
|
590
612
|
}
|
|
591
|
-
#
|
|
613
|
+
#M(e, t) {
|
|
592
614
|
this.#t.add(e);
|
|
593
615
|
try {
|
|
594
616
|
this[e] = t;
|
|
@@ -596,17 +618,17 @@ var U = class e extends p {
|
|
|
596
618
|
this.#t.delete(e);
|
|
597
619
|
}
|
|
598
620
|
}
|
|
599
|
-
#
|
|
621
|
+
#N(e, t, n = void 0) {
|
|
600
622
|
if (!e) return;
|
|
601
|
-
let r = this.#
|
|
623
|
+
let r = this.#G(t, n, e);
|
|
602
624
|
if (!r) {
|
|
603
625
|
let r = e.replaceAll("this..", "this.");
|
|
604
|
-
n ?
|
|
626
|
+
n ? V(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
605
627
|
return;
|
|
606
628
|
}
|
|
607
629
|
let i = this.#n;
|
|
608
630
|
r.forEach((t) => {
|
|
609
|
-
let n =
|
|
631
|
+
let n = M(t);
|
|
610
632
|
if (typeof this[n] == "function") return;
|
|
611
633
|
let r = i.propToExprsMap, a = r.get(n);
|
|
612
634
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
@@ -619,68 +641,68 @@ var U = class e extends p {
|
|
|
619
641
|
a || (a = [], this.#r.set(e, a)), a.push(n ? {
|
|
620
642
|
element: t,
|
|
621
643
|
attrName: n
|
|
622
|
-
} : t), t instanceof HTMLElement && this.#
|
|
644
|
+
} : t), t instanceof HTMLElement && this.#S(t, n, r);
|
|
623
645
|
let o = this.#v(e);
|
|
624
|
-
n ?
|
|
646
|
+
n ? V(t, n, o) : this.#V(t, o);
|
|
625
647
|
}
|
|
626
|
-
#
|
|
648
|
+
#P(e, t) {
|
|
627
649
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
628
|
-
r || this.#
|
|
650
|
+
r || this.#I(e, "ref", n), r.type !== m && this.#F(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#F(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
|
|
629
651
|
}
|
|
630
652
|
setAttributeSafe(e, t) {
|
|
631
653
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
632
654
|
}
|
|
633
655
|
setFormValue(e, t) {
|
|
634
|
-
!this.#a || !
|
|
656
|
+
!this.#a || !P(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
|
|
635
657
|
}
|
|
636
658
|
static ssr(e = {}) {
|
|
637
|
-
throw new
|
|
659
|
+
throw new g("SSR is not available in the browser build.");
|
|
638
660
|
}
|
|
639
|
-
#
|
|
661
|
+
#F(e, t, n) {
|
|
640
662
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
641
|
-
throw new
|
|
663
|
+
throw new g(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
642
664
|
}
|
|
643
|
-
#
|
|
644
|
-
this.#
|
|
665
|
+
#I(e, t, n) {
|
|
666
|
+
this.#F(e, t, `refers to missing property "${n}"`);
|
|
645
667
|
}
|
|
646
|
-
#
|
|
647
|
-
return this.#
|
|
668
|
+
#L(e, t) {
|
|
669
|
+
return this.#R(e, this.getAttribute(t));
|
|
648
670
|
}
|
|
649
|
-
#
|
|
650
|
-
if (n?.match(
|
|
671
|
+
#R(t, n) {
|
|
672
|
+
if (n?.match(w)) return n;
|
|
651
673
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
652
|
-
if (i || this.#
|
|
674
|
+
if (i || this.#F(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
|
|
653
675
|
if (i === String) {
|
|
654
676
|
if (a && !a.includes(n)) {
|
|
655
677
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
656
|
-
this.#
|
|
678
|
+
this.#F(null, t, `must be one of ${e}`);
|
|
657
679
|
}
|
|
658
680
|
return n;
|
|
659
681
|
}
|
|
660
|
-
if (i === Number) return
|
|
682
|
+
if (i === Number) return z(n);
|
|
661
683
|
if (i === Boolean) {
|
|
662
684
|
if (n === "true") return !0;
|
|
663
685
|
if (n === "false" || n === "null") return !1;
|
|
664
686
|
let r = e.getAttrName(t);
|
|
665
|
-
return n && n !== r && this.#
|
|
687
|
+
return n && n !== r && this.#F(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
666
688
|
}
|
|
667
689
|
}
|
|
668
|
-
#
|
|
669
|
-
|
|
690
|
+
#z(e, t, n, r) {
|
|
691
|
+
P(n) && !this.#T(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#L(e, r)) && B(this, r || e, n);
|
|
670
692
|
}
|
|
671
|
-
#
|
|
672
|
-
for (let [t, n] of this.#
|
|
693
|
+
#B(e) {
|
|
694
|
+
for (let [t, n] of this.#x([e])) this.#M(t, this.#v(n));
|
|
673
695
|
}
|
|
674
|
-
#
|
|
696
|
+
#V(e, t) {
|
|
675
697
|
if (t === void 0) return;
|
|
676
698
|
let n = e instanceof HTMLElement;
|
|
677
699
|
Array.isArray(t) && (t = t.join(""));
|
|
678
700
|
let r = typeof t;
|
|
679
|
-
r !== "string" && r !== "number" && this.#
|
|
701
|
+
r !== "string" && r !== "number" && this.#F(e, void 0, " computed content is not a string or number");
|
|
680
702
|
let i = String(t);
|
|
681
|
-
e instanceof HTMLElement &&
|
|
703
|
+
e instanceof HTMLElement && F(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#J(e), this.#E(e)) : n && (e.textContent = i);
|
|
682
704
|
}
|
|
683
|
-
#
|
|
705
|
+
#H(e, t) {
|
|
684
706
|
let n = this.#c.get(e);
|
|
685
707
|
if (!n) return;
|
|
686
708
|
let r = this.getRootNode();
|
|
@@ -690,26 +712,26 @@ var U = class e extends p {
|
|
|
690
712
|
let a = i;
|
|
691
713
|
a[n] = t;
|
|
692
714
|
}
|
|
693
|
-
#
|
|
715
|
+
#U() {
|
|
694
716
|
let e = this.#n;
|
|
695
717
|
function t() {
|
|
696
|
-
let t =
|
|
718
|
+
let t = f();
|
|
697
719
|
e.methodToExprsMap = t;
|
|
698
720
|
let n = Array.from(this.#r.keys());
|
|
699
|
-
for (let e of n) for (let n of e.matchAll(
|
|
721
|
+
for (let e of n) for (let n of e.matchAll(b)) {
|
|
700
722
|
let r = n[1], i = t.get(r);
|
|
701
723
|
i || (i = [], t.set(r, i)), i.includes(e) || i.push(e);
|
|
702
724
|
}
|
|
703
725
|
}
|
|
704
726
|
let { properties: n, propToExprsMap: r } = e;
|
|
705
727
|
for (let [i, a] of Object.entries(n)) {
|
|
706
|
-
let n =
|
|
728
|
+
let n = H(a.usedBy);
|
|
707
729
|
if (!n) continue;
|
|
708
730
|
e.methodToExprsMap || t.call(this);
|
|
709
731
|
let { methodToExprsMap: o } = e, s = r.get(i);
|
|
710
732
|
s || (s = [], r.set(i, s));
|
|
711
733
|
for (let e of n) {
|
|
712
|
-
if (typeof this[e] != "function") throw new
|
|
734
|
+
if (typeof this[e] != "function") throw new g(`property ${i} usedBy contains non-method ${e}`);
|
|
713
735
|
let t = o.get(e) || [];
|
|
714
736
|
for (let e of t) s.includes(e) || s.push(e);
|
|
715
737
|
}
|
|
@@ -720,8 +742,8 @@ var U = class e extends p {
|
|
|
720
742
|
t = {};
|
|
721
743
|
for (let n of Object.keys(e)) t[n] = n;
|
|
722
744
|
}
|
|
723
|
-
this.#
|
|
724
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
745
|
+
this.#K(e, t);
|
|
746
|
+
for (let [n, r] of Object.entries(t)) if (this.#w(r)) {
|
|
725
747
|
let t = o(e, n);
|
|
726
748
|
t !== void 0 && (this[r] = t), this.#l.set(r, {
|
|
727
749
|
state: e,
|
|
@@ -742,50 +764,50 @@ var U = class e extends p {
|
|
|
742
764
|
unsubscribe: i
|
|
743
765
|
});
|
|
744
766
|
}
|
|
745
|
-
#
|
|
767
|
+
#W() {
|
|
746
768
|
let t = new Set(Object.keys(this.#n.properties));
|
|
747
|
-
for (let n of this.getAttributeNames()) if (!
|
|
769
|
+
for (let n of this.getAttributeNames()) if (!p.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
748
770
|
if (n === "form-assoc") {
|
|
749
|
-
this.#
|
|
771
|
+
this.#D();
|
|
750
772
|
continue;
|
|
751
773
|
}
|
|
752
774
|
if (!t.has(e.getPropName(n))) {
|
|
753
775
|
if (n === "name") {
|
|
754
|
-
this.#
|
|
776
|
+
this.#D();
|
|
755
777
|
continue;
|
|
756
778
|
}
|
|
757
|
-
this.#
|
|
779
|
+
this.#F(null, n, "is not a supported attribute");
|
|
758
780
|
}
|
|
759
781
|
}
|
|
760
782
|
}
|
|
761
|
-
#
|
|
762
|
-
let r = n.match(
|
|
783
|
+
#G(e, t, n) {
|
|
784
|
+
let r = n.match(w);
|
|
763
785
|
if (r) return r.forEach((n) => {
|
|
764
|
-
let r =
|
|
765
|
-
this[r] === void 0 && this.#
|
|
786
|
+
let r = M(n);
|
|
787
|
+
this[r] === void 0 && this.#I(e, t, r);
|
|
766
788
|
}), r;
|
|
767
789
|
}
|
|
768
|
-
#
|
|
790
|
+
#K(e, t) {
|
|
769
791
|
for (let [n, r] of Object.entries(t)) {
|
|
770
792
|
let t = o(e, n);
|
|
771
|
-
t === void 0 && this.#
|
|
793
|
+
t === void 0 && this.#F(this, void 0, `invalid state path "${n}"`), t = this[r], this.#w(r) || this.#F(null, r, "refers to missing property in useState map");
|
|
772
794
|
}
|
|
773
795
|
}
|
|
774
|
-
#
|
|
796
|
+
#q(e, t, n) {
|
|
775
797
|
let { values: r } = this.#n.properties[e];
|
|
776
798
|
if (r) {
|
|
777
799
|
let i;
|
|
778
|
-
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.#
|
|
800
|
+
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.#F(null, e, i);
|
|
779
801
|
}
|
|
780
802
|
if (n instanceof t) return;
|
|
781
803
|
let i = typeof n;
|
|
782
804
|
if (i === "object") {
|
|
783
805
|
let { constructor: r } = n;
|
|
784
|
-
i = r.name, r !== t && this.#
|
|
806
|
+
i = r.name, r !== t && this.#F(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
785
807
|
}
|
|
786
|
-
i !== t.name.toLowerCase() && this.#
|
|
808
|
+
i !== t.name.toLowerCase() && this.#F(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
787
809
|
}
|
|
788
|
-
#
|
|
810
|
+
#J(e) {
|
|
789
811
|
let t = Array.from(e.querySelectorAll("*"));
|
|
790
812
|
for (let e of t) {
|
|
791
813
|
let t = [];
|
|
@@ -795,44 +817,44 @@ var U = class e extends p {
|
|
|
795
817
|
let i = r.slice(2);
|
|
796
818
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
797
819
|
let a = n.value;
|
|
798
|
-
this.#
|
|
820
|
+
this.#G(e, r, a);
|
|
799
821
|
let o;
|
|
800
|
-
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#
|
|
822
|
+
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#G(e, r, a), o = () => this.#v(a)), e.addEventListener(i, o), t.push(r);
|
|
801
823
|
}
|
|
802
824
|
}
|
|
803
825
|
for (let n of t) e.removeAttribute(n);
|
|
804
826
|
}
|
|
805
827
|
}
|
|
806
828
|
};
|
|
807
|
-
function
|
|
808
|
-
let n =
|
|
829
|
+
function G(e, ...t) {
|
|
830
|
+
let n = N(e, t);
|
|
809
831
|
for (;;) {
|
|
810
|
-
let e =
|
|
832
|
+
let e = _.exec(n);
|
|
811
833
|
if (!e) break;
|
|
812
834
|
let t = e[2];
|
|
813
|
-
if (
|
|
835
|
+
if (T.test(t)) {
|
|
814
836
|
let r = e[1];
|
|
815
837
|
if (!r.startsWith("--")) {
|
|
816
838
|
let i = `--${r}: ${t};
|
|
817
839
|
${r}: var(--${r})`;
|
|
818
|
-
n =
|
|
840
|
+
n = R(n, e.index, e[0].length, i);
|
|
819
841
|
}
|
|
820
842
|
}
|
|
821
843
|
}
|
|
822
844
|
return n;
|
|
823
845
|
}
|
|
824
|
-
function
|
|
825
|
-
let n =
|
|
846
|
+
function K(e, ...t) {
|
|
847
|
+
let n = N(e, t);
|
|
826
848
|
for (;;) {
|
|
827
|
-
let e =
|
|
849
|
+
let e = S.exec(n);
|
|
828
850
|
if (!e || e[1] === "style") break;
|
|
829
|
-
let t =
|
|
830
|
-
if (
|
|
851
|
+
let t = L(e[2]);
|
|
852
|
+
if (T.test(t)) {
|
|
831
853
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
832
|
-
n =
|
|
854
|
+
n = R(n, i, t.length, r);
|
|
833
855
|
}
|
|
834
856
|
}
|
|
835
857
|
return n;
|
|
836
858
|
}
|
|
837
859
|
//#endregion
|
|
838
|
-
export { a,
|
|
860
|
+
export { a, K as i, O as n, G as r, W as t };
|