keits 0.0.4 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +93 -79
  2. package/dist/dev/api.js +8 -3
  3. package/dist/dev/forms.js +10 -5
  4. package/dist/dev/index.js +28 -35
  5. package/dist/dev/router.js +24 -7
  6. package/dist/dev/shared/{computed-3UO-KiH1.js → computed-DrF8O8b4.js} +1 -1
  7. package/dist/dev/shared/element-Bgf6SNbW.js +21 -0
  8. package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
  9. package/dist/dev/shared/hydrate-g_akkVyT.js +588 -0
  10. package/dist/dev/shared/{element-CQPqagu1.js → insert-DadcXJL8.js} +116 -86
  11. package/dist/dev/shared/mount-BtpMEhSZ.js +23 -0
  12. package/dist/dev/shared/{owner-Dmge21OW.js → owner-BuwIoI4j.js} +12 -2
  13. package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
  14. package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
  15. package/dist/dev/shared/{resource-CbXVATvq.js → resource-DlgzdtcG.js} +24 -33
  16. package/dist/dev/shared/{signal-BOXkY-Iv.js → signal-B3xOKbVm.js} +1 -1
  17. package/dist/dev/shared/{store-BzUN1qE5.js → store-0vEg2bQV.js} +7 -3
  18. package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
  19. package/dist/dev/static.js +76 -0
  20. package/dist/dev/svg.js +2 -1
  21. package/dist/dev/testing.js +236 -0
  22. package/dist/dev/vite.js +141 -0
  23. package/dist/prod/api.js +76 -71
  24. package/dist/prod/forms.js +89 -84
  25. package/dist/prod/index.js +58 -66
  26. package/dist/prod/router.js +86 -73
  27. package/dist/prod/shared/{computed-CAPpOLCY.js → computed-BjqJ6Pps.js} +1 -1
  28. package/dist/prod/shared/element-B-0tH1YW.js +15 -0
  29. package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
  30. package/dist/prod/shared/hydrate-DhHCtdOz.js +480 -0
  31. package/dist/prod/shared/insert-CbcOsYmu.js +192 -0
  32. package/dist/prod/shared/mount-BEAO35S_.js +18 -0
  33. package/dist/prod/shared/owner-DBi3odT4.js +67 -0
  34. package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
  35. package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
  36. package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
  37. package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
  38. package/dist/prod/shared/store-CvW0DbmK.js +110 -0
  39. package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
  40. package/dist/prod/static.js +48 -0
  41. package/dist/prod/svg.js +3 -2
  42. package/dist/prod/testing.js +161 -0
  43. package/dist/prod/vite.js +106 -0
  44. package/dist/types/async/render-context.d.ts +10 -0
  45. package/dist/types/core/effect.d.ts +1 -0
  46. package/dist/types/core/graph.d.ts +11 -0
  47. package/dist/types/core/owner.d.ts +1 -0
  48. package/dist/types/core/unsafe-keys.d.ts +2 -0
  49. package/dist/types/dom/hooks.d.ts +4 -0
  50. package/dist/types/dom/props.d.ts +2 -0
  51. package/dist/types/dom/types.d.ts +5 -0
  52. package/dist/types/router/index.d.ts +1 -0
  53. package/dist/types/router/match.d.ts +1 -0
  54. package/dist/types/router/types.d.ts +1 -0
  55. package/dist/types/static/head.d.ts +36 -0
  56. package/dist/types/static/hydrate.d.ts +3 -0
  57. package/dist/types/static/index.d.ts +4 -0
  58. package/dist/types/static/island.d.ts +14 -0
  59. package/dist/types/static/json.d.ts +1 -0
  60. package/dist/types/static/render.d.ts +11 -0
  61. package/dist/types/static/server-dom.d.ts +100 -0
  62. package/dist/types/testing/index.d.ts +69 -0
  63. package/dist/types/vite/index.d.ts +24 -0
  64. package/package.json +35 -8
  65. package/dist/dev/shared/render-effect-kOGnLNbL.js +0 -26
  66. package/dist/prod/shared/element-DGyQ01Vs.js +0 -164
  67. package/dist/prod/shared/owner-6BFHIPR9.js +0 -59
  68. package/dist/prod/shared/render-effect-DjaUT3Cn.js +0 -23
  69. package/dist/prod/shared/resource-CNC2DBO3.js +0 -109
  70. package/dist/prod/shared/signal-DGrl3r9T.js +0 -16
  71. package/dist/prod/shared/store-Dcscpk_h.js +0 -109
