@manyducks.co/dolla 2.0.0-alpha.55 → 2.0.0-alpha.57

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.
Files changed (49) hide show
  1. package/README.md +5 -2
  2. package/dist/core/context.d.ts +38 -25
  3. package/dist/core/env.d.ts +2 -8
  4. package/dist/core/index.d.ts +3 -5
  5. package/dist/core/logger.d.ts +2 -2
  6. package/dist/core/markup.d.ts +43 -42
  7. package/dist/core/mount.d.ts +1 -1
  8. package/dist/core/nodes/dom.d.ts +6 -6
  9. package/dist/core/nodes/dynamic.d.ts +13 -15
  10. package/dist/core/nodes/html.d.ts +9 -21
  11. package/dist/core/nodes/portal.d.ts +8 -12
  12. package/dist/core/nodes/repeat.d.ts +13 -18
  13. package/dist/core/nodes/view.d.ts +10 -23
  14. package/dist/core/ref.d.ts +2 -6
  15. package/dist/core/symbols.d.ts +1 -1
  16. package/dist/core/views/default-crash-view.d.ts +1 -1
  17. package/dist/core/views/fragment.d.ts +1 -2
  18. package/dist/fragment-BahD_BJA.js +7 -0
  19. package/dist/fragment-BahD_BJA.js.map +1 -0
  20. package/dist/http.js +1 -1
  21. package/dist/i18n.js +2 -2
  22. package/dist/index.js +41 -41
  23. package/dist/index.js.map +1 -1
  24. package/dist/jsx-dev-runtime.d.ts +1 -1
  25. package/dist/jsx-dev-runtime.js +2 -2
  26. package/dist/jsx-runtime.d.ts +2 -2
  27. package/dist/jsx-runtime.js +2 -2
  28. package/dist/{logger-CXdzxt1e.js → logger-sSxIw5od.js} +100 -100
  29. package/dist/logger-sSxIw5od.js.map +1 -0
  30. package/dist/markup-CAJd0zdA.js +937 -0
  31. package/dist/markup-CAJd0zdA.js.map +1 -0
  32. package/dist/router/index.d.ts +1 -1
  33. package/dist/router/router.d.ts +6 -6
  34. package/dist/{router-B-rtBG7i.js → router-ClSFnmRK.js} +184 -183
  35. package/dist/router-ClSFnmRK.js.map +1 -0
  36. package/dist/router.js +1 -1
  37. package/dist/router.js.map +1 -1
  38. package/dist/{typeChecking-lgllKIVq.js → typeChecking-BJ-ymQ2F.js} +5 -10
  39. package/dist/{typeChecking-lgllKIVq.js.map → typeChecking-BJ-ymQ2F.js.map} +1 -1
  40. package/dist/types.d.ts +40 -22
  41. package/package.json +1 -1
  42. package/dist/core/nodes/fragment.d.ts +0 -19
  43. package/dist/core/nodes/outlet.d.ts +0 -19
  44. package/dist/fragment-VXM-P2tT.js +0 -7
  45. package/dist/fragment-VXM-P2tT.js.map +0 -1
  46. package/dist/logger-CXdzxt1e.js.map +0 -1
  47. package/dist/markup-yTuFdC0t.js +0 -923
  48. package/dist/markup-yTuFdC0t.js.map +0 -1
  49. package/dist/router-B-rtBG7i.js.map +0 -1
