@manyducks.co/dolla 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, C as t, D as n, E as r, M as i, N as a, O as o, P as s, S as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as g, i as _, j as v, k as y, l as b, m as x, n as S, o as C, r as w, s as T, t as E, u as D, v as O, y as k } from "./core-CHBZF6Mb.js";
2
- export { d as ViewNode, m as addStore, r as batch, n as compose, o as createAtom, T as createDebug, y as createEffect, c as createMarkup, w as createPortal, E as createRef, p as createRoot, e as createSetter, v as createStream, _ as forEach, f as getDebug, x as getNearestViewNode, g as getRootElement, h as getStore, u as hideIf, S as html, l as onCleanup, O as onEffect, k as onMount, i as peek, t as render, b as setLogFilter, D as setLogLevel, C as showIf, a as subscribe, s as unwrap };
1
+ import { A as e, C as t, D as n, F as r, M as i, N as a, O as o, P as s, _ as c, a as l, b as u, c as d, d as f, f as p, g as m, h, i as g, j as _, k as v, l as y, m as b, n as x, o as S, p as C, r as w, s as T, t as E, u as D, v as O, w as k, x as A, y as j } from "./core-C4DWUGxz.js";
2
+ export { u as ViewNode, p as addStore, n as batch, o as compose, v as createAtom, T as createDebug, e as createEffect, t as createMarkup, w as createPortal, E as createRef, f as createRoot, _ as createSetter, C as createStore, i as createStream, A as createView, g as forEach, d as getDebug, b as getNearestViewNode, h as getRootElement, m as getStore, l as hideIf, x as html, c as onCleanup, O as onEffect, j as onMount, a as peek, k as render, y as setLogFilter, D as setLogLevel, S as showIf, s as subscribe, r as unwrap };
@@ -1,4 +1,4 @@
1
- import { S as e } from "./core-CHBZF6Mb.js";
1
+ import { C as e } from "./core-C4DWUGxz.js";
2
2
  //#region src/jsx-dev-runtime.js
3
3
  var t = ({ children: e }) => e;
