@manyducks.co/dolla 2.0.0-alpha.55 → 2.0.0-alpha.56
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/core/context.d.ts +38 -25
- package/dist/core/env.d.ts +2 -8
- package/dist/core/index.d.ts +3 -5
- package/dist/core/logger.d.ts +2 -2
- package/dist/core/markup.d.ts +43 -42
- package/dist/core/mount.d.ts +1 -1
- package/dist/core/nodes/dom.d.ts +6 -6
- package/dist/core/nodes/dynamic.d.ts +13 -15
- package/dist/core/nodes/html.d.ts +9 -21
- package/dist/core/nodes/portal.d.ts +8 -12
- package/dist/core/nodes/repeat.d.ts +13 -18
- package/dist/core/nodes/view.d.ts +10 -23
- package/dist/core/ref.d.ts +2 -6
- package/dist/core/symbols.d.ts +1 -1
- package/dist/core/views/default-crash-view.d.ts +1 -1
- package/dist/core/views/fragment.d.ts +1 -2
- package/dist/fragment-BahD_BJA.js +7 -0
- package/dist/fragment-BahD_BJA.js.map +1 -0
- package/dist/http.js +1 -1
- package/dist/i18n.js +2 -2
- package/dist/index.js +41 -41
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{logger-CXdzxt1e.js → logger-sSxIw5od.js} +100 -100
- package/dist/logger-sSxIw5od.js.map +1 -0
- package/dist/markup-DS7yYBga.js +844 -0
- package/dist/markup-DS7yYBga.js.map +1 -0
- package/dist/router/index.d.ts +1 -1
- package/dist/router/router.d.ts +6 -6
- package/dist/{router-B-rtBG7i.js → router-D43DV_bv.js} +184 -183
- package/dist/router-D43DV_bv.js.map +1 -0
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/{typeChecking-lgllKIVq.js → typeChecking-BJ-ymQ2F.js} +5 -10
- package/dist/{typeChecking-lgllKIVq.js.map → typeChecking-BJ-ymQ2F.js.map} +1 -1
- package/dist/types.d.ts +12 -13
- package/package.json +1 -1
- package/dist/core/nodes/fragment.d.ts +0 -19
- package/dist/core/nodes/outlet.d.ts +0 -19
- package/dist/fragment-VXM-P2tT.js +0 -7
- package/dist/fragment-VXM-P2tT.js.map +0 -1
- package/dist/logger-CXdzxt1e.js.map +0 -1
- package/dist/markup-yTuFdC0t.js +0 -923
- package/dist/markup-yTuFdC0t.js.map +0 -1
- package/dist/router-B-rtBG7i.js.map +0 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var C = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
set _(
|
|
10
|
-
$(n, t,
|
|
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
|
|
13
|
+
return l(n, t, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { f as
|
|
17
|
-
import {
|
|
18
|
-
import { d as
|
|
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-DS7yYBga.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
|
|
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
|
-
|
|
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((
|
|
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 (
|
|
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
|
|
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
|
|
62
|
+
function V(n, t, e = {}) {
|
|
63
63
|
var a;
|
|
64
|
-
const [r,
|
|
65
|
-
t: for (const
|
|
66
|
-
const { fragments: o } =
|
|
67
|
-
if (!(((a = o[o.length - 1]) == null ? void 0 : a.type) === 3) && o.length !==
|
|
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 =
|
|
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:
|
|
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:
|
|
104
|
-
meta:
|
|
103
|
+
query: at(s),
|
|
104
|
+
meta: c.meta
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const t = [], e = [], r = [],
|
|
108
|
+
function ot(n) {
|
|
109
|
+
const t = [], e = [], r = [], s = [];
|
|
110
110
|
for (const a of n) {
|
|
111
|
-
const { fragments:
|
|
112
|
-
|
|
111
|
+
const { fragments: c } = a;
|
|
112
|
+
c.some(
|
|
113
113
|
(o) => o.type === 3
|
|
114
114
|
/* Wildcard */
|
|
115
|
-
) ?
|
|
115
|
+
) ? s.push(a) : c.some(
|
|
116
116
|
(o) => o.type === 4
|
|
117
117
|
/* NumericParam */
|
|
118
|
-
) ? e.push(a) :
|
|
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
|
|
124
|
-
return t.sort(
|
|
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
|
|
126
|
+
function ct(n) {
|
|
127
127
|
const t = x(n), e = [];
|
|
128
128
|
for (let r = 0; r < t.length; r++) {
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
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
|
|
139
|
-
type:
|
|
140
|
-
name:
|
|
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:
|
|
145
|
-
value:
|
|
144
|
+
name: s,
|
|
145
|
+
value: s
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
return e;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
function
|
|
152
|
-
function r(
|
|
153
|
-
return !
|
|
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
|
|
156
|
-
if (
|
|
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(
|
|
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" &&
|
|
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",
|
|
162
|
-
n.removeEventListener("click",
|
|
161
|
+
return n.addEventListener("click", s), function() {
|
|
162
|
+
n.removeEventListener("click", s);
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
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
|
|
173
|
-
var k,
|
|
174
|
-
class
|
|
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,
|
|
178
|
-
w(this,
|
|
177
|
+
w(this, k, Z("dolla.router"));
|
|
178
|
+
w(this, O, 0);
|
|
179
179
|
w(this, R, []);
|
|
180
|
-
w(this,
|
|
181
|
-
w(this,
|
|
182
|
-
|
|
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
|
-
|
|
196
|
+
j(this, "$pattern", E(() => {
|
|
199
197
|
var t;
|
|
200
|
-
return (t =
|
|
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
|
-
|
|
203
|
+
j(this, "$path", E(() => {
|
|
206
204
|
var t;
|
|
207
|
-
return ((t =
|
|
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
|
-
|
|
210
|
+
j(this, "$params", E(() => {
|
|
213
211
|
var t;
|
|
214
|
-
return ((t =
|
|
215
|
-
}, { equals:
|
|
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
|
-
|
|
217
|
+
j(this, "$query", E(() => {
|
|
220
218
|
var t;
|
|
221
|
-
return ((t =
|
|
222
|
-
}, { equals:
|
|
223
|
-
|
|
224
|
-
t.routes.flatMap((e) => d(this, u,
|
|
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:
|
|
225
|
+
fragments: ct(e.pattern)
|
|
228
226
|
}))
|
|
229
|
-
)),
|
|
227
|
+
)), dt(l(this, S));
|
|
230
228
|
}
|
|
231
|
-
async [
|
|
232
|
-
|
|
229
|
+
async [pt](t, e) {
|
|
230
|
+
const r = E();
|
|
231
|
+
$(this, L, {
|
|
233
232
|
id: -1,
|
|
234
|
-
element:
|
|
233
|
+
element: new _(e, r),
|
|
235
234
|
context: e,
|
|
236
|
-
$slot:
|
|
235
|
+
$slot: r
|
|
237
236
|
});
|
|
238
|
-
const
|
|
239
|
-
d(this, u,
|
|
237
|
+
const s = () => {
|
|
238
|
+
d(this, u, U).call(this, void 0, {});
|
|
240
239
|
};
|
|
241
|
-
return window.addEventListener("popstate",
|
|
242
|
-
|
|
243
|
-
let
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
this.go(
|
|
247
|
-
preserveQuery:
|
|
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
|
-
),
|
|
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 [
|
|
253
|
-
for (const t of
|
|
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,
|
|
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 =
|
|
283
|
+
const e = I(l(this, y)), r = { ...this.$query() };
|
|
285
284
|
for (const a in t) {
|
|
286
|
-
const
|
|
287
|
-
|
|
285
|
+
const c = t[a];
|
|
286
|
+
c === null ? delete r[a] : r[a] = c.toString();
|
|
288
287
|
}
|
|
289
|
-
let
|
|
288
|
+
let s = [];
|
|
290
289
|
for (const a in r)
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
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(),
|
|
297
|
-
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
},
|
|
301
|
-
return
|
|
302
|
-
},
|
|
303
|
-
const r =
|
|
304
|
-
for (const
|
|
305
|
-
switch (
|
|
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(`📍 ${
|
|
306
|
+
r == null || r.info(`📍 ${c.message}`);
|
|
308
307
|
break;
|
|
309
308
|
case "redirect":
|
|
310
|
-
r == null || r.info(`↩️ ${
|
|
309
|
+
r == null || r.info(`↩️ ${c.message}`);
|
|
311
310
|
break;
|
|
312
311
|
case "miss":
|
|
313
|
-
r == null || r.info(`💀 ${
|
|
312
|
+
r == null || r.info(`💀 ${c.message}`);
|
|
314
313
|
break;
|
|
315
314
|
}
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
let o =
|
|
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(),
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
333
|
-
return { match:
|
|
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
|
-
|
|
336
|
+
J = function(t) {
|
|
338
337
|
const e = t.meta.layers;
|
|
339
338
|
for (let r = 0; r < e.length; r++) {
|
|
340
|
-
const
|
|
341
|
-
if ((
|
|
342
|
-
$(this, R,
|
|
343
|
-
const a =
|
|
344
|
-
|
|
345
|
-
|
|
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:
|
|
349
|
+
$slot: c
|
|
349
350
|
});
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
|
-
},
|
|
353
|
-
return new Promise((r,
|
|
353
|
+
}, Q = async function(t, e = []) {
|
|
354
|
+
return new Promise((r, s) => {
|
|
354
355
|
var o;
|
|
355
|
-
const
|
|
356
|
-
if (!
|
|
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 =
|
|
362
|
-
const
|
|
362
|
+
let a = i.meta.redirect;
|
|
363
|
+
const c = async () => {
|
|
363
364
|
if (a != null) {
|
|
364
365
|
let f;
|
|
365
|
-
if (
|
|
366
|
-
f =
|
|
366
|
+
if (P(a))
|
|
367
|
+
f = ft(a, i.params);
|
|
367
368
|
else if (N(a)) {
|
|
368
369
|
const p = {
|
|
369
|
-
path:
|
|
370
|
-
pattern:
|
|
371
|
-
params:
|
|
372
|
-
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), !
|
|
375
|
-
return
|
|
376
|
-
f.startsWith("/") || (f = W(
|
|
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
|
|
379
|
+
return s(new TypeError("Redirect must either be a path string or a function."));
|
|
379
380
|
r(
|
|
380
|
-
d(this, u,
|
|
381
|
+
d(this, u, Q).call(this, new URL(f, window.location.origin), [
|
|
381
382
|
...e,
|
|
382
|
-
{ kind: "redirect", message: `redirecting '${
|
|
383
|
+
{ kind: "redirect", message: `redirecting '${i.path}' -> '${f}'` }
|
|
383
384
|
])
|
|
384
385
|
);
|
|
385
386
|
} else
|
|
386
|
-
r({ match:
|
|
387
|
+
r({ match: i, journey: [...e, { kind: "match", message: `matched route '${i.path}'` }] });
|
|
387
388
|
};
|
|
388
|
-
if ((o =
|
|
389
|
-
const f =
|
|
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 ?
|
|
393
|
-
path:
|
|
394
|
-
pattern:
|
|
395
|
-
params:
|
|
396
|
-
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,
|
|
400
|
+
a = h, c();
|
|
400
401
|
},
|
|
401
402
|
next: m
|
|
402
403
|
});
|
|
403
404
|
};
|
|
404
405
|
m();
|
|
405
406
|
} else
|
|
406
|
-
|
|
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
|
-
|
|
415
|
-
if (!
|
|
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
|
|
424
|
+
let s = [];
|
|
424
425
|
for (const o of e)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
const
|
|
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
|
|
431
|
-
pattern: "/" + M([...
|
|
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
|
-
}),
|
|
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
|
|
443
|
+
const c = { id: F(this, O)._++, view: a };
|
|
443
444
|
if (t.routes)
|
|
444
445
|
for (const o of t.routes)
|
|
445
|
-
|
|
446
|
+
i.push(...d(this, u, T).call(this, o, [...e, t], [...r, c]));
|
|
446
447
|
else
|
|
447
|
-
|
|
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,
|
|
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
|
|
456
|
+
return i;
|
|
456
457
|
};
|
|
457
|
-
function
|
|
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 (
|
|
462
|
-
if (e = t.meta.redirect, !
|
|
463
|
-
willMatch(
|
|
464
|
-
return
|
|
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
|
|
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
|
|
482
|
+
class yt extends Error {
|
|
482
483
|
}
|
|
483
484
|
export {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
pt as M,
|
|
486
|
+
kt as R,
|
|
487
|
+
mt as U
|
|
487
488
|
};
|
|
488
|
-
//# sourceMappingURL=router-
|
|
489
|
+
//# sourceMappingURL=router-D43DV_bv.js.map
|