solely 0.0.20 → 0.0.22
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/base/router-view.d.ts +5 -18
- package/dist/solely.js +142 -175
- package/dist/solely.umd.cjs +1 -1
- package/dist/utils/functions copy 2.d.ts +2 -0
- package/dist/utils/functions copy.d.ts +2 -0
- package/dist/utils/functions.d.ts +2 -2
- package/dist/utils/html-parse.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
interface IRouteParams {
|
|
2
|
-
[key: string]: string;
|
|
3
|
-
}
|
|
4
1
|
export interface IRouter {
|
|
5
2
|
path: string;
|
|
6
3
|
tagName: string;
|
|
@@ -9,25 +6,15 @@ export interface IRouter {
|
|
|
9
6
|
export declare class RouterViewElement extends HTMLElement {
|
|
10
7
|
#private;
|
|
11
8
|
get isRouterView(): boolean;
|
|
12
|
-
constructor();
|
|
13
9
|
get $routes(): IRouter[];
|
|
14
10
|
set $routes(v: IRouter[]);
|
|
15
11
|
get $remainingPath(): string[];
|
|
16
12
|
get $matchedRoute(): IRouter | null;
|
|
17
|
-
set $pipe(v: any);
|
|
13
|
+
set $pipe(v: Record<string, any>);
|
|
18
14
|
connectedCallback(): void;
|
|
19
15
|
disconnectedCallback(): void;
|
|
20
|
-
onHashChange
|
|
21
|
-
matchRoute
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
remainingPath: string[];
|
|
25
|
-
} | {
|
|
26
|
-
matchedRoute: null;
|
|
27
|
-
params: {};
|
|
28
|
-
remainingPath: string[];
|
|
29
|
-
};
|
|
30
|
-
propagateRoutes(node: Node): void;
|
|
31
|
-
findAncestorWithRouterView(node: Element): RouterViewElement | null;
|
|
16
|
+
private onHashChange;
|
|
17
|
+
private matchRoute;
|
|
18
|
+
private propagateRoutes;
|
|
19
|
+
private findAncestorWithRouterView;
|
|
32
20
|
}
|
|
33
|
-
export {};
|
package/dist/solely.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K = (e) => {
|
|
2
2
|
throw TypeError(e);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
const ut = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, ft = /<\/?([^\s]+?)[/\s>]/,
|
|
4
|
+
var F = (e, t, n) => t.has(e) || K("Cannot " + n);
|
|
5
|
+
var v = (e, t, n) => (F(e, t, "read from private field"), n ? n.call(e) : t.get(e)), d = (e, t, n) => t.has(e) ? K("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), m = (e, t, n, s) => (F(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), H = (e, t, n) => (F(e, t, "access private method"), n);
|
|
6
|
+
const ut = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, ft = /<\/?([^\s]+?)[/\s>]/, mt = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, pt = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], j = /\{\{(.+?)\}\}/g;
|
|
7
7
|
function dt(e) {
|
|
8
8
|
return e.replace(/>\s+</g, "><").replace(/\s+/g, " ");
|
|
9
9
|
}
|
|
@@ -15,14 +15,14 @@ function gt(e, t) {
|
|
|
15
15
|
props: {},
|
|
16
16
|
on: {},
|
|
17
17
|
children: []
|
|
18
|
-
}, r = new RegExp(
|
|
18
|
+
}, r = new RegExp(mt);
|
|
19
19
|
for (; ; ) {
|
|
20
20
|
const a = r.exec(t);
|
|
21
21
|
if (a === null) break;
|
|
22
22
|
if (!a[0].trim()) continue;
|
|
23
23
|
const [o, i] = a[1] ? a[1].trim().split("=") : [a[2], a[3].trim().slice(1, -1)];
|
|
24
|
-
if (
|
|
25
|
-
s.on[o.startsWith("on-") ? o.slice(3) : o.slice(2)] =
|
|
24
|
+
if (J.includes(o) || o.startsWith("on-"))
|
|
25
|
+
s.on[o.startsWith("on-") ? o.slice(3) : o.slice(2)] = X(e, i);
|
|
26
26
|
else if (o.startsWith("s-")) {
|
|
27
27
|
const h = o.slice(2);
|
|
28
28
|
switch (h) {
|
|
@@ -30,29 +30,29 @@ function gt(e, t) {
|
|
|
30
30
|
s.model = i;
|
|
31
31
|
break;
|
|
32
32
|
case "style":
|
|
33
|
-
s.styles = (l) =>
|
|
33
|
+
s.styles = (l) => g(e, i, l);
|
|
34
34
|
break;
|
|
35
35
|
case "class":
|
|
36
|
-
s.classes = (l) =>
|
|
36
|
+
s.classes = (l) => g(e, i, l);
|
|
37
37
|
break;
|
|
38
38
|
case "readonly":
|
|
39
|
-
s.props.readOnly = (l) =>
|
|
39
|
+
s.props.readOnly = (l) => g(e, i, l);
|
|
40
40
|
break;
|
|
41
41
|
default:
|
|
42
|
-
s.props[h] = (l) =>
|
|
42
|
+
s.props[h] = (l) => g(e, i, l);
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
} else
|
|
46
46
|
s.attrs[o] = i;
|
|
47
47
|
r.lastIndex--;
|
|
48
48
|
}
|
|
49
|
-
if (n === "For" ? s.fn = (a) =>
|
|
50
|
-
const a = s.model.replace("this.", "").replace("$data.", ""), o = (h) =>
|
|
49
|
+
if (n === "For" ? s.fn = (a) => g(e, s.attrs.each, a) : (n === "If" || n === "ElseIf") && (s.fn = (a) => g(e, s.attrs.condition, a)), s.model) {
|
|
50
|
+
const a = s.model.replace("this.", "").replace("$data.", ""), o = (h) => g(e, `$data.${a}`, h), i = (h) => X(e, `$data.${a}=${h}`);
|
|
51
51
|
n === "input" ? s.attrs.type === "checkbox" || s.attrs.type === "radio" ? (s.props.checked = o, s.on.change = i("checked")) : (s.props.value = o, s.on.input = i("value")) : n === "textarea" ? (s.props.value = o, s.on.input = i("value")) : n === "select" && (s.props.value = o, s.on.change = i("value"));
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Et(e, t) {
|
|
56
56
|
const n = [];
|
|
57
57
|
if (!t) return n;
|
|
58
58
|
t = dt(t);
|
|
@@ -66,15 +66,15 @@ function vt(e, t) {
|
|
|
66
66
|
if (h > o) {
|
|
67
67
|
const c = t.substring(o, h).trim();
|
|
68
68
|
if (c) {
|
|
69
|
-
|
|
70
|
-
const
|
|
69
|
+
j.lastIndex = 0;
|
|
70
|
+
const f = !j.test(c) ? c : (T) => c.replace(j, (D, V) => g(e, V, T));
|
|
71
71
|
l.push({
|
|
72
72
|
rootId: 0,
|
|
73
73
|
tagName: "text",
|
|
74
74
|
attrs: {},
|
|
75
75
|
props: {},
|
|
76
76
|
on: {},
|
|
77
|
-
content:
|
|
77
|
+
content: f,
|
|
78
78
|
children: []
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -95,7 +95,7 @@ function vt(e, t) {
|
|
|
95
95
|
s.pop();
|
|
96
96
|
s.pop();
|
|
97
97
|
} else {
|
|
98
|
-
const c = gt(e, i), u = i.endsWith("/>") ||
|
|
98
|
+
const c = gt(e, i), u = i.endsWith("/>") || pt.includes(c.tagName);
|
|
99
99
|
l.push(c), u || (s.push(c), r.push(c.tagName));
|
|
100
100
|
}
|
|
101
101
|
return "";
|
|
@@ -109,13 +109,13 @@ function vt(e, t) {
|
|
|
109
109
|
children: []
|
|
110
110
|
}), n;
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const g = (e, t, n) => {
|
|
113
113
|
try {
|
|
114
|
-
return
|
|
114
|
+
return N(["$data", ...n.map((r) => r.item), ...n.map((r) => r.index), `return (${t})`]).bind(e)(e.$data, ...n.map((r) => r.value), ...n.map((r) => r.valueIndex));
|
|
115
115
|
} catch (s) {
|
|
116
116
|
console.error(s);
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, X = (e, t) => (n, s) => N(["$data", "event", "value", "checked", ...s.map((a) => a.item), ...s.map((a) => a.index), t]).bind(e)(e.$data, n, n.target.value, n.target.checked, ...s.map((a) => a.value), ...s.map((a) => a.valueIndex)), J = [
|
|
119
119
|
"onabort",
|
|
120
120
|
"onautocomplete",
|
|
121
121
|
"onautocompleteerror",
|
|
@@ -178,75 +178,57 @@ const m = (e, t, n) => {
|
|
|
178
178
|
"ontoggle",
|
|
179
179
|
"onvolumechange",
|
|
180
180
|
"onwaiting"
|
|
181
|
-
],
|
|
181
|
+
], vt = /* @__PURE__ */ (() => {
|
|
182
182
|
const e = typeof requestAnimationFrame == "function" ? (t) => requestAnimationFrame(t) : typeof Promise < "u" ? (t) => Promise.resolve().then(t) : (t) => setTimeout(t, 0);
|
|
183
183
|
return (t, ...n) => {
|
|
184
184
|
if (typeof t != "function")
|
|
185
185
|
throw new Error("runInAsyncQueue expects a function as its first argument");
|
|
186
186
|
e(() => t(...n));
|
|
187
187
|
};
|
|
188
|
-
})(),
|
|
189
|
-
function
|
|
190
|
-
const t = e.join(",");
|
|
191
|
-
if (!
|
|
188
|
+
})(), q = {};
|
|
189
|
+
function N(e) {
|
|
190
|
+
const t = e.map((n) => n.replace(/[',"]/g, "")).join(",");
|
|
191
|
+
if (!q[t]) {
|
|
192
192
|
const n = e[e.length - 1];
|
|
193
193
|
if (n.trim() === "")
|
|
194
|
-
throw new Error("Function body
|
|
195
|
-
if (
|
|
194
|
+
throw new Error("Function body cannot be empty");
|
|
195
|
+
if (yt(n))
|
|
196
196
|
throw new Error("Input contains potentially dangerous code: " + n);
|
|
197
|
-
|
|
198
|
-
j[t] = s;
|
|
197
|
+
q[t] = new Function(...e);
|
|
199
198
|
}
|
|
200
|
-
return
|
|
199
|
+
return q[t];
|
|
201
200
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
"Function",
|
|
206
|
-
"setTimeout",
|
|
207
|
-
"setInterval",
|
|
208
|
-
"window",
|
|
209
|
-
"global",
|
|
210
|
-
"require",
|
|
211
|
-
"XMLHttpRequest",
|
|
212
|
-
"fetch",
|
|
213
|
-
"console",
|
|
214
|
-
"debugger",
|
|
215
|
-
"process",
|
|
216
|
-
"document",
|
|
217
|
-
"importScripts",
|
|
218
|
-
"String.raw",
|
|
219
|
-
"Object.prototype",
|
|
220
|
-
"JSON.parse"
|
|
221
|
-
].some((n) => e.includes(n));
|
|
201
|
+
const bt = ["eval", "Function", "process", "require"];
|
|
202
|
+
function yt(e) {
|
|
203
|
+
return bt.some((t) => new RegExp(`\\b${t}\\b`, "g").test(e));
|
|
222
204
|
}
|
|
223
|
-
const
|
|
224
|
-
const t =
|
|
205
|
+
const wt = "http://www.w3.org/1999/xlink", _t = "http://www.w3.org/2000/xmlns/", Ct = "http://www.w3.org/XML/1998/namespace", xt = "http://www.w3.org/2000/svg", Y = (e) => typeof e.content == "function" ? e.content(e.loops || []) : e.content || "", kt = (e) => {
|
|
206
|
+
const t = Y(e), n = e.elm;
|
|
225
207
|
n.textContent !== t && (n.textContent = t);
|
|
226
|
-
},
|
|
208
|
+
}, tt = (e, t, n = []) => {
|
|
227
209
|
Object.keys(t).forEach((s) => {
|
|
228
210
|
const r = t[s](n);
|
|
229
211
|
e[s] !== r && (e[s] = r);
|
|
230
212
|
});
|
|
231
|
-
},
|
|
213
|
+
}, et = (e, t) => {
|
|
232
214
|
const { styles: n, loops: s = [] } = t;
|
|
233
215
|
if (!n) return;
|
|
234
|
-
const r = n(s), a =
|
|
216
|
+
const r = n(s), a = U(r);
|
|
235
217
|
Object.entries(a).forEach(([o, i]) => {
|
|
236
218
|
e.style[o] = i;
|
|
237
219
|
});
|
|
238
|
-
},
|
|
220
|
+
}, nt = (e, t) => {
|
|
239
221
|
const { classes: n, loops: s = [] } = t;
|
|
240
222
|
if (!n) return;
|
|
241
|
-
const r = n(s), a =
|
|
223
|
+
const r = n(s), a = st(r);
|
|
242
224
|
Object.entries(a).forEach(([o, i]) => {
|
|
243
225
|
i ? e.classList.add(o) : e.classList.remove(o);
|
|
244
226
|
});
|
|
245
|
-
},
|
|
227
|
+
}, U = (e) => {
|
|
246
228
|
let t = {};
|
|
247
229
|
return typeof e == "object" && e !== null && !Array.isArray(e) ? Object.entries(e).forEach(([n, s]) => {
|
|
248
230
|
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
249
|
-
const r =
|
|
231
|
+
const r = U(s);
|
|
250
232
|
Object.entries(r).forEach(([a, o]) => {
|
|
251
233
|
t[`${n}-${a}`] = o;
|
|
252
234
|
});
|
|
@@ -255,32 +237,32 @@ const yt = "http://www.w3.org/1999/xlink", wt = "http://www.w3.org/2000/xmlns/",
|
|
|
255
237
|
const [s, r] = n.split(":").map((a) => a.trim());
|
|
256
238
|
s && r && (t[s] = r);
|
|
257
239
|
}) : Array.isArray(e) && e.forEach((n) => {
|
|
258
|
-
const s =
|
|
240
|
+
const s = U(n);
|
|
259
241
|
Object.entries(s).forEach(([r, a]) => {
|
|
260
242
|
t[r] = a;
|
|
261
243
|
});
|
|
262
244
|
}), t;
|
|
263
|
-
},
|
|
245
|
+
}, st = (e) => {
|
|
264
246
|
let t = {};
|
|
265
247
|
return typeof e == "object" && !Array.isArray(e) ? Object.entries(e).forEach(([n, s]) => {
|
|
266
248
|
t[n] = !!s;
|
|
267
249
|
}) : typeof e == "string" ? e.split(" ").forEach((n) => {
|
|
268
250
|
n !== "" && (t[n] = !0);
|
|
269
251
|
}) : Array.isArray(e) && e.forEach((n) => {
|
|
270
|
-
const s =
|
|
252
|
+
const s = st(n);
|
|
271
253
|
Object.entries(s).forEach(([r, a]) => {
|
|
272
254
|
t[r] = a;
|
|
273
255
|
});
|
|
274
256
|
}), t;
|
|
275
|
-
},
|
|
257
|
+
}, rt = (e, t, n) => {
|
|
276
258
|
const s = (r) => n.on[t](r, n.loops || []);
|
|
277
259
|
e.addEventListener(t, s, !1), n.handlers = n.handlers || {}, n.handlers[t] = s;
|
|
278
|
-
},
|
|
260
|
+
}, It = (e, t) => {
|
|
279
261
|
const n = t.elm;
|
|
280
262
|
Object.keys(t.on).forEach((s) => {
|
|
281
|
-
e.handlers && e.handlers[s] && n.removeEventListener(s, e.handlers[s], !1),
|
|
282
|
-
}),
|
|
283
|
-
},
|
|
263
|
+
e.handlers && e.handlers[s] && n.removeEventListener(s, e.handlers[s], !1), rt(n, s, t);
|
|
264
|
+
}), tt(n, t.props, t.loops), nt(n, t), et(n, t), at(n, e.children, t.children);
|
|
265
|
+
}, At = (e, t) => {
|
|
284
266
|
switch (t.elm = e.elm, t.tagName) {
|
|
285
267
|
case "comment":
|
|
286
268
|
break;
|
|
@@ -290,54 +272,54 @@ const yt = "http://www.w3.org/1999/xlink", wt = "http://www.w3.org/2000/xmlns/",
|
|
|
290
272
|
case "slot":
|
|
291
273
|
break;
|
|
292
274
|
default:
|
|
293
|
-
|
|
275
|
+
It(e, t);
|
|
294
276
|
break;
|
|
295
277
|
}
|
|
296
|
-
},
|
|
278
|
+
}, G = (e, t, n) => {
|
|
297
279
|
n ? e.insertBefore(t, n) : e.appendChild(t);
|
|
298
|
-
}, At = (e, t, n) => {
|
|
299
|
-
const s = N(t), r = document.createTextNode(s);
|
|
300
|
-
t.elm = r, z(e, r, n);
|
|
301
280
|
}, Rt = (e, t, n) => {
|
|
281
|
+
const s = Y(t), r = document.createTextNode(s);
|
|
282
|
+
t.elm = r, G(e, r, n);
|
|
283
|
+
}, $t = (e, t, n) => {
|
|
302
284
|
const s = t.content, r = document.createComment(s);
|
|
303
|
-
t.elm = r,
|
|
304
|
-
},
|
|
305
|
-
t.tagName === "svg" && (s =
|
|
285
|
+
t.elm = r, G(e, r, n);
|
|
286
|
+
}, St = (e, t, n, s) => {
|
|
287
|
+
t.tagName === "svg" && (s = xt);
|
|
306
288
|
const r = s ? document.createElementNS(s, t.tagName) : document.createElement(t.tagName);
|
|
307
289
|
Object.keys(t.attrs).forEach((a) => {
|
|
308
290
|
const o = t.attrs[a] || "";
|
|
309
|
-
a.charAt(0) !== "x" ? r.setAttribute(a, o) : a.startsWith("xml:") ? r.setAttributeNS(Ct, a, o) : a.startsWith("xlink:") ? r.setAttributeNS(
|
|
291
|
+
a.charAt(0) !== "x" ? r.setAttribute(a, o) : a.startsWith("xml:") ? r.setAttributeNS(Ct, a, o) : a.startsWith("xlink:") ? r.setAttributeNS(wt, a, o) : a.startsWith("xmlns:") ? r.setAttributeNS(_t, a, o) : r.setAttribute(a, o);
|
|
310
292
|
}), Object.keys(t.on).forEach((a) => {
|
|
311
|
-
|
|
312
|
-
}),
|
|
313
|
-
|
|
293
|
+
rt(r, a, t);
|
|
294
|
+
}), tt(r, t.props, t.loops), nt(r, t), et(r, t), t.elm = r, G(e, r, n), t.tagName === "foreignObject" && (s = void 0), t.children.forEach((a) => {
|
|
295
|
+
M(r, a, void 0, s);
|
|
314
296
|
});
|
|
315
|
-
},
|
|
297
|
+
}, M = (e, t, n, s) => {
|
|
316
298
|
switch (t.tagName) {
|
|
317
299
|
case "comment":
|
|
318
|
-
|
|
300
|
+
$t(e, t, n);
|
|
319
301
|
break;
|
|
320
302
|
case "text":
|
|
321
|
-
|
|
303
|
+
Rt(e, t, n);
|
|
322
304
|
break;
|
|
323
305
|
default:
|
|
324
|
-
|
|
306
|
+
St(e, t, n, s);
|
|
325
307
|
break;
|
|
326
308
|
}
|
|
327
|
-
},
|
|
309
|
+
}, Wt = (e) => e && (e.tagName === "ElseIf" || e.tagName === "comment"), Ht = (e) => e && e.tagName === "Else", y = (e, t, n = [], s = 0, r = !0, a) => {
|
|
328
310
|
var o, i, h;
|
|
329
311
|
for (let l = 0; l < t.length; l++) {
|
|
330
312
|
const c = t[l];
|
|
331
313
|
if (c.tagName === "If") {
|
|
332
|
-
let u = !1;
|
|
333
|
-
for (((o = c.fn) == null ? void 0 : o.call(c, n)) && (
|
|
334
|
-
((h = (i = t[l + 1]).fn) == null ? void 0 : h.call(i, n)) && !u && (
|
|
335
|
-
l + 1 < t.length &&
|
|
314
|
+
let u = !1, f = 1;
|
|
315
|
+
for (((o = c.fn) == null ? void 0 : o.call(c, n)) && (y(e, c.children, n, s, !1, f), u = !0), f++; l + 1 < t.length && Wt(t[l + 1]); )
|
|
316
|
+
((h = (i = t[l + 1]).fn) == null ? void 0 : h.call(i, n)) && !u && (y(e, t[l + 1].children, n, s, !1, f), u = !0), l++, f++;
|
|
317
|
+
l + 1 < t.length && Ht(t[l + 1]) && (u || (y(e, t[l + 1].children, n, s, !1, f), u = !0), l++);
|
|
336
318
|
} else if (c.tagName === "For") {
|
|
337
|
-
const { item: u = "item", index:
|
|
338
|
-
(c.fn(n) || []).forEach((
|
|
339
|
-
const ht = { item: u, value:
|
|
340
|
-
|
|
319
|
+
const { item: u = "item", index: f = "index" } = c.attrs;
|
|
320
|
+
(c.fn(n) || []).forEach((D, V) => {
|
|
321
|
+
const ht = { item: u, value: D, index: f, valueIndex: V };
|
|
322
|
+
y(e, c.children, [...n, ht], s, !1);
|
|
341
323
|
});
|
|
342
324
|
} else {
|
|
343
325
|
const u = {
|
|
@@ -345,31 +327,31 @@ const yt = "http://www.w3.org/1999/xlink", wt = "http://www.w3.org/2000/xmlns/",
|
|
|
345
327
|
loops: n,
|
|
346
328
|
children: [],
|
|
347
329
|
rootId: s,
|
|
348
|
-
|
|
330
|
+
ifId: a
|
|
349
331
|
};
|
|
350
|
-
|
|
332
|
+
y(u.children, c.children, n), e.push(u);
|
|
351
333
|
}
|
|
352
334
|
r && s++;
|
|
353
335
|
}
|
|
354
|
-
},
|
|
336
|
+
}, at = (e, t, n) => {
|
|
355
337
|
var a, o, i, h, l;
|
|
356
338
|
let s = 0, r = 0;
|
|
357
339
|
for (; s < t.length && r < n.length; ) {
|
|
358
340
|
const c = t[s], u = n[r];
|
|
359
|
-
c.rootId === u.rootId ? (u.
|
|
341
|
+
c.rootId === u.rootId ? (u.ifId && c.ifId !== u.ifId ? ((a = c.elm) == null || a.remove(), M(e, u, (o = t[s + 1]) == null ? void 0 : o.elm)) : At(c, u), r++, s++) : c.rootId > u.rootId ? ((i = c.elm) == null || i.remove(), s++) : (M(e, u, (h = t[s + 1]) == null ? void 0 : h.elm), r++);
|
|
360
342
|
}
|
|
361
343
|
for (; s < t.length; )
|
|
362
344
|
(l = t[s].elm) == null || l.remove(), s++;
|
|
363
345
|
for (; r < n.length; ) {
|
|
364
346
|
const c = n[r];
|
|
365
|
-
|
|
347
|
+
M(e, c), r++;
|
|
366
348
|
}
|
|
367
|
-
},
|
|
349
|
+
}, z = (e, t, n = []) => {
|
|
368
350
|
if (!t || t.length === 0) return [];
|
|
369
351
|
const s = [];
|
|
370
|
-
return
|
|
352
|
+
return y(s, t || [], [], 0, !0), at(e, n, s), s;
|
|
371
353
|
}, ot = (e) => typeof e == "object" && e != null;
|
|
372
|
-
function
|
|
354
|
+
function Mt(e = window.location) {
|
|
373
355
|
let t;
|
|
374
356
|
typeof e == "string" ? t = new URL(e).hash : t = e.hash;
|
|
375
357
|
const n = t.split("?"), s = n[0].substring(2), r = n[1], a = {};
|
|
@@ -390,43 +372,43 @@ const it = (e, t) => new Proxy(e, {
|
|
|
390
372
|
},
|
|
391
373
|
set: (n, s, r) => (n[s] !== r && (n[s] = r, t(s, r)), !0)
|
|
392
374
|
});
|
|
393
|
-
var
|
|
394
|
-
class
|
|
375
|
+
var R, $, S, _, W, C, x, O;
|
|
376
|
+
class jt extends HTMLElement {
|
|
395
377
|
constructor() {
|
|
396
378
|
super();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
379
|
+
d(this, x);
|
|
380
|
+
d(this, R, {});
|
|
381
|
+
d(this, $, []);
|
|
382
|
+
d(this, S, []);
|
|
383
|
+
d(this, _, !1);
|
|
384
|
+
d(this, W, !1);
|
|
385
|
+
d(this, C);
|
|
404
386
|
const n = this._manifest || {};
|
|
405
|
-
n.template && typeof n.template == "string" &&
|
|
387
|
+
n.template && typeof n.template == "string" && m(this, $, Et(this, n.template)), n.shadowDOM && n.shadowDOM.use ? m(this, C, this.attachShadow({
|
|
406
388
|
mode: n.shadowDOM.mode || "open"
|
|
407
|
-
})) :
|
|
389
|
+
})) : m(this, C, this);
|
|
408
390
|
}
|
|
409
391
|
get $data() {
|
|
410
|
-
let n =
|
|
411
|
-
return ot(n) && (n = it(n, () =>
|
|
392
|
+
let n = v(this, R);
|
|
393
|
+
return ot(n) && (n = it(n, () => H(this, x, O).call(this))), n;
|
|
412
394
|
}
|
|
413
395
|
set $data(n) {
|
|
414
|
-
|
|
396
|
+
m(this, R, n || {}), H(this, x, O).call(this);
|
|
415
397
|
}
|
|
416
398
|
connectedCallback() {
|
|
417
399
|
const n = this._manifest || {};
|
|
418
400
|
(n.className || n.tagName || "").split(" ").forEach((r) => {
|
|
419
401
|
r && this.classList.add(r);
|
|
420
|
-
}),
|
|
402
|
+
}), H(this, x, O).call(this);
|
|
421
403
|
}
|
|
422
404
|
onInit() {
|
|
423
405
|
}
|
|
424
406
|
disconnectedCallback() {
|
|
425
407
|
}
|
|
426
408
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
409
|
+
R = new WeakMap(), $ = new WeakMap(), S = new WeakMap(), _ = new WeakMap(), W = new WeakMap(), C = new WeakMap(), x = new WeakSet(), O = function() {
|
|
410
|
+
v(this, _) || (m(this, _, !0), vt(() => {
|
|
411
|
+
m(this, S, z(v(this, C), v(this, $), v(this, S))), m(this, _, !1), this.isConnected && !v(this, W) && (m(this, W, !0), this.onInit());
|
|
430
412
|
}));
|
|
431
413
|
};
|
|
432
414
|
const Ot = (e) => (t) => {
|
|
@@ -434,38 +416,38 @@ const Ot = (e) => (t) => {
|
|
|
434
416
|
console.warn(`标签名称 "${e.tagName}" 已经被注册`);
|
|
435
417
|
return;
|
|
436
418
|
}
|
|
437
|
-
return t.prototype._manifest =
|
|
438
|
-
},
|
|
419
|
+
return t.prototype._manifest = Lt(e), customElements.define(e.tagName, t), t;
|
|
420
|
+
}, Lt = (e) => (e = Object.assign({
|
|
439
421
|
hasConfig: !1
|
|
440
422
|
}, e), e);
|
|
441
|
-
var Pt = Object.defineProperty,
|
|
423
|
+
var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ct = (e) => {
|
|
442
424
|
throw TypeError(e);
|
|
443
|
-
},
|
|
444
|
-
for (var r = s > 1 ? void 0 : s ?
|
|
425
|
+
}, Dt = (e, t, n, s) => {
|
|
426
|
+
for (var r = s > 1 ? void 0 : s ? Tt(t, n) : t, a = e.length - 1, o; a >= 0; a--)
|
|
445
427
|
(o = e[a]) && (r = (s ? o(t, n, r) : o(r)) || r);
|
|
446
428
|
return s && r && Pt(t, n, r), r;
|
|
447
|
-
},
|
|
448
|
-
let
|
|
429
|
+
}, Q = (e, t, n) => t.has(e) || ct("Cannot " + n), E = (e, t, n) => (Q(e, t, "read from private field"), n ? n.call(e) : t.get(e)), b = (e, t, n) => t.has(e) ? ct("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), p = (e, t, n, s) => (Q(e, t, "write to private field"), t.set(e, n), n), Vt = (e, t, n) => (Q(e, t, "access private method"), n), k, L, A, I, w, P, B, lt;
|
|
430
|
+
let Z = class extends HTMLElement {
|
|
449
431
|
constructor() {
|
|
450
|
-
super(),
|
|
432
|
+
super(...arguments), b(this, B), b(this, k, []), b(this, L, []), b(this, A, null), b(this, I), b(this, w, []), b(this, P, {});
|
|
451
433
|
}
|
|
452
434
|
get isRouterView() {
|
|
453
435
|
return !0;
|
|
454
436
|
}
|
|
455
437
|
get $routes() {
|
|
456
|
-
return E(this,
|
|
438
|
+
return E(this, w);
|
|
457
439
|
}
|
|
458
440
|
set $routes(e) {
|
|
459
|
-
|
|
441
|
+
p(this, w, e), this.onHashChange();
|
|
460
442
|
}
|
|
461
443
|
get $remainingPath() {
|
|
462
|
-
return E(this,
|
|
444
|
+
return E(this, L);
|
|
463
445
|
}
|
|
464
446
|
get $matchedRoute() {
|
|
465
|
-
return E(this,
|
|
447
|
+
return E(this, A);
|
|
466
448
|
}
|
|
467
449
|
set $pipe(e) {
|
|
468
|
-
|
|
450
|
+
p(this, P, e || {}), this.onHashChange();
|
|
469
451
|
}
|
|
470
452
|
connectedCallback() {
|
|
471
453
|
window.addEventListener("hashchange", this.onHashChange.bind(this)), this.onHashChange();
|
|
@@ -475,15 +457,15 @@ let J = class extends HTMLElement {
|
|
|
475
457
|
}
|
|
476
458
|
onHashChange() {
|
|
477
459
|
var n;
|
|
478
|
-
if (!this.isConnected)
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
t ? (d(this, k, t.$remainingPath), d(this, _, ((n = t.$matchedRoute) == null ? void 0 : n.children) || [])) : d(this, k, e), Vt(this, U, lt).call(this);
|
|
460
|
+
if (!this.isConnected) return;
|
|
461
|
+
const { path: e } = Mt(window.location), t = this.findAncestorWithRouterView(this);
|
|
462
|
+
t ? (p(this, I, t.$remainingPath), p(this, w, ((n = t.$matchedRoute) == null ? void 0 : n.children) || [])) : p(this, I, e), Vt(this, B, lt).call(this);
|
|
482
463
|
}
|
|
483
464
|
matchRoute(e, t) {
|
|
484
465
|
for (const n of e) {
|
|
485
466
|
const s = n.path.split("/");
|
|
486
|
-
let r = !0
|
|
467
|
+
let r = !0;
|
|
468
|
+
const a = {};
|
|
487
469
|
for (let o = 0; o < s.length; o++) {
|
|
488
470
|
const i = s[o];
|
|
489
471
|
if (i.startsWith(":"))
|
|
@@ -509,16 +491,10 @@ let J = class extends HTMLElement {
|
|
|
509
491
|
remainingPath: t
|
|
510
492
|
};
|
|
511
493
|
}
|
|
512
|
-
// 向直系后代传播路由
|
|
513
494
|
propagateRoutes(e) {
|
|
514
|
-
for (
|
|
515
|
-
|
|
516
|
-
t.onHashChange();
|
|
517
|
-
continue;
|
|
518
|
-
} else
|
|
519
|
-
this.propagateRoutes(t);
|
|
495
|
+
for (const t of e.childNodes)
|
|
496
|
+
t.isRouterView ? t.onHashChange() : this.propagateRoutes(t);
|
|
520
497
|
}
|
|
521
|
-
// 寻找包含 'router-view' 属性的祖辈节点
|
|
522
498
|
findAncestorWithRouterView(e) {
|
|
523
499
|
let t = e.parentNode;
|
|
524
500
|
for (; t; ) {
|
|
@@ -529,23 +505,23 @@ let J = class extends HTMLElement {
|
|
|
529
505
|
return null;
|
|
530
506
|
}
|
|
531
507
|
};
|
|
532
|
-
M = /* @__PURE__ */ new WeakMap();
|
|
533
|
-
P = /* @__PURE__ */ new WeakMap();
|
|
534
|
-
x = /* @__PURE__ */ new WeakMap();
|
|
535
508
|
k = /* @__PURE__ */ new WeakMap();
|
|
536
|
-
_ = /* @__PURE__ */ new WeakMap();
|
|
537
509
|
L = /* @__PURE__ */ new WeakMap();
|
|
538
|
-
|
|
510
|
+
A = /* @__PURE__ */ new WeakMap();
|
|
511
|
+
I = /* @__PURE__ */ new WeakMap();
|
|
512
|
+
w = /* @__PURE__ */ new WeakMap();
|
|
513
|
+
P = /* @__PURE__ */ new WeakMap();
|
|
514
|
+
B = /* @__PURE__ */ new WeakSet();
|
|
539
515
|
lt = function() {
|
|
540
516
|
var h;
|
|
541
|
-
const e = E(this,
|
|
542
|
-
|
|
517
|
+
const e = E(this, I) || [], { matchedRoute: t, params: n, remainingPath: s } = this.matchRoute(E(this, w), e);
|
|
518
|
+
p(this, L, s);
|
|
543
519
|
const r = (t == null ? void 0 : t.tagName) || "comment", a = {}, o = {};
|
|
544
520
|
for (const [l, c] of Object.entries(n))
|
|
545
521
|
a[l] = () => c;
|
|
546
|
-
for (const [l, c] of Object.entries(E(this,
|
|
547
|
-
|
|
548
|
-
|
|
522
|
+
for (const [l, c] of Object.entries(E(this, P)))
|
|
523
|
+
J.includes(l) || l.startsWith("on-") ? o[l.startsWith("on-") ? l.slice(3) : l.slice(2)] = c : a[l] = () => c;
|
|
524
|
+
const i = [
|
|
549
525
|
{
|
|
550
526
|
tagName: r,
|
|
551
527
|
rootId: 0,
|
|
@@ -555,36 +531,27 @@ lt = function() {
|
|
|
555
531
|
children: []
|
|
556
532
|
}
|
|
557
533
|
];
|
|
558
|
-
((h = E(this,
|
|
559
|
-
rootId: 0,
|
|
560
|
-
tagName: "If",
|
|
561
|
-
// 带有If标记的ast会被重建
|
|
562
|
-
attrs: {},
|
|
563
|
-
props: {},
|
|
564
|
-
on: {},
|
|
565
|
-
fn: () => !0,
|
|
566
|
-
children: i
|
|
567
|
-
}]), d(this, M, at(this, i, E(this, M))), d(this, x, t || {
|
|
534
|
+
((h = E(this, A)) == null ? void 0 : h.tagName) !== r ? (this.innerHTML = "", p(this, k, z(this, i, []))) : p(this, k, z(this, i, E(this, k))), p(this, A, t || {
|
|
568
535
|
tagName: "comment",
|
|
569
536
|
path: "",
|
|
570
537
|
children: []
|
|
571
538
|
}), this.propagateRoutes(this);
|
|
572
539
|
};
|
|
573
|
-
|
|
540
|
+
Z = Dt([
|
|
574
541
|
Ot({
|
|
575
542
|
tagName: "router-view"
|
|
576
543
|
})
|
|
577
|
-
],
|
|
544
|
+
], Z);
|
|
578
545
|
export {
|
|
579
|
-
|
|
546
|
+
jt as BaseElement,
|
|
580
547
|
Ot as CustomElement,
|
|
581
|
-
|
|
582
|
-
|
|
548
|
+
Z as RouterViewElement,
|
|
549
|
+
N as createFunction,
|
|
583
550
|
ot as isObject,
|
|
584
|
-
|
|
551
|
+
J as listeners,
|
|
585
552
|
it as observe,
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
553
|
+
Mt as parseHashUrl,
|
|
554
|
+
Et as parseHtml,
|
|
555
|
+
z as patch,
|
|
556
|
+
vt as runInAsyncQueue
|
|
590
557
|
};
|
package/dist/solely.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.solely={}))})(this,function(l){"use strict";var gt=l=>{throw TypeError(l)};var tt=(l,f,p)=>f.has(l)||gt("Cannot "+p);var w=(l,f,p)=>(tt(l,f,"read from private field"),p?p.call(l):f.get(l)),E=(l,f,p)=>f.has(l)?gt("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(l):f.set(l,p),d=(l,f,p,x)=>(tt(l,f,"write to private field"),x?x.call(l,p):f.set(l,p),p),j=(l,f,p)=>(tt(l,f,"access private method"),p);var $,W,H,_,O,k,I,D;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,x=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,vt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=/\{\{(.+?)\}\}/g;function Et(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function bt(n,t){const e=(t.match(p)||[])[1]||"",s={rootId:0,tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(x);for(;;){const a=r.exec(t);if(a===null)break;if(!a[0].trim())continue;const[o,i]=a[1]?a[1].trim().split("="):[a[2],a[3].trim().slice(1,-1)];if(q.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=nt(n,i);else if(o.startsWith("s-")){const u=o.slice(2);switch(u){case"model":s.model=i;break;case"style":s.styles=h=>g(n,i,h);break;case"class":s.classes=h=>g(n,i,h);break;case"readonly":s.props.readOnly=h=>g(n,i,h);break;default:s.props[u]=h=>g(n,i,h);break}}else s.attrs[o]=i;r.lastIndex--}if(e==="For"?s.fn=a=>g(n,s.attrs.each,a):(e==="If"||e==="ElseIf")&&(s.fn=a=>g(n,s.attrs.condition,a)),s.model){const a=s.model.replace("this.","").replace("$data.",""),o=u=>g(n,`$data.${a}`,u),i=u=>nt(n,`$data.${a}=${u}`);e==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=o,s.on.change=i("checked")):(s.props.value=o,s.on.input=i("value")):e==="textarea"?(s.props.value=o,s.on.input=i("value")):e==="select"&&(s.props.value=o,s.on.change=i("value"))}return s}function et(n,t){const e=[];if(!t)return e;t=Et(t);const s=[],r=[],a=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let o=0;return t.replace(f,(i,u)=>{const h=a();if(u>o){const c=t.substring(o,u).trim();if(c){F.lastIndex=0;const L=!F.test(c)?c:N=>c.replace(F,(dt,Y)=>g(n,Y,N));h.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:L,children:[]})}}if(o=u+i.length,i.startsWith("<!--")&&i.endsWith("-->"))h.push({rootId:0,tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const c=r.pop();for(;s.length>0&&s[s.length-1].tagName!==c;)s.pop();s.pop()}else{const c=bt(n,i),m=i.endsWith("/>")||vt.includes(c.tagName);h.push(c),m||(s.push(c),r.push(c.tagName))}return""}),t.length>o&&e.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:t.substring(o).trim(),children:[]}),e}const g=(n,t,e)=>{try{return z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){console.error(s)}},nt=(n,t)=>(e,s)=>z(["$data","event","value","checked",...s.map(a=>a.item),...s.map(a=>a.index),t]).bind(n)(n.$data,e,e.target.value,e.target.checked,...s.map(a=>a.value),...s.map(a=>a.valueIndex)),q=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],st=(()=>{const n=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");n(()=>t(...e))}})(),U={};function z(n){const t=n.join(",");if(!U[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body is empty");if(yt(e))throw new Error("Input contains potentially dangerous code: "+e);const s=new Function(...n);U[t]=s}return U[t]}function yt(n){return["eval","Function","setTimeout","setInterval","window","global","require","XMLHttpRequest","fetch","console","debugger","process","document","importScripts","String.raw","Object.prototype","JSON.parse"].some(e=>n.includes(e))}const wt="http://www.w3.org/1999/xlink",Ct="http://www.w3.org/2000/xmlns/",_t="http://www.w3.org/XML/1998/namespace",kt="http://www.w3.org/2000/svg",rt=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",It=n=>{const t=rt(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},at=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},ot=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=B(r);Object.entries(a).forEach(([o,i])=>{n.style[o]=i})},it=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=ct(r);Object.entries(a).forEach(([o,i])=>{i?n.classList.add(o):n.classList.remove(o)})},B=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=B(s);Object.entries(r).forEach(([a,o])=>{t[`${e}-${a}`]=o})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(a=>a.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=B(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},ct=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=ct(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},lt=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},Rt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),lt(e,s,t)}),at(e,t.props,t.loops),it(e,t),ot(e,t),ht(e,n.children,t.children)},At=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":It(t);break;case"slot":break;default:Rt(n,t);break}},Q=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},St=(n,t,e)=>{const s=rt(t),r=document.createTextNode(s);t.elm=r,Q(n,r,e)},$t=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,Q(n,r,e)},Wt=(n,t,e,s)=>{t.tagName==="svg"&&(s=kt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(a=>{const o=t.attrs[a]||"";a.charAt(0)!=="x"?r.setAttribute(a,o):a.startsWith("xml:")?r.setAttributeNS(_t,a,o):a.startsWith("xlink:")?r.setAttributeNS(wt,a,o):a.startsWith("xmlns:")?r.setAttributeNS(Ct,a,o):r.setAttribute(a,o)}),Object.keys(t.on).forEach(a=>{lt(r,a,t)}),at(r,t.props,t.loops),it(r,t),ot(r,t),t.elm=r,Q(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{M(r,a,void 0,s)})},M=(n,t,e,s)=>{switch(t.tagName){case"comment":$t(n,t,e);break;case"text":St(n,t,e);break;default:Wt(n,t,e,s);break}},Ht=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Ot=n=>n&&n.tagName==="Else",C=(n,t,e=[],s=0,r=!0,a=!1)=>{var o,i,u;for(let h=0;h<t.length;h++){const c=t[h];if(c.tagName==="If"){let m=!1;for(((o=c.fn)==null?void 0:o.call(c,e))&&(C(n,c.children,e,s,!1,!0),m=!0);h+1<t.length&&Ht(t[h+1]);)((u=(i=t[h+1]).fn)==null?void 0:u.call(i,e))&&!m&&(C(n,t[h+1].children,e,s,!1,!0),m=!0),h++;h+1<t.length&&Ot(t[h+1])&&(m||(C(n,t[h+1].children,e,s,!1,!0),m=!0),h++)}else if(c.tagName==="For"){const{item:m="item",index:L="index"}=c.attrs;(c.fn(e)||[]).forEach((dt,Y)=>{const jt={item:m,value:dt,index:L,valueIndex:Y};C(n,c.children,[...e,jt],s,!1)})}else{const m={...c,loops:e,children:[],rootId:s,isIf:a};C(m.children,c.children,e),n.push(m)}r&&s++}},ht=(n,t,e)=>{var a,o,i,u,h;let s=0,r=0;for(;s<t.length&&r<e.length;){const c=t[s],m=e[r];c.rootId===m.rootId?(m.isIf?((a=c.elm)==null||a.remove(),M(n,m,(o=t[s+1])==null?void 0:o.elm)):At(c,m),r++,s++):c.rootId>m.rootId?((i=c.elm)==null||i.remove(),s++):(M(n,m,(u=t[s+1])==null?void 0:u.elm),r++)}for(;s<t.length;)(h=t[s].elm)==null||h.remove(),s++;for(;r<e.length;){const c=e[r];M(n,c),r++}},X=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return C(s,t||[],[],0,!0),ht(n,e,s),s},G=n=>typeof n=="object"&&n!=null;function ut(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],a={};return r&&r.split("&").forEach(o=>{const[i,u]=o.split("=");i&&u&&(a[decodeURIComponent(i)]=decodeURIComponent(u))}),{path:s.split("/"),query:a}}const J=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return G(r)&&(r=J(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class xt extends HTMLElement{constructor(){super();E(this,I);E(this,$,{});E(this,W,[]);E(this,H,[]);E(this,_,!1);E(this,O,!1);E(this,k);const e=this._manifest||{};e.template&&typeof e.template=="string"&&d(this,W,et(this,e.template)),e.shadowDOM&&e.shadowDOM.use?d(this,k,this.attachShadow({mode:e.shadowDOM.mode||"open"})):d(this,k,this)}get $data(){let e=w(this,$);return G(e)&&(e=J(e,()=>j(this,I,D).call(this))),e}set $data(e){d(this,$,e||{}),j(this,I,D).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),j(this,I,D).call(this)}onInit(){}disconnectedCallback(){}}$=new WeakMap,W=new WeakMap,H=new WeakMap,_=new WeakMap,O=new WeakMap,k=new WeakMap,I=new WeakSet,D=function(){w(this,_)||(d(this,_,!0),st(()=>{d(this,H,X(w(this,k),w(this,W),w(this,H))),d(this,_,!1),this.isConnected&&!w(this,O)&&(d(this,O,!0),this.onInit())}))};const ft=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=Mt(n),customElements.define(n.tagName,t),t},Mt=n=>(n=Object.assign({hasConfig:!1},n),n);var Tt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,mt=n=>{throw TypeError(n)},Vt=(n,t,e,s)=>{for(var r=s>1?void 0:s?Pt(t,e):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&Tt(t,e,r),r},K=(n,t,e)=>t.has(n)||mt("Cannot "+e),b=(n,t,e)=>(K(n,t,"read from private field"),e?e.call(n):t.get(n)),y=(n,t,e)=>t.has(n)?mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),v=(n,t,e,s)=>(K(n,t,"write to private field"),t.set(n,e),e),Lt=(n,t,e)=>(K(n,t,"access private method"),e),T,P,R,A,S,V,Z,pt;l.RouterViewElement=class extends HTMLElement{constructor(){super(),y(this,Z),y(this,T,[]),y(this,P,[]),y(this,R,null),y(this,A),y(this,S,[]),y(this,V,{})}get isRouterView(){return!0}get $routes(){return b(this,S)}set $routes(t){v(this,S,t),this.onHashChange()}get $remainingPath(){return b(this,P)}get $matchedRoute(){return b(this,R)}set $pipe(t){v(this,V,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",this.onHashChange.bind(this)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",this.onHashChange.bind(this))}onHashChange(){var s;if(!this.isConnected)return;const{path:t}=ut(window.location),e=this.findAncestorWithRouterView(this);e?(v(this,A,e.$remainingPath),v(this,S,((s=e.$matchedRoute)==null?void 0:s.children)||[])):v(this,A,t),Lt(this,Z,pt).call(this)}matchRoute(t,e){for(const s of t){const r=s.path.split("/");let a=!0,o={};for(let i=0;i<r.length;i++){const u=r[i];if(u.startsWith(":"))o[u.substring(1)]=e[i];else if(u==="*"){a=!0;break}else if(u!==e[i]){a=!1;break}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateRoutes(t){for(let e of t.childNodes)if(e.isRouterView){e.onHashChange();continue}else this.propagateRoutes(e)}findAncestorWithRouterView(t){let e=t.parentNode;for(;e;){if(e.isRouterView)return e;e=e.parentElement}return null}},T=new WeakMap,P=new WeakMap,R=new WeakMap,A=new WeakMap,S=new WeakMap,V=new WeakMap,Z=new WeakSet,pt=function(){var u;const n=b(this,A)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(this.$routes,n);v(this,P,s);const r=(t==null?void 0:t.tagName)||"comment",a={},o={};for(const[h,c]of Object.entries(e))a[h]=()=>c;for(const[h,c]of Object.entries(b(this,V)))q.includes(h)||h.startsWith("on-")?o[h.startsWith("on-")?h.slice(3):h.slice(2)]=c:a[h]=()=>c;let i=[{tagName:r,rootId:0,attrs:{},props:a,on:o,children:[]}];((u=b(this,R))==null?void 0:u.tagName)!==r&&(i=[{rootId:0,tagName:"If",attrs:{},props:{},on:{},fn:()=>!0,children:i}]),v(this,T,X(this,i,b(this,T))),v(this,R,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},l.RouterViewElement=Vt([ft({tagName:"router-view"})],l.RouterViewElement),l.BaseElement=xt,l.CustomElement=ft,l.createFunction=z,l.isObject=G,l.listeners=q,l.observe=J,l.parseHashUrl=ut,l.parseHtml=et,l.patch=X,l.runInAsyncQueue=st,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.solely={}))})(this,function(l){"use strict";var gt=l=>{throw TypeError(l)};var et=(l,m,p)=>m.has(l)||gt("Cannot "+p);var C=(l,m,p)=>(et(l,m,"read from private field"),p?p.call(l):m.get(l)),y=(l,m,p)=>m.has(l)?gt("Cannot add the same private member more than once"):m instanceof WeakSet?m.add(l):m.set(l,p),E=(l,m,p,T)=>(et(l,m,"write to private field"),T?T.call(l,p):m.set(l,p),p),j=(l,m,p)=>(et(l,m,"access private method"),p);var x,H,M,I,O,R,A,F;const m=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,T=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],q=/\{\{(.+?)\}\}/g;function vt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function bt(n,t){const e=(t.match(p)||[])[1]||"",s={rootId:0,tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(T);for(;;){const a=r.exec(t);if(a===null)break;if(!a[0].trim())continue;const[o,i]=a[1]?a[1].trim().split("="):[a[2],a[3].trim().slice(1,-1)];if(U.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=st(n,i);else if(o.startsWith("s-")){const u=o.slice(2);switch(u){case"model":s.model=i;break;case"style":s.styles=h=>v(n,i,h);break;case"class":s.classes=h=>v(n,i,h);break;case"readonly":s.props.readOnly=h=>v(n,i,h);break;default:s.props[u]=h=>v(n,i,h);break}}else s.attrs[o]=i;r.lastIndex--}if(e==="For"?s.fn=a=>v(n,s.attrs.each,a):(e==="If"||e==="ElseIf")&&(s.fn=a=>v(n,s.attrs.condition,a)),s.model){const a=s.model.replace("this.","").replace("$data.",""),o=u=>v(n,`$data.${a}`,u),i=u=>st(n,`$data.${a}=${u}`);e==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=o,s.on.change=i("checked")):(s.props.value=o,s.on.input=i("value")):e==="textarea"?(s.props.value=o,s.on.input=i("value")):e==="select"&&(s.props.value=o,s.on.change=i("value"))}return s}function nt(n,t){const e=[];if(!t)return e;t=vt(t);const s=[],r=[],a=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let o=0;return t.replace(m,(i,u)=>{const h=a();if(u>o){const c=t.substring(o,u).trim();if(c){q.lastIndex=0;const g=!q.test(c)?c:N=>c.replace(q,(Y,tt)=>v(n,tt,N));h.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:g,children:[]})}}if(o=u+i.length,i.startsWith("<!--")&&i.endsWith("-->"))h.push({rootId:0,tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const c=r.pop();for(;s.length>0&&s[s.length-1].tagName!==c;)s.pop();s.pop()}else{const c=bt(n,i),f=i.endsWith("/>")||Et.includes(c.tagName);h.push(c),f||(s.push(c),r.push(c.tagName))}return""}),t.length>o&&e.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:t.substring(o).trim(),children:[]}),e}const v=(n,t,e)=>{try{return z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){console.error(s)}},st=(n,t)=>(e,s)=>z(["$data","event","value","checked",...s.map(a=>a.item),...s.map(a=>a.index),t]).bind(n)(n.$data,e,e.target.value,e.target.checked,...s.map(a=>a.value),...s.map(a=>a.valueIndex)),U=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],rt=(()=>{const n=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");n(()=>t(...e))}})(),B={};function z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!B[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(wt(e))throw new Error("Input contains potentially dangerous code: "+e);B[t]=new Function(...n)}return B[t]}const yt=["eval","Function","process","require"];function wt(n){return yt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ct="http://www.w3.org/1999/xlink",_t="http://www.w3.org/2000/xmlns/",kt="http://www.w3.org/XML/1998/namespace",It="http://www.w3.org/2000/svg",at=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",Rt=n=>{const t=at(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},ot=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},it=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=Q(r);Object.entries(a).forEach(([o,i])=>{n.style[o]=i})},ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=lt(r);Object.entries(a).forEach(([o,i])=>{i?n.classList.add(o):n.classList.remove(o)})},Q=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=Q(s);Object.entries(r).forEach(([a,o])=>{t[`${e}-${a}`]=o})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(a=>a.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=Q(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},lt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=lt(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},ht=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},At=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),ht(e,s,t)}),ot(e,t.props,t.loops),ct(e,t),it(e,t),ut(e,n.children,t.children)},St=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":Rt(t);break;case"slot":break;default:At(n,t);break}},G=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},$t=(n,t,e)=>{const s=at(t),r=document.createTextNode(s);t.elm=r,G(n,r,e)},Wt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,G(n,r,e)},xt=(n,t,e,s)=>{t.tagName==="svg"&&(s=It);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(a=>{const o=t.attrs[a]||"";a.charAt(0)!=="x"?r.setAttribute(a,o):a.startsWith("xml:")?r.setAttributeNS(kt,a,o):a.startsWith("xlink:")?r.setAttributeNS(Ct,a,o):a.startsWith("xmlns:")?r.setAttributeNS(_t,a,o):r.setAttribute(a,o)}),Object.keys(t.on).forEach(a=>{ht(r,a,t)}),ot(r,t.props,t.loops),ct(r,t),it(r,t),t.elm=r,G(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{P(r,a,void 0,s)})},P=(n,t,e,s)=>{switch(t.tagName){case"comment":Wt(n,t,e);break;case"text":$t(n,t,e);break;default:xt(n,t,e,s);break}},Ht=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Mt=n=>n&&n.tagName==="Else",_=(n,t,e=[],s=0,r=!0,a)=>{var o,i,u;for(let h=0;h<t.length;h++){const c=t[h];if(c.tagName==="If"){let f=!1,g=1;for(((o=c.fn)==null?void 0:o.call(c,e))&&(_(n,c.children,e,s,!1,g),f=!0),g++;h+1<t.length&&Ht(t[h+1]);)((u=(i=t[h+1]).fn)==null?void 0:u.call(i,e))&&!f&&(_(n,t[h+1].children,e,s,!1,g),f=!0),h++,g++;h+1<t.length&&Mt(t[h+1])&&(f||(_(n,t[h+1].children,e,s,!1,g),f=!0),h++)}else if(c.tagName==="For"){const{item:f="item",index:g="index"}=c.attrs;(c.fn(e)||[]).forEach((Y,tt)=>{const jt={item:f,value:Y,index:g,valueIndex:tt};_(n,c.children,[...e,jt],s,!1)})}else{const f={...c,loops:e,children:[],rootId:s,ifId:a};_(f.children,c.children,e),n.push(f)}r&&s++}},ut=(n,t,e)=>{var a,o,i,u,h;let s=0,r=0;for(;s<t.length&&r<e.length;){const c=t[s],f=e[r];c.rootId===f.rootId?(f.ifId&&c.ifId!==f.ifId?((a=c.elm)==null||a.remove(),P(n,f,(o=t[s+1])==null?void 0:o.elm)):St(c,f),r++,s++):c.rootId>f.rootId?((i=c.elm)==null||i.remove(),s++):(P(n,f,(u=t[s+1])==null?void 0:u.elm),r++)}for(;s<t.length;)(h=t[s].elm)==null||h.remove(),s++;for(;r<e.length;){const c=e[r];P(n,c),r++}},V=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return _(s,t||[],[],0,!0),ut(n,e,s),s},K=n=>typeof n=="object"&&n!=null;function ft(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],a={};return r&&r.split("&").forEach(o=>{const[i,u]=o.split("=");i&&u&&(a[decodeURIComponent(i)]=decodeURIComponent(u))}),{path:s.split("/"),query:a}}const X=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return K(r)&&(r=X(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class Ot extends HTMLElement{constructor(){super();y(this,A);y(this,x,{});y(this,H,[]);y(this,M,[]);y(this,I,!1);y(this,O,!1);y(this,R);const e=this._manifest||{};e.template&&typeof e.template=="string"&&E(this,H,nt(this,e.template)),e.shadowDOM&&e.shadowDOM.use?E(this,R,this.attachShadow({mode:e.shadowDOM.mode||"open"})):E(this,R,this)}get $data(){let e=C(this,x);return K(e)&&(e=X(e,()=>j(this,A,F).call(this))),e}set $data(e){E(this,x,e||{}),j(this,A,F).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),j(this,A,F).call(this)}onInit(){}disconnectedCallback(){}}x=new WeakMap,H=new WeakMap,M=new WeakMap,I=new WeakMap,O=new WeakMap,R=new WeakMap,A=new WeakSet,F=function(){C(this,I)||(E(this,I,!0),rt(()=>{E(this,M,V(C(this,R),C(this,H),C(this,M))),E(this,I,!1),this.isConnected&&!C(this,O)&&(E(this,O,!0),this.onInit())}))};const mt=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=Tt(n),customElements.define(n.tagName,t),t},Tt=n=>(n=Object.assign({hasConfig:!1},n),n);var Pt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,pt=n=>{throw TypeError(n)},Lt=(n,t,e,s)=>{for(var r=s>1?void 0:s?Vt(t,e):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&Pt(t,e,r),r},Z=(n,t,e)=>t.has(n)||pt("Cannot "+e),b=(n,t,e)=>(Z(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,s)=>(Z(n,t,"write to private field"),t.set(n,e),e),Dt=(n,t,e)=>(Z(n,t,"access private method"),e),S,L,$,W,k,D,J,dt;l.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),w(this,J),w(this,S,[]),w(this,L,[]),w(this,$,null),w(this,W),w(this,k,[]),w(this,D,{})}get isRouterView(){return!0}get $routes(){return b(this,k)}set $routes(t){d(this,k,t),this.onHashChange()}get $remainingPath(){return b(this,L)}get $matchedRoute(){return b(this,$)}set $pipe(t){d(this,D,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",this.onHashChange.bind(this)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",this.onHashChange.bind(this))}onHashChange(){var s;if(!this.isConnected)return;const{path:t}=ft(window.location),e=this.findAncestorWithRouterView(this);e?(d(this,W,e.$remainingPath),d(this,k,((s=e.$matchedRoute)==null?void 0:s.children)||[])):d(this,W,t),Dt(this,J,dt).call(this)}matchRoute(t,e){for(const s of t){const r=s.path.split("/");let a=!0;const o={};for(let i=0;i<r.length;i++){const u=r[i];if(u.startsWith(":"))o[u.substring(1)]=e[i];else if(u==="*"){a=!0;break}else if(u!==e[i]){a=!1;break}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateRoutes(t){for(const e of t.childNodes)e.isRouterView?e.onHashChange():this.propagateRoutes(e)}findAncestorWithRouterView(t){let e=t.parentNode;for(;e;){if(e.isRouterView)return e;e=e.parentElement}return null}},S=new WeakMap,L=new WeakMap,$=new WeakMap,W=new WeakMap,k=new WeakMap,D=new WeakMap,J=new WeakSet,dt=function(){var u;const n=b(this,W)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(b(this,k),n);d(this,L,s);const r=(t==null?void 0:t.tagName)||"comment",a={},o={};for(const[h,c]of Object.entries(e))a[h]=()=>c;for(const[h,c]of Object.entries(b(this,D)))U.includes(h)||h.startsWith("on-")?o[h.startsWith("on-")?h.slice(3):h.slice(2)]=c:a[h]=()=>c;const i=[{tagName:r,rootId:0,attrs:{},props:a,on:o,children:[]}];((u=b(this,$))==null?void 0:u.tagName)!==r?(this.innerHTML="",d(this,S,V(this,i,[]))):d(this,S,V(this,i,b(this,S))),d(this,$,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},l.RouterViewElement=Lt([mt({tagName:"router-view"})],l.RouterViewElement),l.BaseElement=Ot,l.CustomElement=mt,l.createFunction=z,l.isObject=K,l.listeners=U,l.observe=X,l.parseHashUrl=ft,l.parseHtml=nt,l.patch=V,l.runInAsyncQueue=rt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type FunctionCreator = (...args:
|
|
2
|
-
export declare function createFunction(args: string[]): FunctionCreator
|
|
1
|
+
export type FunctionCreator<TArgs extends any[], TReturn> = (...args: TArgs) => TReturn;
|
|
2
|
+
export declare function createFunction<TArgs extends any[]>(args: string[]): FunctionCreator<TArgs, any>;
|