wrec 0.24.7 → 0.24.9

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.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var Tt = (c) => {
2
2
  throw TypeError(c);
3
3
  };
4
- var et = (c, a, t) => a.has(c) || Tt("Cannot " + t);
5
- var h = (c, a, t) => (et(c, a, "read from private field"), t ? t.call(c) : a.get(c)), y = (c, a, t) => a.has(c) ? Tt("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(c) : a.set(c, t), M = (c, a, t, e) => (et(c, a, "write to private field"), e ? e.call(c, t) : a.set(c, t), t), f = (c, a, t) => (et(c, a, "access private method"), t);
4
+ var st = (c, a, t) => a.has(c) || Tt("Cannot " + t);
5
+ var h = (c, a, t) => (st(c, a, "read from private field"), t ? t.call(c) : a.get(c)), y = (c, a, t) => a.has(c) ? Tt("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(c) : a.set(c, t), M = (c, a, t, e) => (st(c, a, "write to private field"), e ? e.call(c, t) : a.set(c, t), t), f = (c, a, t) => (st(c, a, "access private method"), t);
6
6
  import Mt from "xss";
7
7
  function Rt(c, a, t = "") {
8
8
  const e = /* @__PURE__ */ new WeakMap(), s = {
@@ -13,16 +13,16 @@ function Rt(c, a, t = "") {
13
13
  if (r === null || typeof r != "object") return r;
14
14
  const l = e.get(r);
15
15
  if (l) return l;
16
- const u = t ? `${t}.${n}` : n, p = Rt(r, a, u);
17
- return e.set(r, p), p;
16
+ const p = t ? `${t}.${n}` : n, u = Rt(r, a, p);
17
+ return e.set(r, u), u;
18
18
  },
19
19
  // Intercept property writes.
20
20
  set(o, n, r) {
21
21
  const l = Reflect.get(o, n);
22
22
  if (l !== r) {
23
23
  Reflect.set(o, n, r);
24
- const u = t ? `${t}.${n}` : n;
25
- a(u, l, r);
24
+ const p = t ? `${t}.${n}` : n;
25
+ a(p, l, r);
26
26
  }
27
27
  return !0;
28
28
  }
@@ -40,21 +40,21 @@ function Ot(c) {
40
40
  const Z = typeof window < "u" && typeof window.document < "u";
41
41
  let At = class extends Error {
42
42
  };
43
- var P, Q, A, K, U, x, tt, Nt;
43
+ var P, tt, A, X, U, x, et, Nt;
44
44
  const O = class O {
45
45
  constructor(a, t, e) {
46
- y(this, tt);
47
- y(this, Q, /* @__PURE__ */ Symbol("objectId"));
46
+ y(this, et);
47
+ y(this, tt, /* @__PURE__ */ Symbol("objectId"));
48
48
  // This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
49
49
  // because there is no way to iterate over the keys of a WeakMap.
50
50
  y(this, A, []);
51
- y(this, K);
51
+ y(this, X);
52
52
  y(this, U);
53
53
  y(this, x);
54
54
  if (!a) throw new At("name cannot be empty");
55
55
  if (h(O, P).has(a))
56
56
  throw new At(`WrecState with name "${a}" already exists`);
57
- if (M(this, K, a), M(this, U, t), M(this, x, Rt({}, f(this, tt, Nt).bind(this))), t && Z) {
57
+ if (M(this, X, a), M(this, U, t), M(this, x, Rt({}, f(this, et, Nt).bind(this))), t && Z) {
58
58
  const s = sessionStorage.getItem("wrec-state-" + a), o = s ? JSON.parse(s) : void 0;
59
59
  o && (e = o);
60
60
  }
@@ -106,12 +106,12 @@ const O = class O {
106
106
  }), h(this, x)[a] = t;
107
107
  }
108
108
  get id() {
109
- return h(this, Q);
109
+ return h(this, tt);
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:", h(this, K));
114
+ console.log("WrecState:", h(this, X));
115
115
  for (const [a, t] of Object.entries(h(this, x)))
116
116
  console.log(` ${a} = ${JSON.stringify(t)}`);
117
117
  }
@@ -119,7 +119,7 @@ const O = class O {
119
119
  M(this, A, h(this, A).filter((t) => t.listenerRef.deref() !== a));
120
120
  }
121
121
  };
122
- P = new WeakMap(), Q = new WeakMap(), A = new WeakMap(), K = new WeakMap(), U = new WeakMap(), x = new WeakMap(), tt = new WeakSet(), Nt = function(a, t, e) {
122
+ P = new WeakMap(), tt = new WeakMap(), A = new WeakMap(), X = new WeakMap(), U = new WeakMap(), x = new WeakMap(), et = new WeakSet(), Nt = function(a, t, e) {
123
123
  const s = /* @__PURE__ */ new Set();
124
124
  for (const o of h(this, A)) {
125
125
  const n = o.listenerRef.deref();
@@ -148,8 +148,8 @@ P = new WeakMap(), Q = new WeakMap(), A = new WeakMap(), K = new WeakMap(), U =
148
148
  sessionStorage.setItem("wrec-state-" + a, JSON.stringify(e));
149
149
  }
150
150
  });
151
- let rt = O;
152
- Z && process.env.NODE_ENV === "development" && (window.WrecState = rt);
151
+ let ct = O;
152
+ Z && process.env.NODE_ENV === "development" && (window.WrecState = ct);
153
153
  function St(c, a) {
154
154
  let t = c;
155
155
  for (const e of a.split("."))
@@ -207,7 +207,7 @@ const ee = /* @__PURE__ */ new Set([
207
207
  "tabindex",
208
208
  "title"
209
209
  ]), se = globalThis.HTMLElement ?? class {
210
- }, ct = globalThis.customElements ?? {
210
+ }, at = globalThis.customElements ?? {
211
211
  get: (c) => {
212
212
  },
213
213
  getName: () => "",
@@ -221,9 +221,9 @@ const ee = /* @__PURE__ */ new Set([
221
221
  };
222
222
  class v extends Error {
223
223
  }
224
- const oe = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, Lt = "a-zA-Z_$", ie = Lt + "0-9", I = `[${Lt}][${ie}]*`, Ct = new RegExp(`this\\.(${I})\\s*\\(`, "g"), ne = /<!--\s*(.*?)\s*-->/, re = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, st = new RegExp(`^this\\.${I}$`), ot = new RegExp(`this\\.${I}(\\.${I})*`, "g"), jt = new RegExp(`this\\.${I}(\\.${I})*`), ce = 5;
224
+ const oe = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, Lt = "a-zA-Z_$", ie = Lt + "0-9", I = `[${Lt}][${ie}]*`, Ct = new RegExp(`this\\.(${I})\\s*\\(`, "g"), ne = /<!--\s*(.*?)\s*-->/, re = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, ot = new RegExp(`^this\\.${I}$`), it = new RegExp(`this\\.${I}(\\.${I})*`, "g"), jt = new RegExp(`this\\.${I}(\\.${I})*`), ce = 5;
225
225
  function ae(c) {
226
- return c instanceof HTMLButtonElement || c instanceof HTMLFieldSetElement || c instanceof HTMLInputElement || c instanceof HTMLSelectElement || c instanceof HTMLTextAreaElement || c instanceof X;
226
+ return c instanceof HTMLButtonElement || c instanceof HTMLFieldSetElement || c instanceof HTMLInputElement || c instanceof HTMLSelectElement || c instanceof HTMLTextAreaElement || c instanceof K;
227
227
  }
228
228
  function me(c, a, t) {
229
229
  const e = document.createElement(c);
@@ -233,11 +233,11 @@ function me(c, a, t) {
233
233
  return t && (e.innerHTML = t), e;
234
234
  }
235
235
  const Pt = (c) => Array.isArray(c.values) && c.values.length > 0 ? c.values[0] : fe(c.type), fe = (c) => c === String ? "" : c === Number ? 0 : c === Boolean ? !1 : c === Array ? [] : c === Object ? {} : void 0;
236
- function G(c) {
236
+ function Q(c) {
237
237
  const a = [];
238
238
  let t = c.firstElementChild;
239
239
  for (; t; )
240
- a.push(t), t.shadowRoot && a.push(...G(t.shadowRoot)), t.firstElementChild && a.push(...G(t)), t = t.nextElementSibling;
240
+ a.push(t), t.shadowRoot && a.push(...Q(t.shadowRoot)), t.firstElementChild && a.push(...Q(t)), t = t.nextElementSibling;
241
241
  return a;
242
242
  }
243
243
  const D = (c) => c.substring(ce).split(".")[0];
@@ -247,7 +247,7 @@ function Ht(c, a) {
247
247
  t += e + c[s + 1];
248
248
  }), t;
249
249
  }
250
- function at(c) {
250
+ function Y(c) {
251
251
  const a = typeof c;
252
252
  return a === "string" || a === "number" || a === "boolean";
253
253
  }
@@ -262,35 +262,35 @@ const he = (c) => c.replace(/<!--[\s\S]*?-->/g, "");
262
262
  function kt(c, a, t, e) {
263
263
  return c.slice(0, a) + e + c.slice(a + t);
264
264
  }
265
- function it(c) {
265
+ function nt(c) {
266
266
  const a = Number(c);
267
267
  if (isNaN(a)) throw new v(`can't convert "${c}" to a number`);
268
268
  return a;
269
269
  }
270
270
  function Ft(c, a, t) {
271
271
  const [e, s] = a.split(":");
272
- if (at(t))
272
+ if (Y(t))
273
273
  if (typeof t == "boolean") {
274
274
  t ? c.setAttribute(e, e) : c.removeAttribute(e);
275
- const o = X.getPropName(e);
275
+ const o = K.getPropName(e);
276
276
  c[o] = t;
277
277
  } else {
278
278
  const o = c.getAttribute(a), n = String(t);
279
279
  o !== n && (c.setAttribute(e, n), e === "value" && Et(c) && (c.value = n));
280
280
  }
281
281
  else {
282
- const o = X.getPropName(a);
282
+ const o = K.getPropName(a);
283
283
  c[o] = t;
284
284
  }
285
285
  }
286
- function nt(c, a, t) {
286
+ function rt(c, a, t) {
287
287
  const [e, s] = a.split(":");
288
288
  c instanceof CSSStyleRule ? c.style.setProperty(e, t) : (Ft(c, e, t), e === "value" && Et(c) && (c.value = t));
289
289
  }
290
290
  const $t = (c) => typeof c == "string" ? [c] : c;
291
291
  async function le(c) {
292
292
  const a = /* @__PURE__ */ new Set();
293
- for (const e of G(c.content)) {
293
+ for (const e of Q(c.content)) {
294
294
  const { localName: s } = e;
295
295
  s.includes("-") && a.add(s);
296
296
  }
@@ -305,13 +305,13 @@ async function le(c) {
305
305
  return Promise.all(
306
306
  [...a].map(
307
307
  async (e) => Promise.race([
308
- ct.whenDefined(e),
308
+ at.whenDefined(e),
309
309
  t(e)
310
310
  ])
311
311
  )
312
312
  );
313
313
  }
314
- var N, L, m, T, j, C, H, k, F, $, i, It, Bt, Dt, ft, ht, _t, lt, S, Vt, Wt, R, V, W, pt, ut, dt, mt, zt, z, q, w, J, bt, yt, qt, Jt, gt, Xt, Kt, Ut, Y, Zt, Yt, wt;
314
+ var N, L, m, T, j, C, H, k, F, $, i, It, Bt, Dt, ft, ht, _t, lt, S, Vt, Wt, R, V, W, pt, ut, dt, mt, zt, z, q, w, J, bt, yt, qt, Jt, gt, Kt, Xt, Ut, G, Zt, Yt, wt;
315
315
  const g = class g extends se {
316
316
  constructor() {
317
317
  super();
@@ -352,9 +352,9 @@ const g = class g extends se {
352
352
  f(this, i, R).call(this, "attrToPropMap") || (t.attrToPropMap = /* @__PURE__ */ new Map()), f(this, i, R).call(this, "properties") || (t.properties = {}), f(this, i, R).call(this, "propToAttrMap") || (t.propToAttrMap = /* @__PURE__ */ new Map()), f(this, i, R).call(this, "propToComputedMap") || (t.propToComputedMap = /* @__PURE__ */ new Map()), f(this, i, R).call(this, "propToExprsMap") || (t.propToExprsMap = /* @__PURE__ */ new Map());
353
353
  }
354
354
  static define(t) {
355
- if (this.elementName = t, ct.get(t))
355
+ if (this.elementName = t, at.get(t))
356
356
  throw new v(`custom element ${t} is already defined`);
357
- ct.define(t, this);
357
+ at.define(t, this);
358
358
  }
359
359
  attributeChangedCallback(t, e, s) {
360
360
  t === "disabled" && f(this, i, ht).call(this);
@@ -371,30 +371,30 @@ const g = class g extends se {
371
371
  batchSet(t) {
372
372
  M(this, N, !0);
373
373
  const e = h(this, m).propToExprsMap, s = /* @__PURE__ */ new Set();
374
- for (const [l, u] of Object.entries(t)) {
375
- this[l] = u;
376
- const p = e.get(l) ?? [];
377
- for (const d of p)
374
+ for (const [l, p] of Object.entries(t)) {
375
+ this[l] = p;
376
+ const u = e.get(l) ?? [];
377
+ for (const d of u)
378
378
  s.add(d);
379
379
  }
380
380
  const o = h(this, m).propToComputedMap, n = /* @__PURE__ */ new Set(), r = {};
381
381
  for (const l of Object.keys(t)) {
382
- const u = o.get(l) || [];
383
- for (const [p, d] of u)
384
- n.add(p), r[p] = d;
382
+ const p = o.get(l) || [];
383
+ for (const [u, d] of p)
384
+ n.add(u), r[u] = d;
385
385
  }
386
386
  for (const l of n) {
387
- const u = r[l];
388
- f(this, i, z).call(this, l, f(this, i, S).call(this, u));
389
- const p = e.get(l) ?? [];
390
- for (const d of p)
387
+ const p = r[l];
388
+ f(this, i, z).call(this, l, f(this, i, S).call(this, p));
389
+ const u = e.get(l) ?? [];
390
+ for (const d of u)
391
391
  s.add(d);
392
392
  }
393
393
  for (; ; ) {
394
394
  let l = !1;
395
- for (const u of n) {
396
- const p = r[u], d = f(this, i, S).call(this, p), b = this[u];
397
- JSON.stringify(d) !== JSON.stringify(b) && (f(this, i, z).call(this, u, d), l = !0);
395
+ for (const p of n) {
396
+ const u = r[p], d = f(this, i, S).call(this, u), b = this[p];
397
+ JSON.stringify(d) !== JSON.stringify(b) && (f(this, i, z).call(this, p, d), l = !0);
398
398
  }
399
399
  if (!l) break;
400
400
  }
@@ -413,7 +413,7 @@ const g = class g extends se {
413
413
  this[e] = s;
414
414
  }
415
415
  async connectedCallback() {
416
- f(this, i, Ut).call(this), f(this, i, Dt).call(this), await f(this, i, It).call(this), this.hasAttribute("disabled") && f(this, i, ht).call(this), f(this, i, wt).call(this, this.shadowRoot), f(this, i, pt).call(this, this.shadowRoot), f(this, i, Kt).call(this), f(this, i, Bt).call(this);
416
+ f(this, i, Ut).call(this), f(this, i, Dt).call(this), await f(this, i, It).call(this), this.hasAttribute("disabled") && f(this, i, ht).call(this), f(this, i, wt).call(this, this.shadowRoot), f(this, i, pt).call(this, this.shadowRoot), f(this, i, Xt).call(this), f(this, i, Bt).call(this);
417
417
  }
418
418
  disconnectedCallback() {
419
419
  for (const { state: t } of h(this, $).values())
@@ -452,10 +452,14 @@ const g = class g extends se {
452
452
  }
453
453
  const e = {}, s = t.split(",");
454
454
  for (const r of s) {
455
- const [l, u] = r.split(":");
456
- e[l.trim()] = u.trim();
455
+ const [l, p] = r.split(":");
456
+ e[l.trim()] = p.trim();
457
457
  }
458
458
  M(this, j, e), M(this, C, new FormData()), M(this, k, this.attachInternals()), h(this, k).setFormValue(h(this, C));
459
+ for (const [r, l] of Object.entries(e)) {
460
+ const p = this[r];
461
+ Y(p) && this.setFormValue(l, String(p));
462
+ }
459
463
  const o = Object.keys(h(this, m).properties), n = h(this, H);
460
464
  for (const r of o)
461
465
  n[r] = this[r];
@@ -464,7 +468,7 @@ const g = class g extends se {
464
468
  const t = h(this, H);
465
469
  for (const e of Object.keys(t)) {
466
470
  let s = t[e];
467
- st.test(s) && (s = f(this, i, S).call(this, s)), this[e] = s;
471
+ ot.test(s) && (s = f(this, i, S).call(this, s)), this[e] = s;
468
472
  }
469
473
  }
470
474
  static getAttrName(t) {
@@ -488,7 +492,7 @@ const g = class g extends se {
488
492
  this.hasAttribute(t) || this.setAttribute(t, e);
489
493
  }
490
494
  setFormValue(t, e) {
491
- !h(this, C) || !at(e) || (h(this, C).set(t, e), h(this, k)?.setFormValue(h(this, C)));
495
+ !h(this, C) || !Y(e) || (h(this, C).set(t, e), h(this, k)?.setFormValue(h(this, C)));
492
496
  }
493
497
  static ssr(t = {}) {
494
498
  throw new v('Import Wrec from "wrec/ssr" to use the ssr method.');
@@ -534,19 +538,19 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
534
538
  e.required && !n && f(this, i, w).call(this, this, o, "is a required attribute");
535
539
  let r = e.value;
536
540
  this.hasOwnProperty(t) && (r = this[t], delete this[t]);
537
- const { type: l } = e, u = l === Boolean ? r || n : s.includes(o) && n ? f(this, i, bt).call(this, t, o) : r ?? Pt(e), p = "#" + t;
538
- this[p] = u, e.computed && f(this, i, zt).call(this, t, e), Object.defineProperty(this, t, {
541
+ const { type: l } = e, p = l === Boolean ? r || n : s.includes(o) && n ? f(this, i, bt).call(this, t, o) : r ?? Pt(e), u = "#" + t;
542
+ this[u] = p, e.computed && f(this, i, zt).call(this, t, e), Object.defineProperty(this, t, {
539
543
  enumerable: !0,
540
544
  get() {
541
- return this[p];
545
+ return this[u];
542
546
  },
543
547
  set(d) {
544
- e.computed && !h(this, L).has(t) && f(this, i, w).call(this, null, t, "is a computed property and cannot be set directly"), l === Number && typeof d == "string" && (d = it(d));
545
- const b = this[p];
548
+ e.computed && !h(this, L).has(t) && f(this, i, w).call(this, null, t, "is a computed property and cannot be set directly"), l === Number && typeof d == "string" && (d = nt(d));
549
+ const b = this[u];
546
550
  if (d === b) return;
547
- f(this, i, Yt).call(this, t, l, d), this[p] = d;
551
+ f(this, i, Yt).call(this, t, l, d), this[u] = d;
548
552
  const E = h(this, $).get(t);
549
- E && Gt(E.state, E.stateProp, d), f(this, i, qt).call(this, t, l, d, o), h(this, N) || (f(this, i, Jt).call(this, t), f(this, i, mt).call(this, t)), f(this, i, Xt).call(this, t, d);
553
+ E && Gt(E.state, E.stateProp, d), f(this, i, qt).call(this, t, l, d, o), h(this, N) || (f(this, i, Jt).call(this, t), f(this, i, mt).call(this, t)), f(this, i, Kt).call(this, t, d);
550
554
  const B = h(this, j)[t];
551
555
  B && this.setFormValue(B, String(d)), this.propertyChangedCallback(t, b, d), e.dispatch && this.dispatch("change", {
552
556
  tagName: this.localName,
@@ -557,7 +561,7 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
557
561
  }
558
562
  });
559
563
  }, ht = function() {
560
- const t = this.hasAttribute("disabled"), e = G(this.shadowRoot);
564
+ const t = this.hasAttribute("disabled"), e = Q(this.shadowRoot);
561
565
  for (const s of e)
562
566
  ae(s) && (s.disabled = t);
563
567
  }, _t = function(t) {
@@ -568,10 +572,10 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
568
572
  if (r) {
569
573
  const l = this[r];
570
574
  l === void 0 && f(this, i, J).call(this, t, o, r);
571
- let [u, p] = o.split(":");
572
- const d = g.getPropName(u), b = f(this, i, W).call(this, r);
573
- e && f(s = t, i, W).call(s, d) || (t[d] = l), u === "value" && (p ? (t["on" + p] === void 0 && f(this, i, w).call(this, t, o, "refers to an unsupported event name"), t.setAttribute(u, this[r])) : p = "change"), e && !b && h(t, F).set(
574
- g.getPropName(u),
575
+ let [p, u] = o.split(":");
576
+ const d = g.getPropName(p), b = f(this, i, W).call(this, r);
577
+ e && f(s = t, i, W).call(s, d) || (t[d] = l), p === "value" && (u ? (t["on" + u] === void 0 && f(this, i, w).call(this, t, o, "refers to an unsupported event name"), t.setAttribute(p, this[r])) : u = "change"), e && !b && h(t, F).set(
578
+ g.getPropName(p),
575
579
  r
576
580
  );
577
581
  }
@@ -589,8 +593,8 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
589
593
  if (r instanceof HTMLElement)
590
594
  f(this, i, gt).call(this, r, s);
591
595
  else if (!(r instanceof CSSStyleRule)) {
592
- const { element: u, attrName: p } = r;
593
- u instanceof CSSStyleRule ? u.style.setProperty(p, s) : nt(u, p, s);
596
+ const { element: p, attrName: u } = r;
597
+ p instanceof CSSStyleRule ? p.style.setProperty(u, s) : rt(p, u, s);
594
598
  }
595
599
  }
596
600
  if (n.size > 0) {
@@ -611,10 +615,10 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
611
615
  for (const r of n)
612
616
  if (r.constructor === CSSStyleRule) {
613
617
  const l = Array.from(r.style);
614
- for (const u of l)
615
- if (u.startsWith("--")) {
616
- const p = r.style.getPropertyValue(u);
617
- f(this, i, q).call(this, p, r, u);
618
+ for (const p of l)
619
+ if (p.startsWith("--")) {
620
+ const u = r.style.getPropertyValue(p);
621
+ f(this, i, q).call(this, u, r, p);
618
622
  }
619
623
  }
620
624
  } else {
@@ -637,17 +641,17 @@ N = new WeakMap(), L = new WeakMap(), m = new WeakMap(), T = new WeakMap(), j =
637
641
  }, Wt = function(t, e, s) {
638
642
  if (s.length !== 1) return;
639
643
  const [o] = s;
640
- if (!st.test(o)) return;
644
+ if (!ot.test(o)) return;
641
645
  const n = Et(t) || _(t);
642
646
  let [r, l] = (e ?? "").split(":");
643
647
  if (!(n && r === "value" || _(t))) return;
644
648
  l ? t["on" + l] === void 0 && f(this, i, w).call(this, t, e, "refers to an unsupported event name") : l = "change";
645
- const p = D(o);
649
+ const u = D(o);
646
650
  t.addEventListener(l, (d) => {
647
651
  const { target: b } = d;
648
652
  if (!b) return;
649
- const E = b.value, { type: B } = h(this, m).properties[p];
650
- this[p] = B === Number ? it(E) : E, f(this, i, mt).call(this, p);
653
+ const E = b.value, { type: B } = h(this, m).properties[u];
654
+ this[u] = B === Number ? nt(E) : E, f(this, i, mt).call(this, u);
651
655
  });
652
656
  }, R = function(t) {
653
657
  return Object.hasOwn(h(this, m), t);
@@ -665,7 +669,7 @@ ut = function() {
665
669
  const t = h(this, m).name;
666
670
  f(this, i, w).call(this, this, void 0, `inside form, class ${t} requires "static formAssociated = true;"`);
667
671
  }, dt = function(t, e) {
668
- if (!e || !st.test(e)) return;
672
+ if (!e || !ot.test(e)) return;
669
673
  const s = D(e);
670
674
  return this[s] === void 0 && f(this, i, J).call(this, t, "", s), s;
671
675
  }, mt = function(t) {
@@ -673,23 +677,23 @@ ut = function() {
673
677
  f(this, i, lt).call(this, e);
674
678
  }, zt = function(t, e) {
675
679
  const s = h(this, m), o = s.propToComputedMap;
676
- function n(u, p) {
677
- let d = o.get(u);
678
- d || (d = [], o.set(u, d)), d.push([t, p]);
679
- }
680
- const { computed: r } = e, l = r.match(ot) || [];
681
- for (const u of l) {
682
- const p = D(u);
683
- this[p] === void 0 && f(this, i, J).call(this, null, t, p), typeof this[p] != "function" && n(p, r);
684
- }
685
- for (const u of r.matchAll(Ct)) {
686
- const p = u[1];
687
- if (typeof this[p] != "function")
680
+ function n(p, u) {
681
+ let d = o.get(p);
682
+ d || (d = [], o.set(p, d)), d.push([t, u]);
683
+ }
684
+ const { computed: r } = e, l = r.match(it) || [];
685
+ for (const p of l) {
686
+ const u = D(p);
687
+ this[u] === void 0 && f(this, i, J).call(this, null, t, u), typeof this[u] != "function" && n(u, r);
688
+ }
689
+ for (const p of r.matchAll(Ct)) {
690
+ const u = p[1];
691
+ if (typeof this[u] != "function")
688
692
  throw new v(
689
- `property ${t} computed calls non-method ${p}`
693
+ `property ${t} computed calls non-method ${u}`
690
694
  );
691
695
  for (const [d, b] of Object.entries(s.properties))
692
- $t(b.usedBy)?.includes(p) && n(d, r);
696
+ $t(b.usedBy)?.includes(u) && n(d, r);
693
697
  }
694
698
  }, z = function(t, e) {
695
699
  h(this, L).add(t);
@@ -702,32 +706,32 @@ ut = function() {
702
706
  // in attribute values or the text content of elements!
703
707
  q = function(t, e, s = void 0) {
704
708
  if (!t) return;
705
- const o = f(this, i, Y).call(this, e, s, t);
709
+ const o = f(this, i, G).call(this, e, s, t);
706
710
  if (!o) {
707
- const u = t.replaceAll("this..", "this.");
708
- s ? nt(e, s, u) : "textContent" in e && (e.textContent = u);
711
+ const p = t.replaceAll("this..", "this.");
712
+ s ? rt(e, s, p) : "textContent" in e && (e.textContent = p);
709
713
  return;
710
714
  }
711
715
  const n = h(this, m);
712
- o.forEach((u) => {
713
- const p = D(u);
714
- if (typeof this[p] == "function") return;
716
+ o.forEach((p) => {
717
+ const u = D(p);
718
+ if (typeof this[u] == "function") return;
715
719
  const d = n.propToExprsMap;
716
- let b = d.get(p);
717
- b || (b = [], d.set(p, b)), b.includes(t) || b.push(t);
720
+ let b = d.get(u);
721
+ b || (b = [], d.set(u, b)), b.includes(t) || b.push(t);
718
722
  });
719
- for (const [u, p] of h(this, T).entries())
720
- for (const d of p) {
723
+ for (const [p, u] of h(this, T).entries())
724
+ for (const d of u) {
721
725
  const b = d instanceof HTMLElement || d instanceof CSSStyleRule ? d : d.element;
722
726
  b instanceof CSSStyleRule || b.isConnected || h(this, T).set(
723
- u,
724
- p.filter((E) => E !== d)
727
+ p,
728
+ u.filter((E) => E !== d)
725
729
  );
726
730
  }
727
731
  let r = h(this, T).get(t);
728
732
  r || (r = [], h(this, T).set(t, r)), r.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && f(this, i, Wt).call(this, e, s, o);
729
733
  const l = f(this, i, S).call(this, t);
730
- s ? nt(e, s, l) : f(this, i, gt).call(this, e, l);
734
+ s ? rt(e, s, l) : f(this, i, gt).call(this, e, l);
731
735
  }, w = function(t, e, s) {
732
736
  const o = t instanceof HTMLElement ? t.localName : "CSS rule";
733
737
  throw new v(
@@ -738,18 +742,18 @@ q = function(t, e, s = void 0) {
738
742
  }, bt = function(t, e) {
739
743
  return f(this, i, yt).call(this, t, this.getAttribute(e));
740
744
  }, yt = function(t, e) {
741
- if (e?.match(ot)) return e;
745
+ if (e?.match(it)) return e;
742
746
  const o = h(this, m).properties[t], { type: n, values: r } = o;
743
747
  if (n || f(this, i, w).call(this, null, t, "does not specify its type"), e === null)
744
748
  return n === Boolean ? !1 : Pt(o);
745
749
  if (n === String) {
746
750
  if (r && !r.includes(e)) {
747
- const l = r.map((u) => `"${u}"`).join(", ");
751
+ const l = r.map((p) => `"${p}"`).join(", ");
748
752
  f(this, i, w).call(this, null, t, `must be one of ${l}`);
749
753
  }
750
754
  return e;
751
755
  }
752
- if (n === Number) return it(e);
756
+ if (n === Number) return nt(e);
753
757
  if (n === Boolean) {
754
758
  if (e === "true") return !0;
755
759
  if (e === "false" || e === "null") return !1;
@@ -759,7 +763,7 @@ q = function(t, e, s = void 0) {
759
763
  }, // Updates the matching attribute for a property.
760
764
  // VS Code thinks this is never called, but it is called by #defineProp.
761
765
  qt = function(t, e, s, o) {
762
- if (at(s) && !f(this, i, W).call(this, t)) {
766
+ if (Y(s) && !f(this, i, W).call(this, t)) {
763
767
  const n = e === Boolean ? this.hasAttribute(o) : f(this, i, bt).call(this, t, o);
764
768
  s !== n && Ft(this, o || t, s);
765
769
  }
@@ -784,7 +788,7 @@ Jt = function(t) {
784
788
  } else s && (t.textContent = n);
785
789
  }, // Update corresponding parent web component property if bound to one.
786
790
  // VS Code thinks this is never called, but it is called by #defineProp.
787
- Xt = function(t, e) {
791
+ Kt = function(t, e) {
788
792
  const s = h(this, F).get(t);
789
793
  if (!s) return;
790
794
  const o = this.getRootNode();
@@ -795,17 +799,17 @@ Xt = function(t, e) {
795
799
  r[s] = e;
796
800
  }, // This adds expressions to the expressions arrays in propToExprsMap
797
801
  // that contain calls to methods listed the usedBy array or each property.
798
- Kt = function() {
802
+ Xt = function() {
799
803
  const t = h(this, m);
800
804
  function e() {
801
805
  const n = /* @__PURE__ */ new Map();
802
806
  t.methodToExprsMap = n;
803
807
  const r = Array.from(h(this, T).keys());
804
808
  for (const l of r)
805
- for (const u of l.matchAll(Ct)) {
806
- const p = u[1];
807
- let d = n.get(p);
808
- d || (d = [], n.set(p, d)), d.includes(l) || d.push(l);
809
+ for (const p of l.matchAll(Ct)) {
810
+ const u = p[1];
811
+ let d = n.get(u);
812
+ d || (d = [], n.set(u, d)), d.includes(l) || d.push(l);
809
813
  }
810
814
  }
811
815
  const { properties: s, propToExprsMap: o } = t;
@@ -813,17 +817,17 @@ Kt = function() {
813
817
  const l = $t(r.usedBy);
814
818
  if (!l) continue;
815
819
  t.methodToExprsMap || e.call(this);
816
- const { methodToExprsMap: u } = t;
817
- let p = o.get(n);
818
- p || (p = [], o.set(n, p));
820
+ const { methodToExprsMap: p } = t;
821
+ let u = o.get(n);
822
+ u || (u = [], o.set(n, u));
819
823
  for (const d of l) {
820
824
  if (typeof this[d] != "function")
821
825
  throw new v(
822
826
  `property ${n} usedBy contains non-method ${d}`
823
827
  );
824
- const b = u.get(d) || [];
828
+ const b = p.get(d) || [];
825
829
  for (const E of b)
826
- p.includes(E) || p.push(E);
830
+ u.includes(E) || u.push(E);
827
831
  }
828
832
  }
829
833
  }, Ut = function() {
@@ -842,8 +846,8 @@ Kt = function() {
842
846
  f(this, i, w).call(this, null, e, "is not a supported attribute");
843
847
  }
844
848
  }
845
- }, Y = function(t, e, s) {
846
- const o = s.match(ot);
849
+ }, G = function(t, e, s) {
850
+ const o = s.match(it);
847
851
  if (o)
848
852
  return o.forEach((n) => {
849
853
  const r = D(n);
@@ -860,7 +864,7 @@ Yt = function(t, e, s) {
860
864
  const { values: o } = h(this, m).properties[t];
861
865
  if (o) {
862
866
  let r;
863
- e !== String ? r = "declares allowed values, but its type is not String" : typeof s != "string" ? r = `value is a ${typeof s}, but type is String` : o.includes(s) || (r = `must be one of ${o.map((u) => `"${u}"`).join(", ")}`), r && f(this, i, w).call(this, null, t, r);
867
+ e !== String ? r = "declares allowed values, but its type is not String" : typeof s != "string" ? r = `value is a ${typeof s}, but type is String` : o.includes(s) || (r = `must be one of ${o.map((p) => `"${p}"`).join(", ")}`), r && f(this, i, w).call(this, null, t, r);
864
868
  }
865
869
  if (s instanceof e) return;
866
870
  let n = typeof s;
@@ -878,17 +882,17 @@ Yt = function(t, e, s) {
878
882
  if (r.startsWith("on")) {
879
883
  let l = r.slice(2);
880
884
  l = l[0].toLowerCase() + l.slice(1).toLowerCase();
881
- const u = n.value;
882
- f(this, i, Y).call(this, s, r, u);
883
- let p;
884
- typeof this[u] == "function" ? p = (d) => this[u](d) : (f(this, i, Y).call(this, s, r, u), p = () => f(this, i, S).call(this, u)), s.addEventListener(l, p), o.push(r);
885
+ const p = n.value;
886
+ f(this, i, G).call(this, s, r, p);
887
+ let u;
888
+ typeof this[p] == "function" ? u = (d) => this[p](d) : (f(this, i, G).call(this, s, r, p), u = () => f(this, i, S).call(this, p)), s.addEventListener(l, u), o.push(r);
885
889
  }
886
890
  }
887
891
  for (const n of o)
888
892
  s.removeAttribute(n);
889
893
  }
890
894
  }, g.attrToPropMap = /* @__PURE__ */ new Map(), g.propToAttrMap = /* @__PURE__ */ new Map(), g.context = {}, g.css = "", g.elementName = "", g.formAssociated = !1, g.html = "", g.template = null;
891
- let X = g;
895
+ let K = g;
892
896
  function be(c, ...a) {
893
897
  let t = Ht(c, a);
894
898
  for (; ; ) {
@@ -920,8 +924,8 @@ function ye(c, ...a) {
920
924
  return t;
921
925
  }
922
926
  export {
923
- X as Wrec,
924
- rt as WrecState,
927
+ K as Wrec,
928
+ ct as WrecState,
925
929
  me as createElement,
926
930
  be as css,
927
931
  ye 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.24.7",
5
+ "version": "0.24.9",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/scripts/lint.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // - undefined properties accessed in expressions
5
5
  // - undefined instance methods called in expressions
6
6
  // - undefined context functions called in expressions
7
+ // - extra arguments passed to methods and context functions
7
8
  // - incompatible method arguments in expressions
8
9
  // - arithmetic type errors in expressions
9
10
  // - invalid computed property references and calls to non-method members
@@ -173,6 +174,17 @@ function analyzeExpression(
173
174
  .dotDotDotToken
174
175
  );
175
176
 
177
+ if (!isRest && node.arguments.length > parameters.length) {
178
+ node.arguments.slice(parameters.length).forEach((argument, index) => {
179
+ findings.extraArguments.push({
180
+ argument: toUserFacingExpression(argument.getText()),
181
+ argumentIndex: parameters.length + index + 1,
182
+ methodName: toUserFacingExpression(callee.getText()),
183
+ parameterCount: parameters.length
184
+ });
185
+ });
186
+ }
187
+
176
188
  node.arguments.forEach((argument, index) => {
177
189
  let parameterSymbol = parameters[index];
178
190
  let isRestArgument =
@@ -683,6 +695,7 @@ function formatReport(
683
695
  findings.undefinedProperties.length > 0 ||
684
696
  findings.undefinedContextFunctions.length > 0 ||
685
697
  findings.undefinedMethods.length > 0 ||
698
+ findings.extraArguments.length > 0 ||
686
699
  findings.incompatibleArguments.length > 0 ||
687
700
  findings.invalidEventHandlers.length > 0 ||
688
701
  findings.unsupportedHtmlAttributes.length > 0 ||
@@ -801,6 +814,15 @@ function formatReport(
801
814
  findings.invalidUseStateMaps.forEach(message => lines.push(` ${message}`));
802
815
  }
803
816
 
817
+ if (findings.extraArguments.length > 0) {
818
+ lines.push('extra arguments:');
819
+ findings.extraArguments.forEach(finding => {
820
+ lines.push(
821
+ ` ${finding.methodName}: argument ${finding.argumentIndex} "${finding.argument}" exceeds the ${finding.parameterCount}-parameter signature`
822
+ );
823
+ });
824
+ }
825
+
804
826
  if (findings.incompatibleArguments.length > 0) {
805
827
  lines.push('incompatible arguments:');
806
828
  findings.incompatibleArguments.forEach(finding => {
@@ -1177,6 +1199,7 @@ export function lintSource(filePath, sourceText, options = {}) {
1177
1199
  const allMethods = collectClassMethods(classNode);
1178
1200
  const findings = {
1179
1201
  duplicateProperties,
1202
+ extraArguments: [],
1180
1203
  incompatibleArguments: [],
1181
1204
  invalidComputedProperties: [],
1182
1205
  invalidDefaultValues: [],
@@ -1269,6 +1292,11 @@ export function lintSource(filePath, sourceText, options = {}) {
1269
1292
  });
1270
1293
 
1271
1294
  findings.duplicateProperties.sort();
1295
+ findings.extraArguments.sort(
1296
+ (a, b) =>
1297
+ a.methodName.localeCompare(b.methodName) ||
1298
+ a.argumentIndex - b.argumentIndex
1299
+ );
1272
1300
  findings.incompatibleArguments.sort(
1273
1301
  (a, b) =>
1274
1302
  a.methodName.localeCompare(b.methodName) ||