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