@manyducks.co/dolla 2.0.0-alpha.42 → 2.0.0-alpha.44
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/README.md +1 -1
- package/dist/core/signals.d.ts +1 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +258 -255
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{markup-DQdkb3ri.js → markup-aCjkIk4X.js} +244 -233
- package/dist/markup-aCjkIk4X.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/notes/atomic.md +320 -145
- package/package.json +1 -1
- package/dist/markup-DQdkb3ri.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3,19 +3,19 @@ var $t = (a) => {
|
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
5
|
var Bt = (a, t, e) => t in a ? zt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
6
|
-
var w = (a, t, e) => Bt(a, typeof t != "symbol" ? t + "" : t, e),
|
|
7
|
-
var i = (a, t, e) => (
|
|
6
|
+
var w = (a, t, e) => Bt(a, typeof t != "symbol" ? t + "" : t, e), pt = (a, t, e) => t.has(a) || $t("Cannot " + e);
|
|
7
|
+
var i = (a, t, e) => (pt(a, t, "read from private field"), e ? e.call(a) : t.get(a)), u = (a, t, e) => t.has(a) ? $t("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, e), d = (a, t, e, s) => (pt(a, t, "write to private field"), s ? s.call(a, e) : t.set(a, e), e), f = (a, t, e) => (pt(a, t, "access private method"), e);
|
|
8
8
|
var Rt = (a, t, e, s) => ({
|
|
9
|
-
set _(
|
|
10
|
-
d(a, t,
|
|
9
|
+
set _(n) {
|
|
10
|
+
d(a, t, n, e);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
13
|
return i(a, t, s);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { a as Kt, b as
|
|
17
|
-
import { w as
|
|
18
|
-
function
|
|
16
|
+
import { a as Kt, b as Pt, i as A, I as Ft, c as Ot, d as O, s as _t, e as Qt, f as S, g as I, P as Ut, h as Jt, t as St, j as ct, k as Xt, l as Mt, m as xt, S as Yt, n as Tt, o as Lt, p as Zt, V as te, q as ee, r as se, u as re, v as ne } from "./markup-aCjkIk4X.js";
|
|
17
|
+
import { w as Ce, A as De, D as Ie, y as Ve, C as qe, x as Ge, B as We, z as Ae } from "./markup-aCjkIk4X.js";
|
|
18
|
+
function Le(a) {
|
|
19
19
|
return function() {
|
|
20
20
|
if (arguments.length === 1)
|
|
21
21
|
a = arguments[0];
|
|
@@ -25,25 +25,25 @@ function Ne(a) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
function B(a) {
|
|
28
|
-
return
|
|
28
|
+
return Pt(a, "Expected `path` to be a string. Got type: %t, value: %v"), a.split("/").map((t) => t.trim()).filter((t) => t !== "");
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function H(a) {
|
|
31
31
|
var e;
|
|
32
32
|
Kt(
|
|
33
|
-
(s) =>
|
|
33
|
+
(s) => A(s == null ? void 0 : s.toString),
|
|
34
34
|
a,
|
|
35
35
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
36
36
|
), a = a.filter((s) => s).flatMap(String);
|
|
37
37
|
let t = (e = a.shift()) == null ? void 0 : e.toString();
|
|
38
38
|
if (t) {
|
|
39
|
-
for (const s of a.map((
|
|
40
|
-
s.startsWith(".") ? t =
|
|
39
|
+
for (const s of a.map((n) => n.toString()))
|
|
40
|
+
s.startsWith(".") ? t = ht(t, s) : t[t.length - 1] !== "/" ? s[0] !== "/" ? t += "/" + s : t += s : s[0] === "/" ? t += s.slice(1) : t += s;
|
|
41
41
|
t && t !== "/" && t.endsWith("/") && (t = t.slice(0, t.length - 1));
|
|
42
42
|
}
|
|
43
43
|
return t ?? "";
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
45
|
+
function ht(a, t) {
|
|
46
|
+
if (Pt(a, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = a, a = ""), t.startsWith("/"))
|
|
47
47
|
return t;
|
|
48
48
|
let e = a;
|
|
49
49
|
for (; ; )
|
|
@@ -57,27 +57,27 @@ function ct(a, t) {
|
|
|
57
57
|
t = t.replace(/^\.\/?/, "");
|
|
58
58
|
else
|
|
59
59
|
break;
|
|
60
|
-
return
|
|
60
|
+
return H([e, t]);
|
|
61
61
|
}
|
|
62
62
|
function ae(a) {
|
|
63
63
|
if (!a) return {};
|
|
64
64
|
a.startsWith("?") && (a = a.slice(1));
|
|
65
65
|
const t = a.split("&").filter((e) => e.trim() !== "").map((e) => {
|
|
66
|
-
const [s,
|
|
67
|
-
return
|
|
66
|
+
const [s, n] = e.split("=").map((r) => r.trim());
|
|
67
|
+
return n.toLowerCase() === "true" ? [s, !0] : n.toLowerCase() === "false" ? [s, !1] : isNaN(Number(n)) ? [s, n] : [s, Number(n)];
|
|
68
68
|
});
|
|
69
69
|
return Object.fromEntries(t);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function jt(a, t, e = {}) {
|
|
72
72
|
var o;
|
|
73
|
-
const [s,
|
|
73
|
+
const [s, n] = t.split("?"), r = B(s);
|
|
74
74
|
t: for (const c of a) {
|
|
75
75
|
const { fragments: l } = c;
|
|
76
|
-
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !==
|
|
76
|
+
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== r.length || e.willMatch && !e.willMatch(c))
|
|
77
77
|
continue t;
|
|
78
78
|
const b = [];
|
|
79
79
|
e: for (let h = 0; h < l.length; h++) {
|
|
80
|
-
const M =
|
|
80
|
+
const M = r[h], k = l[h];
|
|
81
81
|
if (M == null && k.type !== 3)
|
|
82
82
|
continue t;
|
|
83
83
|
switch (k.type) {
|
|
@@ -91,7 +91,7 @@ function Ct(a, t, e = {}) {
|
|
|
91
91
|
b.push({ ...k, value: M });
|
|
92
92
|
break;
|
|
93
93
|
case 3:
|
|
94
|
-
b.push({ ...k, value:
|
|
94
|
+
b.push({ ...k, value: r.slice(h).join("/") });
|
|
95
95
|
break e;
|
|
96
96
|
case 4:
|
|
97
97
|
if (isNaN(Number(M)))
|
|
@@ -109,19 +109,19 @@ function Ct(a, t, e = {}) {
|
|
|
109
109
|
path: "/" + b.map((h) => h.value).join("/"),
|
|
110
110
|
pattern: "/" + l.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
|
|
111
111
|
params: v,
|
|
112
|
-
query: ae(
|
|
112
|
+
query: ae(n),
|
|
113
113
|
meta: c.meta
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
function ie(a) {
|
|
118
|
-
const t = [], e = [], s = [],
|
|
118
|
+
const t = [], e = [], s = [], n = [];
|
|
119
119
|
for (const o of a) {
|
|
120
120
|
const { fragments: c } = o;
|
|
121
121
|
c.some(
|
|
122
122
|
(l) => l.type === 3
|
|
123
123
|
/* Wildcard */
|
|
124
|
-
) ?
|
|
124
|
+
) ? n.push(o) : c.some(
|
|
125
125
|
(l) => l.type === 4
|
|
126
126
|
/* NumericParam */
|
|
127
127
|
) ? e.push(o) : c.some(
|
|
@@ -129,14 +129,14 @@ function ie(a) {
|
|
|
129
129
|
/* Param */
|
|
130
130
|
) ? s.push(o) : t.push(o);
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
return t.sort(
|
|
132
|
+
const r = (o, c) => o.fragments.length > c.fragments.length ? -1 : 1;
|
|
133
|
+
return t.sort(r), e.sort(r), s.sort(r), n.sort(r), [...t, ...e, ...s, ...n];
|
|
134
134
|
}
|
|
135
135
|
function oe(a) {
|
|
136
136
|
const t = B(a), e = [];
|
|
137
137
|
for (let s = 0; s < t.length; s++) {
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
138
|
+
const n = t[s];
|
|
139
|
+
if (n === "*") {
|
|
140
140
|
if (s !== t.length - 1)
|
|
141
141
|
throw new Error(`Wildcard must be at the end of a pattern. Received: ${a}`);
|
|
142
142
|
e.push({
|
|
@@ -144,42 +144,42 @@ function oe(a) {
|
|
|
144
144
|
name: "*",
|
|
145
145
|
value: null
|
|
146
146
|
});
|
|
147
|
-
} else
|
|
148
|
-
type:
|
|
149
|
-
name:
|
|
147
|
+
} else n.at(0) === "{" && n.at(-1) === "}" ? e.push({
|
|
148
|
+
type: n[1] === "#" ? 4 : 2,
|
|
149
|
+
name: n[1] === "#" ? n.slice(2, -1) : n.slice(1, -1),
|
|
150
150
|
value: null
|
|
151
151
|
}) : e.push({
|
|
152
152
|
type: 1,
|
|
153
|
-
name:
|
|
154
|
-
value:
|
|
153
|
+
name: n,
|
|
154
|
+
value: n
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
return e;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function Ne(a) {
|
|
160
160
|
return new he(a);
|
|
161
161
|
}
|
|
162
|
-
const
|
|
163
|
-
function
|
|
164
|
-
return (a == null ? void 0 : a[
|
|
162
|
+
const Ct = Symbol.for("DollaRouterMountMethod"), Dt = Symbol.for("DollaRouterUnmountMethod");
|
|
163
|
+
function wt(a) {
|
|
164
|
+
return (a == null ? void 0 : a[Ft]) === !0;
|
|
165
165
|
}
|
|
166
166
|
async function le(a, t) {
|
|
167
|
-
return a[
|
|
167
|
+
return a[Ct](t);
|
|
168
168
|
}
|
|
169
169
|
async function ce(a) {
|
|
170
|
-
return a[
|
|
170
|
+
return a[Dt]();
|
|
171
171
|
}
|
|
172
|
-
var
|
|
172
|
+
var Nt, Q, _, ut, x, q, J, U, j, T, m, It, Vt, qt, z, Gt, gt, yt;
|
|
173
173
|
class he {
|
|
174
174
|
constructor(t) {
|
|
175
175
|
u(this, m);
|
|
176
|
-
w(this,
|
|
177
|
-
u(this,
|
|
176
|
+
w(this, Nt, !0);
|
|
177
|
+
u(this, Q);
|
|
178
178
|
u(this, _);
|
|
179
|
-
u(this,
|
|
179
|
+
u(this, ut, 0);
|
|
180
180
|
u(this, x, []);
|
|
181
|
-
u(this,
|
|
182
|
-
u(this,
|
|
181
|
+
u(this, q, []);
|
|
182
|
+
u(this, J, !1);
|
|
183
183
|
/**
|
|
184
184
|
* Use hash routing when true. Configured in router options.
|
|
185
185
|
*/
|
|
@@ -189,7 +189,7 @@ class he {
|
|
|
189
189
|
/**
|
|
190
190
|
* The current match object.
|
|
191
191
|
*/
|
|
192
|
-
u(this, T,
|
|
192
|
+
u(this, T, Ot());
|
|
193
193
|
/**
|
|
194
194
|
* The currently matched route pattern, if any.
|
|
195
195
|
*/
|
|
@@ -218,29 +218,29 @@ class he {
|
|
|
218
218
|
var t;
|
|
219
219
|
return ((t = i(this, T).get()) == null ? void 0 : t.query) ?? {};
|
|
220
220
|
}, { equals: _t }));
|
|
221
|
-
Qt(t, "Options must be an object. Got: %t"), t.hash && d(this, U, !0), d(this,
|
|
221
|
+
Qt(t, "Options must be an object. Got: %t"), t.hash && d(this, U, !0), d(this, q, ie(
|
|
222
222
|
t.routes.flatMap((e) => f(this, m, yt).call(this, e)).map((e) => ({
|
|
223
223
|
pattern: e.pattern,
|
|
224
224
|
meta: e.meta,
|
|
225
225
|
fragments: oe(e.pattern)
|
|
226
226
|
}))
|
|
227
|
-
)), pe(i(this,
|
|
227
|
+
)), pe(i(this, q));
|
|
228
228
|
}
|
|
229
|
-
async [(
|
|
230
|
-
d(this,
|
|
229
|
+
async [(Nt = Ft, Ct)](t) {
|
|
230
|
+
d(this, Q, t), d(this, _, t.createLogger("Dolla.router"));
|
|
231
231
|
const e = () => {
|
|
232
232
|
f(this, m, z).call(this);
|
|
233
233
|
};
|
|
234
234
|
window.addEventListener("popstate", e), i(this, j).push(() => window.removeEventListener("popstate", e));
|
|
235
235
|
const s = t.getRootElement();
|
|
236
236
|
i(this, j).push(
|
|
237
|
-
de(s, (
|
|
238
|
-
let
|
|
239
|
-
i(this, _).info("intercepted click on <a> tag",
|
|
237
|
+
de(s, (n) => {
|
|
238
|
+
let r = n.getAttribute("href");
|
|
239
|
+
i(this, _).info("intercepted click on <a> tag", n), this.go(r);
|
|
240
240
|
})
|
|
241
|
-
), i(this, _).info("will intercept clicks on <a> tags within root element", s), d(this,
|
|
241
|
+
), i(this, _).info("will intercept clicks on <a> tags within root element", s), d(this, J, !0), await f(this, m, z).call(this);
|
|
242
242
|
}
|
|
243
|
-
async [
|
|
243
|
+
async [Dt]() {
|
|
244
244
|
for (const t of i(this, j))
|
|
245
245
|
t();
|
|
246
246
|
d(this, j, []);
|
|
@@ -266,20 +266,20 @@ class he {
|
|
|
266
266
|
*/
|
|
267
267
|
go(t, e = {}) {
|
|
268
268
|
let s;
|
|
269
|
-
Array.isArray(t) ? s =
|
|
269
|
+
Array.isArray(t) ? s = H(t) : s = t.toString(), s = ht(window.location.pathname, s), e.preserveQuery && (s += window.location.search), e.replace ? f(this, m, Vt).call(this, s) : f(this, m, It).call(this, s);
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
Q = new WeakMap(), _ = new WeakMap(), ut = new WeakMap(), x = new WeakMap(), q = new WeakMap(), J = new WeakMap(), U = new WeakMap(), j = new WeakMap(), T = new WeakMap(), m = new WeakSet(), It = function(t, e) {
|
|
273
273
|
var s;
|
|
274
274
|
(s = i(this, _)) == null || s.info("(push)", t), window.history.pushState(e, "", i(this, U) ? "/#" + t : t), f(this, m, z).call(this, t);
|
|
275
|
-
},
|
|
275
|
+
}, Vt = function(t, e) {
|
|
276
276
|
var s;
|
|
277
277
|
(s = i(this, _)) == null || s.info("(replace)", t), window.history.replaceState(e, "", i(this, U) ? "/#" + t : t), f(this, m, z).call(this, t);
|
|
278
278
|
}, qt = function() {
|
|
279
279
|
return i(this, U) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
|
|
280
280
|
}, z = async function(t) {
|
|
281
281
|
var c;
|
|
282
|
-
const e = i(this, _), s = (c = i(this,
|
|
282
|
+
const e = i(this, _), s = (c = i(this, Q)) == null ? void 0 : c.getRootView(), n = t ? new URL(t, window.location.origin) : f(this, m, qt).call(this), { match: r, journey: o } = await f(this, m, gt).call(this, n);
|
|
283
283
|
for (const l of o)
|
|
284
284
|
switch (l.kind) {
|
|
285
285
|
case "match":
|
|
@@ -292,57 +292,57 @@ K = new WeakMap(), _ = new WeakMap(), ht = new WeakMap(), x = new WeakMap(), G =
|
|
|
292
292
|
e == null || e.info(`💀 ${l.message}`);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
|
-
if (
|
|
295
|
+
if (r) {
|
|
296
296
|
const l = this.pattern.peek();
|
|
297
|
-
i(this, T).set(
|
|
297
|
+
i(this, T).set(r), s && r.pattern !== l && f(this, m, Gt).call(this, s, r);
|
|
298
298
|
} else
|
|
299
|
-
i(this,
|
|
300
|
-
return { match:
|
|
299
|
+
i(this, J) && e.crash(new we(`Failed to match route '${n.pathname}'`));
|
|
300
|
+
return { match: r, journey: o };
|
|
301
301
|
}, /**
|
|
302
302
|
* Takes a matched route and mounts it.
|
|
303
303
|
*/
|
|
304
304
|
Gt = function(t, e) {
|
|
305
305
|
const s = e.meta.layers;
|
|
306
|
-
for (let
|
|
307
|
-
const
|
|
308
|
-
if ((o == null ? void 0 : o.id) !==
|
|
309
|
-
d(this, x, i(this, x).slice(0,
|
|
310
|
-
const c = i(this, x).at(-1), p = ((c == null ? void 0 : c.view) ?? t).setChildView(
|
|
311
|
-
i(this, x).push({ id:
|
|
306
|
+
for (let n = 0; n < s.length; n++) {
|
|
307
|
+
const r = s[n], o = i(this, x)[n];
|
|
308
|
+
if ((o == null ? void 0 : o.id) !== r.id) {
|
|
309
|
+
d(this, x, i(this, x).slice(0, n)), o == null || o.view.unmount();
|
|
310
|
+
const c = i(this, x).at(-1), p = ((c == null ? void 0 : c.view) ?? t).setChildView(r.view);
|
|
311
|
+
i(this, x).push({ id: r.id, view: p });
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
}, gt = async function(t, e = []) {
|
|
315
|
-
const s =
|
|
315
|
+
const s = jt(i(this, q), t.pathname);
|
|
316
316
|
if (!s)
|
|
317
317
|
return {
|
|
318
318
|
match: null,
|
|
319
319
|
journey: [...e, { kind: "miss", message: `no match for '${t.pathname}'` }]
|
|
320
320
|
};
|
|
321
|
-
let
|
|
321
|
+
let n = s.meta.redirect;
|
|
322
322
|
if (s.meta.beforeMatch && await s.meta.beforeMatch({
|
|
323
323
|
// TODO: Allow setting context variables from here? Would apply to the context of the matched view.
|
|
324
|
-
redirect: (
|
|
325
|
-
|
|
324
|
+
redirect: (r) => {
|
|
325
|
+
n = r;
|
|
326
326
|
}
|
|
327
|
-
}),
|
|
328
|
-
let
|
|
329
|
-
if (S(
|
|
330
|
-
|
|
331
|
-
else if (
|
|
327
|
+
}), n != null) {
|
|
328
|
+
let r;
|
|
329
|
+
if (S(n))
|
|
330
|
+
r = me(n, s.params);
|
|
331
|
+
else if (A(n)) {
|
|
332
332
|
const o = {
|
|
333
333
|
path: s.path,
|
|
334
334
|
pattern: s.pattern,
|
|
335
335
|
params: s.params,
|
|
336
336
|
query: s.query
|
|
337
337
|
};
|
|
338
|
-
if (
|
|
338
|
+
if (r = await n(o), !S(r))
|
|
339
339
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
340
|
-
|
|
340
|
+
r.startsWith("/") || (r = ht(s.path, r));
|
|
341
341
|
} else
|
|
342
342
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
343
|
-
return f(this, m, gt).call(this, new URL(
|
|
343
|
+
return f(this, m, gt).call(this, new URL(r, window.location.origin), [
|
|
344
344
|
...e,
|
|
345
|
-
{ kind: "redirect", message: `redirecting '${s.path}' -> '${
|
|
345
|
+
{ kind: "redirect", message: `redirecting '${s.path}' -> '${r}'` }
|
|
346
346
|
]);
|
|
347
347
|
} else
|
|
348
348
|
return { match: s, journey: [...e, { kind: "match", message: `matched route '${s.path}'` }] };
|
|
@@ -353,7 +353,7 @@ Gt = function(t, e) {
|
|
|
353
353
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
354
354
|
*/
|
|
355
355
|
yt = function(t, e = [], s = []) {
|
|
356
|
-
if (!
|
|
356
|
+
if (!I(t) || !S(t.path))
|
|
357
357
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${t}`);
|
|
358
358
|
if (t.redirect && t.routes)
|
|
359
359
|
throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
|
|
@@ -361,53 +361,53 @@ yt = function(t, e = [], s = []) {
|
|
|
361
361
|
throw new Error("Route cannot have both a 'redirect' and a 'view'.");
|
|
362
362
|
if (!t.view && !t.routes && !t.redirect)
|
|
363
363
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
364
|
-
let
|
|
364
|
+
let n = [];
|
|
365
365
|
for (const l of e)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
366
|
+
n.push(...B(l.path));
|
|
367
|
+
n.push(...B(t.path)), n[n.length - 1] === "*" && n.pop();
|
|
368
|
+
const r = [];
|
|
369
369
|
if (t.redirect) {
|
|
370
370
|
let l = t.redirect;
|
|
371
|
-
return S(l) && (l =
|
|
372
|
-
pattern: "/" +
|
|
371
|
+
return S(l) && (l = ht(H(n), l), l.startsWith("/") || (l = "/" + l)), r.push({
|
|
372
|
+
pattern: "/" + H([...n, ...B(t.path)]),
|
|
373
373
|
meta: {
|
|
374
374
|
redirect: l
|
|
375
375
|
}
|
|
376
|
-
}),
|
|
376
|
+
}), r;
|
|
377
377
|
}
|
|
378
|
-
let o =
|
|
379
|
-
if (
|
|
378
|
+
let o = Ut;
|
|
379
|
+
if (A(t.view))
|
|
380
380
|
o = t.view;
|
|
381
381
|
else if (t.view)
|
|
382
382
|
throw new TypeError(`Route '${t.path}' expected a view function or undefined. Got: ${t.view}`);
|
|
383
|
-
const c = { id: Rt(this,
|
|
383
|
+
const c = { id: Rt(this, ut)._++, view: o };
|
|
384
384
|
if (t.routes)
|
|
385
385
|
for (const l of t.routes)
|
|
386
|
-
|
|
386
|
+
r.push(...f(this, m, yt).call(this, l, [...e, t], [...s, c]));
|
|
387
387
|
else
|
|
388
|
-
|
|
389
|
-
pattern: parent ?
|
|
388
|
+
r.push({
|
|
389
|
+
pattern: parent ? H([...e.map((l) => l.path), t.path]) : t.path,
|
|
390
390
|
meta: {
|
|
391
391
|
pattern: t.path,
|
|
392
392
|
layers: [...s, c],
|
|
393
393
|
beforeMatch: t.beforeMatch
|
|
394
394
|
}
|
|
395
395
|
});
|
|
396
|
-
return
|
|
396
|
+
return r;
|
|
397
397
|
};
|
|
398
398
|
const ue = /(noopener|noreferrer) (noopener|noreferrer)/, fe = /^[\w-_]+:/;
|
|
399
399
|
function de(a, t, e = window) {
|
|
400
|
-
function s(
|
|
401
|
-
return !
|
|
400
|
+
function s(r) {
|
|
401
|
+
return !r || r === a ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
|
|
402
402
|
}
|
|
403
|
-
function r
|
|
404
|
-
if (
|
|
403
|
+
function n(r) {
|
|
404
|
+
if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
|
|
405
405
|
return;
|
|
406
|
-
const o = s(
|
|
407
|
-
o && (e.location.protocol !== o.protocol || e.location.hostname !== o.hostname || e.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && ue.test(o.getAttribute("rel")) || fe.test(o.getAttribute("href")) || (
|
|
406
|
+
const o = s(r.target);
|
|
407
|
+
o && (e.location.protocol !== o.protocol || e.location.hostname !== o.hostname || e.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && ue.test(o.getAttribute("rel")) || fe.test(o.getAttribute("href")) || (r.preventDefault(), t(o)));
|
|
408
408
|
}
|
|
409
|
-
return a.addEventListener("click",
|
|
410
|
-
a.removeEventListener("click",
|
|
409
|
+
return a.addEventListener("click", n), function() {
|
|
410
|
+
a.removeEventListener("click", n);
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
413
|
function me(a, t) {
|
|
@@ -421,10 +421,10 @@ function pe(a) {
|
|
|
421
421
|
for (const t of a)
|
|
422
422
|
if (t.meta.redirect) {
|
|
423
423
|
let e;
|
|
424
|
-
if (!
|
|
425
|
-
if (e = t.meta.redirect, !
|
|
426
|
-
willMatch(
|
|
427
|
-
return
|
|
424
|
+
if (!A(t.meta.redirect)) if (S(t.meta.redirect)) {
|
|
425
|
+
if (e = t.meta.redirect, !jt(a, e, {
|
|
426
|
+
willMatch(n) {
|
|
427
|
+
return n !== t;
|
|
428
428
|
}
|
|
429
429
|
}))
|
|
430
430
|
throw new Error(`Found a redirect to an undefined URL. From '${t.pattern}' to '${t.meta.redirect}'`);
|
|
@@ -434,12 +434,12 @@ function pe(a) {
|
|
|
434
434
|
}
|
|
435
435
|
class we extends Error {
|
|
436
436
|
}
|
|
437
|
-
var C,
|
|
437
|
+
var C, ft, E, R;
|
|
438
438
|
class ge {
|
|
439
439
|
constructor() {
|
|
440
440
|
u(this, E);
|
|
441
441
|
u(this, C, []);
|
|
442
|
-
u(this,
|
|
442
|
+
u(this, ft, ye());
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
445
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -477,13 +477,13 @@ class ge {
|
|
|
477
477
|
return f(this, E, R).call(this, "trace", t, e);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
C = new WeakMap(),
|
|
480
|
+
C = new WeakMap(), ft = new WeakMap(), E = new WeakSet(), R = async function(t, e, s) {
|
|
481
481
|
return new ke({
|
|
482
482
|
...s,
|
|
483
483
|
method: t,
|
|
484
484
|
uri: e,
|
|
485
485
|
middleware: i(this, C),
|
|
486
|
-
fetch: i(this,
|
|
486
|
+
fetch: i(this, ft)
|
|
487
487
|
}).fetch();
|
|
488
488
|
};
|
|
489
489
|
function ye() {
|
|
@@ -495,7 +495,7 @@ function ye() {
|
|
|
495
495
|
}
|
|
496
496
|
class be extends Error {
|
|
497
497
|
constructor(e) {
|
|
498
|
-
const { status: s, statusText:
|
|
498
|
+
const { status: s, statusText: n, method: r, url: o } = e, c = `${s} ${n}: Request failed (${r.toUpperCase()} ${o.toString()})`;
|
|
499
499
|
super(c);
|
|
500
500
|
w(this, "response");
|
|
501
501
|
this.response = e;
|
|
@@ -518,7 +518,7 @@ class ve {
|
|
|
518
518
|
t.forEach((e, s) => {
|
|
519
519
|
this.headers.set(s, e);
|
|
520
520
|
});
|
|
521
|
-
else if (
|
|
521
|
+
else if (I(t))
|
|
522
522
|
for (const e in t) {
|
|
523
523
|
const s = t[e];
|
|
524
524
|
s instanceof Date ? this.headers.set(e, s.toISOString()) : s != null && this.headers.set(e, String(s));
|
|
@@ -532,7 +532,7 @@ class ve {
|
|
|
532
532
|
t.forEach((e, s) => {
|
|
533
533
|
this.url.searchParams.set(s, e);
|
|
534
534
|
});
|
|
535
|
-
else if (
|
|
535
|
+
else if (I(t))
|
|
536
536
|
for (const e in t) {
|
|
537
537
|
const s = t[e];
|
|
538
538
|
s instanceof Date ? this.url.searchParams.set(e, s.toISOString()) : s != null && this.url.searchParams.set(e, String(s));
|
|
@@ -552,8 +552,8 @@ class ke {
|
|
|
552
552
|
async fetch() {
|
|
553
553
|
if (this._middleware.length > 0) {
|
|
554
554
|
const t = (e = 0) => {
|
|
555
|
-
const s = this._middleware[e],
|
|
556
|
-
return async () => s(this._request, async () => (await
|
|
555
|
+
const s = this._middleware[e], n = this._middleware[e + 1] ? t(e + 1) : this._handler.bind(this);
|
|
556
|
+
return async () => s(this._request, async () => (await n(), this._response));
|
|
557
557
|
};
|
|
558
558
|
await t()();
|
|
559
559
|
} else
|
|
@@ -566,46 +566,46 @@ class ke {
|
|
|
566
566
|
async _handler() {
|
|
567
567
|
let t;
|
|
568
568
|
const e = this._request;
|
|
569
|
-
!e.headers.has("content-type") &&
|
|
569
|
+
!e.headers.has("content-type") && I(e.body) ? (e.headers.set("content-type", "application/json"), t = JSON.stringify(e.body)) : t = e.body;
|
|
570
570
|
const s = await this._fetch(e.url.toString(), {
|
|
571
571
|
method: e.method,
|
|
572
572
|
headers: e.headers,
|
|
573
573
|
body: t
|
|
574
|
-
}),
|
|
575
|
-
let
|
|
576
|
-
|
|
574
|
+
}), n = s.headers.get("content-type");
|
|
575
|
+
let r;
|
|
576
|
+
n != null && n.includes("application/json") ? r = await s.json() : n != null && n.includes("application/x-www-form-urlencoded") ? r = await s.formData() : r = await s.text(), this._response = {
|
|
577
577
|
method: e.method,
|
|
578
578
|
url: e.url,
|
|
579
579
|
status: s.status,
|
|
580
580
|
statusText: s.statusText,
|
|
581
581
|
headers: s.headers,
|
|
582
|
-
body:
|
|
582
|
+
body: r
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
var
|
|
586
|
+
var dt, G, V, bt, Wt;
|
|
587
587
|
class Ee {
|
|
588
588
|
constructor(t, e) {
|
|
589
|
-
u(this,
|
|
589
|
+
u(this, V);
|
|
590
590
|
w(this, "dolla");
|
|
591
591
|
w(this, "config");
|
|
592
|
-
u(this,
|
|
593
|
-
u(this,
|
|
592
|
+
u(this, dt, !1);
|
|
593
|
+
u(this, G, /* @__PURE__ */ new Map());
|
|
594
594
|
this.config = t, this.dolla = e;
|
|
595
595
|
}
|
|
596
596
|
async load() {
|
|
597
597
|
let t;
|
|
598
|
-
if (!i(this,
|
|
599
|
-
if (
|
|
598
|
+
if (!i(this, dt)) {
|
|
599
|
+
if (I(this.config.strings))
|
|
600
600
|
t = this.config.strings;
|
|
601
|
-
else if (
|
|
602
|
-
if (t = await this.config.fetch(), !
|
|
601
|
+
else if (A(this.config.fetch)) {
|
|
602
|
+
if (t = await this.config.fetch(), !I(t))
|
|
603
603
|
throw new Error(`Fetch function did not return an object of language strings: ${t}`);
|
|
604
604
|
} else if (S(this.config.path)) {
|
|
605
605
|
const e = await fetch(this.config.path);
|
|
606
606
|
if (e.ok) {
|
|
607
607
|
const s = await e.json();
|
|
608
|
-
if (
|
|
608
|
+
if (I(s))
|
|
609
609
|
t = s;
|
|
610
610
|
else
|
|
611
611
|
throw new Error(
|
|
@@ -616,34 +616,34 @@ class Ee {
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
if (t) {
|
|
619
|
-
const e = f(this,
|
|
619
|
+
const e = f(this, V, bt).call(this, t);
|
|
620
620
|
for (const s of e)
|
|
621
|
-
i(this,
|
|
621
|
+
i(this, G).set(s[0], s[1]);
|
|
622
622
|
} else
|
|
623
623
|
throw new Error("Language could not be loaded.");
|
|
624
624
|
}
|
|
625
625
|
getTemplate(t) {
|
|
626
|
-
return i(this,
|
|
626
|
+
return i(this, G).get(t) ?? {
|
|
627
627
|
segments: [{ type: 0, text: `[MISSING: ${t}]` }]
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
630
|
hasTemplate(t) {
|
|
631
|
-
return i(this,
|
|
631
|
+
return i(this, G).has(t);
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
|
|
634
|
+
dt = new WeakMap(), G = new WeakMap(), V = new WeakSet(), bt = function(t, e = []) {
|
|
635
635
|
const s = [];
|
|
636
|
-
for (const
|
|
637
|
-
switch (St(t[
|
|
636
|
+
for (const n in t)
|
|
637
|
+
switch (St(t[n])) {
|
|
638
638
|
case "string":
|
|
639
|
-
s.push([[...e,
|
|
639
|
+
s.push([[...e, n].join("."), f(this, V, Wt).call(this, t[n])]);
|
|
640
640
|
break;
|
|
641
641
|
case "object":
|
|
642
|
-
s.push(...f(this,
|
|
642
|
+
s.push(...f(this, V, bt).call(this, t[n], [...e, n]));
|
|
643
643
|
break;
|
|
644
644
|
default:
|
|
645
645
|
throw new Error(
|
|
646
|
-
`Expected to find a string or object at ${[...e,
|
|
646
|
+
`Expected to find a string or object at ${[...e, n].join(".")}. Got: ${St(t[n])}`
|
|
647
647
|
);
|
|
648
648
|
}
|
|
649
649
|
return s;
|
|
@@ -655,7 +655,7 @@ ft = new WeakMap(), W = new WeakMap(), D = new WeakSet(), bt = function(t, e = [
|
|
|
655
655
|
const s = {
|
|
656
656
|
segments: []
|
|
657
657
|
};
|
|
658
|
-
let
|
|
658
|
+
let n = "", r = 0, o = 0, c, l, p;
|
|
659
659
|
const b = () => {
|
|
660
660
|
c = {
|
|
661
661
|
type: 1,
|
|
@@ -668,47 +668,47 @@ ft = new WeakMap(), W = new WeakMap(), D = new WeakSet(), bt = function(t, e = [
|
|
|
668
668
|
options: {}
|
|
669
669
|
};
|
|
670
670
|
};
|
|
671
|
-
for (;
|
|
672
|
-
if (o !== 0 && t[
|
|
673
|
-
|
|
671
|
+
for (; r < t.length; ) {
|
|
672
|
+
if (o !== 0 && t[r] === " ") {
|
|
673
|
+
r++;
|
|
674
674
|
continue;
|
|
675
675
|
}
|
|
676
676
|
switch (o) {
|
|
677
677
|
case 0:
|
|
678
|
-
t[
|
|
678
|
+
t[r] === "{" && t[r + 1] === "{" ? (o = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""), b()) : (n += t[r], r++);
|
|
679
679
|
break;
|
|
680
680
|
case 1:
|
|
681
|
-
t[
|
|
681
|
+
t[r] === "|" ? (o = 2, r += 1, c.name = n, n = "", v()) : t[r] === "}" && t[r + 1] === "}" ? (o = 0, r += 2, c.name = n, n = "", s.segments.push(c)) : (n += t[r], r++);
|
|
682
682
|
break;
|
|
683
683
|
case 2:
|
|
684
|
-
t[
|
|
684
|
+
t[r] === "(" ? (o = 3, r += 1, l.name = n, n = "") : t[r] === "}" && t[r + 1] === "}" ? (o = 0, r += 2, c.formats.push(l), s.segments.push(c)) : (n += t[r], r++);
|
|
685
685
|
break;
|
|
686
686
|
case 3:
|
|
687
|
-
t[
|
|
687
|
+
t[r] === ")" || (t[r] === ":" ? (o = 4, r += 1, p = n, n = "") : t[r] === "}" && t[r + 1] === "}" || (n += t[r], r++));
|
|
688
688
|
break;
|
|
689
689
|
case 4:
|
|
690
|
-
t[
|
|
690
|
+
t[r] === ")" ? (o = 5, r += 1, l.options[p] = n, n = "", c.formats.push(l)) : t[r] === "," ? (o = 3, r += 1, l.options[p] = n, n = "") : t[r] === "}" && t[r + 1] === "}" || (n += t[r], r++);
|
|
691
691
|
break;
|
|
692
692
|
case 5:
|
|
693
|
-
t[
|
|
693
|
+
t[r] === "|" ? (o = 2, r += 1, v()) : t[r] === "}" && t[r + 1] === "}" && (o = 0, r += 2, s.segments.push(c));
|
|
694
694
|
break;
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
return o === 0 &&
|
|
697
|
+
return o === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
|
|
698
698
|
};
|
|
699
|
-
var
|
|
699
|
+
var X, L, g, Y, Z, tt, $, y, At, vt, kt, Et, Ht;
|
|
700
700
|
class $e {
|
|
701
701
|
constructor(t) {
|
|
702
702
|
u(this, y);
|
|
703
|
-
u(this,
|
|
704
|
-
u(this,
|
|
703
|
+
u(this, X);
|
|
704
|
+
u(this, L);
|
|
705
705
|
u(this, g, /* @__PURE__ */ new Map());
|
|
706
|
-
u(this,
|
|
707
|
-
u(this,
|
|
708
|
-
u(this,
|
|
709
|
-
u(this, $,
|
|
710
|
-
d(this,
|
|
711
|
-
i(this, g).size > 0 && await this.setLocale(i(this,
|
|
706
|
+
u(this, Y, []);
|
|
707
|
+
u(this, Z, /* @__PURE__ */ new Map());
|
|
708
|
+
u(this, tt, "auto");
|
|
709
|
+
u(this, $, Ot(""));
|
|
710
|
+
d(this, X, t), d(this, L, t.createLogger("Dolla.i18n")), this.addFormat("number", (e, s, n) => f(this, y, vt).call(this, Number(s), n)), this.addFormat("datetime", (e, s, n) => f(this, y, kt).call(this, s, n)), this.addFormat("list", (e, s, n) => f(this, y, Et).call(this, s, n)), t.beforeMount(async () => {
|
|
711
|
+
i(this, g).size > 0 && await this.setLocale(i(this, tt));
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
714
|
get locale() {
|
|
@@ -719,40 +719,40 @@ class $e {
|
|
|
719
719
|
}
|
|
720
720
|
setup(t) {
|
|
721
721
|
if (t.translations.forEach((e) => {
|
|
722
|
-
i(this, g).set(e.locale, new Ee(e, i(this,
|
|
722
|
+
i(this, g).set(e.locale, new Ee(e, i(this, X)));
|
|
723
723
|
}), t.locale && t.locale !== "auto") {
|
|
724
724
|
if (!t.translations.some((s) => s.locale === t.locale))
|
|
725
725
|
throw new Error(`Initial locale '${t.locale}' is not registered in the locales array.`);
|
|
726
|
-
d(this,
|
|
726
|
+
d(this, tt, t.locale);
|
|
727
727
|
}
|
|
728
|
-
i(this,
|
|
728
|
+
i(this, L).info(
|
|
729
729
|
`${i(this, g).size} language${i(this, g).size === 1 ? "" : "s"} supported: '${[...i(this, g).keys()].join("', '")}'`
|
|
730
730
|
);
|
|
731
731
|
}
|
|
732
732
|
async setLocale(t) {
|
|
733
|
-
var
|
|
733
|
+
var n;
|
|
734
734
|
let e;
|
|
735
735
|
if (t === "auto") {
|
|
736
|
-
let
|
|
736
|
+
let r = [];
|
|
737
737
|
if (typeof navigator < "u") {
|
|
738
738
|
const o = navigator;
|
|
739
|
-
((
|
|
739
|
+
((n = o.languages) == null ? void 0 : n.length) > 0 ? r.push(...o.languages) : o.language ? r.push(o.language) : o.browserLanguage ? r.push(o.browserLanguage) : o.userLanguage && r.push(o.userLanguage);
|
|
740
740
|
}
|
|
741
|
-
for (const o of
|
|
741
|
+
for (const o of r)
|
|
742
742
|
i(this, g).has(o) && (e = o);
|
|
743
743
|
} else
|
|
744
744
|
i(this, g).has(t) && (e = t);
|
|
745
745
|
if (e == null) {
|
|
746
|
-
const
|
|
747
|
-
|
|
746
|
+
const r = i(this, g).keys().next().value;
|
|
747
|
+
r && (e = r);
|
|
748
748
|
}
|
|
749
749
|
if (!e || !i(this, g).has(e))
|
|
750
750
|
throw new Error(`Locale '${t}' has no translation.`);
|
|
751
751
|
const s = i(this, g).get(e);
|
|
752
752
|
try {
|
|
753
|
-
await s.load(), d(this,
|
|
754
|
-
} catch (
|
|
755
|
-
|
|
753
|
+
await s.load(), d(this, Y, []), i(this, $).set(e), i(this, L).info("set language to " + e);
|
|
754
|
+
} catch (r) {
|
|
755
|
+
r instanceof Error && i(this, L).crash(r);
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
/**
|
|
@@ -771,8 +771,8 @@ class $e {
|
|
|
771
771
|
);
|
|
772
772
|
return O(() => {
|
|
773
773
|
const s = {};
|
|
774
|
-
for (const
|
|
775
|
-
s[
|
|
774
|
+
for (const n in e)
|
|
775
|
+
s[n] = ct(e[n]);
|
|
776
776
|
return f(this, y, At).call(this, i(this, $).get(), t, s);
|
|
777
777
|
});
|
|
778
778
|
}
|
|
@@ -791,7 +791,7 @@ class $e {
|
|
|
791
791
|
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
792
792
|
*/
|
|
793
793
|
addFormat(t, e) {
|
|
794
|
-
i(this,
|
|
794
|
+
i(this, Z).set(t, e);
|
|
795
795
|
}
|
|
796
796
|
/**
|
|
797
797
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
@@ -808,7 +808,7 @@ class $e {
|
|
|
808
808
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
809
809
|
*/
|
|
810
810
|
number(t, e) {
|
|
811
|
-
return O(() => f(this, y, vt).call(this,
|
|
811
|
+
return O(() => f(this, y, vt).call(this, ct(t), e));
|
|
812
812
|
}
|
|
813
813
|
/**
|
|
814
814
|
* Formats a date for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -820,7 +820,7 @@ class $e {
|
|
|
820
820
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
821
821
|
*/
|
|
822
822
|
dateTime(t, e) {
|
|
823
|
-
return O(() => f(this, y, kt).call(this,
|
|
823
|
+
return O(() => f(this, y, kt).call(this, ct(t), e));
|
|
824
824
|
}
|
|
825
825
|
/**
|
|
826
826
|
* Formats a list for the current locale. Uses `Intl.ListFormat` under the hood.
|
|
@@ -832,23 +832,23 @@ class $e {
|
|
|
832
832
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
833
833
|
*/
|
|
834
834
|
list(t, e) {
|
|
835
|
-
return O(() => f(this, y, Et).call(this,
|
|
835
|
+
return O(() => f(this, y, Et).call(this, ct(t), e));
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
|
-
|
|
838
|
+
X = new WeakMap(), L = new WeakMap(), g = new WeakMap(), Y = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), $ = new WeakMap(), y = new WeakSet(), At = function(t, e, s) {
|
|
839
839
|
var l;
|
|
840
|
-
const
|
|
841
|
-
if (
|
|
842
|
-
const
|
|
840
|
+
const n = f(this, y, Ht).call(this, e, s);
|
|
841
|
+
if (n) return n;
|
|
842
|
+
const r = i(this, g).get(t);
|
|
843
843
|
if (s.context != null && (e += "_" + s.context), s.count != null)
|
|
844
844
|
if (s.ordinal) {
|
|
845
845
|
const p = `${e}_ordinal_(=${s.count})`;
|
|
846
|
-
|
|
846
|
+
r.hasTemplate(p) ? e = p : e += "_ordinal_" + new Intl.PluralRules(t, { type: "ordinal" }).select(s.count);
|
|
847
847
|
} else {
|
|
848
848
|
const p = `${e}_(=${s.count})`;
|
|
849
|
-
|
|
849
|
+
r.hasTemplate(p) ? e = p : e += "_" + new Intl.PluralRules(t).select(s.count);
|
|
850
850
|
}
|
|
851
|
-
const o =
|
|
851
|
+
const o = r.getTemplate(e);
|
|
852
852
|
let c = "";
|
|
853
853
|
for (const p of o.segments)
|
|
854
854
|
if (p.type === 0)
|
|
@@ -858,12 +858,12 @@ J = new WeakMap(), N = new WeakMap(), g = new WeakMap(), X = new WeakMap(), Y =
|
|
|
858
858
|
const v = ((l = s.formatOverrides) == null ? void 0 : l[p.name]) ?? [...p.formats];
|
|
859
859
|
p.name === "count" && v.length === 0 && v.push({ name: "number", options: {} });
|
|
860
860
|
for (const h of v) {
|
|
861
|
-
const M = i(this,
|
|
861
|
+
const M = i(this, Z).get(h.name);
|
|
862
862
|
if (M == null) {
|
|
863
863
|
const k = new Error(
|
|
864
864
|
`Failed to load format '${h.name}' when processing '${e}', template: ${o}`
|
|
865
865
|
);
|
|
866
|
-
throw i(this,
|
|
866
|
+
throw i(this, L).crash(k), k;
|
|
867
867
|
}
|
|
868
868
|
b = M(t, b, h.options);
|
|
869
869
|
}
|
|
@@ -879,16 +879,16 @@ J = new WeakMap(), N = new WeakMap(), g = new WeakMap(), X = new WeakMap(), Y =
|
|
|
879
879
|
}, // relativeTime(): State<string> {
|
|
880
880
|
// }
|
|
881
881
|
Ht = function(t, e) {
|
|
882
|
-
for (const s of i(this,
|
|
882
|
+
for (const s of i(this, Y))
|
|
883
883
|
if (s[0] === t && Jt(s[1], e))
|
|
884
884
|
return s[2];
|
|
885
885
|
};
|
|
886
886
|
function Re(a, t) {
|
|
887
|
-
const e = String(t).split(/[\.\[\]]/).filter((
|
|
887
|
+
const e = String(t).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
888
888
|
let s = a;
|
|
889
889
|
for (; e.length > 0; ) {
|
|
890
|
-
const
|
|
891
|
-
s != null ? s = s[
|
|
890
|
+
const n = e.shift();
|
|
891
|
+
s != null ? s = s[n] : s = void 0;
|
|
892
892
|
}
|
|
893
893
|
return s;
|
|
894
894
|
}
|
|
@@ -939,92 +939,92 @@ function _e(a) {
|
|
|
939
939
|
</div>
|
|
940
940
|
`;
|
|
941
941
|
}
|
|
942
|
-
var
|
|
942
|
+
var N, et, P, D, st, W, rt, nt, at, it, F, ot, lt, mt;
|
|
943
943
|
class Se {
|
|
944
944
|
constructor() {
|
|
945
945
|
// TODO: Take these off the global Dolla object.
|
|
946
946
|
w(this, "http");
|
|
947
947
|
w(this, "i18n");
|
|
948
|
-
u(this,
|
|
949
|
-
u(this,
|
|
950
|
-
u(this,
|
|
951
|
-
u(this,
|
|
952
|
-
u(this,
|
|
953
|
-
u(this,
|
|
954
|
-
u(this, st, []);
|
|
955
|
-
u(this, nt, []);
|
|
948
|
+
u(this, N, !1);
|
|
949
|
+
u(this, et, "production");
|
|
950
|
+
u(this, P);
|
|
951
|
+
u(this, D);
|
|
952
|
+
u(this, st, _e);
|
|
953
|
+
u(this, W);
|
|
956
954
|
u(this, rt, []);
|
|
955
|
+
u(this, nt, []);
|
|
957
956
|
u(this, at, []);
|
|
957
|
+
u(this, it, []);
|
|
958
958
|
u(this, F, {
|
|
959
959
|
root: this,
|
|
960
960
|
stores: /* @__PURE__ */ new Map(),
|
|
961
961
|
viewName: "Dolla"
|
|
962
962
|
});
|
|
963
|
-
u(this,
|
|
963
|
+
u(this, ot, {
|
|
964
964
|
info: "development",
|
|
965
965
|
log: "development",
|
|
966
966
|
warn: "development",
|
|
967
967
|
error: !0
|
|
968
968
|
});
|
|
969
|
-
u(this,
|
|
969
|
+
u(this, lt, xt("*,-Dolla.*"));
|
|
970
970
|
// Registration functions for modules.
|
|
971
971
|
// All modules will be registered before mount.
|
|
972
|
-
u(this,
|
|
972
|
+
u(this, mt, []);
|
|
973
973
|
this.http = new ge(), this.i18n = new $e(this);
|
|
974
974
|
}
|
|
975
975
|
/**
|
|
976
976
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
977
977
|
*/
|
|
978
978
|
get isMounted() {
|
|
979
|
-
return i(this,
|
|
979
|
+
return i(this, N);
|
|
980
980
|
}
|
|
981
981
|
/**
|
|
982
982
|
* Get the current environment that this app is running in.
|
|
983
983
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
984
984
|
*/
|
|
985
985
|
getEnv() {
|
|
986
|
-
return i(this,
|
|
986
|
+
return i(this, et);
|
|
987
987
|
}
|
|
988
988
|
/**
|
|
989
989
|
* Sets the environment that this app is running in.
|
|
990
990
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
991
991
|
*/
|
|
992
992
|
setEnv(t) {
|
|
993
|
-
d(this,
|
|
993
|
+
d(this, et, t);
|
|
994
994
|
}
|
|
995
995
|
/**
|
|
996
996
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
997
997
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
998
998
|
*/
|
|
999
999
|
setCrashView(t) {
|
|
1000
|
-
d(this,
|
|
1000
|
+
d(this, st, t);
|
|
1001
1001
|
}
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
|
|
1004
1004
|
*/
|
|
1005
1005
|
getRootElement() {
|
|
1006
|
-
return i(this,
|
|
1006
|
+
return i(this, P);
|
|
1007
1007
|
}
|
|
1008
1008
|
/**
|
|
1009
1009
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
1010
1010
|
*/
|
|
1011
1011
|
getRootView() {
|
|
1012
|
-
return i(this,
|
|
1012
|
+
return i(this, D);
|
|
1013
1013
|
}
|
|
1014
1014
|
provide(t, e) {
|
|
1015
1015
|
const s = new Yt(t, e);
|
|
1016
1016
|
if (s.attach(i(this, F)))
|
|
1017
1017
|
return s.value;
|
|
1018
1018
|
{
|
|
1019
|
-
let
|
|
1020
|
-
return console.warn(`An instance of ${
|
|
1019
|
+
let r = t.name ? `'${t.name}'` : "this store";
|
|
1020
|
+
return console.warn(`An instance of ${r} was already attached to this context.`), this.get(t);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
/**
|
|
1024
1024
|
* Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
1025
1025
|
*/
|
|
1026
1026
|
get(t) {
|
|
1027
|
-
if (
|
|
1027
|
+
if (A(t)) {
|
|
1028
1028
|
const e = i(this, F).stores.get(t);
|
|
1029
1029
|
if (e == null)
|
|
1030
1030
|
throw new Tt("Store not found on this context.");
|
|
@@ -1033,26 +1033,26 @@ class Se {
|
|
|
1033
1033
|
throw new Tt("Invalid store.");
|
|
1034
1034
|
}
|
|
1035
1035
|
async mount(t, e) {
|
|
1036
|
-
if (i(this,
|
|
1036
|
+
if (i(this, N))
|
|
1037
1037
|
throw new Error("Dolla is already mounted.");
|
|
1038
1038
|
if (S(t)) {
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1039
|
+
const r = document.querySelector(t);
|
|
1040
|
+
Lt(HTMLElement, r, `Selector '${t}' did not match any element.`), d(this, P, r);
|
|
1041
1041
|
} else
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
const s =
|
|
1045
|
-
d(this,
|
|
1046
|
-
for (const
|
|
1047
|
-
|
|
1048
|
-
for (const
|
|
1049
|
-
|
|
1042
|
+
Lt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), d(this, P, t);
|
|
1043
|
+
wt(e) && d(this, W, e);
|
|
1044
|
+
const s = wt(e) ? Ut : e, n = Zt(s);
|
|
1045
|
+
d(this, D, this.constructView(n.type, n.props)), await Promise.all(i(this, mt).map((r) => r())), wt(e) && await le(e, this), await Promise.all(i(this, rt).map((r) => r())), i(this, D).mount(i(this, P)), d(this, N, !0);
|
|
1046
|
+
for (const r of i(this, F).stores.values())
|
|
1047
|
+
r.handleMount();
|
|
1048
|
+
for (const r of i(this, nt))
|
|
1049
|
+
r();
|
|
1050
1050
|
}
|
|
1051
1051
|
async unmount() {
|
|
1052
1052
|
var t;
|
|
1053
|
-
if (i(this,
|
|
1054
|
-
await Promise.all(i(this,
|
|
1055
|
-
for (const e of i(this,
|
|
1053
|
+
if (i(this, N)) {
|
|
1054
|
+
await Promise.all(i(this, at).map((e) => e())), (t = i(this, D)) == null || t.unmount(!1), i(this, W) && await ce(i(this, W)), d(this, N, !1);
|
|
1055
|
+
for (const e of i(this, it))
|
|
1056
1056
|
e();
|
|
1057
1057
|
}
|
|
1058
1058
|
}
|
|
@@ -1061,7 +1061,7 @@ class Se {
|
|
|
1061
1061
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1062
1062
|
*/
|
|
1063
1063
|
beforeMount(t) {
|
|
1064
|
-
i(this,
|
|
1064
|
+
i(this, rt).push(t);
|
|
1065
1065
|
}
|
|
1066
1066
|
/**
|
|
1067
1067
|
* Registers a `callback` to run after the app is mounted.
|
|
@@ -1074,13 +1074,13 @@ class Se {
|
|
|
1074
1074
|
* it will be awaited before unmounting finishes. Use this to perform cleanup.
|
|
1075
1075
|
*/
|
|
1076
1076
|
beforeUnmount(t) {
|
|
1077
|
-
i(this,
|
|
1077
|
+
i(this, at).push(t);
|
|
1078
1078
|
}
|
|
1079
1079
|
/**
|
|
1080
1080
|
* Registers a `callback` to run after the app is unmounted.
|
|
1081
1081
|
*/
|
|
1082
1082
|
onUnmount(t) {
|
|
1083
|
-
i(this,
|
|
1083
|
+
i(this, it).push(t);
|
|
1084
1084
|
}
|
|
1085
1085
|
/**
|
|
1086
1086
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1088,22 +1088,22 @@ class Se {
|
|
|
1088
1088
|
setLoggles(t) {
|
|
1089
1089
|
for (const e in t) {
|
|
1090
1090
|
const s = t[e];
|
|
1091
|
-
s && (i(this,
|
|
1091
|
+
s && (i(this, ot)[e] = s);
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
1094
|
setLogFilter(t) {
|
|
1095
|
-
d(this,
|
|
1095
|
+
d(this, lt, xt(t));
|
|
1096
1096
|
}
|
|
1097
1097
|
createLogger(t, e) {
|
|
1098
|
-
const s = (e == null ? void 0 : e.console) ?? Me(),
|
|
1099
|
-
if (
|
|
1100
|
-
return
|
|
1098
|
+
const s = (e == null ? void 0 : e.console) ?? Me(), n = this, r = i(this, ot), o = (c) => {
|
|
1099
|
+
if (r[c] === !1 || S(r[c]) && r[c] !== n.getEnv() || !i(this, lt).call(this, t))
|
|
1100
|
+
return re;
|
|
1101
1101
|
{
|
|
1102
1102
|
let l = `%c${t}`;
|
|
1103
1103
|
return e != null && e.uid ? l += ` %c[uid: %c${e.uid}%c]` : l += "%c%c%c", s[c].bind(
|
|
1104
1104
|
s,
|
|
1105
1105
|
l,
|
|
1106
|
-
`color:${
|
|
1106
|
+
`color:${ne(l)};font-weight:bold`,
|
|
1107
1107
|
"color:#777",
|
|
1108
1108
|
"color:#aaa",
|
|
1109
1109
|
"color:#777"
|
|
@@ -1127,11 +1127,11 @@ class Se {
|
|
|
1127
1127
|
return o("error");
|
|
1128
1128
|
},
|
|
1129
1129
|
crash(c) {
|
|
1130
|
-
|
|
1130
|
+
n.isMounted && (n.unmount(), n.constructView(i(n, st), {
|
|
1131
1131
|
error: c,
|
|
1132
1132
|
loggerName: t,
|
|
1133
1133
|
uid: e == null ? void 0 : e.uid
|
|
1134
|
-
}).mount(i(
|
|
1134
|
+
}).mount(i(n, P)));
|
|
1135
1135
|
}
|
|
1136
1136
|
};
|
|
1137
1137
|
}
|
|
@@ -1148,33 +1148,36 @@ class Se {
|
|
|
1148
1148
|
return ee(se(i(this, F), t));
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
|
-
|
|
1151
|
+
N = new WeakMap(), et = new WeakMap(), P = new WeakMap(), D = new WeakMap(), st = new WeakMap(), W = new WeakMap(), rt = new WeakMap(), nt = new WeakMap(), at = new WeakMap(), it = new WeakMap(), F = new WeakMap(), ot = new WeakMap(), lt = new WeakMap(), mt = new WeakMap();
|
|
1152
1152
|
function Me() {
|
|
1153
1153
|
if (typeof window < "u" && window.console)
|
|
1154
1154
|
return window.console;
|
|
1155
1155
|
if (typeof global < "u" && global.console)
|
|
1156
1156
|
return global.console;
|
|
1157
1157
|
}
|
|
1158
|
-
const
|
|
1158
|
+
const K = new Se(), Pe = K.i18n.t.bind(K.i18n), Fe = K.http, Oe = K.createLogger.bind(K);
|
|
1159
1159
|
export {
|
|
1160
|
-
|
|
1160
|
+
Ot as atom,
|
|
1161
1161
|
O as compose,
|
|
1162
1162
|
Xt as cond,
|
|
1163
|
+
Oe as createLogger,
|
|
1163
1164
|
Zt as createMarkup,
|
|
1164
|
-
|
|
1165
|
+
Ne as createRouter,
|
|
1165
1166
|
Jt as deepEqual,
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1167
|
+
K as default,
|
|
1168
|
+
Ce as effect,
|
|
1169
|
+
ct as get,
|
|
1170
|
+
De as getTracked,
|
|
1170
1171
|
Mt as html,
|
|
1171
|
-
|
|
1172
|
-
Ie as
|
|
1173
|
-
Ve as
|
|
1174
|
-
|
|
1175
|
-
|
|
1172
|
+
Fe as http,
|
|
1173
|
+
Ie as list,
|
|
1174
|
+
Ve as peek,
|
|
1175
|
+
qe as portal,
|
|
1176
|
+
Le as ref,
|
|
1177
|
+
Ge as set,
|
|
1176
1178
|
_t as shallowEqual,
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
+
We as strictEqual,
|
|
1180
|
+
Pe as t,
|
|
1181
|
+
Ae as untrack
|
|
1179
1182
|
};
|
|
1180
1183
|
//# sourceMappingURL=index.js.map
|