keits 0.0.4 → 0.1.0
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 +93 -79
- package/dist/dev/api.js +8 -3
- package/dist/dev/forms.js +6 -4
- package/dist/dev/index.js +26 -35
- package/dist/dev/router.js +24 -7
- package/dist/dev/shared/{computed-3UO-KiH1.js → computed-DrF8O8b4.js} +1 -1
- package/dist/dev/shared/{element-CQPqagu1.js → element-DXwmUAnz.js} +30 -76
- package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
- package/dist/dev/shared/hydrate-C8cOsDDH.js +588 -0
- package/dist/dev/shared/mount-CDB2HgN5.js +23 -0
- package/dist/dev/shared/namespaces-Cz82B0Pr.js +84 -0
- package/dist/dev/shared/{owner-Dmge21OW.js → owner-BuwIoI4j.js} +12 -2
- package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
- package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
- package/dist/dev/shared/{resource-CbXVATvq.js → resource-DlgzdtcG.js} +24 -33
- package/dist/dev/shared/{signal-BOXkY-Iv.js → signal-B3xOKbVm.js} +1 -1
- package/dist/dev/shared/{store-BzUN1qE5.js → store-0vEg2bQV.js} +7 -3
- package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
- package/dist/dev/static.js +76 -0
- package/dist/dev/svg.js +2 -1
- package/dist/dev/testing.js +216 -0
- package/dist/dev/vite.js +141 -0
- package/dist/prod/api.js +76 -71
- package/dist/prod/forms.js +63 -60
- package/dist/prod/index.js +56 -64
- package/dist/prod/router.js +86 -73
- package/dist/prod/shared/{computed-CAPpOLCY.js → computed-BjqJ6Pps.js} +1 -1
- package/dist/prod/shared/element-DCit4-3e.js +129 -0
- package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
- package/dist/prod/shared/hydrate-kKnJbkV7.js +480 -0
- package/dist/prod/shared/mount-DbeKIoyD.js +18 -0
- package/dist/prod/shared/namespaces-BSRrBJIU.js +71 -0
- package/dist/prod/shared/owner-DBi3odT4.js +67 -0
- package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
- package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
- package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
- package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
- package/dist/prod/shared/store-CvW0DbmK.js +110 -0
- package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
- package/dist/prod/static.js +48 -0
- package/dist/prod/svg.js +3 -2
- package/dist/prod/testing.js +144 -0
- package/dist/prod/vite.js +106 -0
- package/dist/types/async/render-context.d.ts +10 -0
- package/dist/types/core/effect.d.ts +1 -0
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/owner.d.ts +1 -0
- package/dist/types/core/unsafe-keys.d.ts +2 -0
- package/dist/types/dom/hooks.d.ts +4 -0
- package/dist/types/dom/types.d.ts +5 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/router/match.d.ts +1 -0
- package/dist/types/router/types.d.ts +1 -0
- package/dist/types/static/head.d.ts +36 -0
- package/dist/types/static/hydrate.d.ts +3 -0
- package/dist/types/static/index.d.ts +4 -0
- package/dist/types/static/island.d.ts +14 -0
- package/dist/types/static/json.d.ts +1 -0
- package/dist/types/static/render.d.ts +11 -0
- package/dist/types/static/server-dom.d.ts +100 -0
- package/dist/types/testing/index.d.ts +62 -0
- package/dist/types/vite/index.d.ts +24 -0
- package/package.json +34 -7
- package/dist/dev/shared/render-effect-kOGnLNbL.js +0 -26
- package/dist/prod/shared/element-DGyQ01Vs.js +0 -164
- package/dist/prod/shared/owner-6BFHIPR9.js +0 -59
- package/dist/prod/shared/render-effect-DjaUT3Cn.js +0 -23
- package/dist/prod/shared/resource-CNC2DBO3.js +0 -109
- package/dist/prod/shared/signal-DGrl3r9T.js +0 -16
- package/dist/prod/shared/store-Dcscpk_h.js +0 -109
package/dist/prod/index.js
CHANGED
|
@@ -1,46 +1,35 @@
|
|
|
1
|
-
import { t as e } from "./shared/signal-
|
|
2
|
-
import { n as t, t as n } from "./shared/render-effect-
|
|
3
|
-
import { t as r } from "./shared/computed-
|
|
4
|
-
import { a as i,
|
|
5
|
-
import { a as
|
|
6
|
-
import { a as
|
|
7
|
-
import { n as te, r as ne, t as
|
|
8
|
-
import {
|
|
1
|
+
import { t as e } from "./shared/signal-BDMlfa0Z.js";
|
|
2
|
+
import { n as t, t as n } from "./shared/render-effect-UFDi2Pfh.js";
|
|
3
|
+
import { t as r } from "./shared/computed-BjqJ6Pps.js";
|
|
4
|
+
import { a as i, d as a, i as o, p as s, t as c, x as l } from "./shared/graph-CR2WKbwr.js";
|
|
5
|
+
import { a as u, c as d, n as f, o as p, r as m, s as h, t as g } from "./shared/owner-DBi3odT4.js";
|
|
6
|
+
import { a as _, i as v, o as ee } from "./shared/render-context-DF8lr1uu.js";
|
|
7
|
+
import { n as te, r as ne, t as y } from "./shared/store-CvW0DbmK.js";
|
|
8
|
+
import { n as b } from "./shared/element-DCit4-3e.js";
|
|
9
|
+
import { a as x, n as S, s as re } from "./shared/namespaces-BSRrBJIU.js";
|
|
10
|
+
import { t as ie } from "./shared/mount-DbeKIoyD.js";
|
|
11
|
+
import { n as C, t as w } from "./shared/resource-Ch5tVseZ.js";
|
|
9
12
|
// src/core/env.ts
|
|
10
|
-
var
|
|
11
|
-
// src/dom/mount.ts
|
|
12
|
-
function It(e, t) {
|
|
13
|
-
if (t === null) throw Error("[keits] no target");
|
|
14
|
-
let n = b.marker(), r = b.marker();
|
|
15
|
-
t.append(n, r);
|
|
16
|
-
let i = d((n) => (x(t, e(), r), n));
|
|
17
|
-
return () => {
|
|
18
|
-
i();
|
|
19
|
-
let e = n;
|
|
20
|
-
for (; e !== null;) {
|
|
21
|
-
let t = e === r ? null : e.nextSibling;
|
|
22
|
-
e.remove(), e = t;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
13
|
+
var T = typeof window > "u", E = /* @__PURE__ */ b("a"), D = /* @__PURE__ */ b("abbr"), O = /* @__PURE__ */ b("address"), k = /* @__PURE__ */ b("area"), A = /* @__PURE__ */ b("article"), j = /* @__PURE__ */ b("aside"), M = /* @__PURE__ */ b("audio"), N = /* @__PURE__ */ b("b"), P = /* @__PURE__ */ b("base"), F = /* @__PURE__ */ b("bdi"), I = /* @__PURE__ */ b("bdo"), L = /* @__PURE__ */ b("blockquote"), R = /* @__PURE__ */ b("body"), z = /* @__PURE__ */ b("br"), B = /* @__PURE__ */ b("button"), V = /* @__PURE__ */ b("canvas"), H = /* @__PURE__ */ b("caption"), U = /* @__PURE__ */ b("cite"), W = /* @__PURE__ */ b("code"), G = /* @__PURE__ */ b("col"), K = /* @__PURE__ */ b("colgroup"), q = /* @__PURE__ */ b("data"), J = /* @__PURE__ */ b("datalist"), Y = /* @__PURE__ */ b("dd"), ae = /* @__PURE__ */ b("del"), oe = /* @__PURE__ */ b("details"), se = /* @__PURE__ */ b("dfn"), ce = /* @__PURE__ */ b("dialog"), le = /* @__PURE__ */ b("div"), ue = /* @__PURE__ */ b("dl"), de = /* @__PURE__ */ b("dt"), fe = /* @__PURE__ */ b("em"), pe = /* @__PURE__ */ b("embed"), me = /* @__PURE__ */ b("fieldset"), he = /* @__PURE__ */ b("figcaption"), ge = /* @__PURE__ */ b("figure"), _e = /* @__PURE__ */ b("footer"), ve = /* @__PURE__ */ b("form"), ye = /* @__PURE__ */ b("h1"), be = /* @__PURE__ */ b("h2"), xe = /* @__PURE__ */ b("h3"), Se = /* @__PURE__ */ b("h4"), Ce = /* @__PURE__ */ b("h5"), we = /* @__PURE__ */ b("h6"), Te = /* @__PURE__ */ b("head"), Ee = /* @__PURE__ */ b("header"), De = /* @__PURE__ */ b("hgroup"), Oe = /* @__PURE__ */ b("hr"), ke = /* @__PURE__ */ b("html"), Ae = /* @__PURE__ */ b("i"), je = /* @__PURE__ */ b("iframe"), Me = /* @__PURE__ */ b("img"), Ne = /* @__PURE__ */ b("input"), Pe = /* @__PURE__ */ b("ins"), Fe = /* @__PURE__ */ b("kbd"), Ie = /* @__PURE__ */ b("label"), Le = /* @__PURE__ */ b("legend"), Re = /* @__PURE__ */ b("li"), ze = /* @__PURE__ */ b("link"), Be = /* @__PURE__ */ b("main"), Ve = /* @__PURE__ */ b("map"), He = /* @__PURE__ */ b("mark"), Ue = /* @__PURE__ */ b("menu"), We = /* @__PURE__ */ b("meta"), Ge = /* @__PURE__ */ b("meter"), Ke = /* @__PURE__ */ b("nav"), qe = /* @__PURE__ */ b("noscript"), Je = /* @__PURE__ */ b("object"), Ye = /* @__PURE__ */ b("ol"), Xe = /* @__PURE__ */ b("optgroup"), Ze = /* @__PURE__ */ b("option"), Qe = /* @__PURE__ */ b("output"), $e = /* @__PURE__ */ b("p"), et = /* @__PURE__ */ b("picture"), tt = /* @__PURE__ */ b("pre"), nt = /* @__PURE__ */ b("progress"), rt = /* @__PURE__ */ b("q"), it = /* @__PURE__ */ b("rp"), at = /* @__PURE__ */ b("rt"), ot = /* @__PURE__ */ b("ruby"), st = /* @__PURE__ */ b("s"), ct = /* @__PURE__ */ b("samp"), lt = /* @__PURE__ */ b("script"), ut = /* @__PURE__ */ b("search"), dt = /* @__PURE__ */ b("section"), ft = /* @__PURE__ */ b("select"), pt = /* @__PURE__ */ b("slot"), mt = /* @__PURE__ */ b("small"), ht = /* @__PURE__ */ b("source"), gt = /* @__PURE__ */ b("span"), _t = /* @__PURE__ */ b("strong"), vt = /* @__PURE__ */ b("style"), yt = /* @__PURE__ */ b("sub"), bt = /* @__PURE__ */ b("summary"), xt = /* @__PURE__ */ b("sup"), St = /* @__PURE__ */ b("table"), Ct = /* @__PURE__ */ b("tbody"), wt = /* @__PURE__ */ b("td"), Tt = /* @__PURE__ */ b("template"), Et = /* @__PURE__ */ b("textarea"), Dt = /* @__PURE__ */ b("tfoot"), Ot = /* @__PURE__ */ b("th"), kt = /* @__PURE__ */ b("thead"), At = /* @__PURE__ */ b("time"), jt = /* @__PURE__ */ b("title"), Mt = /* @__PURE__ */ b("tr"), Nt = /* @__PURE__ */ b("track"), Pt = /* @__PURE__ */ b("u"), Ft = /* @__PURE__ */ b("ul"), It = /* @__PURE__ */ b("var"), X = /* @__PURE__ */ b("video"), Lt = /* @__PURE__ */ b("wbr");
|
|
26
14
|
// src/dom/unsafe.ts
|
|
27
|
-
function
|
|
15
|
+
function Rt(e) {
|
|
16
|
+
if (x.html !== void 0) return x.html(e);
|
|
28
17
|
let t = document.createElement("template");
|
|
29
18
|
return t.innerHTML = e, t.content;
|
|
30
19
|
}
|
|
31
20
|
// src/flow/range.ts
|
|
32
21
|
function Z(e, t) {
|
|
33
|
-
return
|
|
22
|
+
return f((n) => {
|
|
34
23
|
let r = e();
|
|
35
|
-
if (
|
|
24
|
+
if (zt(r)) return {
|
|
36
25
|
item: t,
|
|
37
26
|
index: null,
|
|
38
27
|
dispose: n,
|
|
39
28
|
first: r,
|
|
40
29
|
last: r
|
|
41
30
|
};
|
|
42
|
-
let i =
|
|
43
|
-
return i.append(a, o),
|
|
31
|
+
let i = x.fragment(), a = x.marker(), o = x.marker();
|
|
32
|
+
return i.append(a, o), S(i, r, o), {
|
|
44
33
|
item: t,
|
|
45
34
|
index: null,
|
|
46
35
|
dispose: n,
|
|
@@ -49,7 +38,7 @@ function Z(e, t) {
|
|
|
49
38
|
};
|
|
50
39
|
});
|
|
51
40
|
}
|
|
52
|
-
function
|
|
41
|
+
function zt(e) {
|
|
53
42
|
return typeof e == "object" && !!e && e.nodeType === 1;
|
|
54
43
|
}
|
|
55
44
|
function Q(e, t, n) {
|
|
@@ -72,8 +61,8 @@ function $(e) {
|
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
63
|
// src/flow/for.ts
|
|
75
|
-
function
|
|
76
|
-
let a =
|
|
64
|
+
function Bt(t, r, i) {
|
|
65
|
+
let a = x.marker(), o = x.fragment();
|
|
77
66
|
o.append(a);
|
|
78
67
|
let s = [], l = null;
|
|
79
68
|
c(() => {
|
|
@@ -106,7 +95,7 @@ function Rt(t, r, i) {
|
|
|
106
95
|
c[t] = l;
|
|
107
96
|
}
|
|
108
97
|
for (let e = 0; e < s.length; e++) r[e] || $(s[e]);
|
|
109
|
-
let u =
|
|
98
|
+
let u = Vt(c), f = a;
|
|
110
99
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
111
100
|
let n = o[e];
|
|
112
101
|
u.has(e) || Q(t, n, f), f = n.first;
|
|
@@ -122,7 +111,7 @@ function Rt(t, r, i) {
|
|
|
122
111
|
}
|
|
123
112
|
return o;
|
|
124
113
|
}
|
|
125
|
-
function
|
|
114
|
+
function Vt(e) {
|
|
126
115
|
let t = [], n = Array(e.length);
|
|
127
116
|
for (let r = 0; r < e.length; r++) {
|
|
128
117
|
let i = e[r];
|
|
@@ -139,51 +128,54 @@ function zt(e) {
|
|
|
139
128
|
return r;
|
|
140
129
|
}
|
|
141
130
|
// src/flow/if.ts
|
|
142
|
-
function
|
|
143
|
-
let i = r(e),
|
|
144
|
-
return () =>
|
|
131
|
+
function Ht(e, t, n) {
|
|
132
|
+
let i = r(e), a = r(() => !!i()), o = i;
|
|
133
|
+
return () => a() ? l(() => t(o)) : n ? l(n) : null;
|
|
145
134
|
}
|
|
146
135
|
// src/flow/show.ts
|
|
147
|
-
function
|
|
136
|
+
function Ut(e, t) {
|
|
148
137
|
let r = t.style.display;
|
|
149
138
|
return n(() => {
|
|
150
139
|
e() ? t.style.display = r : t.style.display = "none";
|
|
151
140
|
}), t;
|
|
152
141
|
}
|
|
153
142
|
// src/flow/switch.ts
|
|
154
|
-
function
|
|
143
|
+
function Wt(e, t, n) {
|
|
155
144
|
let i = r(e);
|
|
156
145
|
return () => {
|
|
157
146
|
let e = t[i()] ?? n;
|
|
158
|
-
return e ?
|
|
147
|
+
return e ? l(e) : null;
|
|
159
148
|
};
|
|
160
149
|
}
|
|
161
150
|
// src/flow/dynamic.ts
|
|
162
|
-
function
|
|
151
|
+
function Gt(e, t) {
|
|
163
152
|
let n = r(e);
|
|
164
153
|
return () => {
|
|
165
154
|
let e = n();
|
|
166
|
-
return e ?
|
|
155
|
+
return e ? l(() => e(t)) : null;
|
|
167
156
|
};
|
|
168
157
|
}
|
|
169
158
|
// src/flow/catch.ts
|
|
170
|
-
function
|
|
159
|
+
function Kt(t, n) {
|
|
171
160
|
let r = e(null), i = () => r.set(null);
|
|
172
161
|
return () => {
|
|
173
162
|
let e = r();
|
|
174
|
-
return
|
|
175
|
-
let e =
|
|
176
|
-
return
|
|
163
|
+
return l(e === null ? () => g(() => {
|
|
164
|
+
let e = x.fragment();
|
|
165
|
+
return S(e, t()), e;
|
|
177
166
|
}, (e) => r.set({ error: e })) : () => n(e.error, i));
|
|
178
167
|
};
|
|
179
168
|
}
|
|
180
169
|
// src/flow/portal.ts
|
|
181
|
-
function
|
|
182
|
-
if (
|
|
170
|
+
function qt(e, t) {
|
|
171
|
+
if (a()) return s(), null;
|
|
183
172
|
let n = t === void 0 ? document.body : t;
|
|
184
173
|
if (n === null) throw Error("[keits] no target");
|
|
185
|
-
let r =
|
|
186
|
-
|
|
174
|
+
let r = x.marker(), i = x.marker();
|
|
175
|
+
n.append(r, i);
|
|
176
|
+
let o = f((t) => (re(() => S(n, l(e), i)), t));
|
|
177
|
+
return c(() => {
|
|
178
|
+
o();
|
|
187
179
|
let e = r;
|
|
188
180
|
for (; e !== null;) {
|
|
189
181
|
let t = e === i ? null : e.nextSibling;
|
|
@@ -192,42 +184,42 @@ function Gt(e, t) {
|
|
|
192
184
|
}), null;
|
|
193
185
|
}
|
|
194
186
|
// src/flow/suspense.ts
|
|
195
|
-
function
|
|
196
|
-
let
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
function Jt(t, r) {
|
|
188
|
+
let a = e(0), o = /* @__PURE__ */ new Set(), s = { wait(e, t) {
|
|
189
|
+
o.has(e) || (o.add(e), a.set((e) => e + 1), t(() => {
|
|
190
|
+
o.delete(e), a.set((e) => e - 1);
|
|
199
191
|
}));
|
|
200
|
-
} }, u =
|
|
192
|
+
} }, u = x.fragment(), d = x.marker(), f = x.marker();
|
|
201
193
|
u.append(d, f);
|
|
202
|
-
let { release: p } = i(() => _(
|
|
194
|
+
let { release: p } = i(() => _(C, s, () => S(u, l(t), f))), m = {
|
|
203
195
|
item: null,
|
|
204
196
|
index: null,
|
|
205
197
|
dispose: () => {},
|
|
206
198
|
first: d,
|
|
207
199
|
last: f
|
|
208
|
-
}, h =
|
|
200
|
+
}, h = x.marker(), g = x.fragment();
|
|
209
201
|
g.append(h);
|
|
210
202
|
let v = null;
|
|
211
203
|
return c(() => v?.dispose()), n(() => {
|
|
212
|
-
let e =
|
|
213
|
-
|
|
204
|
+
let e = a() > 0;
|
|
205
|
+
l(() => {
|
|
214
206
|
let t = h.parentNode;
|
|
215
207
|
e ? (Q(u, m, null), v === null && (v = Z(r, null), Q(t, v, h))) : (v !== null && ($(v), v = null), Q(t, m, h), p());
|
|
216
208
|
});
|
|
217
209
|
}), g;
|
|
218
210
|
}
|
|
219
211
|
// src/async/lazy.ts
|
|
220
|
-
function
|
|
212
|
+
function Yt(e) {
|
|
221
213
|
let t, n, r = () => n ??= Promise.resolve(e()).then((e) => t = e.default, (e) => {
|
|
222
214
|
throw n = void 0, e;
|
|
223
215
|
});
|
|
224
216
|
return Object.assign((e) => {
|
|
225
|
-
if (t !== void 0) return
|
|
226
|
-
let n =
|
|
217
|
+
if (t !== void 0) return l(() => t(e));
|
|
218
|
+
let n = w(() => t ?? r());
|
|
227
219
|
return () => {
|
|
228
220
|
let t = n();
|
|
229
|
-
return t ?
|
|
221
|
+
return t ? l(() => t(e)) : null;
|
|
230
222
|
};
|
|
231
223
|
}, { preload: r });
|
|
232
224
|
}
|
|
233
|
-
export {
|
|
225
|
+
export { E as $a, D as $abbr, O as $address, k as $area, A as $article, j as $aside, M as $audio, N as $b, P as $base, F as $bdi, I as $bdo, L as $blockquote, R as $body, z as $br, B as $button, V as $canvas, H as $caption, Kt as $catch, U as $cite, W as $code, G as $col, K as $colgroup, q as $data, J as $datalist, Y as $dd, ae as $del, oe as $details, se as $dfn, ce as $dialog, le as $div, ue as $dl, de as $dt, Gt as $dynamic, fe as $em, pe as $embed, me as $fieldset, he as $figcaption, ge as $figure, _e as $footer, Bt as $for, ve as $form, ye as $h1, be as $h2, xe as $h3, Se as $h4, Ce as $h5, we as $h6, Te as $head, Ee as $header, De as $hgroup, Oe as $hr, ke as $html, Ae as $i, Ht as $if, je as $iframe, Me as $img, Ne as $input, Pe as $ins, Fe as $kbd, Ie as $label, Le as $legend, Re as $li, ze as $link, Be as $main, Ve as $map, He as $mark, Ue as $menu, We as $meta, Ge as $meter, Ke as $nav, qe as $noscript, Je as $object, Ye as $ol, Xe as $optgroup, Ze as $option, Qe as $output, $e as $p, et as $picture, qt as $portal, tt as $pre, nt as $progress, rt as $q, it as $rp, at as $rt, ot as $ruby, st as $s, ct as $samp, lt as $script, ut as $search, dt as $section, ft as $select, Ut as $show, pt as $slot, mt as $small, ht as $source, gt as $span, _t as $strong, vt as $style, yt as $sub, bt as $summary, xt as $sup, Jt as $suspense, Wt as $switch, St as $table, Ct as $tbody, wt as $td, Tt as $template, Et as $textarea, Dt as $tfoot, Ot as $th, kt as $thead, At as $time, jt as $title, Mt as $tr, Nt as $track, Pt as $u, Ft as $ul, It as $var, X as $video, Lt as $wbr, o as batch, g as catchError, r as computed, v as createContext, f as createRoot, t as effect, m as getOwner, b as html, S as insert, T as isServer, a as isStaticRender, Yt as lazy, ie as mount, u as onCleanup, p as onMount, _ as provide, y as reconcile, h as renderStatic, w as resource, d as runWithOwner, e as signal, te as store, Rt as unsafeHTML, l as untrack, ne as unwrap, ee as useContext };
|
package/dist/prod/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as e } from "./shared/computed-
|
|
2
|
-
import { t } from "./shared/signal-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "./shared/computed-BjqJ6Pps.js";
|
|
2
|
+
import { t } from "./shared/signal-BDMlfa0Z.js";
|
|
3
|
+
import { g as n, i as r, l as i, n as a, s as o, x as s } from "./shared/graph-CR2WKbwr.js";
|
|
4
|
+
import { a as c } from "./shared/owner-DBi3odT4.js";
|
|
5
5
|
// src/router/history.ts
|
|
6
6
|
var l = () => Math.random().toString(36).slice(2, 10), u = () => window.history.state?.keitsKey ?? "start";
|
|
7
7
|
function d(e = "") {
|
|
@@ -9,7 +9,7 @@ function d(e = "") {
|
|
|
9
9
|
return {
|
|
10
10
|
read() {
|
|
11
11
|
let e = window.location.pathname;
|
|
12
|
-
return t !== "" && e.startsWith(t) && (e = e.slice(t.length)), {
|
|
12
|
+
return t !== "" && (e === t || e.startsWith(`${t}/`)) && (e = e.slice(t.length)), {
|
|
13
13
|
path: e || "/",
|
|
14
14
|
search: window.location.search,
|
|
15
15
|
hash: window.location.hash
|
|
@@ -185,8 +185,21 @@ function w(e, t) {
|
|
|
185
185
|
return encodeURIComponent(String(r));
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
+
async function T(e) {
|
|
189
|
+
let t = [];
|
|
190
|
+
for (let n of _(e)) {
|
|
191
|
+
if (n.keys.includes("*")) continue;
|
|
192
|
+
if (n.keys.length === 0) {
|
|
193
|
+
t.push(n.path);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
let e = [...n.routes].reverse().find((e) => e.paths !== void 0);
|
|
197
|
+
if (e !== void 0) for (let r of await e.paths()) t.push(w(n.path, r));
|
|
198
|
+
}
|
|
199
|
+
return [...new Set(t)];
|
|
200
|
+
}
|
|
188
201
|
// src/router/scroll.ts
|
|
189
|
-
function
|
|
202
|
+
function E() {
|
|
190
203
|
let e = /* @__PURE__ */ new Map();
|
|
191
204
|
return "scrollRestoration" in window.history && (window.history.scrollRestoration = "manual"), {
|
|
192
205
|
save(t) {
|
|
@@ -197,7 +210,7 @@ function T() {
|
|
|
197
210
|
if (o !== void 0) window.scrollTo(o[0], o[1]);
|
|
198
211
|
else {
|
|
199
212
|
if (i !== "" && (r || a)) {
|
|
200
|
-
let e = document.getElementById(
|
|
213
|
+
let e = document.getElementById(D(i));
|
|
201
214
|
if (e !== null) {
|
|
202
215
|
e.scrollIntoView();
|
|
203
216
|
return;
|
|
@@ -208,7 +221,7 @@ function T() {
|
|
|
208
221
|
}
|
|
209
222
|
};
|
|
210
223
|
}
|
|
211
|
-
function
|
|
224
|
+
function D(e) {
|
|
212
225
|
try {
|
|
213
226
|
return decodeURIComponent(e.slice(1));
|
|
214
227
|
} catch {
|
|
@@ -216,130 +229,130 @@ function E(e) {
|
|
|
216
229
|
}
|
|
217
230
|
}
|
|
218
231
|
// src/router/router.ts
|
|
219
|
-
function
|
|
220
|
-
let u = typeof l.history == "object" ? l.history : l.history === "hash" ? f() : d(l.base),
|
|
232
|
+
function O(l) {
|
|
233
|
+
let u = typeof l.history == "object" ? l.history : l.history === "hash" ? f() : typeof window > "u" ? p() : d(l.base), g = o(), v = _(l.routes), b = t(u.read(), { equals: (e, t) => e.path === t.path && e.search === t.search && e.hash === t.hash }), T = t(!1), D = t(!1), O = /* @__PURE__ */ new Set(), M = 0, N = l.scroll ?? typeof window < "u" ? E() : null, P = u.key(), F = e(() => T() ? y(v, b().path) : null), I = e(() => F()?.params ?? {}, { equals: j }), L = e(() => S(x(F()), b().search), { equals: j }), R = (e, t) => {
|
|
221
234
|
let n = w(e, t?.params), r = t?.query ? C(t.query) : "", i = t?.hash ? `#${t.hash.replace(/^#/, "")}` : "";
|
|
222
235
|
return n + r + i;
|
|
223
236
|
};
|
|
224
|
-
function
|
|
225
|
-
let c = ++
|
|
226
|
-
d !== null &&
|
|
227
|
-
let
|
|
228
|
-
return
|
|
229
|
-
if (
|
|
237
|
+
function z(e, t, o = 0) {
|
|
238
|
+
let c = ++M, l = m(e), d = s(T) ? s(b) : null, f = () => {
|
|
239
|
+
d !== null && N?.save(P), t === "push" ? u.push(e) : (t === "replace" || o > 0) && u.replace(e), P = u.key();
|
|
240
|
+
let i = P;
|
|
241
|
+
return r(() => {
|
|
242
|
+
if (D.set(!1), T.set(!0), b.set(u.read()), N !== null && d !== null) {
|
|
230
243
|
let e = d.path !== l.path, r = d.hash !== l.hash;
|
|
231
|
-
|
|
244
|
+
n(null, () => a(() => N.restore(i, t === "pop", e, l.hash, r)));
|
|
232
245
|
}
|
|
233
246
|
}), !0;
|
|
234
247
|
};
|
|
235
248
|
if (d !== null && d.path === l.path) return Promise.resolve(f());
|
|
236
|
-
let
|
|
249
|
+
let p = y(v, l.path), h = {
|
|
237
250
|
path: l.path,
|
|
238
|
-
route:
|
|
239
|
-
params:
|
|
251
|
+
route: p?.path ?? null,
|
|
252
|
+
params: p?.params ?? {},
|
|
240
253
|
search: l.search,
|
|
241
254
|
from: d?.path ?? null
|
|
242
|
-
},
|
|
243
|
-
if (d !== null) for (let e of
|
|
244
|
-
for (let e of
|
|
255
|
+
}, _ = [];
|
|
256
|
+
if (d !== null) for (let e of O) _.push(() => e(h));
|
|
257
|
+
for (let e of p?.routes ?? []) {
|
|
245
258
|
let t = e.guard;
|
|
246
|
-
t &&
|
|
259
|
+
t && _.push(() => t(h));
|
|
247
260
|
}
|
|
248
|
-
let
|
|
249
|
-
if (c !==
|
|
261
|
+
let x = (e) => {
|
|
262
|
+
if (c !== M) return !1;
|
|
250
263
|
if (e === !0) return f();
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
253
|
-
return
|
|
264
|
+
if (D.set(!1), typeof e == "string") {
|
|
265
|
+
if (o >= 10) throw Error("[keits/router] redirect loop");
|
|
266
|
+
return z(e, t === "pop" ? "replace" : t, o + 1);
|
|
254
267
|
}
|
|
255
|
-
return t === "pop" && d !== null && (u.push(d.path + d.search + d.hash),
|
|
256
|
-
},
|
|
257
|
-
c ===
|
|
268
|
+
return t === "pop" && d !== null && (u.push(d.path + d.search + d.hash), P = u.key()), !1;
|
|
269
|
+
}, S = (e) => {
|
|
270
|
+
c === M && D.set(!1);
|
|
258
271
|
try {
|
|
259
|
-
return
|
|
272
|
+
return i(e, g), Promise.resolve(!1);
|
|
260
273
|
} catch (e) {
|
|
261
274
|
return Promise.reject(e);
|
|
262
275
|
}
|
|
263
|
-
},
|
|
276
|
+
}, C = (e) => {
|
|
264
277
|
try {
|
|
265
|
-
return Promise.resolve(
|
|
278
|
+
return Promise.resolve(x(e));
|
|
266
279
|
} catch (e) {
|
|
267
|
-
return
|
|
280
|
+
return S(e);
|
|
268
281
|
}
|
|
269
|
-
},
|
|
282
|
+
}, w;
|
|
270
283
|
try {
|
|
271
|
-
|
|
284
|
+
w = k(_, 0);
|
|
272
285
|
} catch (e) {
|
|
273
|
-
return
|
|
286
|
+
return S(e);
|
|
274
287
|
}
|
|
275
|
-
return
|
|
288
|
+
return A(w) ? (D.set(!0), w.then(C, S)) : C(w);
|
|
276
289
|
}
|
|
277
|
-
let
|
|
290
|
+
let B = u.listen(() => {
|
|
278
291
|
let e = u.read();
|
|
279
|
-
|
|
280
|
-
}),
|
|
281
|
-
|
|
282
|
-
let
|
|
292
|
+
z(e.path + e.search + e.hash, "pop");
|
|
293
|
+
}), V = u.read();
|
|
294
|
+
z(V.path + V.search + V.hash, "start");
|
|
295
|
+
let H = (e) => {
|
|
283
296
|
let t = h(e, (e) => u.toAppUrl(e));
|
|
284
297
|
if (t === null) return;
|
|
285
298
|
e.preventDefault();
|
|
286
|
-
let n =
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
return
|
|
290
|
-
location: () =>
|
|
291
|
-
match: () =>
|
|
292
|
-
params: () =>
|
|
293
|
-
query: () =>
|
|
294
|
-
pending: () =>
|
|
295
|
-
navigate: (e, t) =>
|
|
296
|
-
href: (e, t) => u.href(
|
|
299
|
+
let n = s(b);
|
|
300
|
+
z(t, t === n.path + n.search + n.hash ? "replace" : "push");
|
|
301
|
+
}, U = l.links !== !1 && typeof document < "u";
|
|
302
|
+
return U && document.addEventListener("click", H), {
|
|
303
|
+
location: () => b(),
|
|
304
|
+
match: () => F(),
|
|
305
|
+
params: () => I(),
|
|
306
|
+
query: () => L(),
|
|
307
|
+
pending: () => D(),
|
|
308
|
+
navigate: (e, t) => z(e.includes(":") || t?.query || t?.hash ? R(e, t) : e, t?.replace ? "replace" : "push"),
|
|
309
|
+
href: (e, t) => u.href(R(e, t)),
|
|
297
310
|
setQuery(e, t) {
|
|
298
|
-
let n =
|
|
311
|
+
let n = s(b), r = {
|
|
299
312
|
...Object.fromEntries(new URLSearchParams(n.search)),
|
|
300
313
|
...e
|
|
301
314
|
};
|
|
302
|
-
|
|
315
|
+
z(n.path + C(r) + n.hash, t?.push ? "push" : "replace");
|
|
303
316
|
},
|
|
304
317
|
onLeave(e) {
|
|
305
|
-
|
|
318
|
+
O.add(e), c(() => O.delete(e));
|
|
306
319
|
},
|
|
307
320
|
view() {
|
|
308
|
-
let t = (n,
|
|
309
|
-
let
|
|
321
|
+
let t = (n, r) => {
|
|
322
|
+
let i = e(() => F()?.routes[n] ?? null);
|
|
310
323
|
return () => {
|
|
311
|
-
let e =
|
|
312
|
-
return
|
|
313
|
-
if (e === null) return
|
|
314
|
-
let
|
|
315
|
-
return e.layout ? e.layout({ children:
|
|
324
|
+
let e = i();
|
|
325
|
+
return s(() => {
|
|
326
|
+
if (e === null) return r?.component ? r.component() : null;
|
|
327
|
+
let i = t(n + 1, e);
|
|
328
|
+
return e.layout ? e.layout({ children: i }) : i;
|
|
316
329
|
});
|
|
317
330
|
};
|
|
318
331
|
};
|
|
319
332
|
return t(0, null);
|
|
320
333
|
},
|
|
321
334
|
isActive(e, t = !1) {
|
|
322
|
-
let n =
|
|
335
|
+
let n = b().path.replace(/\/$/, "") || "/", r = m(e).path.replace(/\/$/, "") || "/";
|
|
323
336
|
return t ? n === r : n === r || n.startsWith(`${r}/`);
|
|
324
337
|
},
|
|
325
338
|
dispose() {
|
|
326
|
-
|
|
339
|
+
B(), U && document.removeEventListener("click", H);
|
|
327
340
|
}
|
|
328
341
|
};
|
|
329
342
|
}
|
|
330
|
-
function
|
|
343
|
+
function k(e, t) {
|
|
331
344
|
for (let n = t; n < e.length; n++) {
|
|
332
345
|
let t = e[n]();
|
|
333
|
-
if (
|
|
346
|
+
if (A(t)) return Promise.resolve(t).then((t) => t === !0 ? k(e, n + 1) : t);
|
|
334
347
|
if (t !== !0) return t;
|
|
335
348
|
}
|
|
336
349
|
return !0;
|
|
337
350
|
}
|
|
338
|
-
function
|
|
351
|
+
function A(e) {
|
|
339
352
|
return typeof e?.then == "function";
|
|
340
353
|
}
|
|
341
|
-
function
|
|
354
|
+
function j(e, t) {
|
|
342
355
|
let n = Object.keys(e);
|
|
343
356
|
return n.length === Object.keys(t).length && n.every((n) => Object.is(e[n], t[n]));
|
|
344
357
|
}
|
|
345
|
-
export { d as browserHistory,
|
|
358
|
+
export { d as browserHistory, O as createRouter, f as hashHistory, p as memoryHistory, T as staticPaths };
|