@manyducks.co/dolla 2.0.0-alpha.18 → 2.0.0-alpha.19
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/dist/index.js +447 -442
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/modules/render.d.ts +5 -8
- package/dist/{passthrough-TqzdQt5Q.js → passthrough-DcOD0Wf3.js} +153 -152
- package/dist/passthrough-DcOD0Wf3.js.map +1 -0
- package/notes/scratch.md +1 -1
- package/package.json +1 -1
- package/dist/passthrough-TqzdQt5Q.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Nt = Object.defineProperty;
|
|
2
|
+
var pt = (i) => {
|
|
3
3
|
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var s = (i, e, t) => (
|
|
8
|
-
var
|
|
5
|
+
var Mt = (i, e, t) => e in i ? Nt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
6
|
+
var P = (i, e, t) => Mt(i, typeof e != "symbol" ? e + "" : e, t), Ze = (i, e, t) => e.has(i) || pt("Cannot " + t);
|
|
7
|
+
var s = (i, e, t) => (Ze(i, e, "read from private field"), t ? t.call(i) : e.get(i)), h = (i, e, t) => e.has(i) ? pt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), v = (i, e, t, r) => (Ze(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), b = (i, e, t) => (Ze(i, e, "access private method"), t);
|
|
8
|
+
var et = (i, e, t, r) => ({
|
|
9
9
|
set _(n) {
|
|
10
|
-
|
|
10
|
+
v(i, e, n, t);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
13
|
return s(i, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as
|
|
17
|
-
import { A as
|
|
18
|
-
function
|
|
19
|
-
return
|
|
16
|
+
import { h as mt, c as jt, i as rt, g as Tt, a as ce, d as be, b as dt, e as V, t as gt, f as St, j as qt, k as nt, P as Pt, l as wt, m as Ft, n as At, o as _t, v as Ct, p as Vt, q as It, r as yt, s as vt, u as Ut, w as Ce, x as Ve, V as Ht, y as Wt, z as Bt } from "./passthrough-DcOD0Wf3.js";
|
|
17
|
+
import { A as kr, B as Sr, C as Pr } from "./passthrough-DcOD0Wf3.js";
|
|
18
|
+
function Gt(i) {
|
|
19
|
+
return mt`
|
|
20
20
|
<div
|
|
21
21
|
style=${{
|
|
22
22
|
backgroundColor: "#880000",
|
|
@@ -30,7 +30,7 @@ function Ht(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
|
+
${jt(i.uid, mt`<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 Ht(i) {
|
|
|
62
62
|
</div>
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
|
-
var
|
|
66
|
-
class
|
|
65
|
+
var Y, Qe, M, F;
|
|
66
|
+
class zt {
|
|
67
67
|
constructor() {
|
|
68
|
-
h(this,
|
|
69
|
-
h(this,
|
|
70
|
-
h(this,
|
|
68
|
+
h(this, M);
|
|
69
|
+
h(this, Y, []);
|
|
70
|
+
h(this, Qe, Kt());
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -76,60 +76,60 @@ class It {
|
|
|
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, Y).push(e), () => {
|
|
80
|
+
s(this, Y).splice(s(this, Y).indexOf(e), 1);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
async get(e, t) {
|
|
84
|
-
return
|
|
84
|
+
return b(this, M, F).call(this, "get", e, t);
|
|
85
85
|
}
|
|
86
86
|
async put(e, t) {
|
|
87
|
-
return
|
|
87
|
+
return b(this, M, F).call(this, "put", e, t);
|
|
88
88
|
}
|
|
89
89
|
async patch(e, t) {
|
|
90
|
-
return
|
|
90
|
+
return b(this, M, F).call(this, "patch", e, t);
|
|
91
91
|
}
|
|
92
92
|
async post(e, t) {
|
|
93
|
-
return
|
|
93
|
+
return b(this, M, F).call(this, "post", e, t);
|
|
94
94
|
}
|
|
95
95
|
async delete(e, t) {
|
|
96
|
-
return
|
|
96
|
+
return b(this, M, F).call(this, "delete", e, t);
|
|
97
97
|
}
|
|
98
98
|
async head(e, t) {
|
|
99
|
-
return
|
|
99
|
+
return b(this, M, F).call(this, "head", e, t);
|
|
100
100
|
}
|
|
101
101
|
async options(e, t) {
|
|
102
|
-
return
|
|
102
|
+
return b(this, M, F).call(this, "options", e, t);
|
|
103
103
|
}
|
|
104
104
|
async trace(e, t) {
|
|
105
|
-
return
|
|
105
|
+
return b(this, M, F).call(this, "trace", e, t);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
return
|
|
108
|
+
Y = new WeakMap(), Qe = new WeakMap(), M = new WeakSet(), F = async function(e, t, r) {
|
|
109
|
+
return Jt({
|
|
110
110
|
...r,
|
|
111
111
|
method: e,
|
|
112
112
|
uri: t,
|
|
113
|
-
middleware: s(this,
|
|
114
|
-
fetch: s(this,
|
|
113
|
+
middleware: s(this, Y),
|
|
114
|
+
fetch: s(this, Qe)
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
|
-
function
|
|
117
|
+
function Kt() {
|
|
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 Qt extends Error {
|
|
125
125
|
constructor(t) {
|
|
126
126
|
const { status: r, statusText: n, method: a, uri: o } = t, p = `${r} ${n}: Request failed (${a.toUpperCase()} ${o})`;
|
|
127
127
|
super(p);
|
|
128
|
-
|
|
128
|
+
P(this, "response");
|
|
129
129
|
this.response = t;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
132
|
+
async function Jt(i) {
|
|
133
133
|
const { headers: e, query: t, fetch: r, middleware: n } = i, a = {
|
|
134
134
|
method: i.method,
|
|
135
135
|
uri: i.uri,
|
|
@@ -168,7 +168,7 @@ async function Bt(i) {
|
|
|
168
168
|
const p = async () => {
|
|
169
169
|
const l = a.query.toString(), f = l.length > 0 ? a.uri + "?" + l : a.uri;
|
|
170
170
|
let m;
|
|
171
|
-
!a.headers.has("content-type") &&
|
|
171
|
+
!a.headers.has("content-type") && rt(a.body) ? (a.headers.set("content-type", "application/json"), m = JSON.stringify(a.body)) : m = a.body;
|
|
172
172
|
const g = await r(f, {
|
|
173
173
|
method: a.method,
|
|
174
174
|
headers: a.headers,
|
|
@@ -193,12 +193,12 @@ async function Bt(i) {
|
|
|
193
193
|
} else
|
|
194
194
|
await p();
|
|
195
195
|
if (o.status < 200 || o.status >= 400)
|
|
196
|
-
throw new
|
|
196
|
+
throw new Qt(o);
|
|
197
197
|
return o;
|
|
198
198
|
}
|
|
199
|
-
var
|
|
200
|
-
function
|
|
201
|
-
return
|
|
199
|
+
var tt, bt;
|
|
200
|
+
function Yt() {
|
|
201
|
+
return bt || (bt = 1, tt = function i(e, t) {
|
|
202
202
|
if (e === t) return !0;
|
|
203
203
|
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
204
204
|
if (e.constructor !== t.constructor) return !1;
|
|
@@ -222,30 +222,30 @@ function zt() {
|
|
|
222
222
|
return !0;
|
|
223
223
|
}
|
|
224
224
|
return e !== e && t !== t;
|
|
225
|
-
}),
|
|
225
|
+
}), tt;
|
|
226
226
|
}
|
|
227
|
-
var
|
|
228
|
-
const
|
|
229
|
-
var
|
|
230
|
-
class
|
|
227
|
+
var Xt = Yt();
|
|
228
|
+
const Zt = /* @__PURE__ */ Tt(Xt);
|
|
229
|
+
var Je, ue, se, at, xt;
|
|
230
|
+
class er {
|
|
231
231
|
constructor(e, t) {
|
|
232
|
-
h(this,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
h(this,
|
|
236
|
-
h(this,
|
|
232
|
+
h(this, se);
|
|
233
|
+
P(this, "dolla");
|
|
234
|
+
P(this, "config");
|
|
235
|
+
h(this, Je, !1);
|
|
236
|
+
h(this, ue, /* @__PURE__ */ new Map());
|
|
237
237
|
this.config = e, this.dolla = t;
|
|
238
238
|
}
|
|
239
239
|
async load() {
|
|
240
240
|
let e;
|
|
241
|
-
if (!s(this,
|
|
242
|
-
if (
|
|
243
|
-
if (e = await this.config.fetch(), !
|
|
241
|
+
if (!s(this, Je)) {
|
|
242
|
+
if (dt(this.config.fetch)) {
|
|
243
|
+
if (e = await this.config.fetch(), !rt(e))
|
|
244
244
|
throw new Error(`Fetch function did not return an object of language strings: ${e}`);
|
|
245
|
-
} else if (
|
|
245
|
+
} else if (V(this.config.path)) {
|
|
246
246
|
const t = await this.dolla.http.get(this.config.path);
|
|
247
247
|
if (t.status >= 200 && t.status < 300)
|
|
248
|
-
if (
|
|
248
|
+
if (rt(t.body))
|
|
249
249
|
e = t.body;
|
|
250
250
|
else
|
|
251
251
|
throw new Error(
|
|
@@ -256,38 +256,38 @@ class Jt {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
if (e) {
|
|
259
|
-
const t =
|
|
259
|
+
const t = b(this, se, at).call(this, e);
|
|
260
260
|
for (const r of t)
|
|
261
|
-
s(this,
|
|
261
|
+
s(this, ue).set(r[0], r[1]);
|
|
262
262
|
} else
|
|
263
263
|
throw new Error("Language could not be loaded.");
|
|
264
264
|
}
|
|
265
265
|
getTemplate(e) {
|
|
266
|
-
return s(this,
|
|
266
|
+
return s(this, ue).get(e) ?? {
|
|
267
267
|
segments: [{ type: 0, text: `[MISSING: ${e}]` }]
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
270
|
hasTemplate(e) {
|
|
271
|
-
return s(this,
|
|
271
|
+
return s(this, ue).has(e);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
|
|
274
|
+
Je = new WeakMap(), ue = new WeakMap(), se = new WeakSet(), at = function(e, t = []) {
|
|
275
275
|
const r = [];
|
|
276
276
|
for (const n in e)
|
|
277
|
-
switch (
|
|
277
|
+
switch (gt(e[n])) {
|
|
278
278
|
case "string":
|
|
279
|
-
r.push([[...t, n].join("."),
|
|
279
|
+
r.push([[...t, n].join("."), b(this, se, xt).call(this, e[n])]);
|
|
280
280
|
break;
|
|
281
281
|
case "object":
|
|
282
|
-
r.push(
|
|
282
|
+
r.push(...b(this, se, at).call(this, e[n], [...t, n]));
|
|
283
283
|
break;
|
|
284
284
|
default:
|
|
285
285
|
throw new Error(
|
|
286
|
-
`Expected to find a string or object at ${[...t, n].join(".")}. Got: ${
|
|
286
|
+
`Expected to find a string or object at ${[...t, n].join(".")}. Got: ${gt(e[n])}`
|
|
287
287
|
);
|
|
288
288
|
}
|
|
289
289
|
return r;
|
|
290
|
-
},
|
|
290
|
+
}, xt = function(e) {
|
|
291
291
|
let t;
|
|
292
292
|
((u) => {
|
|
293
293
|
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";
|
|
@@ -336,22 +336,22 @@ Ke = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), et = function(e, t =
|
|
|
336
336
|
}
|
|
337
337
|
return o === 0 && n.length > 0 && r.segments.push({ type: 0, text: n }), r;
|
|
338
338
|
};
|
|
339
|
-
var
|
|
340
|
-
class
|
|
339
|
+
var Ee, I, L, ke, Se, Pe, xe, R, Ot, st, it, ot, Lt;
|
|
340
|
+
class tr {
|
|
341
341
|
constructor(e) {
|
|
342
342
|
h(this, R);
|
|
343
|
-
h(this,
|
|
344
|
-
h(this,
|
|
343
|
+
h(this, Ee);
|
|
344
|
+
h(this, I);
|
|
345
345
|
h(this, L, /* @__PURE__ */ new Map());
|
|
346
|
-
h(this,
|
|
347
|
-
h(this,
|
|
348
|
-
h(this,
|
|
349
|
-
|
|
350
|
-
h(this,
|
|
351
|
-
|
|
352
|
-
const [t, r] =
|
|
353
|
-
this.$locale = t,
|
|
354
|
-
s(this, L).size > 0 && await this.setLocale(s(this,
|
|
346
|
+
h(this, ke, []);
|
|
347
|
+
h(this, Se, /* @__PURE__ */ new Map());
|
|
348
|
+
h(this, Pe, "auto");
|
|
349
|
+
P(this, "$locale");
|
|
350
|
+
h(this, xe);
|
|
351
|
+
v(this, Ee, e), v(this, I, e.createLogger("dolla/i18n"));
|
|
352
|
+
const [t, r] = ce();
|
|
353
|
+
this.$locale = t, v(this, xe, r), this.addFormat("number", (n, a, o) => b(this, R, st).call(this, Number(a), o)), this.addFormat("datetime", (n, a, o) => b(this, R, it).call(this, a, o)), this.addFormat("list", (n, a, o) => b(this, R, ot).call(this, a, o)), e.beforeMount(async () => {
|
|
354
|
+
s(this, L).size > 0 && await this.setLocale(s(this, Pe));
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
357
|
get locales() {
|
|
@@ -359,13 +359,13 @@ class Yt {
|
|
|
359
359
|
}
|
|
360
360
|
setup(e) {
|
|
361
361
|
if (e.translations.forEach((t) => {
|
|
362
|
-
s(this, L).set(t.locale, new
|
|
362
|
+
s(this, L).set(t.locale, new er(t, s(this, Ee)));
|
|
363
363
|
}), e.locale && e.locale !== "auto") {
|
|
364
364
|
if (!e.translations.some((r) => r.locale === e.locale))
|
|
365
365
|
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
366
|
-
|
|
366
|
+
v(this, Pe, e.locale);
|
|
367
367
|
}
|
|
368
|
-
s(this,
|
|
368
|
+
s(this, I).info(
|
|
369
369
|
`${s(this, L).size} language${s(this, L).size === 1 ? "" : "s"} supported: '${[...s(this, L).keys()].join("', '")}'`
|
|
370
370
|
);
|
|
371
371
|
}
|
|
@@ -390,9 +390,9 @@ class Yt {
|
|
|
390
390
|
throw new Error(`Locale '${e}' has no translation.`);
|
|
391
391
|
const r = s(this, L).get(t);
|
|
392
392
|
try {
|
|
393
|
-
await r.load(),
|
|
393
|
+
await r.load(), v(this, ke, []), s(this, xe).call(this, t), s(this, I).info("set language to " + t);
|
|
394
394
|
} catch (a) {
|
|
395
|
-
a instanceof Error && s(this,
|
|
395
|
+
a instanceof Error && s(this, I).crash(a);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
@@ -412,13 +412,13 @@ class Yt {
|
|
|
412
412
|
let r = [], n = [];
|
|
413
413
|
for (const a in t)
|
|
414
414
|
r.push(a), n.push(t[a]);
|
|
415
|
-
return
|
|
415
|
+
return be([this.$locale, ...n], (a, ...o) => {
|
|
416
416
|
if (a == null)
|
|
417
417
|
return "[NO LOCALE SET]";
|
|
418
418
|
const p = {};
|
|
419
419
|
for (let l = 0; l < o.length; l++)
|
|
420
420
|
p[r[l]] = o[l];
|
|
421
|
-
return
|
|
421
|
+
return b(this, R, Ot).call(this, a, e, p);
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
@@ -436,7 +436,7 @@ class Yt {
|
|
|
436
436
|
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
437
437
|
*/
|
|
438
438
|
addFormat(e, t) {
|
|
439
|
-
s(this,
|
|
439
|
+
s(this, Se).set(e, t);
|
|
440
440
|
}
|
|
441
441
|
/**
|
|
442
442
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
@@ -453,7 +453,7 @@ class Yt {
|
|
|
453
453
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
454
454
|
*/
|
|
455
455
|
number(e, t) {
|
|
456
|
-
return
|
|
456
|
+
return be([this.$locale, e], (r, n) => b(this, R, st).call(this, n, t));
|
|
457
457
|
}
|
|
458
458
|
/**
|
|
459
459
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -465,7 +465,7 @@ class Yt {
|
|
|
465
465
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
466
466
|
*/
|
|
467
467
|
dateTime(e, t) {
|
|
468
|
-
return
|
|
468
|
+
return be([this.$locale, e], (r, n) => b(this, R, it).call(this, n, t));
|
|
469
469
|
}
|
|
470
470
|
/**
|
|
471
471
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -477,12 +477,12 @@ class Yt {
|
|
|
477
477
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
478
478
|
*/
|
|
479
479
|
list(e, t) {
|
|
480
|
-
return
|
|
480
|
+
return be([this.$locale, e], (r, n) => b(this, R, ot).call(this, n, t));
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
|
|
483
|
+
Ee = new WeakMap(), I = new WeakMap(), L = new WeakMap(), ke = new WeakMap(), Se = new WeakMap(), Pe = new WeakMap(), xe = new WeakMap(), R = new WeakSet(), Ot = function(e, t, r) {
|
|
484
484
|
var l;
|
|
485
|
-
const n =
|
|
485
|
+
const n = b(this, R, Lt).call(this, t, r);
|
|
486
486
|
if (n) return n;
|
|
487
487
|
const a = s(this, L).get(e);
|
|
488
488
|
if (r.context != null && (t += "_" + r.context), r.count != null)
|
|
@@ -499,38 +499,38 @@ ve = new WeakMap(), V = new WeakMap(), L = new WeakMap(), Ee = new WeakMap(), $e
|
|
|
499
499
|
if (f.type === 0)
|
|
500
500
|
p += f.text;
|
|
501
501
|
else if (f.type === 1) {
|
|
502
|
-
let m =
|
|
502
|
+
let m = rr(r, f.name);
|
|
503
503
|
const g = ((l = r.formatOverrides) == null ? void 0 : l[f.name]) ?? [...f.formats];
|
|
504
504
|
f.name === "count" && g.length === 0 && g.push({ name: "number", options: {} });
|
|
505
505
|
for (const u of g) {
|
|
506
|
-
const y = s(this,
|
|
506
|
+
const y = s(this, Se).get(u.name);
|
|
507
507
|
if (y == null) {
|
|
508
508
|
const k = new Error(
|
|
509
509
|
`Failed to load format '${u.name}' when processing '${t}', template: ${o}`
|
|
510
510
|
);
|
|
511
|
-
throw s(this,
|
|
511
|
+
throw s(this, I).crash(k), k;
|
|
512
512
|
}
|
|
513
513
|
m = y(e, m, u.options);
|
|
514
514
|
}
|
|
515
515
|
p += m;
|
|
516
516
|
}
|
|
517
517
|
return p;
|
|
518
|
-
},
|
|
518
|
+
}, st = function(e, t) {
|
|
519
519
|
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
520
|
-
},
|
|
520
|
+
}, it = function(e, t) {
|
|
521
521
|
return new Intl.DateTimeFormat(this.$locale.get(), t).format(
|
|
522
522
|
typeof e == "string" ? new Date(e) : e
|
|
523
523
|
);
|
|
524
|
-
},
|
|
524
|
+
}, ot = function(e, t) {
|
|
525
525
|
return new Intl.ListFormat(this.$locale.get(), t).format(e);
|
|
526
526
|
}, // relativeTime(): State<string> {
|
|
527
527
|
// }
|
|
528
|
-
|
|
529
|
-
for (const r of s(this,
|
|
530
|
-
if (r[0] === e &&
|
|
528
|
+
Lt = function(e, t) {
|
|
529
|
+
for (const r of s(this, ke))
|
|
530
|
+
if (r[0] === e && Zt(r[1], t))
|
|
531
531
|
return r[2];
|
|
532
532
|
};
|
|
533
|
-
function
|
|
533
|
+
function rr(i, e) {
|
|
534
534
|
const t = String(e).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
535
535
|
let r = i;
|
|
536
536
|
for (; t.length > 0; ) {
|
|
@@ -539,86 +539,91 @@ function Xt(i, e) {
|
|
|
539
539
|
}
|
|
540
540
|
return r;
|
|
541
541
|
}
|
|
542
|
-
var
|
|
543
|
-
class
|
|
542
|
+
var U, he, H, X, Z, ee, Ye, A, Oe, _, lt, Ie;
|
|
543
|
+
class nr {
|
|
544
544
|
constructor(e) {
|
|
545
|
-
h(this,
|
|
546
|
-
h(this,
|
|
547
|
-
h(this,
|
|
548
|
-
//
|
|
545
|
+
h(this, _);
|
|
546
|
+
h(this, U);
|
|
547
|
+
h(this, he);
|
|
548
|
+
// Keys ensure only the most recent callback queued with a certain key
|
|
549
549
|
// will be called, keeping DOM operations to a minimum.
|
|
550
|
-
h(this,
|
|
551
|
-
// All unkeyed
|
|
552
|
-
h(this,
|
|
550
|
+
h(this, H, /* @__PURE__ */ new Map());
|
|
551
|
+
// All unkeyed writes are run on every batch.
|
|
552
|
+
h(this, X, []);
|
|
553
553
|
// All read callbacks are run before updates on every batch.
|
|
554
|
-
h(this,
|
|
555
|
-
h(this,
|
|
556
|
-
|
|
554
|
+
h(this, Z, []);
|
|
555
|
+
h(this, ee, !1);
|
|
556
|
+
// When true, batches that would exceed 16ms will be split and deferred to a rAF.
|
|
557
|
+
// This may not be desirable, because while it does prevent hitching it sometimes leaves
|
|
558
|
+
// the state partially rendered for a brief second and certain elements can be seen to update after the fact.
|
|
559
|
+
// But the tradeoff here is snappier navigation with possibly slightly out of date DOM updates on heavy pages.
|
|
560
|
+
h(this, Ye, !0);
|
|
561
|
+
h(this, A, 0);
|
|
562
|
+
h(this, Oe, new Intl.NumberFormat("en-US", { maximumFractionDigits: 2, minimumFractionDigits: 0 }));
|
|
563
|
+
v(this, U, e), v(this, he, e.createLogger("dolla/render"));
|
|
557
564
|
}
|
|
558
565
|
/**
|
|
559
|
-
* Queues a callback
|
|
560
|
-
* Running your DOM mutations in update callbacks reduces layout thrashing.
|
|
561
|
-
* Returns a Promise that resolves once the callback has run.
|
|
566
|
+
* Queues a callback that runs before the next batch of writes.
|
|
562
567
|
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
t ? s(this, U).set(t, () => {
|
|
566
|
-
e(), r();
|
|
567
|
-
}) : s(this, H).push(() => {
|
|
568
|
-
e(), r();
|
|
569
|
-
}), !s(this, _) && s(this, Y).isMounted && (b(this, _, !0), $(this, ce, Ce).call(this));
|
|
570
|
-
});
|
|
568
|
+
read(e) {
|
|
569
|
+
s(this, U).isMounted && (s(this, Z).push(e), b(this, _, lt).call(this));
|
|
571
570
|
}
|
|
572
571
|
/**
|
|
573
|
-
* Queues a callback
|
|
574
|
-
*
|
|
575
|
-
* Returns a Promise that resolves once the callback has run.
|
|
572
|
+
* Queues a callback to run in the next render batch.
|
|
573
|
+
* Always put DOM mutations in a write callback when possible to help Dolla batch them efficiently.
|
|
576
574
|
*/
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
s(this, le).push(() => {
|
|
580
|
-
e(), t();
|
|
581
|
-
}), !s(this, _) && s(this, Y).isMounted && (b(this, _, !0), $(this, ce, Ce).call(this));
|
|
582
|
-
});
|
|
575
|
+
write(e, t) {
|
|
576
|
+
s(this, U).isMounted && (t ? s(this, H).set(t, e) : s(this, X).push(e), b(this, _, lt).call(this));
|
|
583
577
|
}
|
|
584
578
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
s(this,
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
579
|
+
U = new WeakMap(), he = new WeakMap(), H = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), Ye = new WeakMap(), A = new WeakMap(), Oe = new WeakMap(), _ = new WeakSet(), lt = function() {
|
|
580
|
+
s(this, ee) || (v(this, ee, !0), queueMicrotask(() => {
|
|
581
|
+
b(this, _, Ie).call(this);
|
|
582
|
+
}));
|
|
583
|
+
}, Ie = function() {
|
|
584
|
+
const e = s(this, U).getEnv() === "development";
|
|
585
|
+
s(this, U).isMounted || v(this, ee, !1);
|
|
586
|
+
const t = performance.now();
|
|
587
|
+
let r = 0;
|
|
588
|
+
const n = s(this, Z).length + s(this, H).size + s(this, X).length;
|
|
589
|
+
let a = 0;
|
|
590
|
+
const o = () => (a++, r = performance.now() - t, s(this, Ye) && r > 12 && a < n ? (et(this, A)._++, e && s(this, he).warn(
|
|
591
|
+
`⚠️ Deferring batch to next frame. Performed ${a} of ${n} batched operation${a === 1 ? "" : "s"} in ${s(this, Oe).format(r)}ms (deferral ${s(this, A)}).`
|
|
592
|
+
), requestAnimationFrame(() => {
|
|
593
|
+
b(this, _, Ie).call(this);
|
|
594
|
+
}), !0) : !1), p = [...s(this, H).entries()];
|
|
595
|
+
let l;
|
|
596
|
+
for (; l = s(this, Z).shift(); )
|
|
597
|
+
if (l(), o()) return;
|
|
598
|
+
for (const [f, m] of p)
|
|
599
|
+
if (m(), s(this, H).delete(f), o()) return;
|
|
600
|
+
for (; l = s(this, X).shift(); )
|
|
601
|
+
if (l(), o()) return;
|
|
602
|
+
e && s(this, he)[r > 16 ? "warn" : "info"](
|
|
603
|
+
`${r > 16 ? "⚠️ (>=16ms) " : ""}Executed ${a} operation${a === 1 ? "" : "s"} in ${s(this, Oe).format(r)}ms${s(this, A) > 0 ? ` (after ${s(this, A)} deferral${s(this, A) === 1 ? "" : "s"})` : ""}.`
|
|
604
|
+
), v(this, A, 0), s(this, Z).length || s(this, H).size || s(this, X).length ? queueMicrotask(() => {
|
|
605
|
+
b(this, _, Ie).call(this);
|
|
606
|
+
}) : v(this, ee, !1);
|
|
602
607
|
};
|
|
603
|
-
function
|
|
604
|
-
return
|
|
608
|
+
function me() {
|
|
609
|
+
return me = Object.assign ? Object.assign.bind() : function(i) {
|
|
605
610
|
for (var e = 1; e < arguments.length; e++) {
|
|
606
611
|
var t = arguments[e];
|
|
607
612
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
|
|
608
613
|
}
|
|
609
614
|
return i;
|
|
610
|
-
},
|
|
615
|
+
}, me.apply(null, arguments);
|
|
611
616
|
}
|
|
612
617
|
var T;
|
|
613
618
|
(function(i) {
|
|
614
619
|
i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
|
|
615
620
|
})(T || (T = {}));
|
|
616
|
-
var
|
|
621
|
+
var Be = process.env.NODE_ENV !== "production" ? function(i) {
|
|
617
622
|
return Object.freeze(i);
|
|
618
623
|
} : function(i) {
|
|
619
624
|
return i;
|
|
620
625
|
};
|
|
621
|
-
function
|
|
626
|
+
function Ue(i, e) {
|
|
622
627
|
if (!i) {
|
|
623
628
|
typeof console < "u" && console.warn(e);
|
|
624
629
|
try {
|
|
@@ -627,16 +632,16 @@ function Ve(i, e) {
|
|
|
627
632
|
}
|
|
628
633
|
}
|
|
629
634
|
}
|
|
630
|
-
var
|
|
631
|
-
function
|
|
635
|
+
var Ge = "beforeunload", ar = "hashchange", Rt = "popstate";
|
|
636
|
+
function sr(i) {
|
|
632
637
|
i === void 0 && (i = {});
|
|
633
638
|
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, n = r.history;
|
|
634
639
|
function a() {
|
|
635
|
-
var w = r.location, c = w.pathname, d = w.search,
|
|
636
|
-
return [E.idx,
|
|
640
|
+
var w = r.location, c = w.pathname, d = w.search, $ = w.hash, E = n.state || {};
|
|
641
|
+
return [E.idx, Be({
|
|
637
642
|
pathname: c,
|
|
638
643
|
search: d,
|
|
639
|
-
hash:
|
|
644
|
+
hash: $,
|
|
640
645
|
state: E.usr || null,
|
|
641
646
|
key: E.key || "default"
|
|
642
647
|
})];
|
|
@@ -646,19 +651,19 @@ function tr(i) {
|
|
|
646
651
|
if (o)
|
|
647
652
|
y.call(o), o = null;
|
|
648
653
|
else {
|
|
649
|
-
var w = T.Pop, c = a(), d = c[0],
|
|
654
|
+
var w = T.Pop, c = a(), d = c[0], $ = c[1];
|
|
650
655
|
if (y.length)
|
|
651
656
|
if (d != null) {
|
|
652
657
|
var E = m - d;
|
|
653
658
|
E && (o = {
|
|
654
659
|
action: w,
|
|
655
|
-
location:
|
|
660
|
+
location: $,
|
|
656
661
|
retry: function() {
|
|
657
|
-
|
|
662
|
+
C(E * -1);
|
|
658
663
|
}
|
|
659
|
-
},
|
|
664
|
+
}, C(E));
|
|
660
665
|
} else
|
|
661
|
-
process.env.NODE_ENV !== "production" &&
|
|
666
|
+
process.env.NODE_ENV !== "production" && Ue(
|
|
662
667
|
!1,
|
|
663
668
|
// TODO: Write up a doc that explains our blocking strategy in
|
|
664
669
|
// detail and link to it here so people can understand better what
|
|
@@ -666,42 +671,42 @@ function tr(i) {
|
|
|
666
671
|
"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."
|
|
667
672
|
);
|
|
668
673
|
else
|
|
669
|
-
|
|
674
|
+
ie(w);
|
|
670
675
|
}
|
|
671
676
|
}
|
|
672
|
-
r.addEventListener(
|
|
673
|
-
var l = T.Pop, f = a(), m = f[0], g = f[1], u =
|
|
674
|
-
m == null && (m = 0, n.replaceState(
|
|
677
|
+
r.addEventListener(Rt, p);
|
|
678
|
+
var l = T.Pop, f = a(), m = f[0], g = f[1], u = Ke(), y = Ke();
|
|
679
|
+
m == null && (m = 0, n.replaceState(me({}, n.state, {
|
|
675
680
|
idx: m
|
|
676
681
|
}), ""));
|
|
677
682
|
function k(w) {
|
|
678
|
-
return typeof w == "string" ? w :
|
|
683
|
+
return typeof w == "string" ? w : He(w);
|
|
679
684
|
}
|
|
680
|
-
function
|
|
681
|
-
return c === void 0 && (c = null),
|
|
685
|
+
function ge(w, c) {
|
|
686
|
+
return c === void 0 && (c = null), Be(me({
|
|
682
687
|
pathname: g.pathname,
|
|
683
688
|
hash: "",
|
|
684
689
|
search: ""
|
|
685
|
-
}, typeof w == "string" ?
|
|
690
|
+
}, typeof w == "string" ? ct(w) : w, {
|
|
686
691
|
state: c,
|
|
687
|
-
key:
|
|
692
|
+
key: Dt()
|
|
688
693
|
}));
|
|
689
694
|
}
|
|
690
|
-
function
|
|
695
|
+
function we(w, c) {
|
|
691
696
|
return [{
|
|
692
697
|
usr: w.state,
|
|
693
698
|
key: w.key,
|
|
694
699
|
idx: c
|
|
695
700
|
}, k(w)];
|
|
696
701
|
}
|
|
697
|
-
function
|
|
702
|
+
function ye(w, c, d) {
|
|
698
703
|
return !y.length || (y.call({
|
|
699
704
|
action: w,
|
|
700
705
|
location: c,
|
|
701
706
|
retry: d
|
|
702
707
|
}), !1);
|
|
703
708
|
}
|
|
704
|
-
function
|
|
709
|
+
function ie(w) {
|
|
705
710
|
l = w;
|
|
706
711
|
var c = a();
|
|
707
712
|
m = c[0], g = c[1], u.call({
|
|
@@ -709,35 +714,35 @@ function tr(i) {
|
|
|
709
714
|
location: g
|
|
710
715
|
});
|
|
711
716
|
}
|
|
712
|
-
function
|
|
713
|
-
var d = T.Push,
|
|
717
|
+
function oe(w, c) {
|
|
718
|
+
var d = T.Push, $ = ge(w, c);
|
|
714
719
|
function E() {
|
|
715
|
-
|
|
720
|
+
oe(w, c);
|
|
716
721
|
}
|
|
717
|
-
if (
|
|
718
|
-
var
|
|
722
|
+
if (ye(d, $, E)) {
|
|
723
|
+
var x = we($, m + 1), D = x[0], j = x[1];
|
|
719
724
|
try {
|
|
720
|
-
n.pushState(D, "",
|
|
725
|
+
n.pushState(D, "", j);
|
|
721
726
|
} catch {
|
|
722
|
-
r.location.assign(
|
|
727
|
+
r.location.assign(j);
|
|
723
728
|
}
|
|
724
|
-
|
|
729
|
+
ie(d);
|
|
725
730
|
}
|
|
726
731
|
}
|
|
727
|
-
function
|
|
728
|
-
var d = T.Replace,
|
|
732
|
+
function ve(w, c) {
|
|
733
|
+
var d = T.Replace, $ = ge(w, c);
|
|
729
734
|
function E() {
|
|
730
|
-
|
|
735
|
+
ve(w, c);
|
|
731
736
|
}
|
|
732
|
-
if (
|
|
733
|
-
var
|
|
734
|
-
n.replaceState(D, "",
|
|
737
|
+
if (ye(d, $, E)) {
|
|
738
|
+
var x = we($, m), D = x[0], j = x[1];
|
|
739
|
+
n.replaceState(D, "", j), ie(d);
|
|
735
740
|
}
|
|
736
741
|
}
|
|
737
|
-
function
|
|
742
|
+
function C(w) {
|
|
738
743
|
n.go(w);
|
|
739
744
|
}
|
|
740
|
-
var
|
|
745
|
+
var J = {
|
|
741
746
|
get action() {
|
|
742
747
|
return l;
|
|
743
748
|
},
|
|
@@ -745,36 +750,36 @@ function tr(i) {
|
|
|
745
750
|
return g;
|
|
746
751
|
},
|
|
747
752
|
createHref: k,
|
|
748
|
-
push:
|
|
749
|
-
replace:
|
|
750
|
-
go:
|
|
753
|
+
push: oe,
|
|
754
|
+
replace: ve,
|
|
755
|
+
go: C,
|
|
751
756
|
back: function() {
|
|
752
|
-
|
|
757
|
+
C(-1);
|
|
753
758
|
},
|
|
754
759
|
forward: function() {
|
|
755
|
-
|
|
760
|
+
C(1);
|
|
756
761
|
},
|
|
757
762
|
listen: function(c) {
|
|
758
763
|
return u.push(c);
|
|
759
764
|
},
|
|
760
765
|
block: function(c) {
|
|
761
766
|
var d = y.push(c);
|
|
762
|
-
return y.length === 1 && r.addEventListener(
|
|
763
|
-
d(), y.length || r.removeEventListener(
|
|
767
|
+
return y.length === 1 && r.addEventListener(Ge, ze), function() {
|
|
768
|
+
d(), y.length || r.removeEventListener(Ge, ze);
|
|
764
769
|
};
|
|
765
770
|
}
|
|
766
771
|
};
|
|
767
|
-
return
|
|
772
|
+
return J;
|
|
768
773
|
}
|
|
769
|
-
function
|
|
774
|
+
function ir(i) {
|
|
770
775
|
i === void 0 && (i = {});
|
|
771
776
|
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, n = r.history;
|
|
772
777
|
function a() {
|
|
773
|
-
var c =
|
|
774
|
-
return [q.idx,
|
|
775
|
-
pathname:
|
|
776
|
-
search:
|
|
777
|
-
hash:
|
|
778
|
+
var c = ct(r.location.hash.substr(1)), d = c.pathname, $ = d === void 0 ? "/" : d, E = c.search, x = E === void 0 ? "" : E, D = c.hash, j = D === void 0 ? "" : D, q = n.state || {};
|
|
779
|
+
return [q.idx, Be({
|
|
780
|
+
pathname: $,
|
|
781
|
+
search: x,
|
|
782
|
+
hash: j,
|
|
778
783
|
state: q.usr || null,
|
|
779
784
|
key: q.key || "default"
|
|
780
785
|
})];
|
|
@@ -784,19 +789,19 @@ function rr(i) {
|
|
|
784
789
|
if (o)
|
|
785
790
|
y.call(o), o = null;
|
|
786
791
|
else {
|
|
787
|
-
var c = T.Pop, d = a(),
|
|
792
|
+
var c = T.Pop, d = a(), $ = d[0], E = d[1];
|
|
788
793
|
if (y.length)
|
|
789
|
-
if (
|
|
790
|
-
var
|
|
791
|
-
|
|
794
|
+
if ($ != null) {
|
|
795
|
+
var x = m - $;
|
|
796
|
+
x && (o = {
|
|
792
797
|
action: c,
|
|
793
798
|
location: E,
|
|
794
799
|
retry: function() {
|
|
795
|
-
|
|
800
|
+
J(x * -1);
|
|
796
801
|
}
|
|
797
|
-
},
|
|
802
|
+
}, J(x));
|
|
798
803
|
} else
|
|
799
|
-
process.env.NODE_ENV !== "production" &&
|
|
804
|
+
process.env.NODE_ENV !== "production" && Ue(
|
|
800
805
|
!1,
|
|
801
806
|
// TODO: Write up a doc that explains our blocking strategy in
|
|
802
807
|
// detail and link to it here so people can understand better
|
|
@@ -804,53 +809,53 @@ function rr(i) {
|
|
|
804
809
|
"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."
|
|
805
810
|
);
|
|
806
811
|
else
|
|
807
|
-
|
|
812
|
+
oe(c);
|
|
808
813
|
}
|
|
809
814
|
}
|
|
810
|
-
r.addEventListener(
|
|
815
|
+
r.addEventListener(Rt, p), r.addEventListener(ar, function() {
|
|
811
816
|
var c = a(), d = c[1];
|
|
812
|
-
|
|
817
|
+
He(d) !== He(g) && p();
|
|
813
818
|
});
|
|
814
|
-
var l = T.Pop, f = a(), m = f[0], g = f[1], u =
|
|
815
|
-
m == null && (m = 0, n.replaceState(
|
|
819
|
+
var l = T.Pop, f = a(), m = f[0], g = f[1], u = Ke(), y = Ke();
|
|
820
|
+
m == null && (m = 0, n.replaceState(me({}, n.state, {
|
|
816
821
|
idx: m
|
|
817
822
|
}), ""));
|
|
818
823
|
function k() {
|
|
819
824
|
var c = document.querySelector("base"), d = "";
|
|
820
825
|
if (c && c.getAttribute("href")) {
|
|
821
|
-
var
|
|
822
|
-
d = E === -1 ?
|
|
826
|
+
var $ = r.location.href, E = $.indexOf("#");
|
|
827
|
+
d = E === -1 ? $ : $.slice(0, E);
|
|
823
828
|
}
|
|
824
829
|
return d;
|
|
825
830
|
}
|
|
826
|
-
function
|
|
827
|
-
return k() + "#" + (typeof c == "string" ? c :
|
|
831
|
+
function ge(c) {
|
|
832
|
+
return k() + "#" + (typeof c == "string" ? c : He(c));
|
|
828
833
|
}
|
|
829
|
-
function
|
|
830
|
-
return d === void 0 && (d = null),
|
|
834
|
+
function we(c, d) {
|
|
835
|
+
return d === void 0 && (d = null), Be(me({
|
|
831
836
|
pathname: g.pathname,
|
|
832
837
|
hash: "",
|
|
833
838
|
search: ""
|
|
834
|
-
}, typeof c == "string" ?
|
|
839
|
+
}, typeof c == "string" ? ct(c) : c, {
|
|
835
840
|
state: d,
|
|
836
|
-
key:
|
|
841
|
+
key: Dt()
|
|
837
842
|
}));
|
|
838
843
|
}
|
|
839
|
-
function
|
|
844
|
+
function ye(c, d) {
|
|
840
845
|
return [{
|
|
841
846
|
usr: c.state,
|
|
842
847
|
key: c.key,
|
|
843
848
|
idx: d
|
|
844
|
-
},
|
|
849
|
+
}, ge(c)];
|
|
845
850
|
}
|
|
846
|
-
function
|
|
851
|
+
function ie(c, d, $) {
|
|
847
852
|
return !y.length || (y.call({
|
|
848
853
|
action: c,
|
|
849
854
|
location: d,
|
|
850
|
-
retry:
|
|
855
|
+
retry: $
|
|
851
856
|
}), !1);
|
|
852
857
|
}
|
|
853
|
-
function
|
|
858
|
+
function oe(c) {
|
|
854
859
|
l = c;
|
|
855
860
|
var d = a();
|
|
856
861
|
m = d[0], g = d[1], u.call({
|
|
@@ -858,32 +863,32 @@ function rr(i) {
|
|
|
858
863
|
location: g
|
|
859
864
|
});
|
|
860
865
|
}
|
|
861
|
-
function
|
|
862
|
-
var
|
|
863
|
-
function
|
|
864
|
-
|
|
866
|
+
function ve(c, d) {
|
|
867
|
+
var $ = T.Push, E = we(c, d);
|
|
868
|
+
function x() {
|
|
869
|
+
ve(c, d);
|
|
865
870
|
}
|
|
866
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
867
|
-
var D =
|
|
871
|
+
if (process.env.NODE_ENV !== "production" && Ue(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ie($, E, x)) {
|
|
872
|
+
var D = ye(E, m + 1), j = D[0], q = D[1];
|
|
868
873
|
try {
|
|
869
|
-
n.pushState(
|
|
874
|
+
n.pushState(j, "", q);
|
|
870
875
|
} catch {
|
|
871
876
|
r.location.assign(q);
|
|
872
877
|
}
|
|
873
|
-
|
|
878
|
+
oe($);
|
|
874
879
|
}
|
|
875
880
|
}
|
|
876
|
-
function
|
|
877
|
-
var
|
|
878
|
-
function
|
|
879
|
-
|
|
881
|
+
function C(c, d) {
|
|
882
|
+
var $ = T.Replace, E = we(c, d);
|
|
883
|
+
function x() {
|
|
884
|
+
C(c, d);
|
|
880
885
|
}
|
|
881
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
882
|
-
var D =
|
|
883
|
-
n.replaceState(
|
|
886
|
+
if (process.env.NODE_ENV !== "production" && Ue(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ie($, E, x)) {
|
|
887
|
+
var D = ye(E, m), j = D[0], q = D[1];
|
|
888
|
+
n.replaceState(j, "", q), oe($);
|
|
884
889
|
}
|
|
885
890
|
}
|
|
886
|
-
function
|
|
891
|
+
function J(c) {
|
|
887
892
|
n.go(c);
|
|
888
893
|
}
|
|
889
894
|
var w = {
|
|
@@ -893,32 +898,32 @@ function rr(i) {
|
|
|
893
898
|
get location() {
|
|
894
899
|
return g;
|
|
895
900
|
},
|
|
896
|
-
createHref:
|
|
897
|
-
push:
|
|
898
|
-
replace:
|
|
899
|
-
go:
|
|
901
|
+
createHref: ge,
|
|
902
|
+
push: ve,
|
|
903
|
+
replace: C,
|
|
904
|
+
go: J,
|
|
900
905
|
back: function() {
|
|
901
|
-
|
|
906
|
+
J(-1);
|
|
902
907
|
},
|
|
903
908
|
forward: function() {
|
|
904
|
-
|
|
909
|
+
J(1);
|
|
905
910
|
},
|
|
906
911
|
listen: function(d) {
|
|
907
912
|
return u.push(d);
|
|
908
913
|
},
|
|
909
914
|
block: function(d) {
|
|
910
|
-
var
|
|
911
|
-
return y.length === 1 && r.addEventListener(
|
|
912
|
-
|
|
915
|
+
var $ = y.push(d);
|
|
916
|
+
return y.length === 1 && r.addEventListener(Ge, ze), function() {
|
|
917
|
+
$(), y.length || r.removeEventListener(Ge, ze);
|
|
913
918
|
};
|
|
914
919
|
}
|
|
915
920
|
};
|
|
916
921
|
return w;
|
|
917
922
|
}
|
|
918
|
-
function
|
|
923
|
+
function ze(i) {
|
|
919
924
|
i.preventDefault(), i.returnValue = "";
|
|
920
925
|
}
|
|
921
|
-
function
|
|
926
|
+
function Ke() {
|
|
922
927
|
var i = [];
|
|
923
928
|
return {
|
|
924
929
|
get length() {
|
|
@@ -938,14 +943,14 @@ function Be() {
|
|
|
938
943
|
}
|
|
939
944
|
};
|
|
940
945
|
}
|
|
941
|
-
function
|
|
946
|
+
function Dt() {
|
|
942
947
|
return Math.random().toString(36).substr(2, 8);
|
|
943
948
|
}
|
|
944
|
-
function
|
|
949
|
+
function He(i) {
|
|
945
950
|
var e = i.pathname, t = e === void 0 ? "/" : e, r = i.search, n = r === void 0 ? "" : r, a = i.hash, o = a === void 0 ? "" : a;
|
|
946
951
|
return n && n !== "?" && (t += n.charAt(0) === "?" ? n : "?" + n), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
|
|
947
952
|
}
|
|
948
|
-
function
|
|
953
|
+
function ct(i) {
|
|
949
954
|
var e = {};
|
|
950
955
|
if (i) {
|
|
951
956
|
var t = i.indexOf("#");
|
|
@@ -955,26 +960,26 @@ function at(i) {
|
|
|
955
960
|
}
|
|
956
961
|
return e;
|
|
957
962
|
}
|
|
958
|
-
function
|
|
959
|
-
return
|
|
963
|
+
function $e(i) {
|
|
964
|
+
return St(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
960
965
|
}
|
|
961
|
-
function
|
|
966
|
+
function le(i) {
|
|
962
967
|
var t;
|
|
963
|
-
|
|
964
|
-
(r) =>
|
|
968
|
+
qt(
|
|
969
|
+
(r) => dt(r == null ? void 0 : r.toString),
|
|
965
970
|
i,
|
|
966
971
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
967
972
|
), i = i.filter((r) => r).flatMap(String);
|
|
968
973
|
let e = (t = i.shift()) == null ? void 0 : t.toString();
|
|
969
974
|
if (e) {
|
|
970
975
|
for (const r of i.map((n) => n.toString()))
|
|
971
|
-
r.startsWith(".") ? e =
|
|
976
|
+
r.startsWith(".") ? e = We(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
|
|
972
977
|
e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
|
|
973
978
|
}
|
|
974
979
|
return e ?? "";
|
|
975
980
|
}
|
|
976
|
-
function
|
|
977
|
-
if (
|
|
981
|
+
function We(i, e) {
|
|
982
|
+
if (St(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
|
|
978
983
|
return e;
|
|
979
984
|
let t = i;
|
|
980
985
|
for (; ; )
|
|
@@ -988,9 +993,9 @@ function He(i, e) {
|
|
|
988
993
|
e = e.replace(/^\.\/?/, "");
|
|
989
994
|
else
|
|
990
995
|
break;
|
|
991
|
-
return
|
|
996
|
+
return le([t, e]);
|
|
992
997
|
}
|
|
993
|
-
function
|
|
998
|
+
function ut(i) {
|
|
994
999
|
if (!i) return {};
|
|
995
1000
|
i.startsWith("?") && (i = i.slice(1));
|
|
996
1001
|
const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
|
|
@@ -999,9 +1004,9 @@ function st(i) {
|
|
|
999
1004
|
});
|
|
1000
1005
|
return Object.fromEntries(e);
|
|
1001
1006
|
}
|
|
1002
|
-
function
|
|
1007
|
+
function $t(i, e, t = {}) {
|
|
1003
1008
|
var o;
|
|
1004
|
-
const [r, n] = e.split("?"), a =
|
|
1009
|
+
const [r, n] = e.split("?"), a = $e(r);
|
|
1005
1010
|
e: for (const p of i) {
|
|
1006
1011
|
const { fragments: l } = p;
|
|
1007
1012
|
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== a.length || t.willMatch && !t.willMatch(p))
|
|
@@ -1040,12 +1045,12 @@ function wt(i, e, t = {}) {
|
|
|
1040
1045
|
path: "/" + m.map((u) => u.value).join("/"),
|
|
1041
1046
|
pattern: "/" + l.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
|
|
1042
1047
|
params: g,
|
|
1043
|
-
query:
|
|
1048
|
+
query: ut(n),
|
|
1044
1049
|
meta: p.meta
|
|
1045
1050
|
};
|
|
1046
1051
|
}
|
|
1047
1052
|
}
|
|
1048
|
-
function
|
|
1053
|
+
function or(i) {
|
|
1049
1054
|
const e = [], t = [], r = [], n = [];
|
|
1050
1055
|
for (const o of i) {
|
|
1051
1056
|
const { fragments: p } = o;
|
|
@@ -1063,8 +1068,8 @@ function nr(i) {
|
|
|
1063
1068
|
const a = (o, p) => o.fragments.length > p.fragments.length ? -1 : 1;
|
|
1064
1069
|
return e.sort(a), t.sort(a), r.sort(a), n.sort(a), [...e, ...t, ...r, ...n];
|
|
1065
1070
|
}
|
|
1066
|
-
function
|
|
1067
|
-
const e =
|
|
1071
|
+
function lr(i) {
|
|
1072
|
+
const e = $e(i), t = [];
|
|
1068
1073
|
for (let r = 0; r < e.length; r++) {
|
|
1069
1074
|
const n = e[r];
|
|
1070
1075
|
if (n === "*") {
|
|
@@ -1087,7 +1092,7 @@ function ar(i) {
|
|
|
1087
1092
|
}
|
|
1088
1093
|
return t;
|
|
1089
1094
|
}
|
|
1090
|
-
const
|
|
1095
|
+
const Et = (i, e) => {
|
|
1091
1096
|
if (Object.keys(i).length !== Object.keys(e).length)
|
|
1092
1097
|
return !1;
|
|
1093
1098
|
for (const t in i)
|
|
@@ -1095,87 +1100,87 @@ const yt = (i, e) => {
|
|
|
1095
1100
|
return !1;
|
|
1096
1101
|
return !0;
|
|
1097
1102
|
};
|
|
1098
|
-
var
|
|
1099
|
-
class
|
|
1103
|
+
var Le, N, te, Re, S, Xe, W, De, re, ne, fe, de, pe, Ne, Q, ht, ft;
|
|
1104
|
+
class cr {
|
|
1100
1105
|
constructor(e, t) {
|
|
1101
|
-
h(this,
|
|
1102
|
-
h(this, Oe);
|
|
1103
|
-
h(this, N);
|
|
1104
|
-
h(this, X);
|
|
1105
|
-
h(this, xe, Ze());
|
|
1106
|
-
h(this, P);
|
|
1107
|
-
h(this, Qe, 0);
|
|
1108
|
-
h(this, I, []);
|
|
1106
|
+
h(this, Q);
|
|
1109
1107
|
h(this, Le);
|
|
1110
|
-
h(this,
|
|
1108
|
+
h(this, N);
|
|
1109
|
+
h(this, te);
|
|
1110
|
+
h(this, Re, nt());
|
|
1111
|
+
h(this, S);
|
|
1112
|
+
h(this, Xe, 0);
|
|
1113
|
+
h(this, W, []);
|
|
1114
|
+
h(this, De);
|
|
1115
|
+
h(this, re, []);
|
|
1111
1116
|
// Callbacks that need to be called on unmount.
|
|
1112
|
-
h(this,
|
|
1117
|
+
h(this, ne, []);
|
|
1113
1118
|
/**
|
|
1114
1119
|
* The currently matched route pattern, if any.
|
|
1115
1120
|
*/
|
|
1116
|
-
|
|
1117
|
-
h(this,
|
|
1121
|
+
P(this, "$pattern");
|
|
1122
|
+
h(this, fe);
|
|
1118
1123
|
/**
|
|
1119
1124
|
* The current URL path.
|
|
1120
1125
|
*/
|
|
1121
|
-
|
|
1122
|
-
h(this,
|
|
1126
|
+
P(this, "$path");
|
|
1127
|
+
h(this, de);
|
|
1123
1128
|
/**
|
|
1124
1129
|
* The current named path params.
|
|
1125
1130
|
*/
|
|
1126
|
-
|
|
1127
|
-
h(this,
|
|
1131
|
+
P(this, "$params");
|
|
1132
|
+
h(this, pe);
|
|
1128
1133
|
/**
|
|
1129
1134
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
1130
1135
|
*/
|
|
1131
|
-
|
|
1132
|
-
h(this,
|
|
1133
|
-
|
|
1134
|
-
const [r, n] =
|
|
1135
|
-
|
|
1136
|
-
{ equals:
|
|
1136
|
+
P(this, "$query");
|
|
1137
|
+
h(this, Ne);
|
|
1138
|
+
v(this, Le, e), v(this, N, e.createLogger("dolla/router")), v(this, te, t);
|
|
1139
|
+
const [r, n] = ce(null), [a, o] = ce(""), [p, l] = ce({}, { equals: Et }), [f, m] = ce(
|
|
1140
|
+
ut(typeof window > "u" ? "" : window.location.search ?? ""),
|
|
1141
|
+
{ equals: Et }
|
|
1137
1142
|
);
|
|
1138
|
-
this.$pattern = r,
|
|
1139
|
-
s(this,
|
|
1143
|
+
this.$pattern = r, v(this, fe, n), this.$path = a, v(this, de, o), this.$params = p, v(this, pe, l), this.$query = f, v(this, Ne, m), e.beforeMount(() => {
|
|
1144
|
+
s(this, S) != null && (s(this, Re).watch([f], (g) => {
|
|
1140
1145
|
const u = new URLSearchParams();
|
|
1141
1146
|
for (const k in g)
|
|
1142
1147
|
u.set(k, String(g[k]));
|
|
1143
1148
|
const y = "?" + u.toString();
|
|
1144
|
-
y != s(this,
|
|
1145
|
-
pathname: s(this,
|
|
1149
|
+
y != s(this, S).location.search && s(this, S).replace({
|
|
1150
|
+
pathname: s(this, S).location.pathname,
|
|
1146
1151
|
search: y
|
|
1147
1152
|
});
|
|
1148
|
-
}), s(this,
|
|
1149
|
-
|
|
1153
|
+
}), s(this, ne).push(s(this, S).listen(b(this, Q, ft).bind(this))), b(this, Q, ft).call(this, s(this, S)), s(this, ne).push(
|
|
1154
|
+
fr(s(this, te).rootElement, (g) => {
|
|
1150
1155
|
let u = g.getAttribute("href");
|
|
1151
|
-
s(this, N).info("Intercepted link click", g, u), /^https?:\/\/|^\//.test(u) || (u =
|
|
1156
|
+
s(this, N).info("Intercepted link click", g, u), /^https?:\/\/|^\//.test(u) || (u = le([s(this, S).location.pathname, u])), s(this, S).push(u);
|
|
1152
1157
|
})
|
|
1153
|
-
), s(this, N).info("Intercepting <a> clicks within root element:", s(this,
|
|
1158
|
+
), s(this, N).info("Intercepting <a> clicks within root element:", s(this, te).rootElement));
|
|
1154
1159
|
}), e.onUnmount(() => {
|
|
1155
|
-
for (; s(this,
|
|
1156
|
-
s(this,
|
|
1157
|
-
s(this,
|
|
1160
|
+
for (; s(this, ne).length > 0; )
|
|
1161
|
+
s(this, ne).pop()();
|
|
1162
|
+
s(this, Re).stopAll();
|
|
1158
1163
|
});
|
|
1159
1164
|
}
|
|
1160
1165
|
setup(e) {
|
|
1161
|
-
if (s(this,
|
|
1166
|
+
if (s(this, Le).isMounted) {
|
|
1162
1167
|
s(this, N).crash(
|
|
1163
1168
|
new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
|
|
1164
1169
|
);
|
|
1165
1170
|
return;
|
|
1166
1171
|
}
|
|
1167
|
-
e.style === "hash" ?
|
|
1168
|
-
e.routes.flatMap((t) =>
|
|
1172
|
+
e.style === "hash" ? v(this, S, ir()) : v(this, S, sr()), v(this, re, or(
|
|
1173
|
+
e.routes.flatMap((t) => b(this, Q, ht).call(this, t)).map((t) => ({
|
|
1169
1174
|
pattern: t.pattern,
|
|
1170
1175
|
meta: t.meta,
|
|
1171
|
-
fragments:
|
|
1176
|
+
fragments: lr(t.pattern)
|
|
1172
1177
|
}))
|
|
1173
1178
|
));
|
|
1174
|
-
for (const t of s(this,
|
|
1179
|
+
for (const t of s(this, re))
|
|
1175
1180
|
if (t.meta.redirect) {
|
|
1176
1181
|
let r;
|
|
1177
|
-
if (!
|
|
1178
|
-
if (r = t.meta.redirect,
|
|
1182
|
+
if (!dt(t.meta.redirect)) if (V(t.meta.redirect)) {
|
|
1183
|
+
if (r = t.meta.redirect, !$t(s(this, re), r, {
|
|
1179
1184
|
willMatch(a) {
|
|
1180
1185
|
return a !== t;
|
|
1181
1186
|
}
|
|
@@ -1195,7 +1200,7 @@ class sr {
|
|
|
1195
1200
|
* Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
1196
1201
|
*/
|
|
1197
1202
|
go(e, t = {}) {
|
|
1198
|
-
if (s(this,
|
|
1203
|
+
if (s(this, S) == null) {
|
|
1199
1204
|
s(this, N).crash(
|
|
1200
1205
|
new Error(
|
|
1201
1206
|
"Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1204,13 +1209,13 @@ class sr {
|
|
|
1204
1209
|
return;
|
|
1205
1210
|
}
|
|
1206
1211
|
let r;
|
|
1207
|
-
Array.isArray(e) ? r =
|
|
1212
|
+
Array.isArray(e) ? r = le(e) : r = e.toString(), r = We(s(this, S).location.pathname, r), t.preserveQuery && (r += s(this, S).location.search), t.replace ? s(this, S).replace(r) : s(this, S).push(r);
|
|
1208
1213
|
}
|
|
1209
1214
|
/**
|
|
1210
1215
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
1211
1216
|
*/
|
|
1212
1217
|
back(e = 1) {
|
|
1213
|
-
if (s(this,
|
|
1218
|
+
if (s(this, S) == null) {
|
|
1214
1219
|
s(this, N).crash(
|
|
1215
1220
|
new Error(
|
|
1216
1221
|
"Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1218,13 +1223,13 @@ class sr {
|
|
|
1218
1223
|
);
|
|
1219
1224
|
return;
|
|
1220
1225
|
}
|
|
1221
|
-
s(this,
|
|
1226
|
+
s(this, S).go(-e);
|
|
1222
1227
|
}
|
|
1223
1228
|
/**
|
|
1224
1229
|
* Navigate forward. Pass a number of steps to hit the forward button that many times.
|
|
1225
1230
|
*/
|
|
1226
1231
|
forward(e = 1) {
|
|
1227
|
-
if (s(this,
|
|
1232
|
+
if (s(this, S) == null) {
|
|
1228
1233
|
s(this, N).crash(
|
|
1229
1234
|
new Error(
|
|
1230
1235
|
"Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1232,16 +1237,16 @@ class sr {
|
|
|
1232
1237
|
);
|
|
1233
1238
|
return;
|
|
1234
1239
|
}
|
|
1235
|
-
s(this,
|
|
1240
|
+
s(this, S).go(e);
|
|
1236
1241
|
}
|
|
1237
1242
|
}
|
|
1238
|
-
|
|
1243
|
+
Le = new WeakMap(), N = new WeakMap(), te = new WeakMap(), Re = new WeakMap(), S = new WeakMap(), Xe = new WeakMap(), W = new WeakMap(), De = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), fe = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), Ne = new WeakMap(), Q = new WeakSet(), /**
|
|
1239
1244
|
* Parses a route definition object into a set of matchable routes.
|
|
1240
1245
|
*
|
|
1241
1246
|
* @param route - Route config object.
|
|
1242
1247
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
1243
1248
|
*/
|
|
1244
|
-
|
|
1249
|
+
ht = function(e, t = [], r = []) {
|
|
1245
1250
|
if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
|
|
1246
1251
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
|
|
1247
1252
|
if (e.redirect && e.routes)
|
|
@@ -1252,30 +1257,30 @@ it = function(e, t = [], r = []) {
|
|
|
1252
1257
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
1253
1258
|
let n = [];
|
|
1254
1259
|
for (const l of t)
|
|
1255
|
-
n.push(
|
|
1256
|
-
n.push(
|
|
1260
|
+
n.push(...$e(l.path));
|
|
1261
|
+
n.push(...$e(e.path)), n[n.length - 1] === "*" && n.pop();
|
|
1257
1262
|
const a = [];
|
|
1258
1263
|
if (e.redirect) {
|
|
1259
1264
|
let l = e.redirect;
|
|
1260
|
-
return
|
|
1261
|
-
pattern: "/" +
|
|
1265
|
+
return V(l) && (l = We(le(n), l), l.startsWith("/") || (l = "/" + l)), a.push({
|
|
1266
|
+
pattern: "/" + le([...n, ...$e(e.path)]),
|
|
1262
1267
|
meta: {
|
|
1263
1268
|
redirect: l
|
|
1264
1269
|
}
|
|
1265
1270
|
}), a;
|
|
1266
1271
|
}
|
|
1267
|
-
let o =
|
|
1272
|
+
let o = Pt;
|
|
1268
1273
|
if (typeof e.view == "function")
|
|
1269
1274
|
o = e.view;
|
|
1270
1275
|
else if (e.view)
|
|
1271
1276
|
throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
|
|
1272
|
-
const p = { id:
|
|
1277
|
+
const p = { id: et(this, Xe)._++, view: o };
|
|
1273
1278
|
if (e.routes)
|
|
1274
1279
|
for (const l of e.routes)
|
|
1275
|
-
a.push(
|
|
1280
|
+
a.push(...b(this, Q, ht).call(this, l, [...t, e], [...r, p]));
|
|
1276
1281
|
else
|
|
1277
1282
|
a.push({
|
|
1278
|
-
pattern: parent ?
|
|
1283
|
+
pattern: parent ? le([...t.map((l) => l.path), e.path]) : e.path,
|
|
1279
1284
|
meta: {
|
|
1280
1285
|
pattern: e.path,
|
|
1281
1286
|
layers: [...r, p],
|
|
@@ -1283,11 +1288,11 @@ it = function(e, t = [], r = []) {
|
|
|
1283
1288
|
}
|
|
1284
1289
|
});
|
|
1285
1290
|
return a;
|
|
1286
|
-
},
|
|
1287
|
-
e.search !== s(this,
|
|
1288
|
-
const t =
|
|
1291
|
+
}, ft = async function({ location: e }) {
|
|
1292
|
+
e.search !== s(this, De) && (v(this, De, e.search), s(this, Ne).call(this, ut(e.search)));
|
|
1293
|
+
const t = $t(s(this, re), e.pathname);
|
|
1289
1294
|
if (!t) {
|
|
1290
|
-
s(this,
|
|
1295
|
+
s(this, fe).call(this, null), s(this, de).call(this, e.pathname), s(this, pe).call(this, {
|
|
1291
1296
|
wildcard: e.pathname
|
|
1292
1297
|
});
|
|
1293
1298
|
return;
|
|
@@ -1299,8 +1304,8 @@ it = function(e, t = [], r = []) {
|
|
|
1299
1304
|
}
|
|
1300
1305
|
}), t.meta.redirect != null)
|
|
1301
1306
|
if (typeof t.meta.redirect == "string") {
|
|
1302
|
-
const r =
|
|
1303
|
-
s(this, N).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this,
|
|
1307
|
+
const r = dr(t.meta.redirect, t.params);
|
|
1308
|
+
s(this, N).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, S).replace(r);
|
|
1304
1309
|
} else if (typeof t.meta.redirect == "function") {
|
|
1305
1310
|
const r = {
|
|
1306
1311
|
path: t.path,
|
|
@@ -1311,26 +1316,26 @@ it = function(e, t = [], r = []) {
|
|
|
1311
1316
|
let n = await t.meta.redirect(r);
|
|
1312
1317
|
if (typeof n != "string")
|
|
1313
1318
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
1314
|
-
n.startsWith("/") || (n =
|
|
1319
|
+
n.startsWith("/") || (n = We(t.path, n)), s(this, N).info(`Redirecting to: '${n}'`), s(this, S).replace(n);
|
|
1315
1320
|
} else
|
|
1316
1321
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
1317
|
-
else if (s(this, N).info(`📍 navigating to '${t.path}'`), s(this,
|
|
1318
|
-
s(this,
|
|
1322
|
+
else if (s(this, N).info(`📍 navigating to '${t.path}'`), s(this, de).call(this, t.path), s(this, pe).call(this, t.params), t.pattern !== this.$pattern.get()) {
|
|
1323
|
+
s(this, fe).call(this, t.pattern);
|
|
1319
1324
|
const r = t.meta.layers;
|
|
1320
1325
|
for (let n = 0; n < r.length; n++) {
|
|
1321
|
-
const a = r[n], o = s(this,
|
|
1326
|
+
const a = r[n], o = s(this, W)[n];
|
|
1322
1327
|
if ((o == null ? void 0 : o.id) !== a.id) {
|
|
1323
|
-
|
|
1324
|
-
const p = s(this,
|
|
1328
|
+
v(this, W, s(this, W).slice(0, n));
|
|
1329
|
+
const p = s(this, W).at(-1);
|
|
1325
1330
|
o && o.node.isMounted && o.node.unmount();
|
|
1326
1331
|
let l;
|
|
1327
|
-
p ? l = p.node.setChildView(a.view) : l = s(this,
|
|
1332
|
+
p ? l = p.node.setChildView(a.view) : l = s(this, te).rootView.setChildView(a.view), s(this, W).push({ id: a.id, node: l });
|
|
1328
1333
|
}
|
|
1329
1334
|
}
|
|
1330
1335
|
}
|
|
1331
1336
|
};
|
|
1332
|
-
const
|
|
1333
|
-
function
|
|
1337
|
+
const ur = /(noopener|noreferrer) (noopener|noreferrer)/, hr = /^[\w-_]+:/;
|
|
1338
|
+
function fr(i, e, t = window) {
|
|
1334
1339
|
function r(a) {
|
|
1335
1340
|
return !a || a === i ? null : a.localName !== "a" || a.href === void 0 ? r(a.parentNode) : a;
|
|
1336
1341
|
}
|
|
@@ -1338,64 +1343,64 @@ function lr(i, e, t = window) {
|
|
|
1338
1343
|
if (a.button && a.button !== 0 || a.ctrlKey || a.metaKey || a.altKey || a.shiftKey || a.defaultPrevented)
|
|
1339
1344
|
return;
|
|
1340
1345
|
const o = r(a.target);
|
|
1341
|
-
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" &&
|
|
1346
|
+
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" && ur.test(o.getAttribute("rel")) || hr.test(o.getAttribute("href")) || (a.preventDefault(), e(o)));
|
|
1342
1347
|
}
|
|
1343
1348
|
return i.addEventListener("click", n), function() {
|
|
1344
1349
|
i.removeEventListener("click", n);
|
|
1345
1350
|
};
|
|
1346
1351
|
}
|
|
1347
|
-
function
|
|
1352
|
+
function dr(i, e) {
|
|
1348
1353
|
for (const t in e) {
|
|
1349
1354
|
const r = e[t].toString();
|
|
1350
1355
|
i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
|
|
1351
1356
|
}
|
|
1352
1357
|
return i;
|
|
1353
1358
|
}
|
|
1354
|
-
var
|
|
1355
|
-
class
|
|
1359
|
+
var B, Me, G, ae, je, Te, qe, Fe, Ae, _e, z, O, K;
|
|
1360
|
+
class pr {
|
|
1356
1361
|
constructor() {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
h(this,
|
|
1362
|
-
h(this,
|
|
1362
|
+
P(this, "http");
|
|
1363
|
+
P(this, "i18n");
|
|
1364
|
+
P(this, "render");
|
|
1365
|
+
P(this, "router");
|
|
1366
|
+
h(this, B, !1);
|
|
1367
|
+
h(this, Me, "production");
|
|
1363
1368
|
h(this, G);
|
|
1364
|
-
h(this,
|
|
1365
|
-
h(this,
|
|
1366
|
-
h(this,
|
|
1367
|
-
h(this, Me, []);
|
|
1368
|
-
h(this, Te, []);
|
|
1369
|
+
h(this, ae);
|
|
1370
|
+
h(this, je, Gt);
|
|
1371
|
+
h(this, Te, nt());
|
|
1369
1372
|
h(this, qe, []);
|
|
1373
|
+
h(this, Fe, []);
|
|
1370
1374
|
h(this, Ae, []);
|
|
1371
|
-
h(this,
|
|
1375
|
+
h(this, _e, []);
|
|
1376
|
+
h(this, z, {
|
|
1372
1377
|
root: this,
|
|
1373
1378
|
data: {}
|
|
1374
1379
|
});
|
|
1375
|
-
h(this,
|
|
1380
|
+
h(this, O, {
|
|
1376
1381
|
info: "development",
|
|
1377
1382
|
log: "development",
|
|
1378
1383
|
warn: "development",
|
|
1379
1384
|
error: !0
|
|
1380
1385
|
});
|
|
1381
|
-
h(this,
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1386
|
+
h(this, K, wt("*,-dolla/*"));
|
|
1387
|
+
P(this, "watch", s(this, Te).watch);
|
|
1388
|
+
P(this, "createState", ce);
|
|
1389
|
+
P(this, "createSettableState", Ft);
|
|
1390
|
+
P(this, "toSettableState", At);
|
|
1391
|
+
P(this, "toState", _t);
|
|
1392
|
+
P(this, "valueOf", Ct);
|
|
1393
|
+
P(this, "derive", be);
|
|
1394
|
+
P(this, "createWatcher", nt);
|
|
1395
|
+
P(this, "createRef", Vt);
|
|
1396
|
+
P(this, "isRef", It);
|
|
1392
1397
|
const e = this;
|
|
1393
|
-
this.http = new
|
|
1398
|
+
this.http = new zt(), this.i18n = new tr(this), this.render = new nr(this), this.router = new cr(this, {
|
|
1394
1399
|
get rootElement() {
|
|
1395
1400
|
return s(e, G);
|
|
1396
1401
|
},
|
|
1397
1402
|
get rootView() {
|
|
1398
|
-
return s(e,
|
|
1403
|
+
return s(e, ae);
|
|
1399
1404
|
}
|
|
1400
1405
|
});
|
|
1401
1406
|
}
|
|
@@ -1403,65 +1408,65 @@ class ur {
|
|
|
1403
1408
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
1404
1409
|
*/
|
|
1405
1410
|
get isMounted() {
|
|
1406
|
-
return s(this,
|
|
1411
|
+
return s(this, B);
|
|
1407
1412
|
}
|
|
1408
1413
|
/**
|
|
1409
1414
|
* Get the current environment that this app is running in.
|
|
1410
1415
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1411
1416
|
*/
|
|
1412
1417
|
getEnv() {
|
|
1413
|
-
return s(this,
|
|
1418
|
+
return s(this, Me);
|
|
1414
1419
|
}
|
|
1415
1420
|
/**
|
|
1416
1421
|
* Sets the environment that this app is running in.
|
|
1417
1422
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1418
1423
|
*/
|
|
1419
1424
|
setEnv(e) {
|
|
1420
|
-
|
|
1425
|
+
v(this, Me, e);
|
|
1421
1426
|
}
|
|
1422
1427
|
/**
|
|
1423
1428
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
1424
1429
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
1425
1430
|
*/
|
|
1426
1431
|
setCrashView(e) {
|
|
1427
|
-
|
|
1432
|
+
v(this, je, e);
|
|
1428
1433
|
}
|
|
1429
1434
|
/**
|
|
1430
1435
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
1431
1436
|
*/
|
|
1432
1437
|
set(e, t) {
|
|
1433
|
-
return s(this,
|
|
1438
|
+
return s(this, z).data[e] = t, t;
|
|
1434
1439
|
}
|
|
1435
1440
|
/**
|
|
1436
1441
|
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
1437
1442
|
*/
|
|
1438
1443
|
get(e) {
|
|
1439
|
-
return s(this,
|
|
1444
|
+
return s(this, z).data[e] ?? null;
|
|
1440
1445
|
}
|
|
1441
1446
|
/**
|
|
1442
1447
|
* Returns an object of all context variables stored at the app level.
|
|
1443
1448
|
*/
|
|
1444
1449
|
getAll() {
|
|
1445
|
-
return { ...s(this,
|
|
1450
|
+
return { ...s(this, z).data };
|
|
1446
1451
|
}
|
|
1447
1452
|
async mount(e, t) {
|
|
1448
|
-
if (s(this,
|
|
1453
|
+
if (s(this, B))
|
|
1449
1454
|
throw new Error("Dolla is already mounted.");
|
|
1450
|
-
if (
|
|
1455
|
+
if (V(e)) {
|
|
1451
1456
|
const n = document.querySelector(e);
|
|
1452
|
-
|
|
1457
|
+
yt(HTMLElement, n, `Selector '${e}' did not match any element.`), v(this, G, n);
|
|
1453
1458
|
} else
|
|
1454
|
-
|
|
1459
|
+
yt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), v(this, G, e);
|
|
1455
1460
|
let r;
|
|
1456
|
-
t ? r =
|
|
1457
|
-
for (const n of s(this,
|
|
1461
|
+
t ? r = vt(t) : r = vt(Pt), v(this, ae, this.constructView(r.type, r.props)), await Promise.all(s(this, qe).map((n) => n())), s(this, ae).mount(s(this, G)), v(this, B, !0);
|
|
1462
|
+
for (const n of s(this, Fe))
|
|
1458
1463
|
n();
|
|
1459
1464
|
}
|
|
1460
1465
|
async unmount() {
|
|
1461
1466
|
var e;
|
|
1462
|
-
if (s(this,
|
|
1463
|
-
await Promise.all(s(this,
|
|
1464
|
-
for (const t of s(this,
|
|
1467
|
+
if (s(this, B)) {
|
|
1468
|
+
await Promise.all(s(this, Ae).map((t) => t())), (e = s(this, ae)) == null || e.unmount(), s(this, Te).stopAll(), v(this, B, !1);
|
|
1469
|
+
for (const t of s(this, _e))
|
|
1465
1470
|
t();
|
|
1466
1471
|
}
|
|
1467
1472
|
}
|
|
@@ -1470,26 +1475,26 @@ class ur {
|
|
|
1470
1475
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1471
1476
|
*/
|
|
1472
1477
|
beforeMount(e) {
|
|
1473
|
-
s(this,
|
|
1478
|
+
s(this, qe).push(e);
|
|
1474
1479
|
}
|
|
1475
1480
|
/**
|
|
1476
1481
|
* Registers a `callback` to run after the app is mounted.
|
|
1477
1482
|
*/
|
|
1478
1483
|
onMount(e) {
|
|
1479
|
-
s(this,
|
|
1484
|
+
s(this, Fe).push(e);
|
|
1480
1485
|
}
|
|
1481
1486
|
/**
|
|
1482
1487
|
* Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
|
|
1483
1488
|
* it will be awaited before unmounting finishes. Use this to perform cleanup.
|
|
1484
1489
|
*/
|
|
1485
1490
|
beforeUnmount(e) {
|
|
1486
|
-
s(this,
|
|
1491
|
+
s(this, Ae).push(e);
|
|
1487
1492
|
}
|
|
1488
1493
|
/**
|
|
1489
1494
|
* Registers a `callback` to run after the app is unmounted.
|
|
1490
1495
|
*/
|
|
1491
1496
|
onUnmount(e) {
|
|
1492
|
-
s(this,
|
|
1497
|
+
s(this, _e).push(e);
|
|
1493
1498
|
}
|
|
1494
1499
|
/**
|
|
1495
1500
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1497,28 +1502,28 @@ class ur {
|
|
|
1497
1502
|
setLoggles(e) {
|
|
1498
1503
|
for (const t in e) {
|
|
1499
1504
|
const r = e[t];
|
|
1500
|
-
r && (s(this,
|
|
1505
|
+
r && (s(this, O)[t] = r);
|
|
1501
1506
|
}
|
|
1502
1507
|
}
|
|
1503
1508
|
setLogFilter(e) {
|
|
1504
|
-
|
|
1509
|
+
v(this, K, wt(e));
|
|
1505
1510
|
}
|
|
1506
1511
|
createLogger(e, t) {
|
|
1507
|
-
const r = (t == null ? void 0 : t.console) ??
|
|
1512
|
+
const r = (t == null ? void 0 : t.console) ?? Ut(), n = this;
|
|
1508
1513
|
return {
|
|
1509
1514
|
setName(a) {
|
|
1510
1515
|
return e = a, this;
|
|
1511
1516
|
},
|
|
1512
1517
|
get info() {
|
|
1513
1518
|
var a;
|
|
1514
|
-
if (s(n,
|
|
1515
|
-
return
|
|
1519
|
+
if (s(n, O).info === !1 || V(s(n, O).info) && s(n, O).info !== n.getEnv() || !s(a = n, K).call(a, e))
|
|
1520
|
+
return Ce;
|
|
1516
1521
|
{
|
|
1517
1522
|
let o = `%c${e}`;
|
|
1518
1523
|
return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.info.bind(
|
|
1519
1524
|
r,
|
|
1520
1525
|
o,
|
|
1521
|
-
`color:${
|
|
1526
|
+
`color:${Ve(o)};font-weight:bold`,
|
|
1522
1527
|
"color:#777",
|
|
1523
1528
|
"color:#aaa",
|
|
1524
1529
|
"color:#777"
|
|
@@ -1527,14 +1532,14 @@ class ur {
|
|
|
1527
1532
|
},
|
|
1528
1533
|
get log() {
|
|
1529
1534
|
var a;
|
|
1530
|
-
if (s(n,
|
|
1531
|
-
return
|
|
1535
|
+
if (s(n, O).log === !1 || V(s(n, O).log) && s(n, O).log !== n.getEnv() || !s(a = n, K).call(a, e))
|
|
1536
|
+
return Ce;
|
|
1532
1537
|
{
|
|
1533
1538
|
let o = `%c${e}`;
|
|
1534
1539
|
return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.log.bind(
|
|
1535
1540
|
r,
|
|
1536
1541
|
o,
|
|
1537
|
-
`color:${
|
|
1542
|
+
`color:${Ve(o)};font-weight:bold`,
|
|
1538
1543
|
"color:#777",
|
|
1539
1544
|
"color:#aaa",
|
|
1540
1545
|
"color:#777"
|
|
@@ -1543,14 +1548,14 @@ class ur {
|
|
|
1543
1548
|
},
|
|
1544
1549
|
get warn() {
|
|
1545
1550
|
var a;
|
|
1546
|
-
if (s(n,
|
|
1547
|
-
return
|
|
1551
|
+
if (s(n, O).warn === !1 || V(s(n, O).warn) && s(n, O).warn !== n.getEnv() || !s(a = n, K).call(a, e))
|
|
1552
|
+
return Ce;
|
|
1548
1553
|
{
|
|
1549
1554
|
let o = `%c${e}`;
|
|
1550
1555
|
return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.warn.bind(
|
|
1551
1556
|
r,
|
|
1552
1557
|
o,
|
|
1553
|
-
`color:${
|
|
1558
|
+
`color:${Ve(o)};font-weight:bold`,
|
|
1554
1559
|
"color:#777",
|
|
1555
1560
|
"color:#aaa",
|
|
1556
1561
|
"color:#777"
|
|
@@ -1559,14 +1564,14 @@ class ur {
|
|
|
1559
1564
|
},
|
|
1560
1565
|
get error() {
|
|
1561
1566
|
var a;
|
|
1562
|
-
if (s(n,
|
|
1563
|
-
return
|
|
1567
|
+
if (s(n, O).error === !1 || V(s(n, O).error) && s(n, O).error !== n.getEnv() || !s(a = n, K).call(a, e))
|
|
1568
|
+
return Ce;
|
|
1564
1569
|
{
|
|
1565
1570
|
let o = `%c${e}`;
|
|
1566
1571
|
return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.error.bind(
|
|
1567
1572
|
r,
|
|
1568
1573
|
o,
|
|
1569
|
-
`color:${
|
|
1574
|
+
`color:${Ve(o)};font-weight:bold`,
|
|
1570
1575
|
"color:#777",
|
|
1571
1576
|
"color:#aaa",
|
|
1572
1577
|
"color:#777"
|
|
@@ -1574,7 +1579,7 @@ class ur {
|
|
|
1574
1579
|
}
|
|
1575
1580
|
},
|
|
1576
1581
|
crash(a) {
|
|
1577
|
-
throw n.isMounted && (n.unmount(), n.constructView(s(n,
|
|
1582
|
+
throw n.isMounted && (n.unmount(), n.constructView(s(n, je), {
|
|
1578
1583
|
error: a,
|
|
1579
1584
|
loggerName: e,
|
|
1580
1585
|
uid: t == null ? void 0 : t.uid
|
|
@@ -1586,41 +1591,41 @@ class ur {
|
|
|
1586
1591
|
*
|
|
1587
1592
|
*/
|
|
1588
1593
|
constructView(e, t, r = []) {
|
|
1589
|
-
return new
|
|
1594
|
+
return new Ht(s(this, z), e, t, r);
|
|
1590
1595
|
}
|
|
1591
1596
|
/**
|
|
1592
1597
|
*
|
|
1593
1598
|
*/
|
|
1594
1599
|
constructMarkup(e) {
|
|
1595
|
-
return
|
|
1600
|
+
return Wt(Bt(s(this, z), e));
|
|
1596
1601
|
}
|
|
1597
1602
|
}
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
function
|
|
1603
|
+
B = new WeakMap(), Me = new WeakMap(), G = new WeakMap(), ae = new WeakMap(), je = new WeakMap(), Te = new WeakMap(), qe = new WeakMap(), Fe = new WeakMap(), Ae = new WeakMap(), _e = new WeakMap(), z = new WeakMap(), O = new WeakMap(), K = new WeakMap();
|
|
1604
|
+
const kt = new pr(), yr = kt.i18n.t.bind(kt.i18n);
|
|
1605
|
+
function vr(i) {
|
|
1601
1606
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
|
|
1602
1607
|
}
|
|
1603
|
-
function
|
|
1608
|
+
function br() {
|
|
1604
1609
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1605
1610
|
}
|
|
1606
1611
|
export {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1612
|
+
jt as cond,
|
|
1613
|
+
vt as createMarkup,
|
|
1614
|
+
Vt as createRef,
|
|
1615
|
+
Ft as createSettableState,
|
|
1616
|
+
kr as createSetter,
|
|
1617
|
+
ce as createState,
|
|
1618
|
+
kt as default,
|
|
1619
|
+
be as derive,
|
|
1620
|
+
br as getDevDebug,
|
|
1621
|
+
mt as html,
|
|
1622
|
+
It as isRef,
|
|
1623
|
+
Sr as portal,
|
|
1624
|
+
Pr as repeat,
|
|
1625
|
+
vr as setDevDebug,
|
|
1626
|
+
yr as t,
|
|
1627
|
+
At as toSettableState,
|
|
1628
|
+
_t as toState,
|
|
1629
|
+
Ct as valueOf
|
|
1625
1630
|
};
|
|
1626
1631
|
//# sourceMappingURL=index.js.map
|