solely 0.0.14 → 0.0.15

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