@@ -1,41 +1,41 @@
1
- var Y = Object.defineProperty;
2
- var F = (n) => {
1
+ var X = Object.defineProperty;
2
+ var C = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var Z = (n, t, e) => t in n ? Y(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var S = (n, t, e) => Z(n, typeof t != "symbol" ? t + "" : t, e), Q = (n, t, e) => t.has(n) || F("Cannot " + e);
7
- var c = (n, t, e) => (Q(n, t, "read from private field"), e ? e.call(n) : t.get(n)), w = (n, t, e) => t.has(n) ? F("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), $ = (n, t, e, r) => (Q(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e), d = (n, t, e) => (Q(n, t, "access private method"), e);
8
- var I = (n, t, e, r) => ({
9
- set _(i) {
10
- $(n, t, i, e);
5
+ var Y = (n, t, e) => t in n ? X(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var j = (n, t, e) => Y(n, typeof t != "symbol" ? t + "" : t, e), G = (n, t, e) => t.has(n) || C("Cannot " + e);
7
+ var l = (n, t, e) => (G(n, t, "read from private field"), e ? e.call(n) : t.get(n)), w = (n, t, e) => t.has(n) ? C("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), $ = (n, t, e, r) => (G(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e), d = (n, t, e) => (G(n, t, "access private method"), e);
8
+ var F = (n, t, e, r) => ({
9
+ set _(s) {
10
+ $(n, t, s, e);
11
11
  },
12
12
  get _() {
13
- return c(n, t, r);
13
+ return l(n, t, r);
14
14
  }
15
15
  });
16
- import { f as _, $ as E, p as K, s as V } from "./logger-CXdzxt1e.js";
17
- import { O as tt, V as et, t as rt } from "./markup-yTuFdC0t.js";
18
- import { d as nt, e as z, c as N, f as st, g as it, i as at, b as j } from "./typeChecking-lgllKIVq.js";
16
+ import { f as Z, $ as E, p as I, s as D } from "./logger-sSxIw5od.js";
17
+ import { D as _, V as tt, m as et } from "./markup-CAJd0zdA.js";
18
+ import { d as rt, e as K, c as N, f as nt, g as it, i as st, b as P } from "./typeChecking-BJ-ymQ2F.js";
19
19
  function x(n) {
20
- return z(n, "Expected `path` to be a string. Got type: %t, value: %v"), n.split("/").map((t) => t.trim()).filter((t) => t !== "");
20
+ return K(n, "Expected `path` to be a string. Got type: %t, value: %v"), n.split("/").map((t) => t.trim()).filter((t) => t !== "");
21
21
  }
22
22
  function M(n) {
23
23
  var e;
24
- nt(
24
+ rt(
25
25
  (r) => N(r == null ? void 0 : r.toString),
26
26
  n,
27
27
  "Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
28
28
  ), n = n.filter((r) => r).flatMap(String);
29
29
  let t = (e = n.shift()) == null ? void 0 : e.toString();
30
30
  if (t) {
31
- for (const r of n.map((i) => i.toString()))
31
+ for (const r of n.map((s) => s.toString()))
32
32
  r.startsWith(".") ? t = W(t, r) : t[t.length - 1] !== "/" ? r[0] !== "/" ? t += "/" + r : t += r : r[0] === "/" ? t += r.slice(1) : t += r;
33
33
  t && t !== "/" && t.endsWith("/") && (t = t.slice(0, t.length - 1));
34
34
  }
35
35
  return t ?? "";
36
36
  }
37
37
  function W(n, t) {
38
- if (z(n, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = n, n = ""), t.startsWith("/"))
38
+ if (K(n, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = n, n = ""), t.startsWith("/"))
39
39
  return t;
40
40
  let e = n;
41
41
  for (; ; )
@@ -51,7 +51,7 @@ function W(n, t) {
51
51
  break;
52
52
  return M([e, t]);
53
53
  }
54
- function ot(n) {
54
+ function at(n) {
55
55
  if (!n) return {};
56
56
  n.startsWith("?") && (n = n.slice(1));
57
57
  const t = n.split("&").filter((e) => e.trim() !== "").map(
@@ -59,16 +59,16 @@ function ot(n) {
59
59
  );
60
60
  return Object.fromEntries(t);
61
61
  }
62
- function D(n, t, e = {}) {
62
+ function V(n, t, e = {}) {
63
63
  var a;
64
- const [r, i] = t.split("?"), s = x(r);
65
- t: for (const l of n) {
66
- const { fragments: o } = l;
67
- if (!(((a = o[o.length - 1]) == null ? void 0 : a.type) === 3) && o.length !== s.length || e.willMatch && !e.willMatch(l))
64
+ const [r, s] = t.split("?"), i = x(r);
65
+ t: for (const c of n) {
66
+ const { fragments: o } = c;
67
+ if (!(((a = o[o.length - 1]) == null ? void 0 : a.type) === 3) && o.length !== i.length || e.willMatch && !e.willMatch(c))
68
68
  continue t;
69
69
  const p = [];
70
70
  e: for (let h = 0; h < o.length; h++) {
71
- const g = s[h], v = o[h];
71
+ const g = i[h], v = o[h];
72
72
  if (g == null && v.type !== 3)
73
73
  continue t;
74
74
  switch (v.type) {
@@ -82,7 +82,7 @@ function D(n, t, e = {}) {
82
82
  p.push({ ...v, value: g });
83
83
  break;
84
84
  case 3:
85
- p.push({ ...v, value: s.slice(h).join("/") });
85
+ p.push({ ...v, value: i.slice(h).join("/") });
86
86
  break e;
87
87
  case 4:
88
88
  if (isNaN(Number(g)))
@@ -100,34 +100,34 @@ function D(n, t, e = {}) {
100
100
  path: "/" + p.map((h) => h.value).join("/"),
101
101
  pattern: "/" + o.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
102
102
  params: m,
103
- query: ot(i),
104
- meta: l.meta
103
+ query: at(s),
104
+ meta: c.meta
105
105
  };
106
106
  }
107
107
  }
108
- function ct(n) {
109
- const t = [], e = [], r = [], i = [];
108
+ function ot(n) {
109
+ const t = [], e = [], r = [], s = [];
110
110
  for (const a of n) {
111
- const { fragments: l } = a;
112
- l.some(
111
+ const { fragments: c } = a;
112
+ c.some(
113
113
  (o) => o.type === 3
114
114
  /* Wildcard */
115
- ) ? i.push(a) : l.some(
115
+ ) ? s.push(a) : c.some(
116
116
  (o) => o.type === 4
117
117
  /* NumericParam */
118
- ) ? e.push(a) : l.some(
118
+ ) ? e.push(a) : c.some(
119
119
  (o) => o.type === 2
120
120
  /* Param */
121
121
  ) ? r.push(a) : t.push(a);
122
122
  }
123
- const s = (a, l) => a.fragments.length > l.fragments.length ? -1 : 1;
124
- return t.sort(s), e.sort(s), r.sort(s), i.sort(s), [...t, ...e, ...r, ...i];
123
+ const i = (a, c) => a.fragments.length > c.fragments.length ? -1 : 1;
124
+ return t.sort(i), e.sort(i), r.sort(i), s.sort(i), [...t, ...e, ...r, ...s];
125
125
  }
126
- function lt(n) {
126
+ function ct(n) {
127
127
  const t = x(n), e = [];
128
128
  for (let r = 0; r < t.length; r++) {
129
- const i = t[r];
130
- if (i === "*") {
129
+ const s = t[r];
130
+ if (s === "*") {
131
131
  if (r !== t.length - 1)
132
132
  throw new Error(`Wildcard must be at the end of a pattern. Received: ${n}`);
133
133
  e.push({
@@ -135,53 +135,51 @@ function lt(n) {
135
135
  name: "*",
136
136
  value: null
137
137
  });
138
- } else i.at(0) === "{" && i.at(-1) === "}" ? e.push({
139
- type: i[1] === "#" ? 4 : 2,
140
- name: i[1] === "#" ? i.slice(2, -1) : i.slice(1, -1),
138
+ } else s.at(0) === "{" && s.at(-1) === "}" ? e.push({
139
+ type: s[1] === "#" ? 4 : 2,
140
+ name: s[1] === "#" ? s.slice(2, -1) : s.slice(1, -1),
141
141
  value: null
142
142
  }) : e.push({
143
143
  type: 1,
144
- name: i,
145
- value: i
144
+ name: s,
145
+ value: s
146
146
  });
147
147
  }
148
148
  return e;
149
149
  }
150
- const ht = /(noopener|noreferrer) (noopener|noreferrer)/, ut = /^[\w-_]+:/;
151
- function ft(n, t, e = window) {
152
- function r(s) {
153
- return !s || s === n ? null : s.localName !== "a" || s.href === void 0 ? r(s.parentNode) : s;
150
+ const lt = /(noopener|noreferrer) (noopener|noreferrer)/, ht = /^[\w-_]+:/;
151
+ function ut(n, t, e = window) {
152
+ function r(i) {
153
+ return !i || i === n ? null : i.localName !== "a" || i.href === void 0 ? r(i.parentNode) : i;
154
154
  }
155
- function i(s) {
156
- if (s.button && s.button !== 0 || s.ctrlKey || s.metaKey || s.altKey || s.shiftKey || s.defaultPrevented)
155
+ function s(i) {
156
+ if (i.button && i.button !== 0 || i.ctrlKey || i.metaKey || i.altKey || i.shiftKey || i.defaultPrevented)
157
157
  return;
158
- const a = r(s.target);
159
- a && (e.location.protocol !== a.protocol || e.location.hostname !== a.hostname || e.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && ht.test(a.getAttribute("rel")) || ut.test(a.getAttribute("href")) || (s.preventDefault(), t(a)));
158
+ const a = r(i.target);
159
+ a && (e.location.protocol !== a.protocol || e.location.hostname !== a.hostname || e.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && lt.test(a.getAttribute("rel")) || ht.test(a.getAttribute("href")) || (i.preventDefault(), t(a)));
160
160
  }
161
- return n.addEventListener("click", i), function() {
162
- n.removeEventListener("click", i);
161
+ return n.addEventListener("click", s), function() {
162
+ n.removeEventListener("click", s);
163
163
  };
164
164
  }
165
- function pt(n, t) {
165
+ function ft(n, t) {
166
166
  for (const e in t) {
167
167
  const r = t[e].toString();
168
168
  n = n.replace(`{${e}}`, r).replace(`{#${e}}`, r);
169
169
  }
170
170
  return n;
171
171
  }
172
- const mt = Symbol(), dt = Symbol();
173
- var k, G, R, L, U, A, O, b, q, y, u, B, H, J, P, X, T, C;
174
- class Rt {
172
+ const pt = Symbol(), mt = Symbol();
173
+ var k, O, R, S, A, L, b, q, y, u, z, B, H, U, J, Q, T;
174
+ class kt {
175
175
  constructor(t) {
176
176
  w(this, u);
177
- w(this, k, _("dolla.router"));
178
- w(this, G, 0);
177
+ w(this, k, Z("dolla.router"));
178
+ w(this, O, 0);
179
179
  w(this, R, []);
180
- w(this, L, []);
181
- w(this, U, !1);
182
- S(this, "$slot", E());
183
- w(this, A, new tt(this.$slot));
184
- w(this, O);
180
+ w(this, S, []);
181
+ w(this, A, !1);
182
+ w(this, L);
185
183
  /**
186
184
  * Use hash routing when true. Configured in router options.
187
185
  */
@@ -195,62 +193,63 @@ class Rt {
195
193
  /**
196
194
  * The currently matched route pattern, if any.
197
195
  */
198
- S(this, "$pattern", E(() => {
196
+ j(this, "$pattern", E(() => {
199
197
  var t;
200
- return (t = c(this, y).call(this)) == null ? void 0 : t.pattern;
198
+ return (t = l(this, y).call(this)) == null ? void 0 : t.pattern;
201
199
  }));
202
200
  /**
203
201
  * The current URL path.
204
202
  */
205
- S(this, "$path", E(() => {
203
+ j(this, "$path", E(() => {
206
204
  var t;
207
- return ((t = c(this, y).call(this)) == null ? void 0 : t.path) ?? window.location.pathname;
205
+ return ((t = l(this, y).call(this)) == null ? void 0 : t.path) ?? window.location.pathname;
208
206
  }));
209
207
  /**
210
208
  * The current named path params.
211
209
  */
212
- S(this, "$params", E(() => {
210
+ j(this, "$params", E(() => {
213
211
  var t;
214
- return ((t = c(this, y).call(this)) == null ? void 0 : t.params) ?? {};
215
- }, { equals: V }));
212
+ return ((t = l(this, y).call(this)) == null ? void 0 : t.params) ?? {};
213
+ }, { equals: D }));
216
214
  /**
217
215
  * The current query params.
218
216
  */
219
- S(this, "$query", E(() => {
217
+ j(this, "$query", E(() => {
220
218
  var t;
221
- return ((t = c(this, y).call(this)) == null ? void 0 : t.query) ?? {};
222
- }, { equals: V }));
223
- st(t, "Options must be an object. Got: %t"), t.hash && $(this, b, !0), $(this, L, ct(
224
- t.routes.flatMap((e) => d(this, u, C).call(this, e)).map((e) => ({
219
+ return ((t = l(this, y).call(this)) == null ? void 0 : t.query) ?? {};
220
+ }, { equals: D }));
221
+ nt(t, "Options must be an object. Got: %t"), t.hash && $(this, b, !0), $(this, S, ot(
222
+ t.routes.flatMap((e) => d(this, u, T).call(this, e)).map((e) => ({
225
223
  pattern: e.pattern,
226
224
  meta: e.meta,
227
- fragments: lt(e.pattern)
225
+ fragments: ct(e.pattern)
228
226
  }))
229
- )), wt(c(this, L));
227
+ )), dt(l(this, S));
230
228
  }
231
- async [mt](t, e) {
232
- $(this, O, {
229
+ async [pt](t, e) {
230
+ const r = E();
231
+ $(this, L, {
233
232
  id: -1,
234
- element: c(this, A),
233
+ element: new _(e, r),
235
234
  context: e,
236
- $slot: this.$slot
235
+ $slot: r
237
236
  });
238
- const r = () => {
239
- d(this, u, P).call(this, void 0, {});
237
+ const s = () => {
238
+ d(this, u, U).call(this, void 0, {});
240
239
  };
241
- return window.addEventListener("popstate", r), c(this, q).push(() => window.removeEventListener("popstate", r)), c(this, q).push(
242
- ft(t, (i) => {
243
- let s = i.getAttribute("href");
244
- c(this, k).info("intercepted click on <a> tag", i);
245
- const a = i.getAttribute("data-router-preserve-query");
246
- this.go(s, {
247
- preserveQuery: yt(a)
240
+ return window.addEventListener("popstate", s), l(this, q).push(() => window.removeEventListener("popstate", s)), l(this, q).push(
241
+ ut(t, (i) => {
242
+ let a = i.getAttribute("href");
243
+ l(this, k).info("intercepted click on <a> tag", i);
244
+ const c = i.getAttribute("data-router-preserve-query");
245
+ this.go(a, {
246
+ preserveQuery: wt(c)
248
247
  });
249
248
  })
250
- ), c(this, k).info("will intercept clicks on <a> tags within root element", t), $(this, U, !0), await d(this, u, P).call(this, void 0, {}), c(this, A);
249
+ ), l(this, k).info("will intercept clicks on <a> tags within root element", t), $(this, A, !0), await d(this, u, U).call(this, void 0, {}), l(this, L).element;
251
250
  }
252
- async [dt]() {
253
- for (const t of c(this, q))
251
+ async [mt]() {
252
+ for (const t of l(this, q))
254
253
  t();
255
254
  $(this, q, []);
256
255
  }
@@ -275,135 +274,137 @@ class Rt {
275
274
  */
276
275
  go(t, e = {}) {
277
276
  let r;
278
- Array.isArray(t) ? r = M(t) : r = t.toString(), r = W(window.location.pathname, r), e.replace ? d(this, u, H).call(this, r, e) : d(this, u, B).call(this, r, e);
277
+ Array.isArray(t) ? r = M(t) : r = t.toString(), r = W(window.location.pathname, r), e.replace ? d(this, u, B).call(this, r, e) : d(this, u, z).call(this, r, e);
279
278
  }
280
279
  /**
281
280
  * Updates query params, keeping existing ones and applying new ones. Removes the query param if value is set to `null`.
282
281
  */
283
282
  updateQuery(t) {
284
- const e = K(c(this, y)), r = { ...this.$query() };
283
+ const e = I(l(this, y)), r = { ...this.$query() };
285
284
  for (const a in t) {
286
- const l = t[a];
287
- l === null ? delete r[a] : r[a] = l.toString();
285
+ const c = t[a];
286
+ c === null ? delete r[a] : r[a] = c.toString();
288
287
  }
289
- let i = [];
288
+ let s = [];
290
289
  for (const a in r)
291
- i.push(`${a}=${r[a]}`);
292
- const s = i.length > 0 ? "?" + i.join("&") : "";
293
- c(this, y).call(this, { ...e, query: r }), window.history.replaceState(null, "", c(this, b) ? "/#" + e.path + s : e.path + s);
290
+ s.push(`${a}=${r[a]}`);
291
+ const i = s.length > 0 ? "?" + s.join("&") : "";
292
+ l(this, y).call(this, { ...e, query: r }), window.history.replaceState(null, "", l(this, b) ? "/#" + e.path + i : e.path + i);
294
293
  }
295
294
  }
296
- k = new WeakMap(), G = new WeakMap(), R = new WeakMap(), L = new WeakMap(), U = new WeakMap(), A = new WeakMap(), O = new WeakMap(), b = new WeakMap(), q = new WeakMap(), y = new WeakMap(), u = new WeakSet(), B = function(t, e) {
297
- c(this, k).info("(push)", t), window.history.pushState(null, "", c(this, b) ? "/#" + t : t), d(this, u, P).call(this, t, e);
298
- }, H = function(t, e) {
299
- c(this, k).info("(replace)", t), window.history.replaceState(null, "", c(this, b) ? "/#" + t : t), d(this, u, P).call(this, t, e);
300
- }, J = function() {
301
- return c(this, b) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
302
- }, P = async function(t, e) {
303
- const r = c(this, k), i = t ? new URL(t, window.location.origin) : d(this, u, J).call(this), { match: s, journey: a } = await d(this, u, T).call(this, i);
304
- for (const l of a)
305
- switch (l.kind) {
295
+ k = new WeakMap(), O = new WeakMap(), R = new WeakMap(), S = new WeakMap(), A = new WeakMap(), L = new WeakMap(), b = new WeakMap(), q = new WeakMap(), y = new WeakMap(), u = new WeakSet(), z = function(t, e) {
296
+ l(this, k).info("(push)", t), window.history.pushState(null, "", l(this, b) ? "/#" + t : t), d(this, u, U).call(this, t, e);
297
+ }, B = function(t, e) {
298
+ l(this, k).info("(replace)", t), window.history.replaceState(null, "", l(this, b) ? "/#" + t : t), d(this, u, U).call(this, t, e);
299
+ }, H = function() {
300
+ return l(this, b) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
301
+ }, U = async function(t, e) {
302
+ const r = l(this, k), s = t ? new URL(t, window.location.origin) : d(this, u, H).call(this), { match: i, journey: a } = await d(this, u, Q).call(this, s);
303
+ for (const c of a)
304
+ switch (c.kind) {
306
305
  case "match":
307
- r == null || r.info(`📍 ${l.message}`);
306
+ r == null || r.info(`📍 ${c.message}`);
308
307
  break;
309
308
  case "redirect":
310
- r == null || r.info(`↩️ ${l.message}`);
309
+ r == null || r.info(`↩️ ${c.message}`);
311
310
  break;
312
311
  case "miss":
313
- r == null || r.info(`💀 ${l.message}`);
312
+ r == null || r.info(`💀 ${c.message}`);
314
313
  break;
315
314
  }
316
- if (s) {
317
- const l = K(this.$pattern);
318
- let o = s.query, f = [];
315
+ if (i) {
316
+ const c = I(this.$pattern);
317
+ let o = i.query, f = [];
319
318
  if (e.preserveQuery === !0)
320
- o = Object.assign({}, this.$query(), s.query);
319
+ o = Object.assign({}, this.$query(), i.query);
321
320
  else if (it(e.preserveQuery)) {
322
321
  const m = {}, h = this.$query();
323
322
  for (const g in h)
324
323
  e.preserveQuery.includes(g) && (m[g] = h[g]);
325
- o = Object.assign({}, m, s.query);
324
+ o = Object.assign({}, m, i.query);
326
325
  }
327
326
  for (const m in o)
328
327
  f.push(`${m}=${o[m]}`);
329
328
  const p = f.length > 0 ? "?" + f.join("&") : "";
330
- c(this, y).call(this, { ...s, query: o }), (s.path !== location.pathname || location.search !== p) && window.history.replaceState(null, "", c(this, b) ? "/#" + s.path + p : s.path + p), s.pattern !== l && d(this, u, X).call(this, s);
329
+ l(this, y).call(this, { ...i, query: o }), (i.path !== location.pathname || location.search !== p) && window.history.replaceState(null, "", l(this, b) ? "/#" + i.path + p : i.path + p), i.pattern !== c && d(this, u, J).call(this, i);
331
330
  } else
332
- c(this, U) && r.crash(new gt(`Failed to match route '${i.pathname}'`));
333
- return { match: s, journey: a };
331
+ l(this, A) && r.crash(new yt(`Failed to match route '${s.pathname}'`));
332
+ return { match: i, journey: a };
334
333
  }, /**
335
334
  * Takes a matched route and mounts it.
336
335
  */
337
- X = function(t) {
336
+ J = function(t) {
338
337
  const e = t.meta.layers;
339
338
  for (let r = 0; r < e.length; r++) {
340
- const i = e[r], s = c(this, R)[r];
341
- if ((s == null ? void 0 : s.id) !== i.id) {
342
- $(this, R, c(this, R).slice(0, r)), s == null || s.element.unmount();
343
- const a = c(this, R).at(-1) ?? c(this, O), l = E(), o = new et(a.context, i.view, {}, rt(l));
344
- a.$slot(o), c(this, R).push({
345
- id: i.id,
339
+ const s = e[r], i = l(this, R)[r];
340
+ if ((i == null ? void 0 : i.id) !== s.id) {
341
+ $(this, R, l(this, R).slice(0, r)), i == null || i.element.unmount();
342
+ const a = l(this, R).at(-1) ?? l(this, L), c = E(), o = new tt(a.context, s.view, {}, [
343
+ et("$dynamic", { source: c })
344
+ ]);
345
+ a.$slot(o), l(this, R).push({
346
+ id: s.id,
346
347
  element: o,
347
348
  context: o.context,
348
- $slot: l
349
+ $slot: c
349
350
  });
350
351
  }
351
352
  }
352
- }, T = async function(t, e = []) {
353
- return new Promise((r, i) => {
353
+ }, Q = async function(t, e = []) {
354
+ return new Promise((r, s) => {
354
355
  var o;
355
- const s = D(c(this, L), t.pathname);
356
- if (!s)
356
+ const i = V(l(this, S), t.pathname);
357
+ if (!i)
357
358
  return r({
358
359
  match: null,
359
360
  journey: [...e, { kind: "miss", message: `no match for '${t.pathname}'` }]
360
361
  });
361
- let a = s.meta.redirect;
362
- const l = async () => {
362
+ let a = i.meta.redirect;
363
+ const c = async () => {
363
364
  if (a != null) {
364
365
  let f;
365
- if (j(a))
366
- f = pt(a, s.params);
366
+ if (P(a))
367
+ f = ft(a, i.params);
367
368
  else if (N(a)) {
368
369
  const p = {
369
- path: s.path,
370
- pattern: s.pattern,
371
- params: s.params,
372
- query: s.query
370
+ path: i.path,
371
+ pattern: i.pattern,
372
+ params: i.params,
373
+ query: i.query
373
374
  };
374
- if (f = await a(p), !j(f))
375
- return i(new Error("Redirect function must return a path to redirect to."));
376
- f.startsWith("/") || (f = W(s.path, f));
375
+ if (f = await a(p), !P(f))
376
+ return s(new Error("Redirect function must return a path to redirect to."));
377
+ f.startsWith("/") || (f = W(i.path, f));
377
378
  } else
378
- return i(new TypeError("Redirect must either be a path string or a function."));
379
+ return s(new TypeError("Redirect must either be a path string or a function."));
379
380
  r(
380
- d(this, u, T).call(this, new URL(f, window.location.origin), [
381
+ d(this, u, Q).call(this, new URL(f, window.location.origin), [
381
382
  ...e,
382
- { kind: "redirect", message: `redirecting '${s.path}' -> '${f}'` }
383
+ { kind: "redirect", message: `redirecting '${i.path}' -> '${f}'` }
383
384
  ])
384
385
  );
385
386
  } else
386
- r({ match: s, journey: [...e, { kind: "match", message: `matched route '${s.path}'` }] });
387
+ r({ match: i, journey: [...e, { kind: "match", message: `matched route '${i.path}'` }] });
387
388
  };
388
- if ((o = s.meta.beforeMatch) != null && o.length) {
389
- const f = s.meta.beforeMatch;
389
+ if ((o = i.meta.beforeMatch) != null && o.length) {
390
+ const f = i.meta.beforeMatch;
390
391
  let p = -1;
391
392
  const m = () => {
392
- p++, p === f.length ? l() : f[p]({
393
- path: s.path,
394
- pattern: s.pattern,
395
- params: s.params,
396
- query: s.query,
393
+ p++, p === f.length ? c() : f[p]({
394
+ path: i.path,
395
+ pattern: i.pattern,
396
+ params: i.params,
397
+ query: i.query,
397
398
  // TODO: Allow setting context variables from here? Would apply to the context of the matched view.
398
399
  redirect: (h) => {
399
- a = h, l();
400
+ a = h, c();
400
401
  },
401
402
  next: m
402
403
  });
403
404
  };
404
405
  m();
405
406
  } else
406
- l();
407
+ c();
407
408
  });
408
409
  }, /**
409
410
  * Parses a route definition object into a set of matchable routes.
@@ -411,8 +412,8 @@ X = function(t) {
411
412
  * @param route - Route config object.
412
413
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
413
414
  */
414
- C = function(t, e = [], r = []) {
415
- if (!at(t) || !j(t.path))
415
+ T = function(t, e = [], r = []) {
416
+ if (!st(t) || !P(t.path))
416
417
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${t}`);
417
418
  if (t.redirect && t.routes)
418
419
  throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
@@ -420,48 +421,48 @@ C = function(t, e = [], r = []) {
420
421
  throw new Error("Route cannot have both a 'redirect' and a 'view'.");
421
422
  if (!t.view && !t.routes && !t.redirect)
422
423
  throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
423
- let i = [];
424
+ let s = [];
424
425
  for (const o of e)
425
- i.push(...x(o.path));
426
- i.push(...x(t.path)), i[i.length - 1] === "*" && i.pop();
427
- const s = [];
426
+ s.push(...x(o.path));
427
+ s.push(...x(t.path)), s[s.length - 1] === "*" && s.pop();
428
+ const i = [];
428
429
  if (t.redirect) {
429
430
  let o = t.redirect;
430
- return j(o) && (o = W(M(i), o), o.startsWith("/") || (o = "/" + o)), s.push({
431
- pattern: "/" + M([...i, ...x(t.path)]),
431
+ return P(o) && (o = W(M(s), o), o.startsWith("/") || (o = "/" + o)), i.push({
432
+ pattern: "/" + M([...s, ...x(t.path)]),
432
433
  meta: {
433
434
  redirect: o
434
435
  }
435
- }), s;
436
+ }), i;
436
437
  }
437
438
  let a = (o) => o.children;
438
439
  if (N(t.view))
439
440
  a = t.view;
440
441
  else if (t.view)
441
442
  throw new TypeError(`Route '${t.path}' expected a view function or undefined. Got: ${t.view}`);
442
- const l = { id: I(this, G)._++, view: a };
443
+ const c = { id: F(this, O)._++, view: a };
443
444
  if (t.routes)
444
445
  for (const o of t.routes)
445
- s.push(...d(this, u, C).call(this, o, [...e, t], [...r, l]));
446
+ i.push(...d(this, u, T).call(this, o, [...e, t], [...r, c]));
446
447
  else
447
- s.push({
448
+ i.push({
448
449
  pattern: parent ? M([...e.map((o) => o.path), t.path]) : t.path,
449
450
  meta: {
450
451
  pattern: t.path,
451
- layers: [...r, l],
452
+ layers: [...r, c],
452
453
  beforeMatch: e.flatMap((o) => o.beforeMatch).concat(t.beforeMatch).filter((o) => o != null)
453
454
  }
454
455
  });
455
- return s;
456
+ return i;
456
457
  };
457
- function wt(n) {
458
+ function dt(n) {
458
459
  for (const t of n)
459
460
  if (t.meta.redirect) {
460
461
  let e;
461
- if (!N(t.meta.redirect)) if (j(t.meta.redirect)) {
462
- if (e = t.meta.redirect, !D(n, e, {
463
- willMatch(i) {
464
- return i !== t;
462
+ if (!N(t.meta.redirect)) if (P(t.meta.redirect)) {
463
+ if (e = t.meta.redirect, !V(n, e, {
464
+ willMatch(s) {
465
+ return s !== t;
465
466
  }
466
467
  }))
467
468
  throw new Error(`Found a redirect to an undefined URL. From '${t.pattern}' to '${t.meta.redirect}'`);
@@ -469,7 +470,7 @@ function wt(n) {
469
470
  throw new TypeError(`Expected a string or redirect function. Got: ${t.meta.redirect}`);
470
471
  }
471
472
  }
472
- function yt(n) {
473
+ function wt(n) {
473
474
  if (n === null)
474
475
  return !1;
475
476
  if (n === !0 || n === !1)
@@ -478,11 +479,11 @@ function yt(n) {
478
479
  return n = n.trim(), n === "" || n === "true" ? !0 : n === "false" ? !1 : n.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
479
480
  throw new Error(`Invalid type for data-router-preserve-query attribute: ${typeof n} (value: ${n})`);
480
481
  }
481
- class gt extends Error {
482
+ class yt extends Error {
482
483
  }
483
484
  export {
484
- mt as M,
485
- Rt as R,
486
- dt as U
485
+ pt as M,
486
+ kt as R,
487
+ mt as U
487
488
  };
488
- //# sourceMappingURL=router-B-rtBG7i.js.map
489
+ //# sourceMappingURL=router-ClSFnmRK.js.map