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