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