wrec 0.39.2 → 0.39.4
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-s0eHVxHE.js → wrec-1_q5NXuK.js} +223 -144
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.es.js +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ function t(e, n, r = "") {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
function n(e) {
|
|
21
|
-
let t = {};
|
|
21
|
+
let t = Array.isArray(e) ? [] : {};
|
|
22
22
|
for (let [r, i] of Object.entries(e)) t[r] = typeof i == "object" && i ? n(i) : i;
|
|
23
23
|
return t;
|
|
24
24
|
}
|
|
@@ -98,36 +98,83 @@ 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
|
|
103
|
-
|
|
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;
|
|
104
110
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
116
|
+
}
|
|
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
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
var u = "__WREC", d = "__", f = "[A-Za-z_$][A-Za-z0-9_$]*", p = new Set([
|
|
144
|
+
"checked",
|
|
145
|
+
"colspan",
|
|
146
|
+
"disabled",
|
|
147
|
+
"for",
|
|
148
|
+
"id",
|
|
149
|
+
"max",
|
|
150
|
+
"min",
|
|
151
|
+
"name",
|
|
152
|
+
"rowspan",
|
|
153
|
+
"scope",
|
|
154
|
+
"selected",
|
|
155
|
+
"type",
|
|
156
|
+
"value"
|
|
157
|
+
]);
|
|
158
|
+
function m(e, t) {
|
|
159
|
+
return `${u}${e}_${t}${d}`;
|
|
160
|
+
}
|
|
161
|
+
function h(e) {
|
|
162
|
+
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
163
|
+
}
|
|
164
|
+
function g(e) {
|
|
165
|
+
let t = e.trim();
|
|
166
|
+
return t ? RegExp(`^${f}$`).test(t) ? !0 : t.startsWith("this.") : !1;
|
|
167
|
+
}
|
|
168
|
+
function _(t) {
|
|
121
169
|
let n = {
|
|
122
170
|
allowCommentTag: !0,
|
|
123
|
-
onTag: (e, t) => {
|
|
124
|
-
if (c.has(e)) return t;
|
|
125
|
-
},
|
|
126
171
|
onTagAttr(e, t, n) {
|
|
127
|
-
if (t.startsWith("on")) return "";
|
|
172
|
+
if (t.startsWith("on")) return g(n) ? `${t}="${h(n)}"` : "";
|
|
173
|
+
if (t === "title" || t.startsWith("aria-") || t.startsWith("data-")) return `${t}="${h(n)}"`;
|
|
174
|
+
if (e === "a" && t === "href" && n.startsWith("javascript")) return "";
|
|
128
175
|
},
|
|
129
176
|
safeAttrValue(e, t, n) {
|
|
130
|
-
return t === "class" || e === "a" && t === "href"
|
|
177
|
+
return t === "class" || p.has(t) || e === "a" && t === "href" || e === "img" && t === "src" ? n : "";
|
|
131
178
|
},
|
|
132
179
|
stripIgnoreTagBody: [
|
|
133
180
|
"script",
|
|
@@ -136,55 +183,87 @@ function d(t) {
|
|
|
136
183
|
],
|
|
137
184
|
whiteList: {
|
|
138
185
|
...e.getDefaultWhiteList(),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
186
|
+
button: [
|
|
187
|
+
"class",
|
|
188
|
+
"id",
|
|
189
|
+
"type"
|
|
190
|
+
],
|
|
191
|
+
input: [
|
|
192
|
+
"checked",
|
|
193
|
+
"class",
|
|
194
|
+
"disabled",
|
|
195
|
+
"id",
|
|
196
|
+
"max",
|
|
197
|
+
"min",
|
|
198
|
+
"name",
|
|
199
|
+
"type",
|
|
200
|
+
"value"
|
|
201
|
+
],
|
|
202
|
+
label: [
|
|
203
|
+
"class",
|
|
204
|
+
"for",
|
|
205
|
+
"id"
|
|
206
|
+
],
|
|
207
|
+
option: [
|
|
208
|
+
"class",
|
|
209
|
+
"id",
|
|
210
|
+
"selected",
|
|
211
|
+
"value"
|
|
212
|
+
],
|
|
213
|
+
span: ["class", "id"],
|
|
214
|
+
th: [
|
|
215
|
+
"class",
|
|
216
|
+
"colspan",
|
|
217
|
+
"id",
|
|
218
|
+
"rowspan",
|
|
219
|
+
"scope"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}, r = [], i = Date.now() + Math.floor(Math.random() * 1e6);
|
|
143
223
|
t = t.replace(/<!--[\s\S]*?-->/g, (e) => {
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
224
|
+
let t = m(i, r.length);
|
|
225
|
+
return r.push({
|
|
226
|
+
comment: e,
|
|
227
|
+
token: t
|
|
228
|
+
}), t;
|
|
149
229
|
});
|
|
150
|
-
let
|
|
151
|
-
return r.forEach((e, t) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}), i;
|
|
230
|
+
let a = e(t, n);
|
|
231
|
+
return r.forEach(({ comment: e, token: t }) => {
|
|
232
|
+
a = a.replaceAll(t, e);
|
|
233
|
+
}), a;
|
|
155
234
|
}
|
|
156
235
|
//#endregion
|
|
157
236
|
//#region src/wrec.ts
|
|
158
|
-
var
|
|
237
|
+
var v = () => /* @__PURE__ */ new Map(), y = new Set([
|
|
159
238
|
"class",
|
|
160
239
|
"disabled",
|
|
161
240
|
"hidden",
|
|
162
241
|
"id",
|
|
163
242
|
"tabindex",
|
|
164
243
|
"title"
|
|
165
|
-
]),
|
|
244
|
+
]), b = globalThis.HTMLElement ?? class {}, x = globalThis.customElements ?? {
|
|
166
245
|
get: (e) => void 0,
|
|
167
246
|
getName: (e) => null,
|
|
168
247
|
define: () => {},
|
|
169
248
|
initialize: (e) => {},
|
|
170
249
|
upgrade: (e) => {},
|
|
171
250
|
whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
|
|
172
|
-
},
|
|
173
|
-
function
|
|
174
|
-
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof
|
|
251
|
+
}, S = class extends Error {}, ee = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, C = "a-zA-Z_$", w = `[${C}][${C + "0-9"}]*`, T = RegExp(`this\\.(${w})\\s*\\(`, "g"), E = /<!--\s*(.*?)\s*-->/, D = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, O = RegExp(`^this\\.${w}$`), k = RegExp(`this\\.${w}(\\.${w})*`, "g"), A = RegExp(`this\\.${w}(\\.${w})*`), j = 5;
|
|
252
|
+
function M(e) {
|
|
253
|
+
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof $;
|
|
175
254
|
}
|
|
176
|
-
function
|
|
255
|
+
function N(e, t, n) {
|
|
177
256
|
let r = document.createElement(e);
|
|
178
257
|
if (t) for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
179
258
|
return n && (r.innerHTML = n), r;
|
|
180
259
|
}
|
|
181
|
-
var
|
|
182
|
-
function
|
|
260
|
+
var P = (e) => Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : F(e.type), F = (e) => e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
261
|
+
function I(e) {
|
|
183
262
|
let t = [], n = e.firstElementChild;
|
|
184
|
-
for (; n;) t.push(n), n.shadowRoot && t.push(...
|
|
263
|
+
for (; n;) t.push(n), n.shadowRoot && t.push(...I(n.shadowRoot)), n.firstElementChild && t.push(...I(n)), n = n.nextElementSibling;
|
|
185
264
|
return t;
|
|
186
265
|
}
|
|
187
|
-
function
|
|
266
|
+
function te(e, t) {
|
|
188
267
|
let n = e;
|
|
189
268
|
for (; n;) {
|
|
190
269
|
let e = Object.getOwnPropertyDescriptor(n, t);
|
|
@@ -192,73 +271,73 @@ function M(e, t) {
|
|
|
192
271
|
n = Object.getPrototypeOf(n);
|
|
193
272
|
}
|
|
194
273
|
}
|
|
195
|
-
var
|
|
196
|
-
function
|
|
274
|
+
var L = (e) => e.substring(j).split(".")[0];
|
|
275
|
+
function R(e) {
|
|
197
276
|
return e.substring(4).trim();
|
|
198
277
|
}
|
|
199
|
-
function
|
|
278
|
+
function z(e, t) {
|
|
200
279
|
let n = e[0];
|
|
201
280
|
return t.forEach((t, r) => {
|
|
202
281
|
n += t + e[r + 1];
|
|
203
282
|
}), n;
|
|
204
283
|
}
|
|
205
|
-
function
|
|
284
|
+
function B(e) {
|
|
206
285
|
return e instanceof HTMLInputElement && e.type === "checkbox";
|
|
207
286
|
}
|
|
208
|
-
function
|
|
287
|
+
function V(e) {
|
|
209
288
|
return e.startsWith("get ");
|
|
210
289
|
}
|
|
211
|
-
function
|
|
290
|
+
function H(e) {
|
|
212
291
|
let t = typeof e;
|
|
213
292
|
return t === "string" || t === "number" || t === "boolean";
|
|
214
293
|
}
|
|
215
|
-
function
|
|
294
|
+
function U(e) {
|
|
216
295
|
return e instanceof HTMLInputElement && e.type === "radio";
|
|
217
296
|
}
|
|
218
|
-
function
|
|
297
|
+
function W(e) {
|
|
219
298
|
return e.localName === "textarea";
|
|
220
299
|
}
|
|
221
|
-
function
|
|
300
|
+
function G(e) {
|
|
222
301
|
let { localName: t } = e;
|
|
223
302
|
return t === "input" || t === "select";
|
|
224
303
|
}
|
|
225
|
-
var
|
|
226
|
-
function
|
|
304
|
+
var K = (e) => `get ${e}`, q = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
305
|
+
function J(e, t, n, r) {
|
|
227
306
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
228
307
|
}
|
|
229
|
-
function
|
|
308
|
+
function Y(e) {
|
|
230
309
|
let t = Number(e);
|
|
231
|
-
if (isNaN(t)) throw new
|
|
310
|
+
if (isNaN(t)) throw new S(`can't convert "${e}" to a number`);
|
|
232
311
|
return t;
|
|
233
312
|
}
|
|
234
|
-
function
|
|
313
|
+
function X(e, t, n) {
|
|
235
314
|
let [r] = t.split(":");
|
|
236
|
-
if (r === "checked" &&
|
|
315
|
+
if (r === "checked" && U(e) && typeof n == "string") {
|
|
237
316
|
let t = e.value === n;
|
|
238
317
|
t ? e.setAttribute(r, r) : e.removeAttribute(r), e.checked = t;
|
|
239
318
|
return;
|
|
240
319
|
}
|
|
241
|
-
if (
|
|
320
|
+
if (H(n)) if (typeof n == "boolean") {
|
|
242
321
|
n ? e.setAttribute(r, r) : e.removeAttribute(r);
|
|
243
|
-
let t =
|
|
322
|
+
let t = $.getPropName(r);
|
|
244
323
|
e[t] = n;
|
|
245
324
|
} else {
|
|
246
325
|
let i = e.getAttribute(t), a = String(n);
|
|
247
|
-
i !== a && (e.setAttribute(r, a), r === "value" &&
|
|
326
|
+
i !== a && (e.setAttribute(r, a), r === "value" && G(e) && (e.value = a));
|
|
248
327
|
}
|
|
249
328
|
else {
|
|
250
|
-
let r =
|
|
329
|
+
let r = $.getPropName(t);
|
|
251
330
|
e[r] = n;
|
|
252
331
|
}
|
|
253
332
|
}
|
|
254
|
-
function
|
|
333
|
+
function Z(e, t, n) {
|
|
255
334
|
let [r] = t.split(":");
|
|
256
|
-
e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (
|
|
335
|
+
e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (X(e, r, n), r === "value" && G(e) && e.value !== n && (e.value = n));
|
|
257
336
|
}
|
|
258
|
-
var
|
|
259
|
-
async function
|
|
337
|
+
var Q = (e) => typeof e == "string" ? [e] : e;
|
|
338
|
+
async function ne(e) {
|
|
260
339
|
let t = /* @__PURE__ */ new Set();
|
|
261
|
-
for (let n of
|
|
340
|
+
for (let n of I(e.content)) {
|
|
262
341
|
let { localName: e } = n;
|
|
263
342
|
e.includes("-") && t.add(e);
|
|
264
343
|
}
|
|
@@ -270,9 +349,9 @@ async function Y(e) {
|
|
|
270
349
|
}, 1e3);
|
|
271
350
|
});
|
|
272
351
|
}
|
|
273
|
-
return Promise.all([...t].map(async (e) => Promise.race([
|
|
352
|
+
return Promise.all([...t].map(async (e) => Promise.race([x.whenDefined(e), n(e)])));
|
|
274
353
|
}
|
|
275
|
-
var
|
|
354
|
+
var $ = class e extends b {
|
|
276
355
|
static {
|
|
277
356
|
this.attrToPropMap = /* @__PURE__ */ new Map();
|
|
278
357
|
}
|
|
@@ -311,8 +390,8 @@ var X = class e extends m {
|
|
|
311
390
|
#d = /* @__PURE__ */ new WeakSet();
|
|
312
391
|
#f = /* @__PURE__ */ new Map();
|
|
313
392
|
static define(e) {
|
|
314
|
-
if (this.elementName = e,
|
|
315
|
-
|
|
393
|
+
if (this.elementName = e, x.get(e)) throw new S(`custom element ${e} is already defined`);
|
|
394
|
+
x.define(e, this);
|
|
316
395
|
}
|
|
317
396
|
constructor() {
|
|
318
397
|
super(), this.attachShadow({ mode: "open" });
|
|
@@ -347,13 +426,13 @@ var X = class e extends m {
|
|
|
347
426
|
}
|
|
348
427
|
async #p() {
|
|
349
428
|
let e = this.#n, { template: t } = e;
|
|
350
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
429
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await ne(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
351
430
|
}
|
|
352
431
|
static buildHTML() {
|
|
353
432
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
354
433
|
this.css && (e += this.css), e += "</style>\n";
|
|
355
434
|
let t = this.html.trim();
|
|
356
|
-
if (!t) throw new
|
|
435
|
+
if (!t) throw new S("static property html must be set");
|
|
357
436
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
358
437
|
}
|
|
359
438
|
changed(e, t, n) {
|
|
@@ -373,24 +452,24 @@ var X = class e extends m {
|
|
|
373
452
|
this.#F();
|
|
374
453
|
}
|
|
375
454
|
#g(t, n, r) {
|
|
376
|
-
if (t === "class" || t === "style") throw new
|
|
455
|
+
if (t === "class" || t === "style") throw new S(`"${t}" is a reserved property`);
|
|
377
456
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
378
457
|
n.required && !a && this.#V(this, i, "is a required attribute");
|
|
379
458
|
let o = n.value;
|
|
380
459
|
this.hasOwnProperty(t) && (o = this.#T(t), this.#_(t));
|
|
381
|
-
let { type:
|
|
382
|
-
this.#R(u, this.#j(t,
|
|
460
|
+
let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ?? P(n), u = "#" + t;
|
|
461
|
+
this.#R(u, this.#j(t, s, c)), Object.defineProperty(this, t, {
|
|
383
462
|
enumerable: !0,
|
|
384
463
|
get() {
|
|
385
464
|
return this.#T(u);
|
|
386
465
|
},
|
|
387
466
|
set(e) {
|
|
388
|
-
n.computed && !this.#t.has(t) && this.#V(null, t, "is a computed property and cannot be set directly"),
|
|
467
|
+
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 = Y(e));
|
|
389
468
|
let r = this.#T(u);
|
|
390
469
|
if (e === r) return;
|
|
391
|
-
this.#$(t,
|
|
470
|
+
this.#$(t, s, e), e = this.#j(t, s, e), this.#R(u, e);
|
|
392
471
|
let a = this.#l.get(t);
|
|
393
|
-
a &&
|
|
472
|
+
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
473
|
let o = this.#i[t];
|
|
395
474
|
o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
|
|
396
475
|
tagName: this.localName,
|
|
@@ -405,8 +484,8 @@ var X = class e extends m {
|
|
|
405
484
|
delete this[e];
|
|
406
485
|
}
|
|
407
486
|
#v() {
|
|
408
|
-
let t = this.hasAttribute("disabled"), n =
|
|
409
|
-
for (let r of n)
|
|
487
|
+
let t = this.hasAttribute("disabled"), n = I(this.shadowRoot);
|
|
488
|
+
for (let r of n) M(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
|
|
410
489
|
}
|
|
411
490
|
disconnectedCallback() {
|
|
412
491
|
for (let { unsubscribe: e } of this.#f.values()) e();
|
|
@@ -437,10 +516,10 @@ var X = class e extends m {
|
|
|
437
516
|
let [o, s] = r.split(":"), c = e.getPropName(o);
|
|
438
517
|
if (o === "checked") {
|
|
439
518
|
let { type: e } = this.#n.properties[a];
|
|
440
|
-
|
|
519
|
+
B(t) && e !== Boolean && this.#V(t, r, `refers to property "${a}" whose type is not Boolean`), U(t) && e !== String && this.#V(t, r, `refers to property "${a}" whose type is not String`);
|
|
441
520
|
}
|
|
442
521
|
let l = this.#A(a);
|
|
443
|
-
n && t.#A(c) || (o === "checked" &&
|
|
522
|
+
n && t.#A(c) || (o === "checked" && U(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
523
|
}
|
|
445
524
|
this.#z(i, t, r);
|
|
446
525
|
}
|
|
@@ -457,7 +536,7 @@ var X = class e extends m {
|
|
|
457
536
|
if (t instanceof HTMLElement) this.#q(t, e);
|
|
458
537
|
else if (!(t instanceof CSSStyleRule)) {
|
|
459
538
|
let { element: n, attrName: r } = t;
|
|
460
|
-
n instanceof CSSStyleRule ? n.style.setProperty(r, e) :
|
|
539
|
+
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : Z(n, r, e);
|
|
461
540
|
}
|
|
462
541
|
}
|
|
463
542
|
if (r.size > 0) {
|
|
@@ -483,9 +562,9 @@ var X = class e extends m {
|
|
|
483
562
|
}
|
|
484
563
|
} else {
|
|
485
564
|
let t = "";
|
|
486
|
-
if (
|
|
565
|
+
if (W(e)) {
|
|
487
566
|
this.#z(e.textContent, e);
|
|
488
|
-
let n = e.textContent?.match(
|
|
567
|
+
let n = e.textContent?.match(E);
|
|
489
568
|
n && (t = n[1]);
|
|
490
569
|
} else {
|
|
491
570
|
let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
|
|
@@ -493,7 +572,7 @@ var X = class e extends m {
|
|
|
493
572
|
}
|
|
494
573
|
if (t) {
|
|
495
574
|
let n = this.#N(e, t);
|
|
496
|
-
n &&
|
|
575
|
+
n && W(e) ? e.textContent = this.#T(n) : this.#z(t, e);
|
|
497
576
|
}
|
|
498
577
|
}
|
|
499
578
|
}
|
|
@@ -513,7 +592,7 @@ var X = class e extends m {
|
|
|
513
592
|
this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
|
|
514
593
|
for (let [e, n] of Object.entries(t)) {
|
|
515
594
|
let t = this.#T(e);
|
|
516
|
-
|
|
595
|
+
H(t) && this.setFormValue(n, String(t));
|
|
517
596
|
}
|
|
518
597
|
let r = Object.keys(this.#n.properties), i = this.#o;
|
|
519
598
|
for (let e of r) i[e] = this.#T(e);
|
|
@@ -522,7 +601,7 @@ var X = class e extends m {
|
|
|
522
601
|
let e = this.#o;
|
|
523
602
|
for (let t of Object.keys(e)) {
|
|
524
603
|
let n = e[t];
|
|
525
|
-
|
|
604
|
+
O.test(n) && (n = this.#x(n)), this.#R(t, n);
|
|
526
605
|
}
|
|
527
606
|
}
|
|
528
607
|
static getAttrName(e) {
|
|
@@ -532,7 +611,7 @@ var X = class e extends m {
|
|
|
532
611
|
#C() {
|
|
533
612
|
let e = this.#n, t = e.computedGraph;
|
|
534
613
|
if (t) return t;
|
|
535
|
-
let n =
|
|
614
|
+
let n = v(), r = v(), i = {};
|
|
536
615
|
for (let t of e.registeredComputedProps) n.set(t, []);
|
|
537
616
|
for (let [t, a] of e.propToComputedMap) for (let [o, s] of a) {
|
|
538
617
|
if (i[o] = s, !e.registeredComputedProps.has(o) || (n.has(o) || n.set(o, []), !e.registeredComputedProps.has(t))) continue;
|
|
@@ -568,7 +647,7 @@ var X = class e extends m {
|
|
|
568
647
|
l.set(e, t), t === 0 && s.push(e);
|
|
569
648
|
}
|
|
570
649
|
}
|
|
571
|
-
if (c.length !== a.size) throw new
|
|
650
|
+
if (c.length !== a.size) throw new S(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
572
651
|
return c.map((e) => [e, r[e]]);
|
|
573
652
|
}
|
|
574
653
|
#T(e) {
|
|
@@ -580,21 +659,21 @@ var X = class e extends m {
|
|
|
580
659
|
}
|
|
581
660
|
#E(e, t, n) {
|
|
582
661
|
let r = this.#T("#" + e), i = this.#l.get(e);
|
|
583
|
-
i &&
|
|
662
|
+
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
663
|
}
|
|
585
664
|
#D(e, t, n) {
|
|
586
665
|
if (n.length !== 1) return;
|
|
587
666
|
let [r] = n;
|
|
588
|
-
if (!
|
|
589
|
-
let i =
|
|
590
|
-
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" ||
|
|
667
|
+
if (!O.test(r)) return;
|
|
668
|
+
let i = B(e), a = U(e), o = G(e) || W(e), [s, c] = (t ?? "").split(":");
|
|
669
|
+
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || W(e))) return;
|
|
591
670
|
c ? e["on" + c] === void 0 && this.#V(e, t, "refers to an unsupported event name") : c = "change";
|
|
592
|
-
let l =
|
|
671
|
+
let l = L(r);
|
|
593
672
|
e.addEventListener(c, (e) => {
|
|
594
673
|
let { target: t } = e;
|
|
595
674
|
if (!t) return;
|
|
596
675
|
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 ?
|
|
676
|
+
s === "checked" ? i ? this.#R(l, r.checked) : a && r.checked && this.#R(l, o) : this.#R(l, n === Number ? Y(o) : o), this.#P(l);
|
|
598
677
|
});
|
|
599
678
|
}
|
|
600
679
|
#O(e) {
|
|
@@ -625,8 +704,8 @@ var X = class e extends m {
|
|
|
625
704
|
}
|
|
626
705
|
propertyChangedCallback(e, t, n) {}
|
|
627
706
|
#N(e, t) {
|
|
628
|
-
if (!t || !
|
|
629
|
-
let n =
|
|
707
|
+
if (!t || !O.test(t)) return;
|
|
708
|
+
let n = L(t);
|
|
630
709
|
return this.#T(n) === void 0 && this.#H(e, "", n), n;
|
|
631
710
|
}
|
|
632
711
|
#P(e) {
|
|
@@ -650,17 +729,17 @@ var X = class e extends m {
|
|
|
650
729
|
i || (i = [], r.set(t, i)), i.push([e, n]);
|
|
651
730
|
}
|
|
652
731
|
let a = t.computed;
|
|
653
|
-
for (let t of a.matchAll(
|
|
654
|
-
let r =
|
|
732
|
+
for (let t of a.matchAll(k)) {
|
|
733
|
+
let r = L(t[0]);
|
|
655
734
|
this.#T(r) === void 0 && this.#H(null, e, r);
|
|
656
|
-
let o =
|
|
657
|
-
for (let [e, t] of Object.entries(n.properties))
|
|
735
|
+
let o = K(r), s = !1;
|
|
736
|
+
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(o) && (i(e, a), s = !0);
|
|
658
737
|
!s && typeof this.#T(r) != "function" && i(r, a);
|
|
659
738
|
}
|
|
660
|
-
for (let t of a.matchAll(
|
|
739
|
+
for (let t of a.matchAll(T)) {
|
|
661
740
|
let r = t[1];
|
|
662
|
-
if (typeof this.#T(r) != "function") throw new
|
|
663
|
-
for (let [e, t] of Object.entries(n.properties))
|
|
741
|
+
if (typeof this.#T(r) != "function") throw new S(`property ${e} computed calls non-method ${r}`);
|
|
742
|
+
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(r) && i(e, a);
|
|
664
743
|
}
|
|
665
744
|
}
|
|
666
745
|
#L(e, t) {
|
|
@@ -679,12 +758,12 @@ var X = class e extends m {
|
|
|
679
758
|
let r = this.#Z(t, n, e);
|
|
680
759
|
if (!r) {
|
|
681
760
|
let r = e.replaceAll("this..", "this.");
|
|
682
|
-
n ?
|
|
761
|
+
n ? Z(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
683
762
|
return;
|
|
684
763
|
}
|
|
685
764
|
let i = this.#n;
|
|
686
765
|
r.forEach((t) => {
|
|
687
|
-
let n =
|
|
766
|
+
let n = L(t);
|
|
688
767
|
if (typeof this.#T(n) == "function") return;
|
|
689
768
|
let r = i.propToExprsMap, a = r.get(n);
|
|
690
769
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
@@ -699,24 +778,24 @@ var X = class e extends m {
|
|
|
699
778
|
attrName: n
|
|
700
779
|
} : t), t instanceof HTMLElement && this.#D(t, n, r);
|
|
701
780
|
let o = this.#x(e);
|
|
702
|
-
n ?
|
|
781
|
+
n ? Z(t, n, o) : this.#q(t, o);
|
|
703
782
|
}
|
|
704
783
|
#B(e, t) {
|
|
705
784
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
706
|
-
r || this.#H(e, "ref", n), r.type !==
|
|
785
|
+
r || this.#H(e, "ref", n), r.type !== b && 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
786
|
}
|
|
708
787
|
setAttributeSafe(e, t) {
|
|
709
788
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
710
789
|
}
|
|
711
790
|
setFormValue(e, t) {
|
|
712
|
-
!this.#a || !
|
|
791
|
+
!this.#a || !H(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
|
|
713
792
|
}
|
|
714
793
|
static ssr(e = {}) {
|
|
715
|
-
throw new
|
|
794
|
+
throw new S("SSR is not available in the browser build.");
|
|
716
795
|
}
|
|
717
796
|
#V(e, t, n) {
|
|
718
797
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
719
|
-
throw new
|
|
798
|
+
throw new S(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
720
799
|
}
|
|
721
800
|
#H(e, t, n) {
|
|
722
801
|
this.#V(e, t, `refers to missing property "${n}"`);
|
|
@@ -725,9 +804,9 @@ var X = class e extends m {
|
|
|
725
804
|
return this.#W(e, this.getAttribute(t));
|
|
726
805
|
}
|
|
727
806
|
#W(t, n) {
|
|
728
|
-
if (n?.match(
|
|
807
|
+
if (n?.match(k)) return n;
|
|
729
808
|
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 :
|
|
809
|
+
if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : P(r);
|
|
731
810
|
if (i === String) {
|
|
732
811
|
if (a && !a.includes(n)) {
|
|
733
812
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
@@ -735,7 +814,7 @@ var X = class e extends m {
|
|
|
735
814
|
}
|
|
736
815
|
return n;
|
|
737
816
|
}
|
|
738
|
-
if (i === Number) return
|
|
817
|
+
if (i === Number) return Y(n);
|
|
739
818
|
if (i === Boolean) {
|
|
740
819
|
if (n === "true") return !0;
|
|
741
820
|
if (n === "false" || n === "null") return !1;
|
|
@@ -744,7 +823,7 @@ var X = class e extends m {
|
|
|
744
823
|
}
|
|
745
824
|
}
|
|
746
825
|
#G(e, t, n, r) {
|
|
747
|
-
|
|
826
|
+
H(n) && !this.#A(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#U(e, r)) && X(this, r || e, n);
|
|
748
827
|
}
|
|
749
828
|
#K(e) {
|
|
750
829
|
for (let [t, n] of this.#w([e])) this.#L(t, this.#x(n));
|
|
@@ -756,9 +835,9 @@ var X = class e extends m {
|
|
|
756
835
|
let r = typeof t;
|
|
757
836
|
r !== "string" && r !== "number" && this.#V(e, void 0, " computed content is not a string or number");
|
|
758
837
|
let i = String(t);
|
|
759
|
-
if (e instanceof HTMLElement &&
|
|
838
|
+
if (e instanceof HTMLElement && W(e)) e.value !== i && (e.value = i);
|
|
760
839
|
else if (n && r === "string" && i.trim().startsWith("<")) {
|
|
761
|
-
let t =
|
|
840
|
+
let t = _(i);
|
|
762
841
|
if (e.innerHTML === t) return;
|
|
763
842
|
e.innerHTML = t, this.#te(e), this.#M(e);
|
|
764
843
|
} else n && e.textContent !== i && (e.textContent = i);
|
|
@@ -778,25 +857,25 @@ var X = class e extends m {
|
|
|
778
857
|
let r = e.get(t);
|
|
779
858
|
r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
|
|
780
859
|
}, n = () => {
|
|
781
|
-
let n =
|
|
860
|
+
let n = v();
|
|
782
861
|
e.methodToExprsMap = n;
|
|
783
862
|
let r = Array.from(this.#r.keys());
|
|
784
863
|
for (let e of r) {
|
|
785
|
-
for (let r of e.matchAll(
|
|
786
|
-
for (let r of e.matchAll(
|
|
864
|
+
for (let r of e.matchAll(T)) t(n, r[1], e);
|
|
865
|
+
for (let r of e.matchAll(k)) t(n, K(L(r[0])), e);
|
|
787
866
|
}
|
|
788
867
|
}, { properties: r, propToExprsMap: i } = e;
|
|
789
868
|
for (let [t, a] of Object.entries(r)) {
|
|
790
|
-
let r =
|
|
869
|
+
let r = Q(a.usedBy);
|
|
791
870
|
if (!r) continue;
|
|
792
871
|
e.methodToExprsMap || n();
|
|
793
872
|
let { methodToExprsMap: o } = e, s = i.get(t);
|
|
794
873
|
s || (s = [], i.set(t, s));
|
|
795
874
|
for (let e of r) {
|
|
796
|
-
if (
|
|
797
|
-
let n =
|
|
798
|
-
if (typeof
|
|
799
|
-
} else if (typeof this.#T(e) != "function") throw new
|
|
875
|
+
if (V(e)) {
|
|
876
|
+
let n = R(e);
|
|
877
|
+
if (typeof te(this, n)?.get != "function") throw new S(`property ${t} usedBy contains non-getter ${e}`);
|
|
878
|
+
} else if (typeof this.#T(e) != "function") throw new S(`property ${t} usedBy contains non-method ${e}`);
|
|
800
879
|
let n = o.get(e) || [];
|
|
801
880
|
for (let e of n) s.includes(e) || s.push(e);
|
|
802
881
|
}
|
|
@@ -838,7 +917,7 @@ var X = class e extends m {
|
|
|
838
917
|
}
|
|
839
918
|
#X() {
|
|
840
919
|
let t = new Set(Object.keys(this.#n.properties));
|
|
841
|
-
for (let n of this.getAttributeNames()) if (!
|
|
920
|
+
for (let n of this.getAttributeNames()) if (!y.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
842
921
|
if (n === "form-assoc") {
|
|
843
922
|
this.#ee();
|
|
844
923
|
continue;
|
|
@@ -853,9 +932,9 @@ var X = class e extends m {
|
|
|
853
932
|
}
|
|
854
933
|
}
|
|
855
934
|
#Z(e, t, n) {
|
|
856
|
-
let r = n.match(
|
|
935
|
+
let r = n.match(k);
|
|
857
936
|
if (r) return r.forEach((n) => {
|
|
858
|
-
let r =
|
|
937
|
+
let r = L(n);
|
|
859
938
|
this.#T(r) === void 0 && this.#H(e, t, r);
|
|
860
939
|
}), r;
|
|
861
940
|
}
|
|
@@ -903,35 +982,35 @@ var X = class e extends m {
|
|
|
903
982
|
}
|
|
904
983
|
}
|
|
905
984
|
};
|
|
906
|
-
function
|
|
907
|
-
let n =
|
|
985
|
+
function re(e, ...t) {
|
|
986
|
+
let n = z(e, t);
|
|
908
987
|
for (;;) {
|
|
909
|
-
let e =
|
|
988
|
+
let e = ee.exec(n);
|
|
910
989
|
if (!e) break;
|
|
911
990
|
let t = e[2];
|
|
912
|
-
if (
|
|
991
|
+
if (A.test(t)) {
|
|
913
992
|
let r = e[1];
|
|
914
993
|
if (!r.startsWith("--")) {
|
|
915
994
|
let i = `--${r}: ${t};
|
|
916
995
|
${r}: var(--${r})`;
|
|
917
|
-
n =
|
|
996
|
+
n = J(n, e.index, e[0].length, i);
|
|
918
997
|
}
|
|
919
998
|
}
|
|
920
999
|
}
|
|
921
1000
|
return n;
|
|
922
1001
|
}
|
|
923
|
-
function
|
|
924
|
-
let n =
|
|
1002
|
+
function ie(e, ...t) {
|
|
1003
|
+
let n = z(e, t);
|
|
925
1004
|
for (;;) {
|
|
926
|
-
let e =
|
|
1005
|
+
let e = D.exec(n);
|
|
927
1006
|
if (!e || e[1] === "style") break;
|
|
928
|
-
let t =
|
|
929
|
-
if (
|
|
1007
|
+
let t = q(e[2]);
|
|
1008
|
+
if (A.test(t)) {
|
|
930
1009
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
931
|
-
n =
|
|
1010
|
+
n = J(n, i, t.length, r);
|
|
932
1011
|
}
|
|
933
1012
|
}
|
|
934
1013
|
return n;
|
|
935
1014
|
}
|
|
936
1015
|
//#endregion
|
|
937
|
-
export { a,
|
|
1016
|
+
export { a, ie as i, N as n, re as r, $ as t };
|
package/dist/wrec-ssr.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./wrec-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-1_q5NXuK.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 = {};
|
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-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-1_q5NXuK.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|