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/lazy.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createElement } from "./element.js"
2
2
  import { __DEV__ } from "./env.js"
3
- import { KaiokenError } from "./error.js"
3
+ import { KiruError } from "./error.js"
4
4
  import { node, renderMode } from "./globals.js"
5
5
  import { useContext } from "./hooks/useContext.js"
6
6
  import { useRef } from "./hooks/useRef.js"
@@ -13,16 +13,16 @@ import {
13
13
  import type { SomeDom } from "./types.utils"
14
14
  import { noop } from "./utils.js"
15
15
 
16
- type FCModule = { default: Kaioken.FC<any> }
17
- type LazyImportValue = Kaioken.FC<any> | FCModule
16
+ type FCModule = { default: Kiru.FC<any> }
17
+ type LazyImportValue = Kiru.FC<any> | FCModule
18
18
  type InferLazyImportProps<T extends LazyImportValue> = T extends FCModule
19
- ? Kaioken.InferProps<T["default"]>
20
- : Kaioken.InferProps<T>
19
+ ? Kiru.InferProps<T["default"]>
20
+ : Kiru.InferProps<T>
21
21
 
22
22
  type LazyState = {
23
23
  fn: string
24
24
  promise: Promise<LazyImportValue>
25
- result: Kaioken.FC | null
25
+ result: Kiru.FC | null
26
26
  }
27
27
 
28
28
  type LazyComponentProps<T extends LazyImportValue> = InferLazyImportProps<T> & {
@@ -32,10 +32,10 @@ type LazyComponentProps<T extends LazyImportValue> = InferLazyImportProps<T> & {
32
32
  const lazyCache: Map<string, LazyState> =
33
33
  "window" in globalThis
34
34
  ? // @ts-ignore - we're shamefully polluting the global scope here and hiding it 🥲
35
- (window.__KAIOKEN_LAZY_CACHE ??= new Map<string, LazyState>())
35
+ (window.__KIRU_LAZY_CACHE ??= new Map<string, LazyState>())
36
36
  : new Map<string, LazyState>()
37
37
 
38
- function consumeHydrationBoundaryChildren(parentNode: Kaioken.VNode): {
38
+ function consumeHydrationBoundaryChildren(parentNode: Kiru.VNode): {
39
39
  parent: HTMLElement
40
40
  childNodes: Node[]
41
41
  startIndex: number
@@ -45,9 +45,8 @@ function consumeHydrationBoundaryChildren(parentNode: Kaioken.VNode): {
45
45
  boundaryStart?.nodeType !== Node.COMMENT_NODE ||
46
46
  boundaryStart.nodeValue !== HYDRATION_BOUNDARY_MARKER
47
47
  ) {
48
- throw new KaiokenError({
49
- message:
50
- "Invalid HydrationBoundary node. This is likely a bug in Kaioken.",
48
+ throw new KiruError({
49
+ message: "Invalid HydrationBoundary node. This is likely a bug in Kiru.",
51
50
  fatal: true,
52
51
  vNode: parentNode,
53
52
  })
@@ -71,9 +70,8 @@ function consumeHydrationBoundaryChildren(parentNode: Kaioken.VNode): {
71
70
  }
72
71
  const boundaryEnd = hydrationStack.currentChild()
73
72
  if (!isBoundaryEnd(boundaryEnd)) {
74
- throw new KaiokenError({
75
- message:
76
- "Invalid HydrationBoundary node. This is likely a bug in Kaioken.",
73
+ throw new KiruError({
74
+ message: "Invalid HydrationBoundary node. This is likely a bug in Kiru.",
77
75
  fatal: true,
78
76
  vNode: parentNode,
79
77
  })
@@ -84,7 +82,7 @@ function consumeHydrationBoundaryChildren(parentNode: Kaioken.VNode): {
84
82
 
85
83
  export function lazy<T extends LazyImportValue>(
86
84
  componentPromiseFn: () => Promise<T>
87
- ): Kaioken.FC<LazyComponentProps<T>> {
85
+ ): Kiru.FC<LazyComponentProps<T>> {
88
86
  function LazyComponent(props: LazyComponentProps<T>) {
89
87
  const { fallback = null, ...rest } = props
90
88
  const appCtx = useAppContext()
@@ -136,7 +134,7 @@ export function lazy<T extends LazyImportValue>(
136
134
  }
137
135
 
138
136
  if (__DEV__) {
139
- window.__kaioken?.HMRContext?.onHmr(() => {
137
+ window.__kiru?.HMRContext?.onHmr(() => {
140
138
  if (needsHydration.current) {
141
139
  abortHydration.current()
142
140
  }
@@ -222,7 +220,7 @@ export function lazy<T extends LazyImportValue>(
222
220
  }
223
221
  return createElement(cachedState.result, rest)
224
222
  }
225
- LazyComponent.displayName = "Kaioken.lazy"
223
+ LazyComponent.displayName = "Kiru.lazy"
226
224
  return LazyComponent
227
225
  }
228
226
 
package/src/memo.ts CHANGED
@@ -25,7 +25,7 @@ export type MemoFn = Function & {
25
25
  }
26
26
 
27
27
  export function memo<T extends Record<string, unknown> = {}>(
28
- fn: Kaioken.FC<T>,
28
+ fn: Kiru.FC<T>,
29
29
  arePropsEqual: (prevProps: T, nextProps: T) => boolean = _arePropsEqual
30
30
  ): (props: T) => JSX.Element {
31
31
  return Object.assign(
@@ -34,7 +34,7 @@ export function memo<T extends Record<string, unknown> = {}>(
34
34
  },
35
35
  {
36
36
  [$MEMO]: { arePropsEqual },
37
- displayName: "Kaioken.memo",
37
+ displayName: "Kiru.memo",
38
38
  }
39
39
  )
40
40
  }
package/src/portal.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { __DEV__ } from "./env.js"
2
- import { KaiokenError } from "./error.js"
2
+ import { KiruError } from "./error.js"
3
3
  import { renderMode } from "./globals.js"
4
4
  import { useVNode } from "./hooks/utils.js"
5
5
  import { getVNodeAppContext } from "./utils.js"
@@ -18,7 +18,7 @@ function Portal({ children, container }: PortalProps) {
18
18
  vNode.dom = typeof container === "function" ? container() : container
19
19
  if (!(vNode.dom instanceof HTMLElement)) {
20
20
  if (__DEV__) {
21
- throw new KaiokenError({
21
+ throw new KiruError({
22
22
  message: `Invalid portal container, expected HTMLElement, got ${vNode.dom}`,
23
23
  vNode: vNode,
24
24
  })
@@ -37,7 +37,7 @@ function Portal({ children, container }: PortalProps) {
37
37
  }
38
38
 
39
39
  function isPortal(
40
- node: Kaioken.VNode
41
- ): node is Kaioken.VNode & { type: typeof Portal } {
40
+ node: Kiru.VNode
41
+ ): node is Kiru.VNode & { type: typeof Portal } {
42
42
  return node.type === Portal
43
43
  }
package/src/props.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { KaiokenError } from "./error.js"
1
+ import { KiruError } from "./error.js"
2
2
  import { Signal } from "./signals/base.js"
3
3
 
4
- export function assertValidElementProps(vNode: Kaioken.VNode) {
4
+ export function assertValidElementProps(vNode: Kiru.VNode) {
5
5
  if ("children" in vNode.props && vNode.props.innerHTML) {
6
- throw new KaiokenError({
6
+ throw new KiruError({
7
7
  message: "Cannot use both children and innerHTML on an element",
8
8
  vNode,
9
9
  })
@@ -11,7 +11,7 @@ export function assertValidElementProps(vNode: Kaioken.VNode) {
11
11
 
12
12
  for (const key in vNode.props) {
13
13
  if ("bind:" + key in vNode.props) {
14
- throw new KaiokenError({
14
+ throw new KiruError({
15
15
  message: `Cannot use both bind:${key} and ${key} on an element`,
16
16
  vNode,
17
17
  })
@@ -25,9 +25,7 @@ export function isValidElementKeyProp(
25
25
  return typeof thing === "string" || typeof thing === "number"
26
26
  }
27
27
 
28
- export function isValidElementRefProp(
29
- thing: unknown
30
- ): thing is Kaioken.Ref<any> {
28
+ export function isValidElementRefProp(thing: unknown): thing is Kiru.Ref<any> {
31
29
  return (
32
30
  typeof thing === "function" ||
33
31
  (typeof thing === "object" && !!thing && "current" in thing) ||
package/src/reconciler.ts CHANGED
@@ -6,7 +6,7 @@ import { createElement, Fragment } from "./element.js"
6
6
  import { flags } from "./flags.js"
7
7
  import { ctx } from "./globals.js"
8
8
 
9
- type VNode = Kaioken.VNode
9
+ type VNode = Kiru.VNode
10
10
 
11
11
  export function reconcileChildren(parent: VNode, children: unknown) {
12
12
  if (Array.isArray(children)) {
@@ -428,7 +428,7 @@ function updateFromMap(
428
428
  return null
429
429
  }
430
430
 
431
- function setParent(child: Kaioken.VNode, parent: Kaioken.VNode) {
431
+ function setParent(child: Kiru.VNode, parent: Kiru.VNode) {
432
432
  child.parent = parent
433
433
  child.depth = parent.depth + 1
434
434
  if (parent.isMemoized || flags.get(parent.flags, FLAG.HAS_MEMO_ANCESTOR)) {
@@ -438,15 +438,15 @@ function setParent(child: Kaioken.VNode, parent: Kaioken.VNode) {
438
438
 
439
439
  function emitUpdateNode() {
440
440
  if (!("window" in globalThis)) return
441
- window.__kaioken?.profilingContext?.emit("updateNode", ctx.current)
441
+ window.__kiru?.profilingContext?.emit("updateNode", ctx.current)
442
442
  }
443
443
 
444
444
  function emitCreateNode() {
445
445
  if (!("window" in globalThis)) return
446
- window.__kaioken?.profilingContext?.emit("createNode", ctx.current)
446
+ window.__kiru?.profilingContext?.emit("createNode", ctx.current)
447
447
  }
448
448
 
449
- const $LIST_CHILD = Symbol("kaioken:marked-list-child")
449
+ const $LIST_CHILD = Symbol("kiru:marked-list-child")
450
450
  function markListChild(children: unknown[]) {
451
451
  Object.assign(children, { [$LIST_CHILD]: true })
452
452
  }
@@ -510,7 +510,7 @@ function checkForMissingKeys(parent: VNode, children: unknown[]) {
510
510
  }
511
511
 
512
512
  function keyWarning(str: string) {
513
- const formatted = `[kaioken]: ${str}. See https://kaioken.dev/keys-warning for more information.`
513
+ const formatted = `[kiru]: ${str}. See https://kirujs.dev/keys-warning for more information.`
514
514
  console.error(formatted)
515
515
  }
516
516
 
@@ -31,7 +31,7 @@ export function renderToString<T extends Record<string, unknown>>(
31
31
 
32
32
  function renderToString_internal(
33
33
  el: unknown,
34
- parent: Kaioken.VNode | null,
34
+ parent: Kiru.VNode | null,
35
35
  idx: number
36
36
  ): string {
37
37
  if (el === null) return ""
@@ -46,6 +46,6 @@ export function Route({ element }: RouteProps) {
46
46
 
47
47
  export function isRoute(
48
48
  thing: unknown
49
- ): thing is Kaioken.VNode & { props: RouteProps } {
49
+ ): thing is Kiru.VNode & { props: RouteProps } {
50
50
  return isVNode(thing) && thing.type === Route
51
51
  }
@@ -67,7 +67,7 @@ export function Link({ to, onclick, replace, inherit, ...props }: LinkProps) {
67
67
  }
68
68
 
69
69
  type RouterCtx = {
70
- viewTransition: Kaioken.RefObject<ViewTransition>
70
+ viewTransition: Kiru.RefObject<ViewTransition>
71
71
  queueSyncNav: (callback: () => void) => void
72
72
  params: Record<string, string>
73
73
  query: Record<string, string>
@@ -95,7 +95,7 @@ function setQuery(query: Record<string, string>) {
95
95
  /**
96
96
  * Gets state and methods provided by a parent <Router>.
97
97
  *
98
- * @see https://kaioken.dev/docs/api/routing
98
+ * @see https://kirujs.dev/docs/api/routing
99
99
  */
100
100
  export function useRouter() {
101
101
  const { viewTransition, params, query } = useContext(RouterContext)
@@ -152,7 +152,7 @@ const initLoc = () => ({
152
152
  /**
153
153
  * Main router component.
154
154
  *
155
- * @see https://kaioken.dev/docs/api/routing
155
+ * @see https://kirujs.dev/docs/api/routing
156
156
  */
157
157
  export function Router(props: RouterProps) {
158
158
  const appCtx = useAppContext()
@@ -205,8 +205,8 @@ export function Router(props: RouterProps) {
205
205
  }
206
206
  })
207
207
 
208
- type RouteComponent = Kaioken.VNode & {
209
- props: Kaioken.InferProps<typeof Route>
208
+ type RouteComponent = Kiru.VNode & {
209
+ props: Kiru.InferProps<typeof Route>
210
210
  }
211
211
  let fallbackRoute: RouteComponent | undefined
212
212
  let route: RouteComponent | undefined
@@ -221,7 +221,7 @@ export function Router(props: RouterProps) {
221
221
  if (__DEV__) {
222
222
  if (fallbackRoute) {
223
223
  console.warn(
224
- "[kaioken]: More than one fallback route defined. Only the last one will be used."
224
+ "[kiru]: More than one fallback route defined. Only the last one will be used."
225
225
  )
226
226
  }
227
227
  }
package/src/scheduler.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "./constants.js"
13
13
  import { commitWork, createDom, hydrateDom } from "./dom.js"
14
14
  import { __DEV__ } from "./env.js"
15
- import { KaiokenError } from "./error.js"
15
+ import { KiruError } from "./error.js"
16
16
  import { ctx, hookIndex, node, nodeToCtxMap, renderMode } from "./globals.js"
17
17
  import { hydrationStack } from "./hydration.js"
18
18
  import { assertValidElementProps } from "./props.js"
@@ -26,7 +26,7 @@ import {
26
26
  } from "./utils.js"
27
27
  import { Signal } from "./signals/base.js"
28
28
 
29
- type VNode = Kaioken.VNode
29
+ type VNode = Kiru.VNode
30
30
 
31
31
  export interface Scheduler {
32
32
  clear(): void
@@ -122,7 +122,7 @@ export function createScheduler(
122
122
  // If this node is currently being rendered, just mark it dirty
123
123
  if (node.current === vNode) {
124
124
  if (__DEV__) {
125
- window.__kaioken?.profilingContext?.emit("updateDirtied", appCtx)
125
+ window.__kiru?.profilingContext?.emit("updateDirtied", appCtx)
126
126
  }
127
127
  isRenderDirtied = true
128
128
  return
@@ -234,7 +234,7 @@ export function createScheduler(
234
234
 
235
235
  function workLoop(deadline?: IdleDeadline): void {
236
236
  if (__DEV__) {
237
- window.__kaioken?.profilingContext?.beginTick(appCtx)
237
+ window.__kiru?.profilingContext?.beginTick(appCtx)
238
238
  }
239
239
  ctx.current = appCtx
240
240
  while (nextUnitOfWork) {
@@ -267,17 +267,17 @@ export function createScheduler(
267
267
  immediateEffectDirtiedRender = false
268
268
  consecutiveDirtyCount++
269
269
  if (__DEV__) {
270
- window.__kaioken?.profilingContext?.endTick(appCtx)
271
- window.__kaioken?.profilingContext?.emit("updateDirtied", appCtx)
270
+ window.__kiru?.profilingContext?.endTick(appCtx)
271
+ window.__kiru?.profilingContext?.emit("updateDirtied", appCtx)
272
272
  }
273
273
  return workLoop()
274
274
  }
275
275
  consecutiveDirtyCount = 0
276
276
 
277
277
  flushEffects(effectCallbacks.post)
278
- window.__kaioken!.emit("update", appCtx)
278
+ window.__kiru!.emit("update", appCtx)
279
279
  if (__DEV__) {
280
- window.__kaioken?.profilingContext?.emit("update", appCtx)
280
+ window.__kiru?.profilingContext?.emit("update", appCtx)
281
281
  }
282
282
  }
283
283
 
@@ -287,7 +287,7 @@ export function createScheduler(
287
287
  nextIdleEffects.shift()!(scheduler)
288
288
  }
289
289
  if (__DEV__) {
290
- window.__kaioken?.profilingContext?.endTick(appCtx)
290
+ window.__kiru?.profilingContext?.endTick(appCtx)
291
291
  }
292
292
  return
293
293
  }
@@ -362,12 +362,12 @@ export function createScheduler(
362
362
  renderChild = updateFunctionComponent(vNode as FunctionVNode)
363
363
  }
364
364
  } catch (error) {
365
- window.__kaioken?.emit(
365
+ window.__kiru?.emit(
366
366
  "error",
367
367
  appCtx,
368
368
  error instanceof Error ? error : new Error(String(error))
369
369
  )
370
- if (KaiokenError.isKaiokenError(error)) {
370
+ if (KiruError.isKiruError(error)) {
371
371
  if (error.customNodeStack) {
372
372
  setTimeout(() => {
373
373
  throw new Error(error.customNodeStack)
@@ -452,9 +452,9 @@ export function createScheduler(
452
452
  newChild = latest(type)(props)
453
453
  delete vNode.hmrUpdated
454
454
  if (++renderTryCount > CONSECUTIVE_DIRTY_LIMIT) {
455
- throw new KaiokenError({
455
+ throw new KiruError({
456
456
  message:
457
- "Too many re-renders. Kaioken limits the number of renders to prevent an infinite loop.",
457
+ "Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",
458
458
  fatal: true,
459
459
  vNode,
460
460
  })
@@ -484,7 +484,7 @@ export function createScheduler(
484
484
  }
485
485
  if (__DEV__) {
486
486
  // @ts-expect-error we apply vNode to the dom node
487
- vNode.dom.__kaiokenNode = vNode
487
+ vNode.dom.__kiruNode = vNode
488
488
  }
489
489
  }
490
490
  // text should _never_ have children
@@ -500,8 +500,8 @@ export function createScheduler(
500
500
 
501
501
  function checkForTooManyConsecutiveDirtyRenders() {
502
502
  if (consecutiveDirtyCount > CONSECUTIVE_DIRTY_LIMIT) {
503
- throw new KaiokenError(
504
- "Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kaioken limits the number of nested updates to prevent infinite loops."
503
+ throw new KiruError(
504
+ "Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops."
505
505
  )
506
506
  }
507
507
  }
@@ -111,7 +111,7 @@ export class Signal<T> {
111
111
  return () => signalSubsMap.get(this.$id)?.delete(cb)
112
112
  }
113
113
 
114
- notify(options?: { filter?: (sub: Function | Kaioken.VNode) => boolean }) {
114
+ notify(options?: { filter?: (sub: Function | Kiru.VNode) => boolean }) {
115
115
  signalSubsMap.get(this.$id)?.forEach((sub) => {
116
116
  if (options?.filter && !options.filter(sub)) return
117
117
  if (typeof sub === "function") {
@@ -3,7 +3,7 @@ import { type Signal } from "./base"
3
3
  export type ReadonlySignal<T> = Signal<T> & {
4
4
  readonly value: T
5
5
  }
6
- export type SignalSubscriber = Kaioken.VNode | Function
6
+ export type SignalSubscriber = Kiru.VNode | Function
7
7
 
8
8
  export type SignalValues<T extends readonly Signal<unknown>[]> = {
9
9
  [I in keyof T]: T[I] extends Signal<infer V> ? V : never
@@ -42,7 +42,7 @@ export class WatchEffect<const Deps extends readonly Signal<unknown>[] = []> {
42
42
  },
43
43
  }
44
44
  if ("window" in globalThis) {
45
- const signals = window.__kaioken!.HMRContext!.signals
45
+ const signals = window.__kiru!.HMRContext!.signals
46
46
  if (signals.isWaitingForNextWatchCall()) {
47
47
  signals.pushWatch(this as WatchEffect)
48
48
  }
@@ -62,7 +62,7 @@ export class WatchEffect<const Deps extends readonly Signal<unknown>[] = []> {
62
62
  // postpone execution during HMR
63
63
  if (
64
64
  "window" in globalThis &&
65
- window.__kaioken?.HMRContext?.isReplacement()
65
+ window.__kiru?.HMRContext?.isReplacement()
66
66
  ) {
67
67
  return queueMicrotask(() => {
68
68
  if (this.isRunning) {
@@ -5,7 +5,7 @@ import { renderMode } from "../globals.js"
5
5
 
6
6
  type EventsArray = (keyof GlobalEventHandlersEventMap)[]
7
7
 
8
- export const HYDRATION_BOUNDARY_MARKER = "kaioken:h-boundary"
8
+ export const HYDRATION_BOUNDARY_MARKER = "kiru:h-boundary"
9
9
  export const DEFAULT_INTERACTION_EVENTS = [
10
10
  "pointerdown",
11
11
  "keydown",
package/src/ssr/server.ts CHANGED
@@ -42,7 +42,7 @@ export function renderToReadableStream<T extends Record<string, unknown>>(
42
42
  function renderToStream_internal(
43
43
  state: RequestState,
44
44
  el: unknown,
45
- parent: Kaioken.VNode | null,
45
+ parent: Kiru.VNode | null,
46
46
  idx: number
47
47
  ): void {
48
48
  if (el === null) return
package/src/store.ts CHANGED
@@ -9,7 +9,7 @@ export { createStore }
9
9
  export type { Store, MethodFactory }
10
10
 
11
11
  type MethodFactory<T> = (
12
- setState: (setter: Kaioken.StateSetter<T>) => void,
12
+ setState: (setter: Kiru.StateSetter<T>) => void,
13
13
  getState: () => T
14
14
  ) => Record<string, Function>
15
15
 
@@ -32,7 +32,7 @@ type Subscribe<T> = {
32
32
 
33
33
  type Store<T, U extends Record<string, Function>> = StoreHook<T, U> & {
34
34
  getState: () => T
35
- setState: (setter: Kaioken.StateSetter<T>) => void
35
+ setState: (setter: Kiru.StateSetter<T>) => void
36
36
  methods: U
37
37
  subscribe: Subscribe<T>
38
38
  }
@@ -51,8 +51,8 @@ type NodeState = {
51
51
  type InternalStoreState<T, U extends MethodFactory<T>> = {
52
52
  value: T
53
53
  epoch: number
54
- subscribers: Set<Kaioken.VNode | Function>
55
- nodeStateMap: WeakMap<Kaioken.VNode, NodeState>
54
+ subscribers: Set<Kiru.VNode | Function>
55
+ nodeStateMap: WeakMap<Kiru.VNode, NodeState>
56
56
  methods: ReturnType<U>
57
57
  }
58
58
 
@@ -65,8 +65,8 @@ function createStore<T, U extends MethodFactory<T>>(
65
65
  current: {
66
66
  value: initial,
67
67
  epoch: 0,
68
- subscribers: new Set<Kaioken.VNode | Function>(),
69
- nodeStateMap: new WeakMap<Kaioken.VNode, NodeState>(),
68
+ subscribers: new Set<Kiru.VNode | Function>(),
69
+ nodeStateMap: new WeakMap<Kiru.VNode, NodeState>(),
70
70
  methods: null as any as ReturnType<U>,
71
71
  } satisfies InternalStoreState<T, U>,
72
72
  }
@@ -76,7 +76,7 @@ function createStore<T, U extends MethodFactory<T>>(
76
76
 
77
77
  const getState = () => state.current.value
78
78
 
79
- const setState = (setter: Kaioken.StateSetter<T>) => {
79
+ const setState = (setter: Kiru.StateSetter<T>) => {
80
80
  state.current.value =
81
81
  typeof setter === "function"
82
82
  ? (setter as Function)(state.current.value)
package/src/swr.ts CHANGED
@@ -88,7 +88,7 @@ export type SWROptions = {
88
88
  refetchWhenOffline?: boolean
89
89
  }
90
90
 
91
- type SWRHook = Kaioken.Hook<{
91
+ type SWRHook = Kiru.Hook<{
92
92
  strKey: string
93
93
  options: SWROptions
94
94
  update: () => void
@@ -107,7 +107,7 @@ let SWR_GLOBAL_CACHE: SWRCache
107
107
  let IS_ONLINE = false
108
108
 
109
109
  if ("window" in globalThis) {
110
- SWR_GLOBAL_CACHE = window.__kaioken!.globalState[Symbol.for("SWR_GLOBAL")] ??=
110
+ SWR_GLOBAL_CACHE = window.__kiru!.globalState[Symbol.for("SWR_GLOBAL")] ??=
111
111
  new Map()
112
112
 
113
113
  IS_ONLINE = navigator.onLine
package/src/types.dom.ts CHANGED
@@ -349,7 +349,7 @@ type NoChildElementElement =
349
349
  | HTMLTextAreaElement
350
350
 
351
351
  declare global {
352
- namespace Kaioken {
352
+ namespace Kiru {
353
353
  type DOMEvent<E = Event, C = unknown, T = unknown> = Omit<
354
354
  E,
355
355
  "target" | "currentTarget"
package/src/types.ts CHANGED
@@ -5,7 +5,7 @@ import type {
5
5
  $FRAGMENT,
6
6
  $HYDRATION_BOUNDARY,
7
7
  } from "./constants"
8
- import type { KaiokenGlobalContext } from "./globalContext"
8
+ import type { KiruGlobalContext } from "./globalContext"
9
9
  import type {
10
10
  GlobalAttributes,
11
11
  HtmlElementAttributes,
@@ -50,10 +50,10 @@ type ElementMap = {
50
50
  [Tag in keyof HtmlElementAttributes]: SignalableHtmlElementAttributes<Tag> &
51
51
  SignalableGlobalAttributes &
52
52
  SignalableAriaProps &
53
- Kaioken.EventAttributes<HTMLTagToElement<Tag>> &
53
+ Kiru.EventAttributes<HTMLTagToElement<Tag>> &
54
54
  JSX.ElementAttributes & {
55
55
  ref?:
56
- | Kaioken.Ref<HTMLTagToElement<Tag>>
56
+ | Kiru.Ref<HTMLTagToElement<Tag>>
57
57
  | SignalClass<HTMLTagToElement<Tag> | null>
58
58
  }
59
59
  } & {
@@ -61,10 +61,10 @@ type ElementMap = {
61
61
  SignalableSvgGlobalAttributes &
62
62
  SignalableGlobalAttributes &
63
63
  SignalableAriaProps &
64
- Kaioken.EventAttributes<SVGTagToElement<Tag>> &
64
+ Kiru.EventAttributes<SVGTagToElement<Tag>> &
65
65
  JSX.ElementAttributes & {
66
66
  ref?:
67
- | Kaioken.Ref<SVGTagToElement<Tag>>
67
+ | Kiru.Ref<SVGTagToElement<Tag>>
68
68
  | SignalClass<SVGTagToElement<Tag> | null>
69
69
  }
70
70
  } & {
@@ -73,7 +73,7 @@ type ElementMap = {
73
73
 
74
74
  declare global {
75
75
  interface Window {
76
- __kaioken: KaiokenGlobalContext | undefined
76
+ __kiru: KiruGlobalContext | undefined
77
77
  }
78
78
  namespace JSX {
79
79
  interface IntrinsicElements extends ElementMap {}
@@ -97,9 +97,9 @@ declare global {
97
97
 
98
98
  type Element =
99
99
  | Element[]
100
- | Kaioken.VNode
100
+ | Kiru.VNode
101
101
  | PrimitiveChild
102
- | Kaioken.Signal<PrimitiveChild>
102
+ | Kiru.Signal<PrimitiveChild>
103
103
 
104
104
  type ElementAttributes = {
105
105
  key?: JSX.ElementKey
@@ -107,10 +107,10 @@ declare global {
107
107
  innerHTML?:
108
108
  | string
109
109
  | number
110
- | Kaioken.Signal<string | number | null | undefined>
110
+ | Kiru.Signal<string | number | null | undefined>
111
111
  }
112
112
  }
113
- namespace Kaioken {
113
+ namespace Kiru {
114
114
  type ProviderProps<T> = {
115
115
  value: T
116
116
  children?: JSX.Children | ((value: T) => JSX.Element)
@@ -130,7 +130,7 @@ declare global {
130
130
  displayName?: string
131
131
  }
132
132
  type FCProps<T = {}> = T & { children?: JSX.Children }
133
- type InferProps<T> = T extends Kaioken.FC<infer P> ? P : never
133
+ type InferProps<T> = T extends Kiru.FC<infer P> ? P : never
134
134
 
135
135
  type HookDevtoolsProvisions<T extends Record<string, any>> = {
136
136
  get: () => T
@@ -176,7 +176,7 @@ declare global {
176
176
  [key: string]: any
177
177
  children?: unknown
178
178
  key?: JSX.ElementKey
179
- ref?: Kaioken.Ref<unknown>
179
+ ref?: Kiru.Ref<unknown>
180
180
  }
181
181
  index: number
182
182
  depth: number
@@ -204,6 +204,6 @@ declare global {
204
204
  }
205
205
 
206
206
  interface Element {
207
- __kaiokenNode?: Kaioken.VNode
207
+ __kiruNode?: Kiru.VNode
208
208
  }
209
209
  }
@@ -6,13 +6,13 @@ export type SomeElement = HTMLElement | SVGElement
6
6
  export type SomeDom = HTMLElement | SVGElement | Text
7
7
  export type MaybeDom = SomeDom | undefined
8
8
 
9
- type VNode = Kaioken.VNode
9
+ type VNode = Kiru.VNode
10
10
 
11
11
  export type FunctionVNode = Omit<VNode, "type"> & {
12
12
  type: (...args: any) => any
13
13
  }
14
14
  export type ExoticVNode = Omit<VNode, "type"> & {
15
- type: Kaioken.ExoticSymbol
15
+ type: Kiru.ExoticSymbol
16
16
  }
17
17
  export type ElementVNode = Omit<VNode, "dom" | "type"> & {
18
18
  dom: SomeElement
@@ -23,11 +23,11 @@ export type DomVNode = Omit<VNode, "dom" | "type"> & {
23
23
  type: "#text" | (string & {})
24
24
  }
25
25
 
26
- export type ContextProviderNode<T> = Kaioken.VNode & {
26
+ export type ContextProviderNode<T> = Kiru.VNode & {
27
27
  type: typeof $CONTEXT_PROVIDER
28
- props: { value: T; ctx: Kaioken.Context<T>; dependents: Set<Kaioken.VNode> }
28
+ props: { value: T; ctx: Kiru.Context<T>; dependents: Set<Kiru.VNode> }
29
29
  }
30
- export type HydrationBoundaryNode = Kaioken.VNode & {
30
+ export type HydrationBoundaryNode = Kiru.VNode & {
31
31
  type: typeof $HYDRATION_BOUNDARY
32
32
  props: { mode: HydrationBoundaryMode }
33
33
  }