@manyducks.co/dolla 2.0.0-alpha.5 → 2.0.0-alpha.7
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 +164 -514
- package/dist/index.d.ts +3 -3
- package/dist/index.js +223 -219
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/markup.d.ts +19 -11
- package/dist/modules/dolla.d.ts +7 -7
- package/dist/modules/language.d.ts +4 -4
- package/dist/modules/router.d.ts +4 -4
- package/dist/nodes/cond.d.ts +3 -3
- package/dist/nodes/html.d.ts +1 -1
- package/dist/nodes/observer.d.ts +4 -4
- package/dist/nodes/outlet.d.ts +3 -3
- package/dist/nodes/repeat.d.ts +9 -9
- package/dist/nodes/text.d.ts +3 -3
- package/dist/{passthrough-CtoBcpag.js → passthrough-BVaqqjam.js} +322 -301
- package/dist/passthrough-BVaqqjam.js.map +1 -0
- package/dist/state.d.ts +101 -0
- package/dist/types.d.ts +11 -11
- package/dist/view.d.ts +20 -5
- package/notes/context-vars.md +21 -0
- package/notes/readme-scratch.md +222 -0
- package/notes/route-middleware.md +42 -0
- package/notes/scratch.md +1 -1
- package/package.json +1 -1
- package/tests/{signals.test.js → state.test.js} +6 -6
- package/dist/passthrough-CtoBcpag.js.map +0 -1
- package/dist/signals.d.ts +0 -101
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
1
|
+
var gt = Object.defineProperty;
|
|
2
2
|
var Ze = (a) => {
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
|
-
var mt = (a, e, t) => e in a ?
|
|
5
|
+
var mt = (a, e, t) => e in a ? gt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
6
6
|
var L = (a, e, t) => mt(a, typeof e != "symbol" ? e + "" : e, t), Fe = (a, e, t) => e.has(a) || Ze("Cannot " + t);
|
|
7
|
-
var n = (a, e, t) => (Fe(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),
|
|
7
|
+
var n = (a, e, t) => (Fe(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) => (Fe(a, e, "write to private field"), r ? r.call(a, t) : e.set(a, t), t), P = (a, e, t) => (Fe(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);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
13
|
return n(a, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as tt, c as
|
|
17
|
-
import { B as rr, C as nr, D as ar } from "./passthrough-
|
|
18
|
-
function
|
|
16
|
+
import { h as tt, c as wt, i as Ie, t as Ge, a as yt, d as Be, 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 Ne, x as Te, y as Rt, z as xt, A as Ot } from "./passthrough-BVaqqjam.js";
|
|
17
|
+
import { B as rr, C as nr, D as ar } from "./passthrough-BVaqqjam.js";
|
|
18
|
+
function Mt(a) {
|
|
19
19
|
return tt`
|
|
20
20
|
<div
|
|
21
21
|
style=${{
|
|
@@ -30,7 +30,7 @@ function Nt(a) {
|
|
|
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" }}>${a.loggerName}</span>
|
|
33
|
-
${
|
|
33
|
+
${wt(a.uid, tt`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${a.uid}]</span>`)}
|
|
34
34
|
${" "}says:
|
|
35
35
|
</p>
|
|
36
36
|
<blockquote
|
|
@@ -62,10 +62,10 @@ function Nt(a) {
|
|
|
62
62
|
</div>
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
|
-
var J, _e,
|
|
66
|
-
class
|
|
65
|
+
var J, _e, N, D;
|
|
66
|
+
class Nt {
|
|
67
67
|
constructor() {
|
|
68
|
-
h(this,
|
|
68
|
+
h(this, N);
|
|
69
69
|
h(this, J, []);
|
|
70
70
|
h(this, _e, Tt());
|
|
71
71
|
}
|
|
@@ -81,31 +81,31 @@ class Ot {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
async get(e, t) {
|
|
84
|
-
return P(this,
|
|
84
|
+
return P(this, N, D).call(this, "get", e, t);
|
|
85
85
|
}
|
|
86
86
|
async put(e, t) {
|
|
87
|
-
return P(this,
|
|
87
|
+
return P(this, N, D).call(this, "put", e, t);
|
|
88
88
|
}
|
|
89
89
|
async patch(e, t) {
|
|
90
|
-
return P(this,
|
|
90
|
+
return P(this, N, D).call(this, "patch", e, t);
|
|
91
91
|
}
|
|
92
92
|
async post(e, t) {
|
|
93
|
-
return P(this,
|
|
93
|
+
return P(this, N, D).call(this, "post", e, t);
|
|
94
94
|
}
|
|
95
95
|
async delete(e, t) {
|
|
96
|
-
return P(this,
|
|
96
|
+
return P(this, N, D).call(this, "delete", e, t);
|
|
97
97
|
}
|
|
98
98
|
async head(e, t) {
|
|
99
|
-
return P(this,
|
|
99
|
+
return P(this, N, D).call(this, "head", e, t);
|
|
100
100
|
}
|
|
101
101
|
async options(e, t) {
|
|
102
|
-
return P(this,
|
|
102
|
+
return P(this, N, D).call(this, "options", e, t);
|
|
103
103
|
}
|
|
104
104
|
async trace(e, t) {
|
|
105
|
-
return P(this,
|
|
105
|
+
return P(this, N, D).call(this, "trace", e, t);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
J = new WeakMap(), _e = new WeakMap(),
|
|
108
|
+
J = new WeakMap(), _e = new WeakMap(), N = new WeakSet(), D = async function(e, t, r) {
|
|
109
109
|
return jt({
|
|
110
110
|
...r,
|
|
111
111
|
method: e,
|
|
@@ -142,37 +142,37 @@ async function jt(a) {
|
|
|
142
142
|
};
|
|
143
143
|
if (e)
|
|
144
144
|
if (e instanceof Map || e instanceof Headers)
|
|
145
|
-
e.forEach((c,
|
|
146
|
-
s.headers.set(
|
|
145
|
+
e.forEach((c, w) => {
|
|
146
|
+
s.headers.set(w, c);
|
|
147
147
|
});
|
|
148
148
|
else if (e != null && typeof e == "object" && !Array.isArray(e))
|
|
149
149
|
for (const c in e) {
|
|
150
|
-
const
|
|
151
|
-
|
|
150
|
+
const w = e[c];
|
|
151
|
+
w instanceof Date ? s.headers.set(c, w.toISOString()) : w != null && s.headers.set(c, String(w));
|
|
152
152
|
}
|
|
153
153
|
else
|
|
154
154
|
throw new TypeError(`Unknown headers type. Got: ${e}`);
|
|
155
155
|
if (t)
|
|
156
156
|
if (t instanceof Map || t instanceof URLSearchParams)
|
|
157
|
-
t.forEach((c,
|
|
158
|
-
s.query.set(
|
|
157
|
+
t.forEach((c, w) => {
|
|
158
|
+
s.query.set(w, c);
|
|
159
159
|
});
|
|
160
160
|
else if (t != null && typeof t == "object" && !Array.isArray(t))
|
|
161
161
|
for (const c in t) {
|
|
162
|
-
const
|
|
163
|
-
|
|
162
|
+
const w = t[c];
|
|
163
|
+
w instanceof Date ? s.query.set(c, w.toISOString()) : w != null && s.query.set(c, String(w));
|
|
164
164
|
}
|
|
165
165
|
else
|
|
166
166
|
throw new TypeError(`Unknown query params type. Got: ${t}`);
|
|
167
167
|
let o;
|
|
168
168
|
const f = async () => {
|
|
169
|
-
const c = s.query.toString(),
|
|
170
|
-
let
|
|
171
|
-
!s.headers.has("content-type") && Ie(s.body) ? (s.headers.set("content-type", "application/json"),
|
|
172
|
-
const m = await r(
|
|
169
|
+
const c = s.query.toString(), w = c.length > 0 ? s.uri + "?" + c : s.uri;
|
|
170
|
+
let y;
|
|
171
|
+
!s.headers.has("content-type") && Ie(s.body) ? (s.headers.set("content-type", "application/json"), y = JSON.stringify(s.body)) : y = s.body;
|
|
172
|
+
const m = await r(w, {
|
|
173
173
|
method: s.method,
|
|
174
174
|
headers: s.headers,
|
|
175
|
-
body:
|
|
175
|
+
body: y
|
|
176
176
|
}), d = Object.fromEntries(m.headers.entries()), b = d["content-type"];
|
|
177
177
|
let $;
|
|
178
178
|
b != null && b.includes("application/json") ? $ = await m.json() : b != null && b.includes("application/x-www-form-urlencoded") ? $ = await m.formData() : $ = await m.text(), o = {
|
|
@@ -185,9 +185,9 @@ async function jt(a) {
|
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
187
|
if (i.length > 0) {
|
|
188
|
-
const c = (
|
|
189
|
-
const
|
|
190
|
-
return async () =>
|
|
188
|
+
const c = (w = 0) => {
|
|
189
|
+
const y = i[w], m = i[w + 1] ? c(w + 1) : f;
|
|
190
|
+
return async () => y(s, async () => (await m(), o));
|
|
191
191
|
};
|
|
192
192
|
await c()();
|
|
193
193
|
} else
|
|
@@ -211,7 +211,7 @@ class Ct {
|
|
|
211
211
|
this.strings = e;
|
|
212
212
|
else
|
|
213
213
|
throw new Error(`Fetch function did not return an object of language strings: ${e}`);
|
|
214
|
-
} else if (
|
|
214
|
+
} else if (U(this.config.path)) {
|
|
215
215
|
const e = await this.dolla.http.get(this.config.path);
|
|
216
216
|
if (e.status >= 200 && e.status < 300)
|
|
217
217
|
if (Ie(e.body))
|
|
@@ -229,7 +229,7 @@ class Ct {
|
|
|
229
229
|
return this.strings;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
var we, Y, x, se,
|
|
232
|
+
var we, Y, x, se, ye, be, ie, ve, We, ft;
|
|
233
233
|
class Dt {
|
|
234
234
|
constructor(e) {
|
|
235
235
|
h(this, We);
|
|
@@ -237,15 +237,15 @@ class Dt {
|
|
|
237
237
|
h(this, Y);
|
|
238
238
|
h(this, x, /* @__PURE__ */ new Map());
|
|
239
239
|
h(this, se, []);
|
|
240
|
-
h(this,
|
|
240
|
+
h(this, ye, "auto");
|
|
241
241
|
L(this, "$current");
|
|
242
|
-
h(this,
|
|
242
|
+
h(this, be);
|
|
243
243
|
h(this, ie);
|
|
244
|
-
h(this,
|
|
245
|
-
|
|
244
|
+
h(this, ve);
|
|
245
|
+
g(this, we, e), g(this, Y, e.createLogger("dolla/language"));
|
|
246
246
|
const [t, r] = K(), [i, s] = K();
|
|
247
|
-
this.$current = t,
|
|
248
|
-
n(this, x).size > 0 && await this.setLanguage(n(this,
|
|
247
|
+
this.$current = t, g(this, be, r), g(this, ie, i), g(this, ve, s), e.beforeMount(async () => {
|
|
248
|
+
n(this, x).size > 0 && await this.setLanguage(n(this, ye));
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
get supportedLanguages() {
|
|
@@ -257,7 +257,7 @@ class Dt {
|
|
|
257
257
|
}), e.initialLanguage && e.initialLanguage !== "auto") {
|
|
258
258
|
if (!e.languages.some((r) => r.name === e.initialLanguage))
|
|
259
259
|
throw new Error(`Initial language '${e.initialLanguage}' has no registered translation.`);
|
|
260
|
-
|
|
260
|
+
g(this, ye, e.initialLanguage);
|
|
261
261
|
}
|
|
262
262
|
n(this, Y).info(
|
|
263
263
|
`${n(this, x).size} language${n(this, x).size === 1 ? "" : "s"} supported: '${[...n(this, x).keys()].join("', '")}'`
|
|
@@ -285,13 +285,13 @@ class Dt {
|
|
|
285
285
|
const r = n(this, x).get(t);
|
|
286
286
|
try {
|
|
287
287
|
const s = await r.load();
|
|
288
|
-
n(this,
|
|
288
|
+
n(this, ve).call(this, s), n(this, be).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
|
}
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
|
-
* Returns a
|
|
294
|
+
* Returns a State containing the value at `key`.
|
|
295
295
|
|
|
296
296
|
* @param key - Key to the translated value.
|
|
297
297
|
* @param values - A map of {{placeholder}} names and the values to replace them with.
|
|
@@ -309,18 +309,18 @@ class Dt {
|
|
|
309
309
|
if (t) {
|
|
310
310
|
const s = {};
|
|
311
311
|
for (const [f, c] of Object.entries(t))
|
|
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((
|
|
316
|
-
const m =
|
|
315
|
+
const f = o.map((w) => w[1]), c = Be([n(this, ie), ...f], (w, ...y) => {
|
|
316
|
+
const m = y.map(($, j) => o[j]), d = {
|
|
317
317
|
...t
|
|
318
318
|
};
|
|
319
319
|
for (let $ = 0; $ < m.length; $++) {
|
|
320
320
|
const j = m[$][0];
|
|
321
|
-
d[j] =
|
|
321
|
+
d[j] = y[$];
|
|
322
322
|
}
|
|
323
|
-
const b = it(
|
|
323
|
+
const b = it(w, e) || `[NO TRANSLATION: ${e}]`;
|
|
324
324
|
return st(b, d);
|
|
325
325
|
});
|
|
326
326
|
return n(this, se).push([e, t, c]), c;
|
|
@@ -333,7 +333,7 @@ class Dt {
|
|
|
333
333
|
return n(this, se).push([e, t, i]), i;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
we = new WeakMap(), Y = new WeakMap(), x = new WeakMap(), se = new WeakMap(),
|
|
336
|
+
we = new WeakMap(), Y = new WeakMap(), x = new WeakMap(), se = new WeakMap(), ye = new WeakMap(), be = new WeakMap(), ie = new WeakMap(), ve = new WeakMap(), We = new WeakSet(), ft = function(e, t) {
|
|
337
337
|
for (const r of n(this, se))
|
|
338
338
|
if (r[0] === e && bt(r[1], t))
|
|
339
339
|
return r[2];
|
|
@@ -353,20 +353,21 @@ function it(a, e) {
|
|
|
353
353
|
}
|
|
354
354
|
return r;
|
|
355
355
|
}
|
|
356
|
-
var X,
|
|
357
|
-
class
|
|
356
|
+
var X, $e, H, _, oe, q, ce, Ae;
|
|
357
|
+
class Vt {
|
|
358
358
|
constructor(e) {
|
|
359
359
|
h(this, ce);
|
|
360
360
|
h(this, X);
|
|
361
|
-
h(this,
|
|
361
|
+
h(this, $e);
|
|
362
362
|
// Keyed updates ensure only the most recent callback queued with a certain key
|
|
363
363
|
// will be called, keeping DOM operations to a minimum.
|
|
364
364
|
h(this, H, /* @__PURE__ */ new Map());
|
|
365
365
|
// All unkeyed updates are run on every batch.
|
|
366
366
|
h(this, _, []);
|
|
367
|
+
// All read callbacks are run before updates on every batch.
|
|
367
368
|
h(this, oe, []);
|
|
368
369
|
h(this, q, !1);
|
|
369
|
-
|
|
370
|
+
g(this, X, e), g(this, $e, e.createLogger("dolla/render"));
|
|
370
371
|
}
|
|
371
372
|
/**
|
|
372
373
|
* Queues a callback to run in the next render batch.
|
|
@@ -379,7 +380,7 @@ class Ut {
|
|
|
379
380
|
e(), r();
|
|
380
381
|
}) : n(this, _).push(() => {
|
|
381
382
|
e(), r();
|
|
382
|
-
}), !n(this, q) && n(this, X).isMounted && (
|
|
383
|
+
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this, ce, Ae).call(this));
|
|
383
384
|
});
|
|
384
385
|
}
|
|
385
386
|
/**
|
|
@@ -391,36 +392,36 @@ class Ut {
|
|
|
391
392
|
return new Promise((t) => {
|
|
392
393
|
n(this, oe).push(() => {
|
|
393
394
|
e(), t();
|
|
394
|
-
}), !n(this, q) && n(this, X).isMounted && (
|
|
395
|
+
}), !n(this, q) && n(this, X).isMounted && (g(this, q, !0), P(this, ce, Ae).call(this));
|
|
395
396
|
});
|
|
396
397
|
}
|
|
397
398
|
}
|
|
398
|
-
X = new WeakMap(),
|
|
399
|
+
X = new WeakMap(), $e = new WeakMap(), H = new WeakMap(), _ = new WeakMap(), oe = new WeakMap(), q = new WeakMap(), ce = new WeakSet(), Ae = function() {
|
|
399
400
|
const e = n(this, H).size + n(this, _).length;
|
|
400
|
-
if ((!n(this, X).isMounted || e === 0) &&
|
|
401
|
+
if ((!n(this, X).isMounted || e === 0) && g(this, q, !1), !n(this, q)) {
|
|
401
402
|
for (const t of n(this, oe))
|
|
402
403
|
t();
|
|
403
|
-
|
|
404
|
+
g(this, oe, []);
|
|
404
405
|
return;
|
|
405
406
|
}
|
|
406
407
|
requestAnimationFrame(() => {
|
|
407
|
-
n(this,
|
|
408
|
+
n(this, $e).info(`Batching ${n(this, H).size + n(this, _).length} queued DOM update(s).`);
|
|
408
409
|
for (const t of n(this, H).values())
|
|
409
410
|
t();
|
|
410
411
|
n(this, H).clear();
|
|
411
412
|
for (const t of n(this, _))
|
|
412
413
|
t();
|
|
413
|
-
|
|
414
|
+
g(this, _, []), P(this, ce, Ae).call(this);
|
|
414
415
|
});
|
|
415
416
|
};
|
|
416
|
-
function
|
|
417
|
-
return
|
|
417
|
+
function fe() {
|
|
418
|
+
return fe = Object.assign ? Object.assign.bind() : function(a) {
|
|
418
419
|
for (var e = 1; e < arguments.length; e++) {
|
|
419
420
|
var t = arguments[e];
|
|
420
421
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (a[r] = t[r]);
|
|
421
422
|
}
|
|
422
423
|
return a;
|
|
423
|
-
},
|
|
424
|
+
}, fe.apply(null, arguments);
|
|
424
425
|
}
|
|
425
426
|
var A;
|
|
426
427
|
(function(a) {
|
|
@@ -440,12 +441,12 @@ function je(a, e) {
|
|
|
440
441
|
}
|
|
441
442
|
}
|
|
442
443
|
}
|
|
443
|
-
var
|
|
444
|
+
var Ve = "beforeunload", Ut = "hashchange", dt = "popstate";
|
|
444
445
|
function Ht(a) {
|
|
445
446
|
a === void 0 && (a = {});
|
|
446
447
|
var e = a, t = e.window, r = t === void 0 ? document.defaultView : t, i = r.history;
|
|
447
448
|
function s() {
|
|
448
|
-
var
|
|
449
|
+
var p = r.location, l = p.pathname, u = p.search, v = p.hash, E = i.state || {};
|
|
449
450
|
return [E.idx, qe({
|
|
450
451
|
pathname: l,
|
|
451
452
|
search: u,
|
|
@@ -459,17 +460,17 @@ function Ht(a) {
|
|
|
459
460
|
if (o)
|
|
460
461
|
b.call(o), o = null;
|
|
461
462
|
else {
|
|
462
|
-
var
|
|
463
|
+
var p = A.Pop, l = s(), u = l[0], v = l[1];
|
|
463
464
|
if (b.length)
|
|
464
465
|
if (u != null) {
|
|
465
|
-
var E =
|
|
466
|
+
var E = y - u;
|
|
466
467
|
E && (o = {
|
|
467
|
-
action:
|
|
468
|
+
action: p,
|
|
468
469
|
location: v,
|
|
469
470
|
retry: function() {
|
|
470
|
-
|
|
471
|
+
V(E * -1);
|
|
471
472
|
}
|
|
472
|
-
},
|
|
473
|
+
}, V(E));
|
|
473
474
|
} else
|
|
474
475
|
process.env.NODE_ENV !== "production" && je(
|
|
475
476
|
!1,
|
|
@@ -479,76 +480,76 @@ function Ht(a) {
|
|
|
479
480
|
"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
|
|
480
481
|
);
|
|
481
482
|
else
|
|
482
|
-
re(
|
|
483
|
+
re(p);
|
|
483
484
|
}
|
|
484
485
|
}
|
|
485
486
|
r.addEventListener(dt, f);
|
|
486
|
-
var c = A.Pop,
|
|
487
|
-
|
|
488
|
-
idx:
|
|
487
|
+
var c = A.Pop, w = s(), y = w[0], m = w[1], d = He(), b = He();
|
|
488
|
+
y == null && (y = 0, i.replaceState(fe({}, i.state, {
|
|
489
|
+
idx: y
|
|
489
490
|
}), ""));
|
|
490
|
-
function $(
|
|
491
|
-
return typeof
|
|
491
|
+
function $(p) {
|
|
492
|
+
return typeof p == "string" ? p : Ce(p);
|
|
492
493
|
}
|
|
493
|
-
function j(
|
|
494
|
-
return l === void 0 && (l = null), qe(
|
|
494
|
+
function j(p, l) {
|
|
495
|
+
return l === void 0 && (l = null), qe(fe({
|
|
495
496
|
pathname: m.pathname,
|
|
496
497
|
hash: "",
|
|
497
498
|
search: ""
|
|
498
|
-
}, typeof
|
|
499
|
+
}, typeof p == "string" ? Qe(p) : p, {
|
|
499
500
|
state: l,
|
|
500
|
-
key:
|
|
501
|
+
key: pt()
|
|
501
502
|
}));
|
|
502
503
|
}
|
|
503
|
-
function
|
|
504
|
+
function de(p, l) {
|
|
504
505
|
return [{
|
|
505
|
-
usr:
|
|
506
|
-
key:
|
|
506
|
+
usr: p.state,
|
|
507
|
+
key: p.key,
|
|
507
508
|
idx: l
|
|
508
|
-
}, $(
|
|
509
|
+
}, $(p)];
|
|
509
510
|
}
|
|
510
|
-
function pe(
|
|
511
|
+
function pe(p, l, u) {
|
|
511
512
|
return !b.length || (b.call({
|
|
512
|
-
action:
|
|
513
|
+
action: p,
|
|
513
514
|
location: l,
|
|
514
515
|
retry: u
|
|
515
516
|
}), !1);
|
|
516
517
|
}
|
|
517
|
-
function re(
|
|
518
|
-
c =
|
|
518
|
+
function re(p) {
|
|
519
|
+
c = p;
|
|
519
520
|
var l = s();
|
|
520
|
-
|
|
521
|
+
y = l[0], m = l[1], d.call({
|
|
521
522
|
action: c,
|
|
522
523
|
location: m
|
|
523
524
|
});
|
|
524
525
|
}
|
|
525
|
-
function ne(
|
|
526
|
-
var u = A.Push, v = j(
|
|
526
|
+
function ne(p, l) {
|
|
527
|
+
var u = A.Push, v = j(p, l);
|
|
527
528
|
function E() {
|
|
528
|
-
ne(
|
|
529
|
+
ne(p, l);
|
|
529
530
|
}
|
|
530
531
|
if (pe(u, v, E)) {
|
|
531
|
-
var S =
|
|
532
|
+
var S = de(v, y + 1), M = S[0], T = S[1];
|
|
532
533
|
try {
|
|
533
|
-
i.pushState(
|
|
534
|
+
i.pushState(M, "", T);
|
|
534
535
|
} catch {
|
|
535
536
|
r.location.assign(T);
|
|
536
537
|
}
|
|
537
538
|
re(u);
|
|
538
539
|
}
|
|
539
540
|
}
|
|
540
|
-
function
|
|
541
|
-
var u = A.Replace, v = j(
|
|
541
|
+
function ge(p, l) {
|
|
542
|
+
var u = A.Replace, v = j(p, l);
|
|
542
543
|
function E() {
|
|
543
|
-
|
|
544
|
+
ge(p, l);
|
|
544
545
|
}
|
|
545
546
|
if (pe(u, v, E)) {
|
|
546
|
-
var S =
|
|
547
|
-
i.replaceState(
|
|
547
|
+
var S = de(v, y), M = S[0], T = S[1];
|
|
548
|
+
i.replaceState(M, "", T), re(u);
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
|
-
function
|
|
551
|
-
i.go(
|
|
551
|
+
function V(p) {
|
|
552
|
+
i.go(p);
|
|
552
553
|
}
|
|
553
554
|
var Q = {
|
|
554
555
|
get action() {
|
|
@@ -559,21 +560,21 @@ function Ht(a) {
|
|
|
559
560
|
},
|
|
560
561
|
createHref: $,
|
|
561
562
|
push: ne,
|
|
562
|
-
replace:
|
|
563
|
-
go:
|
|
563
|
+
replace: ge,
|
|
564
|
+
go: V,
|
|
564
565
|
back: function() {
|
|
565
|
-
|
|
566
|
+
V(-1);
|
|
566
567
|
},
|
|
567
568
|
forward: function() {
|
|
568
|
-
|
|
569
|
+
V(1);
|
|
569
570
|
},
|
|
570
571
|
listen: function(l) {
|
|
571
572
|
return d.push(l);
|
|
572
573
|
},
|
|
573
574
|
block: function(l) {
|
|
574
575
|
var u = b.push(l);
|
|
575
|
-
return b.length === 1 && r.addEventListener(
|
|
576
|
-
u(), b.length || r.removeEventListener(
|
|
576
|
+
return b.length === 1 && r.addEventListener(Ve, Ue), function() {
|
|
577
|
+
u(), b.length || r.removeEventListener(Ve, Ue);
|
|
577
578
|
};
|
|
578
579
|
}
|
|
579
580
|
};
|
|
@@ -583,7 +584,7 @@ function _t(a) {
|
|
|
583
584
|
a === void 0 && (a = {});
|
|
584
585
|
var e = a, t = e.window, r = t === void 0 ? document.defaultView : t, i = r.history;
|
|
585
586
|
function s() {
|
|
586
|
-
var l = Qe(r.location.hash.substr(1)), u = l.pathname, v = u === void 0 ? "/" : u, E = l.search, S = E === void 0 ? "" : E,
|
|
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, M = l.hash, T = M === void 0 ? "" : M, C = i.state || {};
|
|
587
588
|
return [C.idx, qe({
|
|
588
589
|
pathname: v,
|
|
589
590
|
search: S,
|
|
@@ -600,7 +601,7 @@ function _t(a) {
|
|
|
600
601
|
var l = A.Pop, u = s(), v = u[0], E = u[1];
|
|
601
602
|
if (b.length)
|
|
602
603
|
if (v != null) {
|
|
603
|
-
var S =
|
|
604
|
+
var S = y - v;
|
|
604
605
|
S && (o = {
|
|
605
606
|
action: l,
|
|
606
607
|
location: E,
|
|
@@ -620,13 +621,13 @@ function _t(a) {
|
|
|
620
621
|
ne(l);
|
|
621
622
|
}
|
|
622
623
|
}
|
|
623
|
-
r.addEventListener(dt, f), r.addEventListener(
|
|
624
|
+
r.addEventListener(dt, f), r.addEventListener(Ut, function() {
|
|
624
625
|
var l = s(), u = l[1];
|
|
625
626
|
Ce(u) !== Ce(m) && f();
|
|
626
627
|
});
|
|
627
|
-
var c = A.Pop,
|
|
628
|
-
|
|
629
|
-
idx:
|
|
628
|
+
var c = A.Pop, w = s(), y = w[0], m = w[1], d = He(), b = He();
|
|
629
|
+
y == null && (y = 0, i.replaceState(fe({}, i.state, {
|
|
630
|
+
idx: y
|
|
630
631
|
}), ""));
|
|
631
632
|
function $() {
|
|
632
633
|
var l = document.querySelector("base"), u = "";
|
|
@@ -639,14 +640,14 @@ function _t(a) {
|
|
|
639
640
|
function j(l) {
|
|
640
641
|
return $() + "#" + (typeof l == "string" ? l : Ce(l));
|
|
641
642
|
}
|
|
642
|
-
function
|
|
643
|
-
return u === void 0 && (u = null), qe(
|
|
643
|
+
function de(l, u) {
|
|
644
|
+
return u === void 0 && (u = null), qe(fe({
|
|
644
645
|
pathname: m.pathname,
|
|
645
646
|
hash: "",
|
|
646
647
|
search: ""
|
|
647
648
|
}, typeof l == "string" ? Qe(l) : l, {
|
|
648
649
|
state: u,
|
|
649
|
-
key:
|
|
650
|
+
key: pt()
|
|
650
651
|
}));
|
|
651
652
|
}
|
|
652
653
|
function pe(l, u) {
|
|
@@ -666,18 +667,18 @@ function _t(a) {
|
|
|
666
667
|
function ne(l) {
|
|
667
668
|
c = l;
|
|
668
669
|
var u = s();
|
|
669
|
-
|
|
670
|
+
y = u[0], m = u[1], d.call({
|
|
670
671
|
action: c,
|
|
671
672
|
location: m
|
|
672
673
|
});
|
|
673
674
|
}
|
|
674
|
-
function
|
|
675
|
-
var v = A.Push, E =
|
|
675
|
+
function ge(l, u) {
|
|
676
|
+
var v = A.Push, E = de(l, u);
|
|
676
677
|
function S() {
|
|
677
|
-
|
|
678
|
+
ge(l, u);
|
|
678
679
|
}
|
|
679
680
|
if (process.env.NODE_ENV !== "production" && je(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(l) + ")"), re(v, E, S)) {
|
|
680
|
-
var
|
|
681
|
+
var M = pe(E, y + 1), T = M[0], C = M[1];
|
|
681
682
|
try {
|
|
682
683
|
i.pushState(T, "", C);
|
|
683
684
|
} catch {
|
|
@@ -686,20 +687,20 @@ function _t(a) {
|
|
|
686
687
|
ne(v);
|
|
687
688
|
}
|
|
688
689
|
}
|
|
689
|
-
function
|
|
690
|
-
var v = A.Replace, E =
|
|
690
|
+
function V(l, u) {
|
|
691
|
+
var v = A.Replace, E = de(l, u);
|
|
691
692
|
function S() {
|
|
692
|
-
|
|
693
|
+
V(l, u);
|
|
693
694
|
}
|
|
694
695
|
if (process.env.NODE_ENV !== "production" && je(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(l) + ")"), re(v, E, S)) {
|
|
695
|
-
var
|
|
696
|
+
var M = pe(E, y), T = M[0], C = M[1];
|
|
696
697
|
i.replaceState(T, "", C), ne(v);
|
|
697
698
|
}
|
|
698
699
|
}
|
|
699
700
|
function Q(l) {
|
|
700
701
|
i.go(l);
|
|
701
702
|
}
|
|
702
|
-
var
|
|
703
|
+
var p = {
|
|
703
704
|
get action() {
|
|
704
705
|
return c;
|
|
705
706
|
},
|
|
@@ -707,8 +708,8 @@ function _t(a) {
|
|
|
707
708
|
return m;
|
|
708
709
|
},
|
|
709
710
|
createHref: j,
|
|
710
|
-
push:
|
|
711
|
-
replace:
|
|
711
|
+
push: ge,
|
|
712
|
+
replace: V,
|
|
712
713
|
go: Q,
|
|
713
714
|
back: function() {
|
|
714
715
|
Q(-1);
|
|
@@ -721,14 +722,14 @@ function _t(a) {
|
|
|
721
722
|
},
|
|
722
723
|
block: function(u) {
|
|
723
724
|
var v = b.push(u);
|
|
724
|
-
return b.length === 1 && r.addEventListener(
|
|
725
|
-
v(), b.length || r.removeEventListener(
|
|
725
|
+
return b.length === 1 && r.addEventListener(Ve, Ue), function() {
|
|
726
|
+
v(), b.length || r.removeEventListener(Ve, Ue);
|
|
726
727
|
};
|
|
727
728
|
}
|
|
728
729
|
};
|
|
729
|
-
return
|
|
730
|
+
return p;
|
|
730
731
|
}
|
|
731
|
-
function
|
|
732
|
+
function Ue(a) {
|
|
732
733
|
a.preventDefault(), a.returnValue = "";
|
|
733
734
|
}
|
|
734
735
|
function He() {
|
|
@@ -751,7 +752,7 @@ function He() {
|
|
|
751
752
|
}
|
|
752
753
|
};
|
|
753
754
|
}
|
|
754
|
-
function
|
|
755
|
+
function pt() {
|
|
755
756
|
return Math.random().toString(36).substr(2, 8);
|
|
756
757
|
}
|
|
757
758
|
function Ce(a) {
|
|
@@ -768,7 +769,7 @@ function Qe(a) {
|
|
|
768
769
|
}
|
|
769
770
|
return e;
|
|
770
771
|
}
|
|
771
|
-
function
|
|
772
|
+
function me(a) {
|
|
772
773
|
return lt(a, "Expected `path` to be a string. Got type: %t, value: %v"), a.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
773
774
|
}
|
|
774
775
|
function ae(a) {
|
|
@@ -814,12 +815,12 @@ function Ke(a) {
|
|
|
814
815
|
}
|
|
815
816
|
function ot(a, e, t = {}) {
|
|
816
817
|
var o;
|
|
817
|
-
const [r, i] = e.split("?"), s =
|
|
818
|
+
const [r, i] = e.split("?"), s = me(r);
|
|
818
819
|
e: for (const f of a) {
|
|
819
820
|
const { fragments: c } = f;
|
|
820
821
|
if (!(((o = c[c.length - 1]) == null ? void 0 : o.type) === 3) && c.length !== s.length || t.willMatch && !t.willMatch(f))
|
|
821
822
|
continue e;
|
|
822
|
-
const
|
|
823
|
+
const y = [];
|
|
823
824
|
t: for (let d = 0; d < c.length; d++) {
|
|
824
825
|
const b = s[d], $ = c[d];
|
|
825
826
|
if (b == null && $.type !== 3)
|
|
@@ -827,30 +828,30 @@ function ot(a, e, t = {}) {
|
|
|
827
828
|
switch ($.type) {
|
|
828
829
|
case 1:
|
|
829
830
|
if ($.name.toLowerCase() === b.toLowerCase()) {
|
|
830
|
-
|
|
831
|
+
y.push($);
|
|
831
832
|
break;
|
|
832
833
|
} else
|
|
833
834
|
continue e;
|
|
834
835
|
case 2:
|
|
835
|
-
|
|
836
|
+
y.push({ ...$, value: b });
|
|
836
837
|
break;
|
|
837
838
|
case 3:
|
|
838
|
-
|
|
839
|
+
y.push({ ...$, value: s.slice(d).join("/") });
|
|
839
840
|
break t;
|
|
840
841
|
case 4:
|
|
841
842
|
if (isNaN(Number(b)))
|
|
842
843
|
continue e;
|
|
843
|
-
|
|
844
|
+
y.push({ ...$, value: Number(b) });
|
|
844
845
|
break;
|
|
845
846
|
default:
|
|
846
847
|
throw new Error(`Unknown fragment type: ${$.type}`);
|
|
847
848
|
}
|
|
848
849
|
}
|
|
849
850
|
const m = /* @__PURE__ */ Object.create(null);
|
|
850
|
-
for (const d of
|
|
851
|
+
for (const d of y)
|
|
851
852
|
d.type === 2 && (m[d.name] = decodeURIComponent(d.value)), d.type === 4 && (m[d.name] = d.value), d.type === 3 && (m.wildcard = "/" + decodeURIComponent(d.value));
|
|
852
853
|
return {
|
|
853
|
-
path: "/" +
|
|
854
|
+
path: "/" + y.map((d) => d.value).join("/"),
|
|
854
855
|
pattern: "/" + c.map((d) => d.type === 2 ? `{${d.name}}` : d.type === 4 ? `{#${d.name}}` : d.name).join("/"),
|
|
855
856
|
params: m,
|
|
856
857
|
query: Ke(i),
|
|
@@ -877,7 +878,7 @@ function Wt(a) {
|
|
|
877
878
|
return e.sort(s), t.sort(s), r.sort(s), i.sort(s), [...e, ...t, ...r, ...i];
|
|
878
879
|
}
|
|
879
880
|
function zt(a) {
|
|
880
|
-
const e =
|
|
881
|
+
const e = me(a), t = [];
|
|
881
882
|
for (let r = 0; r < e.length; r++) {
|
|
882
883
|
const i = e[r];
|
|
883
884
|
if (i === "*") {
|
|
@@ -900,12 +901,12 @@ function zt(a) {
|
|
|
900
901
|
}
|
|
901
902
|
return t;
|
|
902
903
|
}
|
|
903
|
-
var
|
|
904
|
+
var Ee, O, Z, k, ze, W, ke, ee, z, le, ue, he, Le, B, Je, Ye;
|
|
904
905
|
class Ft {
|
|
905
906
|
constructor(e, t) {
|
|
906
907
|
h(this, B);
|
|
907
|
-
h(this,
|
|
908
|
-
h(this,
|
|
908
|
+
h(this, Ee);
|
|
909
|
+
h(this, O);
|
|
909
910
|
h(this, Z);
|
|
910
911
|
h(this, k);
|
|
911
912
|
h(this, ze, 0);
|
|
@@ -918,29 +919,29 @@ class Ft {
|
|
|
918
919
|
* The currently matched route pattern, if any.
|
|
919
920
|
*/
|
|
920
921
|
L(this, "$pattern");
|
|
921
|
-
h(this,
|
|
922
|
+
h(this, le);
|
|
922
923
|
/**
|
|
923
924
|
* The current URL path.
|
|
924
925
|
*/
|
|
925
926
|
L(this, "$path");
|
|
926
|
-
h(this,
|
|
927
|
+
h(this, ue);
|
|
927
928
|
/**
|
|
928
929
|
* The current named path params.
|
|
929
930
|
*/
|
|
930
931
|
L(this, "$params");
|
|
931
|
-
h(this,
|
|
932
|
+
h(this, he);
|
|
932
933
|
/**
|
|
933
934
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
934
935
|
*/
|
|
935
936
|
L(this, "$query");
|
|
936
937
|
h(this, Le);
|
|
937
|
-
|
|
938
|
-
const [r, i] = K(null), [s, o] = K(""), [f, c] = K({}), [
|
|
938
|
+
g(this, Ee, e), g(this, O, e.createLogger("dolla/router")), g(this, Z, t);
|
|
939
|
+
const [r, i] = K(null), [s, o] = K(""), [f, c] = K({}), [w, y] = K(
|
|
939
940
|
Ke(typeof window > "u" ? "" : window.location.search ?? "")
|
|
940
941
|
);
|
|
941
|
-
this.$pattern = r,
|
|
942
|
+
this.$pattern = r, g(this, le, i), this.$path = s, g(this, ue, o), this.$params = f, g(this, he, c), this.$query = w, g(this, Le, y), e.beforeMount(() => {
|
|
942
943
|
n(this, k) != null && (n(this, z).push(
|
|
943
|
-
ut([
|
|
944
|
+
ut([w], (m) => {
|
|
944
945
|
const d = new URLSearchParams();
|
|
945
946
|
for (const $ in m)
|
|
946
947
|
d.set($, String(m[$]));
|
|
@@ -953,22 +954,22 @@ class Ft {
|
|
|
953
954
|
), n(this, z).push(n(this, k).listen(P(this, B, Ye).bind(this))), P(this, B, Ye).call(this, n(this, k)), n(this, z).push(
|
|
954
955
|
Bt(n(this, Z).rootElement, (m) => {
|
|
955
956
|
let d = m.getAttribute("href");
|
|
956
|
-
n(this,
|
|
957
|
+
n(this, O).info("Intercepted link click", m, d), /^https?:\/\/|^\//.test(d) || (d = ae([n(this, k).location.pathname, d])), n(this, k).push(d);
|
|
957
958
|
})
|
|
958
|
-
), n(this,
|
|
959
|
+
), n(this, O).info("Intercepting <a> clicks within root element:", n(this, Z).rootElement));
|
|
959
960
|
}), e.onUnmount(() => {
|
|
960
961
|
for (; n(this, z).length > 0; )
|
|
961
962
|
n(this, z).pop()();
|
|
962
963
|
});
|
|
963
964
|
}
|
|
964
965
|
setup(e) {
|
|
965
|
-
if (n(this,
|
|
966
|
-
n(this,
|
|
966
|
+
if (n(this, Ee).isMounted) {
|
|
967
|
+
n(this, O).crash(
|
|
967
968
|
new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
|
|
968
969
|
);
|
|
969
970
|
return;
|
|
970
971
|
}
|
|
971
|
-
e.style === "hash" ?
|
|
972
|
+
e.style === "hash" ? g(this, k, _t()) : g(this, k, Ht()), g(this, ee, Wt(
|
|
972
973
|
e.routes.flatMap((t) => P(this, B, Je).call(this, t)).map((t) => ({
|
|
973
974
|
pattern: t.pattern,
|
|
974
975
|
meta: t.meta,
|
|
@@ -978,7 +979,7 @@ class Ft {
|
|
|
978
979
|
for (const t of n(this, ee))
|
|
979
980
|
if (t.meta.redirect) {
|
|
980
981
|
let r;
|
|
981
|
-
if (!Xe(t.meta.redirect)) if (
|
|
982
|
+
if (!Xe(t.meta.redirect)) if (U(t.meta.redirect)) {
|
|
982
983
|
if (r = t.meta.redirect, !ot(n(this, ee), r, {
|
|
983
984
|
willMatch(s) {
|
|
984
985
|
return s !== t;
|
|
@@ -1000,7 +1001,7 @@ class Ft {
|
|
|
1000
1001
|
*/
|
|
1001
1002
|
go(e, t = {}) {
|
|
1002
1003
|
if (n(this, k) == null) {
|
|
1003
|
-
n(this,
|
|
1004
|
+
n(this, O).crash(
|
|
1004
1005
|
new Error(
|
|
1005
1006
|
"Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1006
1007
|
)
|
|
@@ -1015,7 +1016,7 @@ class Ft {
|
|
|
1015
1016
|
*/
|
|
1016
1017
|
back(e = 1) {
|
|
1017
1018
|
if (n(this, k) == null) {
|
|
1018
|
-
n(this,
|
|
1019
|
+
n(this, O).crash(
|
|
1019
1020
|
new Error(
|
|
1020
1021
|
"Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1021
1022
|
)
|
|
@@ -1029,7 +1030,7 @@ class Ft {
|
|
|
1029
1030
|
*/
|
|
1030
1031
|
forward(e = 1) {
|
|
1031
1032
|
if (n(this, k) == null) {
|
|
1032
|
-
n(this,
|
|
1033
|
+
n(this, O).crash(
|
|
1033
1034
|
new Error(
|
|
1034
1035
|
"Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
1035
1036
|
)
|
|
@@ -1039,7 +1040,7 @@ class Ft {
|
|
|
1039
1040
|
n(this, k).go(e);
|
|
1040
1041
|
}
|
|
1041
1042
|
}
|
|
1042
|
-
|
|
1043
|
+
Ee = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), k = new WeakMap(), ze = new WeakMap(), W = new WeakMap(), ke = new WeakMap(), ee = new WeakMap(), z = new WeakMap(), le = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), Le = new WeakMap(), B = new WeakSet(), /**
|
|
1043
1044
|
* Parses a route definition object into a set of matchable routes.
|
|
1044
1045
|
*
|
|
1045
1046
|
* @param route - Route config object.
|
|
@@ -1056,13 +1057,13 @@ Je = function(e, t = [], r = []) {
|
|
|
1056
1057
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
1057
1058
|
let i = [];
|
|
1058
1059
|
for (const c of t)
|
|
1059
|
-
i.push(...
|
|
1060
|
-
i.push(...
|
|
1060
|
+
i.push(...me(c.path));
|
|
1061
|
+
i.push(...me(e.path)), i[i.length - 1] === "*" && i.pop();
|
|
1061
1062
|
const s = [];
|
|
1062
1063
|
if (e.redirect) {
|
|
1063
1064
|
let c = e.redirect;
|
|
1064
|
-
return
|
|
1065
|
-
pattern: "/" + ae([...i, ...
|
|
1065
|
+
return U(c) && (c = De(ae(i), c), c.startsWith("/") || (c = "/" + c)), s.push({
|
|
1066
|
+
pattern: "/" + ae([...i, ...me(e.path)]),
|
|
1066
1067
|
meta: {
|
|
1067
1068
|
redirect: c
|
|
1068
1069
|
}
|
|
@@ -1088,22 +1089,23 @@ Je = function(e, t = [], r = []) {
|
|
|
1088
1089
|
});
|
|
1089
1090
|
return s;
|
|
1090
1091
|
}, Ye = async function({ location: e }) {
|
|
1091
|
-
e.search !== n(this, ke) && (
|
|
1092
|
+
e.search !== n(this, ke) && (g(this, ke, e.search), n(this, Le).call(this, Ke(e.search)));
|
|
1092
1093
|
const t = ot(n(this, ee), e.pathname);
|
|
1093
1094
|
if (!t) {
|
|
1094
|
-
n(this,
|
|
1095
|
+
n(this, le).call(this, null), n(this, ue).call(this, e.pathname), n(this, he).call(this, {
|
|
1095
1096
|
wildcard: e.pathname
|
|
1096
1097
|
});
|
|
1097
1098
|
return;
|
|
1098
1099
|
}
|
|
1099
1100
|
if (t.meta.beforeMatch && await t.meta.beforeMatch({
|
|
1101
|
+
// TODO: Allow setting context variables from here.
|
|
1100
1102
|
redirect: (r) => {
|
|
1101
1103
|
throw new Error("Redirect not yet implemented.");
|
|
1102
1104
|
}
|
|
1103
|
-
}), n(this,
|
|
1105
|
+
}), n(this, O).info(`Matched route: '${t.pattern}' ('${t.path}')`), t.meta.redirect != null)
|
|
1104
1106
|
if (typeof t.meta.redirect == "string") {
|
|
1105
1107
|
const r = Qt(t.meta.redirect, t.params);
|
|
1106
|
-
n(this,
|
|
1108
|
+
n(this, O).info(`Redirecting to: '${r}'`), n(this, k).replace(r);
|
|
1107
1109
|
} else if (typeof t.meta.redirect == "function") {
|
|
1108
1110
|
const r = {
|
|
1109
1111
|
path: t.path,
|
|
@@ -1114,18 +1116,20 @@ Je = function(e, t = [], r = []) {
|
|
|
1114
1116
|
let i = await t.meta.redirect(r);
|
|
1115
1117
|
if (typeof i != "string")
|
|
1116
1118
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
1117
|
-
i.startsWith("/") || (i = De(t.path, i)), n(this,
|
|
1119
|
+
i.startsWith("/") || (i = De(t.path, i)), n(this, O).info(`Redirecting to: '${i}'`), n(this, k).replace(i);
|
|
1118
1120
|
} else
|
|
1119
1121
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
1120
|
-
else if (n(this,
|
|
1121
|
-
n(this,
|
|
1122
|
+
else if (n(this, ue).call(this, t.path), n(this, he).call(this, t.params), t.pattern !== this.$pattern.get()) {
|
|
1123
|
+
n(this, le).call(this, t.pattern);
|
|
1122
1124
|
const r = t.meta.layers;
|
|
1123
1125
|
for (let i = 0; i < r.length; i++) {
|
|
1124
1126
|
const s = r[i], o = n(this, W)[i];
|
|
1125
1127
|
if ((o == null ? void 0 : o.id) !== s.id) {
|
|
1126
|
-
n(this,
|
|
1127
|
-
const f = n(this, W).at(-1)
|
|
1128
|
-
o && o.node.isMounted && o.node.unmount()
|
|
1128
|
+
n(this, O).info(`Replacing layer @${i} (active ID: ${o == null ? void 0 : o.id}, matched ID: ${s.id})`), g(this, W, n(this, W).slice(0, i));
|
|
1129
|
+
const f = n(this, W).at(-1);
|
|
1130
|
+
o && o.node.isMounted && o.node.unmount();
|
|
1131
|
+
let c;
|
|
1132
|
+
f ? c = f.node.setChildView(s.view) : c = n(this, Z).rootView.setChildView(s.view), n(this, W).push({ id: s.id, node: c });
|
|
1129
1133
|
}
|
|
1130
1134
|
}
|
|
1131
1135
|
}
|
|
@@ -1152,7 +1156,7 @@ function Qt(a, e) {
|
|
|
1152
1156
|
}
|
|
1153
1157
|
return a;
|
|
1154
1158
|
}
|
|
1155
|
-
var F, Pe, I, te, Se, Re, xe,
|
|
1159
|
+
var F, Pe, I, te, Se, Re, xe, Oe, Me, R, G;
|
|
1156
1160
|
class Kt {
|
|
1157
1161
|
constructor() {
|
|
1158
1162
|
L(this, "http");
|
|
@@ -1163,11 +1167,11 @@ class Kt {
|
|
|
1163
1167
|
h(this, Pe, "production");
|
|
1164
1168
|
h(this, I);
|
|
1165
1169
|
h(this, te);
|
|
1166
|
-
h(this, Se,
|
|
1170
|
+
h(this, Se, Mt);
|
|
1167
1171
|
h(this, Re, []);
|
|
1168
1172
|
h(this, xe, []);
|
|
1173
|
+
h(this, Oe, []);
|
|
1169
1174
|
h(this, Me, []);
|
|
1170
|
-
h(this, Ne, []);
|
|
1171
1175
|
h(this, R, {
|
|
1172
1176
|
info: "development",
|
|
1173
1177
|
log: "development",
|
|
@@ -1175,17 +1179,17 @@ class Kt {
|
|
|
1175
1179
|
error: !0
|
|
1176
1180
|
});
|
|
1177
1181
|
h(this, G, rt("*,-dolla/*"));
|
|
1178
|
-
L(this, "
|
|
1179
|
-
L(this, "
|
|
1180
|
-
L(this, "
|
|
1181
|
-
L(this, "
|
|
1182
|
-
L(this, "
|
|
1182
|
+
L(this, "createState", K);
|
|
1183
|
+
L(this, "createSettableState", $t);
|
|
1184
|
+
L(this, "toSettableState", Et);
|
|
1185
|
+
L(this, "toState", Ge);
|
|
1186
|
+
L(this, "valueOf", kt);
|
|
1183
1187
|
L(this, "derive", Be);
|
|
1184
1188
|
L(this, "watch", ut);
|
|
1185
1189
|
L(this, "createRef", Lt);
|
|
1186
1190
|
L(this, "isRef", Pt);
|
|
1187
1191
|
const e = this;
|
|
1188
|
-
this.http = new
|
|
1192
|
+
this.http = new Nt(), this.language = new Dt(this), this.render = new Vt(this), this.router = new Ft(this, {
|
|
1189
1193
|
get rootElement() {
|
|
1190
1194
|
return n(e, I);
|
|
1191
1195
|
},
|
|
@@ -1212,33 +1216,33 @@ class Kt {
|
|
|
1212
1216
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1213
1217
|
*/
|
|
1214
1218
|
setEnv(e) {
|
|
1215
|
-
|
|
1219
|
+
g(this, Pe, e);
|
|
1216
1220
|
}
|
|
1217
1221
|
/**
|
|
1218
1222
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
1219
1223
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
1220
1224
|
*/
|
|
1221
1225
|
setCrashView(e) {
|
|
1222
|
-
|
|
1226
|
+
g(this, Se, e);
|
|
1223
1227
|
}
|
|
1224
1228
|
async mount(e, t) {
|
|
1225
1229
|
if (n(this, F))
|
|
1226
1230
|
throw new Error("Dolla is already mounted.");
|
|
1227
|
-
if (
|
|
1231
|
+
if (U(e)) {
|
|
1228
1232
|
const i = document.querySelector(e);
|
|
1229
|
-
nt(HTMLElement, i, `Selector '${e}' did not match any element.`),
|
|
1233
|
+
nt(HTMLElement, i, `Selector '${e}' did not match any element.`), g(this, I, i);
|
|
1230
1234
|
} else
|
|
1231
|
-
nt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"),
|
|
1235
|
+
nt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this, I, e);
|
|
1232
1236
|
let r;
|
|
1233
|
-
t ? r = at(t) : r = at(ht),
|
|
1237
|
+
t ? r = at(t) : r = at(ht), g(this, te, this.constructView(r.type, r.props)), await Promise.all(n(this, Re).map((i) => i())), n(this, te).mount(n(this, I)), g(this, F, !0);
|
|
1234
1238
|
for (const i of n(this, xe))
|
|
1235
1239
|
i();
|
|
1236
1240
|
}
|
|
1237
1241
|
async unmount() {
|
|
1238
1242
|
var e;
|
|
1239
1243
|
if (n(this, F)) {
|
|
1240
|
-
await Promise.all(n(this,
|
|
1241
|
-
for (const t of n(this,
|
|
1244
|
+
await Promise.all(n(this, Oe).map((t) => t())), (e = n(this, te)) == null || e.unmount(), g(this, F, !1);
|
|
1245
|
+
for (const t of n(this, Me))
|
|
1242
1246
|
t();
|
|
1243
1247
|
}
|
|
1244
1248
|
}
|
|
@@ -1260,13 +1264,13 @@ class Kt {
|
|
|
1260
1264
|
* it will be awaited before unmounting finishes. Use this to perform cleanup.
|
|
1261
1265
|
*/
|
|
1262
1266
|
beforeUnmount(e) {
|
|
1263
|
-
n(this,
|
|
1267
|
+
n(this, Oe).push(e);
|
|
1264
1268
|
}
|
|
1265
1269
|
/**
|
|
1266
1270
|
* Registers a `callback` to run after the app is unmounted.
|
|
1267
1271
|
*/
|
|
1268
1272
|
onUnmount(e) {
|
|
1269
|
-
n(this,
|
|
1273
|
+
n(this, Me).push(e);
|
|
1270
1274
|
}
|
|
1271
1275
|
/**
|
|
1272
1276
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1278,7 +1282,7 @@ class Kt {
|
|
|
1278
1282
|
}
|
|
1279
1283
|
}
|
|
1280
1284
|
setLogFilter(e) {
|
|
1281
|
-
|
|
1285
|
+
g(this, G, rt(e));
|
|
1282
1286
|
}
|
|
1283
1287
|
createLogger(e, t) {
|
|
1284
1288
|
const r = Ge(e), i = (t == null ? void 0 : t.console) ?? St(), s = this;
|
|
@@ -1286,8 +1290,8 @@ class Kt {
|
|
|
1286
1290
|
get info() {
|
|
1287
1291
|
var f;
|
|
1288
1292
|
const o = r.get();
|
|
1289
|
-
if (n(s, R).info === !1 ||
|
|
1290
|
-
return
|
|
1293
|
+
if (n(s, R).info === !1 || U(n(s, R).info) && n(s, R).info !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1294
|
+
return Ne;
|
|
1291
1295
|
{
|
|
1292
1296
|
let c = `%c${o}`;
|
|
1293
1297
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.info.bind(
|
|
@@ -1303,8 +1307,8 @@ class Kt {
|
|
|
1303
1307
|
get log() {
|
|
1304
1308
|
var f;
|
|
1305
1309
|
const o = r.get();
|
|
1306
|
-
if (n(s, R).log === !1 ||
|
|
1307
|
-
return
|
|
1310
|
+
if (n(s, R).log === !1 || U(n(s, R).log) && n(s, R).log !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1311
|
+
return Ne;
|
|
1308
1312
|
{
|
|
1309
1313
|
let c = `%c${o}`;
|
|
1310
1314
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.log.bind(
|
|
@@ -1320,8 +1324,8 @@ class Kt {
|
|
|
1320
1324
|
get warn() {
|
|
1321
1325
|
var f;
|
|
1322
1326
|
const o = r.get();
|
|
1323
|
-
if (n(s, R).warn === !1 ||
|
|
1324
|
-
return
|
|
1327
|
+
if (n(s, R).warn === !1 || U(n(s, R).warn) && n(s, R).warn !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1328
|
+
return Ne;
|
|
1325
1329
|
{
|
|
1326
1330
|
let c = `%c${o}`;
|
|
1327
1331
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.warn.bind(
|
|
@@ -1337,8 +1341,8 @@ class Kt {
|
|
|
1337
1341
|
get error() {
|
|
1338
1342
|
var f;
|
|
1339
1343
|
const o = r.get();
|
|
1340
|
-
if (n(s, R).error === !1 ||
|
|
1341
|
-
return
|
|
1344
|
+
if (n(s, R).error === !1 || U(n(s, R).error) && n(s, R).error !== s.getEnv() || !n(f = s, G).call(f, o))
|
|
1345
|
+
return Ne;
|
|
1342
1346
|
{
|
|
1343
1347
|
let c = `%c${o}`;
|
|
1344
1348
|
return t != null && t.uid ? c += ` %c[uid: %c${t.uid}%c]` : c += "%c%c%c", i.error.bind(
|
|
@@ -1364,33 +1368,33 @@ class Kt {
|
|
|
1364
1368
|
*
|
|
1365
1369
|
*/
|
|
1366
1370
|
constructView(e, t, r = []) {
|
|
1367
|
-
return Rt({ root: this }, e, t, r);
|
|
1371
|
+
return Rt({ root: this, data: {} }, e, t, r);
|
|
1368
1372
|
}
|
|
1369
1373
|
/**
|
|
1370
1374
|
*
|
|
1371
1375
|
*/
|
|
1372
1376
|
constructMarkup(e) {
|
|
1373
|
-
return xt(
|
|
1377
|
+
return xt(Ot({ root: this, data: {} }, e));
|
|
1374
1378
|
}
|
|
1375
1379
|
}
|
|
1376
|
-
F = new WeakMap(), Pe = new WeakMap(), I = new WeakMap(), te = new WeakMap(), Se = new WeakMap(), Re = new WeakMap(), xe = new WeakMap(),
|
|
1380
|
+
F = new WeakMap(), Pe = new WeakMap(), I = new WeakMap(), te = new WeakMap(), Se = new WeakMap(), Re = new WeakMap(), xe = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), R = new WeakMap(), G = new WeakMap();
|
|
1377
1381
|
const ct = new Kt(), Zt = ct.language.t.bind(ct.language);
|
|
1378
1382
|
export {
|
|
1379
|
-
|
|
1383
|
+
wt as cond,
|
|
1380
1384
|
at as createMarkup,
|
|
1381
1385
|
Lt as createRef,
|
|
1382
|
-
$t as
|
|
1383
|
-
|
|
1384
|
-
|
|
1386
|
+
$t as createSettableState,
|
|
1387
|
+
rr as createSetter,
|
|
1388
|
+
K as createState,
|
|
1385
1389
|
ct as default,
|
|
1386
1390
|
Be as derive,
|
|
1387
|
-
kt as designalify,
|
|
1388
1391
|
tt as html,
|
|
1389
1392
|
Pt as isRef,
|
|
1390
1393
|
nr as portal,
|
|
1391
1394
|
ar as repeat,
|
|
1392
|
-
Ge as signalify,
|
|
1393
1395
|
Zt as t,
|
|
1394
|
-
Et as
|
|
1396
|
+
Et as toSettableState,
|
|
1397
|
+
Ge as toState,
|
|
1398
|
+
kt as valueOf
|
|
1395
1399
|
};
|
|
1396
1400
|
//# sourceMappingURL=index.js.map
|