solely 0.0.20 → 0.0.23

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