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