keits 0.0.2 → 0.0.3

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 (39) hide show
  1. package/dist/dev/index.js +409 -122
  2. package/dist/dev/router.js +443 -0
  3. package/dist/dev/shared/{element-By0uLZli.js → element-C4DfKtZW.js} +2 -291
  4. package/dist/dev/shared/graph-D6-x_CWC.js +324 -0
  5. package/dist/dev/shared/owner-DlUsXKXE.js +122 -0
  6. package/dist/dev/svg.js +1 -1
  7. package/dist/prod/index.js +350 -166
  8. package/dist/prod/router.js +343 -0
  9. package/dist/prod/shared/element-DUtXb3px.js +187 -0
  10. package/dist/prod/shared/graph-C_aA46c6.js +240 -0
  11. package/dist/prod/shared/owner-DgJNPM0P.js +104 -0
  12. package/dist/prod/svg.js +1 -1
  13. package/dist/types/async/index.d.ts +2 -0
  14. package/dist/types/async/lazy.d.ts +7 -0
  15. package/dist/types/async/resource.d.ts +23 -0
  16. package/dist/types/async/suspense-context.d.ts +4 -0
  17. package/dist/types/core/graph.d.ts +8 -0
  18. package/dist/types/dom/types.d.ts +1 -1
  19. package/dist/types/flow/catch.d.ts +2 -0
  20. package/dist/types/flow/dynamic.d.ts +6 -0
  21. package/dist/types/flow/for.d.ts +7 -0
  22. package/dist/types/flow/if.d.ts +4 -0
  23. package/dist/types/flow/index.d.ts +8 -0
  24. package/dist/types/flow/portal.d.ts +2 -0
  25. package/dist/types/flow/range.d.ts +11 -0
  26. package/dist/types/flow/show.d.ts +1 -0
  27. package/dist/types/flow/suspense.d.ts +2 -0
  28. package/dist/types/flow/switch.d.ts +9 -0
  29. package/dist/types/index.d.ts +2 -0
  30. package/dist/types/router/history.d.ts +21 -0
  31. package/dist/types/router/index.d.ts +3 -0
  32. package/dist/types/router/links.d.ts +1 -0
  33. package/dist/types/router/match.d.ts +15 -0
  34. package/dist/types/router/router.d.ts +10 -0
  35. package/dist/types/router/scroll.d.ts +5 -0
  36. package/dist/types/router/types.d.ts +87 -0
  37. package/dist/types/svg/types.d.ts +1 -1
  38. package/package.json +23 -6
  39. package/dist/prod/shared/element-C8c5hIhH.js +0 -394
@@ -0,0 +1,122 @@
1
+ import { _ as withStaticRender, c as handleError, d as notify, g as updateIfNeeded, i as batch, m as track, n as addMount, o as dispose, p as runWithOwner$1, r as adopt, s as getOwner$1, t as addCleanup } from "./graph-D6-x_CWC.js";
2
+ // src/core/signal.ts
3
+ function signal(value, options) {
4
+ const node = {
5
+ kind: 0,
6
+ value,
7
+ equals: options?.equals ?? Object.is,
8
+ observers: [],
9
+ seenBy: 0
10
+ };
11
+ if (options?.name !== void 0) node.name = options.name;
12
+ const read = () => {
13
+ track(node);
14
+ return node.value;
15
+ };
16
+ const set = (next) => {
17
+ const value = typeof next === "function" ? next(node.value) : next;
18
+ if (node.equals !== false && node.equals(node.value, value)) return;
19
+ node.value = value;
20
+ notify(node);
21
+ };
22
+ return Object.assign(read, { set });
23
+ }
24
+ // src/core/computed.ts
25
+ function computed(fn, options) {
26
+ const node = {
27
+ kind: 2,
28
+ fn,
29
+ value: void 0,
30
+ equals: options?.equals ?? Object.is,
31
+ hasValue: false,
32
+ hasError: false,
33
+ error: void 0,
34
+ computing: false,
35
+ state: 2,
36
+ sources: [],
37
+ observers: [],
38
+ seenBy: 0,
39
+ flushId: 0,
40
+ flushRuns: 0,
41
+ owner: null,
42
+ children: null,
43
+ cleanups: null,
44
+ disposed: false
45
+ };
46
+ if (options?.name !== void 0) node.name = options.name;
47
+ adopt(node);
48
+ return () => {
49
+ if (node.computing) throw cycleError(node);
50
+ if (node.state !== 0) updateIfNeeded(node);
51
+ track(node);
52
+ if (node.hasError) throw node.error;
53
+ return node.value;
54
+ };
55
+ }
56
+ function cycleError(node) {
57
+ {
58
+ const who = node.name ? `"${node.name}"` : "a computed";
59
+ return /* @__PURE__ */ new Error(`[keits] Cycle detected: ${who} reads itself (directly or through other computeds).`);
60
+ }
61
+ }
62
+ // src/core/owner.ts
63
+ function getOwner() {
64
+ return getOwner$1();
65
+ }
66
+ function runWithOwner(owner, fn) {
67
+ return runWithOwner$1(owner, fn);
68
+ }
69
+ function createRoot(fn) {
70
+ const root = {
71
+ kind: 3,
72
+ owner: getOwner$1(),
73
+ children: null,
74
+ cleanups: null,
75
+ disposed: false,
76
+ handler: null
77
+ };
78
+ const disposeRoot = () => batch(() => dispose(root));
79
+ return batch(() => {
80
+ try {
81
+ return runWithOwner$1(root, () => fn(disposeRoot));
82
+ } catch (error) {
83
+ dispose(root);
84
+ throw error;
85
+ }
86
+ });
87
+ }
88
+ function onCleanup(fn) {
89
+ if (!addCleanup(fn) && true) console.warn("[keits] onCleanup was called outside an owner, so it will never run.");
90
+ }
91
+ function onMount(fn) {
92
+ addMount(fn);
93
+ }
94
+ function catchError(fn, handler) {
95
+ const boundary = {
96
+ kind: 3,
97
+ owner: null,
98
+ children: null,
99
+ cleanups: null,
100
+ disposed: false,
101
+ handler
102
+ };
103
+ adopt(boundary);
104
+ return batch(() => {
105
+ try {
106
+ return runWithOwner$1(boundary, fn);
107
+ } catch (error) {
108
+ handleError(error, boundary);
109
+ return;
110
+ }
111
+ });
112
+ }
113
+ function renderStatic(fn) {
114
+ return withStaticRender(() => createRoot((dispose) => {
115
+ try {
116
+ return fn();
117
+ } finally {
118
+ dispose();
119
+ }
120
+ }));
121
+ }
122
+ export { onMount as a, computed as c, onCleanup as i, signal as l, createRoot as n, renderStatic as o, getOwner as r, runWithOwner as s, catchError as t };
package/dist/dev/svg.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as SVG_NS, t as createFactory } from "./shared/element-By0uLZli.js";
1
+ import { r as SVG_NS, t as createFactory } from "./shared/element-C4DfKtZW.js";
2
2
  // src/svg/element.ts
3
3
  function svg(tag) {
4
4
  return createFactory(tag, SVG_NS);