kiru 0.44.4 → 0.45.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 (318) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -3
  3. package/dist/appContext.d.ts +38 -0
  4. package/dist/appContext.d.ts.map +1 -0
  5. package/dist/appContext.js +143 -0
  6. package/dist/appContext.js.map +1 -0
  7. package/dist/cloneVNode.d.ts +2 -0
  8. package/dist/cloneVNode.d.ts.map +1 -0
  9. package/dist/cloneVNode.js +14 -0
  10. package/dist/cloneVNode.js.map +1 -0
  11. package/dist/constants.d.ts +31 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +127 -0
  14. package/dist/constants.js.map +1 -0
  15. package/dist/context.d.ts +3 -0
  16. package/dist/context.d.ts.map +1 -0
  17. package/dist/context.js +50 -0
  18. package/dist/context.js.map +1 -0
  19. package/dist/dom.d.ts +8 -0
  20. package/dist/dom.d.ts.map +1 -0
  21. package/dist/dom.js +582 -0
  22. package/dist/dom.js.map +1 -0
  23. package/dist/element.d.ts +6 -0
  24. package/dist/element.d.ts.map +1 -0
  25. package/dist/element.js +41 -0
  26. package/dist/element.js.map +1 -0
  27. package/dist/env.d.ts +2 -0
  28. package/dist/env.d.ts.map +1 -0
  29. package/dist/env.js +6 -0
  30. package/dist/env.js.map +1 -0
  31. package/dist/error.d.ts +19 -0
  32. package/dist/error.d.ts.map +1 -0
  33. package/dist/error.js +63 -0
  34. package/dist/error.js.map +1 -0
  35. package/dist/flags.d.ts +6 -0
  36. package/dist/flags.d.ts.map +1 -0
  37. package/dist/flags.js +16 -0
  38. package/dist/flags.js.map +1 -0
  39. package/dist/form/index.d.ts +4 -0
  40. package/dist/form/index.d.ts.map +1 -0
  41. package/dist/form/index.js +509 -0
  42. package/dist/form/index.js.map +1 -0
  43. package/dist/form/types.d.ts +121 -0
  44. package/dist/form/types.d.ts.map +1 -0
  45. package/dist/form/types.js +2 -0
  46. package/dist/form/types.js.map +1 -0
  47. package/dist/form/utils.d.ts +3 -0
  48. package/dist/form/utils.d.ts.map +1 -0
  49. package/dist/form/utils.js +16 -0
  50. package/dist/form/utils.js.map +1 -0
  51. package/dist/generateId.d.ts +8 -0
  52. package/dist/generateId.d.ts.map +1 -0
  53. package/dist/generateId.js +15 -0
  54. package/dist/generateId.js.map +1 -0
  55. package/dist/globalContext.d.ts +37 -0
  56. package/dist/globalContext.d.ts.map +1 -0
  57. package/dist/globalContext.js +85 -0
  58. package/dist/globalContext.js.map +1 -0
  59. package/dist/globals.d.ts +16 -0
  60. package/dist/globals.d.ts.map +1 -0
  61. package/dist/globals.js +15 -0
  62. package/dist/globals.js.map +1 -0
  63. package/dist/hmr.d.ts +32 -0
  64. package/dist/hmr.d.ts.map +1 -0
  65. package/dist/hmr.js +125 -0
  66. package/dist/hmr.js.map +1 -0
  67. package/dist/hooks/index.d.ts +15 -0
  68. package/dist/hooks/index.d.ts.map +1 -0
  69. package/dist/hooks/index.js +15 -0
  70. package/dist/hooks/index.js.map +1 -0
  71. package/dist/hooks/useAsync.d.ts +29 -0
  72. package/dist/hooks/useAsync.d.ts.map +1 -0
  73. package/dist/hooks/useAsync.js +96 -0
  74. package/dist/hooks/useAsync.js.map +1 -0
  75. package/dist/hooks/useCallback.d.ts +7 -0
  76. package/dist/hooks/useCallback.d.ts.map +1 -0
  77. package/dist/hooks/useCallback.js +29 -0
  78. package/dist/hooks/useCallback.js.map +1 -0
  79. package/dist/hooks/useContext.d.ts +7 -0
  80. package/dist/hooks/useContext.d.ts.map +1 -0
  81. package/dist/hooks/useContext.js +59 -0
  82. package/dist/hooks/useContext.js.map +1 -0
  83. package/dist/hooks/useEffect.d.ts +8 -0
  84. package/dist/hooks/useEffect.d.ts.map +1 -0
  85. package/dist/hooks/useEffect.js +33 -0
  86. package/dist/hooks/useEffect.js.map +1 -0
  87. package/dist/hooks/useEffectEvent.d.ts +8 -0
  88. package/dist/hooks/useEffectEvent.d.ts.map +1 -0
  89. package/dist/hooks/useEffectEvent.js +22 -0
  90. package/dist/hooks/useEffectEvent.js.map +1 -0
  91. package/dist/hooks/useId.d.ts +8 -0
  92. package/dist/hooks/useId.d.ts.map +1 -0
  93. package/dist/hooks/useId.js +35 -0
  94. package/dist/hooks/useId.js.map +1 -0
  95. package/dist/hooks/useLayoutEffect.d.ts +8 -0
  96. package/dist/hooks/useLayoutEffect.d.ts.map +1 -0
  97. package/dist/hooks/useLayoutEffect.js +33 -0
  98. package/dist/hooks/useLayoutEffect.js.map +1 -0
  99. package/dist/hooks/useMemo.d.ts +8 -0
  100. package/dist/hooks/useMemo.d.ts.map +1 -0
  101. package/dist/hooks/useMemo.js +30 -0
  102. package/dist/hooks/useMemo.js.map +1 -0
  103. package/dist/hooks/useReducer.d.ts +7 -0
  104. package/dist/hooks/useReducer.d.ts.map +1 -0
  105. package/dist/hooks/useReducer.js +44 -0
  106. package/dist/hooks/useReducer.js.map +1 -0
  107. package/dist/hooks/useRef.d.ts +10 -0
  108. package/dist/hooks/useRef.d.ts.map +1 -0
  109. package/dist/hooks/useRef.js +28 -0
  110. package/dist/hooks/useRef.js.map +1 -0
  111. package/dist/hooks/useState.d.ts +7 -0
  112. package/dist/hooks/useState.d.ts.map +1 -0
  113. package/dist/hooks/useState.js +54 -0
  114. package/dist/hooks/useState.js.map +1 -0
  115. package/dist/hooks/useSyncExternalStore.d.ts +8 -0
  116. package/dist/hooks/useSyncExternalStore.d.ts.map +1 -0
  117. package/dist/hooks/useSyncExternalStore.js +50 -0
  118. package/dist/hooks/useSyncExternalStore.js.map +1 -0
  119. package/dist/hooks/useViewTransition.d.ts +10 -0
  120. package/dist/hooks/useViewTransition.d.ts.map +1 -0
  121. package/dist/hooks/useViewTransition.js +28 -0
  122. package/dist/hooks/useViewTransition.js.map +1 -0
  123. package/dist/hooks/utils.d.ts +69 -0
  124. package/dist/hooks/utils.d.ts.map +1 -0
  125. package/dist/hooks/utils.js +163 -0
  126. package/dist/hooks/utils.js.map +1 -0
  127. package/dist/hydration.d.ts +17 -0
  128. package/dist/hydration.d.ts.map +1 -0
  129. package/dist/hydration.js +59 -0
  130. package/dist/hydration.js.map +1 -0
  131. package/dist/index.d.ts +17 -0
  132. package/dist/index.d.ts.map +1 -0
  133. package/dist/index.js +40 -0
  134. package/dist/index.js.map +1 -0
  135. package/dist/jsx.d.ts +6 -0
  136. package/dist/jsx.d.ts.map +1 -0
  137. package/dist/jsx.js +8 -0
  138. package/dist/jsx.js.map +1 -0
  139. package/dist/lazy.d.ts +11 -0
  140. package/dist/lazy.d.ts.map +1 -0
  141. package/dist/lazy.js +177 -0
  142. package/dist/lazy.js.map +1 -0
  143. package/dist/memo.d.ts +9 -0
  144. package/dist/memo.d.ts.map +1 -0
  145. package/dist/memo.js +25 -0
  146. package/dist/memo.js.map +1 -0
  147. package/dist/portal.d.ts +10 -0
  148. package/dist/portal.d.ts.map +1 -0
  149. package/dist/portal.js +34 -0
  150. package/dist/portal.js.map +1 -0
  151. package/dist/profiling.d.ts +26 -0
  152. package/dist/profiling.d.ts.map +1 -0
  153. package/dist/profiling.js +83 -0
  154. package/dist/profiling.js.map +1 -0
  155. package/dist/props.d.ts +4 -0
  156. package/dist/props.d.ts.map +1 -0
  157. package/dist/props.js +27 -0
  158. package/dist/props.js.map +1 -0
  159. package/dist/reconciler.d.ts +4 -0
  160. package/dist/reconciler.d.ts.map +1 -0
  161. package/dist/reconciler.js +466 -0
  162. package/dist/reconciler.js.map +1 -0
  163. package/dist/renderToString.d.ts +2 -0
  164. package/dist/renderToString.d.ts.map +1 -0
  165. package/dist/renderToString.js +74 -0
  166. package/dist/renderToString.js.map +1 -0
  167. package/dist/router/index.d.ts +3 -0
  168. package/dist/router/index.d.ts.map +1 -0
  169. package/dist/router/index.js +3 -0
  170. package/dist/router/index.js.map +1 -0
  171. package/dist/router/route.d.ts +46 -0
  172. package/dist/router/route.d.ts.map +1 -0
  173. package/dist/router/route.js +8 -0
  174. package/dist/router/route.js.map +1 -0
  175. package/dist/router/router.d.ts +62 -0
  176. package/dist/router/router.d.ts.map +1 -0
  177. package/dist/router/router.js +178 -0
  178. package/dist/router/router.js.map +1 -0
  179. package/dist/router/routerUtils.d.ts +5 -0
  180. package/dist/router/routerUtils.d.ts.map +1 -0
  181. package/dist/router/routerUtils.js +39 -0
  182. package/dist/router/routerUtils.js.map +1 -0
  183. package/dist/scheduler.d.ts +14 -0
  184. package/dist/scheduler.d.ts.map +1 -0
  185. package/dist/scheduler.js +457 -0
  186. package/dist/scheduler.js.map +1 -0
  187. package/dist/signals/base.d.ts +36 -0
  188. package/dist/signals/base.d.ts.map +1 -0
  189. package/dist/signals/base.js +205 -0
  190. package/dist/signals/base.js.map +1 -0
  191. package/dist/signals/computed.d.ts +16 -0
  192. package/dist/signals/computed.d.ts.map +1 -0
  193. package/dist/signals/computed.js +116 -0
  194. package/dist/signals/computed.js.map +1 -0
  195. package/dist/signals/effect.d.ts +18 -0
  196. package/dist/signals/effect.d.ts.map +1 -0
  197. package/dist/signals/effect.js +43 -0
  198. package/dist/signals/effect.js.map +1 -0
  199. package/dist/signals/globals.d.ts +9 -0
  200. package/dist/signals/globals.d.ts.map +1 -0
  201. package/dist/signals/globals.js +9 -0
  202. package/dist/signals/globals.js.map +1 -0
  203. package/dist/signals/index.d.ts +12 -0
  204. package/dist/signals/index.d.ts.map +1 -0
  205. package/dist/signals/index.js +12 -0
  206. package/dist/signals/index.js.map +1 -0
  207. package/dist/signals/jsx.d.ts +16 -0
  208. package/dist/signals/jsx.d.ts.map +1 -0
  209. package/dist/signals/jsx.js +11 -0
  210. package/dist/signals/jsx.js.map +1 -0
  211. package/dist/signals/types.d.ts +9 -0
  212. package/dist/signals/types.d.ts.map +1 -0
  213. package/dist/signals/types.js +2 -0
  214. package/dist/signals/types.js.map +1 -0
  215. package/dist/signals/utils.d.ts +4 -0
  216. package/dist/signals/utils.d.ts.map +1 -0
  217. package/dist/signals/utils.js +12 -0
  218. package/dist/signals/utils.js.map +1 -0
  219. package/dist/signals/watch.d.ts +24 -0
  220. package/dist/signals/watch.d.ts.map +1 -0
  221. package/dist/signals/watch.js +104 -0
  222. package/dist/signals/watch.js.map +1 -0
  223. package/dist/ssr/client.d.ts +4 -0
  224. package/dist/ssr/client.d.ts.map +1 -0
  225. package/dist/ssr/client.js +12 -0
  226. package/dist/ssr/client.js.map +1 -0
  227. package/dist/ssr/hydrationBoundary.d.ts +27 -0
  228. package/dist/ssr/hydrationBoundary.d.ts.map +1 -0
  229. package/dist/ssr/hydrationBoundary.js +30 -0
  230. package/dist/ssr/hydrationBoundary.js.map +1 -0
  231. package/dist/ssr/index.d.ts +2 -0
  232. package/dist/ssr/index.d.ts.map +1 -0
  233. package/dist/ssr/index.js +2 -0
  234. package/dist/ssr/index.js.map +1 -0
  235. package/dist/ssr/server.d.ts +3 -0
  236. package/dist/ssr/server.d.ts.map +1 -0
  237. package/dist/ssr/server.js +101 -0
  238. package/dist/ssr/server.js.map +1 -0
  239. package/dist/store.d.ts +28 -0
  240. package/dist/store.d.ts.map +1 -0
  241. package/dist/store.js +166 -0
  242. package/dist/store.js.map +1 -0
  243. package/dist/swr.d.ts +74 -0
  244. package/dist/swr.d.ts.map +1 -0
  245. package/dist/swr.js +228 -0
  246. package/dist/swr.js.map +1 -0
  247. package/dist/transition.d.ts +18 -0
  248. package/dist/transition.d.ts.map +1 -0
  249. package/dist/transition.js +48 -0
  250. package/dist/transition.js.map +1 -0
  251. package/dist/types.d.ts +143 -0
  252. package/dist/types.d.ts.map +1 -0
  253. package/dist/types.dom.d.ts +920 -0
  254. package/dist/types.dom.d.ts.map +1 -0
  255. package/dist/types.dom.js +2 -0
  256. package/dist/types.dom.js.map +1 -0
  257. package/dist/types.js +2 -0
  258. package/dist/types.js.map +1 -0
  259. package/dist/types.utils.d.ts +41 -0
  260. package/dist/types.utils.d.ts.map +1 -0
  261. package/dist/types.utils.js +2 -0
  262. package/dist/types.utils.js.map +1 -0
  263. package/dist/utils.d.ts +61 -0
  264. package/dist/utils.d.ts.map +1 -0
  265. package/dist/utils.js +478 -0
  266. package/dist/utils.js.map +1 -0
  267. package/dist/warning.d.ts +2 -0
  268. package/dist/warning.d.ts.map +1 -0
  269. package/dist/warning.js +4 -0
  270. package/dist/warning.js.map +1 -0
  271. package/package.json +2 -2
  272. package/src/appContext.ts +7 -7
  273. package/src/cloneVNode.ts +1 -1
  274. package/src/constants.ts +9 -9
  275. package/src/context.ts +7 -7
  276. package/src/dom.ts +13 -15
  277. package/src/element.ts +4 -4
  278. package/src/error.ts +11 -13
  279. package/src/globalContext.ts +6 -10
  280. package/src/globals.ts +3 -3
  281. package/src/hmr.ts +4 -4
  282. package/src/hooks/useAsync.ts +2 -2
  283. package/src/hooks/useCallback.ts +1 -1
  284. package/src/hooks/useContext.ts +6 -6
  285. package/src/hooks/useEffect.ts +2 -2
  286. package/src/hooks/useEffectEvent.ts +1 -1
  287. package/src/hooks/useId.ts +2 -2
  288. package/src/hooks/useLayoutEffect.ts +2 -2
  289. package/src/hooks/useMemo.ts +2 -2
  290. package/src/hooks/useReducer.ts +2 -2
  291. package/src/hooks/useRef.ts +5 -5
  292. package/src/hooks/useState.ts +5 -5
  293. package/src/hooks/useSyncExternalStore.ts +3 -3
  294. package/src/hooks/useViewTransition.ts +1 -1
  295. package/src/hooks/utils.ts +7 -9
  296. package/src/index.ts +4 -4
  297. package/src/jsx.ts +2 -2
  298. package/src/lazy.ts +15 -17
  299. package/src/memo.ts +2 -2
  300. package/src/portal.ts +4 -4
  301. package/src/props.ts +5 -7
  302. package/src/reconciler.ts +6 -6
  303. package/src/renderToString.ts +1 -1
  304. package/src/router/route.ts +1 -1
  305. package/src/router/router.ts +6 -6
  306. package/src/scheduler.ts +16 -16
  307. package/src/signals/base.ts +1 -1
  308. package/src/signals/types.ts +1 -1
  309. package/src/signals/watch.ts +2 -2
  310. package/src/ssr/hydrationBoundary.ts +1 -1
  311. package/src/ssr/server.ts +1 -1
  312. package/src/store.ts +7 -7
  313. package/src/swr.ts +2 -2
  314. package/src/types.dom.ts +1 -1
  315. package/src/types.ts +13 -13
  316. package/src/types.utils.ts +5 -5
  317. package/src/utils.ts +9 -12
  318. package/src/warning.ts +1 -1
