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