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