kiru 0.48.3 → 0.49.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 (236) hide show
  1. package/dist/action.d.ts +22 -0
  2. package/dist/action.d.ts.map +1 -0
  3. package/dist/action.js +20 -0
  4. package/dist/action.js.map +1 -0
  5. package/dist/components/index.d.ts +5 -0
  6. package/dist/components/index.d.ts.map +1 -0
  7. package/dist/components/index.js +5 -0
  8. package/dist/components/index.js.map +1 -0
  9. package/dist/components/lazy.d.ts.map +1 -0
  10. package/dist/{lazy.js → components/lazy.js} +11 -11
  11. package/dist/components/lazy.js.map +1 -0
  12. package/dist/{memo.d.ts → components/memo.d.ts} +1 -1
  13. package/dist/components/memo.d.ts.map +1 -0
  14. package/dist/{memo.js → components/memo.js} +2 -2
  15. package/dist/components/memo.js.map +1 -0
  16. package/dist/components/portal.d.ts.map +1 -0
  17. package/dist/{portal.js → components/portal.js} +6 -6
  18. package/dist/components/portal.js.map +1 -0
  19. package/dist/components/router/index.d.ts.map +1 -0
  20. package/dist/components/router/index.js.map +1 -0
  21. package/dist/components/router/route.d.ts.map +1 -0
  22. package/dist/{router → components/router}/route.js +1 -1
  23. package/dist/components/router/route.js.map +1 -0
  24. package/dist/{router → components/router}/router.d.ts +1 -1
  25. package/dist/components/router/router.d.ts.map +1 -0
  26. package/dist/{router → components/router}/router.js +12 -8
  27. package/dist/components/router/router.js.map +1 -0
  28. package/dist/components/router/routerUtils.d.ts.map +1 -0
  29. package/dist/components/router/routerUtils.js.map +1 -0
  30. package/dist/components/transition.d.ts.map +1 -0
  31. package/dist/{transition.js → components/transition.js} +5 -5
  32. package/dist/components/transition.js.map +1 -0
  33. package/dist/constants.d.ts +3 -12
  34. package/dist/constants.d.ts.map +1 -1
  35. package/dist/constants.js +80 -12
  36. package/dist/constants.js.map +1 -1
  37. package/dist/context.js +1 -1
  38. package/dist/context.js.map +1 -1
  39. package/dist/dom.d.ts.map +1 -1
  40. package/dist/dom.js +9 -12
  41. package/dist/dom.js.map +1 -1
  42. package/dist/element.js +2 -2
  43. package/dist/element.js.map +1 -1
  44. package/dist/error.js +1 -1
  45. package/dist/error.js.map +1 -1
  46. package/dist/form/index.d.ts.map +1 -1
  47. package/dist/form/index.js +1 -2
  48. package/dist/form/index.js.map +1 -1
  49. package/dist/hmr.js +1 -1
  50. package/dist/hmr.js.map +1 -1
  51. package/dist/hooks/useAsync.d.ts.map +1 -1
  52. package/dist/hooks/useAsync.js +2 -2
  53. package/dist/hooks/useAsync.js.map +1 -1
  54. package/dist/hooks/useCallback.d.ts.map +1 -1
  55. package/dist/hooks/useCallback.js +2 -1
  56. package/dist/hooks/useCallback.js.map +1 -1
  57. package/dist/hooks/useEffect.d.ts.map +1 -1
  58. package/dist/hooks/useEffect.js +2 -1
  59. package/dist/hooks/useEffect.js.map +1 -1
  60. package/dist/hooks/useEffectEvent.d.ts.map +1 -1
  61. package/dist/hooks/useEffectEvent.js +2 -1
  62. package/dist/hooks/useEffectEvent.js.map +1 -1
  63. package/dist/hooks/useLayoutEffect.d.ts.map +1 -1
  64. package/dist/hooks/useLayoutEffect.js +2 -1
  65. package/dist/hooks/useLayoutEffect.js.map +1 -1
  66. package/dist/hooks/useMemo.d.ts.map +1 -1
  67. package/dist/hooks/useMemo.js +2 -1
  68. package/dist/hooks/useMemo.js.map +1 -1
  69. package/dist/hooks/useReducer.js +2 -2
  70. package/dist/hooks/useReducer.js.map +1 -1
  71. package/dist/hooks/useRef.d.ts.map +1 -1
  72. package/dist/hooks/useRef.js +2 -1
  73. package/dist/hooks/useRef.js.map +1 -1
  74. package/dist/hooks/useState.js +2 -2
  75. package/dist/hooks/useState.js.map +1 -1
  76. package/dist/hooks/useSyncExternalStore.js +2 -2
  77. package/dist/hooks/useSyncExternalStore.js.map +1 -1
  78. package/dist/hooks/useViewTransition.d.ts.map +1 -1
  79. package/dist/hooks/useViewTransition.js +1 -2
  80. package/dist/hooks/useViewTransition.js.map +1 -1
  81. package/dist/hooks/utils.d.ts +0 -1
  82. package/dist/hooks/utils.d.ts.map +1 -1
  83. package/dist/hooks/utils.js +2 -2
  84. package/dist/hooks/utils.js.map +1 -1
  85. package/dist/index.d.ts +2 -5
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -5
  88. package/dist/index.js.map +1 -1
  89. package/dist/reconciler.js +8 -7
  90. package/dist/reconciler.js.map +1 -1
  91. package/dist/renderToString.js +2 -4
  92. package/dist/renderToString.js.map +1 -1
  93. package/dist/scheduler.js +14 -2
  94. package/dist/scheduler.js.map +1 -1
  95. package/dist/signals/base.d.ts.map +1 -1
  96. package/dist/signals/base.js +1 -2
  97. package/dist/signals/base.js.map +1 -1
  98. package/dist/signals/computed.js +1 -1
  99. package/dist/signals/computed.js.map +1 -1
  100. package/dist/signals/effect.js +1 -1
  101. package/dist/signals/effect.js.map +1 -1
  102. package/dist/signals/watch.d.ts.map +1 -1
  103. package/dist/signals/watch.js +2 -3
  104. package/dist/signals/watch.js.map +1 -1
  105. package/dist/ssr/server.js +2 -4
  106. package/dist/ssr/server.js.map +1 -1
  107. package/dist/store.d.ts +1 -1
  108. package/dist/store.d.ts.map +1 -1
  109. package/dist/store.js +2 -2
  110. package/dist/store.js.map +1 -1
  111. package/dist/swr.js +1 -1
  112. package/dist/swr.js.map +1 -1
  113. package/dist/types.d.ts +4 -3
  114. package/dist/types.d.ts.map +1 -1
  115. package/dist/types.dom.d.ts +2 -2
  116. package/dist/types.dom.d.ts.map +1 -1
  117. package/dist/utils/compare.d.ts +3 -0
  118. package/dist/utils/compare.d.ts.map +1 -0
  119. package/dist/utils/compare.js +123 -0
  120. package/dist/utils/compare.js.map +1 -0
  121. package/dist/utils/format.d.ts +20 -0
  122. package/dist/utils/format.d.ts.map +1 -0
  123. package/dist/utils/format.js +136 -0
  124. package/dist/utils/format.js.map +1 -0
  125. package/dist/utils/generateId.d.ts.map +1 -0
  126. package/dist/utils/generateId.js.map +1 -0
  127. package/dist/utils/index.d.ts +7 -0
  128. package/dist/utils/index.d.ts.map +1 -0
  129. package/dist/utils/index.js +7 -0
  130. package/dist/utils/index.js.map +1 -0
  131. package/dist/utils/runtime.d.ts +11 -0
  132. package/dist/utils/runtime.d.ts.map +1 -0
  133. package/dist/utils/runtime.js +23 -0
  134. package/dist/utils/runtime.js.map +1 -0
  135. package/dist/utils/vdom.d.ts +25 -0
  136. package/dist/utils/vdom.d.ts.map +1 -0
  137. package/dist/utils/vdom.js +124 -0
  138. package/dist/utils/vdom.js.map +1 -0
  139. package/package.json +6 -6
  140. package/src/action.ts +42 -0
  141. package/src/components/index.ts +4 -0
  142. package/src/{lazy.ts → components/lazy.ts} +12 -12
  143. package/src/{memo.ts → components/memo.ts} +3 -3
  144. package/src/{portal.ts → components/portal.ts} +6 -6
  145. package/src/{router → components/router}/route.ts +1 -1
  146. package/src/{router → components/router}/router.ts +14 -9
  147. package/src/{transition.ts → components/transition.ts} +5 -5
  148. package/src/constants.ts +80 -13
  149. package/src/context.ts +1 -1
  150. package/src/customEvents.ts +22 -22
  151. package/src/dom.ts +8 -11
  152. package/src/element.ts +2 -2
  153. package/src/error.ts +1 -1
  154. package/src/form/index.ts +5 -2
  155. package/src/hmr.ts +1 -1
  156. package/src/hooks/useAsync.ts +5 -3
  157. package/src/hooks/useCallback.ts +2 -1
  158. package/src/hooks/useEffect.ts +2 -6
  159. package/src/hooks/useEffectEvent.ts +2 -1
  160. package/src/hooks/useLayoutEffect.ts +2 -6
  161. package/src/hooks/useMemo.ts +2 -1
  162. package/src/hooks/useReducer.ts +2 -2
  163. package/src/hooks/useRef.ts +2 -1
  164. package/src/hooks/useState.ts +2 -2
  165. package/src/hooks/useSyncExternalStore.ts +2 -2
  166. package/src/hooks/useViewTransition.ts +1 -2
  167. package/src/hooks/utils.ts +2 -2
  168. package/src/index.ts +2 -5
  169. package/src/reconciler.ts +13 -11
  170. package/src/renderToString.ts +3 -4
  171. package/src/scheduler.ts +16 -2
  172. package/src/signals/base.ts +6 -2
  173. package/src/signals/computed.ts +1 -1
  174. package/src/signals/effect.ts +1 -1
  175. package/src/signals/watch.ts +2 -3
  176. package/src/ssr/server.ts +3 -4
  177. package/src/store.ts +6 -2
  178. package/src/swr.ts +3 -3
  179. package/src/types.dom.ts +2 -1
  180. package/src/types.ts +9 -2
  181. package/src/utils/compare.ts +125 -0
  182. package/src/utils/format.ts +162 -0
  183. package/src/utils/index.ts +7 -0
  184. package/src/utils/runtime.ts +25 -0
  185. package/src/utils/vdom.ts +184 -0
  186. package/dist/cloneVNode.d.ts +0 -2
  187. package/dist/cloneVNode.d.ts.map +0 -1
  188. package/dist/cloneVNode.js +0 -14
  189. package/dist/cloneVNode.js.map +0 -1
  190. package/dist/generateId.d.ts.map +0 -1
  191. package/dist/generateId.js.map +0 -1
  192. package/dist/lazy.d.ts.map +0 -1
  193. package/dist/lazy.js.map +0 -1
  194. package/dist/memo.d.ts.map +0 -1
  195. package/dist/memo.js.map +0 -1
  196. package/dist/portal.d.ts.map +0 -1
  197. package/dist/portal.js.map +0 -1
  198. package/dist/props.d.ts +0 -4
  199. package/dist/props.d.ts.map +0 -1
  200. package/dist/props.js +0 -27
  201. package/dist/props.js.map +0 -1
  202. package/dist/router/index.d.ts.map +0 -1
  203. package/dist/router/index.js.map +0 -1
  204. package/dist/router/route.d.ts.map +0 -1
  205. package/dist/router/route.js.map +0 -1
  206. package/dist/router/router.d.ts.map +0 -1
  207. package/dist/router/router.js.map +0 -1
  208. package/dist/router/routerUtils.d.ts.map +0 -1
  209. package/dist/router/routerUtils.js.map +0 -1
  210. package/dist/transition.d.ts.map +0 -1
  211. package/dist/transition.js.map +0 -1
  212. package/dist/utils.d.ts +0 -52
  213. package/dist/utils.d.ts.map +0 -1
  214. package/dist/utils.js +0 -433
  215. package/dist/utils.js.map +0 -1
  216. package/dist/warning.d.ts +0 -2
  217. package/dist/warning.d.ts.map +0 -1
  218. package/dist/warning.js +0 -4
  219. package/dist/warning.js.map +0 -1
  220. package/src/cloneVNode.ts +0 -14
  221. package/src/props.ts +0 -34
  222. package/src/utils.ts +0 -518
  223. package/src/warning.ts +0 -9
  224. /package/dist/{lazy.d.ts → components/lazy.d.ts} +0 -0
  225. /package/dist/{portal.d.ts → components/portal.d.ts} +0 -0
  226. /package/dist/{router → components/router}/index.d.ts +0 -0
  227. /package/dist/{router → components/router}/index.js +0 -0
  228. /package/dist/{router → components/router}/route.d.ts +0 -0
  229. /package/dist/{router → components/router}/routerUtils.d.ts +0 -0
  230. /package/dist/{router → components/router}/routerUtils.js +0 -0
  231. /package/dist/{transition.d.ts → components/transition.d.ts} +0 -0
  232. /package/dist/{generateId.d.ts → utils/generateId.d.ts} +0 -0
  233. /package/dist/{generateId.js → utils/generateId.js} +0 -0
  234. /package/src/{router → components/router}/index.ts +0 -0
  235. /package/src/{router → components/router}/routerUtils.ts +0 -0
  236. /package/src/{generateId.ts → utils/generateId.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAE/B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ export { latest, sideEffectsEnabled };
2
+ /**
3
+ * This is a no-op in production. It is used to get the latest
4
+ * iteration of a component or signal after HMR has happened.
5
+ */
6
+ declare function latest<T>(thing: T): T;
7
+ /**
8
+ * Returns false if called during "stream" or "string" render modes.
9
+ */
10
+ declare function sideEffectsEnabled(): boolean;
11
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAA;AAErC;;;GAGG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAQ9B;AAED;;GAEG;AACH,iBAAS,kBAAkB,IAAI,OAAO,CAErC"}
@@ -0,0 +1,23 @@
1
+ import { __DEV__ } from "../env.js";
2
+ import { renderMode } from "../globals.js";
3
+ export { latest, sideEffectsEnabled };
4
+ /**
5
+ * This is a no-op in production. It is used to get the latest
6
+ * iteration of a component or signal after HMR has happened.
7
+ */
8
+ function latest(thing) {
9
+ let tgt = thing;
10
+ if (__DEV__) {
11
+ while ("__next" in tgt) {
12
+ tgt = tgt.__next;
13
+ }
14
+ }
15
+ return tgt;
16
+ }
17
+ /**
18
+ * Returns false if called during "stream" or "string" render modes.
19
+ */
20
+ function sideEffectsEnabled() {
21
+ return renderMode.current === "dom" || renderMode.current === "hydrate";
22
+ }
23
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAA;AAErC;;;GAGG;AACH,SAAS,MAAM,CAAI,KAAQ;IACzB,IAAI,GAAG,GAAQ,KAAK,CAAA;IACpB,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,QAAQ,IAAI,GAAG,EAAE,CAAC;YACvB,GAAG,GAAG,GAAG,CAAC,MAAoB,CAAA;QAChC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,OAAO,UAAU,CAAC,OAAO,KAAK,KAAK,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,CAAA;AACzE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { $FRAGMENT, $CONTEXT_PROVIDER } from "../constants.js";
2
+ import type { AppContext } from "../appContext.js";
3
+ export { cloneVNode, isVNodeDeleted, isVNode, isExoticType, isFragment, isLazy, isMemo, isContextProvider, vNodeContains, getCurrentVNode, getVNodeAppContext, commitSnapshot, traverseApply, findParent, assertValidElementProps, isValidElementKeyProp, isValidElementRefProp, };
4
+ declare function cloneVNode(vNode: Kiru.VNode): Kiru.VNode;
5
+ declare function isVNodeDeleted(vNode: Kiru.VNode): boolean;
6
+ declare function isVNode(thing: unknown): thing is Kiru.VNode;
7
+ declare function isExoticType(type: Kiru.VNode["type"]): type is Kiru.ExoticSymbol;
8
+ declare function isFragment(vNode: Kiru.VNode): vNode is Kiru.VNode & {
9
+ type: typeof $FRAGMENT;
10
+ };
11
+ declare function isLazy(vNode: Kiru.VNode): boolean;
12
+ declare function isMemo(vNode: Kiru.VNode): boolean;
13
+ declare function isContextProvider(thing: unknown): thing is Kiru.VNode & {
14
+ type: typeof $CONTEXT_PROVIDER;
15
+ };
16
+ declare function getCurrentVNode(): Kiru.VNode | null;
17
+ declare function getVNodeAppContext(vNode: Kiru.VNode): AppContext | null;
18
+ declare function commitSnapshot(vNode: Kiru.VNode): void;
19
+ declare function vNodeContains(haystack: Kiru.VNode, needle: Kiru.VNode): boolean;
20
+ declare function traverseApply(vNode: Kiru.VNode, func: (node: Kiru.VNode) => void): void;
21
+ declare function findParent(vNode: Kiru.VNode, predicate: (n: Kiru.VNode) => boolean): Kiru.VNode | null;
22
+ declare function assertValidElementProps(vNode: Kiru.VNode): void;
23
+ declare function isValidElementKeyProp(thing: unknown): thing is string | number;
24
+ declare function isValidElementRefProp(thing: unknown): thing is Kiru.Ref<any>;
25
+ //# sourceMappingURL=vdom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdom.d.ts","sourceRoot":"","sources":["../../src/utils/vdom.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EACT,iBAAiB,EAIlB,M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CAUhE;AAED,iBAAS,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAQ/C;AAED,iBAAS,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAaxE;AAED,iBAAS,aAAa,CACpB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,GAC/B,IAAI,CAUN;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,KAAK,OAAO,qBAO3E;AAED,iBAAS,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,QAgBjD;AAED,iBAAS,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAEvE;AAED,iBAAS,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAMrE"}
@@ -0,0 +1,124 @@
1
+ import { Signal } from "../signals/index.js";
2
+ import { FLAG_DELETION, $FRAGMENT, $CONTEXT_PROVIDER, $HYDRATION_BOUNDARY, FLAG_PLACEMENT, FLAG_UPDATE, } from "../constants.js";
3
+ import { createElement } from "../index.js";
4
+ import { KiruError } from "../error.js";
5
+ import { node } from "../globals.js";
6
+ export { cloneVNode, isVNodeDeleted, isVNode, isExoticType, isFragment, isLazy, isMemo, isContextProvider, vNodeContains, getCurrentVNode, getVNodeAppContext, commitSnapshot, traverseApply, findParent, assertValidElementProps, isValidElementKeyProp, isValidElementRefProp, };
7
+ function cloneVNode(vNode) {
8
+ const children = vNode.props.children;
9
+ let clonedChildren;
10
+ if (isVNode(children)) {
11
+ clonedChildren = cloneVNode(children);
12
+ }
13
+ else if (Array.isArray(children)) {
14
+ clonedChildren = children.map((c) => (isVNode(c) ? cloneVNode(c) : c));
15
+ }
16
+ return createElement(vNode.type, { ...vNode.props, children: clonedChildren });
17
+ }
18
+ function isVNodeDeleted(vNode) {
19
+ return (vNode.flags & FLAG_DELETION) !== 0;
20
+ }
21
+ function isVNode(thing) {
22
+ return typeof thing === "object" && thing !== null && "type" in thing;
23
+ }
24
+ function isExoticType(type) {
25
+ return (type === $FRAGMENT ||
26
+ type === $CONTEXT_PROVIDER ||
27
+ type === $HYDRATION_BOUNDARY);
28
+ }
29
+ function isFragment(vNode) {
30
+ return vNode.type === $FRAGMENT;
31
+ }
32
+ function isLazy(vNode) {
33
+ return (typeof vNode.type === "function" &&
34
+ "displayName" in vNode.type &&
35
+ vNode.type.displayName === "Kiru.lazy");
36
+ }
37
+ function isMemo(vNode) {
38
+ return (typeof vNode.type === "function" &&
39
+ "displayName" in vNode.type &&
40
+ vNode.type.displayName === "Kiru.memo");
41
+ }
42
+ function isContextProvider(thing) {
43
+ return isVNode(thing) && thing.type === $CONTEXT_PROVIDER;
44
+ }
45
+ function getCurrentVNode() {
46
+ return node.current;
47
+ }
48
+ function getVNodeAppContext(vNode) {
49
+ let n = vNode;
50
+ while (n) {
51
+ if (n.app) {
52
+ return (vNode.app = n.app);
53
+ }
54
+ n = n.parent;
55
+ }
56
+ return null;
57
+ }
58
+ function commitSnapshot(vNode) {
59
+ const { props: { children, ...props }, memoizedProps, index, } = vNode;
60
+ vNode.prev = { props, memoizedProps, index };
61
+ vNode.flags &= ~(FLAG_UPDATE | FLAG_PLACEMENT | FLAG_DELETION);
62
+ }
63
+ function vNodeContains(haystack, needle) {
64
+ if (needle.depth < haystack.depth)
65
+ return false;
66
+ if (haystack === needle)
67
+ return true;
68
+ let checkSiblings = false;
69
+ const stack = [haystack];
70
+ while (stack.length) {
71
+ const n = stack.pop();
72
+ if (n === needle)
73
+ return true;
74
+ n.child && stack.push(n.child);
75
+ checkSiblings && n.sibling && stack.push(n.sibling);
76
+ checkSiblings = true;
77
+ }
78
+ return false;
79
+ }
80
+ function traverseApply(vNode, func) {
81
+ func(vNode);
82
+ let child = vNode.child;
83
+ while (child) {
84
+ func(child);
85
+ if (child.child) {
86
+ traverseApply(child, func);
87
+ }
88
+ child = child.sibling;
89
+ }
90
+ }
91
+ function findParent(vNode, predicate) {
92
+ let n = vNode.parent;
93
+ while (n) {
94
+ if (predicate(n))
95
+ return n;
96
+ n = n.parent;
97
+ }
98
+ return null;
99
+ }
100
+ function assertValidElementProps(vNode) {
101
+ if ("children" in vNode.props && vNode.props.innerHTML) {
102
+ throw new KiruError({
103
+ message: "Cannot use both children and innerHTML on an element",
104
+ vNode,
105
+ });
106
+ }
107
+ for (const key in vNode.props) {
108
+ if ("bind:" + key in vNode.props) {
109
+ throw new KiruError({
110
+ message: `Cannot use both bind:${key} and ${key} on an element`,
111
+ vNode,
112
+ });
113
+ }
114
+ }
115
+ }
116
+ function isValidElementKeyProp(thing) {
117
+ return typeof thing === "string" || typeof thing === "number";
118
+ }
119
+ function isValidElementRefProp(thing) {
120
+ return (typeof thing === "function" ||
121
+ (typeof thing === "object" && !!thing && "current" in thing) ||
122
+ Signal.isSignal(thing));
123
+ }
124
+ //# sourceMappingURL=vdom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdom.js","sourceRoot":"","sources":["../../src/utils/vdom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EACL,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAGpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,YAAY,EACZ,UAAU,EACV,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C,GAAG,CAAC,CAAC,MAAM,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAiB;IAChD,IAAI,UAAU,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACvD,MAAM,IAAI,SAAS,CAAC;YAClB,OAAO,EAAE,sDAAsD;YAC/D,KAAK;SACN,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC;gBAClB,OAAO,EAAE,wBAAwB,GAAG,QAAQ,GAAG,gBAAgB;gBAC/D,KAAK;aACN,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AAC/D,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,UAAU;QAC3B,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,SAAS,IAAI,KAAK,CAAC;QAC5D,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CACvB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiru",
3
- "version": "0.48.3",
3
+ "version": "0.49.1",
4
4
  "description": "A batteries-included, easy-to-use rendering library with a tiny footprint",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -15,16 +15,16 @@
15
15
  "default": "./dist/form/index.js"
16
16
  },
