@manyducks.co/dolla 2.0.0-alpha.47 → 2.0.0-alpha.49

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.
@@ -1,8 +1,8 @@
1
- import { m } from "./markup-B-2w-v-S.js";
1
+ import { m } from "./markup-D67RWnAp.js";
2
2
  function a(r, n) {
3
3
  return m("$dynamic", { source: () => r.children });
4
4
  }
5
5
  export {
6
6
  a as F
7
7
  };
8
- //# sourceMappingURL=fragment-vl5kFl1d.js.map
8
+ //# sourceMappingURL=fragment-CTSra5ph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fragment-vl5kFl1d.js","sources":["../src/core/views/fragment.ts"],"sourcesContent":["import type { Renderable } from \"../../types.js\";\nimport { markup } from \"../markup.js\";\nimport { type ViewContext } from \"../nodes/view.js\";\n\n/**\n * A utility view that displays its children.\n */\nexport function Fragment(props: { children?: Renderable }, ctx: ViewContext) {\n return markup(\"$dynamic\", { source: () => props.children });\n}\n"],"names":["Fragment","props","ctx","markup"],"mappings":";AAOgB,SAAAA,EAASC,GAAkCC,GAAkB;AAC3E,SAAOC,EAAO,YAAY,EAAE,QAAQ,MAAMF,EAAM,UAAU;AAC5D;"}
1
+ {"version":3,"file":"fragment-CTSra5ph.js","sources":["../src/core/views/fragment.ts"],"sourcesContent":["import type { Renderable } from \"../../types.js\";\nimport { markup } from \"../markup.js\";\nimport { type ViewContext } from \"../nodes/view.js\";\n\n/**\n * A utility view that displays its children.\n */\nexport function Fragment(props: { children?: Renderable }, ctx: ViewContext) {\n return markup(\"$dynamic\", { source: () => props.children });\n}\n"],"names":["Fragment","props","ctx","markup"],"mappings":";AAOgB,SAAAA,EAASC,GAAkCC,GAAkB;AAC3E,SAAOC,EAAO,YAAY,EAAE,QAAQ,MAAMF,EAAM,UAAU;AAC5D;"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- var Qt = Object.defineProperty;
1
+ var zt = Object.defineProperty;
2
2
  var St = (i) => {
3
3
  throw TypeError(i);
4
4
  };
5
- var zt = (i, t, e) => t in i ? Qt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var g = (i, t, e) => zt(i, typeof t != "symbol" ? t + "" : t, e), gt = (i, t, e) => t.has(i) || St("Cannot " + e);
5
+ var Bt = (i, t, e) => t in i ? zt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
+ var g = (i, t, e) => Bt(i, typeof t != "symbol" ? t + "" : t, e), gt = (i, t, e) => t.has(i) || St("Cannot " + e);
7
7
  var a = (i, t, e) => (gt(i, t, "read from private field"), e ? e.call(i) : t.get(i)), f = (i, t, e) => t.has(i) ? St("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), p = (i, t, e, s) => (gt(i, t, "write to private field"), s ? s.call(i, e) : t.set(i, e), e), d = (i, t, e) => (gt(i, t, "access private method"), e);
8
8
  var _t = (i, t, e, s) => ({
9
9
  set _(n) {
@@ -13,17 +13,17 @@ var _t = (i, t, e, s) => ({
13
13
  return a(i, t, s);
14
14
  }
15
15
  });
16
- import { a as Bt, b as jt, i as H, I as Ft, $ as R, c as Kt, p as Jt, d as Xt, e as D, f as q, s as Mt, g as Yt, t as xt, h as ht, m as M, w as Zt, j as Pt, S as te, k as Tt, l as qt, V as ee, n as se, o as re, q as ne, r as ie } from "./markup-B-2w-v-S.js";
17
- import { u as Ce, x as Ve, y as De, v as Ae, z as We } from "./markup-B-2w-v-S.js";
18
- function Ot(i, t) {
16
+ import { a as Kt, b as Ft, i as H, I as Ot, $ as R, c as Jt, p as Mt, d as Xt, e as D, f as q, s as xt, g as Yt, t as Pt, h as ht, m as M, w as Zt, j as Tt, S as te, k as qt, l as Lt, V as ee, n as se, o as re, q as ne, r as ie } from "./markup-D67RWnAp.js";
17
+ import { u as Ce, x as Ve, y as De, v as Ae, z as We } from "./markup-D67RWnAp.js";
18
+ function Nt(i, t) {
19
19
  return t.outlet();
20
20
  }
21
21
  function K(i) {
22
- return jt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((t) => t.trim()).filter((t) => t !== "");
22
+ return Ft(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((t) => t.trim()).filter((t) => t !== "");
23
23
  }
24
24
  function z(i) {
25
25
  var e;
26
- Bt(
26
+ Kt(
27
27
  (s) => H(s == null ? void 0 : s.toString),
28
28
  i,
29
29
  "Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
@@ -37,7 +37,7 @@ function z(i) {
37
37
  return t ?? "";
38
38
  }
39
39
  function ut(i, t) {
40
- if (jt(i, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = i, i = ""), t.startsWith("/"))
40
+ if (Ft(i, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = i, i = ""), t.startsWith("/"))
41
41
  return t;
42
42
  let e = i;
43
43
  for (; ; )
@@ -61,7 +61,7 @@ function ae(i) {
61
61
  );
62
62
  return Object.fromEntries(t);
63
63
  }
64
- function Nt(i, t, e = {}) {
64
+ function Ut(i, t, e = {}) {
65
65
  var o;
66
66
  const [s, n] = t.split("?"), r = K(s);
67
67
  t: for (const c of i) {
@@ -174,21 +174,21 @@ function fe(i, t) {
174
174
  function Le(i) {
175
175
  return new pe(i);
176
176
  }
177
- const Ut = Symbol.for("DollaRouterMountMethod"), It = Symbol.for("DollaRouterUnmountMethod");
177
+ const It = Symbol.for("DollaRouterMountMethod"), Ct = Symbol.for("DollaRouterUnmountMethod");
178
178
  function yt(i) {
179
- return (i == null ? void 0 : i[Ft]) === !0;
179
+ return (i == null ? void 0 : i[Ot]) === !0;
180
180
  }
181
181
  async function de(i, t) {
182
- return i[Ut](t);
182
+ return i[It](t);
183
183
  }
184
184
  async function me(i) {
185
- return i[It]();
185
+ return i[Ct]();
186
186
  }
187
- var Lt, J, P, ft, L, U, X, T, I, S, w, Ct, Vt, Dt, B, At, bt, vt;
187
+ var jt, J, P, ft, L, U, X, T, I, S, w, Vt, Dt, At, B, Wt, bt, vt;
188
188
  class pe {
189
189
  constructor(t) {
190
190
  f(this, w);
191
- g(this, Lt, !0);
191
+ g(this, jt, !0);
192
192
  f(this, J);
193
193
  f(this, P);
194
194
  f(this, ft, 0);
@@ -225,15 +225,15 @@ class pe {
225
225
  g(this, "params", R(() => {
226
226
  var t;
227
227
  return ((t = a(this, S).call(this)) == null ? void 0 : t.params) ?? {};
228
- }, { equals: Mt }));
228
+ }, { equals: xt }));
229
229
  /**
230
230
  * The current query params. Changes to this object will be reflected in the URL.
231
231
  */
232
232
  g(this, "query", R(() => {
233
233
  var t;
234
234
  return ((t = a(this, S).call(this)) == null ? void 0 : t.query) ?? {};
235
- }, { equals: Mt }));
236
- Kt(t, "Options must be an object. Got: %t"), t.hash && p(this, T, !0), p(this, U, oe(
235
+ }, { equals: xt }));
236
+ Jt(t, "Options must be an object. Got: %t"), t.hash && p(this, T, !0), p(this, U, oe(
237
237
  t.routes.flatMap((e) => d(this, w, vt).call(this, e)).map((e) => ({
238
238
  pattern: e.pattern,
239
239
  meta: e.meta,
@@ -241,7 +241,7 @@ class pe {
241
241
  }))
242
242
  )), console.log({ routes: t.routes, prepared: a(this, U) }), we(a(this, U));
243
243
  }
244
- async [(Lt = Ft, Ut)](t) {
244
+ async [(jt = Ot, It)](t) {
245
245
  p(this, J, t), p(this, P, t.createLogger("Dolla.router"));
246
246
  const e = () => {
247
247
  d(this, w, B).call(this, void 0, {});
@@ -259,7 +259,7 @@ class pe {
259
259
  })
260
260
  ), a(this, P).info("will intercept clicks on <a> tags within root element", s), p(this, X, !0), await d(this, w, B).call(this, void 0, {});
261
261
  }
262
- async [It]() {
262
+ async [Ct]() {
263
263
  for (const t of a(this, I))
264
264
  t();
265
265
  p(this, I, []);
@@ -285,13 +285,13 @@ class pe {
285
285
  */
286
286
  go(t, e = {}) {
287
287
  let s;
288
- Array.isArray(t) ? s = z(t) : s = t.toString(), s = ut(window.location.pathname, s), e.replace ? d(this, w, Vt).call(this, s, e) : d(this, w, Ct).call(this, s, e);
288
+ Array.isArray(t) ? s = z(t) : s = t.toString(), s = ut(window.location.pathname, s), e.replace ? d(this, w, Dt).call(this, s, e) : d(this, w, Vt).call(this, s, e);
289
289
  }
290
290
  /**
291
291
  * Updates query params, keeping existing ones and applying new ones. Removes the query param if value is set to `null`.
292
292
  */
293
293
  updateQuery(t) {
294
- const e = a(this, S).call(this), s = { ...this.query() };
294
+ const e = Mt(a(this, S)), s = { ...this.query() };
295
295
  for (const o in t) {
296
296
  const c = t[o];
297
297
  c === null ? delete s[o] : s[o] = c.toString();
@@ -303,17 +303,17 @@ class pe {
303
303
  a(this, S).call(this, { ...e, query: s }), window.history.replaceState(null, "", a(this, T) ? "/#" + e.path + r : e.path + r);
304
304
  }
305
305
  }
306
- J = new WeakMap(), P = new WeakMap(), ft = new WeakMap(), L = new WeakMap(), U = new WeakMap(), X = new WeakMap(), T = new WeakMap(), I = new WeakMap(), S = new WeakMap(), w = new WeakSet(), Ct = function(t, e) {
306
+ J = new WeakMap(), P = new WeakMap(), ft = new WeakMap(), L = new WeakMap(), U = new WeakMap(), X = new WeakMap(), T = new WeakMap(), I = new WeakMap(), S = new WeakMap(), w = new WeakSet(), Vt = function(t, e) {
307
307
  var s;
308
308
  (s = a(this, P)) == null || s.info("(push)", t), window.history.pushState(null, "", a(this, T) ? "/#" + t : t), d(this, w, B).call(this, t, e);
309
- }, Vt = function(t, e) {
309
+ }, Dt = function(t, e) {
310
310
  var s;
311
311
  (s = a(this, P)) == null || s.info("(replace)", t), window.history.replaceState(null, "", a(this, T) ? "/#" + t : t), d(this, w, B).call(this, t, e);
312
- }, Dt = function() {
312
+ }, At = function() {
313
313
  return a(this, T) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
314
314
  }, B = async function(t, e) {
315
315
  var l;
316
- const s = a(this, P), n = (l = a(this, J)) == null ? void 0 : l.getRootView(), r = t ? new URL(t, window.location.origin) : d(this, w, Dt).call(this), { match: o, journey: c } = await d(this, w, bt).call(this, r);
316
+ const s = a(this, P), n = (l = a(this, J)) == null ? void 0 : l.getRootView(), r = t ? new URL(t, window.location.origin) : d(this, w, At).call(this), { match: o, journey: c } = await d(this, w, bt).call(this, r);
317
317
  for (const u of c)
318
318
  switch (u.kind) {
319
319
  case "match":
@@ -327,7 +327,7 @@ J = new WeakMap(), P = new WeakMap(), ft = new WeakMap(), L = new WeakMap(), U =
327
327
  break;
328
328
  }
329
329
  if (o) {
330
- const u = Jt(this.pattern);
330
+ const u = Mt(this.pattern);
331
331
  let m = o.query, y = [];
332
332
  if (e.preserveQuery === !0)
333
333
  m = Object.assign({}, this.query(), o.query);
@@ -340,14 +340,14 @@ J = new WeakMap(), P = new WeakMap(), ft = new WeakMap(), L = new WeakMap(), U =
340
340
  for (const k in m)
341
341
  y.push(`${k}=${m[k]}`);
342
342
  const h = y.length > 0 ? "?" + y.join("&") : "";
343
- a(this, S).call(this, { ...o, query: m }), n && (o.path !== location.pathname || location.search !== h) && window.history.replaceState(null, "", a(this, T) ? "/#" + o.path + h : o.path + h), n && o.pattern !== u && d(this, w, At).call(this, n, o);
343
+ a(this, S).call(this, { ...o, query: m }), n && (o.path !== location.pathname || location.search !== h) && window.history.replaceState(null, "", a(this, T) ? "/#" + o.path + h : o.path + h), n && o.pattern !== u && d(this, w, Wt).call(this, n, o);
344
344
  } else
345
345
  a(this, X) && s.crash(new ye(`Failed to match route '${r.pathname}'`));
346
346
  return { match: o, journey: c };
347
347
  }, /**
348
348
  * Takes a matched route and mounts it.
349
349
  */
350
- At = function(t, e) {
350
+ Wt = function(t, e) {
351
351
  const s = e.meta.layers;
352
352
  for (let n = 0; n < s.length; n++) {
353
353
  const r = s[n], o = a(this, L)[n];
@@ -360,7 +360,7 @@ At = function(t, e) {
360
360
  }, bt = async function(t, e = []) {
361
361
  return new Promise((s, n) => {
362
362
  var l;
363
- const r = Nt(a(this, U), t.pathname);
363
+ const r = Ut(a(this, U), t.pathname);
364
364
  if (!r)
365
365
  return s({
366
366
  match: null,
@@ -397,7 +397,7 @@ At = function(t, e) {
397
397
  const u = r.meta.beforeMatch;
398
398
  let m = -1;
399
399
  const y = () => {
400
- m++, console.warn("blep", { i: m, callbacks: u }), m === u.length ? c() : u[m]({
400
+ m++, m === u.length ? c() : u[m]({
401
401
  path: r.path,
402
402
  pattern: r.pattern,
403
403
  params: r.params,
@@ -442,7 +442,7 @@ vt = function(t, e = [], s = []) {
442
442
  }
443
443
  }), r;
444
444
  }
445
- let o = Ot;
445
+ let o = Nt;
446
446
  if (H(t.view))
447
447
  o = t.view;
448
448
  else if (t.view)
@@ -467,7 +467,7 @@ function we(i) {
467
467
  if (t.meta.redirect) {
468
468
  let e;
469
469
  if (!H(t.meta.redirect)) if (q(t.meta.redirect)) {
470
- if (e = t.meta.redirect, !Nt(i, e, {
470
+ if (e = t.meta.redirect, !Ut(i, e, {
471
471
  willMatch(n) {
472
472
  return n !== t;
473
473
  }
@@ -637,7 +637,7 @@ class $e {
637
637
  };
638
638
  }
639
639
  }
640
- var mt, W, A, kt, Wt;
640
+ var mt, W, A, kt, Gt;
641
641
  class Re {
642
642
  constructor(t, e) {
643
643
  f(this, A);
@@ -688,20 +688,20 @@ class Re {
688
688
  mt = new WeakMap(), W = new WeakMap(), A = new WeakSet(), kt = function(t, e = []) {
689
689
  const s = [];
690
690
  for (const n in t)
691
- switch (xt(t[n])) {
691
+ switch (Pt(t[n])) {
692
692
  case "string":
693
- s.push([[...e, n].join("."), d(this, A, Wt).call(this, t[n])]);
693
+ s.push([[...e, n].join("."), d(this, A, Gt).call(this, t[n])]);
694
694
  break;
695
695
  case "object":
696
696
  s.push(...d(this, A, kt).call(this, t[n], [...e, n]));
697
697
  break;
698
698
  default:
699
699
  throw new Error(
700
- `Expected to find a string or object at ${[...e, n].join(".")}. Got: ${xt(t[n])}`
700
+ `Expected to find a string or object at ${[...e, n].join(".")}. Got: ${Pt(t[n])}`
701
701
  );
702
702
  }
703
703
  return s;
704
- }, Wt = function(t) {
704
+ }, Gt = function(t) {
705
705
  let e;
706
706
  ((h) => {
707
707
  h[h.Static = 0] = "Static", h[h.ValueName = 1] = "ValueName", h[h.FormatName = 2] = "FormatName", h[h.FormatOptionName = 3] = "FormatOptionName", h[h.FormatOptionValue = 4] = "FormatOptionValue", h[h.FormatOptionEnd = 5] = "FormatOptionEnd";
@@ -750,7 +750,7 @@ mt = new WeakMap(), W = new WeakMap(), A = new WeakSet(), kt = function(t, e = [
750
750
  }
751
751
  return o === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
752
752
  };
753
- var Y, j, b, Z, tt, et, _, v, Gt, Et, $t, Rt, Ht;
753
+ var Y, j, b, Z, tt, et, _, v, Ht, Et, $t, Rt, Qt;
754
754
  class Se {
755
755
  constructor(t) {
756
756
  f(this, v);
@@ -760,7 +760,7 @@ class Se {
760
760
  f(this, Z, []);
761
761
  f(this, tt, /* @__PURE__ */ new Map());
762
762
  f(this, et, "auto");
763
- f(this, _, R(""));
763
+ f(this, _, R("en"));
764
764
  g(this, "locale", R(a(this, _)));
765
765
  p(this, Y, t), p(this, j, t.createLogger("Dolla.i18n")), this.addFormat("number", (e, s, n) => d(this, v, Et).call(this, Number(s), n)), this.addFormat("datetime", (e, s, n) => d(this, v, $t).call(this, s, n)), this.addFormat("list", (e, s, n) => d(this, v, Rt).call(this, s, n)), t.beforeMount(async () => {
766
766
  a(this, b).size > 0 && await this.setLocale(a(this, et));
@@ -825,7 +825,7 @@ class Se {
825
825
  const s = {};
826
826
  for (const n in e)
827
827
  s[n] = ht(e[n]);
828
- return d(this, v, Gt).call(this, a(this, _).call(this), t, s);
828
+ return d(this, v, Ht).call(this, a(this, _).call(this), t, s);
829
829
  });
830
830
  }
831
831
  /**
@@ -887,9 +887,9 @@ class Se {
887
887
  return R(() => d(this, v, Rt).call(this, ht(t), e));
888
888
  }
889
889
  }
890
- Y = new WeakMap(), j = new WeakMap(), b = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), _ = new WeakMap(), v = new WeakSet(), Gt = function(t, e, s) {
890
+ Y = new WeakMap(), j = new WeakMap(), b = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), _ = new WeakMap(), v = new WeakSet(), Ht = function(t, e, s) {
891
891
  var l;
892
- const n = d(this, v, Ht).call(this, e, s);
892
+ const n = d(this, v, Qt).call(this, e, s);
893
893
  if (n) return n;
894
894
  const r = a(this, b).get(t);
895
895
  if (s.context != null && (e += "_" + s.context), s.count != null)
@@ -930,7 +930,7 @@ Y = new WeakMap(), j = new WeakMap(), b = new WeakMap(), Z = new WeakMap(), tt =
930
930
  return new Intl.ListFormat(a(this, _).call(this), e).format(t);
931
931
  }, // relativeTime(): State<string> {
932
932
  // }
933
- Ht = function(t, e) {
933
+ Qt = function(t, e) {
934
934
  for (const s of a(this, Z))
935
935
  if (s[0] === t && Yt(s[1], e))
936
936
  return s[2];
@@ -1023,7 +1023,7 @@ class xe {
1023
1023
  warn: "development",
1024
1024
  error: !0
1025
1025
  });
1026
- f(this, ct, Pt("*,-Dolla.*"));
1026
+ f(this, ct, Tt("*,-Dolla.*"));
1027
1027
  // Registration functions for modules.
1028
1028
  // All modules will be registered before mount.
1029
1029
  f(this, pt, []);
@@ -1084,21 +1084,21 @@ class xe {
1084
1084
  if (H(t)) {
1085
1085
  const e = a(this, N).stores.get(t);
1086
1086
  if (e == null)
1087
- throw new Tt("Store not found on this context.");
1087
+ throw new qt("Store not found on this context.");
1088
1088
  return e.value;
1089
1089
  } else
1090
- throw new Tt("Invalid store.");
1090
+ throw new qt("Invalid store.");
1091
1091
  }
1092
1092
  async mount(t, e) {
1093
1093
  if (a(this, F))
1094
1094
  throw new Error("Dolla is already mounted.");
1095
1095
  if (q(t)) {
1096
1096
  const r = document.querySelector(t);
1097
- qt(HTMLElement, r, `Selector '${t}' did not match any element.`), p(this, O, r);
1097
+ Lt(HTMLElement, r, `Selector '${t}' did not match any element.`), p(this, O, r);
1098
1098
  } else
1099
- qt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), p(this, O, t);
1099
+ Lt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), p(this, O, t);
1100
1100
  yt(e) && p(this, G, e);
1101
- const s = yt(e) ? Ot : e, n = M(s);
1101
+ const s = yt(e) ? Nt : e, n = M(s);
1102
1102
  p(this, V, this.constructView(n.type, n.props)), await Promise.all(a(this, pt).map((r) => r())), await Promise.all(a(this, nt).map((r) => r()));
1103
1103
  for (const r of a(this, N).stores.values())
1104
1104
  r.handleMount();
@@ -1150,7 +1150,7 @@ class xe {
1150
1150
  }
1151
1151
  }
1152
1152
  setLogFilter(t) {
1153
- p(this, ct, Pt(t));
1153
+ p(this, ct, Tt(t));
1154
1154
  }
1155
1155
  createLogger(t, e) {
1156
1156
  const s = (e == null ? void 0 : e.console) ?? Pe(), n = this, r = a(this, lt), o = (c) => {
@@ -1225,10 +1225,10 @@ export {
1225
1225
  Oe as http,
1226
1226
  Fe as i18n,
1227
1227
  M as markup,
1228
- Jt as peek,
1228
+ Mt as peek,
1229
1229
  Ve as portal,
1230
1230
  De as repeat,
1231
- Mt as shallowEqual,
1231
+ xt as shallowEqual,
1232
1232
  Ae as strictEqual,
1233
1233
  je as t,
1234
1234
  We as unless,