@manyducks.co/dolla 2.0.0-alpha.14 → 2.0.0-alpha.16
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 +20 -15
- package/dist/index.d.ts +4 -4
- package/dist/index.js +368 -345
- 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.d.ts +1 -9
- package/dist/modules/dolla.d.ts +15 -3
- package/dist/nodes/html.d.ts +3 -2
- package/dist/passthrough-DUh0_zQF.js +1398 -0
- package/dist/passthrough-DUh0_zQF.js.map +1 -0
- package/dist/state.d.ts +49 -12
- package/dist/types.d.ts +2 -2
- package/dist/view.d.ts +2 -2
- package/package.json +2 -1
- package/dist/passthrough-MfPKbG0F.js +0 -1303
- package/dist/passthrough-MfPKbG0F.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Lt = Object.defineProperty;
|
|
2
|
+
var ct = (i) => {
|
|
3
3
|
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var S = (i, e, t) =>
|
|
7
|
-
var s = (i, e, t) => (
|
|
8
|
-
var
|
|
5
|
+
var xt = (i, e, t) => e in i ? Lt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
6
|
+
var S = (i, e, t) => xt(i, typeof e != "symbol" ? e + "" : e, t), Je = (i, e, t) => e.has(i) || ct("Cannot " + t);
|
|
7
|
+
var s = (i, e, t) => (Je(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? ct("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Je(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), E = (i, e, t) => (Je(i, e, "access private method"), t);
|
|
8
|
+
var ut = (i, e, t, r) => ({
|
|
9
9
|
set _(a) {
|
|
10
10
|
b(i, e, a, t);
|
|
11
11
|
},
|
|
@@ -13,10 +13,10 @@ var lt = (i, e, t, r) => ({
|
|
|
13
13
|
return s(i, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as
|
|
17
|
-
import { B as
|
|
18
|
-
function
|
|
19
|
-
return
|
|
16
|
+
import { h as ht, c as Rt, i as Ye, a as ie, d as ye, b as Xe, e as lt, f as V, t as ft, g as bt, j as Ot, k as Ze, P as vt, l as dt, m as Nt, n as Mt, o as pt, v as Tt, p as Dt, q as At, r as mt, s as gt, u as _t, w as Ce, x as Fe, y as jt, z as Ct, A as Ft } from "./passthrough-DUh0_zQF.js";
|
|
17
|
+
import { B as dr, C as pr, D as mr } from "./passthrough-DUh0_zQF.js";
|
|
18
|
+
function Vt(i) {
|
|
19
|
+
return ht`
|
|
20
20
|
<div
|
|
21
21
|
style=${{
|
|
22
22
|
backgroundColor: "#880000",
|
|
@@ -30,7 +30,7 @@ function Ct(i) {
|
|
|
30
30
|
<h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
|
|
31
31
|
<p style=${{ marginBottom: "0.25rem" }}>
|
|
32
32
|
<span style=${{ fontFamily: "monospace" }}>${i.loggerName}</span>
|
|
33
|
-
${
|
|
33
|
+
${Rt(i.uid, ht`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
|
|
34
34
|
${" "}says:
|
|
35
35
|
</p>
|
|
36
36
|
<blockquote
|
|
@@ -62,12 +62,12 @@ function Ct(i) {
|
|
|
62
62
|
</div>
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
|
-
var
|
|
66
|
-
class
|
|
65
|
+
var J, ze, T, j;
|
|
66
|
+
class qt {
|
|
67
67
|
constructor() {
|
|
68
68
|
f(this, T);
|
|
69
|
-
f(this,
|
|
70
|
-
f(this,
|
|
69
|
+
f(this, J, []);
|
|
70
|
+
f(this, ze, Ut());
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -76,8 +76,8 @@ class Vt {
|
|
|
76
76
|
* @param middleware - A middleware function that will intercept requests.
|
|
77
77
|
*/
|
|
78
78
|
use(e) {
|
|
79
|
-
return s(this,
|
|
80
|
-
s(this,
|
|
79
|
+
return s(this, J).push(e), () => {
|
|
80
|
+
s(this, J).splice(s(this, J).indexOf(e), 1);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
async get(e, t) {
|
|
@@ -105,23 +105,23 @@ class Vt {
|
|
|
105
105
|
return E(this, T, j).call(this, "trace", e, t);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
return
|
|
108
|
+
J = new WeakMap(), ze = new WeakMap(), T = new WeakSet(), j = async function(e, t, r) {
|
|
109
|
+
return It({
|
|
110
110
|
...r,
|
|
111
111
|
method: e,
|
|
112
112
|
uri: t,
|
|
113
|
-
middleware: s(this,
|
|
114
|
-
fetch: s(this,
|
|
113
|
+
middleware: s(this, J),
|
|
114
|
+
fetch: s(this, ze)
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
|
-
function
|
|
117
|
+
function Ut() {
|
|
118
118
|
if (typeof window < "u" && window.fetch)
|
|
119
119
|
return window.fetch.bind(window);
|
|
120
120
|
if (typeof global < "u" && global.fetch)
|
|
121
121
|
return global.fetch.bind(global);
|
|
122
122
|
throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
|
|
123
123
|
}
|
|
124
|
-
class
|
|
124
|
+
class Ht extends Error {
|
|
125
125
|
constructor(t) {
|
|
126
126
|
const { status: r, statusText: a, method: n, uri: o } = t, h = `${r} ${a}: Request failed (${n.toUpperCase()} ${o})`;
|
|
127
127
|
super(h);
|
|
@@ -129,7 +129,7 @@ class Ut extends Error {
|
|
|
129
129
|
this.response = t;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
132
|
+
async function It(i) {
|
|
133
133
|
const { headers: e, query: t, fetch: r, middleware: a } = i, n = {
|
|
134
134
|
method: i.method,
|
|
135
135
|
uri: i.uri,
|
|
@@ -168,7 +168,7 @@ async function Ht(i) {
|
|
|
168
168
|
const h = async () => {
|
|
169
169
|
const l = n.query.toString(), d = l.length > 0 ? n.uri + "?" + l : n.uri;
|
|
170
170
|
let g;
|
|
171
|
-
!n.headers.has("content-type") &&
|
|
171
|
+
!n.headers.has("content-type") && Ye(n.body) ? (n.headers.set("content-type", "application/json"), g = JSON.stringify(n.body)) : g = n.body;
|
|
172
172
|
const m = await r(d, {
|
|
173
173
|
method: n.method,
|
|
174
174
|
headers: n.headers,
|
|
@@ -193,29 +193,29 @@ async function Ht(i) {
|
|
|
193
193
|
} else
|
|
194
194
|
await h();
|
|
195
195
|
if (o.status < 200 || o.status >= 400)
|
|
196
|
-
throw new
|
|
196
|
+
throw new Ht(o);
|
|
197
197
|
return o;
|
|
198
198
|
}
|
|
199
|
-
var
|
|
200
|
-
class
|
|
199
|
+
var Ke, oe, re, et, $t;
|
|
200
|
+
class Wt {
|
|
201
201
|
constructor(e, t) {
|
|
202
|
-
f(this,
|
|
202
|
+
f(this, re);
|
|
203
203
|
S(this, "dolla");
|
|
204
204
|
S(this, "config");
|
|
205
|
-
f(this,
|
|
206
|
-
f(this,
|
|
205
|
+
f(this, Ke, !1);
|
|
206
|
+
f(this, oe, /* @__PURE__ */ new Map());
|
|
207
207
|
this.config = e, this.dolla = t;
|
|
208
208
|
}
|
|
209
209
|
async load() {
|
|
210
210
|
let e;
|
|
211
|
-
if (!s(this,
|
|
212
|
-
if (
|
|
213
|
-
if (e = await this.config.fetch(), !
|
|
211
|
+
if (!s(this, Ke)) {
|
|
212
|
+
if (lt(this.config.fetch)) {
|
|
213
|
+
if (e = await this.config.fetch(), !Ye(e))
|
|
214
214
|
throw new Error(`Fetch function did not return an object of language strings: ${e}`);
|
|
215
215
|
} else if (V(this.config.path)) {
|
|
216
216
|
const t = await this.dolla.http.get(this.config.path);
|
|
217
217
|
if (t.status >= 200 && t.status < 300)
|
|
218
|
-
if (
|
|
218
|
+
if (Ye(t.body))
|
|
219
219
|
e = t.body;
|
|
220
220
|
else
|
|
221
221
|
throw new Error(
|
|
@@ -226,38 +226,38 @@ class It {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
if (e) {
|
|
229
|
-
const t = E(this,
|
|
229
|
+
const t = E(this, re, et).call(this, e);
|
|
230
230
|
for (const r of t)
|
|
231
|
-
s(this,
|
|
231
|
+
s(this, oe).set(r[0], r[1]);
|
|
232
232
|
} else
|
|
233
233
|
throw new Error("Language could not be loaded.");
|
|
234
234
|
}
|
|
235
235
|
getTemplate(e) {
|
|
236
|
-
return s(this,
|
|
236
|
+
return s(this, oe).get(e) ?? {
|
|
237
237
|
segments: [{ type: 0, text: `[MISSING: ${e}]` }]
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
hasTemplate(e) {
|
|
241
|
-
return s(this,
|
|
241
|
+
return s(this, oe).has(e);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
Ke = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), et = function(e, t = []) {
|
|
245
245
|
const r = [];
|
|
246
246
|
for (const a in e)
|
|
247
|
-
switch (
|
|
247
|
+
switch (ft(e[a])) {
|
|
248
248
|
case "string":
|
|
249
|
-
r.push([[...t, a].join("."), E(this,
|
|
249
|
+
r.push([[...t, a].join("."), E(this, re, $t).call(this, e[a])]);
|
|
250
250
|
break;
|
|
251
251
|
case "object":
|
|
252
|
-
r.push(...E(this,
|
|
252
|
+
r.push(...E(this, re, et).call(this, e[a], [...t, a]));
|
|
253
253
|
break;
|
|
254
254
|
default:
|
|
255
255
|
throw new Error(
|
|
256
|
-
`Expected to find a string or object at ${[...t, a].join(".")}. Got: ${
|
|
256
|
+
`Expected to find a string or object at ${[...t, a].join(".")}. Got: ${ft(e[a])}`
|
|
257
257
|
);
|
|
258
258
|
}
|
|
259
259
|
return r;
|
|
260
|
-
},
|
|
260
|
+
}, $t = function(e) {
|
|
261
261
|
let t;
|
|
262
262
|
((u) => {
|
|
263
263
|
u[u.Static = 0] = "Static", u[u.ValueName = 1] = "ValueName", u[u.FormatName = 2] = "FormatName", u[u.FormatOptionName = 3] = "FormatOptionName", u[u.FormatOptionValue = 4] = "FormatOptionValue", u[u.FormatOptionEnd = 5] = "FormatOptionEnd";
|
|
@@ -306,37 +306,37 @@ ze = new WeakMap(), ie = new WeakMap(), te = new WeakSet(), Xe = function(e, t =
|
|
|
306
306
|
}
|
|
307
307
|
return o === 0 && a.length > 0 && r.segments.push({ type: 0, text: a }), r;
|
|
308
308
|
};
|
|
309
|
-
var
|
|
310
|
-
class
|
|
309
|
+
var ve, q, R, $e, Ee, ke, Pe, O, Et, tt, rt, nt, kt;
|
|
310
|
+
class Gt {
|
|
311
311
|
constructor(e) {
|
|
312
312
|
f(this, O);
|
|
313
|
-
f(this,
|
|
313
|
+
f(this, ve);
|
|
314
314
|
f(this, q);
|
|
315
|
-
f(this,
|
|
316
|
-
f(this,
|
|
317
|
-
f(this,
|
|
318
|
-
f(this,
|
|
315
|
+
f(this, R, /* @__PURE__ */ new Map());
|
|
316
|
+
f(this, $e, []);
|
|
317
|
+
f(this, Ee, /* @__PURE__ */ new Map());
|
|
318
|
+
f(this, ke, "auto");
|
|
319
319
|
S(this, "$locale");
|
|
320
|
-
f(this,
|
|
321
|
-
b(this,
|
|
322
|
-
const [t, r] =
|
|
323
|
-
this.$locale = t, b(this,
|
|
324
|
-
s(this,
|
|
320
|
+
f(this, Pe);
|
|
321
|
+
b(this, ve, e), b(this, q, e.createLogger("dolla/i18n"));
|
|
322
|
+
const [t, r] = ie();
|
|
323
|
+
this.$locale = t, b(this, Pe, r), this.addFormat("number", (a, n, o) => E(this, O, tt).call(this, Number(n), o)), this.addFormat("datetime", (a, n, o) => E(this, O, rt).call(this, n, o)), this.addFormat("list", (a, n, o) => E(this, O, nt).call(this, n, o)), e.beforeMount(async () => {
|
|
324
|
+
s(this, R).size > 0 && await this.setLocale(s(this, ke));
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
get locales() {
|
|
328
|
-
return [...s(this,
|
|
328
|
+
return [...s(this, R).keys()];
|
|
329
329
|
}
|
|
330
330
|
setup(e) {
|
|
331
331
|
if (e.translations.forEach((t) => {
|
|
332
|
-
s(this,
|
|
332
|
+
s(this, R).set(t.locale, new Wt(t, s(this, ve)));
|
|
333
333
|
}), e.locale && e.locale !== "auto") {
|
|
334
334
|
if (!e.translations.some((r) => r.locale === e.locale))
|
|
335
335
|
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
336
|
-
b(this,
|
|
336
|
+
b(this, ke, e.locale);
|
|
337
337
|
}
|
|
338
338
|
s(this, q).info(
|
|
339
|
-
`${s(this,
|
|
339
|
+
`${s(this, R).size} language${s(this, R).size === 1 ? "" : "s"} supported: '${[...s(this, R).keys()].join("', '")}'`
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
async setLocale(e) {
|
|
@@ -349,18 +349,18 @@ class Wt {
|
|
|
349
349
|
((a = o.languages) == null ? void 0 : a.length) > 0 ? n.push(...o.languages) : o.language ? n.push(o.language) : o.browserLanguage ? n.push(o.browserLanguage) : o.userLanguage && n.push(o.userLanguage);
|
|
350
350
|
}
|
|
351
351
|
for (const o of n)
|
|
352
|
-
s(this,
|
|
352
|
+
s(this, R).has(o) && (t = o);
|
|
353
353
|
} else
|
|
354
|
-
s(this,
|
|
354
|
+
s(this, R).has(e) && (t = e);
|
|
355
355
|
if (t == null) {
|
|
356
|
-
const n = s(this,
|
|
356
|
+
const n = s(this, R).keys().next().value;
|
|
357
357
|
n && (t = n);
|
|
358
358
|
}
|
|
359
|
-
if (!t || !s(this,
|
|
359
|
+
if (!t || !s(this, R).has(t))
|
|
360
360
|
throw new Error(`Locale '${e}' has no translation.`);
|
|
361
|
-
const r = s(this,
|
|
361
|
+
const r = s(this, R).get(t);
|
|
362
362
|
try {
|
|
363
|
-
await r.load(), b(this,
|
|
363
|
+
await r.load(), b(this, $e, []), s(this, Pe).call(this, t), s(this, q).info("set language to " + t);
|
|
364
364
|
} catch (n) {
|
|
365
365
|
n instanceof Error && s(this, q).crash(n);
|
|
366
366
|
}
|
|
@@ -382,13 +382,13 @@ class Wt {
|
|
|
382
382
|
let r = [], a = [];
|
|
383
383
|
for (const n in t)
|
|
384
384
|
r.push(n), a.push(t[n]);
|
|
385
|
-
return
|
|
385
|
+
return ye([this.$locale, ...a], (n, ...o) => {
|
|
386
386
|
if (n == null)
|
|
387
387
|
return "[NO LOCALE SET]";
|
|
388
388
|
const h = {};
|
|
389
389
|
for (let l = 0; l < o.length; l++)
|
|
390
390
|
h[r[l]] = o[l];
|
|
391
|
-
return E(this, O,
|
|
391
|
+
return E(this, O, Et).call(this, n, e, h);
|
|
392
392
|
});
|
|
393
393
|
}
|
|
394
394
|
/**
|
|
@@ -406,7 +406,7 @@ class Wt {
|
|
|
406
406
|
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
407
407
|
*/
|
|
408
408
|
addFormat(e, t) {
|
|
409
|
-
s(this,
|
|
409
|
+
s(this, Ee).set(e, t);
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
412
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
@@ -423,7 +423,7 @@ class Wt {
|
|
|
423
423
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
424
424
|
*/
|
|
425
425
|
number(e, t) {
|
|
426
|
-
return
|
|
426
|
+
return ye([this.$locale, e], (r, a) => E(this, O, tt).call(this, a, t));
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -435,7 +435,7 @@ class Wt {
|
|
|
435
435
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
436
436
|
*/
|
|
437
437
|
dateTime(e, t) {
|
|
438
|
-
return
|
|
438
|
+
return ye([this.$locale, e], (r, a) => E(this, O, rt).call(this, a, t));
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -447,14 +447,14 @@ class Wt {
|
|
|
447
447
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
448
448
|
*/
|
|
449
449
|
list(e, t) {
|
|
450
|
-
return
|
|
450
|
+
return ye([this.$locale, e], (r, a) => E(this, O, nt).call(this, a, t));
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
|
|
453
|
+
ve = new WeakMap(), q = new WeakMap(), R = new WeakMap(), $e = new WeakMap(), Ee = new WeakMap(), ke = new WeakMap(), Pe = new WeakMap(), O = new WeakSet(), Et = function(e, t, r) {
|
|
454
454
|
var l;
|
|
455
|
-
const a = E(this, O,
|
|
455
|
+
const a = E(this, O, kt).call(this, t, r);
|
|
456
456
|
if (a) return a;
|
|
457
|
-
const n = s(this,
|
|
457
|
+
const n = s(this, R).get(e);
|
|
458
458
|
if (r.context != null && (t += "_" + r.context), r.count != null)
|
|
459
459
|
if (r.ordinal) {
|
|
460
460
|
const d = `${t}_ordinal_(=${r.count})`;
|
|
@@ -469,11 +469,11 @@ be = new WeakMap(), q = new WeakMap(), x = new WeakMap(), ve = new WeakMap(), $e
|
|
|
469
469
|
if (d.type === 0)
|
|
470
470
|
h += d.text;
|
|
471
471
|
else if (d.type === 1) {
|
|
472
|
-
let g =
|
|
472
|
+
let g = Bt(r, d.name);
|
|
473
473
|
const m = ((l = r.formatOverrides) == null ? void 0 : l[d.name]) ?? [...d.formats];
|
|
474
474
|
d.name === "count" && m.length === 0 && m.push({ name: "number", options: {} });
|
|
475
475
|
for (const u of m) {
|
|
476
|
-
const y = s(this,
|
|
476
|
+
const y = s(this, Ee).get(u.name);
|
|
477
477
|
if (y == null) {
|
|
478
478
|
const k = new Error(
|
|
479
479
|
`Failed to load format '${u.name}' when processing '${t}', template: ${o}`
|
|
@@ -485,22 +485,22 @@ be = new WeakMap(), q = new WeakMap(), x = new WeakMap(), ve = new WeakMap(), $e
|
|
|
485
485
|
h += g;
|
|
486
486
|
}
|
|
487
487
|
return h;
|
|
488
|
-
},
|
|
488
|
+
}, tt = function(e, t) {
|
|
489
489
|
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
490
|
-
},
|
|
490
|
+
}, rt = function(e, t) {
|
|
491
491
|
return new Intl.DateTimeFormat(this.$locale.get(), t).format(
|
|
492
492
|
typeof e == "string" ? new Date(e) : e
|
|
493
493
|
);
|
|
494
|
-
},
|
|
494
|
+
}, nt = function(e, t) {
|
|
495
495
|
return new Intl.ListFormat(this.$locale.get(), t).format(e);
|
|
496
496
|
}, // relativeTime(): State<string> {
|
|
497
497
|
// }
|
|
498
|
-
|
|
499
|
-
for (const r of s(this,
|
|
500
|
-
if (r[0] === e &&
|
|
498
|
+
kt = function(e, t) {
|
|
499
|
+
for (const r of s(this, $e))
|
|
500
|
+
if (r[0] === e && Xe(r[1], t))
|
|
501
501
|
return r[2];
|
|
502
502
|
};
|
|
503
|
-
function
|
|
503
|
+
function Bt(i, e) {
|
|
504
504
|
const t = String(e).split(/[\.\[\]]/).filter((a) => a.trim() !== "");
|
|
505
505
|
let r = i;
|
|
506
506
|
for (; t.length > 0; ) {
|
|
@@ -509,21 +509,21 @@ function Gt(i, e) {
|
|
|
509
509
|
}
|
|
510
510
|
return r;
|
|
511
511
|
}
|
|
512
|
-
var
|
|
513
|
-
class
|
|
512
|
+
var Y, Se, U, H, le, C, ce, Ve;
|
|
513
|
+
class zt {
|
|
514
514
|
constructor(e) {
|
|
515
|
-
f(this,
|
|
516
|
-
f(this,
|
|
517
|
-
f(this,
|
|
515
|
+
f(this, ce);
|
|
516
|
+
f(this, Y);
|
|
517
|
+
f(this, Se);
|
|
518
518
|
// Keyed updates ensure only the most recent callback queued with a certain key
|
|
519
519
|
// will be called, keeping DOM operations to a minimum.
|
|
520
520
|
f(this, U, /* @__PURE__ */ new Map());
|
|
521
521
|
// All unkeyed updates are run on every batch.
|
|
522
522
|
f(this, H, []);
|
|
523
523
|
// All read callbacks are run before updates on every batch.
|
|
524
|
-
f(this,
|
|
525
|
-
f(this,
|
|
526
|
-
b(this,
|
|
524
|
+
f(this, le, []);
|
|
525
|
+
f(this, C, !1);
|
|
526
|
+
b(this, Y, e), b(this, Se, e.createLogger("dolla/render"));
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
529
529
|
* Queues a callback to run in the next render batch.
|
|
@@ -536,7 +536,7 @@ class Bt {
|
|
|
536
536
|
e(), r();
|
|
537
537
|
}) : s(this, H).push(() => {
|
|
538
538
|
e(), r();
|
|
539
|
-
}), !s(this,
|
|
539
|
+
}), !s(this, C) && s(this, Y).isMounted && (b(this, C, !0), E(this, ce, Ve).call(this));
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
/**
|
|
@@ -546,49 +546,49 @@ class Bt {
|
|
|
546
546
|
*/
|
|
547
547
|
read(e) {
|
|
548
548
|
return new Promise((t) => {
|
|
549
|
-
s(this,
|
|
549
|
+
s(this, le).push(() => {
|
|
550
550
|
e(), t();
|
|
551
|
-
}), !s(this,
|
|
551
|
+
}), !s(this, C) && s(this, Y).isMounted && (b(this, C, !0), E(this, ce, Ve).call(this));
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
Y = new WeakMap(), Se = new WeakMap(), U = new WeakMap(), H = new WeakMap(), le = new WeakMap(), C = new WeakMap(), ce = new WeakSet(), Ve = function() {
|
|
556
556
|
const e = s(this, U).size + s(this, H).length;
|
|
557
|
-
if ((!s(this,
|
|
558
|
-
for (const t of s(this,
|
|
557
|
+
if ((!s(this, Y).isMounted || e === 0) && b(this, C, !1), !s(this, C)) {
|
|
558
|
+
for (const t of s(this, le))
|
|
559
559
|
t();
|
|
560
|
-
b(this,
|
|
560
|
+
b(this, le, []);
|
|
561
561
|
return;
|
|
562
562
|
}
|
|
563
563
|
requestAnimationFrame(() => {
|
|
564
|
-
s(this,
|
|
564
|
+
s(this, Se).info(`Batching ${s(this, U).size + s(this, H).length} queued DOM update(s).`);
|
|
565
565
|
for (const t of s(this, U).values())
|
|
566
566
|
t();
|
|
567
567
|
s(this, U).clear();
|
|
568
568
|
for (const t of s(this, H))
|
|
569
569
|
t();
|
|
570
|
-
b(this, H, []), E(this,
|
|
570
|
+
b(this, H, []), E(this, ce, Ve).call(this);
|
|
571
571
|
});
|
|
572
572
|
};
|
|
573
|
-
function
|
|
574
|
-
return
|
|
573
|
+
function de() {
|
|
574
|
+
return de = Object.assign ? Object.assign.bind() : function(i) {
|
|
575
575
|
for (var e = 1; e < arguments.length; e++) {
|
|
576
576
|
var t = arguments[e];
|
|
577
577
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
|
|
578
578
|
}
|
|
579
579
|
return i;
|
|
580
|
-
},
|
|
580
|
+
}, de.apply(null, arguments);
|
|
581
581
|
}
|
|
582
|
-
var
|
|
582
|
+
var A;
|
|
583
583
|
(function(i) {
|
|
584
584
|
i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
|
|
585
|
-
})(
|
|
586
|
-
var
|
|
585
|
+
})(A || (A = {}));
|
|
586
|
+
var Ie = process.env.NODE_ENV !== "production" ? function(i) {
|
|
587
587
|
return Object.freeze(i);
|
|
588
588
|
} : function(i) {
|
|
589
589
|
return i;
|
|
590
590
|
};
|
|
591
|
-
function
|
|
591
|
+
function qe(i, e) {
|
|
592
592
|
if (!i) {
|
|
593
593
|
typeof console < "u" && console.warn(e);
|
|
594
594
|
try {
|
|
@@ -597,13 +597,13 @@ function Ve(i, e) {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
var
|
|
601
|
-
function
|
|
600
|
+
var We = "beforeunload", Kt = "hashchange", Pt = "popstate";
|
|
601
|
+
function Qt(i) {
|
|
602
602
|
i === void 0 && (i = {});
|
|
603
603
|
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
|
|
604
604
|
function n() {
|
|
605
605
|
var w = r.location, c = w.pathname, p = w.search, v = w.hash, $ = a.state || {};
|
|
606
|
-
return [$.idx,
|
|
606
|
+
return [$.idx, Ie({
|
|
607
607
|
pathname: c,
|
|
608
608
|
search: p,
|
|
609
609
|
hash: v,
|
|
@@ -616,7 +616,7 @@ function Kt(i) {
|
|
|
616
616
|
if (o)
|
|
617
617
|
y.call(o), o = null;
|
|
618
618
|
else {
|
|
619
|
-
var w =
|
|
619
|
+
var w = A.Pop, c = n(), p = c[0], v = c[1];
|
|
620
620
|
if (y.length)
|
|
621
621
|
if (p != null) {
|
|
622
622
|
var $ = g - p;
|
|
@@ -624,11 +624,11 @@ function Kt(i) {
|
|
|
624
624
|
action: w,
|
|
625
625
|
location: v,
|
|
626
626
|
retry: function() {
|
|
627
|
-
|
|
627
|
+
F($ * -1);
|
|
628
628
|
}
|
|
629
|
-
},
|
|
629
|
+
}, F($));
|
|
630
630
|
} else
|
|
631
|
-
process.env.NODE_ENV !== "production" &&
|
|
631
|
+
process.env.NODE_ENV !== "production" && qe(
|
|
632
632
|
!1,
|
|
633
633
|
// TODO: Write up a doc that explains our blocking strategy in
|
|
634
634
|
// detail and link to it here so people can understand better what
|
|
@@ -636,42 +636,42 @@ function Kt(i) {
|
|
|
636
636
|
"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."
|
|
637
637
|
);
|
|
638
638
|
else
|
|
639
|
-
|
|
639
|
+
ne(w);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
r.addEventListener(
|
|
643
|
-
var l =
|
|
644
|
-
g == null && (g = 0, a.replaceState(
|
|
642
|
+
r.addEventListener(Pt, h);
|
|
643
|
+
var l = A.Pop, d = n(), g = d[0], m = d[1], u = Be(), y = Be();
|
|
644
|
+
g == null && (g = 0, a.replaceState(de({}, a.state, {
|
|
645
645
|
idx: g
|
|
646
646
|
}), ""));
|
|
647
647
|
function k(w) {
|
|
648
|
-
return typeof w == "string" ? w :
|
|
648
|
+
return typeof w == "string" ? w : Ue(w);
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
return c === void 0 && (c = null),
|
|
650
|
+
function pe(w, c) {
|
|
651
|
+
return c === void 0 && (c = null), Ie(de({
|
|
652
652
|
pathname: m.pathname,
|
|
653
653
|
hash: "",
|
|
654
654
|
search: ""
|
|
655
|
-
}, typeof w == "string" ?
|
|
655
|
+
}, typeof w == "string" ? at(w) : w, {
|
|
656
656
|
state: c,
|
|
657
|
-
key:
|
|
657
|
+
key: St()
|
|
658
658
|
}));
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function me(w, c) {
|
|
661
661
|
return [{
|
|
662
662
|
usr: w.state,
|
|
663
663
|
key: w.key,
|
|
664
664
|
idx: c
|
|
665
665
|
}, k(w)];
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function ge(w, c, p) {
|
|
668
668
|
return !y.length || (y.call({
|
|
669
669
|
action: w,
|
|
670
670
|
location: c,
|
|
671
671
|
retry: p
|
|
672
672
|
}), !1);
|
|
673
673
|
}
|
|
674
|
-
function
|
|
674
|
+
function ne(w) {
|
|
675
675
|
l = w;
|
|
676
676
|
var c = n();
|
|
677
677
|
g = c[0], m = c[1], u.call({
|
|
@@ -679,35 +679,35 @@ function Kt(i) {
|
|
|
679
679
|
location: m
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
|
-
function
|
|
683
|
-
var p =
|
|
682
|
+
function ae(w, c) {
|
|
683
|
+
var p = A.Push, v = pe(w, c);
|
|
684
684
|
function $() {
|
|
685
|
-
|
|
685
|
+
ae(w, c);
|
|
686
686
|
}
|
|
687
|
-
if (
|
|
688
|
-
var L =
|
|
687
|
+
if (ge(p, v, $)) {
|
|
688
|
+
var L = me(v, g + 1), N = L[0], D = L[1];
|
|
689
689
|
try {
|
|
690
690
|
a.pushState(N, "", D);
|
|
691
691
|
} catch {
|
|
692
692
|
r.location.assign(D);
|
|
693
693
|
}
|
|
694
|
-
|
|
694
|
+
ne(p);
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
function
|
|
698
|
-
var p =
|
|
697
|
+
function we(w, c) {
|
|
698
|
+
var p = A.Replace, v = pe(w, c);
|
|
699
699
|
function $() {
|
|
700
|
-
|
|
700
|
+
we(w, c);
|
|
701
701
|
}
|
|
702
|
-
if (
|
|
703
|
-
var L =
|
|
704
|
-
a.replaceState(N, "", D),
|
|
702
|
+
if (ge(p, v, $)) {
|
|
703
|
+
var L = me(v, g), N = L[0], D = L[1];
|
|
704
|
+
a.replaceState(N, "", D), ne(p);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
-
function
|
|
707
|
+
function F(w) {
|
|
708
708
|
a.go(w);
|
|
709
709
|
}
|
|
710
|
-
var
|
|
710
|
+
var Q = {
|
|
711
711
|
get action() {
|
|
712
712
|
return l;
|
|
713
713
|
},
|
|
@@ -715,38 +715,38 @@ function Kt(i) {
|
|
|
715
715
|
return m;
|
|
716
716
|
},
|
|
717
717
|
createHref: k,
|
|
718
|
-
push:
|
|
719
|
-
replace:
|
|
720
|
-
go:
|
|
718
|
+
push: ae,
|
|
719
|
+
replace: we,
|
|
720
|
+
go: F,
|
|
721
721
|
back: function() {
|
|
722
|
-
|
|
722
|
+
F(-1);
|
|
723
723
|
},
|
|
724
724
|
forward: function() {
|
|
725
|
-
|
|
725
|
+
F(1);
|
|
726
726
|
},
|
|
727
727
|
listen: function(c) {
|
|
728
728
|
return u.push(c);
|
|
729
729
|
},
|
|
730
730
|
block: function(c) {
|
|
731
731
|
var p = y.push(c);
|
|
732
|
-
return y.length === 1 && r.addEventListener(
|
|
733
|
-
p(), y.length || r.removeEventListener(
|
|
732
|
+
return y.length === 1 && r.addEventListener(We, Ge), function() {
|
|
733
|
+
p(), y.length || r.removeEventListener(We, Ge);
|
|
734
734
|
};
|
|
735
735
|
}
|
|
736
736
|
};
|
|
737
|
-
return
|
|
737
|
+
return Q;
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function Jt(i) {
|
|
740
740
|
i === void 0 && (i = {});
|
|
741
741
|
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
|
|
742
742
|
function n() {
|
|
743
|
-
var c =
|
|
744
|
-
return [
|
|
743
|
+
var c = at(r.location.hash.substr(1)), p = c.pathname, v = p === void 0 ? "/" : p, $ = c.search, L = $ === void 0 ? "" : $, N = c.hash, D = N === void 0 ? "" : N, _ = a.state || {};
|
|
744
|
+
return [_.idx, Ie({
|
|
745
745
|
pathname: v,
|
|
746
746
|
search: L,
|
|
747
747
|
hash: D,
|
|
748
|
-
state:
|
|
749
|
-
key:
|
|
748
|
+
state: _.usr || null,
|
|
749
|
+
key: _.key || "default"
|
|
750
750
|
})];
|
|
751
751
|
}
|
|
752
752
|
var o = null;
|
|
@@ -754,7 +754,7 @@ function Qt(i) {
|
|
|
754
754
|
if (o)
|
|
755
755
|
y.call(o), o = null;
|
|
756
756
|
else {
|
|
757
|
-
var c =
|
|
757
|
+
var c = A.Pop, p = n(), v = p[0], $ = p[1];
|
|
758
758
|
if (y.length)
|
|
759
759
|
if (v != null) {
|
|
760
760
|
var L = g - v;
|
|
@@ -762,11 +762,11 @@ function Qt(i) {
|
|
|
762
762
|
action: c,
|
|
763
763
|
location: $,
|
|
764
764
|
retry: function() {
|
|
765
|
-
|
|
765
|
+
Q(L * -1);
|
|
766
766
|
}
|
|
767
|
-
},
|
|
767
|
+
}, Q(L));
|
|
768
768
|
} else
|
|
769
|
-
process.env.NODE_ENV !== "production" &&
|
|
769
|
+
process.env.NODE_ENV !== "production" && qe(
|
|
770
770
|
!1,
|
|
771
771
|
// TODO: Write up a doc that explains our blocking strategy in
|
|
772
772
|
// detail and link to it here so people can understand better
|
|
@@ -774,15 +774,15 @@ function Qt(i) {
|
|
|
774
774
|
"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."
|
|
775
775
|
);
|
|
776
776
|
else
|
|
777
|
-
|
|
777
|
+
ae(c);
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
r.addEventListener(
|
|
780
|
+
r.addEventListener(Pt, h), r.addEventListener(Kt, function() {
|
|
781
781
|
var c = n(), p = c[1];
|
|
782
|
-
|
|
782
|
+
Ue(p) !== Ue(m) && h();
|
|
783
783
|
});
|
|
784
|
-
var l =
|
|
785
|
-
g == null && (g = 0, a.replaceState(
|
|
784
|
+
var l = A.Pop, d = n(), g = d[0], m = d[1], u = Be(), y = Be();
|
|
785
|
+
g == null && (g = 0, a.replaceState(de({}, a.state, {
|
|
786
786
|
idx: g
|
|
787
787
|
}), ""));
|
|
788
788
|
function k() {
|
|
@@ -793,34 +793,34 @@ function Qt(i) {
|
|
|
793
793
|
}
|
|
794
794
|
return p;
|
|
795
795
|
}
|
|
796
|
-
function
|
|
797
|
-
return k() + "#" + (typeof c == "string" ? c :
|
|
796
|
+
function pe(c) {
|
|
797
|
+
return k() + "#" + (typeof c == "string" ? c : Ue(c));
|
|
798
798
|
}
|
|
799
|
-
function
|
|
800
|
-
return p === void 0 && (p = null),
|
|
799
|
+
function me(c, p) {
|
|
800
|
+
return p === void 0 && (p = null), Ie(de({
|
|
801
801
|
pathname: m.pathname,
|
|
802
802
|
hash: "",
|
|
803
803
|
search: ""
|
|
804
|
-
}, typeof c == "string" ?
|
|
804
|
+
}, typeof c == "string" ? at(c) : c, {
|
|
805
805
|
state: p,
|
|
806
|
-
key:
|
|
806
|
+
key: St()
|
|
807
807
|
}));
|
|
808
808
|
}
|
|
809
|
-
function
|
|
809
|
+
function ge(c, p) {
|
|
810
810
|
return [{
|
|
811
811
|
usr: c.state,
|
|
812
812
|
key: c.key,
|
|
813
813
|
idx: p
|
|
814
|
-
},
|
|
814
|
+
}, pe(c)];
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function ne(c, p, v) {
|
|
817
817
|
return !y.length || (y.call({
|
|
818
818
|
action: c,
|
|
819
819
|
location: p,
|
|
820
820
|
retry: v
|
|
821
821
|
}), !1);
|
|
822
822
|
}
|
|
823
|
-
function
|
|
823
|
+
function ae(c) {
|
|
824
824
|
l = c;
|
|
825
825
|
var p = n();
|
|
826
826
|
g = p[0], m = p[1], u.call({
|
|
@@ -828,32 +828,32 @@ function Qt(i) {
|
|
|
828
828
|
location: m
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
|
-
function
|
|
832
|
-
var v =
|
|
831
|
+
function we(c, p) {
|
|
832
|
+
var v = A.Push, $ = me(c, p);
|
|
833
833
|
function L() {
|
|
834
|
-
|
|
834
|
+
we(c, p);
|
|
835
835
|
}
|
|
836
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
837
|
-
var N =
|
|
836
|
+
if (process.env.NODE_ENV !== "production" && qe($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ne(v, $, L)) {
|
|
837
|
+
var N = ge($, g + 1), D = N[0], _ = N[1];
|
|
838
838
|
try {
|
|
839
|
-
a.pushState(D, "",
|
|
839
|
+
a.pushState(D, "", _);
|
|
840
840
|
} catch {
|
|
841
|
-
r.location.assign(
|
|
841
|
+
r.location.assign(_);
|
|
842
842
|
}
|
|
843
|
-
|
|
843
|
+
ae(v);
|
|
844
844
|
}
|
|
845
845
|
}
|
|
846
|
-
function
|
|
847
|
-
var v =
|
|
846
|
+
function F(c, p) {
|
|
847
|
+
var v = A.Replace, $ = me(c, p);
|
|
848
848
|
function L() {
|
|
849
|
-
|
|
849
|
+
F(c, p);
|
|
850
850
|
}
|
|
851
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
852
|
-
var N =
|
|
853
|
-
a.replaceState(D, "",
|
|
851
|
+
if (process.env.NODE_ENV !== "production" && qe($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ne(v, $, L)) {
|
|
852
|
+
var N = ge($, g), D = N[0], _ = N[1];
|
|
853
|
+
a.replaceState(D, "", _), ae(v);
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function Q(c) {
|
|
857
857
|
a.go(c);
|
|
858
858
|
}
|
|
859
859
|
var w = {
|
|
@@ -863,32 +863,32 @@ function Qt(i) {
|
|
|
863
863
|
get location() {
|
|
864
864
|
return m;
|
|
865
865
|
},
|
|
866
|
-
createHref:
|
|
867
|
-
push:
|
|
868
|
-
replace:
|
|
869
|
-
go:
|
|
866
|
+
createHref: pe,
|
|
867
|
+
push: we,
|
|
868
|
+
replace: F,
|
|
869
|
+
go: Q,
|
|
870
870
|
back: function() {
|
|
871
|
-
|
|
871
|
+
Q(-1);
|
|
872
872
|
},
|
|
873
873
|
forward: function() {
|
|
874
|
-
|
|
874
|
+
Q(1);
|
|
875
875
|
},
|
|
876
876
|
listen: function(p) {
|
|
877
877
|
return u.push(p);
|
|
878
878
|
},
|
|
879
879
|
block: function(p) {
|
|
880
880
|
var v = y.push(p);
|
|
881
|
-
return y.length === 1 && r.addEventListener(
|
|
882
|
-
v(), y.length || r.removeEventListener(
|
|
881
|
+
return y.length === 1 && r.addEventListener(We, Ge), function() {
|
|
882
|
+
v(), y.length || r.removeEventListener(We, Ge);
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
885
|
};
|
|
886
886
|
return w;
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function Ge(i) {
|
|
889
889
|
i.preventDefault(), i.returnValue = "";
|
|
890
890
|
}
|
|
891
|
-
function
|
|
891
|
+
function Be() {
|
|
892
892
|
var i = [];
|
|
893
893
|
return {
|
|
894
894
|
get length() {
|
|
@@ -908,14 +908,14 @@ function Ge() {
|
|
|
908
908
|
}
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
|
-
function
|
|
911
|
+
function St() {
|
|
912
912
|
return Math.random().toString(36).substr(2, 8);
|
|
913
913
|
}
|
|
914
|
-
function
|
|
914
|
+
function Ue(i) {
|
|
915
915
|
var e = i.pathname, t = e === void 0 ? "/" : e, r = i.search, a = r === void 0 ? "" : r, n = i.hash, o = n === void 0 ? "" : n;
|
|
916
916
|
return a && a !== "?" && (t += a.charAt(0) === "?" ? a : "?" + a), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function at(i) {
|
|
919
919
|
var e = {};
|
|
920
920
|
if (i) {
|
|
921
921
|
var t = i.indexOf("#");
|
|
@@ -925,26 +925,26 @@ function rt(i) {
|
|
|
925
925
|
}
|
|
926
926
|
return e;
|
|
927
927
|
}
|
|
928
|
-
function
|
|
929
|
-
return
|
|
928
|
+
function be(i) {
|
|
929
|
+
return bt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
930
930
|
}
|
|
931
|
-
function
|
|
931
|
+
function se(i) {
|
|
932
932
|
var t;
|
|
933
|
-
|
|
934
|
-
(r) =>
|
|
933
|
+
Ot(
|
|
934
|
+
(r) => lt(r == null ? void 0 : r.toString),
|
|
935
935
|
i,
|
|
936
936
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
937
937
|
), i = i.filter((r) => r).flatMap(String);
|
|
938
938
|
let e = (t = i.shift()) == null ? void 0 : t.toString();
|
|
939
939
|
if (e) {
|
|
940
940
|
for (const r of i.map((a) => a.toString()))
|
|
941
|
-
r.startsWith(".") ? e =
|
|
941
|
+
r.startsWith(".") ? e = He(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
|
|
942
942
|
e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
|
|
943
943
|
}
|
|
944
944
|
return e ?? "";
|
|
945
945
|
}
|
|
946
|
-
function
|
|
947
|
-
if (
|
|
946
|
+
function He(i, e) {
|
|
947
|
+
if (bt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
|
|
948
948
|
return e;
|
|
949
949
|
let t = i;
|
|
950
950
|
for (; ; )
|
|
@@ -958,9 +958,9 @@ function Ue(i, e) {
|
|
|
958
958
|
e = e.replace(/^\.\/?/, "");
|
|
959
959
|
else
|
|
960
960
|
break;
|
|
961
|
-
return
|
|
961
|
+
return se([t, e]);
|
|
962
962
|
}
|
|
963
|
-
function
|
|
963
|
+
function st(i) {
|
|
964
964
|
if (!i) return {};
|
|
965
965
|
i.startsWith("?") && (i = i.slice(1));
|
|
966
966
|
const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
|
|
@@ -969,9 +969,9 @@ function nt(i) {
|
|
|
969
969
|
});
|
|
970
970
|
return Object.fromEntries(e);
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function wt(i, e, t = {}) {
|
|
973
973
|
var o;
|
|
974
|
-
const [r, a] = e.split("?"), n =
|
|
974
|
+
const [r, a] = e.split("?"), n = be(r);
|
|
975
975
|
e: for (const h of i) {
|
|
976
976
|
const { fragments: l } = h;
|
|
977
977
|
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || t.willMatch && !t.willMatch(h))
|
|
@@ -1003,19 +1003,19 @@ function mt(i, e, t = {}) {
|
|
|
1003
1003
|
throw new Error(`Unknown fragment type: ${k.type}`);
|
|
1004
1004
|
}
|
|
1005
1005
|
}
|
|
1006
|
-
const m =
|
|
1006
|
+
const m = {};
|
|
1007
1007
|
for (const u of g)
|
|
1008
1008
|
u.type === 2 && (m[u.name] = decodeURIComponent(u.value)), u.type === 4 && (m[u.name] = u.value), u.type === 3 && (m.wildcard = "/" + decodeURIComponent(u.value));
|
|
1009
1009
|
return {
|
|
1010
1010
|
path: "/" + g.map((u) => u.value).join("/"),
|
|
1011
1011
|
pattern: "/" + l.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
|
|
1012
1012
|
params: m,
|
|
1013
|
-
query:
|
|
1013
|
+
query: st(a),
|
|
1014
1014
|
meta: h.meta
|
|
1015
1015
|
};
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
|
-
function
|
|
1018
|
+
function Yt(i) {
|
|
1019
1019
|
const e = [], t = [], r = [], a = [];
|
|
1020
1020
|
for (const o of i) {
|
|
1021
1021
|
const { fragments: h } = o;
|
|
@@ -1033,8 +1033,8 @@ function Jt(i) {
|
|
|
1033
1033
|
const n = (o, h) => o.fragments.length > h.fragments.length ? -1 : 1;
|
|
1034
1034
|
return e.sort(n), t.sort(n), r.sort(n), a.sort(n), [...e, ...t, ...r, ...a];
|
|
1035
1035
|
}
|
|
1036
|
-
function
|
|
1037
|
-
const e =
|
|
1036
|
+
function Xt(i) {
|
|
1037
|
+
const e = be(i), t = [];
|
|
1038
1038
|
for (let r = 0; r < e.length; r++) {
|
|
1039
1039
|
const a = e[r];
|
|
1040
1040
|
if (a === "*") {
|
|
@@ -1057,47 +1057,48 @@ function Yt(i) {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
return t;
|
|
1059
1059
|
}
|
|
1060
|
-
var
|
|
1061
|
-
class
|
|
1060
|
+
var Le, M, X, xe, P, Qe, I, Re, Z, ee, ue, he, fe, Oe, K, it, ot;
|
|
1061
|
+
class Zt {
|
|
1062
1062
|
constructor(e, t) {
|
|
1063
|
-
f(this,
|
|
1064
|
-
f(this,
|
|
1063
|
+
f(this, K);
|
|
1064
|
+
f(this, Le);
|
|
1065
1065
|
f(this, M);
|
|
1066
|
-
f(this,
|
|
1067
|
-
f(this,
|
|
1066
|
+
f(this, X);
|
|
1067
|
+
f(this, xe, Ze());
|
|
1068
1068
|
f(this, P);
|
|
1069
|
-
f(this,
|
|
1069
|
+
f(this, Qe, 0);
|
|
1070
1070
|
f(this, I, []);
|
|
1071
1071
|
f(this, Re);
|
|
1072
|
-
f(this, X, []);
|
|
1073
|
-
// Callbacks that need to be called on unmount.
|
|
1074
1072
|
f(this, Z, []);
|
|
1073
|
+
// Callbacks that need to be called on unmount.
|
|
1074
|
+
f(this, ee, []);
|
|
1075
1075
|
/**
|
|
1076
1076
|
* The currently matched route pattern, if any.
|
|
1077
1077
|
*/
|
|
1078
1078
|
S(this, "$pattern");
|
|
1079
|
-
f(this,
|
|
1079
|
+
f(this, ue);
|
|
1080
1080
|
/**
|
|
1081
1081
|
* The current URL path.
|
|
1082
1082
|
*/
|
|
1083
1083
|
S(this, "$path");
|
|
1084
|
-
f(this,
|
|
1084
|
+
f(this, he);
|
|
1085
1085
|
/**
|
|
1086
1086
|
* The current named path params.
|
|
1087
1087
|
*/
|
|
1088
1088
|
S(this, "$params");
|
|
1089
|
-
f(this,
|
|
1089
|
+
f(this, fe);
|
|
1090
1090
|
/**
|
|
1091
1091
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
1092
1092
|
*/
|
|
1093
1093
|
S(this, "$query");
|
|
1094
|
-
f(this,
|
|
1095
|
-
b(this,
|
|
1096
|
-
const [r, a] =
|
|
1097
|
-
|
|
1094
|
+
f(this, Oe);
|
|
1095
|
+
b(this, Le, e), b(this, M, e.createLogger("dolla/router")), b(this, X, t);
|
|
1096
|
+
const [r, a] = ie(null), [n, o] = ie(""), [h, l] = ie({}, { equals: Xe }), [d, g] = ie(
|
|
1097
|
+
st(typeof window > "u" ? "" : window.location.search ?? ""),
|
|
1098
|
+
{ equals: Xe }
|
|
1098
1099
|
);
|
|
1099
|
-
this.$pattern = r, b(this,
|
|
1100
|
-
s(this, P) != null && (s(this,
|
|
1100
|
+
this.$pattern = r, b(this, ue, a), this.$path = n, b(this, he, o), this.$params = h, b(this, fe, l), this.$query = d, b(this, Oe, g), e.beforeMount(() => {
|
|
1101
|
+
s(this, P) != null && (s(this, xe).watch([d], (m) => {
|
|
1101
1102
|
const u = new URLSearchParams();
|
|
1102
1103
|
for (const k in m)
|
|
1103
1104
|
u.set(k, String(m[k]));
|
|
@@ -1106,37 +1107,37 @@ class Xt {
|
|
|
1106
1107
|
pathname: s(this, P).location.pathname,
|
|
1107
1108
|
search: y
|
|
1108
1109
|
});
|
|
1109
|
-
}), s(this,
|
|
1110
|
-
|
|
1110
|
+
}), s(this, ee).push(s(this, P).listen(E(this, K, ot).bind(this))), E(this, K, ot).call(this, s(this, P)), s(this, ee).push(
|
|
1111
|
+
rr(s(this, X).rootElement, (m) => {
|
|
1111
1112
|
let u = m.getAttribute("href");
|
|
1112
|
-
s(this, M).info("Intercepted link click", m, u), /^https?:\/\/|^\//.test(u) || (u =
|
|
1113
|
+
s(this, M).info("Intercepted link click", m, u), /^https?:\/\/|^\//.test(u) || (u = se([s(this, P).location.pathname, u])), s(this, P).push(u);
|
|
1113
1114
|
})
|
|
1114
|
-
), s(this, M).info("Intercepting <a> clicks within root element:", s(this,
|
|
1115
|
+
), s(this, M).info("Intercepting <a> clicks within root element:", s(this, X).rootElement));
|
|
1115
1116
|
}), e.onUnmount(() => {
|
|
1116
|
-
for (; s(this,
|
|
1117
|
-
s(this,
|
|
1118
|
-
s(this,
|
|
1117
|
+
for (; s(this, ee).length > 0; )
|
|
1118
|
+
s(this, ee).pop()();
|
|
1119
|
+
s(this, xe).stopAll();
|
|
1119
1120
|
});
|
|
1120
1121
|
}
|
|
1121
1122
|
setup(e) {
|
|
1122
|
-
if (s(this,
|
|
1123
|
+
if (s(this, Le).isMounted) {
|
|
1123
1124
|
s(this, M).crash(
|
|
1124
1125
|
new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
|
|
1125
1126
|
);
|
|
1126
1127
|
return;
|
|
1127
1128
|
}
|
|
1128
|
-
e.style === "hash" ? b(this, P,
|
|
1129
|
-
e.routes.flatMap((t) => E(this,
|
|
1129
|
+
e.style === "hash" ? b(this, P, Jt()) : b(this, P, Qt()), b(this, Z, Yt(
|
|
1130
|
+
e.routes.flatMap((t) => E(this, K, it).call(this, t)).map((t) => ({
|
|
1130
1131
|
pattern: t.pattern,
|
|
1131
1132
|
meta: t.meta,
|
|
1132
|
-
fragments:
|
|
1133
|
+
fragments: Xt(t.pattern)
|
|
1133
1134
|
}))
|
|
1134
1135
|
));
|
|
1135
|
-
for (const t of s(this,
|
|
1136
|
+
for (const t of s(this, Z))
|
|
1136
1137
|
if (t.meta.redirect) {
|
|
1137
1138
|
let r;
|
|
1138
|
-
if (!
|
|
1139
|
-
if (r = t.meta.redirect, !
|
|
1139
|
+
if (!lt(t.meta.redirect)) if (V(t.meta.redirect)) {
|
|
1140
|
+
if (r = t.meta.redirect, !wt(s(this, Z), r, {
|
|
1140
1141
|
willMatch(n) {
|
|
1141
1142
|
return n !== t;
|
|
1142
1143
|
}
|
|
@@ -1165,7 +1166,7 @@ class Xt {
|
|
|
1165
1166
|
return;
|
|
1166
1167
|
}
|
|
1167
1168
|
let r;
|
|
1168
|
-
Array.isArray(e) ? r =
|
|
1169
|
+
Array.isArray(e) ? r = se(e) : r = e.toString(), r = He(s(this, P).location.pathname, r), t.preserveQuery && (r += s(this, P).location.search), t.replace ? s(this, P).replace(r) : s(this, P).push(r);
|
|
1169
1170
|
}
|
|
1170
1171
|
/**
|
|
1171
1172
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
@@ -1196,13 +1197,13 @@ class Xt {
|
|
|
1196
1197
|
s(this, P).go(e);
|
|
1197
1198
|
}
|
|
1198
1199
|
}
|
|
1199
|
-
|
|
1200
|
+
Le = new WeakMap(), M = new WeakMap(), X = new WeakMap(), xe = new WeakMap(), P = new WeakMap(), Qe = new WeakMap(), I = new WeakMap(), Re = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), Oe = new WeakMap(), K = new WeakSet(), /**
|
|
1200
1201
|
* Parses a route definition object into a set of matchable routes.
|
|
1201
1202
|
*
|
|
1202
1203
|
* @param route - Route config object.
|
|
1203
1204
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
1204
1205
|
*/
|
|
1205
|
-
|
|
1206
|
+
it = function(e, t = [], r = []) {
|
|
1206
1207
|
if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
|
|
1207
1208
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
|
|
1208
1209
|
if (e.redirect && e.routes)
|
|
@@ -1213,30 +1214,30 @@ at = function(e, t = [], r = []) {
|
|
|
1213
1214
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
1214
1215
|
let a = [];
|
|
1215
1216
|
for (const l of t)
|
|
1216
|
-
a.push(...
|
|
1217
|
-
a.push(...
|
|
1217
|
+
a.push(...be(l.path));
|
|
1218
|
+
a.push(...be(e.path)), a[a.length - 1] === "*" && a.pop();
|
|
1218
1219
|
const n = [];
|
|
1219
1220
|
if (e.redirect) {
|
|
1220
1221
|
let l = e.redirect;
|
|
1221
|
-
return V(l) && (l =
|
|
1222
|
-
pattern: "/" +
|
|
1222
|
+
return V(l) && (l = He(se(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
|
|
1223
|
+
pattern: "/" + se([...a, ...be(e.path)]),
|
|
1223
1224
|
meta: {
|
|
1224
1225
|
redirect: l
|
|
1225
1226
|
}
|
|
1226
1227
|
}), n;
|
|
1227
1228
|
}
|
|
1228
|
-
let o =
|
|
1229
|
+
let o = vt;
|
|
1229
1230
|
if (typeof e.view == "function")
|
|
1230
1231
|
o = e.view;
|
|
1231
1232
|
else if (e.view)
|
|
1232
1233
|
throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
|
|
1233
|
-
const h = { id:
|
|
1234
|
+
const h = { id: ut(this, Qe)._++, view: o };
|
|
1234
1235
|
if (e.routes)
|
|
1235
1236
|
for (const l of e.routes)
|
|
1236
|
-
n.push(...E(this,
|
|
1237
|
+
n.push(...E(this, K, it).call(this, l, [...t, e], [...r, h]));
|
|
1237
1238
|
else
|
|
1238
1239
|
n.push({
|
|
1239
|
-
pattern: parent ?
|
|
1240
|
+
pattern: parent ? se([...t.map((l) => l.path), e.path]) : e.path,
|
|
1240
1241
|
meta: {
|
|
1241
1242
|
pattern: e.path,
|
|
1242
1243
|
layers: [...r, h],
|
|
@@ -1244,11 +1245,11 @@ at = function(e, t = [], r = []) {
|
|
|
1244
1245
|
}
|
|
1245
1246
|
});
|
|
1246
1247
|
return n;
|
|
1247
|
-
},
|
|
1248
|
-
e.search !== s(this, Re) && (b(this, Re, e.search), s(this,
|
|
1249
|
-
const t =
|
|
1248
|
+
}, ot = async function({ location: e }) {
|
|
1249
|
+
e.search !== s(this, Re) && (b(this, Re, e.search), s(this, Oe).call(this, st(e.search)));
|
|
1250
|
+
const t = wt(s(this, Z), e.pathname);
|
|
1250
1251
|
if (!t) {
|
|
1251
|
-
s(this,
|
|
1252
|
+
s(this, ue).call(this, null), s(this, he).call(this, e.pathname), s(this, fe).call(this, {
|
|
1252
1253
|
wildcard: e.pathname
|
|
1253
1254
|
});
|
|
1254
1255
|
return;
|
|
@@ -1260,7 +1261,7 @@ at = function(e, t = [], r = []) {
|
|
|
1260
1261
|
}
|
|
1261
1262
|
}), t.meta.redirect != null)
|
|
1262
1263
|
if (typeof t.meta.redirect == "string") {
|
|
1263
|
-
const r =
|
|
1264
|
+
const r = nr(t.meta.redirect, t.params);
|
|
1264
1265
|
s(this, M).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, P).replace(r);
|
|
1265
1266
|
} else if (typeof t.meta.redirect == "function") {
|
|
1266
1267
|
const r = {
|
|
@@ -1272,11 +1273,11 @@ at = function(e, t = [], r = []) {
|
|
|
1272
1273
|
let a = await t.meta.redirect(r);
|
|
1273
1274
|
if (typeof a != "string")
|
|
1274
1275
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
1275
|
-
a.startsWith("/") || (a =
|
|
1276
|
+
a.startsWith("/") || (a = He(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, P).replace(a);
|
|
1276
1277
|
} else
|
|
1277
1278
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
1278
|
-
else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this,
|
|
1279
|
-
s(this,
|
|
1279
|
+
else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, he).call(this, t.path), s(this, fe).call(this, t.params), t.pattern !== this.$pattern.get()) {
|
|
1280
|
+
s(this, ue).call(this, t.pattern);
|
|
1280
1281
|
const r = t.meta.layers;
|
|
1281
1282
|
for (let a = 0; a < r.length; a++) {
|
|
1282
1283
|
const n = r[a], o = s(this, I)[a];
|
|
@@ -1285,13 +1286,13 @@ at = function(e, t = [], r = []) {
|
|
|
1285
1286
|
const h = s(this, I).at(-1);
|
|
1286
1287
|
o && o.node.isMounted && o.node.unmount();
|
|
1287
1288
|
let l;
|
|
1288
|
-
h ? l = h.node.setChildView(n.view) : l = s(this,
|
|
1289
|
+
h ? l = h.node.setChildView(n.view) : l = s(this, X).rootView.setChildView(n.view), s(this, I).push({ id: n.id, node: l });
|
|
1289
1290
|
}
|
|
1290
1291
|
}
|
|
1291
1292
|
}
|
|
1292
1293
|
};
|
|
1293
|
-
const
|
|
1294
|
-
function
|
|
1294
|
+
const er = /(noopener|noreferrer) (noopener|noreferrer)/, tr = /^[\w-_]+:/;
|
|
1295
|
+
function rr(i, e, t = window) {
|
|
1295
1296
|
function r(n) {
|
|
1296
1297
|
return !n || n === i ? null : n.localName !== "a" || n.href === void 0 ? r(n.parentNode) : n;
|
|
1297
1298
|
}
|
|
@@ -1299,60 +1300,64 @@ function tr(i, e, t = window) {
|
|
|
1299
1300
|
if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
|
|
1300
1301
|
return;
|
|
1301
1302
|
const o = r(n.target);
|
|
1302
|
-
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" &&
|
|
1303
|
+
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" && er.test(o.getAttribute("rel")) || tr.test(o.getAttribute("href")) || (n.preventDefault(), e(o)));
|
|
1303
1304
|
}
|
|
1304
1305
|
return i.addEventListener("click", a), function() {
|
|
1305
1306
|
i.removeEventListener("click", a);
|
|
1306
1307
|
};
|
|
1307
1308
|
}
|
|
1308
|
-
function
|
|
1309
|
+
function nr(i, e) {
|
|
1309
1310
|
for (const t in e) {
|
|
1310
1311
|
const r = e[t].toString();
|
|
1311
1312
|
i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
|
|
1312
1313
|
}
|
|
1313
1314
|
return i;
|
|
1314
1315
|
}
|
|
1315
|
-
var W,
|
|
1316
|
-
class
|
|
1316
|
+
var W, Ne, G, te, Me, Te, De, Ae, _e, je, B, x, z;
|
|
1317
|
+
class ar {
|
|
1317
1318
|
constructor() {
|
|
1318
1319
|
S(this, "http");
|
|
1319
1320
|
S(this, "i18n");
|
|
1320
1321
|
S(this, "render");
|
|
1321
1322
|
S(this, "router");
|
|
1322
1323
|
f(this, W, !1);
|
|
1323
|
-
f(this,
|
|
1324
|
+
f(this, Ne, "production");
|
|
1324
1325
|
f(this, G);
|
|
1325
|
-
f(this,
|
|
1326
|
-
f(this,
|
|
1327
|
-
f(this,
|
|
1328
|
-
f(this, Te, []);
|
|
1326
|
+
f(this, te);
|
|
1327
|
+
f(this, Me, Vt);
|
|
1328
|
+
f(this, Te, Ze());
|
|
1329
1329
|
f(this, De, []);
|
|
1330
|
-
f(this, _e, []);
|
|
1331
1330
|
f(this, Ae, []);
|
|
1332
|
-
f(this,
|
|
1331
|
+
f(this, _e, []);
|
|
1332
|
+
f(this, je, []);
|
|
1333
|
+
f(this, B, {
|
|
1334
|
+
root: this,
|
|
1335
|
+
data: {}
|
|
1336
|
+
});
|
|
1337
|
+
f(this, x, {
|
|
1333
1338
|
info: "development",
|
|
1334
1339
|
log: "development",
|
|
1335
1340
|
warn: "development",
|
|
1336
1341
|
error: !0
|
|
1337
1342
|
});
|
|
1338
|
-
f(this,
|
|
1339
|
-
S(this, "watch", s(this,
|
|
1340
|
-
S(this, "createState",
|
|
1341
|
-
S(this, "createSettableState",
|
|
1342
|
-
S(this, "toSettableState",
|
|
1343
|
-
S(this, "toState",
|
|
1344
|
-
S(this, "valueOf",
|
|
1345
|
-
S(this, "derive",
|
|
1346
|
-
S(this, "createWatcher",
|
|
1347
|
-
S(this, "createRef",
|
|
1348
|
-
S(this, "isRef",
|
|
1343
|
+
f(this, z, dt("*,-dolla/*"));
|
|
1344
|
+
S(this, "watch", s(this, Te).watch);
|
|
1345
|
+
S(this, "createState", ie);
|
|
1346
|
+
S(this, "createSettableState", Nt);
|
|
1347
|
+
S(this, "toSettableState", Mt);
|
|
1348
|
+
S(this, "toState", pt);
|
|
1349
|
+
S(this, "valueOf", Tt);
|
|
1350
|
+
S(this, "derive", ye);
|
|
1351
|
+
S(this, "createWatcher", Ze);
|
|
1352
|
+
S(this, "createRef", Dt);
|
|
1353
|
+
S(this, "isRef", At);
|
|
1349
1354
|
const e = this;
|
|
1350
|
-
this.http = new
|
|
1355
|
+
this.http = new qt(), this.i18n = new Gt(this), this.render = new zt(this), this.router = new Zt(this, {
|
|
1351
1356
|
get rootElement() {
|
|
1352
1357
|
return s(e, G);
|
|
1353
1358
|
},
|
|
1354
1359
|
get rootView() {
|
|
1355
|
-
return s(e,
|
|
1360
|
+
return s(e, te);
|
|
1356
1361
|
}
|
|
1357
1362
|
});
|
|
1358
1363
|
}
|
|
@@ -1367,40 +1372,58 @@ class nr {
|
|
|
1367
1372
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1368
1373
|
*/
|
|
1369
1374
|
getEnv() {
|
|
1370
|
-
return s(this,
|
|
1375
|
+
return s(this, Ne);
|
|
1371
1376
|
}
|
|
1372
1377
|
/**
|
|
1373
1378
|
* Sets the environment that this app is running in.
|
|
1374
1379
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1375
1380
|
*/
|
|
1376
1381
|
setEnv(e) {
|
|
1377
|
-
b(this,
|
|
1382
|
+
b(this, Ne, e);
|
|
1378
1383
|
}
|
|
1379
1384
|
/**
|
|
1380
1385
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
1381
1386
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
1382
1387
|
*/
|
|
1383
1388
|
setCrashView(e) {
|
|
1384
|
-
b(this,
|
|
1389
|
+
b(this, Me, e);
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
1393
|
+
*/
|
|
1394
|
+
set(e, t) {
|
|
1395
|
+
return s(this, B).data[e] = t, t;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
1399
|
+
*/
|
|
1400
|
+
get(e) {
|
|
1401
|
+
return s(this, B).data[e] ?? null;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Returns an object of all context variables stored at the app level.
|
|
1405
|
+
*/
|
|
1406
|
+
getAll() {
|
|
1407
|
+
return { ...s(this, B).data };
|
|
1385
1408
|
}
|
|
1386
1409
|
async mount(e, t) {
|
|
1387
1410
|
if (s(this, W))
|
|
1388
1411
|
throw new Error("Dolla is already mounted.");
|
|
1389
1412
|
if (V(e)) {
|
|
1390
1413
|
const a = document.querySelector(e);
|
|
1391
|
-
|
|
1414
|
+
mt(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, G, a);
|
|
1392
1415
|
} else
|
|
1393
|
-
|
|
1416
|
+
mt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, G, e);
|
|
1394
1417
|
let r;
|
|
1395
|
-
t ? r =
|
|
1396
|
-
for (const a of s(this,
|
|
1418
|
+
t ? r = gt(t) : r = gt(vt), b(this, te, this.constructView(r.type, r.props)), await Promise.all(s(this, De).map((a) => a())), s(this, te).mount(s(this, G)), b(this, W, !0);
|
|
1419
|
+
for (const a of s(this, Ae))
|
|
1397
1420
|
a();
|
|
1398
1421
|
}
|
|
1399
1422
|
async unmount() {
|
|
1400
1423
|
var e;
|
|
1401
1424
|
if (s(this, W)) {
|
|
1402
|
-
await Promise.all(s(this, _e).map((t) => t())), (e = s(this,
|
|
1403
|
-
for (const t of s(this,
|
|
1425
|
+
await Promise.all(s(this, _e).map((t) => t())), (e = s(this, te)) == null || e.unmount(), s(this, Te).stopAll(), b(this, W, !1);
|
|
1426
|
+
for (const t of s(this, je))
|
|
1404
1427
|
t();
|
|
1405
1428
|
}
|
|
1406
1429
|
}
|
|
@@ -1409,13 +1432,13 @@ class nr {
|
|
|
1409
1432
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1410
1433
|
*/
|
|
1411
1434
|
beforeMount(e) {
|
|
1412
|
-
s(this,
|
|
1435
|
+
s(this, De).push(e);
|
|
1413
1436
|
}
|
|
1414
1437
|
/**
|
|
1415
1438
|
* Registers a `callback` to run after the app is mounted.
|
|
1416
1439
|
*/
|
|
1417
1440
|
onMount(e) {
|
|
1418
|
-
s(this,
|
|
1441
|
+
s(this, Ae).push(e);
|
|
1419
1442
|
}
|
|
1420
1443
|
/**
|
|
1421
1444
|
* Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
|
|
@@ -1428,7 +1451,7 @@ class nr {
|
|
|
1428
1451
|
* Registers a `callback` to run after the app is unmounted.
|
|
1429
1452
|
*/
|
|
1430
1453
|
onUnmount(e) {
|
|
1431
|
-
s(this,
|
|
1454
|
+
s(this, je).push(e);
|
|
1432
1455
|
}
|
|
1433
1456
|
/**
|
|
1434
1457
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1436,20 +1459,20 @@ class nr {
|
|
|
1436
1459
|
setLoggles(e) {
|
|
1437
1460
|
for (const t in e) {
|
|
1438
1461
|
const r = e[t];
|
|
1439
|
-
r && (s(this,
|
|
1462
|
+
r && (s(this, x)[t] = r);
|
|
1440
1463
|
}
|
|
1441
1464
|
}
|
|
1442
1465
|
setLogFilter(e) {
|
|
1443
|
-
b(this,
|
|
1466
|
+
b(this, z, dt(e));
|
|
1444
1467
|
}
|
|
1445
1468
|
createLogger(e, t) {
|
|
1446
|
-
const r =
|
|
1469
|
+
const r = pt(e), a = (t == null ? void 0 : t.console) ?? _t(), n = this;
|
|
1447
1470
|
return {
|
|
1448
1471
|
get info() {
|
|
1449
1472
|
var h;
|
|
1450
1473
|
const o = r.get();
|
|
1451
|
-
if (s(n,
|
|
1452
|
-
return
|
|
1474
|
+
if (s(n, x).info === !1 || V(s(n, x).info) && s(n, x).info !== n.getEnv() || !s(h = n, z).call(h, o))
|
|
1475
|
+
return Ce;
|
|
1453
1476
|
{
|
|
1454
1477
|
let l = `%c${o}`;
|
|
1455
1478
|
return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.info.bind(
|
|
@@ -1465,8 +1488,8 @@ class nr {
|
|
|
1465
1488
|
get log() {
|
|
1466
1489
|
var h;
|
|
1467
1490
|
const o = r.get();
|
|
1468
|
-
if (s(n,
|
|
1469
|
-
return
|
|
1491
|
+
if (s(n, x).log === !1 || V(s(n, x).log) && s(n, x).log !== n.getEnv() || !s(h = n, z).call(h, o))
|
|
1492
|
+
return Ce;
|
|
1470
1493
|
{
|
|
1471
1494
|
let l = `%c${o}`;
|
|
1472
1495
|
return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.log.bind(
|
|
@@ -1482,8 +1505,8 @@ class nr {
|
|
|
1482
1505
|
get warn() {
|
|
1483
1506
|
var h;
|
|
1484
1507
|
const o = r.get();
|
|
1485
|
-
if (s(n,
|
|
1486
|
-
return
|
|
1508
|
+
if (s(n, x).warn === !1 || V(s(n, x).warn) && s(n, x).warn !== n.getEnv() || !s(h = n, z).call(h, o))
|
|
1509
|
+
return Ce;
|
|
1487
1510
|
{
|
|
1488
1511
|
let l = `%c${o}`;
|
|
1489
1512
|
return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.warn.bind(
|
|
@@ -1499,8 +1522,8 @@ class nr {
|
|
|
1499
1522
|
get error() {
|
|
1500
1523
|
var h;
|
|
1501
1524
|
const o = r.get();
|
|
1502
|
-
if (s(n,
|
|
1503
|
-
return
|
|
1525
|
+
if (s(n, x).error === !1 || V(s(n, x).error) && s(n, x).error !== n.getEnv() || !s(h = n, z).call(h, o))
|
|
1526
|
+
return Ce;
|
|
1504
1527
|
{
|
|
1505
1528
|
let l = `%c${o}`;
|
|
1506
1529
|
return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.error.bind(
|
|
@@ -1514,7 +1537,7 @@ class nr {
|
|
|
1514
1537
|
}
|
|
1515
1538
|
},
|
|
1516
1539
|
crash(o) {
|
|
1517
|
-
throw n.isMounted && (n.unmount(), n.constructView(s(n,
|
|
1540
|
+
throw n.isMounted && (n.unmount(), n.constructView(s(n, Me), {
|
|
1518
1541
|
error: o,
|
|
1519
1542
|
loggerName: r.get(),
|
|
1520
1543
|
uid: t == null ? void 0 : t.uid
|
|
@@ -1526,41 +1549,41 @@ class nr {
|
|
|
1526
1549
|
*
|
|
1527
1550
|
*/
|
|
1528
1551
|
constructView(e, t, r = []) {
|
|
1529
|
-
return
|
|
1552
|
+
return jt(s(this, B), e, t, r);
|
|
1530
1553
|
}
|
|
1531
1554
|
/**
|
|
1532
1555
|
*
|
|
1533
1556
|
*/
|
|
1534
1557
|
constructMarkup(e) {
|
|
1535
|
-
return
|
|
1558
|
+
return Ct(Ft(s(this, B), e));
|
|
1536
1559
|
}
|
|
1537
1560
|
}
|
|
1538
|
-
W = new WeakMap(),
|
|
1539
|
-
const
|
|
1540
|
-
function
|
|
1561
|
+
W = new WeakMap(), Ne = new WeakMap(), G = new WeakMap(), te = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), De = new WeakMap(), Ae = new WeakMap(), _e = new WeakMap(), je = new WeakMap(), B = new WeakMap(), x = new WeakMap(), z = new WeakMap();
|
|
1562
|
+
const yt = new ar(), lr = yt.i18n.t.bind(yt.i18n);
|
|
1563
|
+
function cr(i) {
|
|
1541
1564
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
|
|
1542
1565
|
}
|
|
1543
|
-
function
|
|
1566
|
+
function ur() {
|
|
1544
1567
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1545
1568
|
}
|
|
1546
1569
|
export {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1570
|
+
Rt as cond,
|
|
1571
|
+
gt as createMarkup,
|
|
1572
|
+
Dt as createRef,
|
|
1573
|
+
Nt as createSettableState,
|
|
1574
|
+
dr as createSetter,
|
|
1575
|
+
ie as createState,
|
|
1576
|
+
yt as default,
|
|
1577
|
+
ye as derive,
|
|
1578
|
+
ur as getDevDebug,
|
|
1579
|
+
ht as html,
|
|
1580
|
+
At as isRef,
|
|
1581
|
+
pr as portal,
|
|
1582
|
+
mr as repeat,
|
|
1583
|
+
cr as setDevDebug,
|
|
1584
|
+
lr as t,
|
|
1585
|
+
Mt as toSettableState,
|
|
1586
|
+
pt as toState,
|
|
1587
|
+
Tt as valueOf
|
|
1565
1588
|
};
|
|
1566
1589
|
//# sourceMappingURL=index.js.map
|