17
17
  "./router": {
18
- "types": "./dist/router/index.d.ts",
19
- "default": "./dist/router/index.js"
18
+ "types": "./dist/components/router/index.d.ts",
19
+ "default": "./dist/components/router/index.js"
20
20
  },
21
21
  "./swr": {
22
22
  "types": "./dist/swr.d.ts",
23
23
  "default": "./dist/swr.js"
24
24
  },
25
25
  "./utils": {
26
- "types": "./dist/utils.d.ts",
27
- "default": "./dist/utils.js"
26
+ "types": "./dist/utils/index.d.ts",
27
+ "default": "./dist/utils/index.js"
28
28
  },
29
29
  "./ssr": {
30
30
  "types": "./dist/ssr/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "scripts": {
77
77
  "build": "rm -rf dist && pnpm i && tsc",
78
- "test": "node --test",
78
+ "test": "node --test dist/**/*.test.js",
79
79
  "dev": "tsc --watch"
80
80
  }
81
81
  }
package/src/action.ts ADDED
@@ -0,0 +1,42 @@
1
+ export type ActionResult<T> =
2
+ | {
3
+ error: ActionError
4
+ data: null
5
+ }
6
+ | {
7
+ error: null
8
+ data: T
9
+ }
10
+
11
+ export interface ActionConfig<T> {
12
+ /**
13
+ * Executes the action and returns the result.
14
+ */
15
+ execute: () => Promise<T>
16
+ /**
17
+ * Called when the action fails.
18
+ */
19
+ onError?: (error: ActionError) => void
20
+ }
21
+
22
+ export class ActionError extends Error {
23
+ constructor(cause: unknown) {
24
+ super("Error occurred during action execution", { cause })
25
+ }
26
+ }
27
+
28
+ export function defineAction<T extends readonly unknown[], R>(
29
+ callback: (...args: T) => ActionConfig<R>
30
+ ): (...args: T) => Promise<ActionResult<R>> {
31
+ return async (...args: T) => {
32
+ const { execute, onError } = callback(...args)
33
+ try {
34
+ const data = await execute()
35
+ return { error: null, data }
36
+ } catch (e) {
37
+ const error = new ActionError(e)
38
+ onError?.(error)
39
+ return { error, data: null }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./lazy.js"
2
+ export { memo } from "./memo.js"
3
+ export * from "./portal.js"
4
+ export * from "./transition.js"
@@ -1,18 +1,18 @@
1
- import { createElement } from "./element.js"
2
- import { __DEV__ } from "./env.js"
3
- import { KiruError } from "./error.js"
4
- import { node, renderMode } from "./globals.js"
5
- import { useContext } from "./hooks/useContext.js"
6
- import { useRef } from "./hooks/useRef.js"
7
- import { useRequestUpdate } from "./hooks/utils.js"
8
- import { hydrationStack } from "./hydration.js"
9
- import { flushSync, nextIdle } from "./scheduler.js"
1
+ import { createElement } from "../element.js"
2
+ import { __DEV__ } from "../env.js"
3
+ import { KiruError } from "../error.js"
4
+ import { node, renderMode } from "../globals.js"
5
+ import { useContext } from "../hooks/useContext.js"
6
+ import { useRef } from "../hooks/useRef.js"
7
+ import { useRequestUpdate } from "../hooks/utils.js"
8
+ import { hydrationStack } from "../hydration.js"
9
+ import { flushSync, nextIdle } from "../scheduler.js"
10
10
  import {
11
11
  HYDRATION_BOUNDARY_MARKER,
12
12
  HydrationBoundaryContext,
13
- } from "./ssr/hydrationBoundary.js"
14
- import type { SomeDom } from "./types.utils"
15
- import { noop } from "./utils.js"
13
+ } from "../ssr/hydrationBoundary.js"
14
+ import { noop } from "../utils/index.js"
15
+ import type { SomeDom } from "../types.utils"
16
16
 
17
17
  interface FCModule {
18
18
  default: Kiru.FC<any>
@@ -1,6 +1,6 @@
1
- import { $MEMO } from "./constants.js"
2
- import { createElement } from "./element.js"
3
- import { __DEV__ } from "./env.js"
1
+ import { $MEMO } from "../constants.js"
2
+ import { createElement } from "../element.js"
3
+ import { __DEV__ } from "../env.js"
4
4
 
5
5
  function _arePropsEqual<T extends Record<string, unknown>>(
6
6
  prevProps: T,
@@ -1,9 +1,9 @@
1
- import { FLAG_STATIC_DOM } from "./constants.js"
2
- import { __DEV__ } from "./env.js"
3
- import { KiruError } from "./error.js"
4
- import { renderMode } from "./globals.js"
5
- import { useVNode } from "./hooks/utils.js"
6
- import { nextIdle, requestUpdate } from "./scheduler.js"
1
+ import { FLAG_STATIC_DOM } from "../constants.js"
2
+ import { __DEV__ } from "../env.js"
3
+ import { KiruError } from "../error.js"
4
+ import { renderMode } from "../globals.js"
5
+ import { useVNode } from "../hooks/utils.js"
6
+ import { nextIdle, requestUpdate } from "../scheduler.js"
7
7
 
8
8
  interface PortalProps {
9
9
  children?: JSX.Children
@@ -1,4 +1,4 @@
1
- import { isVNode } from "../utils.js"
1
+ import { isVNode } from "../../utils/index.js"
2
2
 
3
3
  interface RouteProps {
4
4
  /**
@@ -1,23 +1,23 @@
1
- import { createElement } from "../element.js"
1
+ import { createElement } from "../../element.js"
2
2
  import {
3
3
  useState,
4
4
  useMemo,
5
5
  useContext,
6
6
  useLayoutEffect,
7
7
  useRef,
8
- } from "../hooks/index.js"
9
- import { __DEV__ } from "../env.js"
8
+ } from "../../hooks/index.js"
9
+ import { __DEV__ } from "../../env.js"
10
+ import { createContext } from "../../context.js"
11
+ import { isRoute, Route } from "./route.js"
12
+ import { noop } from "../../utils/index.js"
13
+ import { node } from "../../globals.js"
14
+ import type { ElementProps } from "../../types.js"
15
+ import { flushSync, nextIdle } from "../../scheduler.js"
10
16
  import {
11
17
  parsePathParams,
12
18
  parseSearchParams,
13
19
  routeMatchesPath,
14
20
  } from "./routerUtils.js"
15
- import { createContext } from "../context.js"
16
- import { isRoute, Route } from "./route.js"
17
- import { noop } from "../utils.js"
18
- import { node } from "../globals.js"
19
- import type { ElementProps } from "../types"
20
- import { flushSync, nextIdle } from "../scheduler.js"
21
21
 
22
22
  export interface LinkProps extends Omit<ElementProps<"a">, "href"> {
23
23
  /**
@@ -67,6 +67,7 @@ export function Link({ to, onclick, replace, inherit, ...props }: LinkProps) {
67
67
  }
68
68
 
69
69
  type RouterCtx = {
70
+ transitionsEnabled: boolean
70
71
  viewTransition: Kiru.RefObject<ViewTransition>
71
72
  queueSyncNav: (callback: () => void) => void
72
73
  params: Record<string, string>
@@ -76,6 +77,7 @@ type RouterCtx = {
76
77
  isDefault: boolean
77
78
  }
78
79
  const RouterContext = createContext<RouterCtx>({
80
+ transitionsEnabled: false,
79
81
  viewTransition: { current: null },
80
82
  queueSyncNav: noop,
81
83
  params: {},
@@ -173,6 +175,8 @@ export function Router(props: RouterProps) {
173
175
  )
174
176
 
175
177
  useLayoutEffect(() => {
178
+ if (!parentRouterContext.isDefault) return
179
+
176
180
  const handler = () => {
177
181
  if (!document.startViewTransition || !props.transition) {
178
182
  return setLoc({
@@ -267,6 +271,7 @@ export function Router(props: RouterProps) {
267
271
  syncNavCallback.current = callback
268
272
  },
269
273
  viewTransition: viewTransition,
274
+ transitionsEnabled: !!props.transition,
270
275
  },
271
276
  children: route ?? fallbackRoute ?? null,
272
277
  })
@@ -1,8 +1,8 @@
1
- import { useCallback } from "./hooks/useCallback.js"
2
- import { useEffect } from "./hooks/useEffect.js"
3
- import { useLayoutEffect } from "./hooks/useLayoutEffect.js"
4
- import { useRef } from "./hooks/useRef.js"
5
- import { useState } from "./hooks/useState.js"
1
+ import { useCallback } from "../hooks/useCallback.js"
2
+ import { useEffect } from "../hooks/useEffect.js"
3
+ import { useLayoutEffect } from "../hooks/useLayoutEffect.js"
4
+ import { useRef } from "../hooks/useRef.js"
5
+ import { useState } from "../hooks/useState.js"
6
6
 
7
7
  export type TransitionState = "entering" | "entered" | "exiting" | "exited"
8
8
  interface TransitionProps {
package/src/constants.ts CHANGED
@@ -8,7 +8,6 @@ export {
8
8
  $MEMO,
9
9
  $HYDRATION_BOUNDARY,
10
10
  CONSECUTIVE_DIRTY_LIMIT,
11
- REGEX_UNIT,
12
11
  EVENT_PREFIX_REGEX,
13
12
  FLAG_UPDATE,
14
13
  FLAG_PLACEMENT,
@@ -19,7 +18,7 @@ export {
19
18
  FLAG_DIRTY,
20
19
  }
21
20
 
22
- export { voidElements, svgTags, booleanAttributes }
21
+ export { voidElements, svgTags, booleanAttributes, snakeCaseAttributes }
23
22
 
24
23
  const $SIGNAL = Symbol.for("kiru.signal")
25
24
  const $CONTEXT = Symbol.for("kiru.context")
@@ -40,17 +39,6 @@ const FLAG_MEMO = 1 << 5
40
39
  const FLAG_NOOP = 1 << 6
41
40
  const FLAG_DIRTY = 1 << 7
42
41
 
43
- const REGEX_UNIT = {
44
- AMP_G: /&/g,
45
- LT_G: /</g,
46
- GT_G: />/g,
47
- SQT_G: /'/g,
48
- DBLQT_G: /"/g,
49
- SLASH_G: /\//g,
50
- SLASHN_SLASHR_G: /[\n\r]+/g,
51
- ALPHA_UPPER_G: /[A-Z]/g,
52
- } as const
53
-
54
42
  const EVENT_PREFIX_REGEX = /^on:?/
55
43
 
56
44
  const voidElements = new Set([
@@ -155,3 +143,82 @@ const booleanAttributes = new Set([
155
143
  "translate",
156
144
  "wrap",
157
145
  ])
146
+
147
+ const snakeCaseAttributes = new Map([
148
+ ["acceptCharset", "accept-charset"],
149
+ ["accentHeight", "accent-height"],
150
+ ["alignmentBaseline", "alignment-baseline"],
151
+ ["arabicForm", "arabic-form"],
152
+ ["baselineShift", "baseline-shift"],
153
+ ["capHeight", "cap-height"],
154
+ ["clipPath", "clip-path"],
155
+ ["clipRule", "clip-rule"],
156
+ ["colorInterpolation", "color-interpolation"],
157
+ ["colorInterpolationFilters", "color-interpolation-filters"],
158
+ ["colorProfile", "color-profile"],
159
+ ["colorRendering", "color-rendering"],
160
+ ["dominantBaseline", "dominant-baseline"],
161
+ ["enableBackground", "enable-background"],
162
+ ["fillOpacity", "fill-opacity"],
163
+ ["fillRule", "fill-rule"],
164
+ ["floodColor", "flood-color"],
165
+ ["floodOpacity", "flood-opacity"],
166
+ ["fontFamily", "font-family"],
167
+ ["fontSize", "font-size"],
168
+ ["fontSizeAdjust", "font-size-adjust"],
169
+ ["fontStretch", "font-stretch"],
170
+ ["fontStyle", "font-style"],
171
+ ["fontVariant", "font-variant"],
172
+ ["fontWeight", "font-weight"],
173
+ ["glyphName", "glyph-name"],
174
+ ["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
175
+ ["glyphOrientationVertical", "glyph-orientation-vertical"],
176
+ ["horizAdvX", "horiz-adv-x"],
177
+ ["horizOriginX", "horiz-origin-x"],
178
+ ["httpEquiv", "http-equiv"],
179
+ ["imageRendering", "image-rendering"],
180
+ ["letterSpacing", "letter-spacing"],
181
+ ["lightingColor", "lighting-color"],
182
+ ["markerEnd", "marker-end"],
183
+ ["markerMid", "marker-mid"],
184
+ ["markerStart", "marker-start"],
185
+ ["overlinePosition", "overline-position"],
186
+ ["overlineThickness", "overline-thickness"],
187
+ ["paintOrder", "paint-order"],
188
+ ["panose-1", "panose-1"],
189
+ ["pointerEvents", "pointer-events"],
190
+ ["renderingIntent", "rendering-intent"],
191
+ ["shapeRendering", "shape-rendering"],
192
+ ["stopColor", "stop-color"],
193
+ ["stopOpacity", "stop-opacity"],
194
+ ["strikethroughPosition", "strikethrough-position"],
195
+ ["strikethroughThickness", "strikethrough-thickness"],
196
+ ["strokeDasharray", "stroke-dasharray"],
197
+ ["strokeDashoffset", "stroke-dashoffset"],
198
+ ["strokeLinecap", "stroke-linecap"],
199
+ ["strokeLinejoin", "stroke-linejoin"],
200
+ ["strokeMiterlimit", "stroke-miterlimit"],
201
+ ["strokeOpacity", "stroke-opacity"],
202
+ ["strokeWidth", "stroke-width"],
203
+ ["textAnchor", "text-anchor"],
204
+ ["textDecoration", "text-decoration"],
205
+ ["textRendering", "text-rendering"],
206
+ ["transformOrigin", "transform-origin"],
207
+ ["underlinePosition", "underline-position"],
208
+ ["underlineThickness", "underline-thickness"],
209
+ ["unicodeBidi", "unicode-bidi"],
210
+ ["unicodeRange", "unicode-range"],
211
+ ["unitsPerEm", "units-per-em"],
212
+ ["vAlphabetic", "v-alphabetic"],
213
+ ["vHanging", "v-hanging"],
214
+ ["vIdeographic", "v-ideographic"],
215
+ ["vMathematical", "v-mathematical"],
216
+ ["vectorEffect", "vector-effect"],
217
+ ["vertAdvY", "vert-adv-y"],
218
+ ["vertOriginX", "vert-origin-x"],
219
+ ["vertOriginY", "vert-origin-y"],
220
+ ["wordSpacing", "word-spacing"],
221
+ ["writingMode", "writing-mode"],
222
+ ["xmlnsXlink", "xmlns:xlink"],
223
+ ["xHeight", "x-height"],
224
+ ])
package/src/context.ts CHANGED
@@ -4,7 +4,7 @@ import { __DEV__ } from "./env.js"
4
4
  import { GenericHMRAcceptor } from "./hmr.js"
5
5
  import { useState } from "./hooks/useState.js"
6
6
  import { requestUpdate } from "./scheduler.js"
7
- import { traverseApply } from "./utils.js"
7
+ import { traverseApply } from "./utils/index.js"
8
8
 
9
9
  export function createContext<T>(defaultValue: T): Kiru.Context<T> {
10
10
  const ctx: Kiru.Context<T> = {
@@ -1,22 +1,22 @@
1
- export class CustomEvents {
2
- private constructor() {}
3
-
4
- static on<K extends keyof Kiru.CustomEvents & string>(
5
- type: K,
6
- callback: (event: CustomEvent<Kiru.CustomEvents[K]>) => void
7
- ) {
8
- window.addEventListener(type, callback as unknown as EventListener)
9
- return () =>
10
- window.removeEventListener(type, callback as unknown as EventListener)
11
- }
12
-
13
- static dispatch<K extends keyof Kiru.CustomEvents & string>(
14
- type: K,
15
- detail: Kiru.CustomEvents[K],
16
- target?: Element
17
- ) {
18
- ;(target || document).dispatchEvent(
19
- new CustomEvent(type, { detail, bubbles: true })
20
- )
21
- }
22
- }
1
+ export class CustomEvents {
2
+ private constructor() {}
3
+
4
+ static on<K extends keyof Kiru.CustomEvents & string>(
5
+ type: K,
6
+ callback: (event: CustomEvent<Kiru.CustomEvents[K]>) => void
7
+ ) {
8
+ window.addEventListener(type, callback as unknown as EventListener)
9
+ return () =>
10
+ window.removeEventListener(type, callback as unknown as EventListener)
11
+ }
12
+
13
+ static dispatch<K extends keyof Kiru.CustomEvents & string>(
14
+ type: K,
15
+ detail: Kiru.CustomEvents[K],
16
+ target?: Element
17
+ ) {
18
+ ;(target || document).dispatchEvent(
19
+ new CustomEvent(type, { detail, bubbles: true })
20
+ )
21
+ }
22
+ }