@manyducks.co/dolla 2.0.0-alpha.41 → 2.0.0-alpha.43
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 +69 -4
- package/dist/core/markup.d.ts +1 -1
- package/dist/core/nodes/dom.d.ts +1 -1
- package/dist/core/nodes/dynamic.d.ts +1 -1
- package/dist/core/nodes/html.d.ts +1 -1
- package/dist/core/nodes/list.d.ts +1 -1
- package/dist/core/nodes/outlet.d.ts +1 -1
- package/dist/core/nodes/view.d.ts +1 -1
- package/dist/core/signals.d.ts +81 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +294 -278
- 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-CSJbSI8_.js +1529 -0
- package/dist/markup-CSJbSI8_.js.map +1 -0
- package/dist/translate/index.d.ts +1 -1
- package/dist/types.d.ts +12 -0
- package/notes/atomic.md +320 -145
- package/notes/context-routes.md +6 -1
- package/notes/custom-nodes.md +17 -0
- package/package.json +1 -1
- package/dist/markup-DkQI155j.js +0 -1447
- package/dist/markup-DkQI155j.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
var zt = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
2
|
+
var $t = (a) => {
|
|
3
|
+
throw TypeError(a);
|
|
4
4
|
};
|
|
5
|
-
var Bt = (
|
|
6
|
-
var w = (
|
|
7
|
-
var
|
|
8
|
-
var Rt = (
|
|
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), 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
|
+
var Rt = (a, t, e, s) => ({
|
|
9
9
|
set _(n) {
|
|
10
|
-
d(
|
|
10
|
+
d(a, t, n, e);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
|
-
return a
|
|
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-CSJbSI8_.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-CSJbSI8_.js";
|
|
18
|
+
function Le(a) {
|
|
19
19
|
return function() {
|
|
20
20
|
if (arguments.length === 1)
|
|
21
|
-
|
|
21
|
+
a = arguments[0];
|
|
22
22
|
else if (arguments.length > 1)
|
|
23
23
|
throw new Error(`Too many arguments. Expected 0 or 1. Got: ${arguments.length}`);
|
|
24
|
-
return
|
|
24
|
+
return a;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function B(a) {
|
|
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) =>
|
|
34
|
-
|
|
33
|
+
(s) => A(s == null ? void 0 : s.toString),
|
|
34
|
+
a,
|
|
35
35
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
36
|
-
),
|
|
37
|
-
let t = (e =
|
|
36
|
+
), a = a.filter((s) => s).flatMap(String);
|
|
37
|
+
let t = (e = a.shift()) == null ? void 0 : e.toString();
|
|
38
38
|
if (t) {
|
|
39
|
-
for (const s of
|
|
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
|
-
let e =
|
|
48
|
+
let e = a;
|
|
49
49
|
for (; ; )
|
|
50
50
|
if (t.startsWith("..")) {
|
|
51
51
|
for (let s = e.length; s > 0; --s)
|
|
@@ -57,66 +57,66 @@ function ct(i, t) {
|
|
|
57
57
|
t = t.replace(/^\.\/?/, "");
|
|
58
58
|
else
|
|
59
59
|
break;
|
|
60
|
-
return
|
|
60
|
+
return H([e, t]);
|
|
61
61
|
}
|
|
62
|
-
function ae(
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
const t =
|
|
62
|
+
function ae(a) {
|
|
63
|
+
if (!a) return {};
|
|
64
|
+
a.startsWith("?") && (a = a.slice(1));
|
|
65
|
+
const t = a.split("&").filter((e) => e.trim() !== "").map((e) => {
|
|
66
66
|
const [s, n] = e.split("=").map((r) => r.trim());
|
|
67
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, n] = t.split("?"), r =
|
|
74
|
-
t: for (const c of
|
|
73
|
+
const [s, n] = t.split("?"), r = B(s);
|
|
74
|
+
t: for (const c of a) {
|
|
75
75
|
const { fragments: l } = c;
|
|
76
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
|
-
const
|
|
78
|
+
const b = [];
|
|
79
79
|
e: for (let h = 0; h < l.length; h++) {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
80
|
+
const M = r[h], k = l[h];
|
|
81
|
+
if (M == null && k.type !== 3)
|
|
82
82
|
continue t;
|
|
83
83
|
switch (k.type) {
|
|
84
84
|
case 1:
|
|
85
|
-
if (k.name.toLowerCase() ===
|
|
86
|
-
|
|
85
|
+
if (k.name.toLowerCase() === M.toLowerCase()) {
|
|
86
|
+
b.push(k);
|
|
87
87
|
break;
|
|
88
88
|
} else
|
|
89
89
|
continue t;
|
|
90
90
|
case 2:
|
|
91
|
-
|
|
91
|
+
b.push({ ...k, value: M });
|
|
92
92
|
break;
|
|
93
93
|
case 3:
|
|
94
|
-
|
|
94
|
+
b.push({ ...k, value: r.slice(h).join("/") });
|
|
95
95
|
break e;
|
|
96
96
|
case 4:
|
|
97
|
-
if (isNaN(Number(
|
|
97
|
+
if (isNaN(Number(M)))
|
|
98
98
|
continue t;
|
|
99
|
-
|
|
99
|
+
b.push({ ...k, value: Number(M) });
|
|
100
100
|
break;
|
|
101
101
|
default:
|
|
102
102
|
throw new Error(`Unknown fragment type: ${k.type}`);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
for (const h of
|
|
107
|
-
h.type === 2 && (
|
|
105
|
+
const v = {};
|
|
106
|
+
for (const h of b)
|
|
107
|
+
h.type === 2 && (v[h.name] = decodeURIComponent(h.value)), h.type === 4 && (v[h.name] = h.value), h.type === 3 && (v.wildcard = "/" + decodeURIComponent(h.value));
|
|
108
108
|
return {
|
|
109
|
-
path: "/" +
|
|
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
|
-
params:
|
|
111
|
+
params: v,
|
|
112
112
|
query: ae(n),
|
|
113
113
|
meta: c.meta
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
function ie(
|
|
117
|
+
function ie(a) {
|
|
118
118
|
const t = [], e = [], s = [], n = [];
|
|
119
|
-
for (const o of
|
|
119
|
+
for (const o of a) {
|
|
120
120
|
const { fragments: c } = o;
|
|
121
121
|
c.some(
|
|
122
122
|
(l) => l.type === 3
|
|
@@ -132,13 +132,13 @@ function ie(i) {
|
|
|
132
132
|
const r = (o, c) => o.fragments.length > c.fragments.length ? -1 : 1;
|
|
133
133
|
return t.sort(r), e.sort(r), s.sort(r), n.sort(r), [...t, ...e, ...s, ...n];
|
|
134
134
|
}
|
|
135
|
-
function oe(
|
|
136
|
-
const t =
|
|
135
|
+
function oe(a) {
|
|
136
|
+
const t = B(a), e = [];
|
|
137
137
|
for (let s = 0; s < t.length; s++) {
|
|
138
138
|
const n = t[s];
|
|
139
139
|
if (n === "*") {
|
|
140
140
|
if (s !== t.length - 1)
|
|
141
|
-
throw new Error(`Wildcard must be at the end of a pattern. Received: ${
|
|
141
|
+
throw new Error(`Wildcard must be at the end of a pattern. Received: ${a}`);
|
|
142
142
|
e.push({
|
|
143
143
|
type: 3,
|
|
144
144
|
name: "*",
|
|
@@ -156,94 +156,94 @@ function oe(i) {
|
|
|
156
156
|
}
|
|
157
157
|
return e;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
return new he(
|
|
159
|
+
function Ne(a) {
|
|
160
|
+
return new he(a);
|
|
161
161
|
}
|
|
162
|
-
const
|
|
163
|
-
function
|
|
164
|
-
return (
|
|
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
|
-
async function le(
|
|
167
|
-
return
|
|
166
|
+
async function le(a, t) {
|
|
167
|
+
return a[Ct](t);
|
|
168
168
|
}
|
|
169
|
-
async function ce(
|
|
170
|
-
return
|
|
169
|
+
async function ce(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,
|
|
176
|
+
w(this, Nt, !0);
|
|
177
177
|
u(this, Q);
|
|
178
|
-
u(this,
|
|
179
|
-
u(this,
|
|
180
|
-
u(this,
|
|
181
|
-
u(this,
|
|
178
|
+
u(this, _);
|
|
179
|
+
u(this, ut, 0);
|
|
180
|
+
u(this, x, []);
|
|
181
|
+
u(this, q, []);
|
|
182
182
|
u(this, J, !1);
|
|
183
183
|
/**
|
|
184
184
|
* Use hash routing when true. Configured in router options.
|
|
185
185
|
*/
|
|
186
|
-
u(this,
|
|
186
|
+
u(this, U, !1);
|
|
187
187
|
// Callbacks that need to be called on unmount.
|
|
188
|
-
u(this,
|
|
188
|
+
u(this, j, []);
|
|
189
189
|
/**
|
|
190
190
|
* The current match object.
|
|
191
191
|
*/
|
|
192
|
-
u(this,
|
|
192
|
+
u(this, T, Ot());
|
|
193
193
|
/**
|
|
194
194
|
* The currently matched route pattern, if any.
|
|
195
195
|
*/
|
|
196
|
-
w(this, "pattern",
|
|
196
|
+
w(this, "pattern", O(() => {
|
|
197
197
|
var t;
|
|
198
|
-
return (t =
|
|
198
|
+
return (t = i(this, T).get()) == null ? void 0 : t.pattern;
|
|
199
199
|
}));
|
|
200
200
|
/**
|
|
201
201
|
* The current URL path.
|
|
202
202
|
*/
|
|
203
|
-
w(this, "path",
|
|
203
|
+
w(this, "path", O(() => {
|
|
204
204
|
var t;
|
|
205
|
-
return ((t =
|
|
205
|
+
return ((t = i(this, T).get()) == null ? void 0 : t.path) ?? window.location.pathname;
|
|
206
206
|
}));
|
|
207
207
|
/**
|
|
208
208
|
* The current named path params.
|
|
209
209
|
*/
|
|
210
|
-
w(this, "params",
|
|
210
|
+
w(this, "params", O(() => {
|
|
211
211
|
var t;
|
|
212
|
-
return ((t =
|
|
212
|
+
return ((t = i(this, T).get()) == null ? void 0 : t.params) ?? {};
|
|
213
213
|
}, { equals: _t }));
|
|
214
214
|
/**
|
|
215
215
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
216
216
|
*/
|
|
217
|
-
w(this, "query",
|
|
217
|
+
w(this, "query", O(() => {
|
|
218
218
|
var t;
|
|
219
|
-
return ((t =
|
|
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,
|
|
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(
|
|
227
|
+
)), pe(i(this, q));
|
|
228
228
|
}
|
|
229
|
-
async [(
|
|
230
|
-
d(this, Q, t), d(this,
|
|
229
|
+
async [(Nt = Ft, Ct)](t) {
|
|
230
|
+
d(this, Q, t), d(this, _, t.createLogger("Dolla.router"));
|
|
231
231
|
const e = () => {
|
|
232
|
-
f(this, m,
|
|
232
|
+
f(this, m, z).call(this);
|
|
233
233
|
};
|
|
234
|
-
window.addEventListener("popstate", e),
|
|
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
237
|
de(s, (n) => {
|
|
238
238
|
let r = n.getAttribute("href");
|
|
239
|
-
|
|
239
|
+
i(this, _).info("intercepted click on <a> tag", n), this.go(r);
|
|
240
240
|
})
|
|
241
|
-
),
|
|
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 [
|
|
244
|
-
for (const t of
|
|
243
|
+
async [Dt]() {
|
|
244
|
+
for (const t of i(this, j))
|
|
245
245
|
t();
|
|
246
|
-
d(this,
|
|
246
|
+
d(this, j, []);
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
249
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
@@ -266,25 +266,37 @@ 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
|
-
Q = new WeakMap(),
|
|
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
|
-
(s =
|
|
275
|
-
},
|
|
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
|
+
}, Vt = function(t, e) {
|
|
276
276
|
var s;
|
|
277
|
-
(s =
|
|
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
|
-
return
|
|
280
|
-
},
|
|
279
|
+
return i(this, U) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
|
|
280
|
+
}, z = async function(t) {
|
|
281
281
|
var c;
|
|
282
|
-
const e =
|
|
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
|
+
for (const l of o)
|
|
284
|
+
switch (l.kind) {
|
|
285
|
+
case "match":
|
|
286
|
+
e == null || e.info(`📍 ${l.message}`);
|
|
287
|
+
break;
|
|
288
|
+
case "redirect":
|
|
289
|
+
e == null || e.info(`↩️ ${l.message}`);
|
|
290
|
+
break;
|
|
291
|
+
case "miss":
|
|
292
|
+
e == null || e.info(`💀 ${l.message}`);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
283
295
|
if (r) {
|
|
284
|
-
const l = this.pattern.
|
|
285
|
-
|
|
296
|
+
const l = this.pattern.peek();
|
|
297
|
+
i(this, T).set(r), s && r.pattern !== l && f(this, m, Gt).call(this, s, r);
|
|
286
298
|
} else
|
|
287
|
-
|
|
299
|
+
i(this, J) && e.crash(new we(`Failed to match route '${n.pathname}'`));
|
|
288
300
|
return { match: r, journey: o };
|
|
289
301
|
}, /**
|
|
290
302
|
* Takes a matched route and mounts it.
|
|
@@ -292,15 +304,15 @@ Q = new WeakMap(), S = new WeakMap(), ht = new WeakMap(), T = new WeakMap(), W =
|
|
|
292
304
|
Gt = function(t, e) {
|
|
293
305
|
const s = e.meta.layers;
|
|
294
306
|
for (let n = 0; n < s.length; n++) {
|
|
295
|
-
const r = s[n], o =
|
|
307
|
+
const r = s[n], o = i(this, x)[n];
|
|
296
308
|
if ((o == null ? void 0 : o.id) !== r.id) {
|
|
297
|
-
d(this,
|
|
298
|
-
const c =
|
|
299
|
-
|
|
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 });
|
|
300
312
|
}
|
|
301
313
|
}
|
|
302
314
|
}, gt = async function(t, e = []) {
|
|
303
|
-
const s =
|
|
315
|
+
const s = jt(i(this, q), t.pathname);
|
|
304
316
|
if (!s)
|
|
305
317
|
return {
|
|
306
318
|
match: null,
|
|
@@ -314,18 +326,18 @@ Gt = function(t, e) {
|
|
|
314
326
|
}
|
|
315
327
|
}), n != null) {
|
|
316
328
|
let r;
|
|
317
|
-
if (
|
|
329
|
+
if (S(n))
|
|
318
330
|
r = me(n, s.params);
|
|
319
|
-
else if (
|
|
331
|
+
else if (A(n)) {
|
|
320
332
|
const o = {
|
|
321
333
|
path: s.path,
|
|
322
334
|
pattern: s.pattern,
|
|
323
335
|
params: s.params,
|
|
324
336
|
query: s.query
|
|
325
337
|
};
|
|
326
|
-
if (r = await n(o), !
|
|
338
|
+
if (r = await n(o), !S(r))
|
|
327
339
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
328
|
-
r.startsWith("/") || (r =
|
|
340
|
+
r.startsWith("/") || (r = ht(s.path, r));
|
|
329
341
|
} else
|
|
330
342
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
331
343
|
return f(this, m, gt).call(this, new URL(r, window.location.origin), [
|
|
@@ -341,7 +353,7 @@ Gt = function(t, e) {
|
|
|
341
353
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
342
354
|
*/
|
|
343
355
|
yt = function(t, e = [], s = []) {
|
|
344
|
-
if (!
|
|
356
|
+
if (!I(t) || !S(t.path))
|
|
345
357
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${t}`);
|
|
346
358
|
if (t.redirect && t.routes)
|
|
347
359
|
throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
|
|
@@ -351,30 +363,30 @@ yt = function(t, e = [], s = []) {
|
|
|
351
363
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
352
364
|
let n = [];
|
|
353
365
|
for (const l of e)
|
|
354
|
-
n.push(...
|
|
355
|
-
n.push(...
|
|
366
|
+
n.push(...B(l.path));
|
|
367
|
+
n.push(...B(t.path)), n[n.length - 1] === "*" && n.pop();
|
|
356
368
|
const r = [];
|
|
357
369
|
if (t.redirect) {
|
|
358
370
|
let l = t.redirect;
|
|
359
|
-
return
|
|
360
|
-
pattern: "/" +
|
|
371
|
+
return S(l) && (l = ht(H(n), l), l.startsWith("/") || (l = "/" + l)), r.push({
|
|
372
|
+
pattern: "/" + H([...n, ...B(t.path)]),
|
|
361
373
|
meta: {
|
|
362
374
|
redirect: l
|
|
363
375
|
}
|
|
364
376
|
}), r;
|
|
365
377
|
}
|
|
366
|
-
let o =
|
|
367
|
-
if (
|
|
378
|
+
let o = Ut;
|
|
379
|
+
if (A(t.view))
|
|
368
380
|
o = t.view;
|
|
369
381
|
else if (t.view)
|
|
370
382
|
throw new TypeError(`Route '${t.path}' expected a view function or undefined. Got: ${t.view}`);
|
|
371
|
-
const c = { id: Rt(this,
|
|
383
|
+
const c = { id: Rt(this, ut)._++, view: o };
|
|
372
384
|
if (t.routes)
|
|
373
385
|
for (const l of t.routes)
|
|
374
386
|
r.push(...f(this, m, yt).call(this, l, [...e, t], [...s, c]));
|
|
375
387
|
else
|
|
376
388
|
r.push({
|
|
377
|
-
pattern: parent ?
|
|
389
|
+
pattern: parent ? H([...e.map((l) => l.path), t.path]) : t.path,
|
|
378
390
|
meta: {
|
|
379
391
|
pattern: t.path,
|
|
380
392
|
layers: [...s, c],
|
|
@@ -384,9 +396,9 @@ yt = function(t, e = [], s = []) {
|
|
|
384
396
|
return r;
|
|
385
397
|
};
|
|
386
398
|
const ue = /(noopener|noreferrer) (noopener|noreferrer)/, fe = /^[\w-_]+:/;
|
|
387
|
-
function de(
|
|
399
|
+
function de(a, t, e = window) {
|
|
388
400
|
function s(r) {
|
|
389
|
-
return !r || r ===
|
|
401
|
+
return !r || r === a ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
|
|
390
402
|
}
|
|
391
403
|
function n(r) {
|
|
392
404
|
if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
|
|
@@ -394,23 +406,23 @@ function de(i, t, e = window) {
|
|
|
394
406
|
const o = s(r.target);
|
|
395
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)));
|
|
396
408
|
}
|
|
397
|
-
return
|
|
398
|
-
|
|
409
|
+
return a.addEventListener("click", n), function() {
|
|
410
|
+
a.removeEventListener("click", n);
|
|
399
411
|
};
|
|
400
412
|
}
|
|
401
|
-
function me(
|
|
413
|
+
function me(a, t) {
|
|
402
414
|
for (const e in t) {
|
|
403
415
|
const s = t[e].toString();
|
|
404
|
-
|
|
416
|
+
a = a.replace(`{${e}}`, s).replace(`{#${e}}`, s);
|
|
405
417
|
}
|
|
406
|
-
return
|
|
418
|
+
return a;
|
|
407
419
|
}
|
|
408
|
-
function pe(
|
|
409
|
-
for (const t of
|
|
420
|
+
function pe(a) {
|
|
421
|
+
for (const t of a)
|
|
410
422
|
if (t.meta.redirect) {
|
|
411
423
|
let e;
|
|
412
|
-
if (!
|
|
413
|
-
if (e = t.meta.redirect, !
|
|
424
|
+
if (!A(t.meta.redirect)) if (S(t.meta.redirect)) {
|
|
425
|
+
if (e = t.meta.redirect, !jt(a, e, {
|
|
414
426
|
willMatch(n) {
|
|
415
427
|
return n !== t;
|
|
416
428
|
}
|
|
@@ -422,12 +434,12 @@ function pe(i) {
|
|
|
422
434
|
}
|
|
423
435
|
class we extends Error {
|
|
424
436
|
}
|
|
425
|
-
var
|
|
437
|
+
var C, ft, E, R;
|
|
426
438
|
class ge {
|
|
427
439
|
constructor() {
|
|
428
|
-
u(this,
|
|
429
|
-
u(this,
|
|
430
|
-
u(this,
|
|
440
|
+
u(this, E);
|
|
441
|
+
u(this, C, []);
|
|
442
|
+
u(this, ft, ye());
|
|
431
443
|
}
|
|
432
444
|
/**
|
|
433
445
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -436,42 +448,42 @@ class ge {
|
|
|
436
448
|
* @param middleware - A middleware function that will intercept requests.
|
|
437
449
|
*/
|
|
438
450
|
use(t) {
|
|
439
|
-
return
|
|
440
|
-
|
|
451
|
+
return i(this, C).push(t), () => {
|
|
452
|
+
i(this, C).splice(i(this, C).indexOf(t), 1);
|
|
441
453
|
};
|
|
442
454
|
}
|
|
443
455
|
async get(t, e) {
|
|
444
|
-
return f(this,
|
|
456
|
+
return f(this, E, R).call(this, "get", t, e);
|
|
445
457
|
}
|
|
446
458
|
async put(t, e) {
|
|
447
|
-
return f(this,
|
|
459
|
+
return f(this, E, R).call(this, "put", t, e);
|
|
448
460
|
}
|
|
449
461
|
async patch(t, e) {
|
|
450
|
-
return f(this,
|
|
462
|
+
return f(this, E, R).call(this, "patch", t, e);
|
|
451
463
|
}
|
|
452
464
|
async post(t, e) {
|
|
453
|
-
return f(this,
|
|
465
|
+
return f(this, E, R).call(this, "post", t, e);
|
|
454
466
|
}
|
|
455
467
|
async delete(t, e) {
|
|
456
|
-
return f(this,
|
|
468
|
+
return f(this, E, R).call(this, "delete", t, e);
|
|
457
469
|
}
|
|
458
470
|
async head(t, e) {
|
|
459
|
-
return f(this,
|
|
471
|
+
return f(this, E, R).call(this, "head", t, e);
|
|
460
472
|
}
|
|
461
473
|
async options(t, e) {
|
|
462
|
-
return f(this,
|
|
474
|
+
return f(this, E, R).call(this, "options", t, e);
|
|
463
475
|
}
|
|
464
476
|
async trace(t, e) {
|
|
465
|
-
return f(this,
|
|
477
|
+
return f(this, E, R).call(this, "trace", t, e);
|
|
466
478
|
}
|
|
467
479
|
}
|
|
468
|
-
|
|
469
|
-
return new
|
|
480
|
+
C = new WeakMap(), ft = new WeakMap(), E = new WeakSet(), R = async function(t, e, s) {
|
|
481
|
+
return new ke({
|
|
470
482
|
...s,
|
|
471
483
|
method: t,
|
|
472
484
|
uri: e,
|
|
473
|
-
middleware:
|
|
474
|
-
fetch:
|
|
485
|
+
middleware: i(this, C),
|
|
486
|
+
fetch: i(this, ft)
|
|
475
487
|
}).fetch();
|
|
476
488
|
};
|
|
477
489
|
function ye() {
|
|
@@ -506,7 +518,7 @@ class ve {
|
|
|
506
518
|
t.forEach((e, s) => {
|
|
507
519
|
this.headers.set(s, e);
|
|
508
520
|
});
|
|
509
|
-
else if (
|
|
521
|
+
else if (I(t))
|
|
510
522
|
for (const e in t) {
|
|
511
523
|
const s = t[e];
|
|
512
524
|
s instanceof Date ? this.headers.set(e, s.toISOString()) : s != null && this.headers.set(e, String(s));
|
|
@@ -520,7 +532,7 @@ class ve {
|
|
|
520
532
|
t.forEach((e, s) => {
|
|
521
533
|
this.url.searchParams.set(s, e);
|
|
522
534
|
});
|
|
523
|
-
else if (
|
|
535
|
+
else if (I(t))
|
|
524
536
|
for (const e in t) {
|
|
525
537
|
const s = t[e];
|
|
526
538
|
s instanceof Date ? this.url.searchParams.set(e, s.toISOString()) : s != null && this.url.searchParams.set(e, String(s));
|
|
@@ -529,7 +541,7 @@ class ve {
|
|
|
529
541
|
throw new TypeError(`Unknown query params type. Got: ${t}`);
|
|
530
542
|
}
|
|
531
543
|
}
|
|
532
|
-
class
|
|
544
|
+
class ke {
|
|
533
545
|
constructor(t) {
|
|
534
546
|
w(this, "_middleware");
|
|
535
547
|
w(this, "_fetch");
|
|
@@ -554,7 +566,7 @@ class Ee {
|
|
|
554
566
|
async _handler() {
|
|
555
567
|
let t;
|
|
556
568
|
const e = this._request;
|
|
557
|
-
!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;
|
|
558
570
|
const s = await this._fetch(e.url.toString(), {
|
|
559
571
|
method: e.method,
|
|
560
572
|
headers: e.headers,
|
|
@@ -571,29 +583,29 @@ class Ee {
|
|
|
571
583
|
};
|
|
572
584
|
}
|
|
573
585
|
}
|
|
574
|
-
var
|
|
575
|
-
class
|
|
586
|
+
var dt, G, V, bt, Wt;
|
|
587
|
+
class Ee {
|
|
576
588
|
constructor(t, e) {
|
|
577
|
-
u(this,
|
|
589
|
+
u(this, V);
|
|
578
590
|
w(this, "dolla");
|
|
579
591
|
w(this, "config");
|
|
580
|
-
u(this,
|
|
581
|
-
u(this,
|
|
592
|
+
u(this, dt, !1);
|
|
593
|
+
u(this, G, /* @__PURE__ */ new Map());
|
|
582
594
|
this.config = t, this.dolla = e;
|
|
583
595
|
}
|
|
584
596
|
async load() {
|
|
585
597
|
let t;
|
|
586
|
-
if (!
|
|
587
|
-
if (
|
|
598
|
+
if (!i(this, dt)) {
|
|
599
|
+
if (I(this.config.strings))
|
|
588
600
|
t = this.config.strings;
|
|
589
|
-
else if (
|
|
590
|
-
if (t = await this.config.fetch(), !
|
|
601
|
+
else if (A(this.config.fetch)) {
|
|
602
|
+
if (t = await this.config.fetch(), !I(t))
|
|
591
603
|
throw new Error(`Fetch function did not return an object of language strings: ${t}`);
|
|
592
|
-
} else if (
|
|
604
|
+
} else if (S(this.config.path)) {
|
|
593
605
|
const e = await fetch(this.config.path);
|
|
594
606
|
if (e.ok) {
|
|
595
607
|
const s = await e.json();
|
|
596
|
-
if (
|
|
608
|
+
if (I(s))
|
|
597
609
|
t = s;
|
|
598
610
|
else
|
|
599
611
|
throw new Error(
|
|
@@ -604,30 +616,30 @@ class $e {
|
|
|
604
616
|
}
|
|
605
617
|
}
|
|
606
618
|
if (t) {
|
|
607
|
-
const e = f(this,
|
|
619
|
+
const e = f(this, V, bt).call(this, t);
|
|
608
620
|
for (const s of e)
|
|
609
|
-
|
|
621
|
+
i(this, G).set(s[0], s[1]);
|
|
610
622
|
} else
|
|
611
623
|
throw new Error("Language could not be loaded.");
|
|
612
624
|
}
|
|
613
625
|
getTemplate(t) {
|
|
614
|
-
return
|
|
626
|
+
return i(this, G).get(t) ?? {
|
|
615
627
|
segments: [{ type: 0, text: `[MISSING: ${t}]` }]
|
|
616
628
|
};
|
|
617
629
|
}
|
|
618
630
|
hasTemplate(t) {
|
|
619
|
-
return
|
|
631
|
+
return i(this, G).has(t);
|
|
620
632
|
}
|
|
621
633
|
}
|
|
622
|
-
|
|
634
|
+
dt = new WeakMap(), G = new WeakMap(), V = new WeakSet(), bt = function(t, e = []) {
|
|
623
635
|
const s = [];
|
|
624
636
|
for (const n in t)
|
|
625
637
|
switch (St(t[n])) {
|
|
626
638
|
case "string":
|
|
627
|
-
s.push([[...e, n].join("."), f(this,
|
|
639
|
+
s.push([[...e, n].join("."), f(this, V, Wt).call(this, t[n])]);
|
|
628
640
|
break;
|
|
629
641
|
case "object":
|
|
630
|
-
s.push(...f(this,
|
|
642
|
+
s.push(...f(this, V, bt).call(this, t[n], [...e, n]));
|
|
631
643
|
break;
|
|
632
644
|
default:
|
|
633
645
|
throw new Error(
|
|
@@ -644,13 +656,13 @@ ft = new WeakMap(), A = new WeakMap(), q = new WeakSet(), bt = function(t, e = [
|
|
|
644
656
|
segments: []
|
|
645
657
|
};
|
|
646
658
|
let n = "", r = 0, o = 0, c, l, p;
|
|
647
|
-
const
|
|
659
|
+
const b = () => {
|
|
648
660
|
c = {
|
|
649
661
|
type: 1,
|
|
650
662
|
name: "",
|
|
651
663
|
formats: []
|
|
652
664
|
};
|
|
653
|
-
},
|
|
665
|
+
}, v = () => {
|
|
654
666
|
l = {
|
|
655
667
|
name: "",
|
|
656
668
|
options: {}
|
|
@@ -663,10 +675,10 @@ ft = new WeakMap(), A = new WeakMap(), q = new WeakSet(), bt = function(t, e = [
|
|
|
663
675
|
}
|
|
664
676
|
switch (o) {
|
|
665
677
|
case 0:
|
|
666
|
-
t[r] === "{" && t[r + 1] === "{" ? (o = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""),
|
|
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++);
|
|
667
679
|
break;
|
|
668
680
|
case 1:
|
|
669
|
-
t[r] === "|" ? (o = 2, r += 1, c.name = n, n = "",
|
|
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++);
|
|
670
682
|
break;
|
|
671
683
|
case 2:
|
|
672
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++);
|
|
@@ -678,43 +690,43 @@ ft = new WeakMap(), A = new WeakMap(), q = new WeakSet(), bt = function(t, e = [
|
|
|
678
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++);
|
|
679
691
|
break;
|
|
680
692
|
case 5:
|
|
681
|
-
t[r] === "|" ? (o = 2, r += 1,
|
|
693
|
+
t[r] === "|" ? (o = 2, r += 1, v()) : t[r] === "}" && t[r + 1] === "}" && (o = 0, r += 2, s.segments.push(c));
|
|
682
694
|
break;
|
|
683
695
|
}
|
|
684
696
|
}
|
|
685
697
|
return o === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
|
|
686
698
|
};
|
|
687
|
-
var X,
|
|
688
|
-
class
|
|
699
|
+
var X, L, g, Y, Z, tt, $, y, At, vt, kt, Et, Ht;
|
|
700
|
+
class $e {
|
|
689
701
|
constructor(t) {
|
|
690
702
|
u(this, y);
|
|
691
703
|
u(this, X);
|
|
692
|
-
u(this,
|
|
704
|
+
u(this, L);
|
|
693
705
|
u(this, g, /* @__PURE__ */ new Map());
|
|
694
706
|
u(this, Y, []);
|
|
695
707
|
u(this, Z, /* @__PURE__ */ new Map());
|
|
696
708
|
u(this, tt, "auto");
|
|
697
|
-
u(this,
|
|
698
|
-
d(this, X, t), d(this,
|
|
699
|
-
|
|
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));
|
|
700
712
|
});
|
|
701
713
|
}
|
|
702
714
|
get locale() {
|
|
703
|
-
return
|
|
715
|
+
return i(this, $);
|
|
704
716
|
}
|
|
705
717
|
get locales() {
|
|
706
|
-
return [...
|
|
718
|
+
return [...i(this, g).keys()];
|
|
707
719
|
}
|
|
708
720
|
setup(t) {
|
|
709
721
|
if (t.translations.forEach((e) => {
|
|
710
|
-
|
|
722
|
+
i(this, g).set(e.locale, new Ee(e, i(this, X)));
|
|
711
723
|
}), t.locale && t.locale !== "auto") {
|
|
712
724
|
if (!t.translations.some((s) => s.locale === t.locale))
|
|
713
725
|
throw new Error(`Initial locale '${t.locale}' is not registered in the locales array.`);
|
|
714
726
|
d(this, tt, t.locale);
|
|
715
727
|
}
|
|
716
|
-
|
|
717
|
-
`${
|
|
728
|
+
i(this, L).info(
|
|
729
|
+
`${i(this, g).size} language${i(this, g).size === 1 ? "" : "s"} supported: '${[...i(this, g).keys()].join("', '")}'`
|
|
718
730
|
);
|
|
719
731
|
}
|
|
720
732
|
async setLocale(t) {
|
|
@@ -727,20 +739,20 @@ class ke {
|
|
|
727
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);
|
|
728
740
|
}
|
|
729
741
|
for (const o of r)
|
|
730
|
-
|
|
742
|
+
i(this, g).has(o) && (e = o);
|
|
731
743
|
} else
|
|
732
|
-
|
|
744
|
+
i(this, g).has(t) && (e = t);
|
|
733
745
|
if (e == null) {
|
|
734
|
-
const r =
|
|
746
|
+
const r = i(this, g).keys().next().value;
|
|
735
747
|
r && (e = r);
|
|
736
748
|
}
|
|
737
|
-
if (!e || !
|
|
749
|
+
if (!e || !i(this, g).has(e))
|
|
738
750
|
throw new Error(`Locale '${t}' has no translation.`);
|
|
739
|
-
const s =
|
|
751
|
+
const s = i(this, g).get(e);
|
|
740
752
|
try {
|
|
741
|
-
await s.load(), d(this, Y, []),
|
|
753
|
+
await s.load(), d(this, Y, []), i(this, $).set(e), i(this, L).info("set language to " + e);
|
|
742
754
|
} catch (r) {
|
|
743
|
-
r instanceof Error &&
|
|
755
|
+
r instanceof Error && i(this, L).crash(r);
|
|
744
756
|
}
|
|
745
757
|
}
|
|
746
758
|
/**
|
|
@@ -757,11 +769,11 @@ class ke {
|
|
|
757
769
|
throw new Error(
|
|
758
770
|
`The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
|
|
759
771
|
);
|
|
760
|
-
return
|
|
772
|
+
return O(() => {
|
|
761
773
|
const s = {};
|
|
762
774
|
for (const n in e)
|
|
763
|
-
s[n] =
|
|
764
|
-
return f(this, y, At).call(this,
|
|
775
|
+
s[n] = ct(e[n]);
|
|
776
|
+
return f(this, y, At).call(this, i(this, $).get(), t, s);
|
|
765
777
|
});
|
|
766
778
|
}
|
|
767
779
|
/**
|
|
@@ -779,16 +791,16 @@ class ke {
|
|
|
779
791
|
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
780
792
|
*/
|
|
781
793
|
addFormat(t, e) {
|
|
782
|
-
|
|
794
|
+
i(this, Z).set(t, e);
|
|
783
795
|
}
|
|
784
796
|
/**
|
|
785
797
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
786
|
-
* NOTE: The
|
|
798
|
+
* NOTE: The locale is tracked if called within a signal tracking context.
|
|
787
799
|
*
|
|
788
800
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options
|
|
789
801
|
*/
|
|
790
802
|
collator(t) {
|
|
791
|
-
return new Intl.Collator(
|
|
803
|
+
return new Intl.Collator(i(this, $).get(), t);
|
|
792
804
|
}
|
|
793
805
|
/**
|
|
794
806
|
* Formats a number for the current locale. Uses `Intl.NumberFormat` under the hood.
|
|
@@ -796,7 +808,7 @@ class ke {
|
|
|
796
808
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
797
809
|
*/
|
|
798
810
|
number(t, e) {
|
|
799
|
-
return
|
|
811
|
+
return O(() => f(this, y, vt).call(this, ct(t), e));
|
|
800
812
|
}
|
|
801
813
|
/**
|
|
802
814
|
* Formats a date for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -808,7 +820,7 @@ class ke {
|
|
|
808
820
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
809
821
|
*/
|
|
810
822
|
dateTime(t, e) {
|
|
811
|
-
return
|
|
823
|
+
return O(() => f(this, y, kt).call(this, ct(t), e));
|
|
812
824
|
}
|
|
813
825
|
/**
|
|
814
826
|
* Formats a list for the current locale. Uses `Intl.ListFormat` under the hood.
|
|
@@ -820,14 +832,14 @@ class ke {
|
|
|
820
832
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
821
833
|
*/
|
|
822
834
|
list(t, e) {
|
|
823
|
-
return
|
|
835
|
+
return O(() => f(this, y, Et).call(this, ct(t), e));
|
|
824
836
|
}
|
|
825
837
|
}
|
|
826
|
-
X = new WeakMap(),
|
|
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) {
|
|
827
839
|
var l;
|
|
828
840
|
const n = f(this, y, Ht).call(this, e, s);
|
|
829
841
|
if (n) return n;
|
|
830
|
-
const r =
|
|
842
|
+
const r = i(this, g).get(t);
|
|
831
843
|
if (s.context != null && (e += "_" + s.context), s.count != null)
|
|
832
844
|
if (s.ordinal) {
|
|
833
845
|
const p = `${e}_ordinal_(=${s.count})`;
|
|
@@ -842,45 +854,45 @@ X = new WeakMap(), P = new WeakMap(), g = new WeakMap(), Y = new WeakMap(), Z =
|
|
|
842
854
|
if (p.type === 0)
|
|
843
855
|
c += p.text;
|
|
844
856
|
else if (p.type === 1) {
|
|
845
|
-
let
|
|
846
|
-
const
|
|
847
|
-
p.name === "count" &&
|
|
848
|
-
for (const h of
|
|
849
|
-
const
|
|
850
|
-
if (
|
|
857
|
+
let b = Re(s, p.name);
|
|
858
|
+
const v = ((l = s.formatOverrides) == null ? void 0 : l[p.name]) ?? [...p.formats];
|
|
859
|
+
p.name === "count" && v.length === 0 && v.push({ name: "number", options: {} });
|
|
860
|
+
for (const h of v) {
|
|
861
|
+
const M = i(this, Z).get(h.name);
|
|
862
|
+
if (M == null) {
|
|
851
863
|
const k = new Error(
|
|
852
864
|
`Failed to load format '${h.name}' when processing '${e}', template: ${o}`
|
|
853
865
|
);
|
|
854
|
-
throw
|
|
866
|
+
throw i(this, L).crash(k), k;
|
|
855
867
|
}
|
|
856
|
-
|
|
868
|
+
b = M(t, b, h.options);
|
|
857
869
|
}
|
|
858
|
-
c +=
|
|
870
|
+
c += b;
|
|
859
871
|
}
|
|
860
872
|
return c;
|
|
861
873
|
}, vt = function(t, e) {
|
|
862
|
-
return new Intl.NumberFormat(
|
|
874
|
+
return new Intl.NumberFormat(i(this, $).get(), e).format(t);
|
|
875
|
+
}, kt = function(t, e) {
|
|
876
|
+
return new Intl.DateTimeFormat(i(this, $).get(), e).format(S(t) ? new Date(t) : t);
|
|
863
877
|
}, Et = function(t, e) {
|
|
864
|
-
return new Intl.
|
|
865
|
-
}, $t = function(t, e) {
|
|
866
|
-
return new Intl.ListFormat(a(this, b).value, e).format(t);
|
|
878
|
+
return new Intl.ListFormat(i(this, $).get(), e).format(t);
|
|
867
879
|
}, // relativeTime(): State<string> {
|
|
868
880
|
// }
|
|
869
881
|
Ht = function(t, e) {
|
|
870
|
-
for (const s of
|
|
882
|
+
for (const s of i(this, Y))
|
|
871
883
|
if (s[0] === t && Jt(s[1], e))
|
|
872
884
|
return s[2];
|
|
873
885
|
};
|
|
874
|
-
function Re(
|
|
886
|
+
function Re(a, t) {
|
|
875
887
|
const e = String(t).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
876
|
-
let s =
|
|
888
|
+
let s = a;
|
|
877
889
|
for (; e.length > 0; ) {
|
|
878
890
|
const n = e.shift();
|
|
879
891
|
s != null ? s = s[n] : s = void 0;
|
|
880
892
|
}
|
|
881
893
|
return s;
|
|
882
894
|
}
|
|
883
|
-
function _e(
|
|
895
|
+
function _e(a) {
|
|
884
896
|
return Mt`
|
|
885
897
|
<div
|
|
886
898
|
style=${{
|
|
@@ -894,8 +906,8 @@ function _e(i) {
|
|
|
894
906
|
>
|
|
895
907
|
<h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
|
|
896
908
|
<p style=${{ marginBottom: "0.25rem" }}>
|
|
897
|
-
<span style=${{ fontFamily: "monospace" }}>${
|
|
898
|
-
${Xt(
|
|
909
|
+
<span style=${{ fontFamily: "monospace" }}>${a.loggerName}</span>
|
|
910
|
+
${Xt(a.uid, Mt`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${a.uid}]</span>`)}
|
|
899
911
|
${" "}says:
|
|
900
912
|
</p>
|
|
901
913
|
<blockquote
|
|
@@ -918,32 +930,32 @@ function _e(i) {
|
|
|
918
930
|
fontWeight: "bold"
|
|
919
931
|
}}
|
|
920
932
|
>
|
|
921
|
-
${
|
|
933
|
+
${a.error.name}
|
|
922
934
|
</span>
|
|
923
|
-
${
|
|
935
|
+
${a.error.message}
|
|
924
936
|
</blockquote>
|
|
925
937
|
|
|
926
938
|
<p>Please see the browser console for details.</p>
|
|
927
939
|
</div>
|
|
928
940
|
`;
|
|
929
941
|
}
|
|
930
|
-
var
|
|
942
|
+
var N, et, P, D, st, W, rt, nt, at, it, F, ot, lt, mt;
|
|
931
943
|
class Se {
|
|
932
944
|
constructor() {
|
|
933
945
|
// TODO: Take these off the global Dolla object.
|
|
934
946
|
w(this, "http");
|
|
935
947
|
w(this, "i18n");
|
|
936
|
-
u(this,
|
|
948
|
+
u(this, N, !1);
|
|
937
949
|
u(this, et, "production");
|
|
938
|
-
u(this,
|
|
939
|
-
u(this,
|
|
950
|
+
u(this, P);
|
|
951
|
+
u(this, D);
|
|
940
952
|
u(this, st, _e);
|
|
941
|
-
u(this,
|
|
953
|
+
u(this, W);
|
|
942
954
|
u(this, rt, []);
|
|
943
955
|
u(this, nt, []);
|
|
944
956
|
u(this, at, []);
|
|
945
957
|
u(this, it, []);
|
|
946
|
-
u(this,
|
|
958
|
+
u(this, F, {
|
|
947
959
|
root: this,
|
|
948
960
|
stores: /* @__PURE__ */ new Map(),
|
|
949
961
|
viewName: "Dolla"
|
|
@@ -957,21 +969,21 @@ class Se {
|
|
|
957
969
|
u(this, lt, xt("*,-Dolla.*"));
|
|
958
970
|
// Registration functions for modules.
|
|
959
971
|
// All modules will be registered before mount.
|
|
960
|
-
u(this,
|
|
961
|
-
this.http = new ge(), this.i18n = new
|
|
972
|
+
u(this, mt, []);
|
|
973
|
+
this.http = new ge(), this.i18n = new $e(this);
|
|
962
974
|
}
|
|
963
975
|
/**
|
|
964
976
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
965
977
|
*/
|
|
966
978
|
get isMounted() {
|
|
967
|
-
return
|
|
979
|
+
return i(this, N);
|
|
968
980
|
}
|
|
969
981
|
/**
|
|
970
982
|
* Get the current environment that this app is running in.
|
|
971
983
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
972
984
|
*/
|
|
973
985
|
getEnv() {
|
|
974
|
-
return
|
|
986
|
+
return i(this, et);
|
|
975
987
|
}
|
|
976
988
|
/**
|
|
977
989
|
* Sets the environment that this app is running in.
|
|
@@ -991,17 +1003,17 @@ class Se {
|
|
|
991
1003
|
* Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
|
|
992
1004
|
*/
|
|
993
1005
|
getRootElement() {
|
|
994
|
-
return
|
|
1006
|
+
return i(this, P);
|
|
995
1007
|
}
|
|
996
1008
|
/**
|
|
997
1009
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
998
1010
|
*/
|
|
999
1011
|
getRootView() {
|
|
1000
|
-
return
|
|
1012
|
+
return i(this, D);
|
|
1001
1013
|
}
|
|
1002
1014
|
provide(t, e) {
|
|
1003
1015
|
const s = new Yt(t, e);
|
|
1004
|
-
if (s.attach(
|
|
1016
|
+
if (s.attach(i(this, F)))
|
|
1005
1017
|
return s.value;
|
|
1006
1018
|
{
|
|
1007
1019
|
let r = t.name ? `'${t.name}'` : "this store";
|
|
@@ -1012,8 +1024,8 @@ class Se {
|
|
|
1012
1024
|
* Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
1013
1025
|
*/
|
|
1014
1026
|
get(t) {
|
|
1015
|
-
if (
|
|
1016
|
-
const e =
|
|
1027
|
+
if (A(t)) {
|
|
1028
|
+
const e = i(this, F).stores.get(t);
|
|
1017
1029
|
if (e == null)
|
|
1018
1030
|
throw new Tt("Store not found on this context.");
|
|
1019
1031
|
return e.value;
|
|
@@ -1021,26 +1033,26 @@ class Se {
|
|
|
1021
1033
|
throw new Tt("Invalid store.");
|
|
1022
1034
|
}
|
|
1023
1035
|
async mount(t, e) {
|
|
1024
|
-
if (
|
|
1036
|
+
if (i(this, N))
|
|
1025
1037
|
throw new Error("Dolla is already mounted.");
|
|
1026
|
-
if (
|
|
1038
|
+
if (S(t)) {
|
|
1027
1039
|
const r = document.querySelector(t);
|
|
1028
|
-
|
|
1040
|
+
Lt(HTMLElement, r, `Selector '${t}' did not match any element.`), d(this, P, r);
|
|
1029
1041
|
} else
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
const s =
|
|
1033
|
-
d(this,
|
|
1034
|
-
for (const r of
|
|
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())
|
|
1035
1047
|
r.handleMount();
|
|
1036
|
-
for (const r of
|
|
1048
|
+
for (const r of i(this, nt))
|
|
1037
1049
|
r();
|
|
1038
1050
|
}
|
|
1039
1051
|
async unmount() {
|
|
1040
1052
|
var t;
|
|
1041
|
-
if (
|
|
1042
|
-
await Promise.all(
|
|
1043
|
-
for (const e of
|
|
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))
|
|
1044
1056
|
e();
|
|
1045
1057
|
}
|
|
1046
1058
|
}
|
|
@@ -1049,26 +1061,26 @@ class Se {
|
|
|
1049
1061
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1050
1062
|
*/
|
|
1051
1063
|
beforeMount(t) {
|
|
1052
|
-
|
|
1064
|
+
i(this, rt).push(t);
|
|
1053
1065
|
}
|
|
1054
1066
|
/**
|
|
1055
1067
|
* Registers a `callback` to run after the app is mounted.
|
|
1056
1068
|
*/
|
|
1057
1069
|
onMount(t) {
|
|
1058
|
-
|
|
1070
|
+
i(this, nt).push(t);
|
|
1059
1071
|
}
|
|
1060
1072
|
/**
|
|
1061
1073
|
* Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
|
|
1062
1074
|
* it will be awaited before unmounting finishes. Use this to perform cleanup.
|
|
1063
1075
|
*/
|
|
1064
1076
|
beforeUnmount(t) {
|
|
1065
|
-
|
|
1077
|
+
i(this, at).push(t);
|
|
1066
1078
|
}
|
|
1067
1079
|
/**
|
|
1068
1080
|
* Registers a `callback` to run after the app is unmounted.
|
|
1069
1081
|
*/
|
|
1070
1082
|
onUnmount(t) {
|
|
1071
|
-
|
|
1083
|
+
i(this, it).push(t);
|
|
1072
1084
|
}
|
|
1073
1085
|
/**
|
|
1074
1086
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1076,15 +1088,15 @@ class Se {
|
|
|
1076
1088
|
setLoggles(t) {
|
|
1077
1089
|
for (const e in t) {
|
|
1078
1090
|
const s = t[e];
|
|
1079
|
-
s && (
|
|
1091
|
+
s && (i(this, ot)[e] = s);
|
|
1080
1092
|
}
|
|
1081
1093
|
}
|
|
1082
1094
|
setLogFilter(t) {
|
|
1083
1095
|
d(this, lt, xt(t));
|
|
1084
1096
|
}
|
|
1085
1097
|
createLogger(t, e) {
|
|
1086
|
-
const s = (e == null ? void 0 : e.console) ?? Me(), n = this, r =
|
|
1087
|
-
if (r[c] === !1 ||
|
|
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))
|
|
1088
1100
|
return re;
|
|
1089
1101
|
{
|
|
1090
1102
|
let l = `%c${t}`;
|
|
@@ -1115,11 +1127,11 @@ class Se {
|
|
|
1115
1127
|
return o("error");
|
|
1116
1128
|
},
|
|
1117
1129
|
crash(c) {
|
|
1118
|
-
n.isMounted && (n.unmount(), n.constructView(
|
|
1130
|
+
n.isMounted && (n.unmount(), n.constructView(i(n, st), {
|
|
1119
1131
|
error: c,
|
|
1120
1132
|
loggerName: t,
|
|
1121
1133
|
uid: e == null ? void 0 : e.uid
|
|
1122
|
-
}).mount(
|
|
1134
|
+
}).mount(i(n, P)));
|
|
1123
1135
|
}
|
|
1124
1136
|
};
|
|
1125
1137
|
}
|
|
@@ -1127,41 +1139,45 @@ class Se {
|
|
|
1127
1139
|
*
|
|
1128
1140
|
*/
|
|
1129
1141
|
constructView(t, e, s = []) {
|
|
1130
|
-
return new te(
|
|
1142
|
+
return new te(i(this, F), t, e, s);
|
|
1131
1143
|
}
|
|
1132
1144
|
/**
|
|
1133
1145
|
*
|
|
1134
1146
|
*/
|
|
1135
1147
|
constructMarkup(t) {
|
|
1136
|
-
return ee(se(
|
|
1148
|
+
return ee(se(i(this, F), t));
|
|
1137
1149
|
}
|
|
1138
1150
|
}
|
|
1139
|
-
|
|
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();
|
|
1140
1152
|
function Me() {
|
|
1141
1153
|
if (typeof window < "u" && window.console)
|
|
1142
1154
|
return window.console;
|
|
1143
1155
|
if (typeof global < "u" && global.console)
|
|
1144
1156
|
return global.console;
|
|
1145
1157
|
}
|
|
1146
|
-
const
|
|
1158
|
+
const K = new Se(), Pe = K.i18n.t.bind(K.i18n), Fe = K.http, Oe = K.createLogger.bind(K);
|
|
1147
1159
|
export {
|
|
1148
|
-
|
|
1149
|
-
|
|
1160
|
+
Ot as atom,
|
|
1161
|
+
O as compose,
|
|
1150
1162
|
Xt as cond,
|
|
1163
|
+
Oe as createLogger,
|
|
1151
1164
|
Zt as createMarkup,
|
|
1152
|
-
|
|
1165
|
+
Ne as createRouter,
|
|
1153
1166
|
Jt as deepEqual,
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1167
|
+
K as default,
|
|
1168
|
+
Ce as effect,
|
|
1169
|
+
ct as get,
|
|
1170
|
+
De as getTracked,
|
|
1157
1171
|
Mt as html,
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1172
|
+
Fe as http,
|
|
1173
|
+
Ie as list,
|
|
1174
|
+
Ve as peek,
|
|
1175
|
+
qe as portal,
|
|
1176
|
+
Le as ref,
|
|
1177
|
+
Ge as set,
|
|
1163
1178
|
_t as shallowEqual,
|
|
1164
|
-
|
|
1165
|
-
|
|
1179
|
+
We as strictEqual,
|
|
1180
|
+
Pe as t,
|
|
1181
|
+
Ae as untrack
|
|
1166
1182
|
};
|
|
1167
1183
|
//# sourceMappingURL=index.js.map
|