@manyducks.co/dolla 2.0.0-alpha.8 → 2.0.0-alpha.9
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 +5 -5
- package/dist/index.js +262 -234
- package/dist/index.js.map +1 -1
- package/dist/modules/dolla.d.ts +2 -2
- package/dist/modules/i18n.d.ts +59 -0
- package/notes/scratch.md +4 -4
- package/package.json +1 -1
- package/dist/modules/language.d.ts +0 -41
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var Ze = (a) => {
|
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
5
|
var mt = (a, e, t) => e in a ? gt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
6
|
-
var L = (a, e, t) => mt(a, typeof e != "symbol" ? e + "" : e, t),
|
|
7
|
-
var n = (a, e, t) => (
|
|
6
|
+
var L = (a, e, t) => mt(a, typeof e != "symbol" ? e + "" : e, t), ze = (a, e, t) => e.has(a) || Ze("Cannot " + t);
|
|
7
|
+
var n = (a, e, t) => (ze(a, e, "read from private field"), t ? t.call(a) : e.get(a)), h = (a, e, t) => e.has(a) ? Ze("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), g = (a, e, t, r) => (ze(a, e, "write to private field"), r ? r.call(a, t) : e.set(a, t), t), P = (a, e, t) => (ze(a, e, "access private method"), t);
|
|
8
8
|
var et = (a, e, t, r) => ({
|
|
9
9
|
set _(i) {
|
|
10
10
|
g(a, e, i, t);
|
|
@@ -13,9 +13,9 @@ var et = (a, e, t, r) => ({
|
|
|
13
13
|
return n(a, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as tt, c as wt, i as Ge, t as Be, a as yt, d as
|
|
16
|
+
import { h as tt, c as wt, i as Ge, t as Be, a as yt, d as ae, b as bt, e as Xe, f as U, g as K, j as lt, k as vt, w as ut, P as ht, l as rt, m as $t, n as Et, v as kt, o as Lt, p as Pt, q as nt, r as at, s as St, u as Te, x as Ae, y as Rt, z as Nt, A as xt } from "./passthrough-9kwwjgWk.js";
|
|
17
17
|
import { B as rr, C as nr, D as ar } from "./passthrough-9kwwjgWk.js";
|
|
18
|
-
function
|
|
18
|
+
function Ot(a) {
|
|
19
19
|
return tt`
|
|
20
20
|
<div
|
|
21
21
|
style=${{
|
|
@@ -62,12 +62,12 @@ function Mt(a) {
|
|
|
62
62
|
</div>
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
|
-
var J,
|
|
66
|
-
class
|
|
65
|
+
var J, Fe, M, C;
|
|
66
|
+
class Mt {
|
|
67
67
|
constructor() {
|
|
68
|
-
h(this,
|
|
68
|
+
h(this, M);
|
|
69
69
|
h(this, J, []);
|
|
70
|
-
h(this,
|
|
70
|
+
h(this, Fe, Tt());
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -81,37 +81,37 @@ class Nt {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
async get(e, t) {
|
|
84
|
-
return P(this,
|
|
84
|
+
return P(this, M, C).call(this, "get", e, t);
|
|
85
85
|
}
|
|
86
86
|
async put(e, t) {
|
|
87
|
-
return P(this,
|
|
87
|
+
return P(this, M, C).call(this, "put", e, t);
|
|
88
88
|
}
|
|
89
89
|
async patch(e, t) {
|
|
90
|
-
return P(this,
|
|
90
|
+
return P(this, M, C).call(this, "patch", e, t);
|
|
91
91
|
}
|
|
92
92
|
async post(e, t) {
|
|
93
|
-
return P(this,
|
|
93
|
+
return P(this, M, C).call(this, "post", e, t);
|
|
94
94
|
}
|
|
95
95
|
async delete(e, t) {
|
|
96
|
-
return P(this,
|
|
96
|
+
return P(this, M, C).call(this, "delete", e, t);
|
|
97
97
|
}
|
|
98
98
|
async head(e, t) {
|
|
99
|
-
return P(this,
|
|
99
|
+
return P(this, M, C).call(this, "head", e, t);
|
|
100
100
|
}
|
|
101
101
|
async options(e, t) {
|
|
102
|
-
return P(this,
|
|
102
|
+
return P(this, M, C).call(this, "options", e, t);
|
|
103
103
|
}
|
|
104
104
|
async trace(e, t) {
|
|
105
|
-
return P(this,
|
|
105
|
+
return P(this, M, C).call(this, "trace", e, t);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
J = new WeakMap(),
|
|
109
|
-
return
|
|
108
|
+
J = new WeakMap(), Fe = new WeakMap(), M = new WeakSet(), C = async function(e, t, r) {
|
|
109
|
+
return Dt({
|
|
110
110
|
...r,
|
|
111
111
|
method: e,
|
|
112
112
|
uri: t,
|
|
113
113
|
middleware: n(this, J),
|
|
114
|
-
fetch: n(this,
|
|
114
|
+
fetch: n(this, Fe)
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
function Tt() {
|
|
@@ -129,7 +129,7 @@ class At extends Error {
|
|
|
129
129
|
this.response = t;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
132
|
+
async function Dt(a) {
|
|
133
133
|
const { headers: e, query: t, fetch: r, middleware: i } = a, s = {
|
|
134
134
|
method: a.method,
|
|
135
135
|
uri: a.uri,
|
|
@@ -196,7 +196,7 @@ async function jt(a) {
|
|
|
196
196
|
throw new At(o);
|
|
197
197
|
return o;
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class jt {
|
|
200
200
|
constructor(e, t) {
|
|
201
201
|
L(this, "dolla");
|
|
202
202
|
L(this, "config");
|
|
@@ -229,41 +229,41 @@ class Ct {
|
|
|
229
229
|
return this.strings;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
var
|
|
233
|
-
class
|
|
232
|
+
var ye, Y, N, ie, be, ve, oe, $e, Ie, ft;
|
|
233
|
+
class Ct {
|
|
234
234
|
constructor(e) {
|
|
235
|
-
h(this,
|
|
236
|
-
h(this,
|
|
235
|
+
h(this, Ie);
|
|
236
|
+
h(this, ye);
|
|
237
237
|
h(this, Y);
|
|
238
|
-
h(this,
|
|
239
|
-
h(this,
|
|
240
|
-
h(this,
|
|
241
|
-
L(this, "$
|
|
242
|
-
h(this, be);
|
|
243
|
-
h(this, ie);
|
|
238
|
+
h(this, N, /* @__PURE__ */ new Map());
|
|
239
|
+
h(this, ie, []);
|
|
240
|
+
h(this, be, "auto");
|
|
241
|
+
L(this, "$locale");
|
|
244
242
|
h(this, ve);
|
|
245
|
-
|
|
243
|
+
h(this, oe);
|
|
244
|
+
h(this, $e);
|
|
245
|
+
g(this, ye, e), g(this, Y, e.createLogger("dolla/i18n"));
|
|
246
246
|
const [t, r] = K(), [i, s] = K();
|
|
247
|
-
this.$
|
|
248
|
-
n(this,
|
|
247
|
+
this.$locale = t, g(this, ve, r), g(this, oe, i), g(this, $e, s), e.beforeMount(async () => {
|
|
248
|
+
n(this, N).size > 0 && await this.setLocale(n(this, be));
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
get
|
|
252
|
-
return [...n(this,
|
|
251
|
+
get locales() {
|
|
252
|
+
return [...n(this, N).keys()];
|
|
253
253
|
}
|
|
254
254
|
setup(e) {
|
|
255
|
-
if (e.
|
|
256
|
-
n(this,
|
|
257
|
-
}), e.
|
|
258
|
-
if (!e.
|
|
259
|
-
throw new Error(`Initial
|
|
260
|
-
g(this,
|
|
255
|
+
if (e.translations.forEach((t) => {
|
|
256
|
+
n(this, N).set(t.locale, new jt(t, n(this, ye)));
|
|
257
|
+
}), e.locale && e.locale !== "auto") {
|
|
258
|
+
if (!e.translations.some((r) => r.locale === e.locale))
|
|
259
|
+
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
260
|
+
g(this, be, e.locale);
|
|
261
261
|
}
|
|
262
262
|
n(this, Y).info(
|
|
263
|
-
`${n(this,
|
|
263
|
+
`${n(this, N).size} language${n(this, N).size === 1 ? "" : "s"} supported: '${[...n(this, N).keys()].join("', '")}'`
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
|
-
async
|
|
266
|
+
async setLocale(e) {
|
|
267
267
|
var i;
|
|
268
268
|
let t;
|
|
269
269
|
if (e === "auto") {
|
|
@@ -273,19 +273,19 @@ class Dt {
|
|
|
273
273
|
((i = o.languages) == null ? void 0 : i.length) > 0 ? s.push(...o.languages) : o.language ? s.push(o.language) : o.browserLanguage ? s.push(o.browserLanguage) : o.userLanguage && s.push(o.userLanguage);
|
|
274
274
|
}
|
|
275
275
|
for (const o of s)
|
|
276
|
-
n(this,
|
|
276
|
+
n(this, N).has(o) && (t = o);
|
|
277
277
|
} else
|
|
278
|
-
n(this,
|
|
278
|
+
n(this, N).has(e) && (t = e);
|
|
279
279
|
if (t == null) {
|
|
280
|
-
const s = n(this,
|
|
280
|
+
const s = n(this, N).keys().next().value;
|
|
281
281
|
s && (t = s);
|
|
282
282
|
}
|
|
283
|
-
if (!t || !n(this,
|
|
283
|
+
if (!t || !n(this, N).has(t))
|
|
284
284
|
throw new Error(`Language '${e}' is not configured for this app.`);
|
|
285
|
-
const r = n(this,
|
|
285
|
+
const r = n(this, N).get(t);
|
|
286
286
|
try {
|
|
287
287
|
const s = await r.load();
|
|
288
|
-
n(this,
|
|
288
|
+
n(this, $e).call(this, s), n(this, ve).call(this, t), n(this, Y).info("set language to " + t);
|
|
289
289
|
} catch (s) {
|
|
290
290
|
s instanceof Error && n(this, Y).crash(s);
|
|
291
291
|
}
|
|
@@ -301,9 +301,9 @@ class Dt {
|
|
|
301
301
|
throw new Error(
|
|
302
302
|
`The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
|
|
303
303
|
);
|
|
304
|
-
if (!this.$
|
|
304
|
+
if (!this.$locale.get())
|
|
305
305
|
return qt;
|
|
306
|
-
const r = P(this,
|
|
306
|
+
const r = P(this, Ie, ft).call(this, e, t);
|
|
307
307
|
if (r)
|
|
308
308
|
return r;
|
|
309
309
|
if (t) {
|
|
@@ -312,29 +312,57 @@ class Dt {
|
|
|
312
312
|
yt(c) && (s[f] = c);
|
|
313
313
|
const o = Object.entries(s);
|
|
314
314
|
if (o.length > 0) {
|
|
315
|
-
const f = o.map((w) => w[1]), c =
|
|
316
|
-
const m = y.map(($,
|
|
315
|
+
const f = o.map((w) => w[1]), c = ae([n(this, oe), ...f], (w, ...y) => {
|
|
316
|
+
const m = y.map(($, D) => o[D]), d = {
|
|
317
317
|
...t
|
|
318
318
|
};
|
|
319
319
|
for (let $ = 0; $ < m.length; $++) {
|
|
320
|
-
const
|
|
321
|
-
d[
|
|
320
|
+
const D = m[$][0];
|
|
321
|
+
d[D] = y[$];
|
|
322
322
|
}
|
|
323
323
|
const b = it(w, e) || `[NO TRANSLATION: ${e}]`;
|
|
324
324
|
return st(b, d);
|
|
325
325
|
});
|
|
326
|
-
return n(this,
|
|
326
|
+
return n(this, ie).push([e, t, c]), c;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
const i =
|
|
329
|
+
const i = ae([n(this, oe)], (s) => {
|
|
330
330
|
let o = it(s, e) || `[NO TRANSLATION: ${e}]`;
|
|
331
331
|
return t && (o = st(o, t)), o;
|
|
332
332
|
});
|
|
333
|
-
return n(this,
|
|
333
|
+
return n(this, ie).push([e, t, i]), i;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Format a number in the current locale.
|
|
337
|
+
*/
|
|
338
|
+
formatNumber(e, t) {
|
|
339
|
+
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Format a number in the current locale and get the result as a State that will update if the locale changes.
|
|
343
|
+
*/
|
|
344
|
+
formatNumber$(e, t) {
|
|
345
|
+
return ae([this.$locale, e], (r, i) => this.formatNumber(i, t));
|
|
346
|
+
}
|
|
347
|
+
formatDate(e, t) {
|
|
348
|
+
return new Intl.DateTimeFormat(this.$locale.get(), t).format(new Date(e));
|
|
349
|
+
}
|
|
350
|
+
formatDate$(e, t) {
|
|
351
|
+
return ae([this.$locale, e], (r, i) => this.formatDate(i, t));
|
|
352
|
+
}
|
|
353
|
+
formatList(e, t) {
|
|
354
|
+
return new Intl.ListFormat(this.$locale.get(), t).format(e);
|
|
355
|
+
}
|
|
356
|
+
formatList$(e, t) {
|
|
357
|
+
return ae([this.$locale, e], (r, i) => this.formatList(i, t));
|
|
334
358
|
}
|
|
335
359
|
}
|
|
336
|
-
|
|
337
|
-
|
|
360
|
+
ye = new WeakMap(), Y = new WeakMap(), N = new WeakMap(), ie = new WeakMap(), be = new WeakMap(), ve = new WeakMap(), oe = new WeakMap(), $e = new WeakMap(), Ie = new WeakSet(), // formatRelativeTime(): string {
|
|
361
|
+
// }
|
|
362
|
+
// formatRelativeTime$(): State<string> {
|
|
363
|
+
// }
|
|
364
|
+
ft = function(e, t) {
|
|
365
|
+
for (const r of n(this, ie))
|
|
338
366
|
if (r[0] === e && bt(r[1], t))
|
|
339
367
|
return r[2];
|
|
340
368
|
};
|
|
@@ -353,21 +381,21 @@ function it(a, e) {
|
|
|
353
381
|
}
|
|
354
382
|
return r;
|
|
355
383
|
}
|
|
356
|
-
var X,
|
|
384
|
+
var X, Ee, _, H, ce, q, le, De;
|
|
357
385
|
class Vt {
|
|
358
386
|
constructor(e) {
|
|
359
|
-
h(this,
|
|
387
|
+
h(this, le);
|
|
360
388
|
h(this, X);
|
|
361
|
-
h(this,
|
|
389
|
+
h(this, Ee);
|
|
362
390
|
// Keyed updates ensure only the most recent callback queued with a certain key
|
|
363
391
|
// will be called, keeping DOM operations to a minimum.
|
|
364
|
-
h(this,
|
|
392
|
+
h(this, _, /* @__PURE__ */ new Map());
|
|
365
393
|
// All unkeyed updates are run on every batch.
|
|
366
|
-
h(this,
|
|
394
|
+
h(this, H, []);
|
|
367
395
|
// All read callbacks are run before updates on every batch.
|
|
368
|
-
h(this,
|
|
396
|
+
h(this, ce, []);
|
|
369
397
|
h(this, q, !1);
|
|
370
|
-
g(this, X, e), g(this,
|
|
398
|
+
g(this, X, e), g(this, Ee, e.createLogger("dolla/render"));
|
|
371
399
|
}
|
|
372
400
|
/**
|
|
373
401
|
* Queues a callback to run in the next render batch.
|
|
@@ -376,11 +404,11 @@ class Vt {
|
|
|
376
404
|
*/
|
|
377
405
|
update(e, t) {
|
|
378
406
|
return new Promise((r) => {
|
|
379
|
-
t ? n(this,
|
|
407
|
+
t ? n(this, _).set(t, () => {
|
|
380
408
|
e(), r();
|
|
381
|
-
}) : n(this,
|
|
409
|
+
}) : n(this, H).push(() => {
|
|
382
410
|
e(), r();
|
|
383
|
-
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this,
|
|
411
|
+
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this, le, De).call(this));
|
|
384
412
|
});
|
|
385
413
|
}
|
|
386
414
|
/**
|
|
@@ -390,44 +418,44 @@ class Vt {
|
|
|
390
418
|
*/
|
|
391
419
|
async read(e) {
|
|
392
420
|
return new Promise((t) => {
|
|
393
|
-
n(this,
|
|
421
|
+
n(this, ce).push(() => {
|
|
394
422
|
e(), t();
|
|
395
|
-
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this,
|
|
423
|
+
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this, le, De).call(this));
|
|
396
424
|
});
|
|
397
425
|
}
|
|
398
426
|
}
|
|
399
|
-
X = new WeakMap(),
|
|
400
|
-
const e = n(this,
|
|
427
|
+
X = new WeakMap(), Ee = new WeakMap(), _ = new WeakMap(), H = new WeakMap(), ce = new WeakMap(), q = new WeakMap(), le = new WeakSet(), De = function() {
|
|
428
|
+
const e = n(this, _).size + n(this, H).length;
|
|
401
429
|
if ((!n(this, X).isMounted || e === 0) && g(this, q, !1), !n(this, q)) {
|
|
402
|
-
for (const t of n(this,
|
|
430
|
+
for (const t of n(this, ce))
|
|
403
431
|
t();
|
|
404
|
-
g(this,
|
|
432
|
+
g(this, ce, []);
|
|
405
433
|
return;
|
|
406
434
|
}
|
|
407
435
|
requestAnimationFrame(() => {
|
|
408
|
-
n(this,
|
|
409
|
-
for (const t of n(this,
|
|
436
|
+
n(this, Ee).info(`Batching ${n(this, _).size + n(this, H).length} queued DOM update(s).`);
|
|
437
|
+
for (const t of n(this, _).values())
|
|
410
438
|
t();
|
|
411
|
-
n(this,
|
|
412
|
-
for (const t of n(this,
|
|
439
|
+
n(this, _).clear();
|
|
440
|
+
for (const t of n(this, H))
|
|
413
441
|
t();
|
|
414
|
-
g(this,
|
|
442
|
+
g(this, H, []), P(this, le, De).call(this);
|
|
415
443
|
});
|
|
416
444
|
};
|
|
417
|
-
function
|
|
418
|
-
return
|
|
445
|
+
function de() {
|
|
446
|
+
return de = Object.assign ? Object.assign.bind() : function(a) {
|
|
419
447
|
for (var e = 1; e < arguments.length; e++) {
|
|
420
448
|
var t = arguments[e];
|
|
421
449
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (a[r] = t[r]);
|
|
422
450
|
}
|
|
423
451
|
return a;
|
|
424
|
-
},
|
|
452
|
+
}, de.apply(null, arguments);
|
|
425
453
|
}
|
|
426
454
|
var A;
|
|
427
455
|
(function(a) {
|
|
428
456
|
a.Pop = "POP", a.Push = "PUSH", a.Replace = "REPLACE";
|
|
429
457
|
})(A || (A = {}));
|
|
430
|
-
var
|
|
458
|
+
var Ve = process.env.NODE_ENV !== "production" ? function(a) {
|
|
431
459
|
return Object.freeze(a);
|
|
432
460
|
} : function(a) {
|
|
433
461
|
return a;
|
|
@@ -441,13 +469,13 @@ function je(a, e) {
|
|
|
441
469
|
}
|
|
442
470
|
}
|
|
443
471
|
}
|
|
444
|
-
var
|
|
445
|
-
function
|
|
472
|
+
var Ue = "beforeunload", Ut = "hashchange", dt = "popstate";
|
|
473
|
+
function _t(a) {
|
|
446
474
|
a === void 0 && (a = {});
|
|
447
475
|
var e = a, t = e.window, r = t === void 0 ? document.defaultView : t, i = r.history;
|
|
448
476
|
function s() {
|
|
449
477
|
var p = r.location, l = p.pathname, u = p.search, v = p.hash, E = i.state || {};
|
|
450
|
-
return [E.idx,
|
|
478
|
+
return [E.idx, Ve({
|
|
451
479
|
pathname: l,
|
|
452
480
|
search: u,
|
|
453
481
|
hash: v,
|
|
@@ -485,14 +513,14 @@ function Ht(a) {
|
|
|
485
513
|
}
|
|
486
514
|
r.addEventListener(dt, f);
|
|
487
515
|
var c = A.Pop, w = s(), y = w[0], m = w[1], d = He(), b = He();
|
|
488
|
-
y == null && (y = 0, i.replaceState(
|
|
516
|
+
y == null && (y = 0, i.replaceState(de({}, i.state, {
|
|
489
517
|
idx: y
|
|
490
518
|
}), ""));
|
|
491
519
|
function $(p) {
|
|
492
520
|
return typeof p == "string" ? p : Ce(p);
|
|
493
521
|
}
|
|
494
|
-
function
|
|
495
|
-
return l === void 0 && (l = null),
|
|
522
|
+
function D(p, l) {
|
|
523
|
+
return l === void 0 && (l = null), Ve(de({
|
|
496
524
|
pathname: m.pathname,
|
|
497
525
|
hash: "",
|
|
498
526
|
search: ""
|
|
@@ -501,14 +529,14 @@ function Ht(a) {
|
|
|
501
529
|
key: pt()
|
|
502
530
|
}));
|
|
503
531
|
}
|
|
504
|
-
function
|
|
532
|
+
function pe(p, l) {
|
|
505
533
|
return [{
|
|
506
534
|
usr: p.state,
|
|
507
535
|
key: p.key,
|
|
508
536
|
idx: l
|
|
509
537
|
}, $(p)];
|
|
510
538
|
}
|
|
511
|
-
function
|
|
539
|
+
function ge(p, l, u) {
|
|
512
540
|
return !b.length || (b.call({
|
|
513
541
|
action: p,
|
|
514
542
|
location: l,
|
|
@@ -524,28 +552,28 @@ function Ht(a) {
|
|
|
524
552
|
});
|
|
525
553
|
}
|
|
526
554
|
function ne(p, l) {
|
|
527
|
-
var u = A.Push, v =
|
|
555
|
+
var u = A.Push, v = D(p, l);
|
|
528
556
|
function E() {
|
|
529
557
|
ne(p, l);
|
|
530
558
|
}
|
|
531
|
-
if (
|
|
532
|
-
var S =
|
|
559
|
+
if (ge(u, v, E)) {
|
|
560
|
+
var S = pe(v, y + 1), x = S[0], T = S[1];
|
|
533
561
|
try {
|
|
534
|
-
i.pushState(
|
|
562
|
+
i.pushState(x, "", T);
|
|
535
563
|
} catch {
|
|
536
564
|
r.location.assign(T);
|
|
537
565
|
}
|
|
538
566
|
re(u);
|
|
539
567
|
}
|
|
540
568
|
}
|
|
541
|
-
function
|
|
542
|
-
var u = A.Replace, v =
|
|
569
|
+
function me(p, l) {
|
|
570
|
+
var u = A.Replace, v = D(p, l);
|
|
543
571
|
function E() {
|
|
544
|
-
|
|
572
|
+
me(p, l);
|
|
545
573
|
}
|
|
546
|
-
if (
|
|
547
|
-
var S =
|
|
548
|
-
i.replaceState(
|
|
574
|
+
if (ge(u, v, E)) {
|
|
575
|
+
var S = pe(v, y), x = S[0], T = S[1];
|
|
576
|
+
i.replaceState(x, "", T), re(u);
|
|
549
577
|
}
|
|
550
578
|
}
|
|
551
579
|
function V(p) {
|
|
@@ -560,7 +588,7 @@ function Ht(a) {
|
|
|
560
588
|
},
|
|
561
589
|
createHref: $,
|
|
562
590
|
push: ne,
|
|
563
|
-
replace:
|
|
591
|
+
replace: me,
|
|
564
592
|
go: V,
|
|
565
593
|
back: function() {
|
|
566
594
|
V(-1);
|
|
@@ -573,24 +601,24 @@ function Ht(a) {
|
|
|
573
601
|
},
|
|
574
602
|
block: function(l) {
|
|
575
603
|
var u = b.push(l);
|
|
576
|
-
return b.length === 1 && r.addEventListener(
|
|
577
|
-
u(), b.length || r.removeEventListener(
|
|
604
|
+
return b.length === 1 && r.addEventListener(Ue, _e), function() {
|
|
605
|
+
u(), b.length || r.removeEventListener(Ue, _e);
|
|
578
606
|
};
|
|
579
607
|
}
|
|
580
608
|
};
|
|
581
609
|
return Q;
|
|
582
610
|
}
|
|
583
|
-
function
|
|
611
|
+
function Ht(a) {
|
|
584
612
|
a === void 0 && (a = {});
|
|
585
613
|
var e = a, t = e.window, r = t === void 0 ? document.defaultView : t, i = r.history;
|
|
586
614
|
function s() {
|
|
587
|
-
var l = Qe(r.location.hash.substr(1)), u = l.pathname, v = u === void 0 ? "/" : u, E = l.search, S = E === void 0 ? "" : E,
|
|
588
|
-
return [
|
|
615
|
+
var l = Qe(r.location.hash.substr(1)), u = l.pathname, v = u === void 0 ? "/" : u, E = l.search, S = E === void 0 ? "" : E, x = l.hash, T = x === void 0 ? "" : x, j = i.state || {};
|
|
616
|
+
return [j.idx, Ve({
|
|
589
617
|
pathname: v,
|
|
590
618
|
search: S,
|
|
591
619
|
hash: T,
|
|
592
|
-
state:
|
|
593
|
-
key:
|
|
620
|
+
state: j.usr || null,
|
|
621
|
+
key: j.key || "default"
|
|
594
622
|
})];
|
|
595
623
|
}
|
|
596
624
|
var o = null;
|
|
@@ -626,7 +654,7 @@ function _t(a) {
|
|
|
626
654
|
Ce(u) !== Ce(m) && f();
|
|
627
655
|
});
|
|
628
656
|
var c = A.Pop, w = s(), y = w[0], m = w[1], d = He(), b = He();
|
|
629
|
-
y == null && (y = 0, i.replaceState(
|
|
657
|
+
y == null && (y = 0, i.replaceState(de({}, i.state, {
|
|
630
658
|
idx: y
|
|
631
659
|
}), ""));
|
|
632
660
|
function $() {
|
|
@@ -637,11 +665,11 @@ function _t(a) {
|
|
|
637
665
|
}
|
|
638
666
|
return u;
|
|
639
667
|
}
|
|
640
|
-
function
|
|
668
|
+
function D(l) {
|
|
641
669
|
return $() + "#" + (typeof l == "string" ? l : Ce(l));
|
|
642
670
|
}
|
|
643
|
-
function
|
|
644
|
-
return u === void 0 && (u = null),
|
|
671
|
+
function pe(l, u) {
|
|
672
|
+
return u === void 0 && (u = null), Ve(de({
|
|
645
673
|
pathname: m.pathname,
|
|
646
674
|
hash: "",
|
|
647
675
|
search: ""
|
|
@@ -650,12 +678,12 @@ function _t(a) {
|
|
|
650
678
|
key: pt()
|
|
651
679
|
}));
|
|
652
680
|
}
|
|
653
|
-
function
|
|
681
|
+
function ge(l, u) {
|
|
654
682
|
return [{
|
|
655
683
|
usr: l.state,
|
|
656
684
|
key: l.key,
|
|
657
685
|
idx: u
|
|
658
|
-
},
|
|
686
|
+
}, D(l)];
|
|
659
687
|
}
|
|
660
688
|
function re(l, u, v) {
|
|
661
689
|
return !b.length || (b.call({
|
|
@@ -672,29 +700,29 @@ function _t(a) {
|
|
|
672
700
|
location: m
|
|
673
701
|
});
|
|
674
702
|
}
|
|
675
|
-
function
|
|
676
|
-
var v = A.Push, E =
|
|
703
|
+
function me(l, u) {
|
|
704
|
+
var v = A.Push, E = pe(l, u);
|
|
677
705
|
function S() {
|
|
678
|
-
|
|
706
|
+
me(l, u);
|
|
679
707
|
}
|
|
680
708
|
if (process.env.NODE_ENV !== "production" && je(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(l) + ")"), re(v, E, S)) {
|
|
681
|
-
var
|
|
709
|
+
var x = ge(E, y + 1), T = x[0], j = x[1];
|
|
682
710
|
try {
|
|
683
|
-
i.pushState(T, "",
|
|
711
|
+
i.pushState(T, "", j);
|
|
684
712
|
} catch {
|
|
685
|
-
r.location.assign(
|
|
713
|
+
r.location.assign(j);
|
|
686
714
|
}
|
|
687
715
|
ne(v);
|
|
688
716
|
}
|
|
689
717
|
}
|
|
690
718
|
function V(l, u) {
|
|
691
|
-
var v = A.Replace, E =
|
|
719
|
+
var v = A.Replace, E = pe(l, u);
|
|
692
720
|
function S() {
|
|
693
721
|
V(l, u);
|
|
694
722
|
}
|
|
695
723
|
if (process.env.NODE_ENV !== "production" && je(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(l) + ")"), re(v, E, S)) {
|
|
696
|
-
var
|
|
697
|
-
i.replaceState(T, "",
|
|
724
|
+
var x = ge(E, y), T = x[0], j = x[1];
|
|
725
|
+
i.replaceState(T, "", j), ne(v);
|
|
698
726
|
}
|
|
699
727
|
}
|
|
700
728
|
function Q(l) {
|
|
@@ -707,8 +735,8 @@ function _t(a) {
|
|
|
707
735
|
get location() {
|
|
708
736
|
return m;
|
|
709
737
|
},
|
|
710
|
-
createHref:
|
|
711
|
-
push:
|
|
738
|
+
createHref: D,
|
|
739
|
+
push: me,
|
|
712
740
|
replace: V,
|
|
713
741
|
go: Q,
|
|
714
742
|
back: function() {
|
|
@@ -722,14 +750,14 @@ function _t(a) {
|
|
|
722
750
|
},
|
|
723
751
|
block: function(u) {
|
|
724
752
|
var v = b.push(u);
|
|
725
|
-
return b.length === 1 && r.addEventListener(
|
|
726
|
-
v(), b.length || r.removeEventListener(
|
|
753
|
+
return b.length === 1 && r.addEventListener(Ue, _e), function() {
|
|
754
|
+
v(), b.length || r.removeEventListener(Ue, _e);
|
|
727
755
|
};
|
|
728
756
|
}
|
|
729
757
|
};
|
|
730
758
|
return p;
|
|
731
759
|
}
|
|
732
|
-
function
|
|
760
|
+
function _e(a) {
|
|
733
761
|
a.preventDefault(), a.returnValue = "";
|
|
734
762
|
}
|
|
735
763
|
function He() {
|
|
@@ -769,10 +797,10 @@ function Qe(a) {
|
|
|
769
797
|
}
|
|
770
798
|
return e;
|
|
771
799
|
}
|
|
772
|
-
function
|
|
800
|
+
function we(a) {
|
|
773
801
|
return lt(a, "Expected `path` to be a string. Got type: %t, value: %v"), a.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
774
802
|
}
|
|
775
|
-
function
|
|
803
|
+
function se(a) {
|
|
776
804
|
var t;
|
|
777
805
|
vt(
|
|
778
806
|
(r) => Xe(r == null ? void 0 : r.toString),
|
|
@@ -782,12 +810,12 @@ function ae(a) {
|
|
|
782
810
|
let e = (t = a.shift()) == null ? void 0 : t.toString();
|
|
783
811
|
if (e) {
|
|
784
812
|
for (const r of a.map((i) => i.toString()))
|
|
785
|
-
r.startsWith(".") ? e =
|
|
813
|
+
r.startsWith(".") ? e = qe(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
|
|
786
814
|
e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
|
|
787
815
|
}
|
|
788
816
|
return e ?? "";
|
|
789
817
|
}
|
|
790
|
-
function
|
|
818
|
+
function qe(a, e) {
|
|
791
819
|
if (lt(a, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = a, a = ""), e.startsWith("/"))
|
|
792
820
|
return e;
|
|
793
821
|
let t = a;
|
|
@@ -802,7 +830,7 @@ function De(a, e) {
|
|
|
802
830
|
e = e.replace(/^\.\/?/, "");
|
|
803
831
|
else
|
|
804
832
|
break;
|
|
805
|
-
return
|
|
833
|
+
return se([t, e]);
|
|
806
834
|
}
|
|
807
835
|
function Ke(a) {
|
|
808
836
|
if (!a) return {};
|
|
@@ -815,7 +843,7 @@ function Ke(a) {
|
|
|
815
843
|
}
|
|
816
844
|
function ot(a, e, t = {}) {
|
|
817
845
|
var o;
|
|
818
|
-
const [r, i] = e.split("?"), s =
|
|
846
|
+
const [r, i] = e.split("?"), s = we(r);
|
|
819
847
|
e: for (const f of a) {
|
|
820
848
|
const { fragments: c } = f;
|
|
821
849
|
if (!(((o = c[c.length - 1]) == null ? void 0 : o.type) === 3) && c.length !== s.length || t.willMatch && !t.willMatch(f))
|
|
@@ -859,7 +887,7 @@ function ot(a, e, t = {}) {
|
|
|
859
887
|
};
|
|
860
888
|
}
|
|
861
889
|
}
|
|
862
|
-
function
|
|
890
|
+
function Ft(a) {
|
|
863
891
|
const e = [], t = [], r = [], i = [];
|
|
864
892
|
for (const o of a) {
|
|
865
893
|
const { fragments: f } = o;
|
|
@@ -877,8 +905,8 @@ function Wt(a) {
|
|
|
877
905
|
const s = (o, f) => o.fragments.length > f.fragments.length ? -1 : 1;
|
|
878
906
|
return e.sort(s), t.sort(s), r.sort(s), i.sort(s), [...e, ...t, ...r, ...i];
|
|
879
907
|
}
|
|
880
|
-
function
|
|
881
|
-
const e =
|
|
908
|
+
function It(a) {
|
|
909
|
+
const e = we(a), t = [];
|
|
882
910
|
for (let r = 0; r < e.length; r++) {
|
|
883
911
|
const i = e[r];
|
|
884
912
|
if (i === "*") {
|
|
@@ -901,46 +929,46 @@ function zt(a) {
|
|
|
901
929
|
}
|
|
902
930
|
return t;
|
|
903
931
|
}
|
|
904
|
-
var
|
|
905
|
-
class
|
|
932
|
+
var ke, O, Z, k, We, F, Le, ee, I, ue, he, fe, Pe, B, Je, Ye;
|
|
933
|
+
class Wt {
|
|
906
934
|
constructor(e, t) {
|
|
907
|
-
h(this,
|
|
908
|
-
h(this,
|
|
909
|
-
h(this,
|
|
935
|
+
h(this, B);
|
|
936
|
+
h(this, ke);
|
|
937
|
+
h(this, O);
|
|
910
938
|
h(this, Z);
|
|
911
939
|
h(this, k);
|
|
912
|
-
h(this,
|
|
913
|
-
h(this,
|
|
914
|
-
h(this,
|
|
940
|
+
h(this, We, 0);
|
|
941
|
+
h(this, F, []);
|
|
942
|
+
h(this, Le);
|
|
915
943
|
h(this, ee, []);
|
|
916
944
|
// Callbacks that need to be called on unmount.
|
|
917
|
-
h(this,
|
|
945
|
+
h(this, I, []);
|
|
918
946
|
/**
|
|
919
947
|
* The currently matched route pattern, if any.
|
|
920
948
|
*/
|
|
921
949
|
L(this, "$pattern");
|
|
922
|
-
h(this,
|
|
950
|
+
h(this, ue);
|
|
923
951
|
/**
|
|
924
952
|
* The current URL path.
|
|
925
953
|
*/
|
|
926
954
|
L(this, "$path");
|
|
927
|
-
h(this,
|
|
955
|
+
h(this, he);
|
|
928
956
|
/**
|
|
929
957
|
* The current named path params.
|
|
930
958
|
*/
|
|
931
959
|
L(this, "$params");
|
|
932
|
-
h(this,
|
|
960
|
+
h(this, fe);
|
|
933
961
|
/**
|
|
934
962
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
935
963
|
*/
|
|
936
964
|
L(this, "$query");
|
|
937
|
-
h(this,
|
|
938
|
-
g(this,
|
|
965
|
+
h(this, Pe);
|
|
966
|
+
g(this, ke, e), g(this, O, e.createLogger("dolla/router")), g(this, Z, t);
|
|
939
967
|
const [r, i] = K(null), [s, o] = K(""), [f, c] = K({}), [w, y] = K(
|
|
940
968
|
Ke(typeof window > "u" ? "" : window.location.search ?? "")
|
|
941
969
|
);
|
|
942
|
-
this.$pattern = r, g(this,
|
|
943
|
-
n(this, k) != null && (n(this,
|
|
970
|
+
this.$pattern = r, g(this, ue, i), this.$path = s, g(this, he, o), this.$params = f, g(this, fe, c), this.$query = w, g(this, Pe, y), e.beforeMount(() => {
|
|
971
|
+
n(this, k) != null && (n(this, I).push(
|
|
944
972
|
ut([w], (m) => {
|
|
945
973
|
const d = new URLSearchParams();
|
|
946
974
|
for (const $ in m)
|
|
@@ -951,29 +979,29 @@ class Ft {
|
|
|
951
979
|
search: b
|
|
952
980
|
});
|
|
953
981
|
})
|
|
954
|
-
), n(this,
|
|
955
|
-
|
|
982
|
+
), n(this, I).push(n(this, k).listen(P(this, B, Ye).bind(this))), P(this, B, Ye).call(this, n(this, k)), n(this, I).push(
|
|
983
|
+
Bt(n(this, Z).rootElement, (m) => {
|
|
956
984
|
let d = m.getAttribute("href");
|
|
957
|
-
n(this,
|
|
985
|
+
n(this, O).info("Intercepted link click", m, d), /^https?:\/\/|^\//.test(d) || (d = se([n(this, k).location.pathname, d])), n(this, k).push(d);
|
|
958
986
|
})
|
|
959
|
-
), n(this,
|
|
987
|
+
), n(this, O).info("Intercepting <a> clicks within root element:", n(this, Z).rootElement));
|
|
960
988
|
}), e.onUnmount(() => {
|
|
961
|
-
for (; n(this,
|
|
962
|
-
n(this,
|
|
989
|
+
for (; n(this, I).length > 0; )
|
|
990
|
+
n(this, I).pop()();
|
|
963
991
|
});
|
|
964
992
|
}
|
|
965
993
|
setup(e) {
|
|
966
|
-
if (n(this,
|
|
967
|
-
n(this,
|
|
994
|
+
if (n(this, ke).isMounted) {
|
|
995
|
+
n(this, O).crash(
|
|
968
996
|
new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
|
|
969
997
|
);
|
|
970
998
|
return;
|
|
971
999
|
}
|
|
972
|
-
e.style === "hash" ? g(this, k,
|
|
973
|
-
e.routes.flatMap((t) => P(this,
|
|
1000
|
+
e.style === "hash" ? g(this, k, Ht()) : g(this, k, _t()), g(this, ee, Ft(
|
|
1001
|
+
e.routes.flatMap((t) => P(this, B, Je).call(this, t)).map((t) => ({
|
|
974
1002
|
pattern: t.pattern,
|
|
975
1003
|
meta: t.meta,
|
|
976
|
-
fragments:
|
|
1004
|
+
fragments: It(t.pattern)
|
|
977
1005
|
}))
|
|
978
1006
|
));
|
|
979
1007
|
for (const t of n(this, ee))
|
|
@@ -1001,7 +1029,7 @@ class Ft {
|
|
|
1001
1029
|
*/
|
|
1002
1030
|
go(e, t = {}) {
|
|
1003
1031
|
if (n(this, k) == null) {
|
|
1004
|
-
n(this,
|
|
1032
|
+
n(this, O).crash(
|
|
1005
1033
|
new Error(
|
|
1006
1034
|
"Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1007
1035
|
)
|
|
@@ -1009,14 +1037,14 @@ class Ft {
|
|
|
1009
1037
|
return;
|
|
1010
1038
|
}
|
|
1011
1039
|
let r;
|
|
1012
|
-
Array.isArray(e) ? r =
|
|
1040
|
+
Array.isArray(e) ? r = se(e) : r = e.toString(), r = qe(n(this, k).location.pathname, r), t.preserveQuery && (r += n(this, k).location.search), t.replace ? n(this, k).replace(r) : n(this, k).push(r);
|
|
1013
1041
|
}
|
|
1014
1042
|
/**
|
|
1015
1043
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
1016
1044
|
*/
|
|
1017
1045
|
back(e = 1) {
|
|
1018
1046
|
if (n(this, k) == null) {
|
|
1019
|
-
n(this,
|
|
1047
|
+
n(this, O).crash(
|
|
1020
1048
|
new Error(
|
|
1021
1049
|
"Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1022
1050
|
)
|
|
@@ -1030,7 +1058,7 @@ class Ft {
|
|
|
1030
1058
|
*/
|
|
1031
1059
|
forward(e = 1) {
|
|
1032
1060
|
if (n(this, k) == null) {
|
|
1033
|
-
n(this,
|
|
1061
|
+
n(this, O).crash(
|
|
1034
1062
|
new Error(
|
|
1035
1063
|
"Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1036
1064
|
)
|
|
@@ -1040,7 +1068,7 @@ class Ft {
|
|
|
1040
1068
|
n(this, k).go(e);
|
|
1041
1069
|
}
|
|
1042
1070
|
}
|
|
1043
|
-
|
|
1071
|
+
ke = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), k = new WeakMap(), We = new WeakMap(), F = new WeakMap(), Le = new WeakMap(), ee = new WeakMap(), I = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), Pe = new WeakMap(), B = new WeakSet(), /**
|
|
1044
1072
|
* Parses a route definition object into a set of matchable routes.
|
|
1045
1073
|
*
|
|
1046
1074
|
* @param route - Route config object.
|
|
@@ -1057,13 +1085,13 @@ Je = function(e, t = [], r = []) {
|
|
|
1057
1085
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
1058
1086
|
let i = [];
|
|
1059
1087
|
for (const c of t)
|
|
1060
|
-
i.push(...
|
|
1061
|
-
i.push(...
|
|
1088
|
+
i.push(...we(c.path));
|
|
1089
|
+
i.push(...we(e.path)), i[i.length - 1] === "*" && i.pop();
|
|
1062
1090
|
const s = [];
|
|
1063
1091
|
if (e.redirect) {
|
|
1064
1092
|
let c = e.redirect;
|
|
1065
|
-
return U(c) && (c =
|
|
1066
|
-
pattern: "/" +
|
|
1093
|
+
return U(c) && (c = qe(se(i), c), c.startsWith("/") || (c = "/" + c)), s.push({
|
|
1094
|
+
pattern: "/" + se([...i, ...we(e.path)]),
|
|
1067
1095
|
meta: {
|
|
1068
1096
|
redirect: c
|
|
1069
1097
|
}
|
|
@@ -1074,13 +1102,13 @@ Je = function(e, t = [], r = []) {
|
|
|
1074
1102
|
o = e.view;
|
|
1075
1103
|
else if (e.view)
|
|
1076
1104
|
throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
|
|
1077
|
-
const f = { id: et(this,
|
|
1105
|
+
const f = { id: et(this, We)._++, view: o };
|
|
1078
1106
|
if (e.routes)
|
|
1079
1107
|
for (const c of e.routes)
|
|
1080
|
-
s.push(...P(this,
|
|
1108
|
+
s.push(...P(this, B, Je).call(this, c, [...t, e], [...r, f]));
|
|
1081
1109
|
else
|
|
1082
1110
|
s.push({
|
|
1083
|
-
pattern: parent ?
|
|
1111
|
+
pattern: parent ? se([...t.map((c) => c.path), e.path]) : e.path,
|
|
1084
1112
|
meta: {
|
|
1085
1113
|
pattern: e.path,
|
|
1086
1114
|
layers: [...r, f],
|
|
@@ -1089,10 +1117,10 @@ Je = function(e, t = [], r = []) {
|
|
|
1089
1117
|
});
|
|
1090
1118
|
return s;
|
|
1091
1119
|
}, Ye = async function({ location: e }) {
|
|
1092
|
-
e.search !== n(this,
|
|
1120
|
+
e.search !== n(this, Le) && (g(this, Le, e.search), n(this, Pe).call(this, Ke(e.search)));
|
|
1093
1121
|
const t = ot(n(this, ee), e.pathname);
|
|
1094
1122
|
if (!t) {
|
|
1095
|
-
n(this,
|
|
1123
|
+
n(this, ue).call(this, null), n(this, he).call(this, e.pathname), n(this, fe).call(this, {
|
|
1096
1124
|
wildcard: e.pathname
|
|
1097
1125
|
});
|
|
1098
1126
|
return;
|
|
@@ -1105,7 +1133,7 @@ Je = function(e, t = [], r = []) {
|
|
|
1105
1133
|
}), t.meta.redirect != null)
|
|
1106
1134
|
if (typeof t.meta.redirect == "string") {
|
|
1107
1135
|
const r = Qt(t.meta.redirect, t.params);
|
|
1108
|
-
n(this,
|
|
1136
|
+
n(this, O).info(`↩️ redirecting from '${t.path}' to '${r}'`), n(this, k).replace(r);
|
|
1109
1137
|
} else if (typeof t.meta.redirect == "function") {
|
|
1110
1138
|
const r = {
|
|
1111
1139
|
path: t.path,
|
|
@@ -1116,26 +1144,26 @@ Je = function(e, t = [], r = []) {
|
|
|
1116
1144
|
let i = await t.meta.redirect(r);
|
|
1117
1145
|
if (typeof i != "string")
|
|
1118
1146
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
1119
|
-
i.startsWith("/") || (i =
|
|
1147
|
+
i.startsWith("/") || (i = qe(t.path, i)), n(this, O).info(`Redirecting to: '${i}'`), n(this, k).replace(i);
|
|
1120
1148
|
} else
|
|
1121
1149
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
1122
|
-
else if (n(this,
|
|
1123
|
-
n(this,
|
|
1150
|
+
else if (n(this, O).info(`📍 navigating to '${t.path}'`), n(this, he).call(this, t.path), n(this, fe).call(this, t.params), t.pattern !== this.$pattern.get()) {
|
|
1151
|
+
n(this, ue).call(this, t.pattern);
|
|
1124
1152
|
const r = t.meta.layers;
|
|
1125
1153
|
for (let i = 0; i < r.length; i++) {
|
|
1126
|
-
const s = r[i], o = n(this,
|
|
1154
|
+
const s = r[i], o = n(this, F)[i];
|
|
1127
1155
|
if ((o == null ? void 0 : o.id) !== s.id) {
|
|
1128
|
-
g(this,
|
|
1129
|
-
const f = n(this,
|
|
1156
|
+
g(this, F, n(this, F).slice(0, i));
|
|
1157
|
+
const f = n(this, F).at(-1);
|
|
1130
1158
|
o && o.node.isMounted && o.node.unmount();
|
|
1131
1159
|
let c;
|
|
1132
|
-
f ? c = f.node.setChildView(s.view) : c = n(this, Z).rootView.setChildView(s.view), n(this,
|
|
1160
|
+
f ? c = f.node.setChildView(s.view) : c = n(this, Z).rootView.setChildView(s.view), n(this, F).push({ id: s.id, node: c });
|
|
1133
1161
|
}
|
|
1134
1162
|
}
|
|
1135
1163
|
}
|
|
1136
1164
|
};
|
|
1137
|
-
const
|
|
1138
|
-
function
|
|
1165
|
+
const zt = /(noopener|noreferrer) (noopener|noreferrer)/, Gt = /^[\w-_]+:/;
|
|
1166
|
+
function Bt(a, e, t = window) {
|
|
1139
1167
|
function r(s) {
|
|
1140
1168
|
return !s || s === a ? null : s.localName !== "a" || s.href === void 0 ? r(s.parentNode) : s;
|
|
1141
1169
|
}
|
|
@@ -1143,7 +1171,7 @@ function It(a, e, t = window) {
|
|
|
1143
1171
|
if (s.button && s.button !== 0 || s.ctrlKey || s.metaKey || s.altKey || s.shiftKey || s.defaultPrevented)
|
|
1144
1172
|
return;
|
|
1145
1173
|
const o = r(s.target);
|
|
1146
|
-
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" &&
|
|
1174
|
+
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" && zt.test(o.getAttribute("rel")) || Gt.test(o.getAttribute("href")) || (s.preventDefault(), e(o)));
|
|
1147
1175
|
}
|
|
1148
1176
|
return a.addEventListener("click", i), function() {
|
|
1149
1177
|
a.removeEventListener("click", i);
|
|
@@ -1156,19 +1184,19 @@ function Qt(a, e) {
|
|
|
1156
1184
|
}
|
|
1157
1185
|
return a;
|
|
1158
1186
|
}
|
|
1159
|
-
var
|
|
1187
|
+
var W, Se, z, te, Re, Ne, xe, Oe, Me, R, G;
|
|
1160
1188
|
class Kt {
|
|
1161
1189
|
constructor() {
|
|
1162
1190
|
L(this, "http");
|
|
1163
|
-
L(this, "
|
|
1191
|
+
L(this, "i18n");
|
|
1164
1192
|
L(this, "render");
|
|
1165
1193
|
L(this, "router");
|
|
1166
|
-
h(this,
|
|
1167
|
-
h(this,
|
|
1168
|
-
h(this,
|
|
1194
|
+
h(this, W, !1);
|
|
1195
|
+
h(this, Se, "production");
|
|
1196
|
+
h(this, z);
|
|
1169
1197
|
h(this, te);
|
|
1170
|
-
h(this,
|
|
1171
|
-
h(this,
|
|
1198
|
+
h(this, Re, Ot);
|
|
1199
|
+
h(this, Ne, []);
|
|
1172
1200
|
h(this, xe, []);
|
|
1173
1201
|
h(this, Oe, []);
|
|
1174
1202
|
h(this, Me, []);
|
|
@@ -1178,20 +1206,20 @@ class Kt {
|
|
|
1178
1206
|
warn: "development",
|
|
1179
1207
|
error: !0
|
|
1180
1208
|
});
|
|
1181
|
-
h(this,
|
|
1209
|
+
h(this, G, rt("*,-dolla/*"));
|
|
1182
1210
|
L(this, "createState", K);
|
|
1183
1211
|
L(this, "createSettableState", $t);
|
|
1184
1212
|
L(this, "toSettableState", Et);
|
|
1185
1213
|
L(this, "toState", Be);
|
|
1186
1214
|
L(this, "valueOf", kt);
|
|
1187
|
-
L(this, "derive",
|
|
1215
|
+
L(this, "derive", ae);
|
|
1188
1216
|
L(this, "watch", ut);
|
|
1189
1217
|
L(this, "createRef", Lt);
|
|
1190
1218
|
L(this, "isRef", Pt);
|
|
1191
1219
|
const e = this;
|
|
1192
|
-
this.http = new
|
|
1220
|
+
this.http = new Mt(), this.i18n = new Ct(this), this.render = new Vt(this), this.router = new Wt(this, {
|
|
1193
1221
|
get rootElement() {
|
|
1194
|
-
return n(e,
|
|
1222
|
+
return n(e, z);
|
|
1195
1223
|
},
|
|
1196
1224
|
get rootView() {
|
|
1197
1225
|
return n(e, te);
|
|
@@ -1202,46 +1230,46 @@ class Kt {
|
|
|
1202
1230
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
1203
1231
|
*/
|
|
1204
1232
|
get isMounted() {
|
|
1205
|
-
return n(this,
|
|
1233
|
+
return n(this, W);
|
|
1206
1234
|
}
|
|
1207
1235
|
/**
|
|
1208
1236
|
* Get the current environment that this app is running in.
|
|
1209
1237
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1210
1238
|
*/
|
|
1211
1239
|
getEnv() {
|
|
1212
|
-
return n(this,
|
|
1240
|
+
return n(this, Se);
|
|
1213
1241
|
}
|
|
1214
1242
|
/**
|
|
1215
1243
|
* Sets the environment that this app is running in.
|
|
1216
1244
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1217
1245
|
*/
|
|
1218
1246
|
setEnv(e) {
|
|
1219
|
-
g(this,
|
|
1247
|
+
g(this, Se, e);
|
|
1220
1248
|
}
|
|
1221
1249
|
/**
|
|
1222
1250
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
1223
1251
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
1224
1252
|
*/
|
|
1225
1253
|
setCrashView(e) {
|
|
1226
|
-
g(this,
|
|
1254
|
+
g(this, Re, e);
|
|
1227
1255
|
}
|
|
1228
1256
|
async mount(e, t) {
|
|
1229
|
-
if (n(this,
|
|
1257
|
+
if (n(this, W))
|
|
1230
1258
|
throw new Error("Dolla is already mounted.");
|
|
1231
1259
|
if (U(e)) {
|
|
1232
1260
|
const i = document.querySelector(e);
|
|
1233
|
-
nt(HTMLElement, i, `Selector '${e}' did not match any element.`), g(this,
|
|
1261
|
+
nt(HTMLElement, i, `Selector '${e}' did not match any element.`), g(this, z, i);
|
|
1234
1262
|
} else
|
|
1235
|
-
nt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this,
|
|
1263
|
+
nt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this, z, e);
|
|
1236
1264
|
let r;
|
|
1237
|
-
t ? r = at(t) : r = at(ht), g(this, te, this.constructView(r.type, r.props)), await Promise.all(n(this,
|
|
1265
|
+
t ? r = at(t) : r = at(ht), g(this, te, this.constructView(r.type, r.props)), await Promise.all(n(this, Ne).map((i) => i())), n(this, te).mount(n(this, z)), g(this, W, !0);
|
|
1238
1266
|
for (const i of n(this, xe))
|
|
1239
1267
|
i();
|
|
1240
1268
|
}
|
|
1241
1269
|
async unmount() {
|
|
1242
1270
|
var e;
|
|
1243
|
-
if (n(this,
|
|
1244
|
-
await Promise.all(n(this, Oe).map((t) => t())), (e = n(this, te)) == null || e.unmount(), g(this,
|
|
1271
|
+
if (n(this, W)) {
|
|
1272
|
+
await Promise.all(n(this, Oe).map((t) => t())), (e = n(this, te)) == null || e.unmount(), g(this, W, !1);
|
|
1245
1273
|
for (const t of n(this, Me))
|
|
1246
1274
|
t();
|
|
1247
1275
|
}
|
|
@@ -1251,7 +1279,7 @@ class Kt {
|
|
|
1251
1279
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1252
1280
|
*/
|
|
1253
1281
|
beforeMount(e) {
|
|
1254
|
-
n(this,
|
|
1282
|
+
n(this, Ne).push(e);
|
|
1255
1283
|
}
|
|
1256
1284
|
/**
|
|
1257
1285
|
* Registers a `callback` to run after the app is mounted.
|
|
@@ -1282,7 +1310,7 @@ class Kt {
|
|
|
1282
1310
|
}
|
|
1283
1311
|
}
|
|
1284
1312
|
setLogFilter(e) {
|
|
1285
|
-
g(this,
|
|
1313
|
+
g(this, G, rt(e));
|
|
1286
1314
|
}
|
|
1287
1315
|
createLogger(e, t) {
|
|
1288
1316
|
const r = Be(e), i = (t == null ? void 0 : t.console) ?? St(), s = this;
|
|
@@ -1290,14 +1318,14 @@ class Kt {
|
|
|
1290
1318
|
get info() {
|
|
1291
1319
|
var f;
|
|
1292
1320
|
const o = r.get();
|
|
1293
|
-
if (n(s, R).info === !1 || U(n(s, R).info) && n(s, R).info !== s.getEnv() || !n(f = s,
|
|
1294
|
-
return
|
|
1321
|
+
if (n(s, R).info === !1 || U(n(s, R).info) && n(s, R).info !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1322
|
+
return Te;
|
|
1295
1323
|
{
|
|
1296
1324
|
let c = `%c${o}`;
|
|
1297
1325
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.info.bind(
|
|
1298
1326
|
i,
|
|
1299
1327
|
c,
|
|
1300
|
-
`color:${
|
|
1328
|
+
`color:${Ae(c)};font-weight:bold`,
|
|
1301
1329
|
"color:#777",
|
|
1302
1330
|
"color:#aaa",
|
|
1303
1331
|
"color:#777"
|
|
@@ -1307,14 +1335,14 @@ class Kt {
|
|
|
1307
1335
|
get log() {
|
|
1308
1336
|
var f;
|
|
1309
1337
|
const o = r.get();
|
|
1310
|
-
if (n(s, R).log === !1 || U(n(s, R).log) && n(s, R).log !== s.getEnv() || !n(f = s,
|
|
1311
|
-
return
|
|
1338
|
+
if (n(s, R).log === !1 || U(n(s, R).log) && n(s, R).log !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1339
|
+
return Te;
|
|
1312
1340
|
{
|
|
1313
1341
|
let c = `%c${o}`;
|
|
1314
1342
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.log.bind(
|
|
1315
1343
|
i,
|
|
1316
1344
|
c,
|
|
1317
|
-
`color:${
|
|
1345
|
+
`color:${Ae(c)};font-weight:bold`,
|
|
1318
1346
|
"color:#777",
|
|
1319
1347
|
"color:#aaa",
|
|
1320
1348
|
"color:#777"
|
|
@@ -1324,14 +1352,14 @@ class Kt {
|
|
|
1324
1352
|
get warn() {
|
|
1325
1353
|
var f;
|
|
1326
1354
|
const o = r.get();
|
|
1327
|
-
if (n(s, R).warn === !1 || U(n(s, R).warn) && n(s, R).warn !== s.getEnv() || !n(f = s,
|
|
1328
|
-
return
|
|
1355
|
+
if (n(s, R).warn === !1 || U(n(s, R).warn) && n(s, R).warn !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1356
|
+
return Te;
|
|
1329
1357
|
{
|
|
1330
1358
|
let c = `%c${o}`;
|
|
1331
1359
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.warn.bind(
|
|
1332
1360
|
i,
|
|
1333
1361
|
c,
|
|
1334
|
-
`color:${
|
|
1362
|
+
`color:${Ae(c)};font-weight:bold`,
|
|
1335
1363
|
"color:#777",
|
|
1336
1364
|
"color:#aaa",
|
|
1337
1365
|
"color:#777"
|
|
@@ -1341,14 +1369,14 @@ class Kt {
|
|
|
1341
1369
|
get error() {
|
|
1342
1370
|
var f;
|
|
1343
1371
|
const o = r.get();
|
|
1344
|
-
if (n(s, R).error === !1 || U(n(s, R).error) && n(s, R).error !== s.getEnv() || !n(f = s,
|
|
1345
|
-
return
|
|
1372
|
+
if (n(s, R).error === !1 || U(n(s, R).error) && n(s, R).error !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1373
|
+
return Te;
|
|
1346
1374
|
{
|
|
1347
1375
|
let c = `%c${o}`;
|
|
1348
1376
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.error.bind(
|
|
1349
1377
|
i,
|
|
1350
1378
|
c,
|
|
1351
|
-
`color:${
|
|
1379
|
+
`color:${Ae(c)};font-weight:bold`,
|
|
1352
1380
|
"color:#777",
|
|
1353
1381
|
"color:#aaa",
|
|
1354
1382
|
"color:#777"
|
|
@@ -1356,11 +1384,11 @@ class Kt {
|
|
|
1356
1384
|
}
|
|
1357
1385
|
},
|
|
1358
1386
|
crash(o) {
|
|
1359
|
-
throw s.isMounted && (s.unmount(), s.constructView(n(s,
|
|
1387
|
+
throw s.isMounted && (s.unmount(), s.constructView(n(s, Re), {
|
|
1360
1388
|
error: o,
|
|
1361
1389
|
loggerName: r.get(),
|
|
1362
1390
|
uid: t == null ? void 0 : t.uid
|
|
1363
|
-
}).mount(n(s,
|
|
1391
|
+
}).mount(n(s, z))), o;
|
|
1364
1392
|
}
|
|
1365
1393
|
};
|
|
1366
1394
|
}
|
|
@@ -1374,11 +1402,11 @@ class Kt {
|
|
|
1374
1402
|
*
|
|
1375
1403
|
*/
|
|
1376
1404
|
constructMarkup(e) {
|
|
1377
|
-
return xt(
|
|
1405
|
+
return Nt(xt({ root: this, data: {} }, e));
|
|
1378
1406
|
}
|
|
1379
1407
|
}
|
|
1380
|
-
|
|
1381
|
-
const ct = new Kt(), Zt = ct.
|
|
1408
|
+
W = new WeakMap(), Se = new WeakMap(), z = new WeakMap(), te = new WeakMap(), Re = new WeakMap(), Ne = new WeakMap(), xe = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), R = new WeakMap(), G = new WeakMap();
|
|
1409
|
+
const ct = new Kt(), Zt = ct.i18n.t.bind(ct.i18n);
|
|
1382
1410
|
export {
|
|
1383
1411
|
wt as cond,
|
|
1384
1412
|
at as createMarkup,
|
|
@@ -1387,7 +1415,7 @@ export {
|
|
|
1387
1415
|
rr as createSetter,
|
|
1388
1416
|
K as createState,
|
|
1389
1417
|
ct as default,
|
|
1390
|
-
|
|
1418
|
+
ae as derive,
|
|
1391
1419
|
tt as html,
|
|
1392
1420
|
Pt as isRef,
|
|
1393
1421
|
nr as portal,
|