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