package/src/dom.ts CHANGED
@@ -12,7 +12,7 @@ import { hydrationStack } from "./hydration.js"
12
12
  import { StyleObject } from "./types.dom.js"
13
13
  import { isPortal } from "./portal.js"
14
14
  import { __DEV__ } from "./env.js"
15
- import { KaiokenError } from "./error.js"
15
+ import { KiruError } from "./error.js"
16
16
  import { flags } from "./flags.js"
17
17
  import type {
18
18
  DomVNode,
@@ -24,7 +24,7 @@ import type {
24
24
 
25
25
  export { commitWork, createDom, updateDom, hydrateDom }
26
26
 
27
- type VNode = Kaioken.VNode
27
+ type VNode = Kiru.VNode
28
28
  type HostNode = {
29
29
  node: ElementVNode
30
30
  lastChild?: DomVNode
@@ -35,7 +35,7 @@ type PlacementScope = {
35
35
  child?: VNode
36
36
  }
37
37
 
38
- function setDomRef(ref: Kaioken.Ref<SomeDom | null>, value: SomeDom | null) {
38
+ function setDomRef(ref: Kiru.Ref<SomeDom | null>, value: SomeDom | null) {
39
39
  if (typeof ref === "function") {
40
40
  ref(value)
41
41
  return
@@ -47,7 +47,7 @@ function setDomRef(ref: Kaioken.Ref<SomeDom | null>, value: SomeDom | null) {
47
47
  })
48
48
  return
49
49
  }
50
- ;(ref as Kaioken.MutableRefObject<SomeDom | null>).current = value
50
+ ;(ref as Kiru.MutableRefObject<SomeDom | null>).current = value
51
51
  }
52
52
 
53
53
  function createDom(vNode: DomVNode): SomeDom {
@@ -247,7 +247,7 @@ function setSignalProp(
247
247
  cleanups[key] = signal.subscribe((value) => {
248
248
  setProp(dom, key, value, null)
249
249
  if (__DEV__) {
250
- window.__kaioken?.profilingContext?.emit("signalAttrUpdate", _ctx)
250
+ window.__kiru?.profilingContext?.emit("signalAttrUpdate", _ctx)
251
251
  }
252
252
  })
253
253
 
@@ -257,9 +257,7 @@ function setSignalProp(
257
257
  const evtName = bindAttrToEventMap[attr]
258
258
  if (!evtName) {
259
259
  if (__DEV__) {
260
- console.error(
261
- `[kaioken]: ${attr} is not a valid element binding attribute.`
262
- )
260
+ console.error(`[kiru]: ${attr} is not a valid element binding attribute.`)
263
261
  }
264
262
  return
265
263
  }
@@ -272,7 +270,7 @@ function setSignalProp(
272
270
  const signalUpdateCallback = (value: any) => {
273
271
  setAttr(value)
274
272
  if (__DEV__) {
275
- window.__kaioken?.profilingContext?.emit("signalAttrUpdate", _ctx)
273
+ window.__kiru?.profilingContext?.emit("signalAttrUpdate", _ctx)
276
274
  }
277
275
  }
278
276
 
@@ -324,7 +322,7 @@ function subTextNode(vNode: VNode, textNode: Text, signal: Signal<string>) {
324
322
  ;(vNode.cleanups ??= {}).nodeValue = signal.subscribe((v) => {
325
323
  textNode.nodeValue = v
326
324
  if (__DEV__) {
327
- window.__kaioken?.profilingContext?.emit("signalTextUpdate", _ctx)
325
+ window.__kiru?.profilingContext?.emit("signalTextUpdate", _ctx)
328
326
  }
329
327
  })
330
328
  }
@@ -332,7 +330,7 @@ function subTextNode(vNode: VNode, textNode: Text, signal: Signal<string>) {
332
330
  function hydrateDom(vNode: VNode) {
333
331
  const dom = hydrationStack.nextChild()
334
332
  if (!dom)
335
- throw new KaiokenError({
333
+ throw new KiruError({
336
334
  message: `Hydration mismatch - no node found`,
337
335
  vNode,
338
336
  })
@@ -341,7 +339,7 @@ function hydrateDom(vNode: VNode) {
341
339
  nodeName = nodeName.toLowerCase()
342
340
  }
343
341
  if ((vNode.type as string) !== nodeName) {
344
- throw new KaiokenError({
342
+ throw new KiruError({
345
343
  message: `Hydration mismatch - expected node of type ${vNode.type.toString()} but received ${nodeName}`,
346
344
  vNode,
347
345
  })
@@ -523,7 +521,7 @@ function getDomParent(vNode: VNode): ElementVNode {
523
521
  return vNode as ElementVNode
524
522
  }
525
523
 
526
- throw new KaiokenError({
524
+ throw new KiruError({
527
525
  message: "No DOM parent found while attempting to place node.",
528
526
  vNode: vNode,
529
527
  })
@@ -698,11 +696,11 @@ function commitDeletion(vNode: VNode) {
698
696
  if (cleanups) Object.values(cleanups).forEach((c) => c())
699
697
 
700
698
  if (__DEV__) {
701
- window.__kaioken?.profilingContext?.emit("removeNode", ctx.current)
699
+ window.__kiru?.profilingContext?.emit("removeNode", ctx.current)
702
700
  }
703
701
 
704
702
  if (dom) {
705
- if (ref) setDomRef(ref as Kaioken.Ref<SomeDom>, null)
703
+ if (ref) setDomRef(ref as Kiru.Ref<SomeDom>, null)
706
704
  if (dom.isConnected && !isPortal(node)) {
707
705
  dom.remove()
708
706
  }
package/src/element.ts CHANGED
@@ -2,15 +2,15 @@ import { $FRAGMENT, $MEMO } from "./constants.js"
2
2
  import { isMemoFn } from "./memo.js"
3
3
  import { isValidElementKeyProp, isValidElementRefProp } from "./props.js"
4
4
 
5
- export function createElement<T extends Kaioken.VNode["type"]>(
5
+ export function createElement<T extends Kiru.VNode["type"]>(
6
6
  type: T,
7
7
  props: null | Record<string, unknown> = null,
8
8
  ...children: unknown[]
9
- ): Kaioken.VNode {
9
+ ): Kiru.VNode {
10
10
  if ((type as any) === Fragment) {
11
11
  return Fragment({ children: children as any, ...props })
12
12
  }
13
- const node: Kaioken.VNode = {
13
+ const node: Kiru.VNode = {
14
14
  type,
15
15
  flags: 0,
16
16
  index: 0,
@@ -49,6 +49,6 @@ export function Fragment({
49
49
  }: {
50
50
  children: JSX.Children
51
51
  key?: JSX.ElementKey
52
- }): Kaioken.VNode {
52
+ }): Kiru.VNode {
53
53
  return createElement($FRAGMENT, key ? { key } : null, children)
54
54
  }
package/src/error.ts CHANGED
@@ -1,24 +1,24 @@
1
- import { $KAIOKEN_ERROR } from "./constants.js"
1
+ import { $KIRU_ERROR } from "./constants.js"
2
2
  import { __DEV__ } from "./env.js"
3
3
  import { findParent, noop } from "./utils.js"
4
4
 
5
- type KaiokenErrorOptions =
5
+ type KiruErrorOptions =
6
6
  | string
7
7
  | {
8
8
  message: string
9
9
  /** Used to indicate that the error is fatal and should crash the application */
10
10
  fatal?: boolean
11
11
  /** Used to generate custom node stack */
12
- vNode?: Kaioken.VNode
12
+ vNode?: Kiru.VNode
13
13
  }
14
14
 
15
- export class KaiokenError extends Error {
16
- [$KAIOKEN_ERROR] = true
15
+ export class KiruError extends Error {
16
+ [$KIRU_ERROR] = true
17
17
  /** Indicates whether the error is fatal and should crash the application */
18
18
  fatal?: boolean
19
19
  /** Present if vNode is provided */
20
20
  customNodeStack?: string
21
- constructor(optionsOrMessage: KaiokenErrorOptions) {
21
+ constructor(optionsOrMessage: KiruErrorOptions) {
22
22
  const message =
23
23
  typeof optionsOrMessage === "string"
24
24
  ? optionsOrMessage
@@ -34,14 +34,12 @@ export class KaiokenError extends Error {
34
34
  }
35
35
  }
36
36
 
37
- static isKaiokenError(error: unknown): error is KaiokenError {
38
- return (
39
- error instanceof Error && (error as KaiokenError)[$KAIOKEN_ERROR] === true
40
- )
37
+ static isKiruError(error: unknown): error is KiruError {
38
+ return error instanceof Error && (error as KiruError)[$KIRU_ERROR] === true
41
39
  }
42
40
  }
43
41
 
44
- function captureErrorStack(vNode: Kaioken.VNode) {
42
+ function captureErrorStack(vNode: Kiru.VNode) {
45
43
  let n = vNode
46
44
  let componentFns: string[] = []
47
45
  while (n) {
@@ -57,7 +55,7 @@ function captureErrorStack(vNode: Kaioken.VNode) {
57
55
  typeof vNode.type === "function"
58
56
  ? vNode
59
57
  : findParent(vNode, (n) => typeof n.type === "function")
60
- ) as (Kaioken.VNode & { type: Function }) | null
58
+ ) as (Kiru.VNode & { type: Function }) | null
61
59
  return `The above error occurred in the <${getFunctionName(
62
60
  componentNode?.type || noop
63
61
  )}> component:
@@ -81,5 +79,5 @@ function getFunctionName(fn: Function) {
81
79
  }
82
80
 
83
81
  function getComponentFileLink(fn: Function) {
84
- return fn.toString().match(/\/\/ \[kaioken_devtools\]:(.*)/)?.[1] ?? null
82
+ return fn.toString().match(/\/\/ \[kiru_devtools\]:(.*)/)?.[1] ?? null
85
83
  }
@@ -4,11 +4,7 @@ import { createHMRContext } from "./hmr.js"
4
4
  import { createProfilingContext } from "./profiling.js"
5
5
  import { Store } from "./store"
6
6
 
7
- export {
8
- createKaiokenGlobalContext,
9
- type GlobalKaiokenEvent,
10
- type KaiokenGlobalContext,
11
- }
7
+ export { createKiruGlobalContext, type GlobalKiruEvent, type KiruGlobalContext }
12
8
 
13
9
  interface ReactiveMap<V> {
14
10
  add(key: string, value: V): void
@@ -72,9 +68,9 @@ type Evt =
72
68
  data: Error
73
69
  }
74
70
 
75
- type GlobalKaiokenEvent = Evt["name"]
71
+ type GlobalKiruEvent = Evt["name"]
76
72
 
77
- interface KaiokenGlobalContext {
73
+ interface KiruGlobalContext {
78
74
  readonly apps: AppContext[]
79
75
  stores?: ReactiveMap<Store<any, any>>
80
76
  HMRContext?: ReturnType<typeof createHMRContext>
@@ -91,10 +87,10 @@ interface KaiokenGlobalContext {
91
87
  ): void
92
88
  }
93
89
 
94
- function createKaiokenGlobalContext(): KaiokenGlobalContext {
90
+ function createKiruGlobalContext(): KiruGlobalContext {
95
91
  const contexts = new Set<AppContext>()
96
92
  const listeners = new Map<
97
- GlobalKaiokenEvent,
93
+ GlobalKiruEvent,
98
94
  Set<(ctx: AppContext, data?: Evt["data"]) => void>
99
95
  >()
100
96
  const globalState: Record<symbol, any> = {}
@@ -128,7 +124,7 @@ function createKaiokenGlobalContext(): KaiokenGlobalContext {
128
124
  listeners.get(event)?.delete(callback)
129
125
  }
130
126
 
131
- const globalContext: KaiokenGlobalContext = {
127
+ const globalContext: KiruGlobalContext = {
132
128
  get apps() {
133
129
  return Array.from(contexts)
134
130
  },
package/src/globals.ts CHANGED
@@ -3,7 +3,7 @@ import type { AppContext } from "./appContext"
3
3
  export { node, hookIndex, ctx, renderMode, nodeToCtxMap }
4
4
 
5
5
  const node = {
6
- current: null as Kaioken.VNode | null,
6
+ current: null as Kiru.VNode | null,
7
7
  }
8
8
 
9
9
  const hookIndex = {
@@ -15,7 +15,7 @@ const ctx = {
15
15
  }
16
16
 
17
17
  const renderMode = {
18
- current: ("window" in globalThis ? "dom" : "string") as Kaioken.RenderMode,
18
+ current: ("window" in globalThis ? "dom" : "string") as Kiru.RenderMode,
19
19
  }
20
20
 
21
- const nodeToCtxMap = new WeakMap<Kaioken.VNode, AppContext<any>>()
21
+ const nodeToCtxMap = new WeakMap<Kiru.VNode, AppContext<any>>()
package/src/hmr.ts CHANGED
@@ -15,7 +15,7 @@ export type HMRAccept<T = {}> = {
15
15
  export type GenericHMRAcceptor<T = {}> = {
16
16
  [$HMR_ACCEPT]: HMRAccept<T>
17
17
  }
18
- type HotVar = Kaioken.FC | Store<any, any> | Signal<any> | Kaioken.Context<any>
18
+ type HotVar = Kiru.FC | Store<any, any> | Signal<any> | Kiru.Context<any>
19
19
 
20
20
  type HotVarDesc = {
21
21
  type: string
@@ -80,7 +80,7 @@ export function createHMRContext() {
80
80
  hotVarRegistrationEntries: Record<string, HotVarRegistrationEntry>
81
81
  ) => {
82
82
  if (currentModuleMemory === null)
83
- throw new Error("[kaioken]: HMR could not register: No active module")
83
+ throw new Error("[kiru]: HMR could not register: No active module")
84
84
 
85
85
  let dirtiedApps: Set<AppContext> = new Set()
86
86
  for (const [name, newEntry] of Object.entries(hotVarRegistrationEntries)) {
@@ -101,7 +101,7 @@ export function createHMRContext() {
101
101
  }
102
102
 
103
103
  if (newEntry.type === "createStore") {
104
- window.__kaioken!.stores!.add(name, newEntry.value as Store<any, any>)
104
+ window.__kiru!.stores!.add(name, newEntry.value as Store<any, any>)
105
105
  }
106
106
 
107
107
  currentModuleMemory.hotVars.set(name, newEntry)
@@ -117,7 +117,7 @@ export function createHMRContext() {
117
117
  continue
118
118
  }
119
119
  if (oldEntry.type === "component" && newEntry.type === "component") {
120
- window.__kaioken!.apps.forEach((ctx) => {
120
+ window.__kiru!.apps.forEach((ctx) => {
121
121
  if (!ctx.mounted || !ctx.rootNode) return
122
122
  traverseApply(ctx.rootNode, (vNode) => {
123
123
  if (vNode.type === oldEntry.value) {
@@ -42,9 +42,9 @@ type AsyncTaskState<T> = {
42
42
  }
43
43
  /**
44
44
  * Runs an asynchronous function on initial render, or when a value provided in the [dependency
45
- * array](https://kaioken.dev/docs/hooks/dependency-arrays) has changed.
45
+ * array](https://kirujs.dev/docs/hooks/dependency-arrays) has changed.
46
46
  *
47
- * @see https://kaioken.dev/docs/hooks/useAsync
47
+ * @see https://kirujs.dev/docs/hooks/useAsync
48
48
  */
49
49
  export function useAsync<T>(
50
50
  func: (ctx: UseAsyncCallbackContext) => Promise<T>,
@@ -4,7 +4,7 @@ import { depsRequireChange, useHook, sideEffectsEnabled } from "./utils.js"
4
4
  /**
5
5
  * Creates a memoized callback function.
6
6
  *
7
- * @see https://kaioken.dev/docs/hooks/useCallback
7
+ * @see https://kirujs.dev/docs/hooks/useCallback
8
8
  */
9
9
  export function useCallback<T extends Function>(
10
10
  callback: T,
@@ -5,17 +5,17 @@ import { $CONTEXT_PROVIDER } from "../constants.js"
5
5
 
6
6
  type UseContextHookState<T> = {
7
7
  provider?: ContextProviderNode<T>
8
- context: Kaioken.Context<T>
8
+ context: Kiru.Context<T>
9
9
  warnIfNotFound: boolean
10
10
  }
11
11
 
12
12
  /**
13
13
  * Gets the current value of a context provider created by the context.
14
14
  *
15
- * @see https://kaioken.dev/docs/hooks/useContext
15
+ * @see https://kirujs.dev/docs/hooks/useContext
16
16
  */
17
17
  export function useContext<T>(
18
- context: Kaioken.Context<T>,
18
+ context: Kiru.Context<T>,
19
19
  warnIfNotFound = true
20
20
  ): T {
21
21
  return useHook(
@@ -70,10 +70,10 @@ const useContextCallback = <T>({
70
70
  return hook.provider.props.value
71
71
  }
72
72
 
73
- const contextsNotFound = new Set<Kaioken.Context<any>>()
74
- function warnProviderNotFound(ctx: Kaioken.Context<any>) {
73
+ const contextsNotFound = new Set<Kiru.Context<any>>()
74
+ function warnProviderNotFound(ctx: Kiru.Context<any>) {
75
75
  if (!contextsNotFound.has(ctx)) {
76
76
  contextsNotFound.add(ctx)
77
- console.warn("[kaioken]: Unable to find context provider")
77
+ console.warn("[kiru]: Unable to find context provider")
78
78
  }
79
79
  }
@@ -8,9 +8,9 @@ import {
8
8
 
9
9
  /**
10
10
  * Runs a function after the component is rendered, or when a value provided in the optional [dependency
11
- * array](https://kaioken.dev/docs/hooks/dependency-arrays) has changed.
11
+ * array](https://kirujs.dev/docs/hooks/dependency-arrays) has changed.
12
12
  *
13
- * @see https://kaioken.dev/docs/hooks/useEffect
13
+ * @see https://kirujs.dev/docs/hooks/useEffect
14
14
  * */
15
15
  export function useEffect(
16
16
  callback: () => void | (() => void),
@@ -6,7 +6,7 @@ import { sideEffectsEnabled, useHook } from "./utils.js"
6
6
  * Wraps a function to be called within effects and other callbacks.
7
7
  * The function will be called with the same arguments as the original function.
8
8
  *
9
- * @see https://kaioken.dev/docs/hooks/useEffectEvent
9
+ * @see https://kirujs.dev/docs/hooks/useEffectEvent
10
10
  */
11
11
  export function useEffectEvent<T extends Function>(callback: T): T {
12
12
  if (!sideEffectsEnabled()) return callback
@@ -5,7 +5,7 @@ import { HookCallback, useHook } from "./utils.js"
5
5
  * Creates a unique id for the current node. This is derived based on the node's position in your application tree.
6
6
  * Useful for assigning predictable ids to elements.
7
7
  *
8
- * @see https://kaioken.dev/docs/hooks/useId
8
+ * @see https://kirujs.dev/docs/hooks/useId
9
9
  */
10
10
  export function useId(): string {
11
11
  return useHook("useId", createUseIdState, useIdCallback)
@@ -30,7 +30,7 @@ const useIdCallback: HookCallback<UseIdState> = ({ hook, isInit, vNode }) => {
30
30
  if (isInit || vNode.index !== hook.idx) {
31
31
  hook.idx = vNode.index
32
32
  const accumulator: number[] = []
33
- let n: Kaioken.VNode | null = vNode
33
+ let n: Kiru.VNode | null = vNode
34
34
  while (n) {
35
35
  accumulator.push(n.index)
36
36
  accumulator.push(n.depth)
@@ -8,9 +8,9 @@ import {
8
8
 
9
9
  /**
10
10
  * Runs a function before the component is rendered, or when a value provided in the optional [dependency
11
- * array](https://kaioken.dev/docs/hooks/dependency-arrays) has changed.
11
+ * array](https://kirujs.dev/docs/hooks/dependency-arrays) has changed.
12
12
  *
13
- * @see https://kaioken.dev/docs/hooks/useLayoutEffect
13
+ * @see https://kirujs.dev/docs/hooks/useLayoutEffect
14
14
  * */
15
15
  export function useLayoutEffect(
16
16
  callback: () => void | (() => void),
@@ -3,9 +3,9 @@ import { depsRequireChange, sideEffectsEnabled, useHook } from "./utils.js"
3
3
 
4
4
  /**
5
5
  * Creates a memoized value that only changes when the [dependency
6
- * array](https://kaioken.dev/docs/hooks/dependency-arrays) has changed.
6
+ * array](https://kirujs.dev/docs/hooks/dependency-arrays) has changed.
7
7
  *
8
- * @see https://kaioken.dev/docs/hooks/useMemo
8
+ * @see https://kirujs.dev/docs/hooks/useMemo
9
9
  */
10
10
  export function useMemo<T>(factory: () => T, deps: unknown[]): T {
11
11
  if (!sideEffectsEnabled()) return factory()
@@ -5,7 +5,7 @@ import { sideEffectsEnabled, useHook } from "./utils.js"
5
5
  /**
6
6
  * Creates 'dispatcher-driven' state.
7
7
  *
8
- * @see https://kaioken.dev/docs/hooks/useReducer
8
+ * @see https://kirujs.dev/docs/hooks/useReducer
9
9
  */
10
10
  export function useReducer<T, A>(
11
11
  reducer: (state: T, action: A) => T,
@@ -23,7 +23,7 @@ export function useReducer<T, A>(
23
23
  devtools: {
24
24
  get: () => ({ value: hook.state }),
25
25
  set: ({ value }) => (hook.state = value),
26
- } satisfies Kaioken.HookDevtoolsProvisions<{ value: T }>,
26
+ } satisfies Kiru.HookDevtoolsProvisions<{ value: T }>,
27
27
  initialArgs: [reducer, state],
28
28
  }
29
29
  }
@@ -5,11 +5,11 @@ import { sideEffectsEnabled, useHook } from "./utils.js"
5
5
  * Creates a ref object. Useful for persisting values between renders or getting
6
6
  * a reference to an element.
7
7
  *
8
- * @see https://kaioken.dev/docs/hooks/useRef
8
+ * @see https://kirujs.dev/docs/hooks/useRef
9
9
  */
10
- export function useRef<T>(initialValue: T): Kaioken.MutableRefObject<T>
11
- export function useRef<T>(initialValue: T | null): Kaioken.RefObject<T>
12
- export function useRef<T = undefined>(): Kaioken.MutableRefObject<T | undefined>
10
+ export function useRef<T>(initialValue: T): Kiru.MutableRefObject<T>
11
+ export function useRef<T>(initialValue: T | null): Kiru.RefObject<T>
12
+ export function useRef<T = undefined>(): Kiru.MutableRefObject<T | undefined>
13
13
  export function useRef<T>(initialValue?: T | null) {
14
14
  if (!sideEffectsEnabled()) return { current: initialValue }
15
15
  return useHook(
@@ -22,7 +22,7 @@ export function useRef<T>(initialValue?: T | null) {
22
22
  devtools: {
23
23
  get: () => ({ value: hook.ref.current! }),
24
24
  set: ({ value }) => (hook.ref.current = value),
25
- } satisfies Kaioken.HookDevtoolsProvisions<{ value: T }>,
25
+ } satisfies Kiru.HookDevtoolsProvisions<{ value: T }>,
26
26
  initialArgs: [hook.ref.current],
27
27
  }
28
28
  }
@@ -5,11 +5,11 @@ import { sideEffectsEnabled, useHook } from "./utils.js"
5
5
  /**
6
6
  * Creates a stateful value, and returns the current value and a function to update it.
7
7
  *
8
- * @see https://kaioken.dev/docs/hooks/useState
8
+ * @see https://kirujs.dev/docs/hooks/useState
9
9
  */
10
10
  export function useState<T>(
11
11
  initial: T | (() => T)
12
- ): readonly [T, (value: Kaioken.StateSetter<T>) => void] {
12
+ ): readonly [T, (value: Kiru.StateSetter<T>) => void] {
13
13
  if (!sideEffectsEnabled()) {
14
14
  return [
15
15
  typeof initial === "function" ? (initial as Function)() : initial,
@@ -20,7 +20,7 @@ export function useState<T>(
20
20
  "useState",
21
21
  {
22
22
  state: undefined as T,
23
- dispatch: noop as (value: Kaioken.StateSetter<T>) => void,
23
+ dispatch: noop as (value: Kiru.StateSetter<T>) => void,
24
24
  },
25
25
  ({ hook, isInit, update, isHMR }) => {
26
26
  if (__DEV__) {
@@ -29,7 +29,7 @@ export function useState<T>(
29
29
  devtools: {
30
30
  get: () => ({ value: hook.state }),
31
31
  set: ({ value }) => (hook.state = value),
32
- } satisfies Kaioken.HookDevtoolsProvisions<{ value: T }>,
32
+ } satisfies Kiru.HookDevtoolsProvisions<{ value: T }>,
33
33
  initialArgs: [initial],
34
34
  }
35
35
  }
@@ -45,7 +45,7 @@ export function useState<T>(
45
45
  if (isInit) {
46
46
  hook.state =
47
47
  typeof initial === "function" ? (initial as Function)() : initial
48
- hook.dispatch = (setter: Kaioken.StateSetter<T>) => {
48
+ hook.dispatch = (setter: Kiru.StateSetter<T>) => {
49
49
  const newState =
50
50
  typeof setter === "function"
51
51
  ? (setter as Function)(hook.state)
@@ -1,5 +1,5 @@
1
1
  import { node } from "../globals.js"
2
- import { KaiokenError } from "../error.js"
2
+ import { KiruError } from "../error.js"
3
3
  import { noop } from "../utils.js"
4
4
  import { sideEffectsEnabled, useHook } from "./utils.js"
5
5
  import { __DEV__ } from "../env.js"
@@ -8,7 +8,7 @@ import { __DEV__ } from "../env.js"
8
8
  * Allows you to use a generic external store as long as it provides
9
9
  * a subscribe function and a way to get its current state.
10
10
  *
11
- * @see https://kaioken.dev/docs/hooks/useSyncExternalStore
11
+ * @see https://kirujs.dev/docs/hooks/useSyncExternalStore
12
12
  */
13
13
  export function useSyncExternalStore<T>(
14
14
  subscribe: (callback: () => void) => () => void,
@@ -17,7 +17,7 @@ export function useSyncExternalStore<T>(
17
17
  ): T {
18
18
  if (!sideEffectsEnabled()) {
19
19
  if (getServerState === undefined) {
20
- throw new KaiokenError({
20
+ throw new KiruError({
21
21
  message:
22
22
  "useSyncExternalStore must receive a getServerSnapshot function if the component is rendered on the server.",
23
23
  vNode: node.current!,
@@ -8,7 +8,7 @@ import { sideEffectsEnabled } from "./utils.js"
8
8
  *
9
9
  * Falls back to the regular `callback` if not supported.
10
10
  *
11
- * @see https://kaioken.dev/docs/hooks/useViewTransition
11
+ * @see https://kirujs.dev/docs/hooks/useViewTransition
12
12
  */
13
13
  export function useViewTransition() {
14
14
  if (!sideEffectsEnabled()) return noop
@@ -1,4 +1,4 @@
1
- import { KaiokenError } from "../error.js"
1
+ import { KiruError } from "../error.js"
2
2
  import { __DEV__ } from "../env.js"
3
3
  import { ctx, hookIndex, node, nodeToCtxMap } from "../globals.js"
4
4
  import { getVNodeAppContext, noop } from "../utils.js"
@@ -17,7 +17,7 @@ export {
17
17
  type HookCallbackContext as HookCallbackState,
18
18
  }
19
19
 
20
- type HookState<T> = Kaioken.Hook<T>
20
+ type HookState<T> = Kiru.Hook<T>
21
21
 
22
22
  enum HookDebugGroupAction {
23
23
  Start = "start",
@@ -57,9 +57,7 @@ const useAppContext = () => {
57
57
  if (!node.current) error_hookMustBeCalledTopLevel("useAppContext")
58
58
  const ctx = nodeToCtxMap.get(node.current)
59
59
  if (!ctx)
60
- error_hookMustBeCalledTopLevel(
61
- "[kaioken]: unable to find node's AppContext"
62
- )
60
+ error_hookMustBeCalledTopLevel("[kiru]: unable to find node's AppContext")
63
61
  return ctx
64
62
  }
65
63
 
@@ -97,7 +95,7 @@ type HookCallbackContext<T> = {
97
95
  /**
98
96
  * The VNode associated with the current component
99
97
  */
100
- vNode: Kaioken.VNode
98
+ vNode: Kiru.VNode
101
99
  /**
102
100
  * The index of the current hook.
103
101
  * You can count on this being stable across renders,
@@ -140,7 +138,7 @@ function useHook<
140
138
  !nestedHookWarnings.has(hookName + currentHookName)
141
139
  ) {
142
140
  nestedHookWarnings.add(hookName + currentHookName)
143
- throw new KaiokenError({
141
+ throw new KiruError({
144
142
  message: `Nested primitive "useHook" calls are not supported. "${hookName}" was called inside "${currentHookName}". Strange will most certainly happen.`,
145
143
  vNode,
146
144
  })
@@ -173,7 +171,7 @@ function useHook<
173
171
  } else {
174
172
  if (vNode.hookSig[index] !== hookName) {
175
173
  console.warn(
176
- `[kaioken]: hooks must be called in the same order. Hook "${hookName}" was called in place of "${vNode.hookSig[index]}". Strange things may happen.`
174
+ `[kiru]: hooks must be called in the same order. Hook "${hookName}" was called in place of "${vNode.hookSig[index]}". Strange things may happen.`
177
175
  )
178
176
  vNode.hooks.length = index
179
177
  vNode.hookSig.length = index
@@ -237,7 +235,7 @@ function useHook<
237
235
  }
238
236
 
239
237
  function error_hookMustBeCalledTopLevel(hookName: string): never {
240
- throw new KaiokenError(
238
+ throw new KiruError(
241
239
  `Hook "${hookName}" must be used at the top level of a component or inside another composite hook.`
242
240
  )
243
241
  }
package/src/index.ts CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  type AppContextOptions,
5
5
  } from "./appContext.js"
6
6
  import { ctx } from "./globals.js"
7
- import { createKaiokenGlobalContext } from "./globalContext.js"
7
+ import { createKiruGlobalContext } from "./globalContext.js"
8
8
  import { __DEV__ } from "./env.js"
9
- import { KaiokenError } from "./error.js"
9
+ import { KiruError } from "./error.js"
10
10
 
11
11
  export type * from "./types"
12
12
  export * from "./appContext.js"
@@ -23,7 +23,7 @@ export * from "./store.js"
23
23
  export * from "./transition.js"
24
24
 
25
25
  if ("window" in globalThis) {
26
- globalThis.window.__kaioken ??= createKaiokenGlobalContext()
26
+ globalThis.window.__kiru ??= createKiruGlobalContext()
27
27
  }
28
28
 
29
29
  export function mount<T extends Record<string, unknown>>(
@@ -52,7 +52,7 @@ export function mount<T extends Record<string, unknown>>(
52
52
  root = optionsOrRoot.root!
53
53
  if (__DEV__) {
54
54
  if (!(root instanceof HTMLElement)) {
55
- throw new KaiokenError("Root node must be an HTMLElement")
55
+ throw new KiruError("Root node must be an HTMLElement")
56
56
  }
57
57
  }
58
58
  }
package/src/jsx.ts CHANGED
@@ -3,8 +3,8 @@ import { createElement, Fragment } from "./element.js"
3
3
  export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment }
4
4
 
5
5
  function jsx(
6
- type: Kaioken.VNode["type"],
7
- { children, ...props } = {} as { children?: Kaioken.VNode[] }
6
+ type: Kiru.VNode["type"],
7
+ { children, ...props } = {} as { children?: Kiru.VNode[] }
8
8
  ) {
9
9
  if (!children) return createElement(type, props)
10
10
  return createElement(type, props, children)