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