@@ -1,7 +1,7 @@
1
- import { t as e } from "./shared/computed-CAPpOLCY.js";
2
- import { t } from "./shared/signal-DGrl3r9T.js";
3
- import { c as n, h as r, i, n as a, p as o, s } from "./shared/graph-C_aA46c6.js";
4
- import { i as c } from "./shared/owner-6BFHIPR9.js";
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 T() {
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(E(i));
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 E(e) {
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 D(l) {
220
- let u = typeof l.history == "object" ? l.history : l.history === "hash" ? f() : d(l.base), p = s(), g = _(l.routes), v = t(u.read(), { equals: (e, t) => e.path === t.path && e.search === t.search && e.hash === t.hash }), b = t(!1), E = t(!1), D = /* @__PURE__ */ new Set(), j = 0, M = l.scroll ?? typeof window < "u" ? T() : null, N = u.key(), P = e(() => b() ? y(g, v().path) : null), F = e(() => P()?.params ?? {}, { equals: A }), I = e(() => S(x(P()), v().search), { equals: A }), L = (e, t) => {
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 R(e, t, s = 0) {
225
- let c = ++j, l = m(e), d = r(b) ? r(v) : null, f = () => {
226
- d !== null && M?.save(N), t === "push" ? u.push(e) : (t === "replace" || s > 0) && u.replace(e), N = u.key();
227
- let n = N;
228
- return i(() => {
229
- if (E.set(!1), b.set(!0), v.set(u.read()), M !== null && d !== null) {
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
- o(null, () => a(() => M.restore(n, t === "pop", e, l.hash, r)));
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 h = y(g, l.path), _ = {
249
+ let p = y(v, l.path), h = {
237
250
  path: l.path,
238
- route: h?.path ?? null,
239
- params: h?.params ?? {},
251
+ route: p?.path ?? null,
252
+ params: p?.params ?? {},
240
253
  search: l.search,
241
254
  from: d?.path ?? null
242
- }, x = [];
243
- if (d !== null) for (let e of D) x.push(() => e(_));
244
- for (let e of h?.routes ?? []) {
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 && x.push(() => t(_));
259
+ t && _.push(() => t(h));
247
260
  }
248
- let S = (e) => {
249
- if (c !== j) return !1;
261
+ let x = (e) => {
262
+ if (c !== M) return !1;
250
263
  if (e === !0) return f();
251
- if (E.set(!1), typeof e == "string") {
252
- if (s >= 10) throw Error("[keits/router] redirect loop");
253
- return R(e, t === "pop" ? "replace" : t, s + 1);
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), N = u.key()), !1;
256
- }, C = (e) => {
257
- c === j && E.set(!1);
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 n(e, p), Promise.resolve(!1);
272
+ return i(e, g), Promise.resolve(!1);
260
273
  } catch (e) {
261
274
  return Promise.reject(e);
262
275
  }
263
- }, w = (e) => {
276
+ }, C = (e) => {
264
277
  try {
265
- return Promise.resolve(S(e));
278
+ return Promise.resolve(x(e));
266
279
  } catch (e) {
267
- return C(e);
280
+ return S(e);
268
281
  }
269
- }, T;
282
+ }, w;
270
283
  try {
271
- T = O(x, 0);
284
+ w = k(_, 0);
272
285
  } catch (e) {
273
- return C(e);
286
+ return S(e);
274
287
  }
275
- return k(T) ? (E.set(!0), T.then(w, C)) : w(T);
288
+ return A(w) ? (D.set(!0), w.then(C, S)) : C(w);
276
289
  }
277
- let z = u.listen(() => {
290
+ let B = u.listen(() => {
278
291
  let e = u.read();
279
- R(e.path + e.search + e.hash, "pop");
280
- }), B = u.read();
281
- R(B.path + B.search + B.hash, "start");
282
- let V = (e) => {
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 = r(v);
287
- R(t, t === n.path + n.search + n.hash ? "replace" : "push");
288
- }, H = l.links !== !1 && typeof document < "u";
289
- return H && document.addEventListener("click", V), {
290
- location: () => v(),
291
- match: () => P(),
292
- params: () => F(),
293
- query: () => I(),
294
- pending: () => E(),
295
- navigate: (e, t) => R(e.includes(":") || t?.query || t?.hash ? L(e, t) : e, t?.replace ? "replace" : "push"),
296
- href: (e, t) => u.href(L(e, t)),
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 = r(v), i = {
311
+ let n = s(b), r = {
299
312
  ...Object.fromEntries(new URLSearchParams(n.search)),
300
313
  ...e
301
314
  };
302
- R(n.path + C(i) + n.hash, t?.push ? "push" : "replace");
315
+ z(n.path + C(r) + n.hash, t?.push ? "push" : "replace");
303
316
  },
304
317
  onLeave(e) {
305
- D.add(e), c(() => D.delete(e));
318
+ O.add(e), c(() => O.delete(e));
306
319
  },
307
320
  view() {
308
- let t = (n, i) => {
309
- let a = e(() => P()?.routes[n] ?? null);
321
+ let t = (n, r) => {
322
+ let i = e(() => F()?.routes[n] ?? null);
310
323
  return () => {
311
- let e = a();
312
- return r(() => {
313
- if (e === null) return i?.component ? i.component() : null;
314
- let r = t(n + 1, e);
315
- return e.layout ? e.layout({ children: r }) : r;
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 = v().path.replace(/\/$/, "") || "/", r = m(e).path.replace(/\/$/, "") || "/";
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
- z(), H && document.removeEventListener("click", V);
339
+ B(), U && document.removeEventListener("click", H);
327
340
  }
328
341
  };
329
342
  }
330
- function O(e, t) {
343
+ function k(e, t) {
331
344
  for (let n = t; n < e.length; n++) {
332
345
  let t = e[n]();
333
- if (k(t)) return Promise.resolve(t).then((t) => t === !0 ? O(e, n + 1) : t);
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 k(e) {
351
+ function A(e) {
339
352
  return typeof e?.then == "function";
340
353
  }
341
- function A(e, t) {
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, D as createRouter, f as hashHistory, p as memoryHistory };
358
+ export { d as browserHistory, O as createRouter, f as hashHistory, p as memoryHistory, T as staticPaths };
@@ -1,4 +1,4 @@
1
- import { g as e, m as t, r as n } from "./graph-C_aA46c6.js";
1
+ import { S as e, b as t, r as n } from "./graph-CR2WKbwr.js";
2
2
  // src/core/computed.ts
3
3
  function r(r, a) {
4
4
  let o = {
@@ -0,0 +1,15 @@
1
+ import { n as e, s as t, t as n } from "./insert-CbcOsYmu.js";
2
+ // src/dom/element.ts
3
+ function r(e) {
4
+ return i(e, null);
5
+ }
6
+ function i(r, i) {
7
+ return (o, s) => {
8
+ let c = t.element(r, i);
9
+ return a(o) ? (n(c, s), e(c, o), typeof o.ref == "function" && o.ref(c)) : o == null ? n(c, s) : n(c, o), c;
10
+ };
11
+ }
12
+ function a(e) {
13
+ return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.nodeType != "number";
14
+ }
15
+ export { r as n, i as t };
@@ -1,40 +1,40 @@
1
- var e = null, t = null, n = 0, r = 0, i = null, a = 0, o = 0, s = 0, c = [], l = [], u = [], d = 0;
2
- function f(t) {
1
+ var e = null, t = null, n = 0, r = 0, i = null, a = 0, o = 0, s = 0, c = [], l = [], u = [], d = 0, f = 0;
2
+ function p(t) {
3
3
  let r = e;
4
4
  r !== null && t.seenBy !== n && (t.seenBy = n, i === null && r.sources[a] === t ? a++ : ((i ??= []).push(t), t.observers.push(r)));
5
5
  }
6
- function p() {
6
+ function m() {
7
7
  return e !== null;
8
8
  }
9
- function m(e) {
9
+ function h(e) {
10
10
  if (e.observers.length !== 0) {
11
11
  o++;
12
12
  try {
13
- for (let t of e.observers) h(t, 2);
13
+ for (let t of e.observers) g(t, 2);
14
14
  } finally {
15
- C();
15
+ w();
16
16
  }
17
17
  }
18
18
  }
19
- function h(e, t) {
19
+ function g(e, t) {
20
20
  if (e.state >= t) return;
21
21
  let n = e.state === 0;
22
22
  if (e.state = t, n) {
23
23
  if (e.kind === 1) c.push(e);
24
- else for (let t of e.observers) h(t, 1);
24
+ else for (let t of e.observers) g(t, 1);
25
25
  }
26
26
  }
27
- function g(e) {
27
+ function _(e) {
28
28
  if (e.state === 1) {
29
- for (let t of e.sources) if (t.kind === 2 && (g(t), e.state === 2)) break;
29
+ for (let t of e.sources) if (t.kind === 2 && (_(t), e.state === 2)) break;
30
30
  }
31
- e.state === 2 ? e.kind === 1 ? v(e) : _(e) : e.state = 0;
31
+ e.state === 2 ? e.kind === 1 ? y(e) : v(e) : e.state = 0;
32
32
  }
33
- function _(e) {
33
+ function v(e) {
34
34
  let t;
35
35
  e.computing = !0;
36
36
  try {
37
- let n = y(e, () => e.fn(e.value));
37
+ let n = b(e, () => e.fn(e.value));
38
38
  t = !e.hasValue || e.hasError || e.equals === !1 || !e.equals(e.value, n), t && (e.value = n), e.hasValue = !0, e.hasError = !1, e.error = void 0;
39
39
  } catch (n) {
40
40
  t = !0, e.hasError = !0, e.error = n;
@@ -43,76 +43,76 @@ function _(e) {
43
43
  }
44
44
  if (t) for (let t of e.observers) t.state === 1 && (t.state = 2);
45
45
  }
46
- function v(e) {
46
+ function y(e) {
47
47
  try {
48
- y(e, e.fn);
48
+ b(e, e.fn);
49
49
  } catch (t) {
50
- z(t, e);
50
+ K(t, e);
51
51
  }
52
52
  }
53
- function y(o, s) {
54
- L(o);
53
+ function b(o, s) {
54
+ W(o);
55
55
  let c = e, l = t, u = n, d = i, f = a;
56
56
  e = o, t = o, n = ++r, i = null, a = 0, o.state = 0;
57
57
  try {
58
58
  return s();
59
59
  } finally {
60
- b(o, i, a), e = c, t = l, n = u, i = d, a = f;
60
+ x(o, i, a), e = c, t = l, n = u, i = d, a = f;
61
61
  }
62
62
  }
63
- function b(e, t, n) {
63
+ function x(e, t, n) {
64
64
  if (e.disposed) {
65
- if (t !== null) for (let n of t) x(n, e);
65
+ if (t !== null) for (let n of t) S(n, e);
66
66
  return;
67
67
  }
68
68
  let r = e.sources;
69
- for (let t = n; t < r.length; t++) x(r[t], e);
69
+ for (let t = n; t < r.length; t++) S(r[t], e);
70
70
  if (r.length = n, t !== null) for (let e of t) r.push(e);
71
71
  }
72
- function x(e, t) {
72
+ function S(e, t) {
73
73
  let n = e.observers, r = n.lastIndexOf(t);
74
74
  r !== -1 && (n[r] = n[n.length - 1], n.pop());
75
75
  }
76
- function S(e) {
76
+ function C(e) {
77
77
  o++;
78
78
  try {
79
79
  return e();
80
80
  } finally {
81
- C();
81
+ w();
82
82
  }
83
83
  }
84
- function C() {
85
- --o === 0 && w();
86
- }
87
84
  function w() {
85
+ --o === 0 && T();
86
+ }
87
+ function T() {
88
88
  do
89
- E(), l.length > 0 && T();
89
+ D(), l.length > 0 && E();
90
90
  while (c.length > 0 || l.length > 0);
91
91
  if (u.length > 0) {
92
92
  let e = u.splice(0);
93
93
  throw e.length === 1 ? e[0] : AggregateError(e, "[keits] multiple unhandled errors");
94
94
  }
95
95
  }
96
- function T() {
96
+ function E() {
97
97
  o++;
98
98
  let e = l.splice(0);
99
99
  try {
100
100
  for (let { owner: t, fn: n } of e) if (!t?.disposed) try {
101
- M(t, n);
101
+ z(t, n);
102
102
  } catch (e) {
103
- z(e, t);
103
+ K(e, t);
104
104
  }
105
105
  } finally {
106
106
  o--;
107
107
  }
108
108
  }
109
- function E() {
109
+ function D() {
110
110
  o++;
111
111
  let e = ++s, t = !1;
112
112
  try {
113
113
  for (let t = 0; t < c.length; t++) {
114
114
  let n = c[t];
115
- n.state !== 0 && (n.flushId !== e && (n.flushId = e, n.flushRuns = 0), ++n.flushRuns > 100 ? (n.state = 0, z(O(n), n)) : D(n));
115
+ n.state !== 0 && (n.flushId !== e && (n.flushId = e, n.flushRuns = 0), ++n.flushRuns > 100 ? (n.state = 0, K(k(n), n)) : O(n));
116
116
  }
117
117
  t = !0;
118
118
  } finally {
@@ -120,16 +120,16 @@ function E() {
120
120
  c.length = 0, o--;
121
121
  }
122
122
  }
123
- function D(e) {
123
+ function O(e) {
124
124
  let t = [];
125
125
  for (let n = e.owner; n !== null; n = n.owner) n.kind !== 3 && n.state !== 0 && t.push(n);
126
- for (let e = t.length - 1; e >= 0; e--) g(t[e]);
127
- g(e);
126
+ for (let e = t.length - 1; e >= 0; e--) _(t[e]);
127
+ _(e);
128
128
  }
129
- function O(e) {
129
+ function k(e) {
130
130
  return /* @__PURE__ */ Error("[keits] infinite update loop");
131
131
  }
132
- function k(t) {
132
+ function A(t) {
133
133
  let n = e;
134
134
  e = null;
135
135
  try {
@@ -138,14 +138,35 @@ function k(t) {
138
138
  e = n;
139
139
  }
140
140
  }
141
- function A(e) {
141
+ function j(e) {
142
142
  let n = t;
143
- e.owner = n, n !== null && (n.children ??= []).push(e);
143
+ e.owner = n, n !== null && (n.children ??= []).push(e), I(e);
144
+ }
145
+ var M = 0;
146
+ function N() {
147
+ M++;
148
+ }
149
+ function P() {
150
+ M--;
151
+ }
152
+ function F() {
153
+ let e = t;
154
+ if (M === 0 || e === null || e.key === void 0) return null;
155
+ let n = e.keyCount ?? 0;
156
+ return e.keyCount = n + 1, `${e.key}.${n}`;
157
+ }
158
+ function I(e) {
159
+ let t = F();
160
+ t !== null && (e.key = t, e.keyCount = 0);
144
161
  }
145
- function j() {
162
+ function L(e = t) {
163
+ for (let t = e; t !== null; t = t.owner) if (t.kind === 3 && t.hydratable) return !0;
164
+ return !1;
165
+ }
166
+ function R() {
146
167
  return t;
147
168
  }
148
- function M(n, r) {
169
+ function z(n, r) {
149
170
  let i = t, a = e;
150
171
  t = n, e = null;
151
172
  try {
@@ -154,13 +175,13 @@ function M(n, r) {
154
175
  t = i, e = a;
155
176
  }
156
177
  }
157
- function N(e) {
178
+ function B(e) {
158
179
  return t !== null && ((t.cleanups ??= []).push(e), !0);
159
180
  }
160
- function P(e) {
161
- d > 0 || F(t, e);
181
+ function V(e) {
182
+ q() || H(t, e);
162
183
  }
163
- function F(e, t) {
184
+ function H(e, t) {
164
185
  for (let n = e; n !== null; n = n.owner) if (n.kind === 3 && n.held) {
165
186
  n.held.push({
166
187
  owner: e,
@@ -173,7 +194,7 @@ function F(e, t) {
173
194
  fn: t
174
195
  });
175
196
  }
176
- function I(e) {
197
+ function U(e) {
177
198
  let t = {
178
199
  kind: 3,
179
200
  owner: null,
@@ -183,41 +204,41 @@ function I(e) {
183
204
  handler: null,
184
205
  held: []
185
206
  };
186
- return A(t), {
187
- result: M(t, e),
207
+ return j(t), {
208
+ result: z(t, e),
188
209
  release: () => {
189
210
  let e = t.held;
190
211
  if (e) {
191
212
  t.held = null;
192
- for (let { owner: t, fn: n } of e) F(t, n);
213
+ for (let { owner: t, fn: n } of e) H(t, n);
193
214
  }
194
215
  }
195
216
  };
196
217
  }
197
- function L(e) {
218
+ function W(e) {
198
219
  let t = e.children, n = e.cleanups;
199
- if (e.children = null, e.cleanups = null, t !== null) for (let e = t.length - 1; e >= 0; e--) R(t[e]);
220
+ if (e.children = null, e.cleanups = null, e.key !== void 0 && (e.keyCount = 0), t !== null) for (let e = t.length - 1; e >= 0; e--) G(t[e]);
200
221
  if (n !== null) for (let t = n.length - 1; t >= 0; t--) try {
201
222
  n[t]();
202
223
  } catch (t) {
203
- z(t, e);
224
+ K(t, e);
204
225
  }
205
226
  }
206
- function R(e) {
227
+ function G(e) {
207
228
  if (!e.disposed) {
208
229
  if (e.disposed = !0, e.kind !== 3) {
209
- for (let t of e.sources) x(t, e);
230
+ for (let t of e.sources) S(t, e);
210
231
  e.sources.length = 0, e.state = 0;
211
232
  }
212
- L(e);
233
+ W(e);
213
234
  }
214
235
  }
215
- function z(e, t) {
236
+ function K(e, t) {
216
237
  for (let n = t; n !== null; n = n.owner) {
217
238
  if (n.kind !== 3 || n.handler === null || n.disposed) continue;
218
239
  let t = n.handler;
219
240
  try {
220
- M(n.owner, () => t(e));
241
+ z(n.owner, () => t(e));
221
242
  return;
222
243
  } catch (t) {
223
244
  e = t;
@@ -226,10 +247,33 @@ function z(e, t) {
226
247
  if (o === 0) throw e;
227
248
  u.push(e);
228
249
  }
229
- function B() {
230
- return d > 0;
250
+ function q() {
251
+ if (d > 0) return !0;
252
+ if (f === 0) return !1;
253
+ for (let e = t; e !== null; e = e.owner) if (e.kind === 3 && e.static) return !0;
254
+ return !1;
231
255
  }
232
- function V(e) {
256
+ function J(e) {
257
+ let t = {
258
+ kind: 3,
259
+ owner: null,
260
+ children: null,
261
+ cleanups: null,
262
+ disposed: !1,
263
+ handler: null,
264
+ static: !0
265
+ };
266
+ f++;
267
+ let n = !1, r = () => {
268
+ n || (n = !0, f--, C(() => G(t)));
269
+ };
270
+ try {
271
+ return C(() => z(t, () => e(r)));
272
+ } catch (e) {
273
+ throw r(), e;
274
+ }
275
+ }
276
+ function Y(e) {
233
277
  d++;
234
278
  try {
235
279
  return e();
@@ -237,4 +281,4 @@ function V(e) {
237
281
  d--;
238
282
  }
239
283
  }
240
- export { V as _, I as a, z as c, m as d, v as f, g, k as h, S as i, B as l, f as m, P as n, R as o, M as p, A as r, j as s, N as t, p as u };
284
+ export { Y as C, _ as S, N as _, U as a, p as b, I as c, q as d, m as f, z as g, y as h, C as i, K as l, h as m, V as n, G as o, F as p, j as r, R as s, B as t, L as u, J as v, A as x, P as y };