@manyducks.co/dolla 2.0.0-alpha.12 → 2.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +496 -498
- package/dist/index.js.map +1 -1
- package/dist/modules/i18n.d.ts +4 -4
- package/docs/http.md +5 -0
- package/docs/i18n.md +5 -0
- package/docs/router.md +5 -0
- package/docs/states.md +5 -0
- package/docs/views.md +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,17 +3,17 @@ var st = (i) => {
|
|
|
3
3
|
throw TypeError(i);
|
|
4
4
|
};
|
|
5
5
|
var Et = (i, e, t) => e in i ? kt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
6
|
-
var
|
|
7
|
-
var s = (i, e, t) => (Be(i, e, "read from private field"), t ? t.call(i) : e.get(i)),
|
|
8
|
-
var it = (i, e, t,
|
|
6
|
+
var P = (i, e, t) => Et(i, typeof e != "symbol" ? e + "" : e, t), Be = (i, e, t) => e.has(i) || st("Cannot " + t);
|
|
7
|
+
var s = (i, e, t) => (Be(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? st("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Be(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), k = (i, e, t) => (Be(i, e, "access private method"), t);
|
|
8
|
+
var it = (i, e, t, r) => ({
|
|
9
9
|
set _(a) {
|
|
10
10
|
b(i, e, a, t);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
|
-
return s(i, e,
|
|
13
|
+
return s(i, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as ot, c as Pt, i as Ke, t as Qe, d as ye, a as St, b as at, e as
|
|
16
|
+
import { h as ot, c as Pt, i as Ke, t as Qe, d as ye, a as St, b as at, e as F, f as lt, g as ie, j as pt, k as Rt, w as gt, P as mt, l as ct, m as xt, n as Lt, v as Nt, o as Ot, p as Mt, q as ut, r as ht, s as Tt, u as Ae, x as De, y as jt, z as At, A as Dt } from "./passthrough-Bz5ZF4jn.js";
|
|
17
17
|
import { B as cr, C as ur, D as hr } from "./passthrough-Bz5ZF4jn.js";
|
|
18
18
|
function _t(i) {
|
|
19
19
|
return ot`
|
|
@@ -62,12 +62,12 @@ function _t(i) {
|
|
|
62
62
|
</div>
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
|
-
var
|
|
65
|
+
var Y, Ge, T, _;
|
|
66
66
|
class Ct {
|
|
67
67
|
constructor() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
f(this, T);
|
|
69
|
+
f(this, Y, []);
|
|
70
|
+
f(this, Ge, Vt());
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -76,8 +76,8 @@ class Ct {
|
|
|
76
76
|
* @param middleware - A middleware function that will intercept requests.
|
|
77
77
|
*/
|
|
78
78
|
use(e) {
|
|
79
|
-
return s(this,
|
|
80
|
-
s(this,
|
|
79
|
+
return s(this, Y).push(e), () => {
|
|
80
|
+
s(this, Y).splice(s(this, Y).indexOf(e), 1);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
async get(e, t) {
|
|
@@ -105,12 +105,12 @@ class Ct {
|
|
|
105
105
|
return k(this, T, _).call(this, "trace", e, t);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
Y = new WeakMap(), Ge = new WeakMap(), T = new WeakSet(), _ = async function(e, t, r) {
|
|
109
109
|
return qt({
|
|
110
|
-
...
|
|
110
|
+
...r,
|
|
111
111
|
method: e,
|
|
112
112
|
uri: t,
|
|
113
|
-
middleware: s(this,
|
|
113
|
+
middleware: s(this, Y),
|
|
114
114
|
fetch: s(this, Ge)
|
|
115
115
|
});
|
|
116
116
|
};
|
|
@@ -123,18 +123,18 @@ function Vt() {
|
|
|
123
123
|
}
|
|
124
124
|
class Ft extends Error {
|
|
125
125
|
constructor(t) {
|
|
126
|
-
const { status:
|
|
127
|
-
super(
|
|
128
|
-
|
|
126
|
+
const { status: r, statusText: a, method: n, uri: o } = t, u = `${r} ${a}: Request failed (${n.toUpperCase()} ${o})`;
|
|
127
|
+
super(u);
|
|
128
|
+
P(this, "response");
|
|
129
129
|
this.response = t;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
async function qt(i) {
|
|
133
|
-
const { headers: e, query: t, fetch:
|
|
133
|
+
const { headers: e, query: t, fetch: r, middleware: a } = i, n = {
|
|
134
134
|
method: i.method,
|
|
135
135
|
uri: i.uri,
|
|
136
136
|
get sameOrigin() {
|
|
137
|
-
return !
|
|
137
|
+
return !n.uri.startsWith("http");
|
|
138
138
|
},
|
|
139
139
|
query: new URLSearchParams(),
|
|
140
140
|
headers: new Headers(),
|
|
@@ -142,69 +142,69 @@ async function qt(i) {
|
|
|
142
142
|
};
|
|
143
143
|
if (e)
|
|
144
144
|
if (e instanceof Map || e instanceof Headers)
|
|
145
|
-
e.forEach((l,
|
|
146
|
-
|
|
145
|
+
e.forEach((l, g) => {
|
|
146
|
+
n.headers.set(g, l);
|
|
147
147
|
});
|
|
148
148
|
else if (e != null && typeof e == "object" && !Array.isArray(e))
|
|
149
149
|
for (const l in e) {
|
|
150
|
-
const
|
|
151
|
-
|
|
150
|
+
const g = e[l];
|
|
151
|
+
g instanceof Date ? n.headers.set(l, g.toISOString()) : g != null && n.headers.set(l, String(g));
|
|
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((l,
|
|
158
|
-
|
|
157
|
+
t.forEach((l, g) => {
|
|
158
|
+
n.query.set(g, l);
|
|
159
159
|
});
|
|
160
160
|
else if (t != null && typeof t == "object" && !Array.isArray(t))
|
|
161
161
|
for (const l in t) {
|
|
162
|
-
const
|
|
163
|
-
|
|
162
|
+
const g = t[l];
|
|
163
|
+
g instanceof Date ? n.query.set(l, g.toISOString()) : g != null && n.query.set(l, String(g));
|
|
164
164
|
}
|
|
165
165
|
else
|
|
166
166
|
throw new TypeError(`Unknown query params type. Got: ${t}`);
|
|
167
167
|
let o;
|
|
168
|
-
const
|
|
169
|
-
const l =
|
|
170
|
-
let
|
|
171
|
-
!
|
|
172
|
-
const
|
|
173
|
-
method:
|
|
174
|
-
headers:
|
|
175
|
-
body:
|
|
176
|
-
}),
|
|
177
|
-
let
|
|
178
|
-
y != null && y.includes("application/json") ?
|
|
179
|
-
method:
|
|
180
|
-
uri:
|
|
181
|
-
status:
|
|
182
|
-
statusText:
|
|
183
|
-
headers:
|
|
184
|
-
body:
|
|
168
|
+
const u = async () => {
|
|
169
|
+
const l = n.query.toString(), g = l.length > 0 ? n.uri + "?" + l : n.uri;
|
|
170
|
+
let m;
|
|
171
|
+
!n.headers.has("content-type") && Ke(n.body) ? (n.headers.set("content-type", "application/json"), m = JSON.stringify(n.body)) : m = n.body;
|
|
172
|
+
const p = await r(g, {
|
|
173
|
+
method: n.method,
|
|
174
|
+
headers: n.headers,
|
|
175
|
+
body: m
|
|
176
|
+
}), h = Object.fromEntries(p.headers.entries()), y = h["content-type"];
|
|
177
|
+
let S;
|
|
178
|
+
y != null && y.includes("application/json") ? S = await p.json() : y != null && y.includes("application/x-www-form-urlencoded") ? S = await p.formData() : S = await p.text(), o = {
|
|
179
|
+
method: n.method,
|
|
180
|
+
uri: n.uri,
|
|
181
|
+
status: p.status,
|
|
182
|
+
statusText: p.statusText,
|
|
183
|
+
headers: h,
|
|
184
|
+
body: S
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
187
|
if (a.length > 0) {
|
|
188
|
-
const l = (
|
|
189
|
-
const
|
|
190
|
-
return async () =>
|
|
188
|
+
const l = (g = 0) => {
|
|
189
|
+
const m = a[g], p = a[g + 1] ? l(g + 1) : u;
|
|
190
|
+
return async () => m(n, async () => (await p(), o));
|
|
191
191
|
};
|
|
192
192
|
await l()();
|
|
193
193
|
} else
|
|
194
|
-
await
|
|
194
|
+
await u();
|
|
195
195
|
if (o.status < 200 || o.status >= 400)
|
|
196
196
|
throw new Ft(o);
|
|
197
197
|
return o;
|
|
198
198
|
}
|
|
199
199
|
const Ut = Qe("[NO LANGUAGE SET]");
|
|
200
|
-
var We,
|
|
200
|
+
var We, oe, re, Je, wt;
|
|
201
201
|
class Ht {
|
|
202
202
|
constructor(e, t) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
f(this, re);
|
|
204
|
+
P(this, "dolla");
|
|
205
|
+
P(this, "config");
|
|
206
|
+
f(this, We, !1);
|
|
207
|
+
f(this, oe, /* @__PURE__ */ new Map());
|
|
208
208
|
this.config = e, this.dolla = t;
|
|
209
209
|
}
|
|
210
210
|
async load() {
|
|
@@ -213,7 +213,7 @@ class Ht {
|
|
|
213
213
|
if (at(this.config.fetch)) {
|
|
214
214
|
if (e = await this.config.fetch(), !Ke(e))
|
|
215
215
|
throw new Error(`Fetch function did not return an object of language strings: ${e}`);
|
|
216
|
-
} else if (
|
|
216
|
+
} else if (F(this.config.path)) {
|
|
217
217
|
const t = await this.dolla.http.get(this.config.path);
|
|
218
218
|
if (t.status >= 200 && t.status < 300)
|
|
219
219
|
if (Ke(t.body))
|
|
@@ -229,99 +229,98 @@ class Ht {
|
|
|
229
229
|
if (e == null)
|
|
230
230
|
throw new Error("Language could not be loaded.");
|
|
231
231
|
{
|
|
232
|
-
const t = k(this,
|
|
233
|
-
for (const
|
|
234
|
-
s(this,
|
|
235
|
-
console.log(t);
|
|
232
|
+
const t = k(this, re, Je).call(this, e);
|
|
233
|
+
for (const r of t)
|
|
234
|
+
s(this, oe).set(r[0], r[1]);
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
getTemplate(e) {
|
|
239
|
-
return s(this,
|
|
238
|
+
return s(this, oe).get(e) ?? null;
|
|
240
239
|
}
|
|
241
240
|
hasTemplate(e) {
|
|
242
|
-
return s(this,
|
|
241
|
+
return s(this, oe).has(e);
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
|
-
We = new WeakMap(),
|
|
246
|
-
const
|
|
244
|
+
We = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), Je = function(e, t = []) {
|
|
245
|
+
const r = [];
|
|
247
246
|
for (const a in e)
|
|
248
247
|
switch (lt(e[a])) {
|
|
249
248
|
case "string":
|
|
250
|
-
|
|
249
|
+
r.push([[...t, a].join("."), k(this, re, wt).call(this, e[a])]);
|
|
251
250
|
break;
|
|
252
251
|
case "object":
|
|
253
|
-
|
|
252
|
+
r.push(...k(this, re, Je).call(this, e[a], [...t, a]));
|
|
254
253
|
break;
|
|
255
254
|
default:
|
|
256
255
|
throw new Error(
|
|
257
256
|
`Expected to find a string or object at ${[...t, a].join(".")}. Got: ${lt(e[a])}`
|
|
258
257
|
);
|
|
259
258
|
}
|
|
260
|
-
return
|
|
259
|
+
return r;
|
|
261
260
|
}, wt = function(e) {
|
|
262
261
|
let t;
|
|
263
|
-
((
|
|
264
|
-
|
|
262
|
+
((h) => {
|
|
263
|
+
h[h.Static = 0] = "Static", h[h.ValueName = 1] = "ValueName", h[h.FormatName = 2] = "FormatName", h[h.FormatOptionName = 3] = "FormatOptionName", h[h.FormatOptionValue = 4] = "FormatOptionValue", h[h.FormatOptionEnd = 5] = "FormatOptionEnd";
|
|
265
264
|
})(t || (t = {}));
|
|
266
|
-
const
|
|
265
|
+
const r = {
|
|
267
266
|
segments: []
|
|
268
267
|
};
|
|
269
|
-
let a = "",
|
|
270
|
-
const
|
|
271
|
-
|
|
268
|
+
let a = "", n = 0, o = 0, u, l, g;
|
|
269
|
+
const m = () => {
|
|
270
|
+
u = {
|
|
272
271
|
type: 1,
|
|
273
272
|
name: "",
|
|
274
273
|
formats: []
|
|
275
274
|
};
|
|
276
|
-
},
|
|
275
|
+
}, p = () => {
|
|
277
276
|
l = {
|
|
278
277
|
name: "",
|
|
279
278
|
options: {}
|
|
280
279
|
};
|
|
281
280
|
};
|
|
282
|
-
for (;
|
|
283
|
-
if (o !== 0 && e[
|
|
284
|
-
|
|
281
|
+
for (; n < e.length; ) {
|
|
282
|
+
if (o !== 0 && e[n] === " ") {
|
|
283
|
+
n++;
|
|
285
284
|
continue;
|
|
286
285
|
}
|
|
287
286
|
switch (o) {
|
|
288
287
|
case 0:
|
|
289
|
-
e[
|
|
288
|
+
e[n] === "{" && e[n + 1] === "{" ? (o = 1, n += 2, a.length > 0 && (r.segments.push({ type: 0, text: a }), a = ""), m()) : (a += e[n], n++);
|
|
290
289
|
break;
|
|
291
290
|
case 1:
|
|
292
|
-
e[
|
|
291
|
+
e[n] === "|" ? (o = 2, n += 1, u.name = a, a = "", p()) : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, u.name = a, a = "", r.segments.push(u)) : (a += e[n], n++);
|
|
293
292
|
break;
|
|
294
293
|
case 2:
|
|
295
|
-
e[
|
|
294
|
+
e[n] === "(" ? (o = 3, n += 1, l.name = a, a = "") : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, u.formats.push(l), r.segments.push(u)) : (a += e[n], n++);
|
|
296
295
|
break;
|
|
297
296
|
case 3:
|
|
298
|
-
e[
|
|
297
|
+
e[n] === ")" || (e[n] === ":" ? (o = 4, n += 1, g = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++));
|
|
299
298
|
break;
|
|
300
299
|
case 4:
|
|
301
|
-
e[
|
|
300
|
+
e[n] === ")" ? (o = 5, n += 1, l.options[g] = a, a = "", u.formats.push(l)) : e[n] === "," ? (o = 3, n += 1, l.options[g] = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++);
|
|
302
301
|
break;
|
|
303
302
|
case 5:
|
|
304
|
-
e[
|
|
303
|
+
e[n] === "|" ? (o = 2, n += 1, p()) : e[n] === "}" && e[n + 1] === "}" && (o = 0, n += 2, r.segments.push(u));
|
|
305
304
|
break;
|
|
306
305
|
}
|
|
307
306
|
}
|
|
308
|
-
return o === 0 && a.length > 0 &&
|
|
307
|
+
return o === 0 && a.length > 0 && r.segments.push({ type: 0, text: a }), r;
|
|
309
308
|
};
|
|
310
|
-
var ve,
|
|
309
|
+
var ve, q, L, $e, U, ke, Ee, N, yt, Ye, Xe, Ze, bt;
|
|
311
310
|
class It {
|
|
312
311
|
constructor(e) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
b(this, ve, e), b(this,
|
|
323
|
-
const [t,
|
|
324
|
-
this.$locale = t, b(this, Ee,
|
|
312
|
+
f(this, N);
|
|
313
|
+
f(this, ve);
|
|
314
|
+
f(this, q);
|
|
315
|
+
f(this, L, /* @__PURE__ */ new Map());
|
|
316
|
+
f(this, $e, []);
|
|
317
|
+
f(this, U, /* @__PURE__ */ new Map());
|
|
318
|
+
f(this, ke, "auto");
|
|
319
|
+
P(this, "$locale");
|
|
320
|
+
f(this, Ee);
|
|
321
|
+
b(this, ve, e), b(this, q, e.createLogger("dolla/i18n"));
|
|
322
|
+
const [t, r] = ie();
|
|
323
|
+
this.$locale = t, b(this, Ee, r), s(this, U).set("number", (a, n, o) => k(this, N, Ye).call(this, Number(n), o)), s(this, U).set("datetime", (a, n, o) => k(this, N, Xe).call(this, n, o)), s(this, U).set("list", (a, n, o) => k(this, N, Ze).call(this, n, o)), e.beforeMount(async () => {
|
|
325
324
|
s(this, L).size > 0 && await this.setLocale(s(this, ke));
|
|
326
325
|
});
|
|
327
326
|
}
|
|
@@ -332,11 +331,11 @@ class It {
|
|
|
332
331
|
if (e.translations.forEach((t) => {
|
|
333
332
|
s(this, L).set(t.locale, new Ht(t, s(this, ve)));
|
|
334
333
|
}), e.locale && e.locale !== "auto") {
|
|
335
|
-
if (!e.translations.some((
|
|
334
|
+
if (!e.translations.some((r) => r.locale === e.locale))
|
|
336
335
|
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
337
336
|
b(this, ke, e.locale);
|
|
338
337
|
}
|
|
339
|
-
s(this,
|
|
338
|
+
s(this, q).info(
|
|
340
339
|
`${s(this, L).size} language${s(this, L).size === 1 ? "" : "s"} supported: '${[...s(this, L).keys()].join("', '")}'`
|
|
341
340
|
);
|
|
342
341
|
}
|
|
@@ -344,26 +343,26 @@ class It {
|
|
|
344
343
|
var a;
|
|
345
344
|
let t;
|
|
346
345
|
if (e === "auto") {
|
|
347
|
-
let
|
|
346
|
+
let n = [];
|
|
348
347
|
if (typeof navigator == "object") {
|
|
349
348
|
const o = navigator;
|
|
350
|
-
((a = o.languages) == null ? void 0 : a.length) > 0 ?
|
|
349
|
+
((a = o.languages) == null ? void 0 : a.length) > 0 ? n.push(...o.languages) : o.language ? n.push(o.language) : o.browserLanguage ? n.push(o.browserLanguage) : o.userLanguage && n.push(o.userLanguage);
|
|
351
350
|
}
|
|
352
|
-
for (const o of
|
|
351
|
+
for (const o of n)
|
|
353
352
|
s(this, L).has(o) && (t = o);
|
|
354
353
|
} else
|
|
355
354
|
s(this, L).has(e) && (t = e);
|
|
356
355
|
if (t == null) {
|
|
357
|
-
const
|
|
358
|
-
|
|
356
|
+
const n = s(this, L).keys().next().value;
|
|
357
|
+
n && (t = n);
|
|
359
358
|
}
|
|
360
359
|
if (!t || !s(this, L).has(t))
|
|
361
360
|
throw new Error(`Language '${e}' is not configured for this app.`);
|
|
362
|
-
const
|
|
361
|
+
const r = s(this, L).get(t);
|
|
363
362
|
try {
|
|
364
|
-
await
|
|
365
|
-
} catch (
|
|
366
|
-
|
|
363
|
+
await r.load(), b(this, $e, []), s(this, Ee).call(this, t), s(this, q).info("set language to " + t);
|
|
364
|
+
} catch (n) {
|
|
365
|
+
n instanceof Error && s(this, q).crash(n);
|
|
367
366
|
}
|
|
368
367
|
}
|
|
369
368
|
/**
|
|
@@ -382,30 +381,32 @@ class It {
|
|
|
382
381
|
);
|
|
383
382
|
if (!this.$locale.get())
|
|
384
383
|
return Ut;
|
|
385
|
-
let
|
|
386
|
-
for (const
|
|
387
|
-
|
|
388
|
-
return ye(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
384
|
+
let r = [], a = [];
|
|
385
|
+
for (const n in t)
|
|
386
|
+
r.push(n), a.push(t[n]);
|
|
387
|
+
return ye([this.$locale, ...a], (n, ...o) => {
|
|
388
|
+
const u = {};
|
|
389
|
+
for (let l = 0; l < o.length; l++)
|
|
390
|
+
u[r[l]] = o[l];
|
|
391
|
+
return k(this, N, yt).call(this, n, e, u);
|
|
392
|
+
});
|
|
392
393
|
}
|
|
393
394
|
/**
|
|
394
395
|
* Add a custom format callback.
|
|
395
396
|
*
|
|
396
397
|
* @example
|
|
397
|
-
* Dolla.i18n.addFormat("
|
|
398
|
-
*
|
|
398
|
+
* Dolla.i18n.addFormat("uppercase", (locale, value, options) => {
|
|
399
|
+
* return value.toUpperCase();
|
|
399
400
|
* });
|
|
400
401
|
*
|
|
401
402
|
* {
|
|
402
|
-
* "
|
|
403
|
+
* "greeting": "Hello, {{name|uppercase}}!"
|
|
403
404
|
* }
|
|
404
405
|
*
|
|
405
|
-
* t("
|
|
406
|
+
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
406
407
|
*/
|
|
407
408
|
addFormat(e, t) {
|
|
408
|
-
s(this,
|
|
409
|
+
s(this, U).set(e, t);
|
|
409
410
|
}
|
|
410
411
|
/**
|
|
411
412
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
@@ -422,7 +423,7 @@ class It {
|
|
|
422
423
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
423
424
|
*/
|
|
424
425
|
number(e, t) {
|
|
425
|
-
return ye([this.$locale, e], (
|
|
426
|
+
return ye([this.$locale, e], (r, a) => k(this, N, Ye).call(this, a, t));
|
|
426
427
|
}
|
|
427
428
|
/**
|
|
428
429
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -434,7 +435,7 @@ class It {
|
|
|
434
435
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
435
436
|
*/
|
|
436
437
|
dateTime(e, t) {
|
|
437
|
-
return ye([this.$locale, e], (
|
|
438
|
+
return ye([this.$locale, e], (r, a) => k(this, N, Xe).call(this, a, t));
|
|
438
439
|
}
|
|
439
440
|
/**
|
|
440
441
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -446,48 +447,45 @@ class It {
|
|
|
446
447
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
447
448
|
*/
|
|
448
449
|
list(e, t) {
|
|
449
|
-
return ye([this.$locale, e], (
|
|
450
|
+
return ye([this.$locale, e], (r, a) => k(this, N, Ze).call(this, a, t));
|
|
450
451
|
}
|
|
451
452
|
}
|
|
452
|
-
ve = new WeakMap(),
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const o = k(this, N, bt).call(this, t, r);
|
|
457
|
-
if (o) return o;
|
|
458
|
-
const h = s(this, L).get(e);
|
|
453
|
+
ve = new WeakMap(), q = new WeakMap(), L = new WeakMap(), $e = new WeakMap(), U = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), N = new WeakSet(), yt = function(e, t, r) {
|
|
454
|
+
const a = k(this, N, bt).call(this, t, r);
|
|
455
|
+
if (a) return a;
|
|
456
|
+
const n = s(this, L).get(e);
|
|
459
457
|
if (r.context != null && (t += "_" + r.context), r.count != null)
|
|
460
458
|
if (r.ordinal) {
|
|
461
|
-
const
|
|
462
|
-
|
|
459
|
+
const l = `${t}_ordinal_(=${r.count})`;
|
|
460
|
+
n.hasTemplate(l) ? t = l : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(r.count);
|
|
463
461
|
} else {
|
|
464
|
-
const
|
|
465
|
-
|
|
462
|
+
const l = `${t}_(=${r.count})`;
|
|
463
|
+
n.hasTemplate(l) ? t = l : t += "_" + new Intl.PluralRules(e).select(r.count);
|
|
466
464
|
}
|
|
467
|
-
const
|
|
465
|
+
const o = n.getTemplate(t) || {
|
|
468
466
|
segments: [{ type: 0, text: `[MISSING: ${t}]` }]
|
|
469
467
|
};
|
|
470
|
-
let
|
|
471
|
-
for (const
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
else if (
|
|
475
|
-
const g = [...
|
|
476
|
-
let
|
|
477
|
-
|
|
478
|
-
for (const
|
|
479
|
-
const
|
|
480
|
-
if (
|
|
481
|
-
const
|
|
482
|
-
`Failed to load format '${
|
|
468
|
+
let u = "";
|
|
469
|
+
for (const l of o.segments)
|
|
470
|
+
if (l.type === 0)
|
|
471
|
+
u += l.text;
|
|
472
|
+
else if (l.type === 1) {
|
|
473
|
+
const g = [...l.formats];
|
|
474
|
+
let m = Gt(r, l.name);
|
|
475
|
+
l.name === "count" && g.length === 0 && g.push({ name: "number", options: {} });
|
|
476
|
+
for (const p of g) {
|
|
477
|
+
const h = s(this, U).get(p.name);
|
|
478
|
+
if (h == null) {
|
|
479
|
+
const y = new Error(
|
|
480
|
+
`Failed to load format '${p.name}' when processing '${t}', template: ${o}`
|
|
483
481
|
);
|
|
484
|
-
throw s(this,
|
|
482
|
+
throw s(this, q).crash(y), y;
|
|
485
483
|
}
|
|
486
|
-
|
|
484
|
+
m = h(e, m, p.options);
|
|
487
485
|
}
|
|
488
|
-
|
|
486
|
+
u += m;
|
|
489
487
|
}
|
|
490
|
-
return
|
|
488
|
+
return u;
|
|
491
489
|
}, Ye = function(e, t) {
|
|
492
490
|
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
493
491
|
}, Xe = function(e, t) {
|
|
@@ -499,34 +497,34 @@ ve = new WeakMap(), U = new WeakMap(), L = new WeakMap(), $e = new WeakMap(), H
|
|
|
499
497
|
}, // relativeTime(): State<string> {
|
|
500
498
|
// }
|
|
501
499
|
bt = function(e, t) {
|
|
502
|
-
for (const
|
|
503
|
-
if (
|
|
504
|
-
return
|
|
500
|
+
for (const r of s(this, $e))
|
|
501
|
+
if (r[0] === e && St(r[1], t))
|
|
502
|
+
return r[2];
|
|
505
503
|
};
|
|
506
504
|
function Gt(i, e) {
|
|
507
505
|
const t = String(e).split(/[\.\[\]]/).filter((a) => a.trim() !== "");
|
|
508
|
-
let
|
|
506
|
+
let r = i;
|
|
509
507
|
for (; t.length > 0; ) {
|
|
510
508
|
const a = t.shift();
|
|
511
|
-
|
|
509
|
+
r != null ? r = r[a] : r = void 0;
|
|
512
510
|
}
|
|
513
|
-
return
|
|
511
|
+
return r;
|
|
514
512
|
}
|
|
515
|
-
var
|
|
513
|
+
var X, Pe, H, I, le, C, ce, _e;
|
|
516
514
|
class Wt {
|
|
517
515
|
constructor(e) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
516
|
+
f(this, ce);
|
|
517
|
+
f(this, X);
|
|
518
|
+
f(this, Pe);
|
|
521
519
|
// Keyed updates ensure only the most recent callback queued with a certain key
|
|
522
520
|
// will be called, keeping DOM operations to a minimum.
|
|
523
|
-
|
|
521
|
+
f(this, H, /* @__PURE__ */ new Map());
|
|
524
522
|
// All unkeyed updates are run on every batch.
|
|
525
|
-
|
|
523
|
+
f(this, I, []);
|
|
526
524
|
// All read callbacks are run before updates on every batch.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
b(this,
|
|
525
|
+
f(this, le, []);
|
|
526
|
+
f(this, C, !1);
|
|
527
|
+
b(this, X, e), b(this, Pe, e.createLogger("dolla/render"));
|
|
530
528
|
}
|
|
531
529
|
/**
|
|
532
530
|
* Queues a callback to run in the next render batch.
|
|
@@ -534,12 +532,12 @@ class Wt {
|
|
|
534
532
|
* Returns a Promise that resolves once the callback has run.
|
|
535
533
|
*/
|
|
536
534
|
update(e, t) {
|
|
537
|
-
return new Promise((
|
|
538
|
-
t ? s(this,
|
|
539
|
-
e(),
|
|
540
|
-
}) : s(this,
|
|
541
|
-
e(),
|
|
542
|
-
}), !s(this, C) && s(this,
|
|
535
|
+
return new Promise((r) => {
|
|
536
|
+
t ? s(this, H).set(t, () => {
|
|
537
|
+
e(), r();
|
|
538
|
+
}) : s(this, I).push(() => {
|
|
539
|
+
e(), r();
|
|
540
|
+
}), !s(this, C) && s(this, X).isMounted && (b(this, C, !0), k(this, ce, _e).call(this));
|
|
543
541
|
});
|
|
544
542
|
}
|
|
545
543
|
/**
|
|
@@ -549,38 +547,38 @@ class Wt {
|
|
|
549
547
|
*/
|
|
550
548
|
read(e) {
|
|
551
549
|
return new Promise((t) => {
|
|
552
|
-
s(this,
|
|
550
|
+
s(this, le).push(() => {
|
|
553
551
|
e(), t();
|
|
554
|
-
}), !s(this, C) && s(this,
|
|
552
|
+
}), !s(this, C) && s(this, X).isMounted && (b(this, C, !0), k(this, ce, _e).call(this));
|
|
555
553
|
});
|
|
556
554
|
}
|
|
557
555
|
}
|
|
558
|
-
|
|
559
|
-
const e = s(this,
|
|
560
|
-
if ((!s(this,
|
|
561
|
-
for (const t of s(this,
|
|
556
|
+
X = new WeakMap(), Pe = new WeakMap(), H = new WeakMap(), I = new WeakMap(), le = new WeakMap(), C = new WeakMap(), ce = new WeakSet(), _e = function() {
|
|
557
|
+
const e = s(this, H).size + s(this, I).length;
|
|
558
|
+
if ((!s(this, X).isMounted || e === 0) && b(this, C, !1), !s(this, C)) {
|
|
559
|
+
for (const t of s(this, le))
|
|
562
560
|
t();
|
|
563
|
-
b(this,
|
|
561
|
+
b(this, le, []);
|
|
564
562
|
return;
|
|
565
563
|
}
|
|
566
564
|
requestAnimationFrame(() => {
|
|
567
|
-
s(this, Pe).info(`Batching ${s(this,
|
|
568
|
-
for (const t of s(this,
|
|
565
|
+
s(this, Pe).info(`Batching ${s(this, H).size + s(this, I).length} queued DOM update(s).`);
|
|
566
|
+
for (const t of s(this, H).values())
|
|
569
567
|
t();
|
|
570
|
-
s(this,
|
|
571
|
-
for (const t of s(this,
|
|
568
|
+
s(this, H).clear();
|
|
569
|
+
for (const t of s(this, I))
|
|
572
570
|
t();
|
|
573
|
-
b(this,
|
|
571
|
+
b(this, I, []), k(this, ce, _e).call(this);
|
|
574
572
|
});
|
|
575
573
|
};
|
|
576
|
-
function
|
|
577
|
-
return
|
|
574
|
+
function de() {
|
|
575
|
+
return de = Object.assign ? Object.assign.bind() : function(i) {
|
|
578
576
|
for (var e = 1; e < arguments.length; e++) {
|
|
579
577
|
var t = arguments[e];
|
|
580
|
-
for (var
|
|
578
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
|
|
581
579
|
}
|
|
582
580
|
return i;
|
|
583
|
-
},
|
|
581
|
+
}, de.apply(null, arguments);
|
|
584
582
|
}
|
|
585
583
|
var A;
|
|
586
584
|
(function(i) {
|
|
@@ -603,33 +601,33 @@ function Ce(i, e) {
|
|
|
603
601
|
var Ue = "beforeunload", zt = "hashchange", vt = "popstate";
|
|
604
602
|
function Bt(i) {
|
|
605
603
|
i === void 0 && (i = {});
|
|
606
|
-
var e = i, t = e.window,
|
|
607
|
-
function
|
|
608
|
-
var w =
|
|
604
|
+
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
|
|
605
|
+
function n() {
|
|
606
|
+
var w = r.location, c = w.pathname, d = w.search, v = w.hash, $ = a.state || {};
|
|
609
607
|
return [$.idx, qe({
|
|
610
608
|
pathname: c,
|
|
611
|
-
search:
|
|
609
|
+
search: d,
|
|
612
610
|
hash: v,
|
|
613
611
|
state: $.usr || null,
|
|
614
612
|
key: $.key || "default"
|
|
615
613
|
})];
|
|
616
614
|
}
|
|
617
615
|
var o = null;
|
|
618
|
-
function
|
|
616
|
+
function u() {
|
|
619
617
|
if (o)
|
|
620
618
|
y.call(o), o = null;
|
|
621
619
|
else {
|
|
622
|
-
var w = A.Pop, c =
|
|
620
|
+
var w = A.Pop, c = n(), d = c[0], v = c[1];
|
|
623
621
|
if (y.length)
|
|
624
|
-
if (
|
|
625
|
-
var $ =
|
|
622
|
+
if (d != null) {
|
|
623
|
+
var $ = m - d;
|
|
626
624
|
$ && (o = {
|
|
627
625
|
action: w,
|
|
628
626
|
location: v,
|
|
629
627
|
retry: function() {
|
|
630
|
-
|
|
628
|
+
V($ * -1);
|
|
631
629
|
}
|
|
632
|
-
},
|
|
630
|
+
}, V($));
|
|
633
631
|
} else
|
|
634
632
|
process.env.NODE_ENV !== "production" && Ce(
|
|
635
633
|
!1,
|
|
@@ -639,20 +637,20 @@ function Bt(i) {
|
|
|
639
637
|
"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."
|
|
640
638
|
);
|
|
641
639
|
else
|
|
642
|
-
|
|
640
|
+
ne(w);
|
|
643
641
|
}
|
|
644
642
|
}
|
|
645
|
-
|
|
646
|
-
var l = A.Pop,
|
|
647
|
-
|
|
648
|
-
idx:
|
|
643
|
+
r.addEventListener(vt, u);
|
|
644
|
+
var l = A.Pop, g = n(), m = g[0], p = g[1], h = Ie(), y = Ie();
|
|
645
|
+
m == null && (m = 0, a.replaceState(de({}, a.state, {
|
|
646
|
+
idx: m
|
|
649
647
|
}), ""));
|
|
650
|
-
function
|
|
648
|
+
function S(w) {
|
|
651
649
|
return typeof w == "string" ? w : Ve(w);
|
|
652
650
|
}
|
|
653
|
-
function
|
|
654
|
-
return c === void 0 && (c = null), qe(
|
|
655
|
-
pathname:
|
|
651
|
+
function pe(w, c) {
|
|
652
|
+
return c === void 0 && (c = null), qe(de({
|
|
653
|
+
pathname: p.pathname,
|
|
656
654
|
hash: "",
|
|
657
655
|
search: ""
|
|
658
656
|
}, typeof w == "string" ? et(w) : w, {
|
|
@@ -665,85 +663,85 @@ function Bt(i) {
|
|
|
665
663
|
usr: w.state,
|
|
666
664
|
key: w.key,
|
|
667
665
|
idx: c
|
|
668
|
-
},
|
|
666
|
+
}, S(w)];
|
|
669
667
|
}
|
|
670
|
-
function me(w, c,
|
|
668
|
+
function me(w, c, d) {
|
|
671
669
|
return !y.length || (y.call({
|
|
672
670
|
action: w,
|
|
673
671
|
location: c,
|
|
674
|
-
retry:
|
|
672
|
+
retry: d
|
|
675
673
|
}), !1);
|
|
676
674
|
}
|
|
677
|
-
function
|
|
675
|
+
function ne(w) {
|
|
678
676
|
l = w;
|
|
679
|
-
var c =
|
|
680
|
-
|
|
677
|
+
var c = n();
|
|
678
|
+
m = c[0], p = c[1], h.call({
|
|
681
679
|
action: l,
|
|
682
|
-
location:
|
|
680
|
+
location: p
|
|
683
681
|
});
|
|
684
682
|
}
|
|
685
|
-
function
|
|
686
|
-
var
|
|
683
|
+
function ae(w, c) {
|
|
684
|
+
var d = A.Push, v = pe(w, c);
|
|
687
685
|
function $() {
|
|
688
|
-
|
|
686
|
+
ae(w, c);
|
|
689
687
|
}
|
|
690
|
-
if (me(
|
|
691
|
-
var R = ge(v,
|
|
688
|
+
if (me(d, v, $)) {
|
|
689
|
+
var R = ge(v, m + 1), O = R[0], j = R[1];
|
|
692
690
|
try {
|
|
693
691
|
a.pushState(O, "", j);
|
|
694
692
|
} catch {
|
|
695
|
-
|
|
693
|
+
r.location.assign(j);
|
|
696
694
|
}
|
|
697
|
-
|
|
695
|
+
ne(d);
|
|
698
696
|
}
|
|
699
697
|
}
|
|
700
698
|
function we(w, c) {
|
|
701
|
-
var
|
|
699
|
+
var d = A.Replace, v = pe(w, c);
|
|
702
700
|
function $() {
|
|
703
701
|
we(w, c);
|
|
704
702
|
}
|
|
705
|
-
if (me(
|
|
706
|
-
var R = ge(v,
|
|
707
|
-
a.replaceState(O, "", j),
|
|
703
|
+
if (me(d, v, $)) {
|
|
704
|
+
var R = ge(v, m), O = R[0], j = R[1];
|
|
705
|
+
a.replaceState(O, "", j), ne(d);
|
|
708
706
|
}
|
|
709
707
|
}
|
|
710
|
-
function
|
|
708
|
+
function V(w) {
|
|
711
709
|
a.go(w);
|
|
712
710
|
}
|
|
713
|
-
var
|
|
711
|
+
var J = {
|
|
714
712
|
get action() {
|
|
715
713
|
return l;
|
|
716
714
|
},
|
|
717
715
|
get location() {
|
|
718
|
-
return
|
|
716
|
+
return p;
|
|
719
717
|
},
|
|
720
|
-
createHref:
|
|
721
|
-
push:
|
|
718
|
+
createHref: S,
|
|
719
|
+
push: ae,
|
|
722
720
|
replace: we,
|
|
723
|
-
go:
|
|
721
|
+
go: V,
|
|
724
722
|
back: function() {
|
|
725
|
-
|
|
723
|
+
V(-1);
|
|
726
724
|
},
|
|
727
725
|
forward: function() {
|
|
728
|
-
|
|
726
|
+
V(1);
|
|
729
727
|
},
|
|
730
728
|
listen: function(c) {
|
|
731
|
-
return
|
|
729
|
+
return h.push(c);
|
|
732
730
|
},
|
|
733
731
|
block: function(c) {
|
|
734
|
-
var
|
|
735
|
-
return y.length === 1 &&
|
|
736
|
-
|
|
732
|
+
var d = y.push(c);
|
|
733
|
+
return y.length === 1 && r.addEventListener(Ue, He), function() {
|
|
734
|
+
d(), y.length || r.removeEventListener(Ue, He);
|
|
737
735
|
};
|
|
738
736
|
}
|
|
739
737
|
};
|
|
740
|
-
return
|
|
738
|
+
return J;
|
|
741
739
|
}
|
|
742
740
|
function Kt(i) {
|
|
743
741
|
i === void 0 && (i = {});
|
|
744
|
-
var e = i, t = e.window,
|
|
745
|
-
function
|
|
746
|
-
var c = et(
|
|
742
|
+
var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
|
|
743
|
+
function n() {
|
|
744
|
+
var c = et(r.location.hash.substr(1)), d = c.pathname, v = d === void 0 ? "/" : d, $ = c.search, R = $ === void 0 ? "" : $, O = c.hash, j = O === void 0 ? "" : O, D = a.state || {};
|
|
747
745
|
return [D.idx, qe({
|
|
748
746
|
pathname: v,
|
|
749
747
|
search: R,
|
|
@@ -753,21 +751,21 @@ function Kt(i) {
|
|
|
753
751
|
})];
|
|
754
752
|
}
|
|
755
753
|
var o = null;
|
|
756
|
-
function
|
|
754
|
+
function u() {
|
|
757
755
|
if (o)
|
|
758
756
|
y.call(o), o = null;
|
|
759
757
|
else {
|
|
760
|
-
var c = A.Pop,
|
|
758
|
+
var c = A.Pop, d = n(), v = d[0], $ = d[1];
|
|
761
759
|
if (y.length)
|
|
762
760
|
if (v != null) {
|
|
763
|
-
var R =
|
|
761
|
+
var R = m - v;
|
|
764
762
|
R && (o = {
|
|
765
763
|
action: c,
|
|
766
764
|
location: $,
|
|
767
765
|
retry: function() {
|
|
768
|
-
|
|
766
|
+
J(R * -1);
|
|
769
767
|
}
|
|
770
|
-
},
|
|
768
|
+
}, J(R));
|
|
771
769
|
} else
|
|
772
770
|
process.env.NODE_ENV !== "production" && Ce(
|
|
773
771
|
!1,
|
|
@@ -777,86 +775,86 @@ function Kt(i) {
|
|
|
777
775
|
"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."
|
|
778
776
|
);
|
|
779
777
|
else
|
|
780
|
-
|
|
778
|
+
ae(c);
|
|
781
779
|
}
|
|
782
780
|
}
|
|
783
|
-
|
|
784
|
-
var c =
|
|
785
|
-
Ve(
|
|
781
|
+
r.addEventListener(vt, u), r.addEventListener(zt, function() {
|
|
782
|
+
var c = n(), d = c[1];
|
|
783
|
+
Ve(d) !== Ve(p) && u();
|
|
786
784
|
});
|
|
787
|
-
var l = A.Pop,
|
|
788
|
-
|
|
789
|
-
idx:
|
|
785
|
+
var l = A.Pop, g = n(), m = g[0], p = g[1], h = Ie(), y = Ie();
|
|
786
|
+
m == null && (m = 0, a.replaceState(de({}, a.state, {
|
|
787
|
+
idx: m
|
|
790
788
|
}), ""));
|
|
791
|
-
function
|
|
792
|
-
var c = document.querySelector("base"),
|
|
789
|
+
function S() {
|
|
790
|
+
var c = document.querySelector("base"), d = "";
|
|
793
791
|
if (c && c.getAttribute("href")) {
|
|
794
|
-
var v =
|
|
795
|
-
|
|
792
|
+
var v = r.location.href, $ = v.indexOf("#");
|
|
793
|
+
d = $ === -1 ? v : v.slice(0, $);
|
|
796
794
|
}
|
|
797
|
-
return
|
|
795
|
+
return d;
|
|
798
796
|
}
|
|
799
|
-
function
|
|
800
|
-
return
|
|
797
|
+
function pe(c) {
|
|
798
|
+
return S() + "#" + (typeof c == "string" ? c : Ve(c));
|
|
801
799
|
}
|
|
802
|
-
function ge(c,
|
|
803
|
-
return
|
|
804
|
-
pathname:
|
|
800
|
+
function ge(c, d) {
|
|
801
|
+
return d === void 0 && (d = null), qe(de({
|
|
802
|
+
pathname: p.pathname,
|
|
805
803
|
hash: "",
|
|
806
804
|
search: ""
|
|
807
805
|
}, typeof c == "string" ? et(c) : c, {
|
|
808
|
-
state:
|
|
806
|
+
state: d,
|
|
809
807
|
key: $t()
|
|
810
808
|
}));
|
|
811
809
|
}
|
|
812
|
-
function me(c,
|
|
810
|
+
function me(c, d) {
|
|
813
811
|
return [{
|
|
814
812
|
usr: c.state,
|
|
815
813
|
key: c.key,
|
|
816
|
-
idx:
|
|
817
|
-
},
|
|
814
|
+
idx: d
|
|
815
|
+
}, pe(c)];
|
|
818
816
|
}
|
|
819
|
-
function
|
|
817
|
+
function ne(c, d, v) {
|
|
820
818
|
return !y.length || (y.call({
|
|
821
819
|
action: c,
|
|
822
|
-
location:
|
|
820
|
+
location: d,
|
|
823
821
|
retry: v
|
|
824
822
|
}), !1);
|
|
825
823
|
}
|
|
826
|
-
function
|
|
824
|
+
function ae(c) {
|
|
827
825
|
l = c;
|
|
828
|
-
var
|
|
829
|
-
|
|
826
|
+
var d = n();
|
|
827
|
+
m = d[0], p = d[1], h.call({
|
|
830
828
|
action: l,
|
|
831
|
-
location:
|
|
829
|
+
location: p
|
|
832
830
|
});
|
|
833
831
|
}
|
|
834
|
-
function we(c,
|
|
835
|
-
var v = A.Push, $ = ge(c,
|
|
832
|
+
function we(c, d) {
|
|
833
|
+
var v = A.Push, $ = ge(c, d);
|
|
836
834
|
function R() {
|
|
837
|
-
we(c,
|
|
835
|
+
we(c, d);
|
|
838
836
|
}
|
|
839
|
-
if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"),
|
|
840
|
-
var O = me($,
|
|
837
|
+
if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ne(v, $, R)) {
|
|
838
|
+
var O = me($, m + 1), j = O[0], D = O[1];
|
|
841
839
|
try {
|
|
842
840
|
a.pushState(j, "", D);
|
|
843
841
|
} catch {
|
|
844
|
-
|
|
842
|
+
r.location.assign(D);
|
|
845
843
|
}
|
|
846
|
-
|
|
844
|
+
ae(v);
|
|
847
845
|
}
|
|
848
846
|
}
|
|
849
|
-
function
|
|
850
|
-
var v = A.Replace, $ = ge(c,
|
|
847
|
+
function V(c, d) {
|
|
848
|
+
var v = A.Replace, $ = ge(c, d);
|
|
851
849
|
function R() {
|
|
852
|
-
|
|
850
|
+
V(c, d);
|
|
853
851
|
}
|
|
854
|
-
if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"),
|
|
855
|
-
var O = me($,
|
|
856
|
-
a.replaceState(j, "", D),
|
|
852
|
+
if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ne(v, $, R)) {
|
|
853
|
+
var O = me($, m), j = O[0], D = O[1];
|
|
854
|
+
a.replaceState(j, "", D), ae(v);
|
|
857
855
|
}
|
|
858
856
|
}
|
|
859
|
-
function
|
|
857
|
+
function J(c) {
|
|
860
858
|
a.go(c);
|
|
861
859
|
}
|
|
862
860
|
var w = {
|
|
@@ -864,25 +862,25 @@ function Kt(i) {
|
|
|
864
862
|
return l;
|
|
865
863
|
},
|
|
866
864
|
get location() {
|
|
867
|
-
return
|
|
865
|
+
return p;
|
|
868
866
|
},
|
|
869
|
-
createHref:
|
|
867
|
+
createHref: pe,
|
|
870
868
|
push: we,
|
|
871
|
-
replace:
|
|
872
|
-
go:
|
|
869
|
+
replace: V,
|
|
870
|
+
go: J,
|
|
873
871
|
back: function() {
|
|
874
|
-
|
|
872
|
+
J(-1);
|
|
875
873
|
},
|
|
876
874
|
forward: function() {
|
|
877
|
-
|
|
875
|
+
J(1);
|
|
878
876
|
},
|
|
879
|
-
listen: function(
|
|
880
|
-
return
|
|
877
|
+
listen: function(d) {
|
|
878
|
+
return h.push(d);
|
|
881
879
|
},
|
|
882
|
-
block: function(
|
|
883
|
-
var v = y.push(
|
|
884
|
-
return y.length === 1 &&
|
|
885
|
-
v(), y.length ||
|
|
880
|
+
block: function(d) {
|
|
881
|
+
var v = y.push(d);
|
|
882
|
+
return y.length === 1 && r.addEventListener(Ue, He), function() {
|
|
883
|
+
v(), y.length || r.removeEventListener(Ue, He);
|
|
886
884
|
};
|
|
887
885
|
}
|
|
888
886
|
};
|
|
@@ -899,14 +897,14 @@ function Ie() {
|
|
|
899
897
|
},
|
|
900
898
|
push: function(t) {
|
|
901
899
|
return i.push(t), function() {
|
|
902
|
-
i = i.filter(function(
|
|
903
|
-
return
|
|
900
|
+
i = i.filter(function(r) {
|
|
901
|
+
return r !== t;
|
|
904
902
|
});
|
|
905
903
|
};
|
|
906
904
|
},
|
|
907
905
|
call: function(t) {
|
|
908
|
-
i.forEach(function(
|
|
909
|
-
return
|
|
906
|
+
i.forEach(function(r) {
|
|
907
|
+
return r && r(t);
|
|
910
908
|
});
|
|
911
909
|
}
|
|
912
910
|
};
|
|
@@ -915,7 +913,7 @@ function $t() {
|
|
|
915
913
|
return Math.random().toString(36).substr(2, 8);
|
|
916
914
|
}
|
|
917
915
|
function Ve(i) {
|
|
918
|
-
var e = i.pathname, t = e === void 0 ? "/" : e,
|
|
916
|
+
var e = i.pathname, t = e === void 0 ? "/" : e, r = i.search, a = r === void 0 ? "" : r, n = i.hash, o = n === void 0 ? "" : n;
|
|
919
917
|
return a && a !== "?" && (t += a.charAt(0) === "?" ? a : "?" + a), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
|
|
920
918
|
}
|
|
921
919
|
function et(i) {
|
|
@@ -923,25 +921,25 @@ function et(i) {
|
|
|
923
921
|
if (i) {
|
|
924
922
|
var t = i.indexOf("#");
|
|
925
923
|
t >= 0 && (e.hash = i.substr(t), i = i.substr(0, t));
|
|
926
|
-
var
|
|
927
|
-
|
|
924
|
+
var r = i.indexOf("?");
|
|
925
|
+
r >= 0 && (e.search = i.substr(r), i = i.substr(0, r)), i && (e.pathname = i);
|
|
928
926
|
}
|
|
929
927
|
return e;
|
|
930
928
|
}
|
|
931
929
|
function be(i) {
|
|
932
930
|
return pt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
933
931
|
}
|
|
934
|
-
function
|
|
932
|
+
function se(i) {
|
|
935
933
|
var t;
|
|
936
934
|
Rt(
|
|
937
|
-
(
|
|
935
|
+
(r) => at(r == null ? void 0 : r.toString),
|
|
938
936
|
i,
|
|
939
937
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
940
|
-
), i = i.filter((
|
|
938
|
+
), i = i.filter((r) => r).flatMap(String);
|
|
941
939
|
let e = (t = i.shift()) == null ? void 0 : t.toString();
|
|
942
940
|
if (e) {
|
|
943
|
-
for (const
|
|
944
|
-
|
|
941
|
+
for (const r of i.map((a) => a.toString()))
|
|
942
|
+
r.startsWith(".") ? e = Fe(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
|
|
945
943
|
e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
|
|
946
944
|
}
|
|
947
945
|
return e ?? "";
|
|
@@ -952,96 +950,96 @@ function Fe(i, e) {
|
|
|
952
950
|
let t = i;
|
|
953
951
|
for (; ; )
|
|
954
952
|
if (e.startsWith("..")) {
|
|
955
|
-
for (let
|
|
956
|
-
if (t[
|
|
957
|
-
t = t.slice(0,
|
|
953
|
+
for (let r = t.length; r > 0; --r)
|
|
954
|
+
if (t[r] === "/" || r === 0) {
|
|
955
|
+
t = t.slice(0, r), e = e.replace(/^\.\.\/?/, "");
|
|
958
956
|
break;
|
|
959
957
|
}
|
|
960
958
|
} else if (e.startsWith("."))
|
|
961
959
|
e = e.replace(/^\.\/?/, "");
|
|
962
960
|
else
|
|
963
961
|
break;
|
|
964
|
-
return
|
|
962
|
+
return se([t, e]);
|
|
965
963
|
}
|
|
966
964
|
function tt(i) {
|
|
967
965
|
if (!i) return {};
|
|
968
966
|
i.startsWith("?") && (i = i.slice(1));
|
|
969
967
|
const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
|
|
970
|
-
const [
|
|
971
|
-
return a.toLowerCase() === "true" ? [
|
|
968
|
+
const [r, a] = t.split("=").map((n) => n.trim());
|
|
969
|
+
return a.toLowerCase() === "true" ? [r, !0] : a.toLowerCase() === "false" ? [r, !1] : isNaN(Number(a)) ? [r, a] : [r, Number(a)];
|
|
972
970
|
});
|
|
973
971
|
return Object.fromEntries(e);
|
|
974
972
|
}
|
|
975
973
|
function ft(i, e, t = {}) {
|
|
976
974
|
var o;
|
|
977
|
-
const [
|
|
978
|
-
e: for (const
|
|
979
|
-
const { fragments: l } =
|
|
980
|
-
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !==
|
|
975
|
+
const [r, a] = e.split("?"), n = be(r);
|
|
976
|
+
e: for (const u of i) {
|
|
977
|
+
const { fragments: l } = u;
|
|
978
|
+
if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || t.willMatch && !t.willMatch(u))
|
|
981
979
|
continue e;
|
|
982
|
-
const
|
|
983
|
-
t: for (let
|
|
984
|
-
const y =
|
|
985
|
-
if (y == null &&
|
|
980
|
+
const m = [];
|
|
981
|
+
t: for (let h = 0; h < l.length; h++) {
|
|
982
|
+
const y = n[h], S = l[h];
|
|
983
|
+
if (y == null && S.type !== 3)
|
|
986
984
|
continue e;
|
|
987
|
-
switch (
|
|
985
|
+
switch (S.type) {
|
|
988
986
|
case 1:
|
|
989
|
-
if (
|
|
990
|
-
|
|
987
|
+
if (S.name.toLowerCase() === y.toLowerCase()) {
|
|
988
|
+
m.push(S);
|
|
991
989
|
break;
|
|
992
990
|
} else
|
|
993
991
|
continue e;
|
|
994
992
|
case 2:
|
|
995
|
-
|
|
993
|
+
m.push({ ...S, value: y });
|
|
996
994
|
break;
|
|
997
995
|
case 3:
|
|
998
|
-
|
|
996
|
+
m.push({ ...S, value: n.slice(h).join("/") });
|
|
999
997
|
break t;
|
|
1000
998
|
case 4:
|
|
1001
999
|
if (isNaN(Number(y)))
|
|
1002
1000
|
continue e;
|
|
1003
|
-
|
|
1001
|
+
m.push({ ...S, value: Number(y) });
|
|
1004
1002
|
break;
|
|
1005
1003
|
default:
|
|
1006
|
-
throw new Error(`Unknown fragment type: ${
|
|
1004
|
+
throw new Error(`Unknown fragment type: ${S.type}`);
|
|
1007
1005
|
}
|
|
1008
1006
|
}
|
|
1009
|
-
const
|
|
1010
|
-
for (const
|
|
1011
|
-
|
|
1007
|
+
const p = /* @__PURE__ */ Object.create(null);
|
|
1008
|
+
for (const h of m)
|
|
1009
|
+
h.type === 2 && (p[h.name] = decodeURIComponent(h.value)), h.type === 4 && (p[h.name] = h.value), h.type === 3 && (p.wildcard = "/" + decodeURIComponent(h.value));
|
|
1012
1010
|
return {
|
|
1013
|
-
path: "/" +
|
|
1014
|
-
pattern: "/" + l.map((
|
|
1015
|
-
params:
|
|
1011
|
+
path: "/" + m.map((h) => h.value).join("/"),
|
|
1012
|
+
pattern: "/" + l.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
|
|
1013
|
+
params: p,
|
|
1016
1014
|
query: tt(a),
|
|
1017
|
-
meta:
|
|
1015
|
+
meta: u.meta
|
|
1018
1016
|
};
|
|
1019
1017
|
}
|
|
1020
1018
|
}
|
|
1021
1019
|
function Qt(i) {
|
|
1022
|
-
const e = [], t = [],
|
|
1020
|
+
const e = [], t = [], r = [], a = [];
|
|
1023
1021
|
for (const o of i) {
|
|
1024
|
-
const { fragments:
|
|
1025
|
-
|
|
1022
|
+
const { fragments: u } = o;
|
|
1023
|
+
u.some(
|
|
1026
1024
|
(l) => l.type === 3
|
|
1027
1025
|
/* Wildcard */
|
|
1028
|
-
) ? a.push(o) :
|
|
1026
|
+
) ? a.push(o) : u.some(
|
|
1029
1027
|
(l) => l.type === 4
|
|
1030
1028
|
/* NumericParam */
|
|
1031
|
-
) ? t.push(o) :
|
|
1029
|
+
) ? t.push(o) : u.some(
|
|
1032
1030
|
(l) => l.type === 2
|
|
1033
1031
|
/* Param */
|
|
1034
|
-
) ?
|
|
1032
|
+
) ? r.push(o) : e.push(o);
|
|
1035
1033
|
}
|
|
1036
|
-
const
|
|
1037
|
-
return e.sort(
|
|
1034
|
+
const n = (o, u) => o.fragments.length > u.fragments.length ? -1 : 1;
|
|
1035
|
+
return e.sort(n), t.sort(n), r.sort(n), a.sort(n), [...e, ...t, ...r, ...a];
|
|
1038
1036
|
}
|
|
1039
1037
|
function Jt(i) {
|
|
1040
1038
|
const e = be(i), t = [];
|
|
1041
|
-
for (let
|
|
1042
|
-
const a = e[
|
|
1039
|
+
for (let r = 0; r < e.length; r++) {
|
|
1040
|
+
const a = e[r];
|
|
1043
1041
|
if (a === "*") {
|
|
1044
|
-
if (
|
|
1042
|
+
if (r !== e.length - 1)
|
|
1045
1043
|
throw new Error(`Wildcard must be at the end of a pattern. Received: ${i}`);
|
|
1046
1044
|
t.push({
|
|
1047
1045
|
type: 3,
|
|
@@ -1060,65 +1058,65 @@ function Jt(i) {
|
|
|
1060
1058
|
}
|
|
1061
1059
|
return t;
|
|
1062
1060
|
}
|
|
1063
|
-
var Se, M,
|
|
1061
|
+
var Se, M, Z, E, ze, G, Re, ee, W, ue, he, fe, xe, Q, rt, nt;
|
|
1064
1062
|
class Yt {
|
|
1065
1063
|
constructor(e, t) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1064
|
+
f(this, Q);
|
|
1065
|
+
f(this, Se);
|
|
1066
|
+
f(this, M);
|
|
1067
|
+
f(this, Z);
|
|
1068
|
+
f(this, E);
|
|
1069
|
+
f(this, ze, 0);
|
|
1070
|
+
f(this, G, []);
|
|
1071
|
+
f(this, Re);
|
|
1072
|
+
f(this, ee, []);
|
|
1075
1073
|
// Callbacks that need to be called on unmount.
|
|
1076
|
-
|
|
1074
|
+
f(this, W, []);
|
|
1077
1075
|
/**
|
|
1078
1076
|
* The currently matched route pattern, if any.
|
|
1079
1077
|
*/
|
|
1080
|
-
|
|
1081
|
-
|
|
1078
|
+
P(this, "$pattern");
|
|
1079
|
+
f(this, ue);
|
|
1082
1080
|
/**
|
|
1083
1081
|
* The current URL path.
|
|
1084
1082
|
*/
|
|
1085
|
-
|
|
1086
|
-
|
|
1083
|
+
P(this, "$path");
|
|
1084
|
+
f(this, he);
|
|
1087
1085
|
/**
|
|
1088
1086
|
* The current named path params.
|
|
1089
1087
|
*/
|
|
1090
|
-
|
|
1091
|
-
|
|
1088
|
+
P(this, "$params");
|
|
1089
|
+
f(this, fe);
|
|
1092
1090
|
/**
|
|
1093
1091
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
1094
1092
|
*/
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this,
|
|
1098
|
-
const [
|
|
1093
|
+
P(this, "$query");
|
|
1094
|
+
f(this, xe);
|
|
1095
|
+
b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this, Z, t);
|
|
1096
|
+
const [r, a] = ie(null), [n, o] = ie(""), [u, l] = ie({}), [g, m] = ie(
|
|
1099
1097
|
tt(typeof window > "u" ? "" : window.location.search ?? "")
|
|
1100
1098
|
);
|
|
1101
|
-
this.$pattern =
|
|
1102
|
-
s(this,
|
|
1103
|
-
gt([
|
|
1104
|
-
const
|
|
1105
|
-
for (const
|
|
1106
|
-
|
|
1107
|
-
const y = "?" +
|
|
1108
|
-
y != s(this,
|
|
1109
|
-
pathname: s(this,
|
|
1099
|
+
this.$pattern = r, b(this, ue, a), this.$path = n, b(this, he, o), this.$params = u, b(this, fe, l), this.$query = g, b(this, xe, m), e.beforeMount(() => {
|
|
1100
|
+
s(this, E) != null && (s(this, W).push(
|
|
1101
|
+
gt([g], (p) => {
|
|
1102
|
+
const h = new URLSearchParams();
|
|
1103
|
+
for (const S in p)
|
|
1104
|
+
h.set(S, String(p[S]));
|
|
1105
|
+
const y = "?" + h.toString();
|
|
1106
|
+
y != s(this, E).location.search && s(this, E).replace({
|
|
1107
|
+
pathname: s(this, E).location.pathname,
|
|
1110
1108
|
search: y
|
|
1111
1109
|
});
|
|
1112
1110
|
})
|
|
1113
|
-
), s(this,
|
|
1114
|
-
er(s(this,
|
|
1115
|
-
let
|
|
1116
|
-
s(this, M).info("Intercepted link click",
|
|
1111
|
+
), s(this, W).push(s(this, E).listen(k(this, Q, nt).bind(this))), k(this, Q, nt).call(this, s(this, E)), s(this, W).push(
|
|
1112
|
+
er(s(this, Z).rootElement, (p) => {
|
|
1113
|
+
let h = p.getAttribute("href");
|
|
1114
|
+
s(this, M).info("Intercepted link click", p, h), /^https?:\/\/|^\//.test(h) || (h = se([s(this, E).location.pathname, h])), s(this, E).push(h);
|
|
1117
1115
|
})
|
|
1118
|
-
), s(this, M).info("Intercepting <a> clicks within root element:", s(this,
|
|
1116
|
+
), s(this, M).info("Intercepting <a> clicks within root element:", s(this, Z).rootElement));
|
|
1119
1117
|
}), e.onUnmount(() => {
|
|
1120
|
-
for (; s(this,
|
|
1121
|
-
s(this,
|
|
1118
|
+
for (; s(this, W).length > 0; )
|
|
1119
|
+
s(this, W).pop()();
|
|
1122
1120
|
});
|
|
1123
1121
|
}
|
|
1124
1122
|
setup(e) {
|
|
@@ -1128,20 +1126,20 @@ class Yt {
|
|
|
1128
1126
|
);
|
|
1129
1127
|
return;
|
|
1130
1128
|
}
|
|
1131
|
-
e.style === "hash" ? b(this,
|
|
1132
|
-
e.routes.flatMap((t) => k(this,
|
|
1129
|
+
e.style === "hash" ? b(this, E, Kt()) : b(this, E, Bt()), b(this, ee, Qt(
|
|
1130
|
+
e.routes.flatMap((t) => k(this, Q, rt).call(this, t)).map((t) => ({
|
|
1133
1131
|
pattern: t.pattern,
|
|
1134
1132
|
meta: t.meta,
|
|
1135
1133
|
fragments: Jt(t.pattern)
|
|
1136
1134
|
}))
|
|
1137
1135
|
));
|
|
1138
|
-
for (const t of s(this,
|
|
1136
|
+
for (const t of s(this, ee))
|
|
1139
1137
|
if (t.meta.redirect) {
|
|
1140
|
-
let
|
|
1141
|
-
if (!at(t.meta.redirect)) if (
|
|
1142
|
-
if (
|
|
1143
|
-
willMatch(
|
|
1144
|
-
return
|
|
1138
|
+
let r;
|
|
1139
|
+
if (!at(t.meta.redirect)) if (F(t.meta.redirect)) {
|
|
1140
|
+
if (r = t.meta.redirect, !ft(s(this, ee), r, {
|
|
1141
|
+
willMatch(n) {
|
|
1142
|
+
return n !== t;
|
|
1145
1143
|
}
|
|
1146
1144
|
}))
|
|
1147
1145
|
throw new Error(
|
|
@@ -1159,7 +1157,7 @@ class Yt {
|
|
|
1159
1157
|
* Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
1160
1158
|
*/
|
|
1161
1159
|
go(e, t = {}) {
|
|
1162
|
-
if (s(this,
|
|
1160
|
+
if (s(this, E) == null) {
|
|
1163
1161
|
s(this, M).crash(
|
|
1164
1162
|
new Error(
|
|
1165
1163
|
"Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1167,14 +1165,14 @@ class Yt {
|
|
|
1167
1165
|
);
|
|
1168
1166
|
return;
|
|
1169
1167
|
}
|
|
1170
|
-
let
|
|
1171
|
-
Array.isArray(e) ?
|
|
1168
|
+
let r;
|
|
1169
|
+
Array.isArray(e) ? r = se(e) : r = e.toString(), r = Fe(s(this, E).location.pathname, r), t.preserveQuery && (r += s(this, E).location.search), t.replace ? s(this, E).replace(r) : s(this, E).push(r);
|
|
1172
1170
|
}
|
|
1173
1171
|
/**
|
|
1174
1172
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
1175
1173
|
*/
|
|
1176
1174
|
back(e = 1) {
|
|
1177
|
-
if (s(this,
|
|
1175
|
+
if (s(this, E) == null) {
|
|
1178
1176
|
s(this, M).crash(
|
|
1179
1177
|
new Error(
|
|
1180
1178
|
"Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1182,13 +1180,13 @@ class Yt {
|
|
|
1182
1180
|
);
|
|
1183
1181
|
return;
|
|
1184
1182
|
}
|
|
1185
|
-
s(this,
|
|
1183
|
+
s(this, E).go(-e);
|
|
1186
1184
|
}
|
|
1187
1185
|
/**
|
|
1188
1186
|
* Navigate forward. Pass a number of steps to hit the forward button that many times.
|
|
1189
1187
|
*/
|
|
1190
1188
|
forward(e = 1) {
|
|
1191
|
-
if (s(this,
|
|
1189
|
+
if (s(this, E) == null) {
|
|
1192
1190
|
s(this, M).crash(
|
|
1193
1191
|
new Error(
|
|
1194
1192
|
"Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
|
|
@@ -1196,16 +1194,16 @@ class Yt {
|
|
|
1196
1194
|
);
|
|
1197
1195
|
return;
|
|
1198
1196
|
}
|
|
1199
|
-
s(this,
|
|
1197
|
+
s(this, E).go(e);
|
|
1200
1198
|
}
|
|
1201
1199
|
}
|
|
1202
|
-
Se = new WeakMap(), M = new WeakMap(),
|
|
1200
|
+
Se = new WeakMap(), M = new WeakMap(), Z = new WeakMap(), E = new WeakMap(), ze = new WeakMap(), G = new WeakMap(), Re = new WeakMap(), ee = new WeakMap(), W = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), xe = new WeakMap(), Q = new WeakSet(), /**
|
|
1203
1201
|
* Parses a route definition object into a set of matchable routes.
|
|
1204
1202
|
*
|
|
1205
1203
|
* @param route - Route config object.
|
|
1206
1204
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
1207
1205
|
*/
|
|
1208
|
-
rt = function(e, t = [],
|
|
1206
|
+
rt = function(e, t = [], r = []) {
|
|
1209
1207
|
if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
|
|
1210
1208
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
|
|
1211
1209
|
if (e.redirect && e.routes)
|
|
@@ -1218,91 +1216,91 @@ rt = function(e, t = [], n = []) {
|
|
|
1218
1216
|
for (const l of t)
|
|
1219
1217
|
a.push(...be(l.path));
|
|
1220
1218
|
a.push(...be(e.path)), a[a.length - 1] === "*" && a.pop();
|
|
1221
|
-
const
|
|
1219
|
+
const n = [];
|
|
1222
1220
|
if (e.redirect) {
|
|
1223
1221
|
let l = e.redirect;
|
|
1224
|
-
return
|
|
1225
|
-
pattern: "/" +
|
|
1222
|
+
return F(l) && (l = Fe(se(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
|
|
1223
|
+
pattern: "/" + se([...a, ...be(e.path)]),
|
|
1226
1224
|
meta: {
|
|
1227
1225
|
redirect: l
|
|
1228
1226
|
}
|
|
1229
|
-
}),
|
|
1227
|
+
}), n;
|
|
1230
1228
|
}
|
|
1231
1229
|
let o = mt;
|
|
1232
1230
|
if (typeof e.view == "function")
|
|
1233
1231
|
o = e.view;
|
|
1234
1232
|
else if (e.view)
|
|
1235
1233
|
throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
|
|
1236
|
-
const
|
|
1234
|
+
const u = { id: it(this, ze)._++, view: o };
|
|
1237
1235
|
if (e.routes)
|
|
1238
1236
|
for (const l of e.routes)
|
|
1239
|
-
|
|
1237
|
+
n.push(...k(this, Q, rt).call(this, l, [...t, e], [...r, u]));
|
|
1240
1238
|
else
|
|
1241
|
-
|
|
1242
|
-
pattern: parent ?
|
|
1239
|
+
n.push({
|
|
1240
|
+
pattern: parent ? se([...t.map((l) => l.path), e.path]) : e.path,
|
|
1243
1241
|
meta: {
|
|
1244
1242
|
pattern: e.path,
|
|
1245
|
-
layers: [...
|
|
1243
|
+
layers: [...r, u],
|
|
1246
1244
|
beforeMatch: e.beforeMatch
|
|
1247
1245
|
}
|
|
1248
1246
|
});
|
|
1249
|
-
return
|
|
1247
|
+
return n;
|
|
1250
1248
|
}, nt = async function({ location: e }) {
|
|
1251
1249
|
e.search !== s(this, Re) && (b(this, Re, e.search), s(this, xe).call(this, tt(e.search)));
|
|
1252
|
-
const t = ft(s(this,
|
|
1250
|
+
const t = ft(s(this, ee), e.pathname);
|
|
1253
1251
|
if (!t) {
|
|
1254
|
-
s(this,
|
|
1252
|
+
s(this, ue).call(this, null), s(this, he).call(this, e.pathname), s(this, fe).call(this, {
|
|
1255
1253
|
wildcard: e.pathname
|
|
1256
1254
|
});
|
|
1257
1255
|
return;
|
|
1258
1256
|
}
|
|
1259
1257
|
if (t.meta.beforeMatch && await t.meta.beforeMatch({
|
|
1260
1258
|
// TODO: Allow setting context variables from here.
|
|
1261
|
-
redirect: (
|
|
1259
|
+
redirect: (r) => {
|
|
1262
1260
|
throw new Error("Redirect not yet implemented.");
|
|
1263
1261
|
}
|
|
1264
1262
|
}), t.meta.redirect != null)
|
|
1265
1263
|
if (typeof t.meta.redirect == "string") {
|
|
1266
|
-
const
|
|
1267
|
-
s(this, M).info(`↩️ redirecting from '${t.path}' to '${
|
|
1264
|
+
const r = tr(t.meta.redirect, t.params);
|
|
1265
|
+
s(this, M).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, E).replace(r);
|
|
1268
1266
|
} else if (typeof t.meta.redirect == "function") {
|
|
1269
|
-
const
|
|
1267
|
+
const r = {
|
|
1270
1268
|
path: t.path,
|
|
1271
1269
|
pattern: t.pattern,
|
|
1272
1270
|
params: t.params,
|
|
1273
1271
|
query: t.query
|
|
1274
1272
|
};
|
|
1275
|
-
let a = await t.meta.redirect(
|
|
1273
|
+
let a = await t.meta.redirect(r);
|
|
1276
1274
|
if (typeof a != "string")
|
|
1277
1275
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
1278
|
-
a.startsWith("/") || (a = Fe(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this,
|
|
1276
|
+
a.startsWith("/") || (a = Fe(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, E).replace(a);
|
|
1279
1277
|
} else
|
|
1280
1278
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
1281
|
-
else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this,
|
|
1282
|
-
s(this,
|
|
1283
|
-
const
|
|
1284
|
-
for (let a = 0; a <
|
|
1285
|
-
const
|
|
1286
|
-
if ((o == null ? void 0 : o.id) !==
|
|
1287
|
-
b(this,
|
|
1288
|
-
const
|
|
1279
|
+
else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, he).call(this, t.path), s(this, fe).call(this, t.params), t.pattern !== this.$pattern.get()) {
|
|
1280
|
+
s(this, ue).call(this, t.pattern);
|
|
1281
|
+
const r = t.meta.layers;
|
|
1282
|
+
for (let a = 0; a < r.length; a++) {
|
|
1283
|
+
const n = r[a], o = s(this, G)[a];
|
|
1284
|
+
if ((o == null ? void 0 : o.id) !== n.id) {
|
|
1285
|
+
b(this, G, s(this, G).slice(0, a));
|
|
1286
|
+
const u = s(this, G).at(-1);
|
|
1289
1287
|
o && o.node.isMounted && o.node.unmount();
|
|
1290
1288
|
let l;
|
|
1291
|
-
|
|
1289
|
+
u ? l = u.node.setChildView(n.view) : l = s(this, Z).rootView.setChildView(n.view), s(this, G).push({ id: n.id, node: l });
|
|
1292
1290
|
}
|
|
1293
1291
|
}
|
|
1294
1292
|
}
|
|
1295
1293
|
};
|
|
1296
1294
|
const Xt = /(noopener|noreferrer) (noopener|noreferrer)/, Zt = /^[\w-_]+:/;
|
|
1297
1295
|
function er(i, e, t = window) {
|
|
1298
|
-
function n
|
|
1299
|
-
return !
|
|
1296
|
+
function r(n) {
|
|
1297
|
+
return !n || n === i ? null : n.localName !== "a" || n.href === void 0 ? r(n.parentNode) : n;
|
|
1300
1298
|
}
|
|
1301
|
-
function a(
|
|
1302
|
-
if (
|
|
1299
|
+
function a(n) {
|
|
1300
|
+
if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
|
|
1303
1301
|
return;
|
|
1304
|
-
const o = n
|
|
1305
|
-
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" && Xt.test(o.getAttribute("rel")) || Zt.test(o.getAttribute("href")) || (
|
|
1302
|
+
const o = r(n.target);
|
|
1303
|
+
o && (t.location.protocol !== o.protocol || t.location.hostname !== o.hostname || t.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && Xt.test(o.getAttribute("rel")) || Zt.test(o.getAttribute("href")) || (n.preventDefault(), e(o)));
|
|
1306
1304
|
}
|
|
1307
1305
|
return i.addEventListener("click", a), function() {
|
|
1308
1306
|
i.removeEventListener("click", a);
|
|
@@ -1310,50 +1308,50 @@ function er(i, e, t = window) {
|
|
|
1310
1308
|
}
|
|
1311
1309
|
function tr(i, e) {
|
|
1312
1310
|
for (const t in e) {
|
|
1313
|
-
const
|
|
1314
|
-
i = i.replace(`{${t}}`,
|
|
1311
|
+
const r = e[t].toString();
|
|
1312
|
+
i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
|
|
1315
1313
|
}
|
|
1316
1314
|
return i;
|
|
1317
1315
|
}
|
|
1318
|
-
var
|
|
1316
|
+
var z, Le, B, te, Ne, Oe, Me, Te, je, x, K;
|
|
1319
1317
|
class rr {
|
|
1320
1318
|
constructor() {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1319
|
+
P(this, "http");
|
|
1320
|
+
P(this, "i18n");
|
|
1321
|
+
P(this, "render");
|
|
1322
|
+
P(this, "router");
|
|
1323
|
+
f(this, z, !1);
|
|
1324
|
+
f(this, Le, "production");
|
|
1325
|
+
f(this, B);
|
|
1326
|
+
f(this, te);
|
|
1327
|
+
f(this, Ne, _t);
|
|
1328
|
+
f(this, Oe, []);
|
|
1329
|
+
f(this, Me, []);
|
|
1330
|
+
f(this, Te, []);
|
|
1331
|
+
f(this, je, []);
|
|
1332
|
+
f(this, x, {
|
|
1335
1333
|
info: "development",
|
|
1336
1334
|
log: "development",
|
|
1337
1335
|
warn: "development",
|
|
1338
1336
|
error: !0
|
|
1339
1337
|
});
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1338
|
+
f(this, K, ct("*,-dolla/*"));
|
|
1339
|
+
P(this, "createState", ie);
|
|
1340
|
+
P(this, "createSettableState", xt);
|
|
1341
|
+
P(this, "toSettableState", Lt);
|
|
1342
|
+
P(this, "toState", Qe);
|
|
1343
|
+
P(this, "valueOf", Nt);
|
|
1344
|
+
P(this, "derive", ye);
|
|
1345
|
+
P(this, "watch", gt);
|
|
1346
|
+
P(this, "createRef", Ot);
|
|
1347
|
+
P(this, "isRef", Mt);
|
|
1350
1348
|
const e = this;
|
|
1351
1349
|
this.http = new Ct(), this.i18n = new It(this), this.render = new Wt(this), this.router = new Yt(this, {
|
|
1352
1350
|
get rootElement() {
|
|
1353
|
-
return s(e,
|
|
1351
|
+
return s(e, B);
|
|
1354
1352
|
},
|
|
1355
1353
|
get rootView() {
|
|
1356
|
-
return s(e,
|
|
1354
|
+
return s(e, te);
|
|
1357
1355
|
}
|
|
1358
1356
|
});
|
|
1359
1357
|
}
|
|
@@ -1361,7 +1359,7 @@ class rr {
|
|
|
1361
1359
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
1362
1360
|
*/
|
|
1363
1361
|
get isMounted() {
|
|
1364
|
-
return s(this,
|
|
1362
|
+
return s(this, z);
|
|
1365
1363
|
}
|
|
1366
1364
|
/**
|
|
1367
1365
|
* Get the current environment that this app is running in.
|
|
@@ -1385,22 +1383,22 @@ class rr {
|
|
|
1385
1383
|
b(this, Ne, e);
|
|
1386
1384
|
}
|
|
1387
1385
|
async mount(e, t) {
|
|
1388
|
-
if (s(this,
|
|
1386
|
+
if (s(this, z))
|
|
1389
1387
|
throw new Error("Dolla is already mounted.");
|
|
1390
|
-
if (
|
|
1388
|
+
if (F(e)) {
|
|
1391
1389
|
const a = document.querySelector(e);
|
|
1392
|
-
ut(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this,
|
|
1390
|
+
ut(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, B, a);
|
|
1393
1391
|
} else
|
|
1394
|
-
ut(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this,
|
|
1395
|
-
let
|
|
1396
|
-
t ?
|
|
1392
|
+
ut(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, B, e);
|
|
1393
|
+
let r;
|
|
1394
|
+
t ? r = ht(t) : r = ht(mt), b(this, te, this.constructView(r.type, r.props)), await Promise.all(s(this, Oe).map((a) => a())), s(this, te).mount(s(this, B)), b(this, z, !0);
|
|
1397
1395
|
for (const a of s(this, Me))
|
|
1398
1396
|
a();
|
|
1399
1397
|
}
|
|
1400
1398
|
async unmount() {
|
|
1401
1399
|
var e;
|
|
1402
|
-
if (s(this,
|
|
1403
|
-
await Promise.all(s(this, Te).map((t) => t())), (e = s(this,
|
|
1400
|
+
if (s(this, z)) {
|
|
1401
|
+
await Promise.all(s(this, Te).map((t) => t())), (e = s(this, te)) == null || e.unmount(), b(this, z, !1);
|
|
1404
1402
|
for (const t of s(this, je))
|
|
1405
1403
|
t();
|
|
1406
1404
|
}
|
|
@@ -1436,20 +1434,20 @@ class rr {
|
|
|
1436
1434
|
*/
|
|
1437
1435
|
setLoggles(e) {
|
|
1438
1436
|
for (const t in e) {
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1437
|
+
const r = e[t];
|
|
1438
|
+
r && (s(this, x)[t] = r);
|
|
1441
1439
|
}
|
|
1442
1440
|
}
|
|
1443
1441
|
setLogFilter(e) {
|
|
1444
|
-
b(this,
|
|
1442
|
+
b(this, K, ct(e));
|
|
1445
1443
|
}
|
|
1446
1444
|
createLogger(e, t) {
|
|
1447
|
-
const
|
|
1445
|
+
const r = Qe(e), a = (t == null ? void 0 : t.console) ?? Tt(), n = this;
|
|
1448
1446
|
return {
|
|
1449
1447
|
get info() {
|
|
1450
|
-
var
|
|
1451
|
-
const o =
|
|
1452
|
-
if (s(
|
|
1448
|
+
var u;
|
|
1449
|
+
const o = r.get();
|
|
1450
|
+
if (s(n, x).info === !1 || F(s(n, x).info) && s(n, x).info !== n.getEnv() || !s(u = n, K).call(u, o))
|
|
1453
1451
|
return Ae;
|
|
1454
1452
|
{
|
|
1455
1453
|
let l = `%c${o}`;
|
|
@@ -1464,9 +1462,9 @@ class rr {
|
|
|
1464
1462
|
}
|
|
1465
1463
|
},
|
|
1466
1464
|
get log() {
|
|
1467
|
-
var
|
|
1468
|
-
const o =
|
|
1469
|
-
if (s(
|
|
1465
|
+
var u;
|
|
1466
|
+
const o = r.get();
|
|
1467
|
+
if (s(n, x).log === !1 || F(s(n, x).log) && s(n, x).log !== n.getEnv() || !s(u = n, K).call(u, o))
|
|
1470
1468
|
return Ae;
|
|
1471
1469
|
{
|
|
1472
1470
|
let l = `%c${o}`;
|
|
@@ -1481,9 +1479,9 @@ class rr {
|
|
|
1481
1479
|
}
|
|
1482
1480
|
},
|
|
1483
1481
|
get warn() {
|
|
1484
|
-
var
|
|
1485
|
-
const o =
|
|
1486
|
-
if (s(
|
|
1482
|
+
var u;
|
|
1483
|
+
const o = r.get();
|
|
1484
|
+
if (s(n, x).warn === !1 || F(s(n, x).warn) && s(n, x).warn !== n.getEnv() || !s(u = n, K).call(u, o))
|
|
1487
1485
|
return Ae;
|
|
1488
1486
|
{
|
|
1489
1487
|
let l = `%c${o}`;
|
|
@@ -1498,9 +1496,9 @@ class rr {
|
|
|
1498
1496
|
}
|
|
1499
1497
|
},
|
|
1500
1498
|
get error() {
|
|
1501
|
-
var
|
|
1502
|
-
const o =
|
|
1503
|
-
if (s(
|
|
1499
|
+
var u;
|
|
1500
|
+
const o = r.get();
|
|
1501
|
+
if (s(n, x).error === !1 || F(s(n, x).error) && s(n, x).error !== n.getEnv() || !s(u = n, K).call(u, o))
|
|
1504
1502
|
return Ae;
|
|
1505
1503
|
{
|
|
1506
1504
|
let l = `%c${o}`;
|
|
@@ -1515,19 +1513,19 @@ class rr {
|
|
|
1515
1513
|
}
|
|
1516
1514
|
},
|
|
1517
1515
|
crash(o) {
|
|
1518
|
-
throw
|
|
1516
|
+
throw n.isMounted && (n.unmount(), n.constructView(s(n, Ne), {
|
|
1519
1517
|
error: o,
|
|
1520
|
-
loggerName:
|
|
1518
|
+
loggerName: r.get(),
|
|
1521
1519
|
uid: t == null ? void 0 : t.uid
|
|
1522
|
-
}).mount(s(
|
|
1520
|
+
}).mount(s(n, B))), o;
|
|
1523
1521
|
}
|
|
1524
1522
|
};
|
|
1525
1523
|
}
|
|
1526
1524
|
/**
|
|
1527
1525
|
*
|
|
1528
1526
|
*/
|
|
1529
|
-
constructView(e, t,
|
|
1530
|
-
return jt({ root: this, data: {} }, e, t,
|
|
1527
|
+
constructView(e, t, r = []) {
|
|
1528
|
+
return jt({ root: this, data: {} }, e, t, r);
|
|
1531
1529
|
}
|
|
1532
1530
|
/**
|
|
1533
1531
|
*
|
|
@@ -1536,7 +1534,7 @@ class rr {
|
|
|
1536
1534
|
return At(Dt({ root: this, data: {} }, e));
|
|
1537
1535
|
}
|
|
1538
1536
|
}
|
|
1539
|
-
|
|
1537
|
+
z = new WeakMap(), Le = new WeakMap(), B = new WeakMap(), te = new WeakMap(), Ne = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), je = new WeakMap(), x = new WeakMap(), K = new WeakMap();
|
|
1540
1538
|
const dt = new rr(), ir = dt.i18n.t.bind(dt.i18n);
|
|
1541
1539
|
export {
|
|
1542
1540
|
Pt as cond,
|
|
@@ -1544,7 +1542,7 @@ export {
|
|
|
1544
1542
|
Ot as createRef,
|
|
1545
1543
|
xt as createSettableState,
|
|
1546
1544
|
cr as createSetter,
|
|
1547
|
-
|
|
1545
|
+
ie as createState,
|
|
1548
1546
|
dt as default,
|
|
1549
1547
|
ye as derive,
|
|
1550
1548
|
ot as html,
|