wrec 0.23.0 → 0.23.1

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.
@@ -22,6 +22,7 @@ declare type PropertyConfig = {
22
22
  dispatch?: boolean;
23
23
  required?: boolean;
24
24
  type: AnyClass;
25
+ usedBy?: string[];
25
26
  value?: any;
26
27
  values?: string[];
27
28
  };
@@ -50,7 +51,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
50
51
  batchSet(changes: StringToAny): void;
51
52
  private static buildHTML;
52
53
  changed(_statePath: string, componentProp: string, newValue: unknown): void;
53
- connectedCallback(): void;
54
+ connectedCallback(): Promise<void>;
54
55
  disconnectedCallback(): void;
55
56
  dispatch(name: string, detail: any): void;
56
57
  displayIfSet(value: any, display?: string): string;
@@ -62,7 +63,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
62
63
  propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
63
64
  setAttributeSafe(name: string, value: string): void;
64
65
  setFormValue(propName: string, value: string): void;
65
- static ssr(properties?: StringToAny): void;
66
+ static ssr(properties?: StringToAny): string;
66
67
  /**
67
68
  * @param state - WrecState object
68
69
  * @param map - object whose keys are state properties and
package/dist/wrec.d.ts CHANGED
@@ -22,6 +22,7 @@ declare type PropertyConfig = {
22
22
  dispatch?: boolean;
23
23
  required?: boolean;
24
24
  type: AnyClass;
25
+ usedBy?: string[];
25
26
  value?: any;
26
27
  values?: string[];
27
28
  };
@@ -50,7 +51,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
50
51
  batchSet(changes: StringToAny): void;
51
52
  private static buildHTML;
52
53
  changed(_statePath: string, componentProp: string, newValue: unknown): void;
53
- connectedCallback(): void;
54
+ connectedCallback(): Promise<void>;
54
55
  disconnectedCallback(): void;
55
56
  dispatch(name: string, detail: any): void;
56
57
  displayIfSet(value: any, display?: string): string;
@@ -62,7 +63,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
62
63
  propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
63
64
  setAttributeSafe(name: string, value: string): void;
64
65
  setFormValue(propName: string, value: string): void;
65
- static ssr(properties?: StringToAny): void;
66
+ static ssr(properties?: StringToAny): string;
66
67
  /**
67
68
  * @param state - WrecState object
68
69
  * @param map - object whose keys are state properties and
package/dist/wrec.es.js CHANGED
@@ -1,8 +1,8 @@
1
- var B = (r) => {
1
+ var D = (r) => {
2
2
  throw TypeError(r);
3
3
  };
4
- var L = (r, t, e) => t.has(r) || B("Cannot " + e);
5
- var u = (r, t, e) => (L(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? B("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), w = (r, t, e, s) => (L(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), V = (r, t, e) => (L(r, t, "access private method"), e);
4
+ var L = (r, t, e) => t.has(r) || D("Cannot " + e);
5
+ var p = (r, t, e) => (L(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? D("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), E = (r, t, e, s) => (L(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), V = (r, t, e) => (L(r, t, "access private method"), e);
6
6
  import W from "xss";
7
7
  function U(r, t, e = "") {
8
8
  const s = /* @__PURE__ */ new WeakMap(), o = {
@@ -40,7 +40,7 @@ function Z(r) {
40
40
  const P = typeof window < "u" && typeof window.document < "u";
41
41
  let z = class extends Error {
42
42
  };
43
- var y, $, d, v, C, g, O, Y;
43
+ var w, $, d, v, C, g, O, Y;
44
44
  const T = class T {
45
45
  constructor(t, e, s) {
46
46
  b(this, O);
@@ -52,16 +52,16 @@ const T = class T {
52
52
  b(this, C);
53
53
  b(this, g);
54
54
  if (!t) throw new z("name cannot be empty");
55
- if (u(T, y).has(t))
55
+ if (p(T, w).has(t))
56
56
  throw new z(`WrecState with name "${t}" already exists`);
57
- if (w(this, v, t), w(this, C, e), w(this, g, U({}, V(this, O, Y).bind(this))), e && P) {
57
+ if (E(this, v, t), E(this, C, e), E(this, g, U({}, V(this, O, Y).bind(this))), e && P) {
58
58
  const o = sessionStorage.getItem("wrec-state-" + t), i = o ? JSON.parse(o) : void 0;
59
59
  i && (s = i);
60
60
  }
61
61
  if (s)
62
62
  for (const [o, i] of Object.entries(s))
63
63
  this.addProperty(o, i);
64
- u(T, y).set(t, this);
64
+ p(T, w).set(t, this);
65
65
  }
66
66
  // This static method is useful for accessing a specific WrecState object
67
67
  // from the DevTools console. For example:
@@ -74,14 +74,14 @@ const T = class T {
74
74
  // state.color = 'blue';
75
75
  // state.team.leader.name = 'Mark';
76
76
  static get(t) {
77
- return u(this, y).get(t);
77
+ return p(this, w).get(t);
78
78
  }
79
79
  /**
80
80
  * @param listener - object that has a "changed" method
81
81
  * @param map - map from state property paths to component properties
82
82
  */
83
83
  addListener(t, e = {}) {
84
- const s = u(this, d).find(
84
+ const s = p(this, d).find(
85
85
  (o) => o.listenerRef.deref() === t
86
86
  );
87
87
  if (s) {
@@ -89,7 +89,7 @@ const T = class T {
89
89
  for (const [i, n] of Object.entries(e))
90
90
  o[i] = n;
91
91
  } else
92
- u(this, d).push({
92
+ p(this, d).push({
93
93
  listenerRef: new WeakRef(t),
94
94
  propertyMap: e
95
95
  });
@@ -98,30 +98,30 @@ const T = class T {
98
98
  Object.defineProperty(this, t, {
99
99
  enumerable: !0,
100
100
  get() {
101
- return u(this, g)[t];
101
+ return p(this, g)[t];
102
102
  },
103
103
  set(s) {
104
- u(this, g)[t] = s;
104
+ p(this, g)[t] = s;
105
105
  }
106
- }), u(this, g)[t] = e;
106
+ }), p(this, g)[t] = e;
107
107
  }
108
108
  get id() {
109
- return u(this, $);
109
+ return p(this, $);
110
110
  }
111
111
  // This is useful for debugging from the DevTools console.
112
112
  // For example: state.log()
113
113
  log() {
114
- console.log("WrecState:", u(this, v));
115
- for (const [t, e] of Object.entries(u(this, g)))
114
+ console.log("WrecState:", p(this, v));
115
+ for (const [t, e] of Object.entries(p(this, g)))
116
116
  console.log(` ${t} = ${JSON.stringify(e)}`);
117
117
  }
118
118
  removeListener(t) {
119
- w(this, d, u(this, d).filter((e) => e.listenerRef.deref() !== t));
119
+ E(this, d, p(this, d).filter((e) => e.listenerRef.deref() !== t));
120
120
  }
121
121
  };
122
- y = new WeakMap(), $ = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C = new WeakMap(), g = new WeakMap(), O = new WeakSet(), Y = function(t, e, s) {
122
+ w = new WeakMap(), $ = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C = new WeakMap(), g = new WeakMap(), O = new WeakSet(), Y = function(t, e, s) {
123
123
  const o = /* @__PURE__ */ new Set();
124
- for (const i of u(this, d)) {
124
+ for (const i of p(this, d)) {
125
125
  const n = i.listenerRef.deref();
126
126
  if (!n)
127
127
  o.add(i);
@@ -138,12 +138,12 @@ y = new WeakMap(), $ = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C =
138
138
  );
139
139
  }
140
140
  }
141
- w(this, d, u(this, d).filter(
141
+ E(this, d, p(this, d).filter(
142
142
  (i) => !o.has(i)
143
143
  ));
144
- }, b(T, y, /* @__PURE__ */ new Map()), P && window.addEventListener("beforeunload", () => {
145
- for (const [t, e] of u(T, y).entries())
146
- if (u(e, C)) {
144
+ }, b(T, w, /* @__PURE__ */ new Map()), P && window.addEventListener("beforeunload", () => {
145
+ for (const [t, e] of p(T, w).entries())
146
+ if (p(e, C)) {
147
147
  const s = Z(e);
148
148
  sessionStorage.setItem("wrec-state-" + t, JSON.stringify(s));
149
149
  }
@@ -219,11 +219,11 @@ const rt = /* @__PURE__ */ new Set([
219
219
  new Error("customElements is not available in this environment")
220
220
  )
221
221
  };
222
- class E extends Error {
222
+ class y extends Error {
223
223
  }
224
- const at = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, G = "a-zA-Z_$", ft = G + "0-9", A = `[${G}][${ft}]*`, lt = /<!--\s*(.*?)\s*-->/, ht = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, N = new RegExp(`^this\\.${A}$`), j = new RegExp(`this\\.${A}(\\.${A})*`, "g"), Q = new RegExp(`this\\.${A}(\\.${A})*`), ut = 5;
225
- function pt(r) {
226
- return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof p;
224
+ const at = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, G = "a-zA-Z_$", ft = G + "0-9", M = `[${G}][${ft}]*`, lt = /<!--\s*(.*?)\s*-->/, ht = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, N = new RegExp(`^this\\.${M}$`), j = new RegExp(`this\\.${M}(\\.${M})*`, "g"), Q = new RegExp(`this\\.${M}(\\.${M})*`), pt = 5;
225
+ function ut(r) {
226
+ return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof u;
227
227
  }
228
228
  function Et(r, t, e) {
229
229
  const s = document.createElement(r);
@@ -240,7 +240,7 @@ function R(r) {
240
240
  t.push(e), e.shadowRoot && t.push(...R(e.shadowRoot)), e.firstElementChild && t.push(...R(e)), e = e.nextElementSibling;
241
241
  return t;
242
242
  }
243
- const M = (r) => r.substring(ut).split(".")[0];
243
+ const A = (r) => r.substring(pt).split(".")[0];
244
244
  function tt(r, t) {
245
245
  let e = r[0];
246
246
  return t.forEach((s, o) => {
@@ -254,7 +254,7 @@ function I(r) {
254
254
  function S(r) {
255
255
  return r.localName === "textarea";
256
256
  }
257
- function D(r) {
257
+ function B(r) {
258
258
  const { localName: t } = r;
259
259
  return t === "input" || t === "select";
260
260
  }
@@ -264,7 +264,7 @@ function et(r, t, e, s) {
264
264
  }
265
265
  function H(r) {
266
266
  const t = Number(r);
267
- if (isNaN(t)) throw new E(`can't convert "${r}" to a number`);
267
+ if (isNaN(t)) throw new y(`can't convert "${r}" to a number`);
268
268
  return t;
269
269
  }
270
270
  function st(r, t, e) {
@@ -272,20 +272,20 @@ function st(r, t, e) {
272
272
  if (I(e))
273
273
  if (typeof e == "boolean") {
274
274
  e ? r.setAttribute(s, s) : r.removeAttribute(s);
275
- const i = p.getPropName(s);
275
+ const i = u.getPropName(s);
276
276
  r[i] = e;
277
277
  } else {
278
278
  const i = r.getAttribute(t), n = String(e);
279
- i !== n && (r.setAttribute(s, n), s === "value" && D(r) && (r.value = n));
279
+ i !== n && (r.setAttribute(s, n), s === "value" && B(r) && (r.value = n));
280
280
  }
281
281
  else {
282
- const i = p.getPropName(t);
282
+ const i = u.getPropName(t);
283
283
  r[i] = e;
284
284
  }
285
285
  }
286
286
  function k(r, t, e) {
287
287
  const [s, o] = t.split(":");
288
- r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (st(r, s, e), s === "value" && D(r) && (r.value = e));
288
+ r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (st(r, s, e), s === "value" && B(r) && (r.value = e));
289
289
  }
290
290
  async function bt(r) {
291
291
  const t = /* @__PURE__ */ new Set();
@@ -310,7 +310,7 @@ async function bt(r) {
310
310
  )
311
311
  );
312
312
  }
313
- class p extends ct {
313
+ class u extends ct {
314
314
  // There is one instance of `attrToPropMap`, `properties`, `propToAttrMap`,
315
315
  // `propToComputedMap`, and `propToExprsMap` per Wrec subclass,
316
316
  // not one for only the Wrec class.
@@ -352,10 +352,10 @@ class p extends ct {
352
352
  static propToExprsMap;
353
353
  static template = null;
354
354
  // This is true while the batchSet method is running.
355
- #u = !1;
355
+ #p = !1;
356
356
  // This holds the names of computed properties
357
357
  // that are currently being updated.
358
- #p = /* @__PURE__ */ new Set();
358
+ #u = /* @__PURE__ */ new Set();
359
359
  #t = this.constructor;
360
360
  // This is a map from expressions to references to them
361
361
  // which can be found in element text content,
@@ -384,7 +384,7 @@ class p extends ct {
384
384
  #r = /* @__PURE__ */ new Map();
385
385
  static define(t) {
386
386
  if (this.elementName = t, F.get(t))
387
- throw new E(`custom element ${t} is already defined`);
387
+ throw new y(`custom element ${t} is already defined`);
388
388
  F.define(t, this);
389
389
  }
390
390
  constructor() {
@@ -394,7 +394,7 @@ class p extends ct {
394
394
  }
395
395
  attributeChangedCallback(t, e, s) {
396
396
  t === "disabled" && this.#E();
397
- const o = p.getPropName(t);
397
+ const o = u.getPropName(t);
398
398
  if (!this.#a(o) && this.#c(o)) {
399
399
  const i = this.#x(o, s);
400
400
  this[o] = i;
@@ -405,7 +405,7 @@ class p extends ct {
405
405
  // This applies multiple property changes and only updates
406
406
  // the affected parts of the DOM after all of them are made.
407
407
  batchSet(t) {
408
- this.#u = !0;
408
+ this.#p = !0;
409
409
  const e = this.#t.propToExprsMap, s = /* @__PURE__ */ new Set();
410
410
  for (const [c, a] of Object.entries(t)) {
411
411
  this[c] = a;
@@ -434,7 +434,7 @@ class p extends ct {
434
434
  }
435
435
  if (!c) break;
436
436
  }
437
- this.#T([...s]), this.#u = !1;
437
+ this.#T([...s]), this.#p = !1;
438
438
  }
439
439
  async #$() {
440
440
  const t = this.#t;
@@ -447,16 +447,14 @@ class p extends ct {
447
447
  this.css && (t += this.css), t += `</style>
448
448
  `;
449
449
  let e = this.html.trim();
450
- if (!e) throw new E("static property html must be set");
450
+ if (!e) throw new y("static property html must be set");
451
451
  return e.startsWith("<") || (e = `<span><!--${e}--></span>`), t + e;
452
452
  }
453
453
  changed(t, e, s) {
454
454
  this[e] = s;
455
455
  }
456
- connectedCallback() {
457
- this.#D(), this.#L(), this.#$().then(() => {
458
- this.hasAttribute("disabled") && this.#E(), this.#R(this.shadowRoot), this.#M(this.shadowRoot), this.#O();
459
- });
456
+ async connectedCallback() {
457
+ this.#D(), this.#L(), await this.#$(), this.hasAttribute("disabled") && this.#E(), this.#R(this.shadowRoot), this.#M(this.shadowRoot), this.#B(), this.#O();
460
458
  }
461
459
  #O() {
462
460
  const t = this.#t, { properties: e } = t;
@@ -472,8 +470,8 @@ class p extends ct {
472
470
  }
473
471
  #w(t, e, s) {
474
472
  if (t === "class" || t === "style")
475
- throw new E(`"${t}" is a reserved property`);
476
- const o = p.getAttrName(t), i = this.hasAttribute(o);
473
+ throw new y(`"${t}" is a reserved property`);
474
+ const o = u.getAttrName(t), i = this.hasAttribute(o);
477
475
  e.required && !i && this.#e(this, o, "is a required attribute");
478
476
  let n = e.value;
479
477
  this.hasOwnProperty(t) && (n = this[t], delete this[t]);
@@ -484,16 +482,16 @@ class p extends ct {
484
482
  return this[f];
485
483
  },
486
484
  set(l) {
487
- e.computed && !this.#p.has(t) && this.#e(
485
+ e.computed && !this.#u.has(t) && this.#e(
488
486
  null,
489
487
  t,
490
488
  "is a computed property and cannot be set directly"
491
489
  ), c === Number && typeof l == "string" && (l = H(l));
492
490
  const h = this[f];
493
491
  if (l === h) return;
494
- this.#V(t, c, l), this[f] = l;
492
+ this.#W(t, c, l), this[f] = l;
495
493
  const m = this.#r.get(t);
496
- m && ot(m.state, m.stateProp, l), this.#_(t, c, l, o), this.#u || (this.#F(t), this.#v(t)), this.#I(t, l);
494
+ m && ot(m.state, m.stateProp, l), this.#_(t, c, l, o), this.#p || (this.#F(t), this.#v(t)), this.#I(t, l);
497
495
  const x = this.#d[t];
498
496
  x && this.setFormValue(x, String(l)), this.propertyChangedCallback(t, h, l), e.dispatch && this.dispatch("change", {
499
497
  tagName: this.localName,
@@ -507,7 +505,7 @@ class p extends ct {
507
505
  #E() {
508
506
  const t = this.hasAttribute("disabled"), e = R(this.shadowRoot);
509
507
  for (const s of e)
510
- pt(s) && (s.disabled = t);
508
+ ut(s) && (s.disabled = t);
511
509
  }
512
510
  disconnectedCallback() {
513
511
  for (const { state: t } of this.#r.values())
@@ -529,16 +527,16 @@ class p extends ct {
529
527
  return `display: ${t ? e : "none"}`;
530
528
  }
531
529
  #N(t) {
532
- const e = t instanceof p;
530
+ const e = t instanceof u;
533
531
  for (const s of t.getAttributeNames()) {
534
- const o = t.getAttribute(s), i = this.#A(t, o);
532
+ const o = t.getAttribute(s), i = this.#S(t, o);
535
533
  if (i) {
536
534
  const n = this[i];
537
535
  n === void 0 && this.#h(t, s, i);
538
536
  let [c, a] = s.split(":");
539
- const f = p.getPropName(c), l = this.#a(i);
537
+ const f = u.getPropName(c), l = this.#a(i);
540
538
  e && t.#a(f) || (t[f] = n), c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && !l && t.#g.set(
541
- p.getPropName(c),
539
+ u.getPropName(c),
542
540
  i
543
541
  );
544
542
  }
@@ -600,7 +598,7 @@ class p extends ct {
600
598
  o && (s = o.textContent?.trim() ?? "");
601
599
  }
602
600
  if (s) {
603
- const o = this.#A(t, s);
601
+ const o = this.#S(t, s);
604
602
  o && S(t) ? t.textContent = this[o] : this.#l(s, t);
605
603
  }
606
604
  }
@@ -650,11 +648,11 @@ class p extends ct {
650
648
  if (s.length !== 1) return;
651
649
  const [o] = s;
652
650
  if (!N.test(o)) return;
653
- const i = D(t) || S(t);
651
+ const i = B(t) || S(t);
654
652
  let [n, c] = (e ?? "").split(":");
655
653
  if (!(i && n === "value" || S(t))) return;
656
654
  c ? t["on" + c] === void 0 && this.#e(t, e, "refers to an unsupported event name") : c = "change";
657
- const f = M(o);
655
+ const f = A(o);
658
656
  t.addEventListener(c, (l) => {
659
657
  const { target: h } = l;
660
658
  if (!h) return;
@@ -677,7 +675,7 @@ class p extends ct {
677
675
  this.#N(s), s.firstElementChild || this.#j(s);
678
676
  }
679
677
  // formAssociated is only needed when the component is inside a form.
680
- #S() {
678
+ #A() {
681
679
  if (this.#t.formAssociated || this.closest("form") === null) return;
682
680
  const t = this.#t.name;
683
681
  this.#e(
@@ -687,15 +685,15 @@ class p extends ct {
687
685
  );
688
686
  }
689
687
  static get observedAttributes() {
690
- const t = Object.entries(this.properties || {}).filter(([e, s]) => !s.computed).map(([e]) => p.getAttrName(e));
688
+ const t = Object.entries(this.properties || {}).filter(([e, s]) => !s.computed).map(([e]) => u.getAttrName(e));
691
689
  return t.includes("disabled") || t.push("disabled"), t;
692
690
  }
693
691
  // Subclasses can override this to add functionality.
694
692
  propertyChangedCallback(t, e, s) {
695
693
  }
696
- #A(t, e) {
694
+ #S(t, e) {
697
695
  if (!e || !N.test(e)) return;
698
- const s = M(e);
696
+ const s = A(e);
699
697
  return this[s] === void 0 && this.#h(t, "", s), s;
700
698
  }
701
699
  #v(t) {
@@ -710,7 +708,7 @@ class p extends ct {
710
708
  }
711
709
  const c = s.match(j) || [];
712
710
  for (const a of c) {
713
- const f = M(a);
711
+ const f = A(a);
714
712
  this[f] === void 0 && this.#h(null, t, f), typeof this[f] != "function" && n(f, s);
715
713
  }
716
714
  if (o)
@@ -718,11 +716,11 @@ class p extends ct {
718
716
  n(a.trim(), s);
719
717
  }
720
718
  #f(t, e) {
721
- this.#p.add(t);
719
+ this.#u.add(t);
722
720
  try {
723
721
  this[t] = e;
724
722
  } finally {
725
- this.#p.delete(t);
723
+ this.#u.delete(t);
726
724
  }
727
725
  }
728
726
  // WARNING: Do not place untrusted JavaScript expressions
@@ -737,7 +735,7 @@ class p extends ct {
737
735
  }
738
736
  const i = this.#t;
739
737
  o.forEach((a) => {
740
- const f = M(a);
738
+ const f = A(a);
741
739
  if (typeof this[f] == "function") return;
742
740
  const l = i.propToExprsMap;
743
741
  let h = l.get(f);
@@ -765,11 +763,11 @@ class p extends ct {
765
763
  !this.#i || !I(e) || (this.#i.set(t, e), this.#b?.setFormValue(this.#i));
766
764
  }
767
765
  static ssr(t = {}) {
768
- throw new E('Import Wrec from "wrec/ssr" to use the ssr method.');
766
+ throw new y('Import Wrec from "wrec/ssr" to use the ssr method.');
769
767
  }
770
768
  #e(t, e, s) {
771
769
  const o = t instanceof HTMLElement ? t.localName : "CSS rule";
772
- throw new E(
770
+ throw new y(
773
771
  `component ${this.#t.elementName}` + (t ? `, element "${o}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
774
772
  );
775
773
  }
@@ -795,7 +793,7 @@ class p extends ct {
795
793
  if (i === Boolean) {
796
794
  if (e === "true") return !0;
797
795
  if (e === "false" || e === "null") return !1;
798
- const c = p.getAttrName(t);
796
+ const c = u.getAttrName(t);
799
797
  return e && e !== c && this.#e(
800
798
  null,
801
799
  t,
@@ -848,6 +846,38 @@ class p extends ct {
848
846
  const n = i;
849
847
  n[s] = e;
850
848
  }
849
+ // This adds expressions to the expressions arrays in propToExprsMap
850
+ // that contain calls to methods listed the usedBy array or each property.
851
+ #B() {
852
+ let t;
853
+ function e() {
854
+ t = /* @__PURE__ */ new Map();
855
+ const i = Array.from(this.#s.keys()), n = new RegExp(`this\\.(${M})\\s*\\(`, "g");
856
+ for (const c of i)
857
+ for (const a of c.matchAll(n)) {
858
+ const f = a[1];
859
+ let l = t.get(f);
860
+ l || (l = [], t.set(f, l)), l.includes(c) || l.push(c);
861
+ }
862
+ }
863
+ const { properties: s, propToExprsMap: o } = this.#t;
864
+ for (const [i, n] of Object.entries(s)) {
865
+ const { usedBy: c } = n;
866
+ if (!c) continue;
867
+ t || e.call(this);
868
+ let a = o.get(i);
869
+ a || (a = [], o.set(i, a));
870
+ for (const f of c) {
871
+ if (typeof this[f] != "function") {
872
+ const h = `property ${i} usedBy contains non-method ${f}`;
873
+ throw new y(h);
874
+ }
875
+ const l = t.get(f) || [];
876
+ for (const h of l)
877
+ a.includes(h) || a.push(h);
878
+ }
879
+ }
880
+ }
851
881
  /**
852
882
  * @param state - WrecState object
853
883
  * @param map - object whose keys are state properties and
@@ -859,7 +889,7 @@ class p extends ct {
859
889
  for (const s of Object.keys(t))
860
890
  e[s] = s;
861
891
  }
862
- this.#B(t, e);
892
+ this.#V(t, e);
863
893
  for (const [s, o] of Object.entries(e))
864
894
  if (this.#c(o)) {
865
895
  const i = q(t, s);
@@ -872,12 +902,12 @@ class p extends ct {
872
902
  for (const e of this.getAttributeNames())
873
903
  if (!rt.has(e) && !e.startsWith("on")) {
874
904
  if (e === "form-assoc") {
875
- this.#S();
905
+ this.#A();
876
906
  continue;
877
907
  }
878
- if (!t.has(p.getPropName(e))) {
908
+ if (!t.has(u.getPropName(e))) {
879
909
  if (e === "name") {
880
- this.#S();
910
+ this.#A();
881
911
  continue;
882
912
  }
883
913
  this.#e(null, e, "is not a supported attribute");
@@ -888,11 +918,11 @@ class p extends ct {
888
918
  const o = s.match(j);
889
919
  if (o)
890
920
  return o.forEach((i) => {
891
- const n = M(i);
921
+ const n = A(i);
892
922
  this[n] === void 0 && this.#h(t, e, n);
893
923
  }), o;
894
924
  }
895
- #B(t, e) {
925
+ #V(t, e) {
896
926
  for (const [s, o] of Object.entries(e)) {
897
927
  let i = q(t, s);
898
928
  i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#c(o) || this.#e(
@@ -904,7 +934,7 @@ class p extends ct {
904
934
  }
905
935
  // When type is an array, this can't validate the type of the array elements.
906
936
  // This is called by #defineProp.
907
- #V(t, e, s) {
937
+ #W(t, e, s) {
908
938
  const { values: o } = this.#t.properties[t];
909
939
  if (o) {
910
940
  let n;
@@ -977,7 +1007,7 @@ function Mt(r, ...t) {
977
1007
  return e;
978
1008
  }
979
1009
  export {
980
- p as Wrec,
1010
+ u as Wrec,
981
1011
  _ as WrecState,
982
1012
  Et as createElement,
983
1013
  Tt as css,
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.23.0",
5
+ "version": "0.23.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",