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