4
4
  function n(t, n, r, i, a, o) {
@@ -1,4 +1,4 @@
1
- import { S as e } from "./core-CHBZF6Mb.js";
1
+ import { C as e } from "./core-C4DWUGxz.js";
2
2
  //#region src/jsx-runtime.js
3
3
  var t = ({ children: e }) => e;
4
4
  function n(t, n, r) {
@@ -1,4 +1,3 @@
1
- import { Context } from "../core";
2
1
  export { createRouter, lazy, Outlet, RedirectError } from "./router";
2
+ export { getRouter } from "./store";
3
3
  export type { RouterOptions } from "./types";
4
- export declare function getRouter(context: Context): import("./types").Router;
@@ -1,4 +1,4 @@
1
- import { type Context, type Getter, type Setter } from "../core";
1
+ import { type Getter, type Setter } from "../core";
2
2
  import type { Router } from "./types";
3
3
  import { type HistoryAdapter, type Match } from "./utils";
4
4
  export interface RouterStoreProps {
@@ -9,4 +9,4 @@ export interface RouterStoreProps {
9
9
  updateRoute: () => void;
10
10
  guards: Set<() => boolean | Promise<boolean>>;
11
11
  }
12
- export declare function RouterStore(this: Context, { currentMatch, setCurrentMatch, progress, history, updateRoute, guards }: RouterStoreProps): Router;
12
+ export declare const addRouter: (context: import("../core").Context, props: RouterStoreProps) => Router, getRouter: (context: import("../core").Context) => Router;
package/dist/router.js CHANGED
@@ -1,9 +1,9 @@
1
- import { B as e, D as t, E as n, F as r, I as i, L as a, M as o, O as s, P as c, R as l, S as u, T as d, _ as f, b as p, c as m, f as h, g, h as _, p as v, w as y, x as b, y as x, z as S } from "./core-CHBZF6Mb.js";
1
+ import { B as e, C as t, D as n, E as r, F as i, I as a, L as o, N as s, O as c, R as l, S as u, T as d, V as f, _ as p, b as m, c as h, h as g, k as _, p as v, s as y, y as b, z as x } from "./core-C4DWUGxz.js";
2
2
  //#region src/router/utils.ts
3
- function C(e) {
3
+ function S(e) {
4
4
  return e.split("/").map((e) => e.trim()).filter(Boolean);
5
5
  }
6
- function w(e) {
6
+ function C(e) {
7
7
  let t = e.map((e) => e.toString()).filter(Boolean).join("/");
8
8
  if (!t) return "";
9
9
  let n = t.startsWith("/"), r = t.split("/"), i = [];
@@ -11,20 +11,20 @@ function w(e) {
11
11
  let a = i.join("/");
12
12
  return n && (a = "/" + a), a || (n ? "/" : "");
13
13
  }
14
- function T(e, t = null) {
15
- return t ?? (t = e, e = ""), t.startsWith("/") ? w([t]) : w([e, t]);
14
+ function w(e, t = null) {
15
+ return t ?? (t = e, e = ""), t.startsWith("/") ? C([t]) : C([e, t]);
16
16
  }
17
- function E(e) {
17
+ function T(e) {
18
18
  return Object.fromEntries(new URLSearchParams(e));
19
19
  }
20
- function D(e, t, n) {
20
+ function E(e, t, n) {
21
21
  let r = {};
22
22
  if (n === !0) Object.assign(r, e);
23
- else if (i(n)) for (let t of n) t in e && (r[t] = e[t]);
23
+ else if (o(n)) for (let t of n) t in e && (r[t] = e[t]);
24
24
  for (let [e, n] of Object.entries(t)) n === null ? delete r[e] : r[e] = n;
25
25
  return new URLSearchParams(r);
26
26
  }
27
- var O = class {
27
+ var D = class {
28
28
  staticChildren = /* @__PURE__ */ new Map();
29
29
  numericChild = null;
30
30
  paramChild = null;
@@ -33,77 +33,77 @@ var O = class {
33
33
  paramName;
34
34
  numericName;
35
35
  };
36
- function k(t) {
37
- let n = new O(), i = [];
38
- function o(e, t) {
39
- let r = C(e), i = n;
40
- for (let e of r) if (e === "*") i = i.wildcardChild ??= new O();
41
- else if (e.charCodeAt(0) === 123) e.charCodeAt(1) === 35 ? (i = i.numericChild ??= new O(), i.numericName = e.slice(2, -1)) : (i = i.paramChild ??= new O(), i.paramName = e.slice(1, -1));
36
+ function O(t) {
37
+ let n = new D(), r = [];
38
+ function i(e, t) {
39
+ let r = S(e), i = n;
40
+ for (let e of r) if (e === "*") i = i.wildcardChild ??= new D();
41
+ else if (e.charCodeAt(0) === 123) e.charCodeAt(1) === 35 ? (i = i.numericChild ??= new D(), i.numericName = e.slice(2, -1)) : (i = i.paramChild ??= new D(), i.paramName = e.slice(1, -1));
42
42
  else {
43
43
  let t = e.toLowerCase(), n = i.staticChildren.get(t);
44
- n || i.staticChildren.set(t, n = new O()), i = n;
44
+ n || i.staticChildren.set(t, n = new D()), i = n;
45
45
  }
46
46
  i.route = t;
47
47
  }
48
- function s(t, n = [], c = []) {
49
- r(l(t) && S(t.path), "Invalid route object");
50
- let u = n.map((e) => e.path), d = n.at(-1), f = d && t.meta ? {
51
- ...d.meta,
48
+ function o(t, n = [], s = []) {
49
+ a(x(t) && e(t.path), "Invalid route object");
50
+ let c = n.map((e) => e.path), u = n.at(-1), d = u && t.meta ? {
51
+ ...u.meta,
52
52
  ...t.meta
53
- } : t.meta || {}, p = u.length ? w([...u, t.path]) : t.path, m = N(p);
53
+ } : t.meta || {}, p = c.length ? C([...c, t.path]) : t.path, m = M(p);
54
54
  if (t.redirect) {
55
- r(!t.routes && !t.view, "Route cannot mix redirect with view/routes");
56
- let e = t.redirect;
57
- S(e) && (e = T(w(u), e), e.startsWith("/") || (e = "/" + e));
55
+ a(!t.routes && !t.view, "Route cannot mix redirect with view/routes");
56
+ let n = t.redirect;
57
+ e(n) && (n = w(C(c), n), n.startsWith("/") || (n = "/" + n));
58
58
  for (let t of m) {
59
- let n = {
59
+ let a = {
60
60
  pattern: t,
61
- meta: f,
62
- redirect: e
61
+ meta: d,
62
+ redirect: n
63
63
  };
64
- o(t, n), S(e) && i.push(n);
64
+ i(t, a), e(n) && r.push(a);
65
65
  }
66
66
  return;
67
67
  }
68
- r(t.view || t.routes, "Route must have view, redirect, or routes");
68
+ a(t.view || t.routes, "Route must have view, redirect, or routes");
69
69
  let h = t.view || ((e) => e.children);
70
- if (!a(h) && !h._lazy) throw TypeError(`Expected view function for ${t.path}`);
70
+ if (!l(h) && !h._lazy) throw TypeError(`Expected view function for ${t.path}`);
71
71
  if (t.routes) {
72
- let r = {
73
- id: e(),
72
+ let e = {
73
+ id: f(),
74
74
  pattern: p,
75
75
  view: h,
76
76
  preload: t.preload,
77
77
  errorView: t.errorView
78
78
  };
79
- for (let e of t.routes) s(e, [...n, t], [...c, r]);
80
- } else for (let n of m) {
81
- let r = {
82
- id: e(),
83
- pattern: n,
79
+ for (let r of t.routes) o(r, [...n, t], [...s, e]);
80
+ } else for (let e of m) {
81
+ let n = {
82
+ id: f(),
83
+ pattern: e,
84
84
  view: h,
85
85
  preload: t.preload,
86
86
  errorView: t.errorView
87
87
  };
88
- o(n, {
89
- pattern: n,
90
- meta: f,
91
- layers: [...c, r]
88
+ i(e, {
89
+ pattern: e,
90
+ meta: d,
91
+ layers: [...s, n]
92
92
  });
93
93
  }
94
94
  }
95
- for (let e of t) s(e);
96
- for (let e of i) r(A(n, e.redirect, { willMatch: (t) => t !== e }), `Dead redirect: ${e.pattern} -> ${e.redirect}`);
95
+ for (let e of t) o(e);
96
+ for (let e of r) a(k(n, e.redirect, { willMatch: (t) => t !== e }), `Dead redirect: ${e.pattern} -> ${e.redirect}`);
97
97
  return n;
98
98
  }
99
- function A(e, t, n = {}) {
100
- let [r, i] = t.split("?"), a = C(r), o = {};
99
+ function k(e, t, n = {}) {
100
+ let [r, i] = t.split("?"), a = S(r), o = {};
101
101
  function s(e, t) {
102
102
  if (t === a.length) return e.route && (!n.willMatch || n.willMatch(e.route)) ? {
103
103
  path: r || "/",
104
104
  pattern: e.route.pattern,
105
105
  params: { ...o },
106
- query: E(i || ""),
106
+ query: T(i || ""),
107
107
  meta: e.route.meta,
108
108
  layers: e.route.layers ?? [],
109
109
  redirect: e.route.redirect
@@ -114,7 +114,7 @@ function A(e, t, n = {}) {
114
114
  ...o,
115
115
  wildcard: "/"
116
116
  },
117
- query: E(i || ""),
117
+ query: T(i || ""),
118
118
  meta: e.wildcardChild.route.meta,
119
119
  layers: e.wildcardChild.route.layers ?? [],
120
120
  redirect: e.wildcardChild.route.redirect
@@ -143,7 +143,7 @@ function A(e, t, n = {}) {
143
143
  ...o,
144
144
  wildcard: "/" + a.slice(t).map(decodeURIComponent).join("/")
145
145
  },
146
- query: E(i || ""),
146
+ query: T(i || ""),
147
147
  meta: e.wildcardChild.route.meta,
148
148
  layers: e.wildcardChild.route.layers ?? [],
149
149
  redirect: e.wildcardChild.route.redirect
@@ -151,28 +151,28 @@ function A(e, t, n = {}) {
151
151
  }
152
152
  return s(e, 0);
153
153
  }
154
- async function j(e, t, n = []) {
155
- let i = A(e, t);
156
- if (!i) return { journey: [...n, {
154
+ async function A(t, n, r = []) {
155
+ let i = k(t, n);
156
+ if (!i) return { journey: [...r, {
157
157
  kind: "miss",
158
- message: `no match for '${t}'`
158
+ message: `no match for '${n}'`
159
159
  }] };
160
160
  if (i.redirect != null) {
161
- let t = i.redirect;
162
- return S(t) ? t = P(t, i.params) : (t = await t(i), r(S(t), "Redirect function must return a path."), t.startsWith("/") || (t = T(i.path, t))), j(e, t, [...n, {
161
+ let n = i.redirect;
162
+ return e(n) ? n = N(n, i.params) : (n = await n(i), a(e(n), "Redirect function must return a path."), n.startsWith("/") || (n = w(i.path, n))), A(t, n, [...r, {
163
163
  kind: "redirect",
164
- message: `redirecting '${i.path}' -> '${t}'`
164
+ message: `redirecting '${i.path}' -> '${n}'`
165
165
  }]);
166
166
  }
167
167
  return {
168
168
  match: i,
169
- journey: [...n, {
169
+ journey: [...r, {
170
170
  kind: "match",
171
171
  message: `matched route '${i.path}'`
172
172
  }]
173
173
  };
174
174
  }
175
- function M(e, t, n = window) {
175
+ function j(e, t, n = window) {
176
176
  function r(r) {
177
177
  if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented) return;
178
178
  let i = r.target.closest("a");
@@ -182,8 +182,8 @@ function M(e, t, n = window) {
182
182
  }
183
183
  return e.addEventListener("click", r), () => e.removeEventListener("click", r);
184
184
  }
185
- function N(e) {
186
- let t = C(e), n = [[]];
185
+ function M(e) {
186
+ let t = S(e), n = [[]];
187
187
  for (let e of t) {
188
188
  let t = e.endsWith("?}"), r = t ? e.replace("?", "") : e;
189
189
  if (t) {
@@ -193,89 +193,85 @@ function N(e) {
193
193
  }
194
194
  return n.map((e) => "/" + e.join("/")).map((e) => e === "/" ? e : e.replace(/\/$/, ""));
195
195
  }
196
- function P(e, t) {
196
+ function N(e, t) {
197
197
  for (let n in t) {
198
198
  let r = String(t[n]);
199
199
  e = e.replace(`{${n}}`, r).replace(`{#${n}}`, r).replace(`{${n}?}`, r).replace(`{#${n}?}`, r);
200
200
  }
201
201
  return e = e.replace(/\{#?[a-zA-Z0-9_]+\?\}/g, ""), e = e.replace(/\/+/g, "/"), e.length > 1 && e.endsWith("/") && (e = e.slice(0, -1)), e;
202
202
  }
203
- function F(t) {
204
- let n = window.history.state?.index || 0;
203
+ function P(e) {
204
+ let t = window.history.state?.index || 0;
205
205
  window.history.state?.index === void 0 && window.history.replaceState({
206
206
  ...window.history.state,
207
207
  key: Date.now().toString(),
208
- index: n
208
+ index: t
209
209
  }, "");
210
- let r = t ? () => window.location.hash.slice(1).split("?")[0] || "/" : () => window.location.pathname, i = t ? () => {
210
+ let n = e ? () => window.location.hash.slice(1).split("?")[0] || "/" : () => window.location.pathname, r = e ? () => {
211
211
  let e = window.location.hash, t = e.indexOf("?");
212
212
  return t === -1 ? "" : e.slice(t);
213
- } : () => window.location.search, a = () => window.history.state?.key || "root";
213
+ } : () => window.location.search, i = () => window.history.state?.key || "root";
214
214
  return {
215
- getPath: r,
216
- getSearch: i,
217
- getKey: a,
215
+ getPath: n,
216
+ getSearch: r,
217
+ getKey: i,
218
218
  getIndex: () => window.history.state?.index || 0,
219
- push: (r) => {
220
- n++;
221
- let i = t ? "/#" : "";
219
+ push: (n) => {
220
+ t++;
221
+ let r = e ? "/#" : "";
222
222
  window.history.pushState({
223
- key: e(),
224
- index: n
225
- }, "", i + r);
223
+ key: f(),
224
+ index: t
225
+ }, "", r + n);
226
226
  },
227
- replace: (e) => {
228
- let r = t ? "/#" : "";
227
+ replace: (n) => {
228
+ let r = e ? "/#" : "";
229
229
  window.history.replaceState({
230
- key: a(),
231
- index: n
232
- }, "", r + e);
230
+ key: i(),
231
+ index: t
232
+ }, "", r + n);
233
233
  }
234
234
  };
235
235
  }
236
236
  //#endregion
237
237
  //#region src/router/store.ts
238
- function I({ currentMatch: e, setCurrentMatch: n, progress: r, history: i, updateRoute: a, guards: s }) {
239
- this.name = "dolla:router";
240
- let l = m(this);
241
- async function u(e, t) {
242
- for (let e of s) if (await e()) return;
243
- l.info(`🗺️ navigating to '${e}'${t ? " (replace)" : ""}`);
244
- let n = T(i.getPath(), e);
245
- t ? i.replace(n) : i.push(n), a();
238
+ var [F, I] = v("dolla:router", (e, t) => {
239
+ let n = h(e), { currentMatch: r, setCurrentMatch: a, progress: o, history: l, updateRoute: u, guards: d } = t;
240
+ async function f(e, t) {
241
+ for (let e of d) if (await e()) return;
242
+ n.info(`🗺️ navigating to '${e}'${t ? " (replace)" : ""}`);
243
+ let r = w(l.getPath(), e);
244
+ t ? l.replace(r) : l.push(r), u();
246
245
  }
247
246
  return {
248
- path: t(() => e().path),
249
- pattern: t(() => e().pattern),
250
- params: t(() => e().params),
251
- query: t(() => e().query),
252
- meta: t(() => e().meta),
253
- progress: r,
254
- setQuery(t) {
255
- let r = o(e), a = D(r.query, t, !0), s = Object.fromEntries(a);
256
- n({
257
- ...r,
258
- query: s
247
+ path: c(() => r().path),
248
+ pattern: c(() => r().pattern),
249
+ params: c(() => r().params),
250
+ query: c(() => r().query),
251
+ meta: c(() => r().meta),
252
+ progress: o,
253
+ setQuery(e) {
254
+ let t = s(r), n = E(t.query, e, !0), i = Object.fromEntries(n);
255
+ a({
256
+ ...t,
257
+ query: i
259
258
  });
260
- let c = a.size ? "?" + a.toString() : "";
261
- return i.replace(r.path + c), s;
259
+ let o = n.size ? "?" + n.toString() : "";
260
+ return l.replace(t.path + o), i;
262
261
  },
263
262
  back: (e = 1) => window.history.go(-e),
264
263
  forward: (e = 1) => window.history.go(e),
265
- push: (e) => u(e, !1),
266
- replace: (e) => u(e, !0),
267
- block: (e) => (s.add(e), () => s.delete(e)),
268
- isActive(n, r = !1) {
269
- return t(() => {
270
- let t = c(n), i = t === "/" ? "/" : t.replace(/\/$/, ""), a = i === "/" ? "/" : i + "/", o = e().path, s = o === "/" ? "/" : o.replace(/\/$/, "");
271
- return r ? s === i : s === i || s.startsWith(a);
264
+ push: (e) => f(e, !1),
265
+ replace: (e) => f(e, !0),
266
+ block: (e) => (d.add(e), () => d.delete(e)),
267
+ isActive(e, t = !1) {
268
+ return c(() => {
269
+ let n = i(e), a = n === "/" ? "/" : n.replace(/\/$/, ""), o = a === "/" ? "/" : a + "/", s = r().path, c = s === "/" ? "/" : s.replace(/\/$/, "");
270
+ return t ? c === a : c === a || c.startsWith(o);
272
271
  });
273
272
  }
274
273
  };
275
- }
276
- //#endregion
277
- //#region src/router/router.ts
278
- var L = Symbol();
274
+ }), L = Symbol.for("$_ROUTER_ROOT_SLOT");
279
275
  function R(e) {
280
276
  return {
281
277
  _lazy: !0,
@@ -283,133 +279,131 @@ function R(e) {
283
279
  };
284
280
  }
285
281
  function z(e) {
286
- return function(t) {
282
+ return function(i) {
287
283
  "scrollRestoration" in window.history && (window.history.scrollRestoration = "manual");
288
- let r = F(!!e.hash), i = /* @__PURE__ */ new Map(), a = r.getKey(), [c, l] = s({
289
- path: r.getPath(),
284
+ let a = P(!!e.hash), o = /* @__PURE__ */ new Map(), c = a.getKey(), [l, f] = _({
285
+ path: a.getPath(),
290
286
  pattern: "",
291
287
  params: {},
292
- query: Object.fromEntries(new URLSearchParams(r.getSearch())),
288
+ query: Object.fromEntries(new URLSearchParams(a.getSearch())),
293
289
  meta: {}
294
- }), [g, S] = s(0), C = k(e.routes), w = /* @__PURE__ */ new Set(), T = v(t);
295
- T.name = "dolla:router";
296
- let E = m(T), [O, A] = s();
297
- t[L] = O;
298
- let N = {
299
- context: t,
300
- slot: O,
301
- setSlot: A
302
- }, R = [];
303
- async function z(f) {
304
- i.set(a, window.scrollY);
305
- let m = f ?? r.getPath(), { match: h, journey: g } = await j(C, m);
306
- if (t[y]) for (let e = 0; e < g.length; e++) {
290
+ }), [h, v] = _(0), x = O(e.routes), S = /* @__PURE__ */ new Set(), C = y("dolla:router"), [w, T] = _();
291
+ i[L] = w;
292
+ let D = {
293
+ context: i,
294
+ slot: w,
295
+ setSlot: T
296
+ }, k = [];
297
+ async function M(u) {
298
+ o.set(c, window.scrollY);
299
+ let p = u ?? a.getPath(), { match: h, journey: g } = await A(x, p);
300
+ if (i[d]) for (let e = 0; e < g.length; e++) {
307
301
  let t = g[e], n = `(update ${e + 1}/${g.length})`;
308
- t.kind === "match" ? E.info(`📍 ${n} ${t.message}`) : t.kind === "redirect" ? E.info(`↩️ ${n} ${t.message}`) : E.info(`💀 ${n} ${t.message}`);
302
+ t.kind === "match" ? C.info(`📍 ${n} ${t.message}`) : t.kind === "redirect" ? C.info(`↩️ ${n} ${t.message}`) : C.info(`💀 ${n} ${t.message}`);
309
303
  }
310
- if (!h) throw Error(`Failed to match route '${m}'`);
311
- let { layers: _, params: v } = h, b = [], x = 0;
312
- for (let e = 0; e < _.length; e++) {
313
- let t = `${_[e].id}:${P(_[e].pattern, v)}`;
314
- b.push(t), x === e && R[e]?.key === t && x++;
304
+ if (!h) throw Error(`Failed to match route '${p}'`);
305
+ let { layers: y, params: b } = h, S = [], w = 0;
306
+ for (let e = 0; e < y.length; e++) {
307
+ let t = `${y[e].id}:${N(y[e].pattern, b)}`;
308
+ S.push(t), w === e && k[e]?.key === t && w++;
315
309
  }
316
- let w = [], T = [];
317
- for (let e = x; e < _.length; e++) {
318
- let t = _[e];
319
- t.preload && w.push(Promise.resolve(t.preload(h)).then((t) => {
320
- T[e - x] = t;
310
+ let T = [], O = [];
311
+ for (let e = w; e < y.length; e++) {
312
+ let t = y[e];
313
+ t.preload && T.push(Promise.resolve(t.preload(h)).then((t) => {
314
+ O[e - w] = t;
321
315
  }));
322
316
  let n = t.view;
323
- n._lazy && w.push(n.load().then((e) => {
317
+ n._lazy && T.push(n.load().then((e) => {
324
318
  t.view = e.default ?? e;
325
319
  }));
326
320
  }
327
- let O = null, k = -1;
328
- if (w.length > 0) {
329
- S(.1);
330
- let e = 0, t = .8 / w.length;
331
- w.forEach((n) => n.then(() => S(.1 + ++e * t)).catch(() => {}));
321
+ let j = null, M = -1;
322
+ if (T.length > 0) {
323
+ v(.1);
324
+ let e = 0, t = .8 / T.length;
325
+ T.forEach((n) => n.then(() => v(.1 + ++e * t)).catch(() => {}));
332
326
  try {
333
- await Promise.all(w);
327
+ await Promise.all(T);
334
328
  } catch (e) {
335
- if (S(0), e instanceof V) return B.replace(e.redirectPath);
336
- O = e instanceof Error ? e : Error(String(e)), k = x;
329
+ if (v(0), e instanceof V) return I.replace(e.redirectPath);
330
+ j = e instanceof Error ? e : Error(String(e)), M = w;
337
331
  }
338
332
  }
339
- let A = D(o(c).query, h.query, e.preserveQuery), M = A.toString(), F = h.path + (M ? `?${M}` : "");
340
- F !== r.getPath() + r.getSearch() && r.replace(F), n(() => {
341
- if (l({
333
+ let P = E(s(l).query, h.query, e.preserveQuery), F = P.toString(), L = h.path + (F ? `?${F}` : "");
334
+ L !== a.getPath() + a.getSearch() && a.replace(L), n(() => {
335
+ if (f({
342
336
  ...h,
343
- query: Object.fromEntries(A)
344
- }), !(x === _.length && R.length === _.length)) {
345
- R[x] && (R[x].node.unmount(), R.length = x);
346
- for (let e = x; e < _.length; e++) {
347
- let t = _[e], n = R[e - 1] ?? N, [r, i] = s(), a = t.view, o = {
348
- data: T[e - x],
349
- children: u(d, { args: [r] })
337
+ query: Object.fromEntries(P)
338
+ }), !(w === y.length && k.length === y.length)) {
339
+ k[w] && (k[w].node.unmount(), k.length = w);
340
+ for (let e = w; e < y.length; e++) {
341
+ let n = y[e], i = k[e - 1] ?? D, [a, o] = _(), s = n.view, c = {
342
+ data: O[e - w],
343
+ children: t(r, { args: [a] })
350
344
  };
351
- if (O && e === k) {
352
- if (!t.errorView) throw O;
353
- a = t.errorView, o = { error: O };
345
+ if (j && e === M) {
346
+ if (!n.errorView) throw j;
347
+ s = n.errorView, c = { error: j };
354
348
  }
355
- let c = new p(n.context, a, o);
356
- if (n.setSlot(c), R.push({
357
- id: t.id,
358
- key: b[e],
359
- node: c,
360
- context: c.context,
361
- slot: r,
362
- setSlot: i
363
- }), O && e === k) break;
349
+ let l = new m(i.context, s, c);
350
+ if (i.setSlot(l), k.push({
351
+ id: n.id,
352
+ key: S[e],
353
+ node: l,
354
+ context: l.context,
355
+ slot: a,
356
+ setSlot: o
357
+ }), j && e === M) break;
364
358
  }
365
359
  }
366
- }), S(0), requestAnimationFrame(() => {
367
- window.scrollTo(0, i.get(r.getKey()) ?? 0), a = r.getKey();
360
+ }), v(0), requestAnimationFrame(() => {
361
+ window.scrollTo(0, o.get(a.getKey()) ?? 0), c = a.getKey();
368
362
  });
369
363
  }
370
- let B = h(t, I, {
371
- currentMatch: c,
372
- setCurrentMatch: l,
373
- progress: g,
374
- history: r,
375
- updateRoute: z,
376
- guards: w
364
+ let I = F(i, {
365
+ currentMatch: l,
366
+ setCurrentMatch: f,
367
+ progress: h,
368
+ history: a,
369
+ updateRoute: M,
370
+ guards: S
377
371
  });
378
- x(t, () => {
379
- let e = !1, n = !1, i = r.getIndex(), a = b(window, "popstate", async () => {
372
+ b(i, () => {
373
+ let e = !1, t = !1, n = a.getIndex(), r = u(window, "popstate", async () => {
380
374
  if (e) {
381
375
  e = !1;
382
376
  return;
383
377
  }
384
- if (n) {
385
- n = !1, i = r.getIndex(), z();
378
+ if (t) {
379
+ t = !1, n = a.getIndex(), M();
386
380
  return;
387
381
  }
388
- let t = r.getIndex(), a = i - t;
389
- if (w.size > 0) {
390
- e = !0, window.history.go(a);
391
- let t = !1;
392
- for (let e of w) if (await e()) {
393
- t = !0;
382
+ let r = a.getIndex(), i = n - r;
383
+ if (S.size > 0) {
384
+ e = !0, window.history.go(i);
385
+ let n = !1;
386
+ for (let e of S) if (await e()) {
387
+ n = !0;
394
388
  break;
395
389
  }
396
- t || (n = !0, window.history.go(-a));
390
+ n || (t = !0, window.history.go(-i));
397
391
  return;
398
392
  }
399
- i = t, z();
400
- }), o = b(window, "beforeunload", (e) => {
401
- w.size > 0 && (e.preventDefault(), e.returnValue = "");
402
- }), s = M(_(t), B.push);
403
- f(t, () => {
404
- a(), o(), s();
405
- }), z();
393
+ n = r, M();
394
+ }), o = u(window, "beforeunload", (e) => {
395
+ S.size > 0 && (e.preventDefault(), e.returnValue = "");
396
+ }), s = j(g(i), I.push);
397
+ p(i, () => {
398
+ r(), o(), s();
399
+ }), M();
406
400
  });
407
401
  };
408
402
  }
409
403
  function B() {
410
404
  this.name = "dolla:router";
411
405
  let e = this[L];
412
- return r(e != null, "Router plugin not found on root."), new d(this, e);
406
+ return a(e != null, "Router plugin not found on root."), new r(this, e);
413
407
  }
414
408
  var V = class extends Error {
415
409
  constructor(e) {
@@ -417,11 +411,6 @@ var V = class extends Error {
417
411
  }
418
412
  };
419
413
  //#endregion
420
- //#region src/router/index.ts
421
- function H(e) {
422
- return g(e, I);
423
- }
424
- //#endregion
425
- export { B as Outlet, V as RedirectError, z as createRouter, H as getRouter, R as lazy };
414
+ export { B as Outlet, V as RedirectError, z as createRouter, I as getRouter, R as lazy };
426
415
 
427
416
  //# sourceMappingURL=router.js.map