wrec 0.39.1 → 0.39.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,30 +98,60 @@ r && process.env.NODE_ENV === "development" && (window.WrecState = a);
98
98
  //#endregion
99
99
  //#region src/paths.ts
100
100
  function o(e, t) {
101
- let n = e;
102
- for (let e of t.split(".")) n = n[e];
103
- return n;
101
+ let n = c(t), r = e;
102
+ for (let e of n) {
103
+ if (!s(r)) return;
104
+ r = r[e];
105
+ }
106
+ return r;
107
+ }
108
+ function s(e) {
109
+ return typeof e == "object" && !!e;
110
+ }
111
+ function c(e) {
112
+ if (e = e.trim(), !e) throw Error("path cannot be empty");
113
+ let t = e.split(".");
114
+ if (t.some((e) => e.length === 0)) throw Error(`path "${e}" contains an empty segment`);
115
+ return t;
104
116
  }
105
- function s(e, t, n) {
106
- let r = t.split("."), i = r.length - 1, a = e;
107
- r.forEach((e, t) => {
108
- t === i ? a[e] = n : a = a[e];
117
+ function l(e, t, n) {
118
+ let r = c(t), i = r.length - 1, a = e;
119
+ r.forEach((e, o) => {
120
+ if (!s(a)) {
121
+ let e = r.slice(0, o).join(".");
122
+ throw Error(`cannot set path "${t}": "${e}" is not object-like`);
123
+ }
124
+ let c = a;
125
+ if (o === i) {
126
+ c[e] = n;
127
+ return;
128
+ }
129
+ let l = c[e];
130
+ if (l === void 0) {
131
+ let e = r.slice(0, o + 1).join(".");
132
+ throw Error(`cannot set path "${t}": missing "${e}"`);
133
+ }
134
+ if (!s(l)) {
135
+ let e = r.slice(0, o + 1).join(".");
136
+ throw Error(`cannot set path "${t}": "${e}" is not object-like`);
137
+ }
138
+ a = l;
109
139
  });
110
140
  }
111
141
  //#endregion
112
142
  //#region src/sanitize-xss.ts
113
- var c = new Set([
143
+ var u = new Set([
114
144
  "button",
115
145
  "input",
116
146
  "label",
117
147
  "option",
118
148
  "th"
119
- ]), l = "__WREC", u = "__";
120
- function d(t) {
149
+ ]), d = "__WREC", f = "__";
150
+ function p(t) {
121
151
  let n = {
122
152
  allowCommentTag: !0,
123
153
  onTag: (e, t) => {
124
- if (c.has(e)) return t;
154
+ if (u.has(e)) return t;
125
155
  },
126
156
  onTagAttr(e, t, n) {
127
157
  if (t.startsWith("on")) return "";
@@ -143,48 +173,48 @@ function d(t) {
143
173
  t = t.replace(/<!--[\s\S]*?-->/g, (e) => {
144
174
  let n = "";
145
175
  do
146
- n = l + r.length + u;
176
+ n = d + r.length + f;
147
177
  while (t.includes(n));
148
178
  return r.push(e), n;
149
179
  });
150
180
  let i = e(t, n);
151
181
  return r.forEach((e, t) => {
152
- let n = RegExp(`${l}${t}${u}`, "g");
182
+ let n = RegExp(`${d}${t}${f}`, "g");
153
183
  i = i.replace(n, e);
154
184
  }), i;
155
185
  }
156
186
  //#endregion
157
187
  //#region src/wrec.ts
158
- var f = () => /* @__PURE__ */ new Map(), p = new Set([
188
+ var m = () => /* @__PURE__ */ new Map(), h = new Set([
159
189
  "class",
160
190
  "disabled",
161
191
  "hidden",
162
192
  "id",
163
193
  "tabindex",
164
194
  "title"
165
- ]), m = globalThis.HTMLElement ?? class {}, h = globalThis.customElements ?? {
195
+ ]), g = globalThis.HTMLElement ?? class {}, _ = globalThis.customElements ?? {
166
196
  get: (e) => void 0,
167
197
  getName: (e) => null,
168
198
  define: () => {},
169
199
  initialize: (e) => {},
170
200
  upgrade: (e) => {},
171
201
  whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
172
- }, 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;
173
- function D(e) {
174
- return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof X;
202
+ }, v = class extends Error {}, y = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, b = "a-zA-Z_$", x = `[${b}][${b + "0-9"}]*`, S = RegExp(`this\\.(${x})\\s*\\(`, "g"), C = /<!--\s*(.*?)\s*-->/, w = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, T = RegExp(`^this\\.${x}$`), E = RegExp(`this\\.${x}(\\.${x})*`, "g"), D = RegExp(`this\\.${x}(\\.${x})*`), O = 5;
203
+ function k(e) {
204
+ return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof Q;
175
205
  }
176
- function O(e, t, n) {
206
+ function A(e, t, n) {
177
207
  let r = document.createElement(e);
178
208
  if (t) for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
179
209
  return n && (r.innerHTML = n), r;
180
210
  }
181
- 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;
182
- function j(e) {
211
+ var j = (e) => Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : M(e.type), M = (e) => e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
212
+ function N(e) {
183
213
  let t = [], n = e.firstElementChild;
184
- for (; n;) t.push(n), n.shadowRoot && t.push(...j(n.shadowRoot)), n.firstElementChild && t.push(...j(n)), n = n.nextElementSibling;
214
+ for (; n;) t.push(n), n.shadowRoot && t.push(...N(n.shadowRoot)), n.firstElementChild && t.push(...N(n)), n = n.nextElementSibling;
185
215
  return t;
186
216
  }
187
- function M(e, t) {
217
+ function P(e, t) {
188
218
  let n = e;
189
219
  for (; n;) {
190
220
  let e = Object.getOwnPropertyDescriptor(n, t);
@@ -192,73 +222,73 @@ function M(e, t) {
192
222
  n = Object.getPrototypeOf(n);
193
223
  }
194
224
  }
195
- var N = (e) => e.substring(E).split(".")[0];
196
- function P(e) {
225
+ var F = (e) => e.substring(O).split(".")[0];
226
+ function I(e) {
197
227
  return e.substring(4).trim();
198
228
  }
199
- function F(e, t) {
229
+ function L(e, t) {
200
230
  let n = e[0];
201
231
  return t.forEach((t, r) => {
202
232
  n += t + e[r + 1];
203
233
  }), n;
204
234
  }
205
- function I(e) {
235
+ function R(e) {
206
236
  return e instanceof HTMLInputElement && e.type === "checkbox";
207
237
  }
208
- function L(e) {
238
+ function z(e) {
209
239
  return e.startsWith("get ");
210
240
  }
211
- function R(e) {
241
+ function B(e) {
212
242
  let t = typeof e;
213
243
  return t === "string" || t === "number" || t === "boolean";
214
244
  }
215
- function z(e) {
245
+ function V(e) {
216
246
  return e instanceof HTMLInputElement && e.type === "radio";
217
247
  }
218
- function B(e) {
248
+ function H(e) {
219
249
  return e.localName === "textarea";
220
250
  }
221
- function V(e) {
251
+ function U(e) {
222
252
  let { localName: t } = e;
223
253
  return t === "input" || t === "select";
224
254
  }
225
- var H = (e) => `get ${e}`, U = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
226
- function W(e, t, n, r) {
255
+ var W = (e) => `get ${e}`, G = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
256
+ function K(e, t, n, r) {
227
257
  return e.slice(0, t) + r + e.slice(t + n);
228
258
  }
229
- function G(e) {
259
+ function q(e) {
230
260
  let t = Number(e);
231
- if (isNaN(t)) throw new g(`can't convert "${e}" to a number`);
261
+ if (isNaN(t)) throw new v(`can't convert "${e}" to a number`);
232
262
  return t;
233
263
  }
234
- function K(e, t, n) {
264
+ function J(e, t, n) {
235
265
  let [r] = t.split(":");
236
- if (r === "checked" && z(e) && typeof n == "string") {
266
+ if (r === "checked" && V(e) && typeof n == "string") {
237
267
  let t = e.value === n;
238
268
  t ? e.setAttribute(r, r) : e.removeAttribute(r), e.checked = t;
239
269
  return;
240
270
  }
241
- if (R(n)) if (typeof n == "boolean") {
271
+ if (B(n)) if (typeof n == "boolean") {
242
272
  n ? e.setAttribute(r, r) : e.removeAttribute(r);
243
- let t = X.getPropName(r);
273
+ let t = Q.getPropName(r);
244
274
  e[t] = n;
245
275
  } else {
246
276
  let i = e.getAttribute(t), a = String(n);
247
- i !== a && (e.setAttribute(r, a), r === "value" && V(e) && (e.value = a));
277
+ i !== a && (e.setAttribute(r, a), r === "value" && U(e) && (e.value = a));
248
278
  }
249
279
  else {
250
- let r = X.getPropName(t);
280
+ let r = Q.getPropName(t);
251
281
  e[r] = n;
252
282
  }
253
283
  }
254
- function q(e, t, n) {
284
+ function Y(e, t, n) {
255
285
  let [r] = t.split(":");
256
- e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (K(e, r, n), r === "value" && V(e) && e.value !== n && (e.value = n));
286
+ e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (J(e, r, n), r === "value" && U(e) && e.value !== n && (e.value = n));
257
287
  }
258
- var J = (e) => typeof e == "string" ? [e] : e;
259
- async function Y(e) {
288
+ var X = (e) => typeof e == "string" ? [e] : e;
289
+ async function Z(e) {
260
290
  let t = /* @__PURE__ */ new Set();
261
- for (let n of j(e.content)) {
291
+ for (let n of N(e.content)) {
262
292
  let { localName: e } = n;
263
293
  e.includes("-") && t.add(e);
264
294
  }
@@ -270,9 +300,9 @@ async function Y(e) {
270
300
  }, 1e3);
271
301
  });
272
302
  }
273
- return Promise.all([...t].map(async (e) => Promise.race([h.whenDefined(e), n(e)])));
303
+ return Promise.all([...t].map(async (e) => Promise.race([_.whenDefined(e), n(e)])));
274
304
  }
275
- var X = class e extends m {
305
+ var Q = class e extends g {
276
306
  static {
277
307
  this.attrToPropMap = /* @__PURE__ */ new Map();
278
308
  }
@@ -311,8 +341,8 @@ var X = class e extends m {
311
341
  #d = /* @__PURE__ */ new WeakSet();
312
342
  #f = /* @__PURE__ */ new Map();
313
343
  static define(e) {
314
- if (this.elementName = e, h.get(e)) throw new g(`custom element ${e} is already defined`);
315
- h.define(e, this);
344
+ if (this.elementName = e, _.get(e)) throw new v(`custom element ${e} is already defined`);
345
+ _.define(e, this);
316
346
  }
317
347
  constructor() {
318
348
  super(), this.attachShadow({ mode: "open" });
@@ -347,13 +377,13 @@ var X = class e extends m {
347
377
  }
348
378
  async #p() {
349
379
  let e = this.#n, { template: t } = e;
350
- t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await Y(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
380
+ t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await Z(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
351
381
  }
352
382
  static buildHTML() {
353
383
  let e = "<style>\n :host([hidden]) { display: none; }";
354
384
  this.css && (e += this.css), e += "</style>\n";
355
385
  let t = this.html.trim();
356
- if (!t) throw new g("static property html must be set");
386
+ if (!t) throw new v("static property html must be set");
357
387
  return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
358
388
  }
359
389
  changed(e, t, n) {
@@ -373,24 +403,24 @@ var X = class e extends m {
373
403
  this.#F();
374
404
  }
375
405
  #g(t, n, r) {
376
- if (t === "class" || t === "style") throw new g(`"${t}" is a reserved property`);
406
+ if (t === "class" || t === "style") throw new v(`"${t}" is a reserved property`);
377
407
  let i = e.getAttrName(t), a = this.hasAttribute(i);
378
408
  n.required && !a && this.#V(this, i, "is a required attribute");
379
409
  let o = n.value;
380
410
  this.hasOwnProperty(t) && (o = this.#T(t), this.#_(t));
381
- let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ?? k(n), u = "#" + t;
382
- this.#R(u, this.#j(t, c, l)), Object.defineProperty(this, t, {
411
+ let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ?? j(n), u = "#" + t;
412
+ this.#R(u, this.#j(t, s, c)), Object.defineProperty(this, t, {
383
413
  enumerable: !0,
384
414
  get() {
385
415
  return this.#T(u);
386
416
  },
387
417
  set(e) {
388
- n.computed && !this.#t.has(t) && this.#V(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = G(e));
418
+ n.computed && !this.#t.has(t) && this.#V(null, t, "is a computed property and cannot be set directly"), s === Number && typeof e == "string" && (e = q(e));
389
419
  let r = this.#T(u);
390
420
  if (e === r) return;
391
- this.#$(t, c, e), e = this.#j(t, c, e), this.#R(u, e);
421
+ this.#$(t, s, e), e = this.#j(t, s, e), this.#R(u, e);
392
422
  let a = this.#l.get(t);
393
- a && s(a.state, a.stateProp, e), this.#G(t, c, e, i), this.#e || (this.#K(t), this.#P(t)), this.#J(t, e);
423
+ a && l(a.state, a.stateProp, e), this.#G(t, s, e, i), this.#e || (this.#K(t), this.#P(t)), this.#J(t, e);
394
424
  let o = this.#i[t];
395
425
  o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
396
426
  tagName: this.localName,
@@ -405,8 +435,8 @@ var X = class e extends m {
405
435
  delete this[e];
406
436
  }
407
437
  #v() {
408
- let t = this.hasAttribute("disabled"), n = j(this.shadowRoot);
409
- for (let r of n) D(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
438
+ let t = this.hasAttribute("disabled"), n = N(this.shadowRoot);
439
+ for (let r of n) k(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
410
440
  }
411
441
  disconnectedCallback() {
412
442
  for (let { unsubscribe: e } of this.#f.values()) e();
@@ -437,10 +467,10 @@ var X = class e extends m {
437
467
  let [o, s] = r.split(":"), c = e.getPropName(o);
438
468
  if (o === "checked") {
439
469
  let { type: e } = this.#n.properties[a];
440
- I(t) && e !== Boolean && this.#V(t, r, `refers to property "${a}" whose type is not Boolean`), z(t) && e !== String && this.#V(t, r, `refers to property "${a}" whose type is not String`);
470
+ R(t) && e !== Boolean && this.#V(t, r, `refers to property "${a}" whose type is not Boolean`), V(t) && e !== String && this.#V(t, r, `refers to property "${a}" whose type is not String`);
441
471
  }
442
472
  let l = this.#A(a);
443
- n && t.#A(c) || (o === "checked" && z(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#V(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#T(a))) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
473
+ n && t.#A(c) || (o === "checked" && V(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#V(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#T(a))) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
444
474
  }
445
475
  this.#z(i, t, r);
446
476
  }
@@ -457,7 +487,7 @@ var X = class e extends m {
457
487
  if (t instanceof HTMLElement) this.#q(t, e);
458
488
  else if (!(t instanceof CSSStyleRule)) {
459
489
  let { element: n, attrName: r } = t;
460
- n instanceof CSSStyleRule ? n.style.setProperty(r, e) : q(n, r, e);
490
+ n instanceof CSSStyleRule ? n.style.setProperty(r, e) : Y(n, r, e);
461
491
  }
462
492
  }
463
493
  if (r.size > 0) {
@@ -483,9 +513,9 @@ var X = class e extends m {
483
513
  }
484
514
  } else {
485
515
  let t = "";
486
- if (B(e)) {
516
+ if (H(e)) {
487
517
  this.#z(e.textContent, e);
488
- let n = e.textContent?.match(x);
518
+ let n = e.textContent?.match(C);
489
519
  n && (t = n[1]);
490
520
  } else {
491
521
  let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
@@ -493,7 +523,7 @@ var X = class e extends m {
493
523
  }
494
524
  if (t) {
495
525
  let n = this.#N(e, t);
496
- n && B(e) ? e.textContent = this.#T(n) : this.#z(t, e);
526
+ n && H(e) ? e.textContent = this.#T(n) : this.#z(t, e);
497
527
  }
498
528
  }
499
529
  }
@@ -513,7 +543,7 @@ var X = class e extends m {
513
543
  this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
514
544
  for (let [e, n] of Object.entries(t)) {
515
545
  let t = this.#T(e);
516
- R(t) && this.setFormValue(n, String(t));
546
+ B(t) && this.setFormValue(n, String(t));
517
547
  }
518
548
  let r = Object.keys(this.#n.properties), i = this.#o;
519
549
  for (let e of r) i[e] = this.#T(e);
@@ -522,7 +552,7 @@ var X = class e extends m {
522
552
  let e = this.#o;
523
553
  for (let t of Object.keys(e)) {
524
554
  let n = e[t];
525
- C.test(n) && (n = this.#x(n)), this.#R(t, n);
555
+ T.test(n) && (n = this.#x(n)), this.#R(t, n);
526
556
  }
527
557
  }
528
558
  static getAttrName(e) {
@@ -532,7 +562,7 @@ var X = class e extends m {
532
562
  #C() {
533
563
  let e = this.#n, t = e.computedGraph;
534
564
  if (t) return t;
535
- let n = f(), r = f(), i = {};
565
+ let n = m(), r = m(), i = {};
536
566
  for (let t of e.registeredComputedProps) n.set(t, []);
537
567
  for (let [t, a] of e.propToComputedMap) for (let [o, s] of a) {
538
568
  if (i[o] = s, !e.registeredComputedProps.has(o) || (n.has(o) || n.set(o, []), !e.registeredComputedProps.has(t))) continue;
@@ -568,7 +598,7 @@ var X = class e extends m {
568
598
  l.set(e, t), t === 0 && s.push(e);
569
599
  }
570
600
  }
571
- if (c.length !== a.size) throw new g(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
601
+ if (c.length !== a.size) throw new v(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
572
602
  return c.map((e) => [e, r[e]]);
573
603
  }
574
604
  #T(e) {
@@ -580,21 +610,21 @@ var X = class e extends m {
580
610
  }
581
611
  #E(e, t, n) {
582
612
  let r = this.#T("#" + e), i = this.#l.get(e);
583
- i && s(i.state, i.stateProp, r), this.#e || (this.#K(e), this.#P(e)), this.#J(e, r), this.propertyChangedCallback(e, t, n);
613
+ i && l(i.state, i.stateProp, r), this.#e || (this.#K(e), this.#P(e)), this.#J(e, r), this.propertyChangedCallback(e, t, n);
584
614
  }
585
615
  #D(e, t, n) {
586
616
  if (n.length !== 1) return;
587
617
  let [r] = n;
588
- if (!C.test(r)) return;
589
- let i = I(e), a = z(e), o = V(e) || B(e), [s, c] = (t ?? "").split(":");
590
- if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || B(e))) return;
618
+ if (!T.test(r)) return;
619
+ let i = R(e), a = V(e), o = U(e) || H(e), [s, c] = (t ?? "").split(":");
620
+ if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || H(e))) return;
591
621
  c ? e["on" + c] === void 0 && this.#V(e, t, "refers to an unsupported event name") : c = "change";
592
- let l = N(r);
622
+ let l = F(r);
593
623
  e.addEventListener(c, (e) => {
594
624
  let { target: t } = e;
595
625
  if (!t) return;
596
626
  let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
597
- s === "checked" ? i ? this.#R(l, r.checked) : a && r.checked && this.#R(l, o) : this.#R(l, n === Number ? G(o) : o), this.#P(l);
627
+ s === "checked" ? i ? this.#R(l, r.checked) : a && r.checked && this.#R(l, o) : this.#R(l, n === Number ? q(o) : o), this.#P(l);
598
628
  });
599
629
  }
600
630
  #O(e) {
@@ -625,8 +655,8 @@ var X = class e extends m {
625
655
  }
626
656
  propertyChangedCallback(e, t, n) {}
627
657
  #N(e, t) {
628
- if (!t || !C.test(t)) return;
629
- let n = N(t);
658
+ if (!t || !T.test(t)) return;
659
+ let n = F(t);
630
660
  return this.#T(n) === void 0 && this.#H(e, "", n), n;
631
661
  }
632
662
  #P(e) {
@@ -650,17 +680,17 @@ var X = class e extends m {
650
680
  i || (i = [], r.set(t, i)), i.push([e, n]);
651
681
  }
652
682
  let a = t.computed;
653
- for (let t of a.matchAll(w)) {
654
- let r = N(t[0]);
683
+ for (let t of a.matchAll(E)) {
684
+ let r = F(t[0]);
655
685
  this.#T(r) === void 0 && this.#H(null, e, r);
656
- let o = H(r), s = !1;
657
- for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(o) && (i(e, a), s = !0);
686
+ let o = W(r), s = !1;
687
+ for (let [e, t] of Object.entries(n.properties)) X(t.usedBy)?.includes(o) && (i(e, a), s = !0);
658
688
  !s && typeof this.#T(r) != "function" && i(r, a);
659
689
  }
660
- for (let t of a.matchAll(b)) {
690
+ for (let t of a.matchAll(S)) {
661
691
  let r = t[1];
662
- if (typeof this.#T(r) != "function") throw new g(`property ${e} computed calls non-method ${r}`);
663
- for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(r) && i(e, a);
692
+ if (typeof this.#T(r) != "function") throw new v(`property ${e} computed calls non-method ${r}`);
693
+ for (let [e, t] of Object.entries(n.properties)) X(t.usedBy)?.includes(r) && i(e, a);
664
694
  }
665
695
  }
666
696
  #L(e, t) {
@@ -679,12 +709,12 @@ var X = class e extends m {
679
709
  let r = this.#Z(t, n, e);
680
710
  if (!r) {
681
711
  let r = e.replaceAll("this..", "this.");
682
- n ? q(t, n, r) : "textContent" in t && (t.textContent = r);
712
+ n ? Y(t, n, r) : "textContent" in t && (t.textContent = r);
683
713
  return;
684
714
  }
685
715
  let i = this.#n;
686
716
  r.forEach((t) => {
687
- let n = N(t);
717
+ let n = F(t);
688
718
  if (typeof this.#T(n) == "function") return;
689
719
  let r = i.propToExprsMap, a = r.get(n);
690
720
  a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
@@ -699,24 +729,24 @@ var X = class e extends m {
699
729
  attrName: n
700
730
  } : t), t instanceof HTMLElement && this.#D(t, n, r);
701
731
  let o = this.#x(e);
702
- n ? q(t, n, o) : this.#q(t, o);
732
+ n ? Y(t, n, o) : this.#q(t, o);
703
733
  }
704
734
  #B(e, t) {
705
735
  let n = t?.trim() ?? "", r = this.#n.properties[n];
706
- r || this.#H(e, "ref", n), r.type !== m && this.#V(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#T(n) && this.#V(e, "ref", `is a duplicate reference to the property "${n}"`), this.#R(n, e), e.removeAttribute("ref");
736
+ r || this.#H(e, "ref", n), r.type !== g && this.#V(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#T(n) && this.#V(e, "ref", `is a duplicate reference to the property "${n}"`), this.#R(n, e), e.removeAttribute("ref");
707
737
  }
708
738
  setAttributeSafe(e, t) {
709
739
  this.hasAttribute(e) || this.setAttribute(e, t);
710
740
  }
711
741
  setFormValue(e, t) {
712
- !this.#a || !R(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
742
+ !this.#a || !B(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
713
743
  }
714
744
  static ssr(e = {}) {
715
- throw new g("SSR is not available in the browser build.");
745
+ throw new v("SSR is not available in the browser build.");
716
746
  }
717
747
  #V(e, t, n) {
718
748
  let r = e instanceof HTMLElement ? e.localName : "CSS rule";
719
- throw new g(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
749
+ throw new v(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
720
750
  }
721
751
  #H(e, t, n) {
722
752
  this.#V(e, t, `refers to missing property "${n}"`);
@@ -725,9 +755,9 @@ var X = class e extends m {
725
755
  return this.#W(e, this.getAttribute(t));
726
756
  }
727
757
  #W(t, n) {
728
- if (n?.match(w)) return n;
758
+ if (n?.match(E)) return n;
729
759
  let r = this.#n.properties[t], { type: i, values: a } = r;
730
- if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
760
+ if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : j(r);
731
761
  if (i === String) {
732
762
  if (a && !a.includes(n)) {
733
763
  let e = a.map((e) => `"${e}"`).join(", ");
@@ -735,7 +765,7 @@ var X = class e extends m {
735
765
  }
736
766
  return n;
737
767
  }
738
- if (i === Number) return G(n);
768
+ if (i === Number) return q(n);
739
769
  if (i === Boolean) {
740
770
  if (n === "true") return !0;
741
771
  if (n === "false" || n === "null") return !1;
@@ -744,7 +774,7 @@ var X = class e extends m {
744
774
  }
745
775
  }
746
776
  #G(e, t, n, r) {
747
- R(n) && !this.#A(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#U(e, r)) && K(this, r || e, n);
777
+ B(n) && !this.#A(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#U(e, r)) && J(this, r || e, n);
748
778
  }
749
779
  #K(e) {
750
780
  for (let [t, n] of this.#w([e])) this.#L(t, this.#x(n));
@@ -756,9 +786,9 @@ var X = class e extends m {
756
786
  let r = typeof t;
757
787
  r !== "string" && r !== "number" && this.#V(e, void 0, " computed content is not a string or number");
758
788
  let i = String(t);
759
- if (e instanceof HTMLElement && B(e)) e.value !== i && (e.value = i);
789
+ if (e instanceof HTMLElement && H(e)) e.value !== i && (e.value = i);
760
790
  else if (n && r === "string" && i.trim().startsWith("<")) {
761
- let t = d(i);
791
+ let t = p(i);
762
792
  if (e.innerHTML === t) return;
763
793
  e.innerHTML = t, this.#te(e), this.#M(e);
764
794
  } else n && e.textContent !== i && (e.textContent = i);
@@ -778,25 +808,25 @@ var X = class e extends m {
778
808
  let r = e.get(t);
779
809
  r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
780
810
  }, n = () => {
781
- let n = f();
811
+ let n = m();
782
812
  e.methodToExprsMap = n;
783
813
  let r = Array.from(this.#r.keys());
784
814
  for (let e of r) {
785
- for (let r of e.matchAll(b)) t(n, r[1], e);
786
- for (let r of e.matchAll(w)) t(n, H(N(r[0])), e);
815
+ for (let r of e.matchAll(S)) t(n, r[1], e);
816
+ for (let r of e.matchAll(E)) t(n, W(F(r[0])), e);
787
817
  }
788
818
  }, { properties: r, propToExprsMap: i } = e;
789
819
  for (let [t, a] of Object.entries(r)) {
790
- let r = J(a.usedBy);
820
+ let r = X(a.usedBy);
791
821
  if (!r) continue;
792
822
  e.methodToExprsMap || n();
793
823
  let { methodToExprsMap: o } = e, s = i.get(t);
794
824
  s || (s = [], i.set(t, s));
795
825
  for (let e of r) {
796
- if (L(e)) {
797
- let n = P(e);
798
- if (typeof M(this, n)?.get != "function") throw new g(`property ${t} usedBy contains non-getter ${e}`);
799
- } else if (typeof this.#T(e) != "function") throw new g(`property ${t} usedBy contains non-method ${e}`);
826
+ if (z(e)) {
827
+ let n = I(e);
828
+ if (typeof P(this, n)?.get != "function") throw new v(`property ${t} usedBy contains non-getter ${e}`);
829
+ } else if (typeof this.#T(e) != "function") throw new v(`property ${t} usedBy contains non-method ${e}`);
800
830
  let n = o.get(e) || [];
801
831
  for (let e of n) s.includes(e) || s.push(e);
802
832
  }
@@ -838,7 +868,7 @@ var X = class e extends m {
838
868
  }
839
869
  #X() {
840
870
  let t = new Set(Object.keys(this.#n.properties));
841
- for (let n of this.getAttributeNames()) if (!p.has(n) && !n.startsWith("on") && n !== "ref") {
871
+ for (let n of this.getAttributeNames()) if (!h.has(n) && !n.startsWith("on") && n !== "ref") {
842
872
  if (n === "form-assoc") {
843
873
  this.#ee();
844
874
  continue;
@@ -853,9 +883,9 @@ var X = class e extends m {
853
883
  }
854
884
  }
855
885
  #Z(e, t, n) {
856
- let r = n.match(w);
886
+ let r = n.match(E);
857
887
  if (r) return r.forEach((n) => {
858
- let r = N(n);
888
+ let r = F(n);
859
889
  this.#T(r) === void 0 && this.#H(e, t, r);
860
890
  }), r;
861
891
  }
@@ -903,35 +933,35 @@ var X = class e extends m {
903
933
  }
904
934
  }
905
935
  };
906
- function Z(e, ...t) {
907
- let n = F(e, t);
936
+ function $(e, ...t) {
937
+ let n = L(e, t);
908
938
  for (;;) {
909
- let e = _.exec(n);
939
+ let e = y.exec(n);
910
940
  if (!e) break;
911
941
  let t = e[2];
912
- if (T.test(t)) {
942
+ if (D.test(t)) {
913
943
  let r = e[1];
914
944
  if (!r.startsWith("--")) {
915
945
  let i = `--${r}: ${t};
916
946
  ${r}: var(--${r})`;
917
- n = W(n, e.index, e[0].length, i);
947
+ n = K(n, e.index, e[0].length, i);
918
948
  }
919
949
  }
920
950
  }
921
951
  return n;
922
952
  }
923
- function Q(e, ...t) {
924
- let n = F(e, t);
953
+ function ee(e, ...t) {
954
+ let n = L(e, t);
925
955
  for (;;) {
926
- let e = S.exec(n);
956
+ let e = w.exec(n);
927
957
  if (!e || e[1] === "style") break;
928
- let t = U(e[2]);
929
- if (T.test(t)) {
958
+ let t = G(e[2]);
959
+ if (D.test(t)) {
930
960
  let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
931
- n = W(n, i, t.length, r);
961
+ n = K(n, i, t.length, r);
932
962
  }
933
963
  }
934
964
  return n;
935
965
  }
936
966
  //#endregion
937
- export { a, Q as i, O as n, Z as r, X as t };
967
+ export { a, ee as i, A as n, $ as r, Q as t };
@@ -1,4 +1,4 @@
1
- import { a as e, i as t, n, r, t as i } from "./wrec-s0eHVxHE.js";
1
+ import { a as e, i as t, n, r, t as i } from "./wrec-CtwG5h9M.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), e = null), t.exports), d = (e, t) => {
4
4
  let n = {};
@@ -9158,13 +9158,17 @@ var G, K, ve, q, J, ye = l((() => {
9158
9158
  return (0, s.default)(e, t);
9159
9159
  }
9160
9160
  e.parse = l, l.parse = s.default, l.HTMLElement = r.default, l.CommentNode = n.default, l.valid = c.default, l.Node = i.default, l.TextNode = a.default, l.NodeType = o.default;
9161
- })))(), Re = "a-zA-Z_$", ze = `[${Re}][${Re + "0-9"}]*`, Be = RegExp(`this\\.${ze}(\\.${ze})*`), Ve = 5, He = (e) => e.substring(Ve).split(".")[0];
9161
+ })))(), Re = "a-zA-Z_$", ze = `[${Re}][${Re + "0-9"}]*`, Be = RegExp(`this\\.${ze}(\\.${ze})*`), Ve = 5;
9162
+ function He(e) {
9163
+ return String(e).replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
9164
+ }
9165
+ var Ue = (e) => e.substring(Ve).split(".")[0];
9162
9166
  i.ssr = function(e = {}) {
9163
9167
  let t = "", n = Object.keys(e);
9164
9168
  n.sort();
9165
9169
  for (let r of n) {
9166
- let n = this.getAttrName(r);
9167
- t += ` ${n}="${e[r]}"`;
9170
+ let n = this.getAttrName(r), i = He(e[r]);
9171
+ t += ` ${n}="${i}"`;
9168
9172
  }
9169
9173
  let r = this.properties;
9170
9174
  for (let [t, n] of Object.entries(r)) if (e[t] === void 0) {
@@ -9178,7 +9182,7 @@ i.ssr = function(e = {}) {
9178
9182
  let { attributes: t } = e;
9179
9183
  for (let [n, a] of Object.entries(t)) if (Be.test(a)) {
9180
9184
  let t = i(a);
9181
- t === (r[He(n)]?.value ?? "") ? e.removeAttribute(n) : e.setAttribute(n, String(t));
9185
+ t === (r[Ue(n)]?.value ?? "") ? e.removeAttribute(n) : e.setAttribute(n, He(t));
9182
9186
  }
9183
9187
  let { childNodes: n } = e;
9184
9188
  n.forEach((e, t) => {
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-s0eHVxHE.js";
1
+ import { a as e, i as t, n, r, t as i } from "./wrec-CtwG5h9M.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 library that greatly simplifies building web components",
4
4
  "author": "R. Mark Volkmann",
5
- "version": "0.39.1",
5
+ "version": "0.39.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",