@manyducks.co/dolla 2.0.0-alpha.29 → 2.0.0-alpha.30
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/core/context.d.ts +6 -0
- package/dist/core/nodes/view.d.ts +2 -1
- package/dist/core/store.d.ts +2 -1
- package/dist/index.js +415 -398
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{passthrough-eH8w4zJi.js → passthrough-d2lcM0cd.js} +248 -196
- package/dist/passthrough-d2lcM0cd.js.map +1 -0
- package/package.json +1 -1
- package/dist/passthrough-eH8w4zJi.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var it = Object.defineProperty;
|
|
2
|
+
var qe = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var d = (o, e, t) =>
|
|
7
|
-
var i = (o, e, t) => (
|
|
8
|
-
var
|
|
9
|
-
set _(
|
|
10
|
-
m(o, e,
|
|
5
|
+
var at = (o, e, t) => e in o ? it(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var d = (o, e, t) => at(o, typeof e != "symbol" ? e + "" : e, t), De = (o, e, t) => e.has(o) || qe("Cannot " + t);
|
|
7
|
+
var i = (o, e, t) => (De(o, e, "read from private field"), t ? t.call(o) : e.get(o)), l = (o, e, t) => e.has(o) ? qe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), m = (o, e, t, s) => (De(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), u = (o, e, t) => (De(o, e, "access private method"), t);
|
|
8
|
+
var ee = (o, e, t, s) => ({
|
|
9
|
+
set _(n) {
|
|
10
|
+
m(o, e, n, t);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
13
|
return i(o, e, s);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { i as
|
|
17
|
-
import { F as
|
|
18
|
-
var
|
|
19
|
-
class
|
|
16
|
+
import { i as Z, c as Ie, d as x, a as E, b as ot, e as re, t as We, f as Je, g as lt, s as Ae, h as Ge, P as Xe, j as He, k as ht, l as Be, p as ct, m as ze, S as ut, n as ft, o as dt, q as mt, r as wt, u as pt, C as gt, v as yt, w as Fe, x as bt, y as Ke, z as $t, A as $e, B as ve, V as vt, D as Et, E as kt } from "./passthrough-d2lcM0cd.js";
|
|
17
|
+
import { F as Zt, J as es, H as ts, I as ss, G as rs } from "./passthrough-d2lcM0cd.js";
|
|
18
|
+
var I, Se, Re, ne, R, _;
|
|
19
|
+
class St {
|
|
20
20
|
constructor(e) {
|
|
21
21
|
l(this, R);
|
|
22
|
-
l(this,
|
|
23
|
-
l(this,
|
|
24
|
-
l(this,
|
|
25
|
-
l(this,
|
|
26
|
-
m(this,
|
|
22
|
+
l(this, I, []);
|
|
23
|
+
l(this, Se, Rt());
|
|
24
|
+
l(this, Re);
|
|
25
|
+
l(this, ne);
|
|
26
|
+
m(this, Re, e), m(this, ne, e.createLogger("Dolla.http"));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Adds a new middleware that will apply to subsequent requests.
|
|
@@ -32,8 +32,8 @@ class kt {
|
|
|
32
32
|
* @param middleware - A middleware function that will intercept requests.
|
|
33
33
|
*/
|
|
34
34
|
use(e) {
|
|
35
|
-
return i(this,
|
|
36
|
-
i(this,
|
|
35
|
+
return i(this, I).push(e), () => {
|
|
36
|
+
i(this, I).splice(i(this, I).indexOf(e), 1);
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
async get(e, t) {
|
|
@@ -61,32 +61,32 @@ class kt {
|
|
|
61
61
|
return u(this, R, _).call(this, "trace", e, t);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
return new
|
|
64
|
+
I = new WeakMap(), Se = new WeakMap(), Re = new WeakMap(), ne = new WeakMap(), R = new WeakSet(), _ = async function(e, t, s) {
|
|
65
|
+
return new Mt({
|
|
66
66
|
...s,
|
|
67
67
|
method: e,
|
|
68
68
|
uri: t,
|
|
69
|
-
middleware: i(this,
|
|
70
|
-
fetch: i(this,
|
|
71
|
-
logger: i(this,
|
|
69
|
+
middleware: i(this, I),
|
|
70
|
+
fetch: i(this, Se),
|
|
71
|
+
logger: i(this, ne)
|
|
72
72
|
}).fetch();
|
|
73
73
|
};
|
|
74
|
-
function
|
|
74
|
+
function Rt() {
|
|
75
75
|
if (typeof window < "u" && window.fetch)
|
|
76
76
|
return window.fetch.bind(window);
|
|
77
77
|
if (typeof global < "u" && global.fetch)
|
|
78
78
|
return global.fetch.bind(global);
|
|
79
79
|
throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class _t extends Error {
|
|
82
82
|
constructor(t) {
|
|
83
|
-
const { status: s, statusText:
|
|
83
|
+
const { status: s, statusText: n, method: r, url: a } = t, f = `${s} ${n}: Request failed (${r.toUpperCase()} ${a.toString()})`;
|
|
84
84
|
super(f);
|
|
85
85
|
d(this, "response");
|
|
86
86
|
this.response = t;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class Lt {
|
|
90
90
|
constructor(e) {
|
|
91
91
|
d(this, "method");
|
|
92
92
|
d(this, "url");
|
|
@@ -103,7 +103,7 @@ class _t {
|
|
|
103
103
|
e.forEach((t, s) => {
|
|
104
104
|
this.headers.set(s, t);
|
|
105
105
|
});
|
|
106
|
-
else if (
|
|
106
|
+
else if (Z(e))
|
|
107
107
|
for (const t in e) {
|
|
108
108
|
const s = e[t];
|
|
109
109
|
s instanceof Date ? this.headers.set(t, s.toISOString()) : s != null && this.headers.set(t, String(s));
|
|
@@ -117,7 +117,7 @@ class _t {
|
|
|
117
117
|
e.forEach((t, s) => {
|
|
118
118
|
this.url.searchParams.set(s, t);
|
|
119
119
|
});
|
|
120
|
-
else if (
|
|
120
|
+
else if (Z(e))
|
|
121
121
|
for (const t in e) {
|
|
122
122
|
const s = e[t];
|
|
123
123
|
s instanceof Date ? this.url.searchParams.set(t, s.toISOString()) : s != null && this.url.searchParams.set(t, String(s));
|
|
@@ -126,69 +126,69 @@ class _t {
|
|
|
126
126
|
throw new TypeError(`Unknown query params type. Got: ${e}`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class Mt {
|
|
130
130
|
constructor(e) {
|
|
131
131
|
d(this, "_middleware");
|
|
132
132
|
d(this, "_fetch");
|
|
133
133
|
d(this, "_request");
|
|
134
134
|
d(this, "_response");
|
|
135
|
-
this._middleware = e.middleware, this._fetch = e.fetch, this._request = new
|
|
135
|
+
this._middleware = e.middleware, this._fetch = e.fetch, this._request = new Lt(e);
|
|
136
136
|
}
|
|
137
137
|
async fetch() {
|
|
138
138
|
if (this._middleware.length > 0) {
|
|
139
139
|
const e = (t = 0) => {
|
|
140
|
-
const s = this._middleware[t],
|
|
141
|
-
return async () => s(this._request, async () => (await
|
|
140
|
+
const s = this._middleware[t], n = this._middleware[t + 1] ? e(t + 1) : this._handler.bind(this);
|
|
141
|
+
return async () => s(this._request, async () => (await n(), this._response));
|
|
142
142
|
};
|
|
143
143
|
await e()();
|
|
144
144
|
} else
|
|
145
145
|
await this._handler();
|
|
146
146
|
if (this._response.status < 200 || this._response.status >= 400)
|
|
147
|
-
throw new
|
|
147
|
+
throw new _t(this._response);
|
|
148
148
|
return this._response;
|
|
149
149
|
}
|
|
150
150
|
// This is the function that performs the actual request after the final middleware.
|
|
151
151
|
async _handler() {
|
|
152
152
|
let e;
|
|
153
153
|
const t = this._request;
|
|
154
|
-
!t.headers.has("content-type") &&
|
|
154
|
+
!t.headers.has("content-type") && Z(t.body) ? (t.headers.set("content-type", "application/json"), e = JSON.stringify(t.body)) : e = t.body;
|
|
155
155
|
const s = await this._fetch(t.url.toString(), {
|
|
156
156
|
method: t.method,
|
|
157
157
|
headers: t.headers,
|
|
158
158
|
body: e
|
|
159
|
-
}),
|
|
160
|
-
let
|
|
161
|
-
|
|
159
|
+
}), n = s.headers.get("content-type");
|
|
160
|
+
let r;
|
|
161
|
+
n != null && n.includes("application/json") ? r = await s.json() : n != null && n.includes("application/x-www-form-urlencoded") ? r = await s.formData() : r = await s.text(), this._response = {
|
|
162
162
|
method: t.method,
|
|
163
163
|
url: t.url,
|
|
164
164
|
status: s.status,
|
|
165
165
|
statusText: s.statusText,
|
|
166
166
|
headers: s.headers,
|
|
167
|
-
body:
|
|
167
|
+
body: r
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
var
|
|
171
|
+
var _e, Q, z, Pe, Ye;
|
|
172
172
|
class xt {
|
|
173
173
|
constructor(e, t) {
|
|
174
|
-
l(this,
|
|
174
|
+
l(this, z);
|
|
175
175
|
d(this, "dolla");
|
|
176
176
|
d(this, "config");
|
|
177
|
-
l(this,
|
|
178
|
-
l(this,
|
|
177
|
+
l(this, _e, !1);
|
|
178
|
+
l(this, Q, /* @__PURE__ */ new Map());
|
|
179
179
|
this.config = e, this.dolla = t;
|
|
180
180
|
}
|
|
181
181
|
async load() {
|
|
182
182
|
let e;
|
|
183
|
-
if (!i(this,
|
|
184
|
-
if (
|
|
185
|
-
if (e = await this.config.fetch(), !
|
|
183
|
+
if (!i(this, _e)) {
|
|
184
|
+
if (re(this.config.fetch)) {
|
|
185
|
+
if (e = await this.config.fetch(), !Z(e))
|
|
186
186
|
throw new Error(`Fetch function did not return an object of language strings: ${e}`);
|
|
187
187
|
} else if (E(this.config.path)) {
|
|
188
188
|
const t = await fetch(this.config.path);
|
|
189
189
|
if (t.ok) {
|
|
190
190
|
const s = await t.json();
|
|
191
|
-
if (
|
|
191
|
+
if (Z(s))
|
|
192
192
|
e = s;
|
|
193
193
|
else
|
|
194
194
|
throw new Error(
|
|
@@ -199,38 +199,38 @@ class xt {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
if (e) {
|
|
202
|
-
const t = u(this,
|
|
202
|
+
const t = u(this, z, Pe).call(this, e);
|
|
203
203
|
for (const s of t)
|
|
204
|
-
i(this,
|
|
204
|
+
i(this, Q).set(s[0], s[1]);
|
|
205
205
|
} else
|
|
206
206
|
throw new Error("Language could not be loaded.");
|
|
207
207
|
}
|
|
208
208
|
getTemplate(e) {
|
|
209
|
-
return i(this,
|
|
209
|
+
return i(this, Q).get(e) ?? {
|
|
210
210
|
segments: [{ type: 0, text: `[MISSING: ${e}]` }]
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
hasTemplate(e) {
|
|
214
|
-
return i(this,
|
|
214
|
+
return i(this, Q).has(e);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
_e = new WeakMap(), Q = new WeakMap(), z = new WeakSet(), Pe = function(e, t = []) {
|
|
218
218
|
const s = [];
|
|
219
|
-
for (const
|
|
220
|
-
switch (
|
|
219
|
+
for (const n in e)
|
|
220
|
+
switch (We(e[n])) {
|
|
221
221
|
case "string":
|
|
222
|
-
s.push([[...t,
|
|
222
|
+
s.push([[...t, n].join("."), u(this, z, Ye).call(this, e[n])]);
|
|
223
223
|
break;
|
|
224
224
|
case "object":
|
|
225
|
-
s.push(...u(this,
|
|
225
|
+
s.push(...u(this, z, Pe).call(this, e[n], [...t, n]));
|
|
226
226
|
break;
|
|
227
227
|
default:
|
|
228
228
|
throw new Error(
|
|
229
|
-
`Expected to find a string or object at ${[...t,
|
|
229
|
+
`Expected to find a string or object at ${[...t, n].join(".")}. Got: ${We(e[n])}`
|
|
230
230
|
);
|
|
231
231
|
}
|
|
232
232
|
return s;
|
|
233
|
-
},
|
|
233
|
+
}, Ye = function(e) {
|
|
234
234
|
let t;
|
|
235
235
|
((c) => {
|
|
236
236
|
c[c.Static = 0] = "Static", c[c.ValueName = 1] = "ValueName", c[c.FormatName = 2] = "FormatName", c[c.FormatOptionName = 3] = "FormatOptionName", c[c.FormatOptionValue = 4] = "FormatOptionValue", c[c.FormatOptionEnd = 5] = "FormatOptionEnd";
|
|
@@ -238,7 +238,7 @@ Re = new WeakMap(), K = new WeakMap(), B = new WeakSet(), Fe = function(e, t = [
|
|
|
238
238
|
const s = {
|
|
239
239
|
segments: []
|
|
240
240
|
};
|
|
241
|
-
let
|
|
241
|
+
let n = "", r = 0, a = 0, f, h, w;
|
|
242
242
|
const v = () => {
|
|
243
243
|
f = {
|
|
244
244
|
type: 1,
|
|
@@ -251,91 +251,91 @@ Re = new WeakMap(), K = new WeakMap(), B = new WeakSet(), Fe = function(e, t = [
|
|
|
251
251
|
options: {}
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
|
-
for (;
|
|
255
|
-
if (a !== 0 && e[
|
|
256
|
-
|
|
254
|
+
for (; r < e.length; ) {
|
|
255
|
+
if (a !== 0 && e[r] === " ") {
|
|
256
|
+
r++;
|
|
257
257
|
continue;
|
|
258
258
|
}
|
|
259
259
|
switch (a) {
|
|
260
260
|
case 0:
|
|
261
|
-
e[
|
|
261
|
+
e[r] === "{" && e[r + 1] === "{" ? (a = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""), v()) : (n += e[r], r++);
|
|
262
262
|
break;
|
|
263
263
|
case 1:
|
|
264
|
-
e[
|
|
264
|
+
e[r] === "|" ? (a = 2, r += 1, f.name = n, n = "", k()) : e[r] === "}" && e[r + 1] === "}" ? (a = 0, r += 2, f.name = n, n = "", s.segments.push(f)) : (n += e[r], r++);
|
|
265
265
|
break;
|
|
266
266
|
case 2:
|
|
267
|
-
e[
|
|
267
|
+
e[r] === "(" ? (a = 3, r += 1, h.name = n, n = "") : e[r] === "}" && e[r + 1] === "}" ? (a = 0, r += 2, f.formats.push(h), s.segments.push(f)) : (n += e[r], r++);
|
|
268
268
|
break;
|
|
269
269
|
case 3:
|
|
270
|
-
e[
|
|
270
|
+
e[r] === ")" || (e[r] === ":" ? (a = 4, r += 1, w = n, n = "") : e[r] === "}" && e[r + 1] === "}" || (n += e[r], r++));
|
|
271
271
|
break;
|
|
272
272
|
case 4:
|
|
273
|
-
e[
|
|
273
|
+
e[r] === ")" ? (a = 5, r += 1, h.options[w] = n, n = "", f.formats.push(h)) : e[r] === "," ? (a = 3, r += 1, h.options[w] = n, n = "") : e[r] === "}" && e[r + 1] === "}" || (n += e[r], r++);
|
|
274
274
|
break;
|
|
275
275
|
case 5:
|
|
276
|
-
e[
|
|
276
|
+
e[r] === "|" ? (a = 2, r += 1, k()) : e[r] === "}" && e[r + 1] === "}" && (a = 0, r += 2, s.segments.push(f));
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
return a === 0 &&
|
|
280
|
+
return a === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
|
|
281
281
|
};
|
|
282
|
-
var
|
|
283
|
-
class
|
|
282
|
+
var ie, P, b, ae, oe, le, he, $, Ze, Te, Ce, Ne, et;
|
|
283
|
+
class Dt {
|
|
284
284
|
constructor(e) {
|
|
285
|
-
l(this,
|
|
286
|
-
l(this,
|
|
285
|
+
l(this, $);
|
|
286
|
+
l(this, ie);
|
|
287
287
|
l(this, P);
|
|
288
|
-
l(this,
|
|
289
|
-
l(this,
|
|
290
|
-
l(this,
|
|
291
|
-
l(this,
|
|
288
|
+
l(this, b, /* @__PURE__ */ new Map());
|
|
289
|
+
l(this, ae, []);
|
|
290
|
+
l(this, oe, /* @__PURE__ */ new Map());
|
|
291
|
+
l(this, le, "auto");
|
|
292
292
|
d(this, "$locale");
|
|
293
|
-
l(this,
|
|
294
|
-
m(this,
|
|
295
|
-
const [t, s] =
|
|
296
|
-
this.$locale = t, m(this,
|
|
297
|
-
i(this,
|
|
293
|
+
l(this, he);
|
|
294
|
+
m(this, ie, e), m(this, P, e.createLogger("Dolla.i18n"));
|
|
295
|
+
const [t, s] = Ie();
|
|
296
|
+
this.$locale = t, m(this, he, s), this.addFormat("number", (n, r, a) => u(this, $, Te).call(this, Number(r), a)), this.addFormat("datetime", (n, r, a) => u(this, $, Ce).call(this, r, a)), this.addFormat("list", (n, r, a) => u(this, $, Ne).call(this, r, a)), e.beforeMount(async () => {
|
|
297
|
+
i(this, b).size > 0 && await this.setLocale(i(this, le));
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
300
|
get locales() {
|
|
301
|
-
return [...i(this,
|
|
301
|
+
return [...i(this, b).keys()];
|
|
302
302
|
}
|
|
303
303
|
setup(e) {
|
|
304
304
|
if (e.translations.forEach((t) => {
|
|
305
|
-
i(this,
|
|
305
|
+
i(this, b).set(t.locale, new xt(t, i(this, ie)));
|
|
306
306
|
}), e.locale && e.locale !== "auto") {
|
|
307
307
|
if (!e.translations.some((s) => s.locale === e.locale))
|
|
308
308
|
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
309
|
-
m(this,
|
|
309
|
+
m(this, le, e.locale);
|
|
310
310
|
}
|
|
311
311
|
i(this, P).info(
|
|
312
|
-
`${i(this,
|
|
312
|
+
`${i(this, b).size} language${i(this, b).size === 1 ? "" : "s"} supported: '${[...i(this, b).keys()].join("', '")}'`
|
|
313
313
|
);
|
|
314
314
|
}
|
|
315
315
|
async setLocale(e) {
|
|
316
|
-
var
|
|
316
|
+
var n;
|
|
317
317
|
let t;
|
|
318
318
|
if (e === "auto") {
|
|
319
|
-
let
|
|
319
|
+
let r = [];
|
|
320
320
|
if (typeof navigator < "u") {
|
|
321
321
|
const a = navigator;
|
|
322
|
-
((
|
|
322
|
+
((n = a.languages) == null ? void 0 : n.length) > 0 ? r.push(...a.languages) : a.language ? r.push(a.language) : a.browserLanguage ? r.push(a.browserLanguage) : a.userLanguage && r.push(a.userLanguage);
|
|
323
323
|
}
|
|
324
|
-
for (const a of
|
|
325
|
-
i(this,
|
|
324
|
+
for (const a of r)
|
|
325
|
+
i(this, b).has(a) && (t = a);
|
|
326
326
|
} else
|
|
327
|
-
i(this,
|
|
327
|
+
i(this, b).has(e) && (t = e);
|
|
328
328
|
if (t == null) {
|
|
329
|
-
const
|
|
330
|
-
|
|
329
|
+
const r = i(this, b).keys().next().value;
|
|
330
|
+
r && (t = r);
|
|
331
331
|
}
|
|
332
|
-
if (!t || !i(this,
|
|
332
|
+
if (!t || !i(this, b).has(t))
|
|
333
333
|
throw new Error(`Locale '${e}' has no translation.`);
|
|
334
|
-
const s = i(this,
|
|
334
|
+
const s = i(this, b).get(t);
|
|
335
335
|
try {
|
|
336
|
-
await s.load(), m(this,
|
|
337
|
-
} catch (
|
|
338
|
-
|
|
336
|
+
await s.load(), m(this, ae, []), i(this, he).call(this, t), i(this, P).info("set language to " + t);
|
|
337
|
+
} catch (r) {
|
|
338
|
+
r instanceof Error && i(this, P).crash(r);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
@@ -352,16 +352,16 @@ class Mt {
|
|
|
352
352
|
throw new Error(
|
|
353
353
|
`The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
|
|
354
354
|
);
|
|
355
|
-
let s = [],
|
|
356
|
-
for (const
|
|
357
|
-
s.push(
|
|
358
|
-
return
|
|
359
|
-
if (
|
|
355
|
+
let s = [], n = [];
|
|
356
|
+
for (const r in t)
|
|
357
|
+
s.push(r), n.push(t[r]);
|
|
358
|
+
return x([this.$locale, ...n], (r, ...a) => {
|
|
359
|
+
if (r == null)
|
|
360
360
|
return "[NO LOCALE SET]";
|
|
361
361
|
const f = {};
|
|
362
362
|
for (let h = 0; h < a.length; h++)
|
|
363
363
|
f[s[h]] = a[h];
|
|
364
|
-
return u(this,
|
|
364
|
+
return u(this, $, Ze).call(this, r, e, f);
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
@@ -379,7 +379,7 @@ class Mt {
|
|
|
379
379
|
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
380
380
|
*/
|
|
381
381
|
addFormat(e, t) {
|
|
382
|
-
i(this,
|
|
382
|
+
i(this, oe).set(e, t);
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
385
|
* Creates an `Intl.Collator` configured for the current locale.
|
|
@@ -396,7 +396,7 @@ class Mt {
|
|
|
396
396
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
397
397
|
*/
|
|
398
398
|
number(e, t) {
|
|
399
|
-
return
|
|
399
|
+
return x([this.$locale, e], (s, n) => u(this, $, Te).call(this, n, t));
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
402
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -408,7 +408,7 @@ class Mt {
|
|
|
408
408
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
409
409
|
*/
|
|
410
410
|
dateTime(e, t) {
|
|
411
|
-
return
|
|
411
|
+
return x([this.$locale, e], (s, n) => u(this, $, Ce).call(this, n, t));
|
|
412
412
|
}
|
|
413
413
|
/**
|
|
414
414
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -420,33 +420,33 @@ class Mt {
|
|
|
420
420
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
421
421
|
*/
|
|
422
422
|
list(e, t) {
|
|
423
|
-
return
|
|
423
|
+
return x([this.$locale, e], (s, n) => u(this, $, Ne).call(this, n, t));
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
|
|
426
|
+
ie = new WeakMap(), P = new WeakMap(), b = new WeakMap(), ae = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), he = new WeakMap(), $ = new WeakSet(), Ze = function(e, t, s) {
|
|
427
427
|
var h;
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
428
|
+
const n = u(this, $, et).call(this, t, s);
|
|
429
|
+
if (n) return n;
|
|
430
|
+
const r = i(this, b).get(e);
|
|
431
431
|
if (s.context != null && (t += "_" + s.context), s.count != null)
|
|
432
432
|
if (s.ordinal) {
|
|
433
433
|
const w = `${t}_ordinal_(=${s.count})`;
|
|
434
|
-
|
|
434
|
+
r.hasTemplate(w) ? t = w : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(s.count);
|
|
435
435
|
} else {
|
|
436
436
|
const w = `${t}_(=${s.count})`;
|
|
437
|
-
|
|
437
|
+
r.hasTemplate(w) ? t = w : t += "_" + new Intl.PluralRules(e).select(s.count);
|
|
438
438
|
}
|
|
439
|
-
const a =
|
|
439
|
+
const a = r.getTemplate(t);
|
|
440
440
|
let f = "";
|
|
441
441
|
for (const w of a.segments)
|
|
442
442
|
if (w.type === 0)
|
|
443
443
|
f += w.text;
|
|
444
444
|
else if (w.type === 1) {
|
|
445
|
-
let v =
|
|
445
|
+
let v = Ft(s, w.name);
|
|
446
446
|
const k = ((h = s.formatOverrides) == null ? void 0 : h[w.name]) ?? [...w.formats];
|
|
447
447
|
w.name === "count" && k.length === 0 && k.push({ name: "number", options: {} });
|
|
448
448
|
for (const c of k) {
|
|
449
|
-
const F = i(this,
|
|
449
|
+
const F = i(this, oe).get(c.name);
|
|
450
450
|
if (F == null) {
|
|
451
451
|
const S = new Error(
|
|
452
452
|
`Failed to load format '${c.name}' when processing '${t}', template: ${a}`
|
|
@@ -458,48 +458,48 @@ ne = new WeakMap(), P = new WeakMap(), y = new WeakMap(), ie = new WeakMap(), ae
|
|
|
458
458
|
f += v;
|
|
459
459
|
}
|
|
460
460
|
return f;
|
|
461
|
-
},
|
|
461
|
+
}, Te = function(e, t) {
|
|
462
462
|
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
463
|
-
},
|
|
463
|
+
}, Ce = function(e, t) {
|
|
464
464
|
return new Intl.DateTimeFormat(this.$locale.get(), t).format(E(e) ? new Date(e) : e);
|
|
465
|
-
},
|
|
465
|
+
}, Ne = function(e, t) {
|
|
466
466
|
return new Intl.ListFormat(this.$locale.get(), t).format(e);
|
|
467
467
|
}, // relativeTime(): State<string> {
|
|
468
468
|
// }
|
|
469
|
-
|
|
470
|
-
for (const s of i(this,
|
|
471
|
-
if (s[0] === e &&
|
|
469
|
+
et = function(e, t) {
|
|
470
|
+
for (const s of i(this, ae))
|
|
471
|
+
if (s[0] === e && ot(s[1], t))
|
|
472
472
|
return s[2];
|
|
473
473
|
};
|
|
474
|
-
function
|
|
475
|
-
const t = String(e).split(/[\.\[\]]/).filter((
|
|
474
|
+
function Ft(o, e) {
|
|
475
|
+
const t = String(e).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
476
476
|
let s = o;
|
|
477
477
|
for (; t.length > 0; ) {
|
|
478
|
-
const
|
|
479
|
-
s != null ? s = s[
|
|
478
|
+
const n = t.shift();
|
|
479
|
+
s != null ? s = s[n] : s = void 0;
|
|
480
480
|
}
|
|
481
481
|
return s;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
return
|
|
483
|
+
function se(o) {
|
|
484
|
+
return Je(o, "Expected `path` to be a string. Got type: %t, value: %v"), o.split("/").map((e) => e.trim()).filter((e) => e !== "");
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function K(o) {
|
|
487
487
|
var t;
|
|
488
|
-
|
|
489
|
-
(s) =>
|
|
488
|
+
lt(
|
|
489
|
+
(s) => re(s == null ? void 0 : s.toString),
|
|
490
490
|
o,
|
|
491
491
|
"Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
|
|
492
492
|
), o = o.filter((s) => s).flatMap(String);
|
|
493
493
|
let e = (t = o.shift()) == null ? void 0 : t.toString();
|
|
494
494
|
if (e) {
|
|
495
|
-
for (const s of o.map((
|
|
496
|
-
s.startsWith(".") ? e =
|
|
495
|
+
for (const s of o.map((n) => n.toString()))
|
|
496
|
+
s.startsWith(".") ? e = Ee(e, s) : e[e.length - 1] !== "/" ? s[0] !== "/" ? e += "/" + s : e += s : s[0] === "/" ? e += s.slice(1) : e += s;
|
|
497
497
|
e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
|
|
498
498
|
}
|
|
499
499
|
return e ?? "";
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
if (
|
|
501
|
+
function Ee(o, e) {
|
|
502
|
+
if (Je(o, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = o, o = ""), e.startsWith("/"))
|
|
503
503
|
return e;
|
|
504
504
|
let t = o;
|
|
505
505
|
for (; ; )
|
|
@@ -513,27 +513,27 @@ function ve(o, e) {
|
|
|
513
513
|
e = e.replace(/^\.\/?/, "");
|
|
514
514
|
else
|
|
515
515
|
break;
|
|
516
|
-
return
|
|
516
|
+
return K([t, e]);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Pt(o) {
|
|
519
519
|
if (!o) return {};
|
|
520
520
|
o.startsWith("?") && (o = o.slice(1));
|
|
521
521
|
const e = o.split("&").filter((t) => t.trim() !== "").map((t) => {
|
|
522
|
-
const [s,
|
|
523
|
-
return
|
|
522
|
+
const [s, n] = t.split("=").map((r) => r.trim());
|
|
523
|
+
return n.toLowerCase() === "true" ? [s, !0] : n.toLowerCase() === "false" ? [s, !1] : isNaN(Number(n)) ? [s, n] : [s, Number(n)];
|
|
524
524
|
});
|
|
525
525
|
return Object.fromEntries(e);
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function tt(o, e, t = {}) {
|
|
528
528
|
var a;
|
|
529
|
-
const [s,
|
|
529
|
+
const [s, n] = e.split("?"), r = se(s);
|
|
530
530
|
e: for (const f of o) {
|
|
531
531
|
const { fragments: h } = f;
|
|
532
|
-
if (!(((a = h[h.length - 1]) == null ? void 0 : a.type) === 3) && h.length !==
|
|
532
|
+
if (!(((a = h[h.length - 1]) == null ? void 0 : a.type) === 3) && h.length !== r.length || t.willMatch && !t.willMatch(f))
|
|
533
533
|
continue e;
|
|
534
534
|
const v = [];
|
|
535
535
|
t: for (let c = 0; c < h.length; c++) {
|
|
536
|
-
const F =
|
|
536
|
+
const F = r[c], S = h[c];
|
|
537
537
|
if (F == null && S.type !== 3)
|
|
538
538
|
continue e;
|
|
539
539
|
switch (S.type) {
|
|
@@ -547,7 +547,7 @@ function et(o, e, t = {}) {
|
|
|
547
547
|
v.push({ ...S, value: F });
|
|
548
548
|
break;
|
|
549
549
|
case 3:
|
|
550
|
-
v.push({ ...S, value:
|
|
550
|
+
v.push({ ...S, value: r.slice(c).join("/") });
|
|
551
551
|
break t;
|
|
552
552
|
case 4:
|
|
553
553
|
if (isNaN(Number(F)))
|
|
@@ -565,19 +565,19 @@ function et(o, e, t = {}) {
|
|
|
565
565
|
path: "/" + v.map((c) => c.value).join("/"),
|
|
566
566
|
pattern: "/" + h.map((c) => c.type === 2 ? `{${c.name}}` : c.type === 4 ? `{#${c.name}}` : c.name).join("/"),
|
|
567
567
|
params: k,
|
|
568
|
-
query:
|
|
568
|
+
query: Pt(n),
|
|
569
569
|
meta: f.meta
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const e = [], t = [], s = [],
|
|
573
|
+
function Tt(o) {
|
|
574
|
+
const e = [], t = [], s = [], n = [];
|
|
575
575
|
for (const a of o) {
|
|
576
576
|
const { fragments: f } = a;
|
|
577
577
|
f.some(
|
|
578
578
|
(h) => h.type === 3
|
|
579
579
|
/* Wildcard */
|
|
580
|
-
) ?
|
|
580
|
+
) ? n.push(a) : f.some(
|
|
581
581
|
(h) => h.type === 4
|
|
582
582
|
/* NumericParam */
|
|
583
583
|
) ? t.push(a) : f.some(
|
|
@@ -585,14 +585,14 @@ function Pt(o) {
|
|
|
585
585
|
/* Param */
|
|
586
586
|
) ? s.push(a) : e.push(a);
|
|
587
587
|
}
|
|
588
|
-
const
|
|
589
|
-
return e.sort(
|
|
588
|
+
const r = (a, f) => a.fragments.length > f.fragments.length ? -1 : 1;
|
|
589
|
+
return e.sort(r), t.sort(r), s.sort(r), n.sort(r), [...e, ...t, ...s, ...n];
|
|
590
590
|
}
|
|
591
|
-
function
|
|
592
|
-
const e =
|
|
591
|
+
function Ct(o) {
|
|
592
|
+
const e = se(o), t = [];
|
|
593
593
|
for (let s = 0; s < e.length; s++) {
|
|
594
|
-
const
|
|
595
|
-
if (
|
|
594
|
+
const n = e[s];
|
|
595
|
+
if (n === "*") {
|
|
596
596
|
if (s !== e.length - 1)
|
|
597
597
|
throw new Error(`Wildcard must be at the end of a pattern. Received: ${o}`);
|
|
598
598
|
t.push({
|
|
@@ -600,38 +600,38 @@ function Nt(o) {
|
|
|
600
600
|
name: "*",
|
|
601
601
|
value: null
|
|
602
602
|
});
|
|
603
|
-
} else
|
|
604
|
-
type:
|
|
605
|
-
name:
|
|
603
|
+
} else n.at(0) === "{" && n.at(-1) === "}" ? t.push({
|
|
604
|
+
type: n[1] === "#" ? 4 : 2,
|
|
605
|
+
name: n[1] === "#" ? n.slice(2, -1) : n.slice(1, -1),
|
|
606
606
|
value: null
|
|
607
607
|
}) : t.push({
|
|
608
608
|
type: 1,
|
|
609
|
-
name:
|
|
610
|
-
value:
|
|
609
|
+
name: n,
|
|
610
|
+
value: n
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
613
|
return t;
|
|
614
614
|
}
|
|
615
|
-
var
|
|
616
|
-
class
|
|
615
|
+
var q, L, Le, T, J, W, A, C, ce, p, Oe, st, rt, te, je, nt, Ve;
|
|
616
|
+
class Nt {
|
|
617
617
|
constructor(e) {
|
|
618
618
|
l(this, p);
|
|
619
|
-
l(this,
|
|
619
|
+
l(this, q);
|
|
620
620
|
l(this, L);
|
|
621
|
-
l(this,
|
|
622
|
-
l(this,
|
|
623
|
-
l(this,
|
|
621
|
+
l(this, Le, 0);
|
|
622
|
+
l(this, T, []);
|
|
623
|
+
l(this, J, []);
|
|
624
624
|
/**
|
|
625
625
|
* Use hash routing when true. Configured in router options.
|
|
626
626
|
*/
|
|
627
|
-
l(this,
|
|
627
|
+
l(this, W, !1);
|
|
628
628
|
// Callbacks that need to be called on unmount.
|
|
629
|
-
l(this,
|
|
629
|
+
l(this, A, []);
|
|
630
630
|
/**
|
|
631
631
|
* The current match object.
|
|
632
632
|
*/
|
|
633
|
-
l(this,
|
|
634
|
-
l(this,
|
|
633
|
+
l(this, C);
|
|
634
|
+
l(this, ce);
|
|
635
635
|
/**
|
|
636
636
|
* The currently matched route pattern, if any.
|
|
637
637
|
*/
|
|
@@ -648,35 +648,35 @@ class Tt {
|
|
|
648
648
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
649
649
|
*/
|
|
650
650
|
d(this, "$query");
|
|
651
|
-
m(this,
|
|
651
|
+
m(this, q, e), m(this, L, e.createLogger("Dolla.router")), [ee(this, C)._, ee(this, ce)._] = Ie(), this.$pattern = x([i(this, C)], (t) => t == null ? void 0 : t.pattern), this.$path = x([i(this, C)], (t) => (t == null ? void 0 : t.path) ?? window.location.pathname), this.$params = x([i(this, C)], (t) => (t == null ? void 0 : t.params) ?? {}, { equals: Ae }), this.$query = x([i(this, C)], (t) => (t == null ? void 0 : t.query) ?? {}, { equals: Ae }), e.beforeMount(async () => {
|
|
652
652
|
const t = () => {
|
|
653
|
-
u(this, p,
|
|
653
|
+
u(this, p, te).call(this);
|
|
654
654
|
};
|
|
655
|
-
window.addEventListener("popstate", t), i(this,
|
|
655
|
+
window.addEventListener("popstate", t), i(this, A).push(() => window.removeEventListener("popstate", t));
|
|
656
656
|
const s = e.getRootElement();
|
|
657
|
-
i(this,
|
|
658
|
-
|
|
659
|
-
let
|
|
660
|
-
i(this, L).info("intercepted click on <a> tag",
|
|
657
|
+
i(this, A).push(
|
|
658
|
+
Vt(s, (n) => {
|
|
659
|
+
let r = n.getAttribute("href");
|
|
660
|
+
i(this, L).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(r) || (r = K([window.location.pathname, r])), u(this, p, Oe).call(this, r);
|
|
661
661
|
})
|
|
662
|
-
), i(this, L).info("will intercept clicks on <a> tags within root element", s), await u(this, p,
|
|
662
|
+
), i(this, L).info("will intercept clicks on <a> tags within root element", s), await u(this, p, te).call(this);
|
|
663
663
|
}), e.onUnmount(() => {
|
|
664
|
-
for (const t of i(this,
|
|
664
|
+
for (const t of i(this, A))
|
|
665
665
|
t();
|
|
666
|
-
m(this,
|
|
666
|
+
m(this, A, []);
|
|
667
667
|
});
|
|
668
668
|
}
|
|
669
669
|
async setup(e) {
|
|
670
|
-
|
|
671
|
-
!i(this,
|
|
670
|
+
Ge(e != null, "Options object must not be null. Got: %t"), Ge(
|
|
671
|
+
!i(this, q).isMounted,
|
|
672
672
|
"Dolla is already mounted. Dolla.router.setup() must be called before Dolla.mount()."
|
|
673
|
-
), e.hash && m(this,
|
|
674
|
-
e.routes.flatMap((t) => u(this, p,
|
|
673
|
+
), e.hash && m(this, W, !0), m(this, J, Tt(
|
|
674
|
+
e.routes.flatMap((t) => u(this, p, Ve).call(this, t)).map((t) => ({
|
|
675
675
|
pattern: t.pattern,
|
|
676
676
|
meta: t.meta,
|
|
677
|
-
fragments:
|
|
677
|
+
fragments: Ct(t.pattern)
|
|
678
678
|
}))
|
|
679
|
-
)),
|
|
679
|
+
)), It(i(this, J));
|
|
680
680
|
}
|
|
681
681
|
/**
|
|
682
682
|
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
@@ -698,21 +698,21 @@ class Tt {
|
|
|
698
698
|
* Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
699
699
|
*/
|
|
700
700
|
go(e, t = {}) {
|
|
701
|
-
if (i(this,
|
|
701
|
+
if (i(this, q) == null)
|
|
702
702
|
throw new Error("Routa methods won't work until you register it: Dolla.use(Routa, { /* ...options */ })");
|
|
703
703
|
let s;
|
|
704
|
-
Array.isArray(e) ? s =
|
|
704
|
+
Array.isArray(e) ? s = K(e) : s = e.toString(), s = Ee(window.location.pathname, s), t.preserveQuery && (s += window.location.search), t.replace ? u(this, p, st).call(this, s) : u(this, p, Oe).call(this, s);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
-
|
|
708
|
-
i(this, L).info("(push)", e), window.history.pushState(t, "", i(this,
|
|
709
|
-
},
|
|
710
|
-
i(this, L).info("(replace)", e), window.history.replaceState(t, "", i(this,
|
|
711
|
-
},
|
|
712
|
-
return i(this,
|
|
713
|
-
},
|
|
714
|
-
const t = i(this, L), s = e ? new URL(e, window.location.origin) : u(this, p,
|
|
715
|
-
for (const a of
|
|
707
|
+
q = new WeakMap(), L = new WeakMap(), Le = new WeakMap(), T = new WeakMap(), J = new WeakMap(), W = new WeakMap(), A = new WeakMap(), C = new WeakMap(), ce = new WeakMap(), p = new WeakSet(), Oe = function(e, t) {
|
|
708
|
+
i(this, L).info("(push)", e), window.history.pushState(t, "", i(this, W) ? "/#" + e : e), u(this, p, te).call(this, e);
|
|
709
|
+
}, st = function(e, t) {
|
|
710
|
+
i(this, L).info("(replace)", e), window.history.replaceState(t, "", i(this, W) ? "/#" + e : e), u(this, p, te).call(this, e);
|
|
711
|
+
}, rt = function() {
|
|
712
|
+
return i(this, W) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
|
|
713
|
+
}, te = async function(e) {
|
|
714
|
+
const t = i(this, L), s = e ? new URL(e, window.location.origin) : u(this, p, rt).call(this), { match: n, journey: r } = await u(this, p, je).call(this, s);
|
|
715
|
+
for (const a of r)
|
|
716
716
|
switch (a.kind) {
|
|
717
717
|
case "match":
|
|
718
718
|
t.info(`📍 ${a.message}`);
|
|
@@ -724,58 +724,58 @@ I = new WeakMap(), L = new WeakMap(), _e = new WeakMap(), N = new WeakMap(), Q =
|
|
|
724
724
|
t.info(`💀 ${a.message}`);
|
|
725
725
|
break;
|
|
726
726
|
}
|
|
727
|
-
if (
|
|
727
|
+
if (n) {
|
|
728
728
|
const a = this.$pattern.get();
|
|
729
|
-
i(this,
|
|
729
|
+
i(this, ce).call(this, n), n.pattern !== a && u(this, p, nt).call(this, n);
|
|
730
730
|
} else
|
|
731
|
-
t.crash(new
|
|
732
|
-
return { match:
|
|
733
|
-
},
|
|
734
|
-
const s =
|
|
731
|
+
t.crash(new qt(`Failed to match route '${s.pathname}'`));
|
|
732
|
+
return { match: n, journey: r };
|
|
733
|
+
}, je = async function(e, t = []) {
|
|
734
|
+
const s = tt(i(this, J), e.pathname);
|
|
735
735
|
if (!s)
|
|
736
736
|
return {
|
|
737
737
|
match: null,
|
|
738
738
|
journey: [...t, { kind: "miss", message: `no match for '${e.pathname}'` }]
|
|
739
739
|
};
|
|
740
|
-
let
|
|
740
|
+
let n = s.meta.redirect;
|
|
741
741
|
if (s.meta.beforeMatch && await s.meta.beforeMatch({
|
|
742
742
|
// TODO: Allow setting context variables from here? Would apply to the context of the matched view.
|
|
743
|
-
redirect: (
|
|
744
|
-
|
|
743
|
+
redirect: (r) => {
|
|
744
|
+
n = r;
|
|
745
745
|
}
|
|
746
|
-
}),
|
|
747
|
-
let
|
|
748
|
-
if (E(
|
|
749
|
-
|
|
750
|
-
else if (
|
|
746
|
+
}), n != null) {
|
|
747
|
+
let r;
|
|
748
|
+
if (E(n))
|
|
749
|
+
r = Ut(n, s.params);
|
|
750
|
+
else if (re(n)) {
|
|
751
751
|
const a = {
|
|
752
752
|
path: s.path,
|
|
753
753
|
pattern: s.pattern,
|
|
754
754
|
params: s.params,
|
|
755
755
|
query: s.query
|
|
756
756
|
};
|
|
757
|
-
if (
|
|
757
|
+
if (r = await n(a), !E(r))
|
|
758
758
|
throw new Error("Redirect function must return a path to redirect to.");
|
|
759
|
-
|
|
759
|
+
r.startsWith("/") || (r = Ee(s.path, r));
|
|
760
760
|
} else
|
|
761
761
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
762
|
-
return u(this, p,
|
|
762
|
+
return u(this, p, je).call(this, new URL(r, window.location.origin), [
|
|
763
763
|
...t,
|
|
764
|
-
{ kind: "redirect", message: `redirecting '${s.path}' -> '${
|
|
764
|
+
{ kind: "redirect", message: `redirecting '${s.path}' -> '${r}'` }
|
|
765
765
|
]);
|
|
766
766
|
} else
|
|
767
767
|
return { match: s, journey: [...t, { kind: "match", message: `matched route '${s.path}'` }] };
|
|
768
768
|
}, /**
|
|
769
769
|
* Takes a matched route and mounts it.
|
|
770
770
|
*/
|
|
771
|
-
|
|
771
|
+
nt = function(e) {
|
|
772
772
|
const t = e.meta.layers;
|
|
773
773
|
for (let s = 0; s < t.length; s++) {
|
|
774
|
-
const
|
|
775
|
-
if ((
|
|
776
|
-
m(this,
|
|
777
|
-
const a = i(this,
|
|
778
|
-
i(this,
|
|
774
|
+
const n = t[s], r = i(this, T)[s];
|
|
775
|
+
if ((r == null ? void 0 : r.id) !== n.id) {
|
|
776
|
+
m(this, T, i(this, T).slice(0, s)), r == null || r.view.unmount();
|
|
777
|
+
const a = i(this, T).at(-1), h = ((a == null ? void 0 : a.view) ?? i(this, q).getRootView()).setChildView(n.view);
|
|
778
|
+
i(this, T).push({ id: n.id, view: h });
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
781
|
}, /**
|
|
@@ -784,8 +784,8 @@ rt = function(e) {
|
|
|
784
784
|
* @param route - Route config object.
|
|
785
785
|
* @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
|
|
786
786
|
*/
|
|
787
|
-
|
|
788
|
-
if (!
|
|
787
|
+
Ve = function(e, t = [], s = []) {
|
|
788
|
+
if (!Z(e) || !E(e.path))
|
|
789
789
|
throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
|
|
790
790
|
if (e.redirect && e.routes)
|
|
791
791
|
throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
|
|
@@ -793,70 +793,70 @@ je = function(e, t = [], s = []) {
|
|
|
793
793
|
throw new Error("Route cannot have both a 'redirect' and a 'view'.");
|
|
794
794
|
if (!e.view && !e.routes && !e.redirect)
|
|
795
795
|
throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
|
|
796
|
-
let
|
|
796
|
+
let n = [];
|
|
797
797
|
for (const h of t)
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const
|
|
798
|
+
n.push(...se(h.path));
|
|
799
|
+
n.push(...se(e.path)), n[n.length - 1] === "*" && n.pop();
|
|
800
|
+
const r = [];
|
|
801
801
|
if (e.redirect) {
|
|
802
802
|
let h = e.redirect;
|
|
803
|
-
return E(h) && (h =
|
|
804
|
-
pattern: "/" +
|
|
803
|
+
return E(h) && (h = Ee(K(n), h), h.startsWith("/") || (h = "/" + h)), r.push({
|
|
804
|
+
pattern: "/" + K([...n, ...se(e.path)]),
|
|
805
805
|
meta: {
|
|
806
806
|
redirect: h
|
|
807
807
|
}
|
|
808
|
-
}),
|
|
808
|
+
}), r;
|
|
809
809
|
}
|
|
810
|
-
let a =
|
|
811
|
-
if (
|
|
810
|
+
let a = Xe;
|
|
811
|
+
if (re(e.view))
|
|
812
812
|
a = e.view;
|
|
813
813
|
else if (e.view)
|
|
814
814
|
throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
|
|
815
|
-
const f = { id:
|
|
815
|
+
const f = { id: ee(this, Le)._++, view: a };
|
|
816
816
|
if (e.routes)
|
|
817
817
|
for (const h of e.routes)
|
|
818
|
-
|
|
818
|
+
r.push(...u(this, p, Ve).call(this, h, [...t, e], [...s, f]));
|
|
819
819
|
else
|
|
820
|
-
|
|
821
|
-
pattern: parent ?
|
|
820
|
+
r.push({
|
|
821
|
+
pattern: parent ? K([...t.map((h) => h.path), e.path]) : e.path,
|
|
822
822
|
meta: {
|
|
823
823
|
pattern: e.path,
|
|
824
824
|
layers: [...s, f],
|
|
825
825
|
beforeMatch: e.beforeMatch
|
|
826
826
|
}
|
|
827
827
|
});
|
|
828
|
-
return
|
|
828
|
+
return r;
|
|
829
829
|
};
|
|
830
|
-
const
|
|
831
|
-
function
|
|
832
|
-
function s(
|
|
833
|
-
return !
|
|
830
|
+
const Ot = /(noopener|noreferrer) (noopener|noreferrer)/, jt = /^[\w-_]+:/;
|
|
831
|
+
function Vt(o, e, t = window) {
|
|
832
|
+
function s(r) {
|
|
833
|
+
return !r || r === o ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
|
|
834
834
|
}
|
|
835
|
-
function r
|
|
836
|
-
if (
|
|
835
|
+
function n(r) {
|
|
836
|
+
if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
|
|
837
837
|
return;
|
|
838
|
-
const a = s(
|
|
839
|
-
a && (t.location.protocol !== a.protocol || t.location.hostname !== a.hostname || t.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" &&
|
|
838
|
+
const a = s(r.target);
|
|
839
|
+
a && (t.location.protocol !== a.protocol || t.location.hostname !== a.hostname || t.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && Ot.test(a.getAttribute("rel")) || jt.test(a.getAttribute("href")) || (r.preventDefault(), e(a)));
|
|
840
840
|
}
|
|
841
|
-
return o.addEventListener("click",
|
|
842
|
-
o.removeEventListener("click",
|
|
841
|
+
return o.addEventListener("click", n), function() {
|
|
842
|
+
o.removeEventListener("click", n);
|
|
843
843
|
};
|
|
844
844
|
}
|
|
845
|
-
function
|
|
845
|
+
function Ut(o, e) {
|
|
846
846
|
for (const t in e) {
|
|
847
847
|
const s = e[t].toString();
|
|
848
848
|
o = o.replace(`{${t}}`, s).replace(`{#${t}}`, s);
|
|
849
849
|
}
|
|
850
850
|
return o;
|
|
851
851
|
}
|
|
852
|
-
function
|
|
852
|
+
function It(o) {
|
|
853
853
|
for (const e of o)
|
|
854
854
|
if (e.meta.redirect) {
|
|
855
855
|
let t;
|
|
856
|
-
if (!
|
|
857
|
-
if (t = e.meta.redirect, !
|
|
858
|
-
willMatch(
|
|
859
|
-
return
|
|
856
|
+
if (!re(e.meta.redirect)) if (E(e.meta.redirect)) {
|
|
857
|
+
if (t = e.meta.redirect, !tt(o, t, {
|
|
858
|
+
willMatch(n) {
|
|
859
|
+
return n !== e;
|
|
860
860
|
}
|
|
861
861
|
}))
|
|
862
862
|
throw new Error(`Found a redirect to an undefined URL. From '${e.pattern}' to '${e.meta.redirect}'`);
|
|
@@ -864,10 +864,10 @@ function Ut(o) {
|
|
|
864
864
|
throw new TypeError(`Expected a string or redirect function. Got: ${e.meta.redirect}`);
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
|
-
class
|
|
867
|
+
class qt extends Error {
|
|
868
868
|
}
|
|
869
|
-
function
|
|
870
|
-
return
|
|
869
|
+
function Wt(o) {
|
|
870
|
+
return He`
|
|
871
871
|
<div
|
|
872
872
|
style=${{
|
|
873
873
|
backgroundColor: "#880000",
|
|
@@ -881,7 +881,7 @@ function qt(o) {
|
|
|
881
881
|
<h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
|
|
882
882
|
<p style=${{ marginBottom: "0.25rem" }}>
|
|
883
883
|
<span style=${{ fontFamily: "monospace" }}>${o.loggerName}</span>
|
|
884
|
-
${
|
|
884
|
+
${ht(o.uid, He`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${o.uid}]</span>`)}
|
|
885
885
|
${" "}says:
|
|
886
886
|
</p>
|
|
887
887
|
<blockquote
|
|
@@ -913,82 +913,82 @@ function qt(o) {
|
|
|
913
913
|
</div>
|
|
914
914
|
`;
|
|
915
915
|
}
|
|
916
|
-
var
|
|
917
|
-
class
|
|
916
|
+
var ue, X, N, G, H, Y, Me, M, fe, D, Ue, ke;
|
|
917
|
+
class At {
|
|
918
918
|
constructor(e) {
|
|
919
919
|
l(this, D);
|
|
920
|
-
l(this,
|
|
921
|
-
l(this,
|
|
920
|
+
l(this, ue);
|
|
921
|
+
l(this, X);
|
|
922
922
|
// Keys ensure only the most recent callback queued with a certain key
|
|
923
923
|
// will be called, keeping DOM operations to a minimum.
|
|
924
|
-
l(this,
|
|
924
|
+
l(this, N, /* @__PURE__ */ new Map());
|
|
925
925
|
// All unkeyed writes are run on every batch.
|
|
926
|
-
l(this, A, []);
|
|
927
|
-
// All read callbacks are run before updates on every batch.
|
|
928
926
|
l(this, G, []);
|
|
929
|
-
|
|
927
|
+
// All read callbacks are run before updates on every batch.
|
|
928
|
+
l(this, H, []);
|
|
929
|
+
l(this, Y, !1);
|
|
930
930
|
// When true, batches that would exceed 16ms will be split and deferred to a rAF.
|
|
931
931
|
// This may not be desirable, because while it does prevent hitching it sometimes leaves
|
|
932
932
|
// the state partially rendered for a brief second and certain elements can be seen to update after the fact.
|
|
933
933
|
// But the tradeoff here is snappier navigation with possibly slightly out of date DOM updates on heavy pages.
|
|
934
|
-
l(this,
|
|
935
|
-
l(this,
|
|
936
|
-
l(this,
|
|
934
|
+
l(this, Me, !0);
|
|
935
|
+
l(this, M, 0);
|
|
936
|
+
l(this, fe, new Intl.NumberFormat("en-US", {
|
|
937
937
|
maximumFractionDigits: 2,
|
|
938
938
|
minimumFractionDigits: 0,
|
|
939
939
|
style: "unit",
|
|
940
940
|
unit: "millisecond",
|
|
941
941
|
unitDisplay: "short"
|
|
942
942
|
}));
|
|
943
|
-
m(this,
|
|
943
|
+
m(this, ue, e), m(this, X, e.createLogger("Dolla.batch"));
|
|
944
944
|
}
|
|
945
945
|
/**
|
|
946
946
|
* Queues a callback that runs before the next batch of writes.
|
|
947
947
|
*/
|
|
948
948
|
read(e) {
|
|
949
|
-
i(this,
|
|
949
|
+
i(this, H).push(e), u(this, D, Ue).call(this);
|
|
950
950
|
}
|
|
951
951
|
/**
|
|
952
952
|
* Queues a callback to run in the next render batch.
|
|
953
953
|
* Always put DOM mutations in a write callback when possible to help Dolla batch them efficiently.
|
|
954
954
|
*/
|
|
955
955
|
write(e, t) {
|
|
956
|
-
t ? i(this,
|
|
956
|
+
t ? i(this, N).set(t, e) : i(this, G).push(e), u(this, D, Ue).call(this);
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
|
-
|
|
960
|
-
if (!i(this,
|
|
961
|
-
m(this,
|
|
962
|
-
const e = i(this,
|
|
959
|
+
ue = new WeakMap(), X = new WeakMap(), N = new WeakMap(), G = new WeakMap(), H = new WeakMap(), Y = new WeakMap(), Me = new WeakMap(), M = new WeakMap(), fe = new WeakMap(), D = new WeakSet(), Ue = function() {
|
|
960
|
+
if (!i(this, Y)) {
|
|
961
|
+
m(this, Y, !0);
|
|
962
|
+
const e = i(this, ue).getEnv() === "development";
|
|
963
963
|
queueMicrotask(() => {
|
|
964
|
-
u(this, D,
|
|
964
|
+
u(this, D, ke).call(this, e);
|
|
965
965
|
});
|
|
966
966
|
}
|
|
967
|
-
},
|
|
967
|
+
}, ke = function(e = !1) {
|
|
968
968
|
const t = performance.now();
|
|
969
969
|
let s = 0;
|
|
970
|
-
const
|
|
971
|
-
let
|
|
972
|
-
const a = () => (
|
|
973
|
-
`⚠️ Deferring batch to next frame. Performed ${
|
|
970
|
+
const n = i(this, H).length + i(this, N).size + i(this, G).length;
|
|
971
|
+
let r = 0;
|
|
972
|
+
const a = () => (r++, s = performance.now() - t, i(this, Me) && s > 12 && r < n ? (ee(this, M)._++, e && i(this, X).warn(
|
|
973
|
+
`⚠️ Deferring batch to next frame. Performed ${r} of ${n} batched operation${r === 1 ? "" : "s"} in ${i(this, fe).format(s)} (deferral ${i(this, M)}).`
|
|
974
974
|
), requestAnimationFrame(() => {
|
|
975
|
-
u(this, D,
|
|
976
|
-
}), !0) : !1), f = [...i(this,
|
|
975
|
+
u(this, D, ke).call(this, e);
|
|
976
|
+
}), !0) : !1), f = [...i(this, N).entries()];
|
|
977
977
|
let h, w;
|
|
978
|
-
for (; w = i(this,
|
|
978
|
+
for (; w = i(this, H).shift(); )
|
|
979
979
|
if (w(), a()) return;
|
|
980
980
|
for ([h, w] of f)
|
|
981
|
-
if (w(), i(this,
|
|
982
|
-
for (; w = i(this,
|
|
981
|
+
if (w(), i(this, N).delete(h), a()) return;
|
|
982
|
+
for (; w = i(this, G).shift(); )
|
|
983
983
|
if (w(), a()) return;
|
|
984
|
-
e && i(this,
|
|
985
|
-
`${s > 16 ? "⚠️ (>=16ms) " : ""}Executed ${
|
|
986
|
-
), m(this,
|
|
987
|
-
u(this, D,
|
|
988
|
-
}) : m(this,
|
|
984
|
+
e && i(this, X)[s > 16 ? "warn" : "info"](
|
|
985
|
+
`${s > 16 ? "⚠️ (>=16ms) " : ""}Executed ${r} operation${r === 1 ? "" : "s"} in ${i(this, fe).format(s)}${i(this, M) > 0 ? ` (after ${i(this, M)} deferral${i(this, M) === 1 ? "" : "s"})` : ""}.`
|
|
986
|
+
), m(this, M, 0), i(this, H).length || i(this, N).size || i(this, G).length ? queueMicrotask(() => {
|
|
987
|
+
u(this, D, ke).call(this, e);
|
|
988
|
+
}) : m(this, Y, !1);
|
|
989
989
|
};
|
|
990
|
-
var O,
|
|
991
|
-
class
|
|
990
|
+
var O, de, j, B, me, we, pe, ge, ye, be, g, y, V, U, xe;
|
|
991
|
+
class Gt {
|
|
992
992
|
constructor() {
|
|
993
993
|
d(this, "batch");
|
|
994
994
|
// Remove `private` when there are public methods to call.
|
|
@@ -997,42 +997,43 @@ class At {
|
|
|
997
997
|
d(this, "i18n");
|
|
998
998
|
d(this, "router");
|
|
999
999
|
l(this, O, !1);
|
|
1000
|
-
l(this,
|
|
1000
|
+
l(this, de, "production");
|
|
1001
1001
|
l(this, j);
|
|
1002
|
-
l(this,
|
|
1003
|
-
l(this,
|
|
1004
|
-
l(this,
|
|
1005
|
-
l(this, we, []);
|
|
1002
|
+
l(this, B);
|
|
1003
|
+
l(this, me, Wt);
|
|
1004
|
+
l(this, we, Be());
|
|
1006
1005
|
l(this, pe, []);
|
|
1007
1006
|
l(this, ge, []);
|
|
1008
1007
|
l(this, ye, []);
|
|
1009
|
-
l(this,
|
|
1008
|
+
l(this, be, []);
|
|
1009
|
+
l(this, g, {
|
|
1010
1010
|
root: this,
|
|
1011
1011
|
data: {},
|
|
1012
|
-
emitter: new
|
|
1012
|
+
emitter: new ct(),
|
|
1013
1013
|
stores: /* @__PURE__ */ new Map(),
|
|
1014
1014
|
viewName: "Dolla"
|
|
1015
1015
|
});
|
|
1016
|
-
l(this,
|
|
1016
|
+
l(this, y, {
|
|
1017
1017
|
info: "development",
|
|
1018
1018
|
log: "development",
|
|
1019
1019
|
warn: "development",
|
|
1020
1020
|
error: !0
|
|
1021
1021
|
});
|
|
1022
|
-
l(this, V,
|
|
1022
|
+
l(this, V, ze("*,-Dolla.*"));
|
|
1023
|
+
l(this, U, /* @__PURE__ */ new Map());
|
|
1023
1024
|
// Registration functions for modules.
|
|
1024
1025
|
// All modules will be registered before mount.
|
|
1025
1026
|
l(this, xe, []);
|
|
1026
|
-
d(this, "watch", i(this,
|
|
1027
|
-
d(this, "createState",
|
|
1028
|
-
d(this, "toState",
|
|
1029
|
-
d(this, "toValue",
|
|
1030
|
-
d(this, "isState",
|
|
1031
|
-
d(this, "derive",
|
|
1032
|
-
d(this, "createWatcher",
|
|
1033
|
-
d(this, "createRef",
|
|
1034
|
-
d(this, "isRef",
|
|
1035
|
-
this.batch = new
|
|
1027
|
+
d(this, "watch", i(this, we).watch);
|
|
1028
|
+
d(this, "createState", Ie);
|
|
1029
|
+
d(this, "toState", ft);
|
|
1030
|
+
d(this, "toValue", dt);
|
|
1031
|
+
d(this, "isState", mt);
|
|
1032
|
+
d(this, "derive", x);
|
|
1033
|
+
d(this, "createWatcher", Be);
|
|
1034
|
+
d(this, "createRef", wt);
|
|
1035
|
+
d(this, "isRef", pt);
|
|
1036
|
+
this.batch = new At(this), this.stats = new ut(this), this.http = new St(this), this.i18n = new Dt(this), this.router = new Nt(this);
|
|
1036
1037
|
}
|
|
1037
1038
|
/**
|
|
1038
1039
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
@@ -1045,21 +1046,21 @@ class At {
|
|
|
1045
1046
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1046
1047
|
*/
|
|
1047
1048
|
getEnv() {
|
|
1048
|
-
return i(this,
|
|
1049
|
+
return i(this, de);
|
|
1049
1050
|
}
|
|
1050
1051
|
/**
|
|
1051
1052
|
* Sets the environment that this app is running in.
|
|
1052
1053
|
* Environment affects which log messages will print and how much debugging info is included in the DOM.
|
|
1053
1054
|
*/
|
|
1054
1055
|
setEnv(e) {
|
|
1055
|
-
m(this,
|
|
1056
|
+
m(this, de, e);
|
|
1056
1057
|
}
|
|
1057
1058
|
/**
|
|
1058
1059
|
* Sets the view that will be shown when the `crash` method is called on any logger.
|
|
1059
1060
|
* When a crash is reported the app will be unmounted and replaced with this crash page.
|
|
1060
1061
|
*/
|
|
1061
1062
|
setCrashView(e) {
|
|
1062
|
-
m(this,
|
|
1063
|
+
m(this, me, e);
|
|
1063
1064
|
}
|
|
1064
1065
|
/**
|
|
1065
1066
|
* Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
|
|
@@ -1071,19 +1072,19 @@ class At {
|
|
|
1071
1072
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
1072
1073
|
*/
|
|
1073
1074
|
getRootView() {
|
|
1074
|
-
return i(this,
|
|
1075
|
+
return i(this, B);
|
|
1075
1076
|
}
|
|
1076
1077
|
/**
|
|
1077
1078
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
1078
1079
|
*/
|
|
1079
1080
|
set(e, t) {
|
|
1080
|
-
return i(this,
|
|
1081
|
+
return i(this, g).data[e] = t, t;
|
|
1081
1082
|
}
|
|
1082
1083
|
/**
|
|
1083
1084
|
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
1084
1085
|
*/
|
|
1085
1086
|
get(e) {
|
|
1086
|
-
return i(this,
|
|
1087
|
+
return i(this, g).data[e] ?? null;
|
|
1087
1088
|
}
|
|
1088
1089
|
/**
|
|
1089
1090
|
* Returns an object of all context variables stored at the app level.
|
|
@@ -1095,31 +1096,47 @@ class At {
|
|
|
1095
1096
|
* Adds a listener to be called when `eventName` is emitted.
|
|
1096
1097
|
*/
|
|
1097
1098
|
on(e, t) {
|
|
1098
|
-
|
|
1099
|
+
if (e === "*") {
|
|
1100
|
+
const s = (n, r) => {
|
|
1101
|
+
t(r);
|
|
1102
|
+
};
|
|
1103
|
+
i(this, g).emitter.on(e, s), i(this, U).set(t, s);
|
|
1104
|
+
} else
|
|
1105
|
+
i(this, g).emitter.on(e, t);
|
|
1099
1106
|
}
|
|
1100
1107
|
/**
|
|
1101
1108
|
* Removes a listener from the list to be called when `eventName` is emitted.
|
|
1102
1109
|
*/
|
|
1103
1110
|
off(e, t) {
|
|
1104
|
-
|
|
1111
|
+
if (e === "*") {
|
|
1112
|
+
const s = i(this, U).get(t);
|
|
1113
|
+
s && (i(this, g).emitter.off(e, s), i(this, U).delete(t));
|
|
1114
|
+
} else
|
|
1115
|
+
i(this, g).emitter.off(e, t);
|
|
1105
1116
|
}
|
|
1106
1117
|
/**
|
|
1107
1118
|
* Adds a listener to be called when `eventName` is emitted. The listener is immediately removed after being called once.
|
|
1108
1119
|
*/
|
|
1109
1120
|
once(e, t) {
|
|
1110
|
-
|
|
1121
|
+
if (e === "*") {
|
|
1122
|
+
const s = (n, r) => {
|
|
1123
|
+
i(this, U).delete(t), t(r);
|
|
1124
|
+
};
|
|
1125
|
+
i(this, g).emitter.once(e, s), i(this, U).set(t, s);
|
|
1126
|
+
} else
|
|
1127
|
+
i(this, g).emitter.once(e, t);
|
|
1111
1128
|
}
|
|
1112
1129
|
/**
|
|
1113
1130
|
* Emits a new event to all listeners.
|
|
1114
1131
|
*/
|
|
1115
1132
|
emit(e, t) {
|
|
1116
|
-
return i(this,
|
|
1133
|
+
return i(this, g).emitter.emit(e, new gt(e, t));
|
|
1117
1134
|
}
|
|
1118
1135
|
/**
|
|
1119
1136
|
* Attaches a new store to this context.
|
|
1120
1137
|
*/
|
|
1121
1138
|
attachStore(e) {
|
|
1122
|
-
if (!e.attach(i(this,
|
|
1139
|
+
if (!e.attach(i(this, g))) {
|
|
1123
1140
|
let s = e.name ? `'${e.name}'` : "this store";
|
|
1124
1141
|
console.warn(`An instance of ${s} was already attached to this context.`);
|
|
1125
1142
|
}
|
|
@@ -1128,35 +1145,35 @@ class At {
|
|
|
1128
1145
|
* Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
1129
1146
|
*/
|
|
1130
1147
|
useStore(e) {
|
|
1131
|
-
if (
|
|
1132
|
-
const t = e.key, s = i(this,
|
|
1148
|
+
if (yt(e)) {
|
|
1149
|
+
const t = e.key, s = i(this, g).stores.get(t);
|
|
1133
1150
|
if (s == null)
|
|
1134
|
-
throw new
|
|
1151
|
+
throw new Fe("Store not found on this context.");
|
|
1135
1152
|
return s.value;
|
|
1136
|
-
} else throw
|
|
1153
|
+
} else throw bt(e) ? new Fe(
|
|
1137
1154
|
"Received a Store instance. Please pass the Store factory function to useStore without calling it."
|
|
1138
|
-
) : new
|
|
1155
|
+
) : new Fe("Invalid store.");
|
|
1139
1156
|
}
|
|
1140
1157
|
async mount(e, t) {
|
|
1141
1158
|
if (i(this, O))
|
|
1142
1159
|
throw new Error("Dolla is already mounted.");
|
|
1143
1160
|
if (E(e)) {
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1161
|
+
const n = document.querySelector(e);
|
|
1162
|
+
Ke(HTMLElement, n, `Selector '${e}' did not match any element.`), m(this, j, n);
|
|
1146
1163
|
} else
|
|
1147
|
-
|
|
1148
|
-
const s =
|
|
1149
|
-
m(this,
|
|
1150
|
-
for (const
|
|
1151
|
-
|
|
1152
|
-
for (const
|
|
1153
|
-
|
|
1164
|
+
Ke(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), m(this, j, e);
|
|
1165
|
+
const s = $t(t ?? Xe);
|
|
1166
|
+
m(this, B, this.constructView(s.type, s.props)), await Promise.all(i(this, xe).map((n) => n())), await Promise.all(i(this, pe).map((n) => n())), i(this, B).mount(i(this, j)), m(this, O, !0);
|
|
1167
|
+
for (const n of i(this, g).stores.values())
|
|
1168
|
+
n.handleMount();
|
|
1169
|
+
for (const n of i(this, ge))
|
|
1170
|
+
n();
|
|
1154
1171
|
}
|
|
1155
1172
|
async unmount() {
|
|
1156
1173
|
var e;
|
|
1157
1174
|
if (i(this, O)) {
|
|
1158
|
-
await Promise.all(i(this,
|
|
1159
|
-
for (const t of i(this,
|
|
1175
|
+
await Promise.all(i(this, ye).map((t) => t())), (e = i(this, B)) == null || e.unmount(!1), i(this, we).stopAll(), m(this, O, !1);
|
|
1176
|
+
for (const t of i(this, be))
|
|
1160
1177
|
t();
|
|
1161
1178
|
}
|
|
1162
1179
|
}
|
|
@@ -1165,26 +1182,26 @@ class At {
|
|
|
1165
1182
|
* it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
|
|
1166
1183
|
*/
|
|
1167
1184
|
beforeMount(e) {
|
|
1168
|
-
i(this,
|
|
1185
|
+
i(this, pe).push(e);
|
|
1169
1186
|
}
|
|
1170
1187
|
/**
|
|
1171
1188
|
* Registers a `callback` to run after the app is mounted.
|
|
1172
1189
|
*/
|
|
1173
1190
|
onMount(e) {
|
|
1174
|
-
i(this,
|
|
1191
|
+
i(this, ge).push(e);
|
|
1175
1192
|
}
|
|
1176
1193
|
/**
|
|
1177
1194
|
* Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
|
|
1178
1195
|
* it will be awaited before unmounting finishes. Use this to perform cleanup.
|
|
1179
1196
|
*/
|
|
1180
1197
|
beforeUnmount(e) {
|
|
1181
|
-
i(this,
|
|
1198
|
+
i(this, ye).push(e);
|
|
1182
1199
|
}
|
|
1183
1200
|
/**
|
|
1184
1201
|
* Registers a `callback` to run after the app is unmounted.
|
|
1185
1202
|
*/
|
|
1186
1203
|
onUnmount(e) {
|
|
1187
|
-
i(this,
|
|
1204
|
+
i(this, be).push(e);
|
|
1188
1205
|
}
|
|
1189
1206
|
/**
|
|
1190
1207
|
* Update log type toggles. Values that are not passed will remain unchanged.
|
|
@@ -1192,28 +1209,28 @@ class At {
|
|
|
1192
1209
|
setLoggles(e) {
|
|
1193
1210
|
for (const t in e) {
|
|
1194
1211
|
const s = e[t];
|
|
1195
|
-
s && (i(this,
|
|
1212
|
+
s && (i(this, y)[t] = s);
|
|
1196
1213
|
}
|
|
1197
1214
|
}
|
|
1198
1215
|
setLogFilter(e) {
|
|
1199
|
-
m(this, V,
|
|
1216
|
+
m(this, V, ze(e));
|
|
1200
1217
|
}
|
|
1201
1218
|
createLogger(e, t) {
|
|
1202
|
-
const s = (t == null ? void 0 : t.console) ??
|
|
1219
|
+
const s = (t == null ? void 0 : t.console) ?? Ht(), n = this;
|
|
1203
1220
|
return {
|
|
1204
|
-
setName(
|
|
1205
|
-
return e =
|
|
1221
|
+
setName(r) {
|
|
1222
|
+
return e = r, this;
|
|
1206
1223
|
},
|
|
1207
1224
|
get info() {
|
|
1208
|
-
var
|
|
1209
|
-
if (i(
|
|
1210
|
-
return
|
|
1225
|
+
var r;
|
|
1226
|
+
if (i(n, y).info === !1 || E(i(n, y).info) && i(n, y).info !== n.getEnv() || !i(r = n, V).call(r, e))
|
|
1227
|
+
return $e;
|
|
1211
1228
|
{
|
|
1212
1229
|
let a = `%c${e}`;
|
|
1213
1230
|
return t != null && t.uid ? a += ` %c[uid: %c${t.uid}%c]` : a += "%c%c%c", s.info.bind(
|
|
1214
1231
|
s,
|
|
1215
1232
|
a,
|
|
1216
|
-
`color:${
|
|
1233
|
+
`color:${ve(a)};font-weight:bold`,
|
|
1217
1234
|
"color:#777",
|
|
1218
1235
|
"color:#aaa",
|
|
1219
1236
|
"color:#777"
|
|
@@ -1221,15 +1238,15 @@ class At {
|
|
|
1221
1238
|
}
|
|
1222
1239
|
},
|
|
1223
1240
|
get log() {
|
|
1224
|
-
var
|
|
1225
|
-
if (i(
|
|
1226
|
-
return
|
|
1241
|
+
var r;
|
|
1242
|
+
if (i(n, y).log === !1 || E(i(n, y).log) && i(n, y).log !== n.getEnv() || !i(r = n, V).call(r, e))
|
|
1243
|
+
return $e;
|
|
1227
1244
|
{
|
|
1228
1245
|
let a = `%c${e}`;
|
|
1229
1246
|
return t != null && t.uid ? a += ` %c[uid: %c${t.uid}%c]` : a += "%c%c%c", s.log.bind(
|
|
1230
1247
|
s,
|
|
1231
1248
|
a,
|
|
1232
|
-
`color:${
|
|
1249
|
+
`color:${ve(a)};font-weight:bold`,
|
|
1233
1250
|
"color:#777",
|
|
1234
1251
|
"color:#aaa",
|
|
1235
1252
|
"color:#777"
|
|
@@ -1237,15 +1254,15 @@ class At {
|
|
|
1237
1254
|
}
|
|
1238
1255
|
},
|
|
1239
1256
|
get warn() {
|
|
1240
|
-
var
|
|
1241
|
-
if (i(
|
|
1242
|
-
return
|
|
1257
|
+
var r;
|
|
1258
|
+
if (i(n, y).warn === !1 || E(i(n, y).warn) && i(n, y).warn !== n.getEnv() || !i(r = n, V).call(r, e))
|
|
1259
|
+
return $e;
|
|
1243
1260
|
{
|
|
1244
1261
|
let a = `%c${e}`;
|
|
1245
1262
|
return t != null && t.uid ? a += ` %c[uid: %c${t.uid}%c]` : a += "%c%c%c", s.warn.bind(
|
|
1246
1263
|
s,
|
|
1247
1264
|
a,
|
|
1248
|
-
`color:${
|
|
1265
|
+
`color:${ve(a)};font-weight:bold`,
|
|
1249
1266
|
"color:#777",
|
|
1250
1267
|
"color:#aaa",
|
|
1251
1268
|
"color:#777"
|
|
@@ -1253,27 +1270,27 @@ class At {
|
|
|
1253
1270
|
}
|
|
1254
1271
|
},
|
|
1255
1272
|
get error() {
|
|
1256
|
-
var
|
|
1257
|
-
if (i(
|
|
1258
|
-
return
|
|
1273
|
+
var r;
|
|
1274
|
+
if (i(n, y).error === !1 || E(i(n, y).error) && i(n, y).error !== n.getEnv() || !i(r = n, V).call(r, e))
|
|
1275
|
+
return $e;
|
|
1259
1276
|
{
|
|
1260
1277
|
let a = `%c${e}`;
|
|
1261
1278
|
return t != null && t.uid ? a += ` %c[uid: %c${t.uid}%c]` : a += "%c%c%c", s.error.bind(
|
|
1262
1279
|
s,
|
|
1263
1280
|
a,
|
|
1264
|
-
`color:${
|
|
1281
|
+
`color:${ve(a)};font-weight:bold`,
|
|
1265
1282
|
"color:#777",
|
|
1266
1283
|
"color:#aaa",
|
|
1267
1284
|
"color:#777"
|
|
1268
1285
|
);
|
|
1269
1286
|
}
|
|
1270
1287
|
},
|
|
1271
|
-
crash(
|
|
1272
|
-
throw
|
|
1273
|
-
error:
|
|
1288
|
+
crash(r) {
|
|
1289
|
+
throw n.isMounted && (n.unmount(), n.constructView(i(n, me), {
|
|
1290
|
+
error: r,
|
|
1274
1291
|
loggerName: e,
|
|
1275
1292
|
uid: t == null ? void 0 : t.uid
|
|
1276
|
-
}).mount(i(
|
|
1293
|
+
}).mount(i(n, j))), r;
|
|
1277
1294
|
}
|
|
1278
1295
|
};
|
|
1279
1296
|
}
|
|
@@ -1281,50 +1298,50 @@ class At {
|
|
|
1281
1298
|
*
|
|
1282
1299
|
*/
|
|
1283
1300
|
constructView(e, t, s = []) {
|
|
1284
|
-
return new
|
|
1301
|
+
return new vt(i(this, g), e, t, s);
|
|
1285
1302
|
}
|
|
1286
1303
|
/**
|
|
1287
1304
|
*
|
|
1288
1305
|
*/
|
|
1289
1306
|
constructMarkup(e) {
|
|
1290
|
-
return
|
|
1307
|
+
return Et(kt(i(this, g), e));
|
|
1291
1308
|
}
|
|
1292
1309
|
}
|
|
1293
|
-
O = new WeakMap(),
|
|
1294
|
-
function
|
|
1310
|
+
O = new WeakMap(), de = new WeakMap(), j = new WeakMap(), B = new WeakMap(), me = new WeakMap(), we = new WeakMap(), pe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), be = new WeakMap(), g = new WeakMap(), y = new WeakMap(), V = new WeakMap(), U = new WeakMap(), xe = new WeakMap();
|
|
1311
|
+
function Ht() {
|
|
1295
1312
|
if (typeof window < "u" && window.console)
|
|
1296
1313
|
return window.console;
|
|
1297
1314
|
if (typeof global < "u" && global.console)
|
|
1298
1315
|
return global.console;
|
|
1299
1316
|
}
|
|
1300
|
-
const
|
|
1301
|
-
function
|
|
1317
|
+
const Qe = new Gt(), Kt = Qe.i18n.t.bind(Qe.i18n);
|
|
1318
|
+
function Qt(o) {
|
|
1302
1319
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = o);
|
|
1303
1320
|
}
|
|
1304
|
-
function
|
|
1321
|
+
function Jt() {
|
|
1305
1322
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1306
1323
|
}
|
|
1307
1324
|
export {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1325
|
+
ht as cond,
|
|
1326
|
+
$t as createMarkup,
|
|
1327
|
+
wt as createRef,
|
|
1328
|
+
Ie as createState,
|
|
1329
|
+
Zt as createStore,
|
|
1330
|
+
es as createView,
|
|
1331
|
+
ot as deepEqual,
|
|
1332
|
+
Qe as default,
|
|
1333
|
+
x as derive,
|
|
1334
|
+
Jt as getDevDebug,
|
|
1335
|
+
He as html,
|
|
1336
|
+
pt as isRef,
|
|
1337
|
+
mt as isState,
|
|
1338
|
+
ts as portal,
|
|
1339
|
+
ss as repeat,
|
|
1340
|
+
Qt as setDevDebug,
|
|
1341
|
+
Ae as shallowEqual,
|
|
1342
|
+
rs as strictEqual,
|
|
1343
|
+
Kt as t,
|
|
1344
|
+
ft as toState,
|
|
1345
|
+
dt as toValue
|
|
1329
1346
|
};
|
|
1330
1347
|
//# sourceMappingURL=index.js.map
|