@manyducks.co/dolla 2.0.0-alpha.31 → 2.0.0-alpha.33
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 +2 -2
- package/dist/core/context.d.ts +27 -20
- package/dist/core/dolla.d.ts +18 -10
- package/dist/core/markup.d.ts +23 -2
- package/dist/core/nodes/view.d.ts +1 -2
- package/dist/core/store.d.ts +3 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +231 -234
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.js +2 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/markup-Dbw-610R.js +1525 -0
- package/dist/markup-Dbw-610R.js.map +1 -0
- package/dist/modules/router.d.ts +2 -2
- package/docs/i18n.md +2 -2
- package/docs/router.md +12 -9
- package/docs/state.md +2 -2
- package/docs/stores.md +18 -18
- package/docs/views.md +56 -70
- package/notes/readme-scratch.md +29 -7
- package/notes/scratch.md +135 -0
- package/notes/stores.md +17 -37
- package/notes/viewstate.md +15 -0
- package/package.json +1 -1
- package/build.js +0 -34
- package/dist/markup-D1i09ddt.js +0 -1563
- package/dist/markup-D1i09ddt.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var ue = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var At = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
5
|
var fe = (o, t, e) => t in o ? ue(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
6
|
-
var d = (o, t, e) => fe(o, typeof t != "symbol" ? t + "" : t, e),
|
|
7
|
-
var i = (o, t, e) => (
|
|
8
|
-
var
|
|
6
|
+
var d = (o, t, e) => fe(o, typeof t != "symbol" ? t + "" : t, e), Nt = (o, t, e) => t.has(o) || At("Cannot " + e);
|
|
7
|
+
var i = (o, t, e) => (Nt(o, t, "read from private field"), e ? e.call(o) : t.get(o)), l = (o, t, e) => t.has(o) ? At("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), m = (o, t, e, s) => (Nt(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e), f = (o, t, e) => (Nt(o, t, "access private method"), e);
|
|
8
|
+
var st = (o, t, e, s) => ({
|
|
9
9
|
set _(n) {
|
|
10
10
|
m(o, t, n, e);
|
|
11
11
|
},
|
|
@@ -13,15 +13,15 @@ var et = (o, t, e, s) => ({
|
|
|
13
13
|
return i(o, t, s);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { a as Zt, b as de, i as
|
|
17
|
-
import { F as
|
|
18
|
-
function
|
|
16
|
+
import { a as Zt, b as de, i as tt, I as te, c as me, d as Wt, e as x, s as Gt, f as E, g as et, P as ee, h as we, t as Bt, j as Ht, k as pe, l as zt, p as ge, m as Kt, S as ye, n as be, o as $e, q as ve, r as Ee, u as ke, C as Re, v as Qt, w as Jt, x as _e, y as Et, z as kt, V as Se, A as Le, B as Me, D as xe } from "./markup-Dbw-610R.js";
|
|
17
|
+
import { F as ls, G as hs, E as cs } from "./markup-Dbw-610R.js";
|
|
18
|
+
function nt(o) {
|
|
19
19
|
return Zt(o, "Expected `path` to be a string. Got type: %t, value: %v"), o.split("/").map((t) => t.trim()).filter((t) => t !== "");
|
|
20
20
|
}
|
|
21
21
|
function z(o) {
|
|
22
22
|
var e;
|
|
23
23
|
de(
|
|
24
|
-
(s) =>
|
|
24
|
+
(s) => tt(s == null ? void 0 : s.toString),
|
|
25
25
|
o,
|
|
26
26
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
27
27
|
), o = o.filter((s) => s).flatMap(String);
|
|
@@ -61,43 +61,43 @@ function De(o) {
|
|
|
61
61
|
}
|
|
62
62
|
function se(o, t, e = {}) {
|
|
63
63
|
var a;
|
|
64
|
-
const [s, n] = t.split("?"), r =
|
|
64
|
+
const [s, n] = t.split("?"), r = nt(s);
|
|
65
65
|
t: for (const c of o) {
|
|
66
66
|
const { fragments: h } = c;
|
|
67
67
|
if (!(((a = h[h.length - 1]) == null ? void 0 : a.type) === 3) && h.length !== r.length || e.willMatch && !e.willMatch(c))
|
|
68
68
|
continue t;
|
|
69
|
-
const
|
|
69
|
+
const v = [];
|
|
70
70
|
e: for (let u = 0; u < h.length; u++) {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
71
|
+
const F = r[u], R = h[u];
|
|
72
|
+
if (F == null && R.type !== 3)
|
|
73
73
|
continue t;
|
|
74
74
|
switch (R.type) {
|
|
75
75
|
case 1:
|
|
76
|
-
if (R.name.toLowerCase() ===
|
|
77
|
-
|
|
76
|
+
if (R.name.toLowerCase() === F.toLowerCase()) {
|
|
77
|
+
v.push(R);
|
|
78
78
|
break;
|
|
79
79
|
} else
|
|
80
80
|
continue t;
|
|
81
81
|
case 2:
|
|
82
|
-
|
|
82
|
+
v.push({ ...R, value: F });
|
|
83
83
|
break;
|
|
84
84
|
case 3:
|
|
85
|
-
|
|
85
|
+
v.push({ ...R, value: r.slice(u).join("/") });
|
|
86
86
|
break e;
|
|
87
87
|
case 4:
|
|
88
|
-
if (isNaN(Number(
|
|
88
|
+
if (isNaN(Number(F)))
|
|
89
89
|
continue t;
|
|
90
|
-
|
|
90
|
+
v.push({ ...R, value: Number(F) });
|
|
91
91
|
break;
|
|
92
92
|
default:
|
|
93
93
|
throw new Error(`Unknown fragment type: ${R.type}`);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
const k = {};
|
|
97
|
-
for (const u of
|
|
97
|
+
for (const u of v)
|
|
98
98
|
u.type === 2 && (k[u.name] = decodeURIComponent(u.value)), u.type === 4 && (k[u.name] = u.value), u.type === 3 && (k.wildcard = "/" + decodeURIComponent(u.value));
|
|
99
99
|
return {
|
|
100
|
-
path: "/" +
|
|
100
|
+
path: "/" + v.map((u) => u.value).join("/"),
|
|
101
101
|
pattern: "/" + h.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
|
|
102
102
|
params: k,
|
|
103
103
|
query: De(n),
|
|
@@ -105,7 +105,7 @@ function se(o, t, e = {}) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Fe(o) {
|
|
109
109
|
const t = [], e = [], s = [], n = [];
|
|
110
110
|
for (const a of o) {
|
|
111
111
|
const { fragments: c } = a;
|
|
@@ -123,8 +123,8 @@ function Pe(o) {
|
|
|
123
123
|
const r = (a, c) => a.fragments.length > c.fragments.length ? -1 : 1;
|
|
124
124
|
return t.sort(r), e.sort(r), s.sort(r), n.sort(r), [...t, ...e, ...s, ...n];
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const t =
|
|
126
|
+
function Ne(o) {
|
|
127
|
+
const t = nt(o), e = [];
|
|
128
128
|
for (let s = 0; s < t.length; s++) {
|
|
129
129
|
const n = t[s];
|
|
130
130
|
if (n === "*") {
|
|
@@ -147,28 +147,28 @@ function Te(o) {
|
|
|
147
147
|
}
|
|
148
148
|
return e;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
return new
|
|
150
|
+
function ss(o) {
|
|
151
|
+
return new Oe(o);
|
|
152
152
|
}
|
|
153
153
|
const re = Symbol.for("DollaRouterMountMethod"), ne = Symbol.for("DollaRouterUnmountMethod");
|
|
154
|
-
function
|
|
154
|
+
function Pt(o) {
|
|
155
155
|
return (o == null ? void 0 : o[te]) === !0;
|
|
156
156
|
}
|
|
157
|
-
async function
|
|
157
|
+
async function Pe(o, t) {
|
|
158
158
|
return o[re](t);
|
|
159
159
|
}
|
|
160
|
-
async function
|
|
160
|
+
async function Te(o) {
|
|
161
161
|
return o[ne]();
|
|
162
162
|
}
|
|
163
|
-
var Yt, K, L,
|
|
164
|
-
class
|
|
163
|
+
var Yt, K, L, St, N, Q, it, I, q, P, at, p, Tt, ie, ae, rt, Ot, oe, Ut;
|
|
164
|
+
class Oe {
|
|
165
165
|
constructor(t) {
|
|
166
166
|
l(this, p);
|
|
167
167
|
d(this, Yt, !0);
|
|
168
168
|
l(this, K);
|
|
169
169
|
l(this, L);
|
|
170
|
-
l(this,
|
|
171
|
-
l(this,
|
|
170
|
+
l(this, St, 0);
|
|
171
|
+
l(this, N, []);
|
|
172
172
|
l(this, Q, []);
|
|
173
173
|
l(this, it, !1);
|
|
174
174
|
/**
|
|
@@ -180,7 +180,7 @@ class Ue {
|
|
|
180
180
|
/**
|
|
181
181
|
* The current match object.
|
|
182
182
|
*/
|
|
183
|
-
l(this,
|
|
183
|
+
l(this, P);
|
|
184
184
|
l(this, at);
|
|
185
185
|
/**
|
|
186
186
|
* The currently matched route pattern, if any.
|
|
@@ -198,27 +198,27 @@ class Ue {
|
|
|
198
198
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
199
199
|
*/
|
|
200
200
|
d(this, "$query");
|
|
201
|
-
me(t, "Options must be an object. Got: %t"), [
|
|
202
|
-
t.routes.flatMap((e) => f(this, p,
|
|
201
|
+
me(t, "Options must be an object. Got: %t"), [st(this, P)._, st(this, at)._] = Wt(), this.$pattern = x([i(this, P)], (e) => e == null ? void 0 : e.pattern), this.$path = x([i(this, P)], (e) => (e == null ? void 0 : e.path) ?? window.location.pathname), this.$params = x([i(this, P)], (e) => (e == null ? void 0 : e.params) ?? {}, { equals: Gt }), this.$query = x([i(this, P)], (e) => (e == null ? void 0 : e.query) ?? {}, { equals: Gt }), t.hash && m(this, I, !0), m(this, Q, Fe(
|
|
202
|
+
t.routes.flatMap((e) => f(this, p, Ut).call(this, e)).map((e) => ({
|
|
203
203
|
pattern: e.pattern,
|
|
204
204
|
meta: e.meta,
|
|
205
|
-
fragments:
|
|
205
|
+
fragments: Ne(e.pattern)
|
|
206
206
|
}))
|
|
207
|
-
)),
|
|
207
|
+
)), Ie(i(this, Q));
|
|
208
208
|
}
|
|
209
209
|
async [(Yt = te, re)](t) {
|
|
210
210
|
m(this, K, t), m(this, L, t.createLogger("Dolla.router"));
|
|
211
211
|
const e = () => {
|
|
212
|
-
f(this, p,
|
|
212
|
+
f(this, p, rt).call(this);
|
|
213
213
|
};
|
|
214
214
|
window.addEventListener("popstate", e), i(this, q).push(() => window.removeEventListener("popstate", e));
|
|
215
215
|
const s = t.getRootElement();
|
|
216
216
|
i(this, q).push(
|
|
217
|
-
|
|
217
|
+
je(s, (n) => {
|
|
218
218
|
let r = n.getAttribute("href");
|
|
219
|
-
i(this, L).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(r) || (r = z([window.location.pathname, r])), f(this, p,
|
|
219
|
+
i(this, L).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(r) || (r = z([window.location.pathname, r])), f(this, p, Tt).call(this, r);
|
|
220
220
|
})
|
|
221
|
-
), i(this, L).info("will intercept clicks on <a> tags within root element", s), m(this, it, !0), await f(this, p,
|
|
221
|
+
), i(this, L).info("will intercept clicks on <a> tags within root element", s), m(this, it, !0), await f(this, p, rt).call(this);
|
|
222
222
|
}
|
|
223
223
|
async [ne]() {
|
|
224
224
|
for (const t of i(this, q))
|
|
@@ -241,27 +241,27 @@ class Ue {
|
|
|
241
241
|
* Navigates to another route.
|
|
242
242
|
*
|
|
243
243
|
* @example
|
|
244
|
-
*
|
|
245
|
-
*
|
|
244
|
+
* router.go("/login"); // navigate to `/login`
|
|
245
|
+
* router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
246
246
|
*/
|
|
247
247
|
go(t, e = {}) {
|
|
248
248
|
if (i(this, K) == null)
|
|
249
249
|
throw new Error("Routa methods won't work until you register it: Dolla.use(Routa, { /* ...options */ })");
|
|
250
250
|
let s;
|
|
251
|
-
Array.isArray(t) ? s = z(t) : s = t.toString(), s = Rt(window.location.pathname, s), e.preserveQuery && (s += window.location.search), e.replace ? f(this, p, ie).call(this, s) : f(this, p,
|
|
251
|
+
Array.isArray(t) ? s = z(t) : s = t.toString(), s = Rt(window.location.pathname, s), e.preserveQuery && (s += window.location.search), e.replace ? f(this, p, ie).call(this, s) : f(this, p, Tt).call(this, s);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
K = new WeakMap(), L = new WeakMap(),
|
|
254
|
+
K = new WeakMap(), L = new WeakMap(), St = new WeakMap(), N = new WeakMap(), Q = new WeakMap(), it = new WeakMap(), I = new WeakMap(), q = new WeakMap(), P = new WeakMap(), at = new WeakMap(), p = new WeakSet(), Tt = function(t, e) {
|
|
255
255
|
var s;
|
|
256
|
-
(s = i(this, L)) == null || s.info("(push)", t), window.history.pushState(e, "", i(this, I) ? "/#" + t : t), f(this, p,
|
|
256
|
+
(s = i(this, L)) == null || s.info("(push)", t), window.history.pushState(e, "", i(this, I) ? "/#" + t : t), f(this, p, rt).call(this, t);
|
|
257
257
|
}, ie = function(t, e) {
|
|
258
258
|
var s;
|
|
259
|
-
(s = i(this, L)) == null || s.info("(replace)", t), window.history.replaceState(e, "", i(this, I) ? "/#" + t : t), f(this, p,
|
|
259
|
+
(s = i(this, L)) == null || s.info("(replace)", t), window.history.replaceState(e, "", i(this, I) ? "/#" + t : t), f(this, p, rt).call(this, t);
|
|
260
260
|
}, ae = function() {
|
|
261
261
|
return i(this, I) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
|
|
262
|
-
},
|
|
262
|
+
}, rt = async function(t) {
|
|
263
263
|
var c;
|
|
264
|
-
const e = i(this, L), s = (c = i(this, K)) == null ? void 0 : c.getRootView(), n = t ? new URL(t, window.location.origin) : f(this, p, ae).call(this), { match: r, journey: a } = await f(this, p,
|
|
264
|
+
const e = i(this, L), s = (c = i(this, K)) == null ? void 0 : c.getRootView(), n = t ? new URL(t, window.location.origin) : f(this, p, ae).call(this), { match: r, journey: a } = await f(this, p, Ot).call(this, n);
|
|
265
265
|
for (const h of a)
|
|
266
266
|
switch (h.kind) {
|
|
267
267
|
case "match":
|
|
@@ -278,9 +278,9 @@ K = new WeakMap(), L = new WeakMap(), _t = new WeakMap(), P = new WeakMap(), Q =
|
|
|
278
278
|
const h = this.$pattern.get();
|
|
279
279
|
i(this, at).call(this, r), s && r.pattern !== h && f(this, p, oe).call(this, s, r);
|
|
280
280
|
} else
|
|
281
|
-
i(this, it) && e.crash(new
|
|
281
|
+
i(this, it) && e.crash(new qe(`Failed to match route '${n.pathname}'`));
|
|
282
282
|
return { match: r, journey: a };
|
|
283
|
-
},
|
|
283
|
+
}, Ot = async function(t, e = []) {
|
|
284
284
|
const s = se(i(this, Q), t.pathname);
|
|
285
285
|
if (!s)
|
|
286
286
|
return {
|
|
@@ -295,21 +295,21 @@ K = new WeakMap(), L = new WeakMap(), _t = new WeakMap(), P = new WeakMap(), Q =
|
|
|
295
295
|
}
|
|
296
296
|
}), n != null) {
|
|
297
297
|
let r;
|
|
298
|
-
if (
|
|
299
|
-
r =
|
|
300
|
-
else if (
|
|
298
|
+
if (E(n))
|
|
299
|
+
r = Ve(n, s.params);
|
|
300
|
+
else if (tt(n)) {
|
|
301
301
|
const a = {
|
|
302
302
|
path: s.path,
|
|
303
303
|
pattern: s.pattern,
|
|
304
304
|
params: s.params,
|
|
305
305
|
query: s.query
|
|
306
306
|
};
|
|
307
|
-
if (r = await n(a), !
|
|
307
|
+
if (r = await n(a), !E(r))
|
|
308
308
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
309
309
|
r.startsWith("/") || (r = Rt(s.path, r));
|
|
310
310
|
} else
|
|
311
311
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
312
|
-
return f(this, p,
|
|
312
|
+
return f(this, p, Ot).call(this, new URL(r, window.location.origin), [
|
|
313
313
|
...e,
|
|
314
314
|
{ kind: "redirect", message: `redirecting '${s.path}' -> '${r}'` }
|
|
315
315
|
]);
|
|
@@ -321,11 +321,11 @@ K = new WeakMap(), L = new WeakMap(), _t = new WeakMap(), P = new WeakMap(), Q =
|
|
|
321
321
|
oe = function(t, e) {
|
|
322
322
|
const s = e.meta.layers;
|
|
323
323
|
for (let n = 0; n < s.length; n++) {
|
|
324
|
-
const r = s[n], a = i(this,
|
|
324
|
+
const r = s[n], a = i(this, N)[n];
|
|
325
325
|
if ((a == null ? void 0 : a.id) !== r.id) {
|
|
326
|
-
m(this,
|
|
327
|
-
const c = i(this,
|
|
328
|
-
i(this,
|
|
326
|
+
m(this, N, i(this, N).slice(0, n)), a == null || a.view.unmount();
|
|
327
|
+
const c = i(this, N).at(-1), w = ((c == null ? void 0 : c.view) ?? t).setChildView(r.view);
|
|
328
|
+
i(this, N).push({ id: r.id, view: w });
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}, /**
|
|
@@ -334,8 +334,8 @@ oe = function(t, e) {
|
|
|
334
334
|
* @param route - Route config object.
|
|
335
335
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
336
336
|
*/
|
|
337
|
-
|
|
338
|
-
if (!
|
|
337
|
+
Ut = function(t, e = [], s = []) {
|
|
338
|
+
if (!et(t) || !E(t.path))
|
|
339
339
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${t}`);
|
|
340
340
|
if (t.redirect && t.routes)
|
|
341
341
|
throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
|
|
@@ -345,27 +345,27 @@ Ct = function(t, e = [], s = []) {
|
|
|
345
345
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
346
346
|
let n = [];
|
|
347
347
|
for (const h of e)
|
|
348
|
-
n.push(...
|
|
349
|
-
n.push(...
|
|
348
|
+
n.push(...nt(h.path));
|
|
349
|
+
n.push(...nt(t.path)), n[n.length - 1] === "*" && n.pop();
|
|
350
350
|
const r = [];
|
|
351
351
|
if (t.redirect) {
|
|
352
352
|
let h = t.redirect;
|
|
353
|
-
return
|
|
354
|
-
pattern: "/" + z([...n, ...
|
|
353
|
+
return E(h) && (h = Rt(z(n), h), h.startsWith("/") || (h = "/" + h)), r.push({
|
|
354
|
+
pattern: "/" + z([...n, ...nt(t.path)]),
|
|
355
355
|
meta: {
|
|
356
356
|
redirect: h
|
|
357
357
|
}
|
|
358
358
|
}), r;
|
|
359
359
|
}
|
|
360
360
|
let a = ee;
|
|
361
|
-
if (
|
|
361
|
+
if (tt(t.view))
|
|
362
362
|
a = t.view;
|
|
363
363
|
else if (t.view)
|
|
364
364
|
throw new TypeError(`Route '${t.path}' expected a view function or undefined. Got: ${t.view}`);
|
|
365
|
-
const c = { id:
|
|
365
|
+
const c = { id: st(this, St)._++, view: a };
|
|
366
366
|
if (t.routes)
|
|
367
367
|
for (const h of t.routes)
|
|
368
|
-
r.push(...f(this, p,
|
|
368
|
+
r.push(...f(this, p, Ut).call(this, h, [...e, t], [...s, c]));
|
|
369
369
|
else
|
|
370
370
|
r.push({
|
|
371
371
|
pattern: parent ? z([...e.map((h) => h.path), t.path]) : t.path,
|
|
@@ -377,8 +377,8 @@ Ct = function(t, e = [], s = []) {
|
|
|
377
377
|
});
|
|
378
378
|
return r;
|
|
379
379
|
};
|
|
380
|
-
const
|
|
381
|
-
function
|
|
380
|
+
const Ue = /(noopener|noreferrer) (noopener|noreferrer)/, Ce = /^[\w-_]+:/;
|
|
381
|
+
function je(o, t, e = window) {
|
|
382
382
|
function s(r) {
|
|
383
383
|
return !r || r === o ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
|
|
384
384
|
}
|
|
@@ -386,24 +386,24 @@ function Ve(o, t, e = window) {
|
|
|
386
386
|
if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
|
|
387
387
|
return;
|
|
388
388
|
const a = s(r.target);
|
|
389
|
-
a && (e.location.protocol !== a.protocol || e.location.hostname !== a.hostname || e.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" &&
|
|
389
|
+
a && (e.location.protocol !== a.protocol || e.location.hostname !== a.hostname || e.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && Ue.test(a.getAttribute("rel")) || Ce.test(a.getAttribute("href")) || (r.preventDefault(), t(a)));
|
|
390
390
|
}
|
|
391
391
|
return o.addEventListener("click", n), function() {
|
|
392
392
|
o.removeEventListener("click", n);
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function Ve(o, t) {
|
|
396
396
|
for (const e in t) {
|
|
397
397
|
const s = t[e].toString();
|
|
398
398
|
o = o.replace(`{${e}}`, s).replace(`{#${e}}`, s);
|
|
399
399
|
}
|
|
400
400
|
return o;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function Ie(o) {
|
|
403
403
|
for (const t of o)
|
|
404
404
|
if (t.meta.redirect) {
|
|
405
405
|
let e;
|
|
406
|
-
if (!
|
|
406
|
+
if (!tt(t.meta.redirect)) if (E(t.meta.redirect)) {
|
|
407
407
|
if (e = t.meta.redirect, !se(o, e, {
|
|
408
408
|
willMatch(n) {
|
|
409
409
|
return n !== t;
|
|
@@ -414,14 +414,14 @@ function qe(o) {
|
|
|
414
414
|
throw new TypeError(`Expected a string or redirect function. Got: ${t.meta.redirect}`);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class qe extends Error {
|
|
418
418
|
}
|
|
419
|
-
var W, Lt, Mt, ot,
|
|
420
|
-
class
|
|
419
|
+
var W, Lt, Mt, ot, _, S;
|
|
420
|
+
class We {
|
|
421
421
|
constructor(t) {
|
|
422
|
-
l(this,
|
|
422
|
+
l(this, _);
|
|
423
423
|
l(this, W, []);
|
|
424
|
-
l(this, Lt,
|
|
424
|
+
l(this, Lt, Ae());
|
|
425
425
|
l(this, Mt);
|
|
426
426
|
l(this, ot);
|
|
427
427
|
m(this, Mt, t), m(this, ot, t.createLogger("Dolla.http"));
|
|
@@ -438,32 +438,32 @@ class Ae {
|
|
|
438
438
|
};
|
|
439
439
|
}
|
|
440
440
|
async get(t, e) {
|
|
441
|
-
return f(this,
|
|
441
|
+
return f(this, _, S).call(this, "get", t, e);
|
|
442
442
|
}
|
|
443
443
|
async put(t, e) {
|
|
444
|
-
return f(this,
|
|
444
|
+
return f(this, _, S).call(this, "put", t, e);
|
|
445
445
|
}
|
|
446
446
|
async patch(t, e) {
|
|
447
|
-
return f(this,
|
|
447
|
+
return f(this, _, S).call(this, "patch", t, e);
|
|
448
448
|
}
|
|
449
449
|
async post(t, e) {
|
|
450
|
-
return f(this,
|
|
450
|
+
return f(this, _, S).call(this, "post", t, e);
|
|
451
451
|
}
|
|
452
452
|
async delete(t, e) {
|
|
453
|
-
return f(this,
|
|
453
|
+
return f(this, _, S).call(this, "delete", t, e);
|
|
454
454
|
}
|
|
455
455
|
async head(t, e) {
|
|
456
|
-
return f(this,
|
|
456
|
+
return f(this, _, S).call(this, "head", t, e);
|
|
457
457
|
}
|
|
458
458
|
async options(t, e) {
|
|
459
|
-
return f(this,
|
|
459
|
+
return f(this, _, S).call(this, "options", t, e);
|
|
460
460
|
}
|
|
461
461
|
async trace(t, e) {
|
|
462
|
-
return f(this,
|
|
462
|
+
return f(this, _, S).call(this, "trace", t, e);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
W = new WeakMap(), Lt = new WeakMap(), Mt = new WeakMap(), ot = new WeakMap(),
|
|
466
|
-
return new
|
|
465
|
+
W = new WeakMap(), Lt = new WeakMap(), Mt = new WeakMap(), ot = new WeakMap(), _ = new WeakSet(), S = async function(t, e, s) {
|
|
466
|
+
return new He({
|
|
467
467
|
...s,
|
|
468
468
|
method: t,
|
|
469
469
|
uri: e,
|
|
@@ -472,14 +472,14 @@ W = new WeakMap(), Lt = new WeakMap(), Mt = new WeakMap(), ot = new WeakMap(), S
|
|
|
472
472
|
logger: i(this, ot)
|
|
473
473
|
}).fetch();
|
|
474
474
|
};
|
|
475
|
-
function
|
|
475
|
+
function Ae() {
|
|
476
476
|
if (typeof window < "u" && window.fetch)
|
|
477
477
|
return window.fetch.bind(window);
|
|
478
478
|
if (typeof global < "u" && global.fetch)
|
|
479
479
|
return global.fetch.bind(global);
|
|
480
480
|
throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
|
|
481
481
|
}
|
|
482
|
-
class
|
|
482
|
+
class Ge extends Error {
|
|
483
483
|
constructor(e) {
|
|
484
484
|
const { status: s, statusText: n, method: r, url: a } = e, c = `${s} ${n}: Request failed (${r.toUpperCase()} ${a.toString()})`;
|
|
485
485
|
super(c);
|
|
@@ -504,7 +504,7 @@ class Be {
|
|
|
504
504
|
t.forEach((e, s) => {
|
|
505
505
|
this.headers.set(s, e);
|
|
506
506
|
});
|
|
507
|
-
else if (
|
|
507
|
+
else if (et(t))
|
|
508
508
|
for (const e in t) {
|
|
509
509
|
const s = t[e];
|
|
510
510
|
s instanceof Date ? this.headers.set(e, s.toISOString()) : s != null && this.headers.set(e, String(s));
|
|
@@ -518,7 +518,7 @@ class Be {
|
|
|
518
518
|
t.forEach((e, s) => {
|
|
519
519
|
this.url.searchParams.set(s, e);
|
|
520
520
|
});
|
|
521
|
-
else if (
|
|
521
|
+
else if (et(t))
|
|
522
522
|
for (const e in t) {
|
|
523
523
|
const s = t[e];
|
|
524
524
|
s instanceof Date ? this.url.searchParams.set(e, s.toISOString()) : s != null && this.url.searchParams.set(e, String(s));
|
|
@@ -527,7 +527,7 @@ class Be {
|
|
|
527
527
|
throw new TypeError(`Unknown query params type. Got: ${t}`);
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
-
class
|
|
530
|
+
class He {
|
|
531
531
|
constructor(t) {
|
|
532
532
|
d(this, "_middleware");
|
|
533
533
|
d(this, "_fetch");
|
|
@@ -545,14 +545,14 @@ class ze {
|
|
|
545
545
|
} else
|
|
546
546
|
await this._handler();
|
|
547
547
|
if (this._response.status < 200 || this._response.status >= 400)
|
|
548
|
-
throw new
|
|
548
|
+
throw new Ge(this._response);
|
|
549
549
|
return this._response;
|
|
550
550
|
}
|
|
551
551
|
// This is the function that performs the actual request after the final middleware.
|
|
552
552
|
async _handler() {
|
|
553
553
|
let t;
|
|
554
554
|
const e = this._request;
|
|
555
|
-
!e.headers.has("content-type") &&
|
|
555
|
+
!e.headers.has("content-type") && et(e.body) ? (e.headers.set("content-type", "application/json"), t = JSON.stringify(e.body)) : t = e.body;
|
|
556
556
|
const s = await this._fetch(e.url.toString(), {
|
|
557
557
|
method: e.method,
|
|
558
558
|
headers: e.headers,
|
|
@@ -569,10 +569,10 @@ class ze {
|
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
var xt, J,
|
|
573
|
-
class
|
|
572
|
+
var xt, J, H, Ct, le;
|
|
573
|
+
class ze {
|
|
574
574
|
constructor(t, e) {
|
|
575
|
-
l(this,
|
|
575
|
+
l(this, H);
|
|
576
576
|
d(this, "dolla");
|
|
577
577
|
d(this, "config");
|
|
578
578
|
l(this, xt, !1);
|
|
@@ -582,14 +582,14 @@ class Ke {
|
|
|
582
582
|
async load() {
|
|
583
583
|
let t;
|
|
584
584
|
if (!i(this, xt)) {
|
|
585
|
-
if (
|
|
586
|
-
if (t = await this.config.fetch(), !
|
|
585
|
+
if (tt(this.config.fetch)) {
|
|
586
|
+
if (t = await this.config.fetch(), !et(t))
|
|
587
587
|
throw new Error(`Fetch function did not return an object of language strings: ${t}`);
|
|
588
|
-
} else if (
|
|
588
|
+
} else if (E(this.config.path)) {
|
|
589
589
|
const e = await fetch(this.config.path);
|
|
590
590
|
if (e.ok) {
|
|
591
591
|
const s = await e.json();
|
|
592
|
-
if (
|
|
592
|
+
if (et(s))
|
|
593
593
|
t = s;
|
|
594
594
|
else
|
|
595
595
|
throw new Error(
|
|
@@ -600,7 +600,7 @@ class Ke {
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
if (t) {
|
|
603
|
-
const e = f(this,
|
|
603
|
+
const e = f(this, H, Ct).call(this, t);
|
|
604
604
|
for (const s of e)
|
|
605
605
|
i(this, J).set(s[0], s[1]);
|
|
606
606
|
} else
|
|
@@ -615,15 +615,15 @@ class Ke {
|
|
|
615
615
|
return i(this, J).has(t);
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
xt = new WeakMap(), J = new WeakMap(),
|
|
618
|
+
xt = new WeakMap(), J = new WeakMap(), H = new WeakSet(), Ct = function(t, e = []) {
|
|
619
619
|
const s = [];
|
|
620
620
|
for (const n in t)
|
|
621
621
|
switch (Bt(t[n])) {
|
|
622
622
|
case "string":
|
|
623
|
-
s.push([[...e, n].join("."), f(this,
|
|
623
|
+
s.push([[...e, n].join("."), f(this, H, le).call(this, t[n])]);
|
|
624
624
|
break;
|
|
625
625
|
case "object":
|
|
626
|
-
s.push(...f(this,
|
|
626
|
+
s.push(...f(this, H, Ct).call(this, t[n], [...e, n]));
|
|
627
627
|
break;
|
|
628
628
|
default:
|
|
629
629
|
throw new Error(
|
|
@@ -640,7 +640,7 @@ xt = new WeakMap(), J = new WeakMap(), B = new WeakSet(), jt = function(t, e = [
|
|
|
640
640
|
segments: []
|
|
641
641
|
};
|
|
642
642
|
let n = "", r = 0, a = 0, c, h, w;
|
|
643
|
-
const
|
|
643
|
+
const v = () => {
|
|
644
644
|
c = {
|
|
645
645
|
type: 1,
|
|
646
646
|
name: "",
|
|
@@ -659,7 +659,7 @@ xt = new WeakMap(), J = new WeakMap(), B = new WeakSet(), jt = function(t, e = [
|
|
|
659
659
|
}
|
|
660
660
|
switch (a) {
|
|
661
661
|
case 0:
|
|
662
|
-
t[r] === "{" && t[r + 1] === "{" ? (a = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""),
|
|
662
|
+
t[r] === "{" && t[r + 1] === "{" ? (a = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""), v()) : (n += t[r], r++);
|
|
663
663
|
break;
|
|
664
664
|
case 1:
|
|
665
665
|
t[r] === "|" ? (a = 2, r += 1, c.name = n, n = "", k()) : t[r] === "}" && t[r + 1] === "}" ? (a = 0, r += 2, c.name = n, n = "", s.segments.push(c)) : (n += t[r], r++);
|
|
@@ -680,21 +680,21 @@ xt = new WeakMap(), J = new WeakMap(), B = new WeakSet(), jt = function(t, e = [
|
|
|
680
680
|
}
|
|
681
681
|
return a === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
|
|
682
682
|
};
|
|
683
|
-
var lt,
|
|
684
|
-
class
|
|
683
|
+
var lt, T, b, ht, ct, ut, ft, $, he, jt, Vt, It, ce;
|
|
684
|
+
class Ke {
|
|
685
685
|
constructor(t) {
|
|
686
686
|
l(this, $);
|
|
687
687
|
l(this, lt);
|
|
688
|
-
l(this,
|
|
688
|
+
l(this, T);
|
|
689
689
|
l(this, b, /* @__PURE__ */ new Map());
|
|
690
690
|
l(this, ht, []);
|
|
691
691
|
l(this, ct, /* @__PURE__ */ new Map());
|
|
692
692
|
l(this, ut, "auto");
|
|
693
693
|
d(this, "$locale");
|
|
694
694
|
l(this, ft);
|
|
695
|
-
m(this, lt, t), m(this,
|
|
696
|
-
const [e, s] =
|
|
697
|
-
this.$locale = e, m(this, ft, s), this.addFormat("number", (n, r, a) => f(this, $,
|
|
695
|
+
m(this, lt, t), m(this, T, t.createLogger("Dolla.i18n"));
|
|
696
|
+
const [e, s] = Wt();
|
|
697
|
+
this.$locale = e, m(this, ft, s), this.addFormat("number", (n, r, a) => f(this, $, jt).call(this, Number(r), a)), this.addFormat("datetime", (n, r, a) => f(this, $, Vt).call(this, r, a)), this.addFormat("list", (n, r, a) => f(this, $, It).call(this, r, a)), t.beforeMount(async () => {
|
|
698
698
|
i(this, b).size > 0 && await this.setLocale(i(this, ut));
|
|
699
699
|
});
|
|
700
700
|
}
|
|
@@ -703,13 +703,13 @@ class Qe {
|
|
|
703
703
|
}
|
|
704
704
|
setup(t) {
|
|
705
705
|
if (t.translations.forEach((e) => {
|
|
706
|
-
i(this, b).set(e.locale, new
|
|
706
|
+
i(this, b).set(e.locale, new ze(e, i(this, lt)));
|
|
707
707
|
}), t.locale && t.locale !== "auto") {
|
|
708
708
|
if (!t.translations.some((s) => s.locale === t.locale))
|
|
709
709
|
throw new Error(`Initial locale '${t.locale}' is not registered in the locales array.`);
|
|
710
710
|
m(this, ut, t.locale);
|
|
711
711
|
}
|
|
712
|
-
i(this,
|
|
712
|
+
i(this, T).info(
|
|
713
713
|
`${i(this, b).size} language${i(this, b).size === 1 ? "" : "s"} supported: '${[...i(this, b).keys()].join("', '")}'`
|
|
714
714
|
);
|
|
715
715
|
}
|
|
@@ -734,9 +734,9 @@ class Qe {
|
|
|
734
734
|
throw new Error(`Locale '${t}' has no translation.`);
|
|
735
735
|
const s = i(this, b).get(e);
|
|
736
736
|
try {
|
|
737
|
-
await s.load(), m(this, ht, []), i(this, ft).call(this, e), i(this,
|
|
737
|
+
await s.load(), m(this, ht, []), i(this, ft).call(this, e), i(this, T).info("set language to " + e);
|
|
738
738
|
} catch (r) {
|
|
739
|
-
r instanceof Error && i(this,
|
|
739
|
+
r instanceof Error && i(this, T).crash(r);
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
742
|
/**
|
|
@@ -797,7 +797,7 @@ class Qe {
|
|
|
797
797
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
798
798
|
*/
|
|
799
799
|
number(t, e) {
|
|
800
|
-
return x([this.$locale, t], (s, n) => f(this, $,
|
|
800
|
+
return x([this.$locale, t], (s, n) => f(this, $, jt).call(this, n, e));
|
|
801
801
|
}
|
|
802
802
|
/**
|
|
803
803
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -809,7 +809,7 @@ class Qe {
|
|
|
809
809
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
810
810
|
*/
|
|
811
811
|
dateTime(t, e) {
|
|
812
|
-
return x([this.$locale, t], (s, n) => f(this, $,
|
|
812
|
+
return x([this.$locale, t], (s, n) => f(this, $, Vt).call(this, n, e));
|
|
813
813
|
}
|
|
814
814
|
/**
|
|
815
815
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -821,10 +821,10 @@ class Qe {
|
|
|
821
821
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
822
822
|
*/
|
|
823
823
|
list(t, e) {
|
|
824
|
-
return x([this.$locale, t], (s, n) => f(this, $,
|
|
824
|
+
return x([this.$locale, t], (s, n) => f(this, $, It).call(this, n, e));
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
lt = new WeakMap(),
|
|
827
|
+
lt = new WeakMap(), T = new WeakMap(), b = new WeakMap(), ht = new WeakMap(), ct = new WeakMap(), ut = new WeakMap(), ft = new WeakMap(), $ = new WeakSet(), he = function(t, e, s) {
|
|
828
828
|
var h;
|
|
829
829
|
const n = f(this, $, ce).call(this, e, s);
|
|
830
830
|
if (n) return n;
|
|
@@ -843,27 +843,27 @@ lt = new WeakMap(), O = new WeakMap(), b = new WeakMap(), ht = new WeakMap(), ct
|
|
|
843
843
|
if (w.type === 0)
|
|
844
844
|
c += w.text;
|
|
845
845
|
else if (w.type === 1) {
|
|
846
|
-
let
|
|
846
|
+
let v = Qe(s, w.name);
|
|
847
847
|
const k = ((h = s.formatOverrides) == null ? void 0 : h[w.name]) ?? [...w.formats];
|
|
848
848
|
w.name === "count" && k.length === 0 && k.push({ name: "number", options: {} });
|
|
849
849
|
for (const u of k) {
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
850
|
+
const F = i(this, ct).get(u.name);
|
|
851
|
+
if (F == null) {
|
|
852
852
|
const R = new Error(
|
|
853
853
|
`Failed to load format '${u.name}' when processing '${e}', template: ${a}`
|
|
854
854
|
);
|
|
855
|
-
throw i(this,
|
|
855
|
+
throw i(this, T).crash(R), R;
|
|
856
856
|
}
|
|
857
|
-
|
|
857
|
+
v = F(t, v, u.options);
|
|
858
858
|
}
|
|
859
|
-
c +=
|
|
859
|
+
c += v;
|
|
860
860
|
}
|
|
861
861
|
return c;
|
|
862
|
-
},
|
|
862
|
+
}, jt = function(t, e) {
|
|
863
863
|
return new Intl.NumberFormat(this.$locale.get(), e).format(t);
|
|
864
|
+
}, Vt = function(t, e) {
|
|
865
|
+
return new Intl.DateTimeFormat(this.$locale.get(), e).format(E(t) ? new Date(t) : t);
|
|
864
866
|
}, It = function(t, e) {
|
|
865
|
-
return new Intl.DateTimeFormat(this.$locale.get(), e).format(v(t) ? new Date(t) : t);
|
|
866
|
-
}, qt = function(t, e) {
|
|
867
867
|
return new Intl.ListFormat(this.$locale.get(), e).format(t);
|
|
868
868
|
}, // relativeTime(): State<string> {
|
|
869
869
|
// }
|
|
@@ -872,7 +872,7 @@ ce = function(t, e) {
|
|
|
872
872
|
if (s[0] === t && we(s[1], e))
|
|
873
873
|
return s[2];
|
|
874
874
|
};
|
|
875
|
-
function
|
|
875
|
+
function Qe(o, t) {
|
|
876
876
|
const e = String(t).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
877
877
|
let s = o;
|
|
878
878
|
for (; e.length > 0; ) {
|
|
@@ -881,8 +881,8 @@ function Je(o, t) {
|
|
|
881
881
|
}
|
|
882
882
|
return s;
|
|
883
883
|
}
|
|
884
|
-
function
|
|
885
|
-
return
|
|
884
|
+
function Je(o) {
|
|
885
|
+
return Ht`
|
|
886
886
|
<div
|
|
887
887
|
style=${{
|
|
888
888
|
backgroundColor: "#880000",
|
|
@@ -896,7 +896,7 @@ function Xe(o) {
|
|
|
896
896
|
<h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
|
|
897
897
|
<p style=${{ marginBottom: "0.25rem" }}>
|
|
898
898
|
<span style=${{ fontFamily: "monospace" }}>${o.loggerName}</span>
|
|
899
|
-
${pe(o.uid,
|
|
899
|
+
${pe(o.uid, Ht`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${o.uid}]</span>`)}
|
|
900
900
|
${" "}says:
|
|
901
901
|
</p>
|
|
902
902
|
<blockquote
|
|
@@ -928,15 +928,15 @@ function Xe(o) {
|
|
|
928
928
|
</div>
|
|
929
929
|
`;
|
|
930
930
|
}
|
|
931
|
-
var dt, X,
|
|
932
|
-
class
|
|
931
|
+
var dt, X, O, A, G, Y, Dt, M, mt, D, qt, _t;
|
|
932
|
+
class Xe {
|
|
933
933
|
constructor(t) {
|
|
934
|
-
l(this,
|
|
934
|
+
l(this, D);
|
|
935
935
|
l(this, dt);
|
|
936
936
|
l(this, X);
|
|
937
937
|
// Keys ensure only the most recent callback queued with a certain key
|
|
938
938
|
// will be called, keeping DOM operations to a minimum.
|
|
939
|
-
l(this,
|
|
939
|
+
l(this, O, /* @__PURE__ */ new Map());
|
|
940
940
|
// All unkeyed writes are run on every batch.
|
|
941
941
|
l(this, A, []);
|
|
942
942
|
// All read callbacks are run before updates on every batch.
|
|
@@ -946,7 +946,7 @@ class Ye {
|
|
|
946
946
|
// This may not be desirable, because while it does prevent hitching it sometimes leaves
|
|
947
947
|
// the state partially rendered for a brief second and certain elements can be seen to update after the fact.
|
|
948
948
|
// But the tradeoff here is snappier navigation with possibly slightly out of date DOM updates on heavy pages.
|
|
949
|
-
l(this,
|
|
949
|
+
l(this, Dt, !0);
|
|
950
950
|
l(this, M, 0);
|
|
951
951
|
l(this, mt, new Intl.NumberFormat("en-US", {
|
|
952
952
|
maximumFractionDigits: 2,
|
|
@@ -961,49 +961,49 @@ class Ye {
|
|
|
961
961
|
* Queues a callback that runs before the next batch of writes.
|
|
962
962
|
*/
|
|
963
963
|
read(t) {
|
|
964
|
-
i(this, G).push(t), f(this,
|
|
964
|
+
i(this, G).push(t), f(this, D, qt).call(this);
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
967
967
|
* Queues a callback to run in the next render batch.
|
|
968
968
|
* Always put DOM mutations in a write callback when possible to help Dolla batch them efficiently.
|
|
969
969
|
*/
|
|
970
970
|
write(t, e) {
|
|
971
|
-
e ? i(this,
|
|
971
|
+
e ? i(this, O).set(e, t) : i(this, A).push(t), f(this, D, qt).call(this);
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
|
-
dt = new WeakMap(), X = new WeakMap(),
|
|
974
|
+
dt = new WeakMap(), X = new WeakMap(), O = new WeakMap(), A = new WeakMap(), G = new WeakMap(), Y = new WeakMap(), Dt = new WeakMap(), M = new WeakMap(), mt = new WeakMap(), D = new WeakSet(), qt = function() {
|
|
975
975
|
if (!i(this, Y)) {
|
|
976
976
|
m(this, Y, !0);
|
|
977
977
|
const t = i(this, dt).getEnv() === "development";
|
|
978
978
|
queueMicrotask(() => {
|
|
979
|
-
f(this,
|
|
979
|
+
f(this, D, _t).call(this, t);
|
|
980
980
|
});
|
|
981
981
|
}
|
|
982
|
-
},
|
|
982
|
+
}, _t = function(t = !1) {
|
|
983
983
|
const e = performance.now();
|
|
984
984
|
let s = 0;
|
|
985
|
-
const n = i(this, G).length + i(this,
|
|
985
|
+
const n = i(this, G).length + i(this, O).size + i(this, A).length;
|
|
986
986
|
let r = 0;
|
|
987
|
-
const a = () => (r++, s = performance.now() - e, i(this,
|
|
987
|
+
const a = () => (r++, s = performance.now() - e, i(this, Dt) && s > 12 && r < n ? (st(this, M)._++, t && i(this, X).warn(
|
|
988
988
|
`⚠️ Deferring batch to next frame. Performed ${r} of ${n} batched operation${r === 1 ? "" : "s"} in ${i(this, mt).format(s)} (deferral ${i(this, M)}).`
|
|
989
989
|
), requestAnimationFrame(() => {
|
|
990
|
-
f(this,
|
|
991
|
-
}), !0) : !1), c = [...i(this,
|
|
990
|
+
f(this, D, _t).call(this, t);
|
|
991
|
+
}), !0) : !1), c = [...i(this, O).entries()];
|
|
992
992
|
let h, w;
|
|
993
993
|
for (; w = i(this, G).shift(); )
|
|
994
994
|
if (w(), a()) return;
|
|
995
995
|
for ([h, w] of c)
|
|
996
|
-
if (w(), i(this,
|
|
996
|
+
if (w(), i(this, O).delete(h), a()) return;
|
|
997
997
|
for (; w = i(this, A).shift(); )
|
|
998
998
|
if (w(), a()) return;
|
|
999
999
|
t && i(this, X)[s > 16 ? "warn" : "info"](
|
|
1000
1000
|
`${s > 16 ? "⚠️ (>=16ms) " : ""}Executed ${r} operation${r === 1 ? "" : "s"} in ${i(this, mt).format(s)}${i(this, M) > 0 ? ` (after ${i(this, M)} deferral${i(this, M) === 1 ? "" : "s"})` : ""}.`
|
|
1001
|
-
), m(this, M, 0), i(this, G).length || i(this,
|
|
1002
|
-
f(this,
|
|
1001
|
+
), m(this, M, 0), i(this, G).length || i(this, O).size || i(this, A).length ? queueMicrotask(() => {
|
|
1002
|
+
f(this, D, _t).call(this, t);
|
|
1003
1003
|
}) : m(this, Y, !1);
|
|
1004
1004
|
};
|
|
1005
|
-
var U, wt, C,
|
|
1006
|
-
class
|
|
1005
|
+
var U, wt, C, B, pt, gt, Z, yt, bt, $t, vt, g, y, j, V, Ft;
|
|
1006
|
+
class Ye {
|
|
1007
1007
|
constructor() {
|
|
1008
1008
|
d(this, "batch");
|
|
1009
1009
|
// Remove `private` when there are public methods to call.
|
|
@@ -1013,14 +1013,14 @@ class Ze {
|
|
|
1013
1013
|
l(this, U, !1);
|
|
1014
1014
|
l(this, wt, "production");
|
|
1015
1015
|
l(this, C);
|
|
1016
|
-
l(this,
|
|
1017
|
-
l(this, pt,
|
|
1018
|
-
l(this, gt,
|
|
1016
|
+
l(this, B);
|
|
1017
|
+
l(this, pt, Je);
|
|
1018
|
+
l(this, gt, zt());
|
|
1019
1019
|
l(this, Z);
|
|
1020
1020
|
l(this, yt, []);
|
|
1021
1021
|
l(this, bt, []);
|
|
1022
1022
|
l(this, $t, []);
|
|
1023
|
-
l(this,
|
|
1023
|
+
l(this, vt, []);
|
|
1024
1024
|
l(this, g, {
|
|
1025
1025
|
root: this,
|
|
1026
1026
|
data: {},
|
|
@@ -1034,21 +1034,21 @@ class Ze {
|
|
|
1034
1034
|
warn: "development",
|
|
1035
1035
|
error: !0
|
|
1036
1036
|
});
|
|
1037
|
-
l(this, j,
|
|
1037
|
+
l(this, j, Kt("*,-Dolla.*"));
|
|
1038
1038
|
l(this, V, /* @__PURE__ */ new Map());
|
|
1039
1039
|
// Registration functions for modules.
|
|
1040
1040
|
// All modules will be registered before mount.
|
|
1041
|
-
l(this,
|
|
1041
|
+
l(this, Ft, []);
|
|
1042
1042
|
d(this, "watch", i(this, gt).watch);
|
|
1043
|
-
d(this, "createState",
|
|
1043
|
+
d(this, "createState", Wt);
|
|
1044
1044
|
d(this, "toState", be);
|
|
1045
1045
|
d(this, "toValue", $e);
|
|
1046
|
-
d(this, "isState",
|
|
1046
|
+
d(this, "isState", ve);
|
|
1047
1047
|
d(this, "derive", x);
|
|
1048
|
-
d(this, "createWatcher",
|
|
1049
|
-
d(this, "createRef",
|
|
1048
|
+
d(this, "createWatcher", zt);
|
|
1049
|
+
d(this, "createRef", Ee);
|
|
1050
1050
|
d(this, "isRef", ke);
|
|
1051
|
-
this.batch = new
|
|
1051
|
+
this.batch = new Xe(this), this.stats = new ye(this), this.http = new We(this), this.i18n = new Ke(this);
|
|
1052
1052
|
}
|
|
1053
1053
|
/**
|
|
1054
1054
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
@@ -1087,7 +1087,7 @@ class Ze {
|
|
|
1087
1087
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
1088
1088
|
*/
|
|
1089
1089
|
getRootView() {
|
|
1090
|
-
return i(this,
|
|
1090
|
+
return i(this, B);
|
|
1091
1091
|
}
|
|
1092
1092
|
/**
|
|
1093
1093
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
@@ -1108,19 +1108,19 @@ class Ze {
|
|
|
1108
1108
|
// return { ...this.#rootElementContext.data };
|
|
1109
1109
|
// }
|
|
1110
1110
|
/**
|
|
1111
|
-
* Adds a listener to be called when `
|
|
1111
|
+
* Adds a listener to be called when an event with a matching `type` is emitted.
|
|
1112
1112
|
*/
|
|
1113
1113
|
on(t, e) {
|
|
1114
1114
|
if (t === "*") {
|
|
1115
|
-
const s = (n, r) => {
|
|
1116
|
-
e(r);
|
|
1115
|
+
const s = (n, r, ...a) => {
|
|
1116
|
+
e(r, ...a);
|
|
1117
1117
|
};
|
|
1118
1118
|
i(this, g).emitter.on(t, s), i(this, V).set(e, s);
|
|
1119
1119
|
} else
|
|
1120
1120
|
i(this, g).emitter.on(t, e);
|
|
1121
1121
|
}
|
|
1122
1122
|
/**
|
|
1123
|
-
* Removes a listener from the list to be called when `
|
|
1123
|
+
* Removes a listener from the list to be called when an event with a matching `type` is emitted.
|
|
1124
1124
|
*/
|
|
1125
1125
|
off(t, e) {
|
|
1126
1126
|
if (t === "*") {
|
|
@@ -1130,12 +1130,12 @@ class Ze {
|
|
|
1130
1130
|
i(this, g).emitter.off(t, e);
|
|
1131
1131
|
}
|
|
1132
1132
|
/**
|
|
1133
|
-
* Adds a listener to be called when `
|
|
1133
|
+
* Adds a listener to be called when an event with a matching `type` is emitted. The listener is immediately removed after being called once.
|
|
1134
1134
|
*/
|
|
1135
1135
|
once(t, e) {
|
|
1136
1136
|
if (t === "*") {
|
|
1137
|
-
const s = (n, r) => {
|
|
1138
|
-
i(this, V).delete(e), e(r);
|
|
1137
|
+
const s = (n, r, ...a) => {
|
|
1138
|
+
i(this, V).delete(e), e(r, ...a);
|
|
1139
1139
|
};
|
|
1140
1140
|
i(this, g).emitter.once(t, s), i(this, V).set(e, s);
|
|
1141
1141
|
} else
|
|
@@ -1144,42 +1144,41 @@ class Ze {
|
|
|
1144
1144
|
/**
|
|
1145
1145
|
* Emits a new event to all listeners.
|
|
1146
1146
|
*/
|
|
1147
|
-
emit(t, e) {
|
|
1148
|
-
return i(this, g).emitter.emit(t, new Re(t, e)
|
|
1147
|
+
emit(t, ...e) {
|
|
1148
|
+
return i(this, g).emitter.emit(t, new Re(t), ...e);
|
|
1149
1149
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
let
|
|
1156
|
-
console.warn(`An instance of ${
|
|
1150
|
+
provide(t, e) {
|
|
1151
|
+
const s = new xe(t, e);
|
|
1152
|
+
if (s.attach(i(this, g)))
|
|
1153
|
+
return s.value;
|
|
1154
|
+
{
|
|
1155
|
+
let r = t.name ? `'${t.name}'` : "this store";
|
|
1156
|
+
return console.warn(`An instance of ${r} was already attached to this context.`), this.use(t);
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
1159
|
/**
|
|
1160
1160
|
* Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
1161
1161
|
*/
|
|
1162
|
-
|
|
1163
|
-
if (
|
|
1164
|
-
const e =
|
|
1165
|
-
if (
|
|
1166
|
-
throw new
|
|
1167
|
-
return
|
|
1168
|
-
} else
|
|
1169
|
-
|
|
1170
|
-
) : new Tt("Invalid store.");
|
|
1162
|
+
use(t) {
|
|
1163
|
+
if (tt(t)) {
|
|
1164
|
+
const e = i(this, g).stores.get(t);
|
|
1165
|
+
if (e == null)
|
|
1166
|
+
throw new Qt("Store not found on this context.");
|
|
1167
|
+
return e.value;
|
|
1168
|
+
} else
|
|
1169
|
+
throw new Qt("Invalid store.");
|
|
1171
1170
|
}
|
|
1172
1171
|
async mount(t, e) {
|
|
1173
1172
|
if (i(this, U))
|
|
1174
1173
|
throw new Error("Dolla is already mounted.");
|
|
1175
|
-
if (
|
|
1174
|
+
if (E(t)) {
|
|
1176
1175
|
const r = document.querySelector(t);
|
|
1177
1176
|
Jt(HTMLElement, r, `Selector '${t}' did not match any element.`), m(this, C, r);
|
|
1178
1177
|
} else
|
|
1179
1178
|
Jt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), m(this, C, t);
|
|
1180
|
-
|
|
1181
|
-
const s =
|
|
1182
|
-
m(this,
|
|
1179
|
+
Pt(e) && m(this, Z, e);
|
|
1180
|
+
const s = Pt(e) ? ee : e, n = _e(s);
|
|
1181
|
+
m(this, B, this.constructView(n.type, n.props)), await Promise.all(i(this, Ft).map((r) => r())), Pt(e) && await Pe(e, this), await Promise.all(i(this, yt).map((r) => r())), i(this, B).mount(i(this, C)), m(this, U, !0);
|
|
1183
1182
|
for (const r of i(this, g).stores.values())
|
|
1184
1183
|
r.handleMount();
|
|
1185
1184
|
for (const r of i(this, bt))
|
|
@@ -1188,8 +1187,8 @@ class Ze {
|
|
|
1188
1187
|
async unmount() {
|
|
1189
1188
|
var t;
|
|
1190
1189
|
if (i(this, U)) {
|
|
1191
|
-
await Promise.all(i(this, $t).map((e) => e())), (t = i(this,
|
|
1192
|
-
for (const e of i(this,
|
|
1190
|
+
await Promise.all(i(this, $t).map((e) => e())), (t = i(this, B)) == null || t.unmount(!1), i(this, gt).stopAll(), i(this, Z) && await Te(i(this, Z)), m(this, U, !1);
|
|
1191
|
+
for (const e of i(this, vt))
|
|
1193
1192
|
e();
|
|
1194
1193
|
}
|
|
1195
1194
|
}
|
|
@@ -1217,7 +1216,7 @@ class Ze {
|
|
|
1217
1216
|
* Registers a `callback` to run after the app is unmounted.
|
|
1218
1217
|
*/
|
|
1219
1218
|
onUnmount(t) {
|
|
1220
|
-
i(this,
|
|
1219
|
+
i(this, vt).push(t);
|
|
1221
1220
|
}
|
|
1222
1221
|
/**
|
|
1223
1222
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1229,18 +1228,18 @@ class Ze {
|
|
|
1229
1228
|
}
|
|
1230
1229
|
}
|
|
1231
1230
|
setLogFilter(t) {
|
|
1232
|
-
m(this, j,
|
|
1231
|
+
m(this, j, Kt(t));
|
|
1233
1232
|
}
|
|
1234
1233
|
createLogger(t, e) {
|
|
1235
|
-
const s = (e == null ? void 0 : e.console) ??
|
|
1234
|
+
const s = (e == null ? void 0 : e.console) ?? Ze(), n = this;
|
|
1236
1235
|
return {
|
|
1237
1236
|
setName(r) {
|
|
1238
1237
|
return t = r, this;
|
|
1239
1238
|
},
|
|
1240
1239
|
get info() {
|
|
1241
1240
|
var r;
|
|
1242
|
-
if (i(n, y).info === !1 ||
|
|
1243
|
-
return
|
|
1241
|
+
if (i(n, y).info === !1 || E(i(n, y).info) && i(n, y).info !== n.getEnv() || !i(r = n, j).call(r, t))
|
|
1242
|
+
return Et;
|
|
1244
1243
|
{
|
|
1245
1244
|
let a = `%c${t}`;
|
|
1246
1245
|
return e != null && e.uid ? a += ` %c[uid: %c${e.uid}%c]` : a += "%c%c%c", s.info.bind(
|
|
@@ -1255,8 +1254,8 @@ class Ze {
|
|
|
1255
1254
|
},
|
|
1256
1255
|
get log() {
|
|
1257
1256
|
var r;
|
|
1258
|
-
if (i(n, y).log === !1 ||
|
|
1259
|
-
return
|
|
1257
|
+
if (i(n, y).log === !1 || E(i(n, y).log) && i(n, y).log !== n.getEnv() || !i(r = n, j).call(r, t))
|
|
1258
|
+
return Et;
|
|
1260
1259
|
{
|
|
1261
1260
|
let a = `%c${t}`;
|
|
1262
1261
|
return e != null && e.uid ? a += ` %c[uid: %c${e.uid}%c]` : a += "%c%c%c", s.log.bind(
|
|
@@ -1271,8 +1270,8 @@ class Ze {
|
|
|
1271
1270
|
},
|
|
1272
1271
|
get warn() {
|
|
1273
1272
|
var r;
|
|
1274
|
-
if (i(n, y).warn === !1 ||
|
|
1275
|
-
return
|
|
1273
|
+
if (i(n, y).warn === !1 || E(i(n, y).warn) && i(n, y).warn !== n.getEnv() || !i(r = n, j).call(r, t))
|
|
1274
|
+
return Et;
|
|
1276
1275
|
{
|
|
1277
1276
|
let a = `%c${t}`;
|
|
1278
1277
|
return e != null && e.uid ? a += ` %c[uid: %c${e.uid}%c]` : a += "%c%c%c", s.warn.bind(
|
|
@@ -1287,8 +1286,8 @@ class Ze {
|
|
|
1287
1286
|
},
|
|
1288
1287
|
get error() {
|
|
1289
1288
|
var r;
|
|
1290
|
-
if (i(n, y).error === !1 ||
|
|
1291
|
-
return
|
|
1289
|
+
if (i(n, y).error === !1 || E(i(n, y).error) && i(n, y).error !== n.getEnv() || !i(r = n, j).call(r, t))
|
|
1290
|
+
return Et;
|
|
1292
1291
|
{
|
|
1293
1292
|
let a = `%c${t}`;
|
|
1294
1293
|
return e != null && e.uid ? a += ` %c[uid: %c${e.uid}%c]` : a += "%c%c%c", s.error.bind(
|
|
@@ -1302,11 +1301,11 @@ class Ze {
|
|
|
1302
1301
|
}
|
|
1303
1302
|
},
|
|
1304
1303
|
crash(r) {
|
|
1305
|
-
|
|
1304
|
+
n.isMounted && (n.unmount(), n.constructView(i(n, pt), {
|
|
1306
1305
|
error: r,
|
|
1307
1306
|
loggerName: t,
|
|
1308
1307
|
uid: e == null ? void 0 : e.uid
|
|
1309
|
-
}).mount(i(n, C)))
|
|
1308
|
+
}).mount(i(n, C)));
|
|
1310
1309
|
}
|
|
1311
1310
|
};
|
|
1312
1311
|
}
|
|
@@ -1314,50 +1313,48 @@ class Ze {
|
|
|
1314
1313
|
*
|
|
1315
1314
|
*/
|
|
1316
1315
|
constructView(t, e, s = []) {
|
|
1317
|
-
return new
|
|
1316
|
+
return new Se(i(this, g), t, e, s);
|
|
1318
1317
|
}
|
|
1319
1318
|
/**
|
|
1320
1319
|
*
|
|
1321
1320
|
*/
|
|
1322
1321
|
constructMarkup(t) {
|
|
1323
|
-
return
|
|
1322
|
+
return Le(Me(i(this, g), t));
|
|
1324
1323
|
}
|
|
1325
1324
|
}
|
|
1326
|
-
U = new WeakMap(), wt = new WeakMap(), C = new WeakMap(),
|
|
1327
|
-
function
|
|
1325
|
+
U = new WeakMap(), wt = new WeakMap(), C = new WeakMap(), B = new WeakMap(), pt = new WeakMap(), gt = new WeakMap(), Z = new WeakMap(), yt = new WeakMap(), bt = new WeakMap(), $t = new WeakMap(), vt = new WeakMap(), g = new WeakMap(), y = new WeakMap(), j = new WeakMap(), V = new WeakMap(), Ft = new WeakMap();
|
|
1326
|
+
function Ze() {
|
|
1328
1327
|
if (typeof window < "u" && window.console)
|
|
1329
1328
|
return window.console;
|
|
1330
1329
|
if (typeof global < "u" && global.console)
|
|
1331
1330
|
return global.console;
|
|
1332
1331
|
}
|
|
1333
|
-
const Xt = new
|
|
1334
|
-
function
|
|
1332
|
+
const Xt = new Ye(), rs = Xt.i18n.t.bind(Xt.i18n);
|
|
1333
|
+
function ns(o) {
|
|
1335
1334
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = o);
|
|
1336
1335
|
}
|
|
1337
|
-
function
|
|
1336
|
+
function is() {
|
|
1338
1337
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1339
1338
|
}
|
|
1340
1339
|
export {
|
|
1341
1340
|
pe as cond,
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
hs as createStore,
|
|
1347
|
-
cs as createView,
|
|
1341
|
+
_e as createMarkup,
|
|
1342
|
+
Ee as createRef,
|
|
1343
|
+
ss as createRouter,
|
|
1344
|
+
Wt as createState,
|
|
1348
1345
|
we as deepEqual,
|
|
1349
1346
|
Xt as default,
|
|
1350
1347
|
x as derive,
|
|
1351
|
-
|
|
1352
|
-
|
|
1348
|
+
is as getDevDebug,
|
|
1349
|
+
Ht as html,
|
|
1353
1350
|
ke as isRef,
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1351
|
+
ve as isState,
|
|
1352
|
+
ls as portal,
|
|
1353
|
+
hs as repeat,
|
|
1354
|
+
ns as setDevDebug,
|
|
1355
|
+
Gt as shallowEqual,
|
|
1356
|
+
cs as strictEqual,
|
|
1357
|
+
rs as t,
|
|
1361
1358
|
be as toState,
|
|
1362
1359
|
$e as toValue
|
|
1363
1360
|
};
|