@manyducks.co/dolla 2.0.0-alpha.23 → 2.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -22
- package/dist/core/dolla.d.ts +3 -4
- package/dist/core/nodes/html.d.ts +2 -0
- package/dist/core/nodes/observer.d.ts +3 -6
- package/dist/core/nodes/outlet.d.ts +5 -4
- package/dist/core/nodes/view.d.ts +1 -0
- package/dist/core/state.d.ts +44 -35
- package/dist/index.d.ts +4 -4
- package/dist/index.js +97 -99
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{passthrough-C9975ULD.js → passthrough-D_L3EUe_.js} +362 -465
- package/dist/passthrough-D_L3EUe_.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/docs/setup.md +22 -0
- package/docs/states.md +38 -2
- package/notes/scratch.md +116 -15
- package/package.json +1 -1
- package/dist/passthrough-C9975ULD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -13,9 +13,9 @@ var Y = (o, e, t, r) => ({
|
|
|
13
13
|
return a(o, e, r);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
import { h as Ie, c as it, i as ke, a as Ve, d as F, b as k, e as ot, f as te, t as We, g as Qe, j as lt, s as _e, k as Ge, P as Je, l as Be, m as ze, n as ct, o as ht, p as ut,
|
|
17
|
-
import { B as
|
|
18
|
-
function
|
|
16
|
+
import { h as Ie, c as it, i as ke, a as Ve, d as F, b as k, e as ot, f as te, t as We, g as Qe, j as lt, s as _e, k as Ge, P as Je, l as Be, m as ze, n as ct, o as ht, p as ut, q as ft, r as dt, u as He, v as mt, w as be, x as $e, V as gt, y as pt, z as wt } from "./passthrough-D_L3EUe_.js";
|
|
17
|
+
import { B as zt, C as Ht, A as Kt } from "./passthrough-D_L3EUe_.js";
|
|
18
|
+
function yt(o) {
|
|
19
19
|
return Ie`
|
|
20
20
|
<div
|
|
21
21
|
style=${{
|
|
@@ -63,7 +63,7 @@ function bt(o) {
|
|
|
63
63
|
`;
|
|
64
64
|
}
|
|
65
65
|
var re, K, N, V, A, Q, Re, M, se, q, Ne, ve;
|
|
66
|
-
class
|
|
66
|
+
class bt {
|
|
67
67
|
constructor(e) {
|
|
68
68
|
l(this, q);
|
|
69
69
|
l(this, re);
|
|
@@ -131,11 +131,11 @@ re = new WeakMap(), K = new WeakMap(), N = new WeakMap(), V = new WeakMap(), A =
|
|
|
131
131
|
}) : g(this, Q, !1);
|
|
132
132
|
};
|
|
133
133
|
var I, Se, Le, ne, S, L;
|
|
134
|
-
class
|
|
134
|
+
class $t {
|
|
135
135
|
constructor(e) {
|
|
136
136
|
l(this, S);
|
|
137
137
|
l(this, I, []);
|
|
138
|
-
l(this, Se,
|
|
138
|
+
l(this, Se, vt());
|
|
139
139
|
l(this, Le);
|
|
140
140
|
l(this, ne);
|
|
141
141
|
g(this, Le, e), g(this, ne, e.createLogger("dolla/http"));
|
|
@@ -177,7 +177,7 @@ class vt {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
I = new WeakMap(), Se = new WeakMap(), Le = new WeakMap(), ne = new WeakMap(), S = new WeakSet(), L = async function(e, t, r) {
|
|
180
|
-
return
|
|
180
|
+
return kt({
|
|
181
181
|
...r,
|
|
182
182
|
method: e,
|
|
183
183
|
uri: t,
|
|
@@ -186,14 +186,14 @@ I = new WeakMap(), Se = new WeakMap(), Le = new WeakMap(), ne = new WeakMap(), S
|
|
|
186
186
|
logger: a(this, ne)
|
|
187
187
|
});
|
|
188
188
|
};
|
|
189
|
-
function
|
|
189
|
+
function vt() {
|
|
190
190
|
if (typeof window < "u" && window.fetch)
|
|
191
191
|
return window.fetch.bind(window);
|
|
192
192
|
if (typeof global < "u" && global.fetch)
|
|
193
193
|
return global.fetch.bind(global);
|
|
194
194
|
throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
|
|
195
195
|
}
|
|
196
|
-
class
|
|
196
|
+
class Et extends Error {
|
|
197
197
|
constructor(t) {
|
|
198
198
|
const { status: r, statusText: n, method: s, uri: i } = t, f = `${r} ${n}: Request failed (${s.toUpperCase()} ${i})`;
|
|
199
199
|
super(f);
|
|
@@ -201,7 +201,7 @@ class kt extends Error {
|
|
|
201
201
|
this.response = t;
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
async function
|
|
204
|
+
async function kt(o) {
|
|
205
205
|
const { headers: e, query: t, fetch: r, middleware: n, logger: s } = o, i = {
|
|
206
206
|
method: o.method,
|
|
207
207
|
uri: o.uri,
|
|
@@ -265,11 +265,11 @@ async function Rt(o) {
|
|
|
265
265
|
} else
|
|
266
266
|
await c();
|
|
267
267
|
if (f.status < 200 || f.status >= 400)
|
|
268
|
-
throw new
|
|
268
|
+
throw new Et(f);
|
|
269
269
|
return f;
|
|
270
270
|
}
|
|
271
271
|
var Me, J, z, Pe, Xe;
|
|
272
|
-
class
|
|
272
|
+
class Rt {
|
|
273
273
|
constructor(e, t) {
|
|
274
274
|
l(this, z);
|
|
275
275
|
p(this, "dolla");
|
|
@@ -379,8 +379,8 @@ Me = new WeakMap(), J = new WeakMap(), z = new WeakSet(), Pe = function(e, t = [
|
|
|
379
379
|
}
|
|
380
380
|
return i === 0 && n.length > 0 && r.segments.push({ type: 0, text: n }), r;
|
|
381
381
|
};
|
|
382
|
-
var ae, P, v, ie, oe, le, ce, E, Ye,
|
|
383
|
-
class
|
|
382
|
+
var ae, P, v, ie, oe, le, ce, E, Ye, Te, De, je, Ze;
|
|
383
|
+
class St {
|
|
384
384
|
constructor(e) {
|
|
385
385
|
l(this, E);
|
|
386
386
|
l(this, ae);
|
|
@@ -393,7 +393,7 @@ class Lt {
|
|
|
393
393
|
l(this, ce);
|
|
394
394
|
g(this, ae, e), g(this, P, e.createLogger("dolla/i18n"));
|
|
395
395
|
const [t, r] = Ve();
|
|
396
|
-
this.$locale = t, g(this, ce, r), this.addFormat("number", (n, s, i) => d(this, E,
|
|
396
|
+
this.$locale = t, g(this, ce, r), this.addFormat("number", (n, s, i) => d(this, E, Te).call(this, Number(s), i)), this.addFormat("datetime", (n, s, i) => d(this, E, De).call(this, s, i)), this.addFormat("list", (n, s, i) => d(this, E, je).call(this, s, i)), e.beforeMount(async () => {
|
|
397
397
|
a(this, v).size > 0 && await this.setLocale(a(this, le));
|
|
398
398
|
});
|
|
399
399
|
}
|
|
@@ -402,7 +402,7 @@ class Lt {
|
|
|
402
402
|
}
|
|
403
403
|
setup(e) {
|
|
404
404
|
if (e.translations.forEach((t) => {
|
|
405
|
-
a(this, v).set(t.locale, new
|
|
405
|
+
a(this, v).set(t.locale, new Rt(t, a(this, ae)));
|
|
406
406
|
}), e.locale && e.locale !== "auto") {
|
|
407
407
|
if (!e.translations.some((r) => r.locale === e.locale))
|
|
408
408
|
throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
|
|
@@ -496,7 +496,7 @@ class Lt {
|
|
|
496
496
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
497
497
|
*/
|
|
498
498
|
number(e, t) {
|
|
499
|
-
return F([this.$locale, e], (r, n) => d(this, E,
|
|
499
|
+
return F([this.$locale, e], (r, n) => d(this, E, Te).call(this, n, t));
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -508,7 +508,7 @@ class Lt {
|
|
|
508
508
|
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
509
509
|
*/
|
|
510
510
|
dateTime(e, t) {
|
|
511
|
-
return F([this.$locale, e], (r, n) => d(this, E,
|
|
511
|
+
return F([this.$locale, e], (r, n) => d(this, E, De).call(this, n, t));
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
514
|
* Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
@@ -520,7 +520,7 @@ class Lt {
|
|
|
520
520
|
* const $formatted = Dolla.i18n.list(list, { });
|
|
521
521
|
*/
|
|
522
522
|
list(e, t) {
|
|
523
|
-
return F([this.$locale, e], (r, n) => d(this, E,
|
|
523
|
+
return F([this.$locale, e], (r, n) => d(this, E, je).call(this, n, t));
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
ae = new WeakMap(), P = new WeakMap(), v = new WeakMap(), ie = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), E = new WeakSet(), Ye = function(e, t, r) {
|
|
@@ -542,7 +542,7 @@ ae = new WeakMap(), P = new WeakMap(), v = new WeakMap(), ie = new WeakMap(), oe
|
|
|
542
542
|
if (u.type === 0)
|
|
543
543
|
f += u.text;
|
|
544
544
|
else if (u.type === 1) {
|
|
545
|
-
let m =
|
|
545
|
+
let m = Lt(r, u.name);
|
|
546
546
|
const b = ((c = r.formatOverrides) == null ? void 0 : c[u.name]) ?? [...u.formats];
|
|
547
547
|
u.name === "count" && b.length === 0 && b.push({ name: "number", options: {} });
|
|
548
548
|
for (const h of b) {
|
|
@@ -558,11 +558,11 @@ ae = new WeakMap(), P = new WeakMap(), v = new WeakMap(), ie = new WeakMap(), oe
|
|
|
558
558
|
f += m;
|
|
559
559
|
}
|
|
560
560
|
return f;
|
|
561
|
-
}, De = function(e, t) {
|
|
562
|
-
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
563
561
|
}, Te = function(e, t) {
|
|
562
|
+
return new Intl.NumberFormat(this.$locale.get(), t).format(e);
|
|
563
|
+
}, De = function(e, t) {
|
|
564
564
|
return new Intl.DateTimeFormat(this.$locale.get(), t).format(k(e) ? new Date(e) : e);
|
|
565
|
-
},
|
|
565
|
+
}, je = function(e, t) {
|
|
566
566
|
return new Intl.ListFormat(this.$locale.get(), t).format(e);
|
|
567
567
|
}, // relativeTime(): State<string> {
|
|
568
568
|
// }
|
|
@@ -571,7 +571,7 @@ Ze = function(e, t) {
|
|
|
571
571
|
if (r[0] === e && ot(r[1], t))
|
|
572
572
|
return r[2];
|
|
573
573
|
};
|
|
574
|
-
function
|
|
574
|
+
function Lt(o, e) {
|
|
575
575
|
const t = String(e).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
|
|
576
576
|
let r = o;
|
|
577
577
|
for (; t.length > 0; ) {
|
|
@@ -615,7 +615,7 @@ function Ee(o, e) {
|
|
|
615
615
|
break;
|
|
616
616
|
return H([t, e]);
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function Mt(o) {
|
|
619
619
|
if (!o) return {};
|
|
620
620
|
o.startsWith("?") && (o = o.slice(1));
|
|
621
621
|
const e = o.split("&").filter((t) => t.trim() !== "").map((t) => {
|
|
@@ -665,12 +665,12 @@ function et(o, e, t = {}) {
|
|
|
665
665
|
path: "/" + m.map((h) => h.value).join("/"),
|
|
666
666
|
pattern: "/" + c.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
|
|
667
667
|
params: b,
|
|
668
|
-
query:
|
|
668
|
+
query: Mt(n),
|
|
669
669
|
meta: f.meta
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function xt(o) {
|
|
674
674
|
const e = [], t = [], r = [], n = [];
|
|
675
675
|
for (const i of o) {
|
|
676
676
|
const { fragments: f } = i;
|
|
@@ -688,7 +688,7 @@ function Ft(o) {
|
|
|
688
688
|
const s = (i, f) => i.fragments.length > f.fragments.length ? -1 : 1;
|
|
689
689
|
return e.sort(s), t.sort(s), r.sort(s), n.sort(s), [...e, ...t, ...r, ...n];
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function Ft(o) {
|
|
692
692
|
const e = ee(o), t = [];
|
|
693
693
|
for (let r = 0; r < e.length; r++) {
|
|
694
694
|
const n = e[r];
|
|
@@ -712,14 +712,14 @@ function qt(o) {
|
|
|
712
712
|
}
|
|
713
713
|
return t;
|
|
714
714
|
}
|
|
715
|
-
var W, x, xe,
|
|
716
|
-
class
|
|
715
|
+
var W, x, xe, T, X, _, G, D, he, w, Ce, tt, rt, Z, Oe, st, Ue;
|
|
716
|
+
class qt {
|
|
717
717
|
constructor(e) {
|
|
718
718
|
l(this, w);
|
|
719
719
|
l(this, W);
|
|
720
720
|
l(this, x);
|
|
721
721
|
l(this, xe, 0);
|
|
722
|
-
l(this,
|
|
722
|
+
l(this, T, []);
|
|
723
723
|
l(this, X, []);
|
|
724
724
|
/**
|
|
725
725
|
* Use hash routing when true. Configured in router options.
|
|
@@ -730,7 +730,7 @@ class Nt {
|
|
|
730
730
|
/**
|
|
731
731
|
* The current match object.
|
|
732
732
|
*/
|
|
733
|
-
l(this,
|
|
733
|
+
l(this, D);
|
|
734
734
|
l(this, he);
|
|
735
735
|
/**
|
|
736
736
|
* The currently matched route pattern, if any.
|
|
@@ -748,18 +748,18 @@ class Nt {
|
|
|
748
748
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
749
749
|
*/
|
|
750
750
|
p(this, "$query");
|
|
751
|
-
g(this, W, e), g(this, x, e.createLogger("dolla/router")), [Y(this,
|
|
751
|
+
g(this, W, e), g(this, x, e.createLogger("dolla/router")), [Y(this, D)._, Y(this, he)._] = Ve(), this.$pattern = F([a(this, D)], (t) => t == null ? void 0 : t.pattern), this.$path = F([a(this, D)], (t) => (t == null ? void 0 : t.path) ?? window.location.pathname), this.$params = F([a(this, D)], (t) => (t == null ? void 0 : t.params) ?? {}, { equals: _e }), this.$query = F([a(this, D)], (t) => (t == null ? void 0 : t.query) ?? {}, { equals: _e }), e.beforeMount(async () => {
|
|
752
752
|
const t = () => {
|
|
753
753
|
d(this, w, Z).call(this);
|
|
754
754
|
};
|
|
755
755
|
window.addEventListener("popstate", t), a(this, G).push(() => window.removeEventListener("popstate", t));
|
|
756
756
|
const r = e.getRootElement();
|
|
757
|
-
|
|
757
|
+
a(this, G).push(
|
|
758
758
|
Tt(r, (n) => {
|
|
759
759
|
let s = n.getAttribute("href");
|
|
760
|
-
a(this, x).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(s) || (s = H([window.location.pathname, s])), d(this, w,
|
|
760
|
+
a(this, x).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(s) || (s = H([window.location.pathname, s])), d(this, w, Ce).call(this, s);
|
|
761
761
|
})
|
|
762
|
-
), a(this, x).info("will intercept clicks on <a> tags within root element", r), d(this, w, Z).call(this);
|
|
762
|
+
), a(this, x).info("will intercept clicks on <a> tags within root element", r), await d(this, w, Z).call(this);
|
|
763
763
|
}), e.onUnmount(() => {
|
|
764
764
|
for (const t of a(this, G))
|
|
765
765
|
t();
|
|
@@ -770,11 +770,11 @@ class Nt {
|
|
|
770
770
|
Ge(e != null, "Options object must not be null. Got: %t"), Ge(
|
|
771
771
|
!a(this, W).isMounted,
|
|
772
772
|
"Dolla is already mounted. Dolla.router.setup() must be called before Dolla.mount()."
|
|
773
|
-
), e.hash && g(this, _, !0), g(this, X,
|
|
773
|
+
), e.hash && g(this, _, !0), g(this, X, xt(
|
|
774
774
|
e.routes.flatMap((t) => d(this, w, Ue).call(this, t)).map((t) => ({
|
|
775
775
|
pattern: t.pattern,
|
|
776
776
|
meta: t.meta,
|
|
777
|
-
fragments:
|
|
777
|
+
fragments: Ft(t.pattern)
|
|
778
778
|
}))
|
|
779
779
|
)), jt(a(this, X));
|
|
780
780
|
}
|
|
@@ -801,17 +801,17 @@ class Nt {
|
|
|
801
801
|
if (a(this, W) == null)
|
|
802
802
|
throw new Error("Routa methods won't work until you register it: Dolla.use(Routa, { /* ...options */ })");
|
|
803
803
|
let r;
|
|
804
|
-
Array.isArray(e) ? r = H(e) : r = e.toString(), r = Ee(window.location.pathname, r), t.preserveQuery && (r += window.location.search), t.replace ? d(this, w, tt).call(this, r) : d(this, w,
|
|
804
|
+
Array.isArray(e) ? r = H(e) : r = e.toString(), r = Ee(window.location.pathname, r), t.preserveQuery && (r += window.location.search), t.replace ? d(this, w, tt).call(this, r) : d(this, w, Ce).call(this, r);
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(),
|
|
807
|
+
W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), T = new WeakMap(), X = new WeakMap(), _ = new WeakMap(), G = new WeakMap(), D = new WeakMap(), he = new WeakMap(), w = new WeakSet(), Ce = function(e, t) {
|
|
808
808
|
a(this, x).info("(push)", e), window.history.pushState(t, "", a(this, _) ? "/#" + e : e), d(this, w, Z).call(this, e);
|
|
809
809
|
}, tt = function(e, t) {
|
|
810
810
|
a(this, x).info("(replace)", e), window.history.replaceState(t, "", a(this, _) ? "/#" + e : e), d(this, w, Z).call(this, e);
|
|
811
811
|
}, rt = function() {
|
|
812
812
|
return a(this, _) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
|
|
813
813
|
}, Z = async function(e) {
|
|
814
|
-
const t = a(this, x), r = e ? new URL(e, window.location.origin) : d(this, w, rt).call(this), { match: n, journey: s } = await d(this, w,
|
|
814
|
+
const t = a(this, x), r = e ? new URL(e, window.location.origin) : d(this, w, rt).call(this), { match: n, journey: s } = await d(this, w, Oe).call(this, r);
|
|
815
815
|
for (const i of s)
|
|
816
816
|
switch (i.kind) {
|
|
817
817
|
case "match":
|
|
@@ -829,7 +829,8 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
829
829
|
a(this, he).call(this, n), n.pattern !== i && d(this, w, st).call(this, n);
|
|
830
830
|
} else
|
|
831
831
|
t.crash(new Ct(`Failed to match route '${r.pathname}'`));
|
|
832
|
-
|
|
832
|
+
return { match: n, journey: s };
|
|
833
|
+
}, Oe = async function(e, t = []) {
|
|
833
834
|
const r = et(a(this, X), e.pathname);
|
|
834
835
|
if (!r)
|
|
835
836
|
return {
|
|
@@ -845,7 +846,7 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
845
846
|
}), n != null) {
|
|
846
847
|
let s;
|
|
847
848
|
if (k(n))
|
|
848
|
-
s =
|
|
849
|
+
s = Dt(n, r.params);
|
|
849
850
|
else if (te(n)) {
|
|
850
851
|
const i = {
|
|
851
852
|
path: r.path,
|
|
@@ -858,7 +859,7 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
858
859
|
s.startsWith("/") || (s = Ee(r.path, s));
|
|
859
860
|
} else
|
|
860
861
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
861
|
-
return d(this, w,
|
|
862
|
+
return d(this, w, Oe).call(this, new URL(s, window.location.origin), [
|
|
862
863
|
...t,
|
|
863
864
|
{ kind: "redirect", message: `redirecting '${r.path}' -> '${s}'` }
|
|
864
865
|
]);
|
|
@@ -870,11 +871,11 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
870
871
|
st = function(e) {
|
|
871
872
|
const t = e.meta.layers;
|
|
872
873
|
for (let r = 0; r < t.length; r++) {
|
|
873
|
-
const n = t[r], s = a(this,
|
|
874
|
+
const n = t[r], s = a(this, T)[r];
|
|
874
875
|
if ((s == null ? void 0 : s.id) !== n.id) {
|
|
875
|
-
g(this,
|
|
876
|
-
const i = a(this,
|
|
877
|
-
a(this,
|
|
876
|
+
g(this, T, a(this, T).slice(0, r)), s == null || s.node.unmount();
|
|
877
|
+
const i = a(this, T).at(-1), c = ((i == null ? void 0 : i.node) ?? a(this, W).getRootView()).setChildView(n.view);
|
|
878
|
+
a(this, T).push({ id: n.id, node: c });
|
|
878
879
|
}
|
|
879
880
|
}
|
|
880
881
|
}, /**
|
|
@@ -926,7 +927,7 @@ Ue = function(e, t = [], r = []) {
|
|
|
926
927
|
});
|
|
927
928
|
return s;
|
|
928
929
|
};
|
|
929
|
-
const
|
|
930
|
+
const Nt = /(noopener|noreferrer) (noopener|noreferrer)/, Pt = /^[\w-_]+:/;
|
|
930
931
|
function Tt(o, e, t = window) {
|
|
931
932
|
function r(s) {
|
|
932
933
|
return !s || s === o ? null : s.localName !== "a" || s.href === void 0 ? r(s.parentNode) : s;
|
|
@@ -935,13 +936,13 @@ function Tt(o, e, t = window) {
|
|
|
935
936
|
if (s.button && s.button !== 0 || s.ctrlKey || s.metaKey || s.altKey || s.shiftKey || s.defaultPrevented)
|
|
936
937
|
return;
|
|
937
938
|
const i = r(s.target);
|
|
938
|
-
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" &&
|
|
939
|
+
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" && Nt.test(i.getAttribute("rel")) || Pt.test(i.getAttribute("href")) || (s.preventDefault(), e(i)));
|
|
939
940
|
}
|
|
940
941
|
return o.addEventListener("click", n), function() {
|
|
941
942
|
o.removeEventListener("click", n);
|
|
942
943
|
};
|
|
943
944
|
}
|
|
944
|
-
function
|
|
945
|
+
function Dt(o, e) {
|
|
945
946
|
for (const t in e) {
|
|
946
947
|
const r = e[t].toString();
|
|
947
948
|
o = o.replace(`{${t}}`, r).replace(`{#${t}}`, r);
|
|
@@ -965,24 +966,24 @@ function jt(o) {
|
|
|
965
966
|
}
|
|
966
967
|
class Ct extends Error {
|
|
967
968
|
}
|
|
968
|
-
var
|
|
969
|
-
class
|
|
969
|
+
var j, ue, C, B, fe, de, me, ge, pe, we, O, $, U, Fe;
|
|
970
|
+
class Ot {
|
|
970
971
|
constructor() {
|
|
971
972
|
p(this, "batch");
|
|
972
973
|
p(this, "http");
|
|
973
974
|
p(this, "i18n");
|
|
974
975
|
p(this, "router");
|
|
975
|
-
l(this,
|
|
976
|
+
l(this, j, !1);
|
|
976
977
|
l(this, ue, "production");
|
|
977
|
-
l(this,
|
|
978
|
+
l(this, C);
|
|
978
979
|
l(this, B);
|
|
979
|
-
l(this, fe,
|
|
980
|
+
l(this, fe, yt);
|
|
980
981
|
l(this, de, Be());
|
|
981
982
|
l(this, me, []);
|
|
982
983
|
l(this, ge, []);
|
|
983
984
|
l(this, pe, []);
|
|
984
985
|
l(this, we, []);
|
|
985
|
-
l(this,
|
|
986
|
+
l(this, O, {
|
|
986
987
|
root: this,
|
|
987
988
|
data: {}
|
|
988
989
|
});
|
|
@@ -998,21 +999,20 @@ class Ut {
|
|
|
998
999
|
l(this, Fe, []);
|
|
999
1000
|
p(this, "watch", a(this, de).watch);
|
|
1000
1001
|
p(this, "createState", Ve);
|
|
1001
|
-
p(this, "
|
|
1002
|
-
p(this, "
|
|
1003
|
-
p(this, "
|
|
1004
|
-
p(this, "valueOf", ft);
|
|
1002
|
+
p(this, "toState", ct);
|
|
1003
|
+
p(this, "toValue", ht);
|
|
1004
|
+
p(this, "isState", ut);
|
|
1005
1005
|
p(this, "derive", F);
|
|
1006
1006
|
p(this, "createWatcher", Be);
|
|
1007
|
-
p(this, "createRef",
|
|
1008
|
-
p(this, "isRef",
|
|
1009
|
-
this.batch = new
|
|
1007
|
+
p(this, "createRef", ft);
|
|
1008
|
+
p(this, "isRef", dt);
|
|
1009
|
+
this.batch = new bt(this), this.http = new $t(this), this.i18n = new St(this), this.router = new qt(this);
|
|
1010
1010
|
}
|
|
1011
1011
|
/**
|
|
1012
1012
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
1013
1013
|
*/
|
|
1014
1014
|
get isMounted() {
|
|
1015
|
-
return a(this,
|
|
1015
|
+
return a(this, j);
|
|
1016
1016
|
}
|
|
1017
1017
|
/**
|
|
1018
1018
|
* Get the current environment that this app is running in.
|
|
@@ -1039,7 +1039,7 @@ class Ut {
|
|
|
1039
1039
|
* Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
|
|
1040
1040
|
*/
|
|
1041
1041
|
getRootElement() {
|
|
1042
|
-
return a(this,
|
|
1042
|
+
return a(this, C);
|
|
1043
1043
|
}
|
|
1044
1044
|
/**
|
|
1045
1045
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
@@ -1060,37 +1060,37 @@ class Ut {
|
|
|
1060
1060
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
1061
1061
|
*/
|
|
1062
1062
|
set(e, t) {
|
|
1063
|
-
return a(this,
|
|
1063
|
+
return a(this, O).data[e] = t, t;
|
|
1064
1064
|
}
|
|
1065
1065
|
/**
|
|
1066
1066
|
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
1067
1067
|
*/
|
|
1068
1068
|
get(e) {
|
|
1069
|
-
return a(this,
|
|
1069
|
+
return a(this, O).data[e] ?? null;
|
|
1070
1070
|
}
|
|
1071
1071
|
/**
|
|
1072
1072
|
* Returns an object of all context variables stored at the app level.
|
|
1073
1073
|
*/
|
|
1074
1074
|
getAll() {
|
|
1075
|
-
return { ...a(this,
|
|
1075
|
+
return { ...a(this, O).data };
|
|
1076
1076
|
}
|
|
1077
1077
|
async mount(e, t) {
|
|
1078
|
-
if (a(this,
|
|
1078
|
+
if (a(this, j))
|
|
1079
1079
|
throw new Error("Dolla is already mounted.");
|
|
1080
1080
|
if (k(e)) {
|
|
1081
1081
|
const n = document.querySelector(e);
|
|
1082
|
-
He(HTMLElement, n, `Selector '${e}' did not match any element.`), g(this,
|
|
1082
|
+
He(HTMLElement, n, `Selector '${e}' did not match any element.`), g(this, C, n);
|
|
1083
1083
|
} else
|
|
1084
|
-
He(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this,
|
|
1085
|
-
const r =
|
|
1086
|
-
g(this, B, this.constructView(r.type, r.props)), await Promise.all(a(this, Fe).map((n) => n())), await Promise.all(a(this, me).map((n) => n())), a(this, B).mount(a(this,
|
|
1084
|
+
He(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this, C, e);
|
|
1085
|
+
const r = mt(t ?? Je);
|
|
1086
|
+
g(this, B, this.constructView(r.type, r.props)), await Promise.all(a(this, Fe).map((n) => n())), await Promise.all(a(this, me).map((n) => n())), a(this, B).mount(a(this, C)), g(this, j, !0);
|
|
1087
1087
|
for (const n of a(this, ge))
|
|
1088
1088
|
n();
|
|
1089
1089
|
}
|
|
1090
1090
|
async unmount() {
|
|
1091
1091
|
var e;
|
|
1092
|
-
if (a(this,
|
|
1093
|
-
await Promise.all(a(this, pe).map((t) => t())), (e = a(this, B)) == null || e.unmount(!1), a(this, de).stopAll(), g(this,
|
|
1092
|
+
if (a(this, j)) {
|
|
1093
|
+
await Promise.all(a(this, pe).map((t) => t())), (e = a(this, B)) == null || e.unmount(!1), a(this, de).stopAll(), g(this, j, !1);
|
|
1094
1094
|
for (const t of a(this, we))
|
|
1095
1095
|
t();
|
|
1096
1096
|
}
|
|
@@ -1134,7 +1134,7 @@ class Ut {
|
|
|
1134
1134
|
g(this, U, ze(e));
|
|
1135
1135
|
}
|
|
1136
1136
|
createLogger(e, t) {
|
|
1137
|
-
const r = (t == null ? void 0 : t.console) ??
|
|
1137
|
+
const r = (t == null ? void 0 : t.console) ?? Ut(), n = this;
|
|
1138
1138
|
return {
|
|
1139
1139
|
setName(s) {
|
|
1140
1140
|
return e = s, this;
|
|
@@ -1208,7 +1208,7 @@ class Ut {
|
|
|
1208
1208
|
error: s,
|
|
1209
1209
|
loggerName: e,
|
|
1210
1210
|
uid: t == null ? void 0 : t.uid
|
|
1211
|
-
}).mount(a(n,
|
|
1211
|
+
}).mount(a(n, C))), s;
|
|
1212
1212
|
}
|
|
1213
1213
|
};
|
|
1214
1214
|
}
|
|
@@ -1216,50 +1216,48 @@ class Ut {
|
|
|
1216
1216
|
*
|
|
1217
1217
|
*/
|
|
1218
1218
|
constructView(e, t, r = []) {
|
|
1219
|
-
return new
|
|
1219
|
+
return new gt(a(this, O), e, t, r);
|
|
1220
1220
|
}
|
|
1221
1221
|
/**
|
|
1222
1222
|
*
|
|
1223
1223
|
*/
|
|
1224
1224
|
constructMarkup(e) {
|
|
1225
|
-
return wt(
|
|
1225
|
+
return pt(wt(a(this, O), e));
|
|
1226
1226
|
}
|
|
1227
1227
|
}
|
|
1228
|
-
|
|
1229
|
-
function
|
|
1228
|
+
j = new WeakMap(), ue = new WeakMap(), C = new WeakMap(), B = new WeakMap(), fe = new WeakMap(), de = new WeakMap(), me = new WeakMap(), ge = new WeakMap(), pe = new WeakMap(), we = new WeakMap(), O = new WeakMap(), $ = new WeakMap(), U = new WeakMap(), Fe = new WeakMap();
|
|
1229
|
+
function Ut() {
|
|
1230
1230
|
if (typeof window < "u" && window.console)
|
|
1231
1231
|
return window.console;
|
|
1232
1232
|
if (typeof global < "u" && global.console)
|
|
1233
1233
|
return global.console;
|
|
1234
1234
|
}
|
|
1235
|
-
const Ke = new
|
|
1236
|
-
function
|
|
1235
|
+
const Ke = new Ot(), It = Ke.i18n.t.bind(Ke.i18n);
|
|
1236
|
+
function Wt(o) {
|
|
1237
1237
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = o);
|
|
1238
1238
|
}
|
|
1239
|
-
function
|
|
1239
|
+
function _t() {
|
|
1240
1240
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1241
1241
|
}
|
|
1242
1242
|
export {
|
|
1243
1243
|
it as cond,
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
ct as createSettableState,
|
|
1247
|
-
Ht as createSetter,
|
|
1244
|
+
mt as createMarkup,
|
|
1245
|
+
ft as createRef,
|
|
1248
1246
|
Ve as createState,
|
|
1249
1247
|
ot as deepEqual,
|
|
1250
1248
|
Ke as default,
|
|
1251
1249
|
F as derive,
|
|
1252
|
-
|
|
1250
|
+
_t as getDevDebug,
|
|
1253
1251
|
Ie as html,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1252
|
+
dt as isRef,
|
|
1253
|
+
ut as isState,
|
|
1254
|
+
zt as portal,
|
|
1255
|
+
Ht as repeat,
|
|
1256
|
+
Wt as setDevDebug,
|
|
1258
1257
|
_e as shallowEqual,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
ft as valueOf
|
|
1258
|
+
Kt as strictEqual,
|
|
1259
|
+
It as t,
|
|
1260
|
+
ct as toState,
|
|
1261
|
+
ht as toValue
|
|
1264
1262
|
};
|
|
1265
1263
|
//# sourceMappingURL=index.js.map
|