@manyducks.co/dolla 2.0.0-alpha.24 → 2.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/dolla.d.ts +3 -4
- package/dist/core/markup.d.ts +1 -6
- package/dist/core/nodes/observer.d.ts +7 -11
- package/dist/core/nodes/outlet.d.ts +6 -5
- package/dist/core/nodes/repeat.d.ts +1 -2
- 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 +94 -97
- 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-BeKX_qRr.js → passthrough-CACEgFx5.js} +394 -546
- package/dist/passthrough-CACEgFx5.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/docs/states.md +3 -50
- package/notes/scratch.md +112 -11
- package/package.json +1 -1
- package/dist/core/nodes/cond.d.ts +0 -28
- package/dist/passthrough-BeKX_qRr.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-CACEgFx5.js";
|
|
17
|
+
import { B as zt, C as Ht, A as Kt } from "./passthrough-CACEgFx5.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,7 +748,7 @@ 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
|
};
|
|
@@ -757,7 +757,7 @@ class Nt {
|
|
|
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
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(() => {
|
|
@@ -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":
|
|
@@ -830,7 +830,7 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
830
830
|
} else
|
|
831
831
|
t.crash(new Ct(`Failed to match route '${r.pathname}'`));
|
|
832
832
|
return { match: n, journey: s };
|
|
833
|
-
},
|
|
833
|
+
}, Oe = async function(e, t = []) {
|
|
834
834
|
const r = et(a(this, X), e.pathname);
|
|
835
835
|
if (!r)
|
|
836
836
|
return {
|
|
@@ -846,7 +846,7 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
846
846
|
}), n != null) {
|
|
847
847
|
let s;
|
|
848
848
|
if (k(n))
|
|
849
|
-
s =
|
|
849
|
+
s = Dt(n, r.params);
|
|
850
850
|
else if (te(n)) {
|
|
851
851
|
const i = {
|
|
852
852
|
path: r.path,
|
|
@@ -859,7 +859,7 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
859
859
|
s.startsWith("/") || (s = Ee(r.path, s));
|
|
860
860
|
} else
|
|
861
861
|
throw new TypeError("Redirect must either be a path string or a function.");
|
|
862
|
-
return d(this, w,
|
|
862
|
+
return d(this, w, Oe).call(this, new URL(s, window.location.origin), [
|
|
863
863
|
...t,
|
|
864
864
|
{ kind: "redirect", message: `redirecting '${r.path}' -> '${s}'` }
|
|
865
865
|
]);
|
|
@@ -871,11 +871,11 @@ W = new WeakMap(), x = new WeakMap(), xe = new WeakMap(), D = new WeakMap(), X =
|
|
|
871
871
|
st = function(e) {
|
|
872
872
|
const t = e.meta.layers;
|
|
873
873
|
for (let r = 0; r < t.length; r++) {
|
|
874
|
-
const n = t[r], s = a(this,
|
|
874
|
+
const n = t[r], s = a(this, T)[r];
|
|
875
875
|
if ((s == null ? void 0 : s.id) !== n.id) {
|
|
876
|
-
g(this,
|
|
877
|
-
const i = a(this,
|
|
878
|
-
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 });
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
}, /**
|
|
@@ -927,7 +927,7 @@ Ue = function(e, t = [], r = []) {
|
|
|
927
927
|
});
|
|
928
928
|
return s;
|
|
929
929
|
};
|
|
930
|
-
const
|
|
930
|
+
const Nt = /(noopener|noreferrer) (noopener|noreferrer)/, Pt = /^[\w-_]+:/;
|
|
931
931
|
function Tt(o, e, t = window) {
|
|
932
932
|
function r(s) {
|
|
933
933
|
return !s || s === o ? null : s.localName !== "a" || s.href === void 0 ? r(s.parentNode) : s;
|
|
@@ -936,13 +936,13 @@ function Tt(o, e, t = window) {
|
|
|
936
936
|
if (s.button && s.button !== 0 || s.ctrlKey || s.metaKey || s.altKey || s.shiftKey || s.defaultPrevented)
|
|
937
937
|
return;
|
|
938
938
|
const i = r(s.target);
|
|
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" &&
|
|
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)));
|
|
940
940
|
}
|
|
941
941
|
return o.addEventListener("click", n), function() {
|
|
942
942
|
o.removeEventListener("click", n);
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function Dt(o, e) {
|
|
946
946
|
for (const t in e) {
|
|
947
947
|
const r = e[t].toString();
|
|
948
948
|
o = o.replace(`{${t}}`, r).replace(`{#${t}}`, r);
|
|
@@ -966,24 +966,24 @@ function jt(o) {
|
|
|
966
966
|
}
|
|
967
967
|
class Ct extends Error {
|
|
968
968
|
}
|
|
969
|
-
var
|
|
970
|
-
class
|
|
969
|
+
var j, ue, C, B, fe, de, me, ge, pe, we, O, $, U, Fe;
|
|
970
|
+
class Ot {
|
|
971
971
|
constructor() {
|
|
972
972
|
p(this, "batch");
|
|
973
973
|
p(this, "http");
|
|
974
974
|
p(this, "i18n");
|
|
975
975
|
p(this, "router");
|
|
976
|
-
l(this,
|
|
976
|
+
l(this, j, !1);
|
|
977
977
|
l(this, ue, "production");
|
|
978
|
-
l(this,
|
|
978
|
+
l(this, C);
|
|
979
979
|
l(this, B);
|
|
980
|
-
l(this, fe,
|
|
980
|
+
l(this, fe, yt);
|
|
981
981
|
l(this, de, Be());
|
|
982
982
|
l(this, me, []);
|
|
983
983
|
l(this, ge, []);
|
|
984
984
|
l(this, pe, []);
|
|
985
985
|
l(this, we, []);
|
|
986
|
-
l(this,
|
|
986
|
+
l(this, O, {
|
|
987
987
|
root: this,
|
|
988
988
|
data: {}
|
|
989
989
|
});
|
|
@@ -999,21 +999,20 @@ class Ut {
|
|
|
999
999
|
l(this, Fe, []);
|
|
1000
1000
|
p(this, "watch", a(this, de).watch);
|
|
1001
1001
|
p(this, "createState", Ve);
|
|
1002
|
-
p(this, "
|
|
1003
|
-
p(this, "
|
|
1004
|
-
p(this, "
|
|
1005
|
-
p(this, "valueOf", ft);
|
|
1002
|
+
p(this, "toState", ct);
|
|
1003
|
+
p(this, "toValue", ht);
|
|
1004
|
+
p(this, "isState", ut);
|
|
1006
1005
|
p(this, "derive", F);
|
|
1007
1006
|
p(this, "createWatcher", Be);
|
|
1008
|
-
p(this, "createRef",
|
|
1009
|
-
p(this, "isRef",
|
|
1010
|
-
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);
|
|
1011
1010
|
}
|
|
1012
1011
|
/**
|
|
1013
1012
|
* True when the app is connected to a DOM node and displayed to the user.
|
|
1014
1013
|
*/
|
|
1015
1014
|
get isMounted() {
|
|
1016
|
-
return a(this,
|
|
1015
|
+
return a(this, j);
|
|
1017
1016
|
}
|
|
1018
1017
|
/**
|
|
1019
1018
|
* Get the current environment that this app is running in.
|
|
@@ -1040,7 +1039,7 @@ class Ut {
|
|
|
1040
1039
|
* Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
|
|
1041
1040
|
*/
|
|
1042
1041
|
getRootElement() {
|
|
1043
|
-
return a(this,
|
|
1042
|
+
return a(this, C);
|
|
1044
1043
|
}
|
|
1045
1044
|
/**
|
|
1046
1045
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
@@ -1061,37 +1060,37 @@ class Ut {
|
|
|
1061
1060
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
1062
1061
|
*/
|
|
1063
1062
|
set(e, t) {
|
|
1064
|
-
return a(this,
|
|
1063
|
+
return a(this, O).data[e] = t, t;
|
|
1065
1064
|
}
|
|
1066
1065
|
/**
|
|
1067
1066
|
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
1068
1067
|
*/
|
|
1069
1068
|
get(e) {
|
|
1070
|
-
return a(this,
|
|
1069
|
+
return a(this, O).data[e] ?? null;
|
|
1071
1070
|
}
|
|
1072
1071
|
/**
|
|
1073
1072
|
* Returns an object of all context variables stored at the app level.
|
|
1074
1073
|
*/
|
|
1075
1074
|
getAll() {
|
|
1076
|
-
return { ...a(this,
|
|
1075
|
+
return { ...a(this, O).data };
|
|
1077
1076
|
}
|
|
1078
1077
|
async mount(e, t) {
|
|
1079
|
-
if (a(this,
|
|
1078
|
+
if (a(this, j))
|
|
1080
1079
|
throw new Error("Dolla is already mounted.");
|
|
1081
1080
|
if (k(e)) {
|
|
1082
1081
|
const n = document.querySelector(e);
|
|
1083
|
-
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);
|
|
1084
1083
|
} else
|
|
1085
|
-
He(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), g(this,
|
|
1086
|
-
const r =
|
|
1087
|
-
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);
|
|
1088
1087
|
for (const n of a(this, ge))
|
|
1089
1088
|
n();
|
|
1090
1089
|
}
|
|
1091
1090
|
async unmount() {
|
|
1092
1091
|
var e;
|
|
1093
|
-
if (a(this,
|
|
1094
|
-
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);
|
|
1095
1094
|
for (const t of a(this, we))
|
|
1096
1095
|
t();
|
|
1097
1096
|
}
|
|
@@ -1135,7 +1134,7 @@ class Ut {
|
|
|
1135
1134
|
g(this, U, ze(e));
|
|
1136
1135
|
}
|
|
1137
1136
|
createLogger(e, t) {
|
|
1138
|
-
const r = (t == null ? void 0 : t.console) ??
|
|
1137
|
+
const r = (t == null ? void 0 : t.console) ?? Ut(), n = this;
|
|
1139
1138
|
return {
|
|
1140
1139
|
setName(s) {
|
|
1141
1140
|
return e = s, this;
|
|
@@ -1209,7 +1208,7 @@ class Ut {
|
|
|
1209
1208
|
error: s,
|
|
1210
1209
|
loggerName: e,
|
|
1211
1210
|
uid: t == null ? void 0 : t.uid
|
|
1212
|
-
}).mount(a(n,
|
|
1211
|
+
}).mount(a(n, C))), s;
|
|
1213
1212
|
}
|
|
1214
1213
|
};
|
|
1215
1214
|
}
|
|
@@ -1217,50 +1216,48 @@ class Ut {
|
|
|
1217
1216
|
*
|
|
1218
1217
|
*/
|
|
1219
1218
|
constructView(e, t, r = []) {
|
|
1220
|
-
return new
|
|
1219
|
+
return new gt(a(this, O), e, t, r);
|
|
1221
1220
|
}
|
|
1222
1221
|
/**
|
|
1223
1222
|
*
|
|
1224
1223
|
*/
|
|
1225
1224
|
constructMarkup(e) {
|
|
1226
|
-
return wt(
|
|
1225
|
+
return pt(wt(a(this, O), e));
|
|
1227
1226
|
}
|
|
1228
1227
|
}
|
|
1229
|
-
|
|
1230
|
-
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() {
|
|
1231
1230
|
if (typeof window < "u" && window.console)
|
|
1232
1231
|
return window.console;
|
|
1233
1232
|
if (typeof global < "u" && global.console)
|
|
1234
1233
|
return global.console;
|
|
1235
1234
|
}
|
|
1236
|
-
const Ke = new
|
|
1237
|
-
function
|
|
1235
|
+
const Ke = new Ot(), It = Ke.i18n.t.bind(Ke.i18n);
|
|
1236
|
+
function Wt(o) {
|
|
1238
1237
|
typeof window < "u" && (window.DOLLA_DEV_DEBUG = o);
|
|
1239
1238
|
}
|
|
1240
|
-
function
|
|
1239
|
+
function _t() {
|
|
1241
1240
|
return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
|
|
1242
1241
|
}
|
|
1243
1242
|
export {
|
|
1244
1243
|
it as cond,
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
ct as createSettableState,
|
|
1248
|
-
Ht as createSetter,
|
|
1244
|
+
mt as createMarkup,
|
|
1245
|
+
ft as createRef,
|
|
1249
1246
|
Ve as createState,
|
|
1250
1247
|
ot as deepEqual,
|
|
1251
1248
|
Ke as default,
|
|
1252
1249
|
F as derive,
|
|
1253
|
-
|
|
1250
|
+
_t as getDevDebug,
|
|
1254
1251
|
Ie as html,
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1252
|
+
dt as isRef,
|
|
1253
|
+
ut as isState,
|
|
1254
|
+
zt as portal,
|
|
1255
|
+
Ht as repeat,
|
|
1256
|
+
Wt as setDevDebug,
|
|
1259
1257
|
_e as shallowEqual,
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
ft as valueOf
|
|
1258
|
+
Kt as strictEqual,
|
|
1259
|
+
It as t,
|
|
1260
|
+
ct as toState,
|
|
1261
|
+
ht as toValue
|
|
1265
1262
|
};
|
|
1266
1263
|
//# sourceMappingURL=index.js.map
|