solely 0.0.15 → 0.0.17

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.
@@ -8,14 +8,15 @@ export interface IRouter {
8
8
  }
9
9
  export declare class RouterViewElement extends HTMLElement {
10
10
  #private;
11
+ get isRouterView(): boolean;
11
12
  constructor();
12
- $path?: string[];
13
13
  get $routes(): IRouter[];
14
14
  set $routes(v: IRouter[]);
15
15
  get $remainingPath(): string[];
16
16
  get $matchedRoute(): IRouter | null;
17
17
  set $pipe(v: any);
18
18
  connectedCallback(): void;
19
+ disconnectedCallback(): void;
19
20
  onHashChange(): void;
20
21
  matchRoute(routes: IRouter[], remainingPath: string[]): {
21
22
  matchedRoute: IRouter;
package/dist/solely.js CHANGED
@@ -1,28 +1,28 @@
1
- var B = (e) => {
1
+ var Q = (e) => {
2
2
  throw TypeError(e);
3
3
  };
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) {
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), d = (e, t, n, s) => (V(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), W = (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 mt(e, t) {
11
- const n = (t.match(ht) || [])[1] || "", s = {
10
+ function dt(e, t) {
11
+ const n = (t.match(ut) || [])[1] || "", s = {
12
12
  rootId: 0,
13
13
  tagName: n,
14
14
  attrs: {},
15
15
  props: {},
16
16
  on: {},
17
17
  children: []
18
- }, r = new RegExp(ut);
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
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})`);
24
+ if (J.includes(o) || o.startsWith("on-"))
25
+ s.on[o.startsWith("on-") ? o.slice(3) : o.slice(2)] = X(e, `return (${i})`);
26
26
  else if (o.startsWith("s-")) {
27
27
  const h = o.slice(2);
28
28
  switch (h) {
@@ -47,34 +47,34 @@ function mt(e, t) {
47
47
  r.lastIndex--;
48
48
  }
49
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}`);
50
+ const a = s.model.replace("this.", "").replace("$data.", ""), o = (h) => f(e, `$data.${a}`, h), i = (h) => X(e, `$data.${a}=${h}`);
51
51
  n === "input" ? s.attrs.type === "checkbox" || s.attrs.type === "radio" ? (s.props.checked = o, s.on.change = i("checked")) : (s.props.value = o, s.on.input = i("value")) : n === "textarea" ? (s.props.value = o, s.on.input = i("value")) : n === "select" && (s.props.value = o, s.on.change = i("value"));
52
52
  }
53
53
  return s;
54
54
  }
55
- function dt(e, t) {
55
+ function gt(e, t) {
56
56
  const n = [];
57
57
  if (!t) return n;
58
- t = pt(t);
58
+ t = mt(t);
59
59
  const s = [], r = [], a = () => {
60
60
  var i;
61
61
  return s.length === 0 ? n : (i = s[s.length - 1]).children || (i.children = []);
62
62
  };
63
63
  let o = 0;
64
- return t.replace(lt, (i, h) => {
64
+ return t.replace(ht, (i, h) => {
65
65
  const l = a();
66
66
  if (h > o) {
67
67
  const c = t.substring(o, h).trim();
68
68
  if (c) {
69
- L.lastIndex = 0;
70
- const k = !L.test(c) ? c : (H) => c.replace(L, (z, P) => f(e, P, H));
69
+ F.lastIndex = 0;
70
+ const x = !F.test(c) ? c : (L) => c.replace(F, (B, T) => f(e, T, L));
71
71
  l.push({
72
72
  rootId: 0,
73
73
  tagName: "text",
74
74
  attrs: {},
75
75
  props: {},
76
76
  on: {},
77
- content: k,
77
+ content: x,
78
78
  children: []
79
79
  });
80
80
  }
@@ -95,7 +95,7 @@ function dt(e, t) {
95
95
  s.pop();
96
96
  s.pop();
97
97
  } else {
98
- const c = mt(e, i), u = i.endsWith("/>") || ft.includes(c.tagName);
98
+ const c = dt(e, i), u = i.endsWith("/>") || pt.includes(c.tagName);
99
99
  l.push(c), u || (s.push(c), r.push(c.tagName));
100
100
  }
101
101
  return "";
@@ -111,11 +111,11 @@ function dt(e, t) {
111
111
  }
112
112
  const f = (e, t, n) => {
113
113
  try {
114
- return J(["$data", ...n.map((r) => r.item), `return (${t})`]).bind(e)(e.$data, ...n.map((r) => r.value));
114
+ return K(["$data", ...n.map((r) => r.item), `return (${t})`]).bind(e)(e.$data, ...n.map((r) => r.value));
115
115
  } catch (s) {
116
116
  console.error(s);
117
117
  }
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 = [
118
+ }, X = (e, t) => (n, s) => K(["$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)), J = [
119
119
  "onabort",
120
120
  "onautocomplete",
121
121
  "onautocompleteerror",
@@ -178,28 +178,28 @@ const f = (e, t, n) => {
178
178
  "ontoggle",
179
179
  "onvolumechange",
180
180
  "onwaiting"
181
- ], Et = /* @__PURE__ */ (() => {
181
+ ], vt = /* @__PURE__ */ (() => {
182
182
  const e = typeof requestAnimationFrame == "function" ? (t) => requestAnimationFrame(t) : typeof Promise < "u" ? (t) => Promise.resolve().then(t) : (t) => setTimeout(t, 0);
183
183
  return (t, ...n) => {
184
184
  if (typeof t != "function")
185
185
  throw new Error("runInAsyncQueue expects a function as its first argument");
186
186
  e(() => t(...n));
187
187
  };
188
- })(), F = {};
189
- function J(e) {
188
+ })(), j = {};
189
+ function K(e) {
190
190
  const t = e.join(",");
191
- if (!F[t]) {
191
+ if (!j[t]) {
192
192
  const n = e[e.length - 1];
193
193
  if (n.trim() === "")
194
194
  throw new Error("Function body is empty");
195
- if (vt(n))
195
+ if (Et(n))
196
196
  throw new Error("Input contains potentially dangerous code: " + n);
197
197
  const s = new Function(...e);
198
- F[t] = s;
198
+ j[t] = s;
199
199
  }
200
- return F[t];
200
+ return j[t];
201
201
  }
202
- function vt(e) {
202
+ function Et(e) {
203
203
  return [
204
204
  "eval",
205
205
  "Function",
@@ -220,10 +220,10 @@ function vt(e) {
220
220
  "JSON.parse"
221
221
  ].some((n) => e.includes(n));
222
222
  }
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;
223
+ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/", wt = "http://www.w3.org/XML/1998/namespace", Ct = "http://www.w3.org/2000/svg", Z = (e) => typeof e.content == "function" ? e.content(e.loops || []) : e.content || "", _t = (e) => {
224
+ const t = Z(e), n = e.elm;
225
225
  n.textContent !== t && (n.textContent = t);
226
- }, Z = (e, t, n = []) => {
226
+ }, N = (e, t, n = []) => {
227
227
  Object.keys(t).forEach((s) => {
228
228
  const r = t[s](n);
229
229
  e[s] !== r && (e[s] = r);
@@ -231,7 +231,7 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
231
231
  }, Y = (e, t) => {
232
232
  const { styles: n, loops: s = [] } = t;
233
233
  if (!n) return;
234
- const r = n(s), a = V(r);
234
+ const r = n(s), a = D(r);
235
235
  Object.entries(a).forEach(([o, i]) => {
236
236
  e.style[o] = i;
237
237
  });
@@ -242,11 +242,11 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
242
242
  Object.entries(a).forEach(([o, i]) => {
243
243
  i ? e.classList.add(o) : e.classList.remove(o);
244
244
  });
245
- }, V = (e) => {
245
+ }, D = (e) => {
246
246
  let t = {};
247
247
  return typeof e == "object" && e !== null && !Array.isArray(e) ? Object.entries(e).forEach(([n, s]) => {
248
248
  if (typeof s == "object" && s !== null && !Array.isArray(s)) {
249
- const r = V(s);
249
+ const r = D(s);
250
250
  Object.entries(r).forEach(([a, o]) => {
251
251
  t[`${n}-${a}`] = o;
252
252
  });
@@ -255,7 +255,7 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
255
255
  const [s, r] = n.split(":").map((a) => a.trim());
256
256
  s && r && (t[s] = r);
257
257
  }) : Array.isArray(e) && e.forEach((n) => {
258
- const s = V(n);
258
+ const s = D(n);
259
259
  Object.entries(s).forEach(([r, a]) => {
260
260
  t[r] = a;
261
261
  });
@@ -275,69 +275,69 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
275
275
  }, nt = (e, t, n) => {
276
276
  const s = (r) => n.on[t](r, n.loops || []);
277
277
  e.addEventListener(t, s, !1), n.handlers = n.handlers || {}, n.handlers[t] = s;
278
- }, Ct = (e, t) => {
278
+ }, kt = (e, t) => {
279
279
  const n = t.elm;
280
280
  Object.keys(t.on).forEach((s) => {
281
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);
282
+ }), N(n, t.props, t.loops), tt(n, t), Y(n, t), st(n, e.children, t.children);
283
283
  }, It = (e, t) => {
284
284
  switch (t.elm = e.elm, t.tagName) {
285
285
  case "comment":
286
286
  break;
287
287
  case "text":
288
- $t(t);
288
+ _t(t);
289
289
  break;
290
290
  case "slot":
291
291
  break;
292
292
  default:
293
- Ct(e, t);
293
+ kt(e, t);
294
294
  break;
295
295
  }
296
296
  }, U = (e, t, n) => {
297
297
  n ? e.insertBefore(t, n) : e.appendChild(t);
298
- }, kt = (e, t, n) => {
299
- const s = K(t), r = document.createTextNode(s);
298
+ }, $t = (e, t, n) => {
299
+ const s = Z(t), r = document.createTextNode(s);
300
300
  t.elm = r, U(e, r, n);
301
- }, Rt = (e, t, n) => {
301
+ }, At = (e, t, n) => {
302
302
  const s = t.content, r = document.createComment(s);
303
303
  t.elm = r, U(e, r, n);
304
- }, At = (e, t, n, s) => {
305
- t.tagName === "svg" && (s = wt);
304
+ }, Rt = (e, t, n, s) => {
305
+ t.tagName === "svg" && (s = Ct);
306
306
  const r = s ? document.createElementNS(s, t.tagName) : document.createElement(t.tagName);
307
307
  Object.keys(t.attrs).forEach((a) => {
308
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);
309
+ a.charAt(0) !== "x" ? r.setAttribute(a, o) : a.startsWith("xml:") ? r.setAttributeNS(wt, a, o) : a.startsWith("xlink:") ? r.setAttributeNS(bt, a, o) : a.startsWith("xmlns:") ? r.setAttributeNS(yt, a, o) : r.setAttribute(a, o);
310
310
  }), Object.keys(t.on).forEach((a) => {
311
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);
312
+ }), N(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
+ S(r, a, void 0, s);
314
314
  });
315
- }, R = (e, t, n, s) => {
315
+ }, S = (e, t, n, s) => {
316
316
  switch (t.tagName) {
317
317
  case "comment":
318
- Rt(e, t, n);
318
+ At(e, t, n);
319
319
  break;
320
320
  case "text":
321
- kt(e, t, n);
321
+ $t(e, t, n);
322
322
  break;
323
323
  default:
324
- At(e, t, n, s);
324
+ Rt(e, t, n, s);
325
325
  break;
326
326
  }
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) => {
327
+ }, xt = (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
328
  var o, i, h;
329
329
  for (let l = 0; l < t.length; l++) {
330
330
  const c = t[l];
331
331
  if (c.tagName === "If") {
332
332
  let u = !1;
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++);
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 && xt(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
336
  } else if (c.tagName === "For") {
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);
337
+ const { item: u = "item", index: x = "index" } = c.attrs;
338
+ (c.fn(n) || []).forEach((B, T) => {
339
+ const lt = { item: u, value: B, index: x, valueIndex: T };
340
+ b(e, c.children, [...n, lt], s, !1);
341
341
  });
342
342
  } else {
343
343
  const u = {
@@ -347,7 +347,7 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
347
347
  rootId: s,
348
348
  isIf: a
349
349
  };
350
- v(u.children, c.children, n), e.push(u);
350
+ b(u.children, c.children, n), e.push(u);
351
351
  }
352
352
  r && s++;
353
353
  }
@@ -356,20 +356,20 @@ const bt = "http://www.w3.org/1999/xlink", yt = "http://www.w3.org/2000/xmlns/",
356
356
  let s = 0, r = 0;
357
357
  for (; s < t.length && r < n.length; ) {
358
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++);
359
+ c.rootId === u.rootId ? (u.isIf ? ((a = c.elm) == null || a.remove(), S(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++) : (S(e, u, (h = t[s + 1]) == null ? void 0 : h.elm), r++);
360
360
  }
361
361
  for (; s < t.length; )
362
362
  (l = t[s].elm) == null || l.remove(), s++;
363
363
  for (; r < n.length; ) {
364
364
  const c = n[r];
365
- R(e, c), r++;
365
+ S(e, c), r++;
366
366
  }
367
- }, D = (e, t, n = []) => {
367
+ }, rt = (e, t, n = []) => {
368
368
  if (!t || t.length === 0) return [];
369
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) {
370
+ return b(s, t || [], [], 0, !0), st(e, n, s), s;
371
+ }, at = (e) => typeof e == "object" && e != null;
372
+ function St(e = window.location) {
373
373
  let t;
374
374
  typeof e == "string" ? t = new URL(e).hash : t = e.hash;
375
375
  const n = t.split("?"), s = n[0].substring(2), r = n[1], a = {};
@@ -383,91 +383,97 @@ function Wt(e = window.location) {
383
383
  // 查询参数对象
384
384
  };
385
385
  }
386
- const at = (e, t) => new Proxy(e, {
386
+ const ot = (e, t) => new Proxy(e, {
387
387
  get: (n, s) => {
388
388
  let r = n[s];
389
- return rt(r) && (r = at(r, t)), r;
389
+ return at(r) && (r = ot(r, t)), r;
390
390
  },
391
391
  set: (n, s, r) => (n[s] !== r && (n[s] = r, t(s, r)), !0)
392
392
  });
393
- var C, y, d, _, I, j;
394
- class Vt extends HTMLElement {
393
+ var I, $, A, y, R, w, H;
394
+ class Ft extends HTMLElement {
395
395
  constructor() {
396
396
  super();
397
- g(this, I);
398
- g(this, C, {});
399
- g(this, y, []);
400
- g(this, d, []);
401
- g(this, _, !1);
397
+ m(this, w);
398
+ m(this, I, {});
399
+ m(this, $, []);
400
+ m(this, A, []);
401
+ m(this, y, !1);
402
+ m(this, R, !1);
402
403
  const n = this._manifest || {};
403
- n.template && typeof n.template == "string" && m(this, y, dt(this, n.template));
404
+ n.template && typeof n.template == "string" && d(this, $, gt(this, n.template));
404
405
  }
405
406
  get $data() {
406
- let n = p(this, C);
407
- return rt(n) && (n = at(n, () => M(this, I, j).call(this))), n;
407
+ let n = E(this, I);
408
+ return at(n) && (n = ot(n, () => W(this, w, H).call(this))), n;
408
409
  }
409
410
  set $data(n) {
410
- m(this, C, n || {}), M(this, I, j).call(this);
411
+ d(this, I, n || {}), W(this, w, H).call(this);
411
412
  }
412
413
  connectedCallback() {
413
414
  const n = this._manifest || {};
414
415
  (n.className || n.tagName || "").split(" ").forEach((r) => {
415
- this.classList.add(r);
416
- }), m(this, d, D(this, p(this, y), p(this, d))), this.onInit();
416
+ r && this.classList.add(r);
417
+ }), W(this, w, H).call(this);
417
418
  }
418
419
  onInit() {
419
420
  }
420
421
  disconnectedCallback() {
421
- console.log("disconnectedCallback");
422
422
  }
423
423
  }
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);
424
+ I = new WeakMap(), $ = new WeakMap(), A = new WeakMap(), y = new WeakMap(), R = new WeakMap(), w = new WeakSet(), H = function() {
425
+ E(this, y) || (d(this, y, !0), vt(() => {
426
+ d(this, A, rt(this, E(this, $), E(this, A))), d(this, y, !1), this.isConnected && !E(this, R) && (d(this, R, !0), this.onInit());
427
427
  }));
428
428
  };
429
- const Ot = (e) => (t) => {
429
+ const Ht = (e) => (t) => {
430
430
  if (customElements.get(e.tagName)) {
431
431
  console.warn(`标签名称 "${e.tagName}" 已经被注册`);
432
432
  return;
433
433
  }
434
- return t.prototype._manifest = Ht(e), customElements.define(e.tagName, t), t;
435
- }, Ht = (e) => (e = Object.assign({
434
+ return t.prototype._manifest = Ot(e), customElements.define(e.tagName, t), t;
435
+ }, Ot = (e) => (e = Object.assign({
436
436
  hasConfig: !1
437
437
  }, e), e);
438
- var ot = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, it = (e) => {
438
+ var Mt = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, it = (e) => {
439
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) => {
440
+ }, Lt = (e, t, n, s) => {
441
441
  for (var r = s > 1 ? void 0 : s ? Pt(t, n) : t, a = e.length - 1, o; a >= 0; a--)
442
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;
443
+ return s && r && Mt(t, n, r), r;
444
+ }, z = (e, t, n) => t.has(e) || it("Cannot " + n), v = (e, t, n) => (z(e, t, "read from private field"), n ? n.call(e) : t.get(e)), g = (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), p = (e, t, n, s) => (z(e, t, "write to private field"), t.set(e, n), n), Tt = (e, t, n) => (z(e, t, "access private method"), n), O, M, k, _, C, P, q, ct;
445
445
  let G = class extends HTMLElement {
446
446
  constructor() {
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));
447
+ super(), g(this, q), g(this, O, []), g(this, M, []), g(this, k, null), g(this, _), g(this, C, []), g(this, P, {});
448
+ }
449
+ get isRouterView() {
450
+ return !0;
448
451
  }
449
452
  get $routes() {
450
- return b(this, A);
453
+ return v(this, C);
451
454
  }
452
455
  set $routes(e) {
453
- w(this, A, e), X(this, x, q).call(this);
456
+ p(this, C, e), this.onHashChange();
454
457
  }
455
458
  get $remainingPath() {
456
- return b(this, W);
459
+ return v(this, M);
457
460
  }
458
461
  get $matchedRoute() {
459
- return b(this, $);
462
+ return v(this, k);
460
463
  }
461
464
  set $pipe(e) {
462
- w(this, O, e || {}), X(this, x, q).call(this);
465
+ p(this, P, e || {}), this.onHashChange();
463
466
  }
464
467
  connectedCallback() {
465
- this.onHashChange();
468
+ window.addEventListener("hashchange", this.onHashChange.bind(this)), this.onHashChange();
469
+ }
470
+ disconnectedCallback() {
471
+ window.removeEventListener("hashchange", this.onHashChange.bind(this));
466
472
  }
467
473
  onHashChange() {
468
474
  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);
475
+ const { path: e } = St(window.location), t = this.findAncestorWithRouterView(this);
476
+ t ? (p(this, _, t.$remainingPath), p(this, C, ((n = t.$matchedRoute) == null ? void 0 : n.children) || [])) : p(this, _, e), Tt(this, q, ct).call(this);
471
477
  }
472
478
  matchRoute(e, t) {
473
479
  for (const n of e) {
@@ -501,7 +507,7 @@ let G = class extends HTMLElement {
501
507
  // 向直系后代传播路由
502
508
  propagateRoutes(e) {
503
509
  for (let t of e.childNodes)
504
- if (t.tagName === "ROUTER-VIEW") {
510
+ if (t.isRouterView) {
505
511
  t.onHashChange();
506
512
  continue;
507
513
  } else
@@ -511,28 +517,29 @@ let G = class extends HTMLElement {
511
517
  findAncestorWithRouterView(e) {
512
518
  let t = e.parentNode;
513
519
  for (; t; ) {
514
- if (t.tagName === "ROUTER-VIEW")
520
+ if (t.isRouterView)
515
521
  return t;
516
522
  t = t.parentElement;
517
523
  }
518
524
  return null;
519
525
  }
520
526
  };
521
- S = /* @__PURE__ */ new WeakMap();
522
- W = /* @__PURE__ */ new WeakMap();
523
- $ = /* @__PURE__ */ new WeakMap();
524
- A = /* @__PURE__ */ new WeakMap();
525
527
  O = /* @__PURE__ */ new WeakMap();
526
- x = /* @__PURE__ */ new WeakSet();
527
- q = function() {
528
+ M = /* @__PURE__ */ new WeakMap();
529
+ k = /* @__PURE__ */ new WeakMap();
530
+ _ = /* @__PURE__ */ new WeakMap();
531
+ C = /* @__PURE__ */ new WeakMap();
532
+ P = /* @__PURE__ */ new WeakMap();
533
+ q = /* @__PURE__ */ new WeakSet();
534
+ ct = function() {
528
535
  var h;
529
- const e = this.$path || [], { matchedRoute: t, params: n, remainingPath: s } = this.matchRoute(this.$routes, e);
530
- w(this, W, s);
536
+ const e = v(this, _) || [], { matchedRoute: t, params: n, remainingPath: s } = this.matchRoute(this.$routes, e);
537
+ p(this, M, s);
531
538
  const r = (t == null ? void 0 : t.tagName) || "comment", a = {}, o = {};
532
539
  for (const [l, c] of Object.entries(n))
533
540
  a[l] = () => c;
534
- for (const [l, c] of Object.entries(b(this, O)))
535
- typeof c == "function" ? o[l] = c : a[l] = () => c;
541
+ for (const [l, c] of Object.entries(v(this, P)))
542
+ J.includes(l) || l.startsWith("on-") ? o[l.startsWith("on-") ? l.slice(3) : l.slice(2)] = c : a[l] = () => c;
536
543
  let i = [
537
544
  {
538
545
  tagName: r,
@@ -543,7 +550,7 @@ q = function() {
543
550
  children: []
544
551
  }
545
552
  ];
546
- ((h = b(this, $)) == null ? void 0 : h.tagName) !== r && (i = [{
553
+ ((h = v(this, k)) == null ? void 0 : h.tagName) !== r && (i = [{
547
554
  rootId: 0,
548
555
  tagName: "If",
549
556
  // 带有If标记的ast会被重建
@@ -552,27 +559,27 @@ q = function() {
552
559
  on: {},
553
560
  fn: () => !0,
554
561
  children: i
555
- }]), w(this, S, D(this, i, b(this, S))), w(this, $, t || {
562
+ }]), p(this, O, rt(this, i, v(this, O))), p(this, k, t || {
556
563
  tagName: "comment",
557
564
  path: "",
558
565
  children: []
559
566
  }), this.propagateRoutes(this);
560
567
  };
561
- G = Mt([
562
- Ot({
568
+ G = Lt([
569
+ Ht({
563
570
  tagName: "router-view"
564
571
  })
565
572
  ], G);
566
573
  export {
567
- Vt as BaseElement,
568
- Ot as CustomElement,
574
+ Ft as BaseElement,
575
+ Ht as CustomElement,
569
576
  G as RouterViewElement,
570
- J as createFunction,
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
577
+ K as createFunction,
578
+ at as isObject,
579
+ J as listeners,
580
+ ot as observe,
581
+ St as parseHashUrl,
582
+ gt as parseHtml,
583
+ rt as patch,
584
+ vt as runInAsyncQueue
578
585
  };
@@ -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 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"})});
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 Y=(l,f,p)=>f.has(l)||dt("Cannot "+p);var k=(l,f,p)=>(Y(l,f,"read from private field"),p?p.call(l):f.get(l)),b=(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),y=(l,f,p,O)=>(Y(l,f,"write to private field"),O?O.call(l,p):f.set(l,p),p),L=(l,f,p)=>(Y(l,f,"access private method"),p);var $,S,W,C,H,_,j;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,O=/\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(O);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(D.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=et(n,`return (${i})`);else if(o.startsWith("s-")){const u=o.slice(2);switch(u){case"model":s.model=i;break;case"style":s.styles=h=>d(n,i,h);break;case"class":s.classes=h=>d(n,i,h);break;case"readonly":s.props.readOnly=h=>d(n,i,h);break;default:s.props[u]=h=>d(n,i,h);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=u=>d(n,`$data.${a}`,u),i=u=>et(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 tt(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 x=!F.test(c)?c:Z=>c.replace(F,(pt,N)=>d(n,N,Z));h.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:x,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=vt(n,i),m=i.endsWith("/>")||gt.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 d=(n,t,e)=>{try{return U(["$data",...e.map(r=>r.item),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value))}catch(s){console.error(s)}},et=(n,t)=>(e,s)=>U(["$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)),D=["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"],nt=(()=>{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 U(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(bt(e))throw new Error("Input contains potentially dangerous code: "+e);const s=new Function(...n);q[t]=s}return q[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/",Ct="http://www.w3.org/XML/1998/namespace",_t="http://www.w3.org/2000/svg",st=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",kt=n=>{const t=st(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},rt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},at=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=z(r);Object.entries(a).forEach(([o,i])=>{n.style[o]=i})},ot=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=it(r);Object.entries(a).forEach(([o,i])=>{i?n.classList.add(o):n.classList.remove(o)})},z=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=z(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=z(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),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,a])=>{t[r]=a})}),t},ct=(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),ct(e,s,t)}),rt(e,t.props,t.loops),ot(e,t),at(e,t),lt(e,n.children,t.children)},It=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":kt(t);break;case"slot":break;default:Rt(n,t);break}},B=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},At=(n,t,e)=>{const s=st(t),r=document.createTextNode(s);t.elm=r,B(n,r,e)},$t=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,B(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(Ct,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=>{ct(r,a,t)}),rt(r,t.props,t.loops),ot(r,t),at(r,t),t.elm=r,B(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{T(r,a,void 0,s)})},T=(n,t,e,s)=>{switch(t.tagName){case"comment":$t(n,t,e);break;case"text":At(n,t,e);break;default:St(n,t,e,s);break}},Wt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Ht=n=>n&&n.tagName==="Else",w=(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))&&(w(n,c.children,e,s,!1,!0),m=!0);h+1<t.length&&Wt(t[h+1]);)((u=(i=t[h+1]).fn)==null?void 0:u.call(i,e))&&!m&&(w(n,t[h+1].children,e,s,!1,!0),m=!0),h++;h+1<t.length&&Ht(t[h+1])&&(m||(w(n,t[h+1].children,e,s,!1,!0),m=!0),h++)}else if(c.tagName==="For"){const{item:m="item",index:x="index"}=c.attrs;(c.fn(e)||[]).forEach((pt,N)=>{const Lt={item:m,value:pt,index:x,valueIndex:N};w(n,c.children,[...e,Lt],s,!1)})}else{const m={...c,loops:e,children:[],rootId:s,isIf:a};w(m.children,c.children,e),n.push(m)}r&&s++}},lt=(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(),T(n,m,(o=t[s+1])==null?void 0:o.elm)):It(c,m),r++,s++):c.rootId>m.rootId?((i=c.elm)==null||i.remove(),s++):(T(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];T(n,c),r++}},Q=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return w(s,t||[],[],0,!0),lt(n,e,s),s},X=n=>typeof n=="object"&&n!=null;function ht(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 G=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return X(r)&&(r=G(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class Ot extends HTMLElement{constructor(){super();b(this,_);b(this,$,{});b(this,S,[]);b(this,W,[]);b(this,C,!1);b(this,H,!1);const e=this._manifest||{};e.template&&typeof e.template=="string"&&y(this,S,tt(this,e.template))}get $data(){let e=k(this,$);return X(e)&&(e=G(e,()=>L(this,_,j).call(this))),e}set $data(e){y(this,$,e||{}),L(this,_,j).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),L(this,_,j).call(this)}onInit(){}disconnectedCallback(){}}$=new WeakMap,S=new WeakMap,W=new WeakMap,C=new WeakMap,H=new WeakMap,_=new WeakSet,j=function(){k(this,C)||(y(this,C,!0),nt(()=>{y(this,W,Q(this,k(this,S),k(this,W))),y(this,C,!1),this.isConnected&&!k(this,H)&&(y(this,H,!0),this.onInit())}))};const ut=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 Mt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,ft=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&&Mt(t,e,r),r},J=(n,t,e)=>t.has(n)||ft("Cannot "+e),E=(n,t,e)=>(J(n,t,"read from private field"),e?e.call(n):t.get(n)),v=(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),g=(n,t,e,s)=>(J(n,t,"write to private field"),t.set(n,e),e),xt=(n,t,e)=>(J(n,t,"access private method"),e),M,P,R,I,A,V,K,mt;l.RouterViewElement=class extends HTMLElement{constructor(){super(),v(this,K),v(this,M,[]),v(this,P,[]),v(this,R,null),v(this,I),v(this,A,[]),v(this,V,{})}get isRouterView(){return!0}get $routes(){return E(this,A)}set $routes(t){g(this,A,t),this.onHashChange()}get $remainingPath(){return E(this,P)}get $matchedRoute(){return E(this,R)}set $pipe(t){g(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;const{path:t}=ht(window.location),e=this.findAncestorWithRouterView(this);e?(g(this,I,e.$remainingPath),g(this,A,((s=e.$matchedRoute)==null?void 0:s.children)||[])):g(this,I,t),xt(this,K,mt).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}},M=new WeakMap,P=new WeakMap,R=new WeakMap,I=new WeakMap,A=new WeakMap,V=new WeakMap,K=new WeakSet,mt=function(){var u;const n=E(this,I)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(this.$routes,n);g(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(E(this,V)))D.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=E(this,R))==null?void 0:u.tagName)!==r&&(i=[{rootId:0,tagName:"If",attrs:{},props:{},on:{},fn:()=>!0,children:i}]),g(this,M,Q(this,i,E(this,M))),g(this,R,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},l.RouterViewElement=Vt([ut({tagName:"router-view"})],l.RouterViewElement),l.BaseElement=Ot,l.CustomElement=ut,l.createFunction=U,l.isObject=X,l.listeners=D,l.observe=G,l.parseHashUrl=ht,l.parseHtml=tt,l.patch=Q,l.runInAsyncQueue=nt,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.15",
4
+ "version": "0.0.17",
5
5
  "type": "module",
6
6
  "module": "./dist/solely.js",
7
7
  "types": "./dist/solely.d.ts",
@@ -19,6 +19,7 @@
19
19
  "preview": "vite preview"
20
20
  },
21
21
  "devDependencies": {
22
+ "@types/node": "^22.10.2",
22
23
  "sass": "^1.83.0",
23
24
  "typescript": "~5.6.2",
24
25
  "vite": "^5.4.10",