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