kiru 0.49.2 → 0.50.0-preview.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 (143) hide show
  1. package/dist/components/errorBoundary.d.ts +7 -0
  2. package/dist/components/errorBoundary.d.ts.map +1 -0
  3. package/dist/components/errorBoundary.js +6 -0
  4. package/dist/components/errorBoundary.js.map +1 -0
  5. package/dist/components/index.d.ts +2 -0
  6. package/dist/components/index.d.ts.map +1 -1
  7. package/dist/components/index.js +2 -0
  8. package/dist/components/index.js.map +1 -1
  9. package/dist/components/lazy.d.ts.map +1 -1
  10. package/dist/components/lazy.js +11 -136
  11. package/dist/components/lazy.js.map +1 -1
  12. package/dist/components/suspense.d.ts +34 -0
  13. package/dist/components/suspense.d.ts.map +1 -0
  14. package/dist/components/suspense.js +110 -0
  15. package/dist/components/suspense.js.map +1 -0
  16. package/dist/constants.d.ts +4 -2
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +4 -2
  19. package/dist/constants.js.map +1 -1
  20. package/dist/hmr.d.ts +1 -0
  21. package/dist/hmr.d.ts.map +1 -1
  22. package/dist/hmr.js +7 -0
  23. package/dist/hmr.js.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/recursiveRender.d.ts +6 -0
  29. package/dist/recursiveRender.d.ts.map +1 -0
  30. package/dist/recursiveRender.js +109 -0
  31. package/dist/recursiveRender.js.map +1 -0
  32. package/dist/renderToString.d.ts.map +1 -1
  33. package/dist/renderToString.js +10 -59
  34. package/dist/renderToString.js.map +1 -1
  35. package/dist/router/config.d.ts +3 -0
  36. package/dist/router/config.d.ts.map +1 -0
  37. package/dist/router/config.js +13 -0
  38. package/dist/router/config.js.map +1 -0
  39. package/dist/router/context.d.ts +15 -0
  40. package/dist/router/context.d.ts.map +1 -0
  41. package/dist/router/context.js +11 -0
  42. package/dist/router/context.js.map +1 -0
  43. package/dist/router/errors.d.ts +4 -0
  44. package/dist/router/errors.d.ts.map +1 -0
  45. package/dist/router/errors.js +7 -0
  46. package/dist/router/errors.js.map +1 -0
  47. package/dist/router/fileRouter.d.ts +48 -0
  48. package/dist/router/fileRouter.d.ts.map +1 -0
  49. package/dist/router/fileRouter.js +311 -0
  50. package/dist/router/fileRouter.js.map +1 -0
  51. package/dist/router/globals.d.ts +5 -0
  52. package/dist/router/globals.d.ts.map +1 -0
  53. package/dist/router/globals.js +4 -0
  54. package/dist/router/globals.js.map +1 -0
  55. package/dist/router/index.d.ts +7 -0
  56. package/dist/router/index.d.ts.map +1 -0
  57. package/dist/router/index.js +7 -0
  58. package/dist/router/index.js.map +1 -0
  59. package/dist/router/link.d.ts +8 -0
  60. package/dist/router/link.d.ts.map +1 -0
  61. package/dist/router/link.js +15 -0
  62. package/dist/router/link.js.map +1 -0
  63. package/dist/router/types.d.ts +63 -0
  64. package/dist/router/types.d.ts.map +1 -0
  65. package/dist/router/types.internal.d.ts +12 -0
  66. package/dist/router/types.internal.d.ts.map +1 -0
  67. package/dist/router/types.internal.js +2 -0
  68. package/dist/router/types.internal.js.map +1 -0
  69. package/dist/router/types.js +2 -0
  70. package/dist/router/types.js.map +1 -0
  71. package/dist/scheduler.d.ts.map +1 -1
  72. package/dist/scheduler.js +35 -10
  73. package/dist/scheduler.js.map +1 -1
  74. package/dist/ssr/server.d.ts +4 -1
  75. package/dist/ssr/server.d.ts.map +1 -1
  76. package/dist/ssr/server.js +50 -82
  77. package/dist/ssr/server.js.map +1 -1
  78. package/dist/types.d.ts +10 -2
  79. package/dist/types.d.ts.map +1 -1
  80. package/dist/types.utils.d.ts +6 -7
  81. package/dist/types.utils.d.ts.map +1 -1
  82. package/dist/utils/runtime.d.ts +1 -1
  83. package/dist/utils/runtime.d.ts.map +1 -1
  84. package/dist/utils/runtime.js.map +1 -1
  85. package/dist/utils/vdom.d.ts +3 -1
  86. package/dist/utils/vdom.d.ts.map +1 -1
  87. package/dist/utils/vdom.js +6 -5
  88. package/dist/utils/vdom.js.map +1 -1
  89. package/package.json +4 -8
  90. package/src/components/errorBoundary.ts +16 -0
  91. package/src/components/index.ts +2 -0
  92. package/src/components/lazy.ts +12 -169
  93. package/src/components/suspense.ts +191 -0
  94. package/src/constants.ts +6 -2
  95. package/src/hmr.ts +8 -0
  96. package/src/index.ts +1 -0
  97. package/src/recursiveRender.ts +127 -0
  98. package/src/renderToString.ts +10 -73
  99. package/src/router/config.ts +15 -0
  100. package/src/router/context.ts +23 -0
  101. package/src/router/errors.ts +6 -0
  102. package/src/router/fileRouter.ts +475 -0
  103. package/src/router/globals.ts +5 -0
  104. package/src/router/index.ts +6 -0
  105. package/src/router/link.ts +32 -0
  106. package/src/router/types.internal.ts +14 -0
  107. package/src/router/types.ts +81 -0
  108. package/src/scheduler.ts +45 -12
  109. package/src/ssr/server.ts +58 -95
  110. package/src/types.ts +11 -2
  111. package/src/types.utils.ts +6 -11
  112. package/src/utils/runtime.ts +1 -1
  113. package/src/utils/vdom.ts +11 -4
  114. package/dist/components/router/index.d.ts +0 -3
  115. package/dist/components/router/index.d.ts.map +0 -1
  116. package/dist/components/router/index.js +0 -3
  117. package/dist/components/router/index.js.map +0 -1
  118. package/dist/components/router/route.d.ts +0 -46
  119. package/dist/components/router/route.d.ts.map +0 -1
  120. package/dist/components/router/route.js +0 -8
  121. package/dist/components/router/route.js.map +0 -1
  122. package/dist/components/router/router.d.ts +0 -62
  123. package/dist/components/router/router.d.ts.map +0 -1
  124. package/dist/components/router/router.js +0 -181
  125. package/dist/components/router/router.js.map +0 -1
  126. package/dist/components/router/routerUtils.d.ts +0 -5
  127. package/dist/components/router/routerUtils.d.ts.map +0 -1
  128. package/dist/components/router/routerUtils.js +0 -39
  129. package/dist/components/router/routerUtils.js.map +0 -1
  130. package/dist/ssr/hydrationBoundary.d.ts +0 -27
  131. package/dist/ssr/hydrationBoundary.d.ts.map +0 -1
  132. package/dist/ssr/hydrationBoundary.js +0 -30
  133. package/dist/ssr/hydrationBoundary.js.map +0 -1
  134. package/dist/ssr/index.d.ts +0 -2
  135. package/dist/ssr/index.d.ts.map +0 -1
  136. package/dist/ssr/index.js +0 -2
  137. package/dist/ssr/index.js.map +0 -1
  138. package/src/components/router/index.ts +0 -2
  139. package/src/components/router/route.ts +0 -51
  140. package/src/components/router/router.ts +0 -280
  141. package/src/components/router/routerUtils.ts +0 -49
  142. package/src/ssr/hydrationBoundary.ts +0 -63
  143. package/src/ssr/index.ts +0 -1
package/src/ssr/server.ts CHANGED
@@ -1,109 +1,72 @@
1
1
  import { Readable } from "node:stream"
2
2
  import { Fragment } from "../element.js"
3
- import { renderMode, node } from "../globals.js"
4
- import {
5
- isVNode,
6
- encodeHtmlEntities,
7
- propsToElementAttributes,
8
- isExoticType,
9
- assertValidElementProps,
10
- } from "../utils/index.js"
11
- import { Signal } from "../signals/base.js"
12
- import { $HYDRATION_BOUNDARY, voidElements } from "../constants.js"
13
- import { HYDRATION_BOUNDARY_MARKER } from "./hydrationBoundary.js"
3
+ import { renderMode } from "../globals.js"
4
+ import { PREFETCHED_DATA_EVENT } from "../constants.js"
14
5
  import { __DEV__ } from "../env.js"
6
+ import { recursiveRender, RecursiveRenderContext } from "../recursiveRender.js"
15
7
 
16
- export function renderToReadableStream(element: JSX.Element): Readable {
17
- const prev = renderMode.current
18
- renderMode.current = "stream"
19
- const stream = new Readable()
20
- const rootNode = Fragment({ children: element })
8
+ const PREFETCH_EVENTS_SETUP = `
9
+ <script type="text/javascript">
10
+ const d = document,
11
+ m = (window["${PREFETCHED_DATA_EVENT}"] ??= new Map());
12
+ d.querySelectorAll("[x-data]").forEach((p) => {
13
+ const id = p.getAttribute("id");
14
+ const { data, error } = JSON.parse(p.innerHTML);
15
+ m.set(id, { data, error });
16
+ const event = new CustomEvent("${PREFETCHED_DATA_EVENT}", { detail: { id, data, error } });
17
+ window.dispatchEvent(event);
18
+ p.remove();
19
+ });
20
+ d.currentScript.remove()
21
+ </script>
22
+ `
21
23
 
22
- renderToStream_internal(stream, rootNode, null, 0)
23
- stream.push(null)
24
- renderMode.current = prev
24
+ export function renderToReadableStream(element: JSX.Element): {
25
+ immediate: string
26
+ stream: Readable
27
+ } {
28
+ const stream = new Readable({ read() {} })
29
+ const rootNode = Fragment({ children: element })
30
+ const prefetchPromises = new Set<Kiru.StatefulPromise<unknown>>()
31
+ const pendingWritePromises: Promise<unknown>[] = []
25
32
 
26
- return stream
27
- }
33
+ let immediate = ""
28
34
 
29
- function renderToStream_internal(
30
- stream: Readable,
31
- el: unknown,
32
- parent: Kiru.VNode | null,
33
- idx: number
34
- ): void {
35
- if (el === null) return
36
- if (el === undefined) return
37
- if (typeof el === "boolean") return
38
- if (typeof el === "string") {
39
- stream.push(encodeHtmlEntities(el))
40
- return
41
- }
42
- if (typeof el === "number" || typeof el === "bigint") {
43
- stream.push(el.toString())
44
- return
45
- }
46
- if (el instanceof Array) {
47
- el.forEach((c, i) => renderToStream_internal(stream, c, parent, i))
48
- return
49
- }
50
- if (Signal.isSignal(el)) {
51
- stream.push(String(el.peek()))
52
- return
53
- }
54
- if (!isVNode(el)) {
55
- stream.push(String(el))
56
- return
57
- }
58
- el.parent = parent
59
- el.depth = (parent?.depth ?? -1) + 1
60
- el.index = idx
61
- const { type, props = {} } = el
62
- const children = props.children
63
- if (type === "#text") {
64
- stream.push(encodeHtmlEntities(props.nodeValue ?? ""))
65
- return
66
- }
67
- if (isExoticType(type)) {
68
- if (type === $HYDRATION_BOUNDARY) {
69
- stream.push(`<!--${HYDRATION_BOUNDARY_MARKER}-->`)
70
- renderToStream_internal(stream, children, el, idx)
71
- stream.push(`<!--/${HYDRATION_BOUNDARY_MARKER}-->`)
72
- return
73
- }
74
- return renderToStream_internal(stream, children, el, idx)
75
- }
35
+ const ctx: RecursiveRenderContext = {
36
+ write: (chunk) => (immediate += chunk),
37
+ onPending(data) {
38
+ for (const promise of data) {
39
+ if (prefetchPromises.has(promise)) continue
40
+ prefetchPromises.add(promise)
76
41
 
77
- if (typeof type !== "string") {
78
- node.current = el
79
- const res = type(props)
80
- node.current = null
81
- return renderToStream_internal(stream, res, parent, idx)
82
- }
42
+ const writePromise = promise
43
+ .then(() => ({ data: promise.value }))
44
+ .catch(() => ({ error: promise.error?.message }))
45
+ .then((value) => {
46
+ const content = JSON.stringify(value)
47
+ stream.push(
48
+ `<script id="${promise.id}" x-data type="application/json">${content}</script>`
49
+ )
50
+ })
83
51
 
84
- if (__DEV__) {
85
- assertValidElementProps(el)
52
+ pendingWritePromises.push(writePromise)
53
+ }
54
+ },
86
55
  }
87
- const attrs = propsToElementAttributes(props)
88
- stream.push(`<${type}${attrs.length ? ` ${attrs}` : ""}>`)
89
56
 
90
- if (!voidElements.has(type)) {
91
- if ("innerHTML" in props) {
92
- stream.push(
93
- String(
94
- Signal.isSignal(props.innerHTML)
95
- ? props.innerHTML.peek()
96
- : props.innerHTML
97
- )
98
- )
99
- } else {
100
- if (Array.isArray(children)) {
101
- children.forEach((c, i) => renderToStream_internal(stream, c, el, i))
102
- } else {
103
- renderToStream_internal(stream, children, el, 0)
104
- }
105
- }
57
+ const prev = renderMode.current
58
+ renderMode.current = "stream"
59
+ recursiveRender(ctx, rootNode, null, 0)
60
+ renderMode.current = prev
106
61
 
107
- stream.push(`</${type}>`)
62
+ if (pendingWritePromises.length > 0) {
63
+ Promise.all(pendingWritePromises).then(() => {
64
+ stream.push(PREFETCH_EVENTS_SETUP)
65
+ stream.push(null)
66
+ })
67
+ } else {
68
+ stream.push(null)
108
69
  }
70
+
71
+ return { immediate, stream }
109
72
  }
package/src/types.ts CHANGED
@@ -2,8 +2,8 @@ import type { ReadonlySignal, Signal as SignalClass } from "./signals"
2
2
  import type {
3
3
  $CONTEXT,
4
4
  $CONTEXT_PROVIDER,
5
+ $ERROR_BOUNDARY,
5
6
  $FRAGMENT,
6
- $HYDRATION_BOUNDARY,
7
7
  } from "./constants"
8
8
  import type { KiruGlobalContext } from "./globalContext"
9
9
  import type {
@@ -167,6 +167,15 @@ declare global {
167
167
 
168
168
  type Ref<T> = RefCallback<T> | RefObject<T> | null | undefined
169
169
 
170
+ interface PromiseState<T> {
171
+ id: string
172
+ state: "pending" | "fulfilled" | "rejected"
173
+ value?: T
174
+ error?: Error
175
+ }
176
+
177
+ interface StatefulPromise<T> extends Promise<T>, PromiseState<T> {}
178
+
170
179
  type RenderMode = "dom" | "hydrate" | "string" | "stream"
171
180
 
172
181
  type StateSetter<T> = T | ((prev: T) => T)
@@ -176,7 +185,7 @@ declare global {
176
185
  type ExoticSymbol =
177
186
  | typeof $FRAGMENT
178
187
  | typeof $CONTEXT_PROVIDER
179
- | typeof $HYDRATION_BOUNDARY
188
+ | typeof $ERROR_BOUNDARY
180
189
 
181
190
  interface VNode {
182
191
  app?: AppContext
@@ -1,10 +1,6 @@
1
- import type {
2
- $CONTEXT_PROVIDER,
3
- $FRAGMENT,
4
- $HYDRATION_BOUNDARY,
5
- } from "./constants"
6
- import type { HydrationBoundaryMode } from "./ssr/hydrationBoundary"
1
+ import type { $CONTEXT_PROVIDER, $ERROR_BOUNDARY, $FRAGMENT } from "./constants"
7
2
  import type { Signal } from "./signals"
3
+ import type { ErrorBoundaryProps } from "./components/errorBoundary"
8
4
 
9
5
  export type SomeElement = HTMLElement | SVGElement
10
6
  export type SomeDom = HTMLElement | SVGElement | Text
@@ -33,11 +29,10 @@ export interface ContextProviderNode<T> extends Kiru.VNode {
33
29
  }
34
30
  }
35
31
 
36
- export interface HydrationBoundaryNode extends Kiru.VNode {
37
- type: typeof $HYDRATION_BOUNDARY
38
- props: Kiru.VNode["props"] & {
39
- mode: HydrationBoundaryMode
40
- }
32
+ export interface ErrorBoundaryNode extends Kiru.VNode {
33
+ type: typeof $ERROR_BOUNDARY
34
+ props: ErrorBoundaryProps
35
+ error?: Error
41
36
  }
42
37
 
43
38
  export interface FragmentNode extends Kiru.VNode {
@@ -7,7 +7,7 @@ export { latest, sideEffectsEnabled }
7
7
  * This is a no-op in production. It is used to get the latest
8
8
  * iteration of a component or signal after HMR has happened.
9
9
  */
10
- function latest<T>(thing: T): T {
10
+ function latest<T extends Exclude<object, null>>(thing: T): T {
11
11
  let tgt: any = thing
12
12
  if (__DEV__) {
13
13
  while ("__next" in tgt) {
package/src/utils/vdom.ts CHANGED
@@ -3,14 +3,15 @@ import {
3
3
  FLAG_DELETION,
4
4
  $FRAGMENT,
5
5
  $CONTEXT_PROVIDER,
6
- $HYDRATION_BOUNDARY,
7
6
  FLAG_PLACEMENT,
8
7
  FLAG_UPDATE,
8
+ $ERROR_BOUNDARY,
9
9
  } from "../constants.js"
10
10
  import { createElement } from "../index.js"
11
11
  import { KiruError } from "../error.js"
12
12
  import { node } from "../globals.js"
13
13
  import type { AppContext } from "../appContext.js"
14
+ import type { ErrorBoundaryNode } from "../types.utils.js"
14
15
 
15
16
  export {
16
17
  cloneVNode,
@@ -27,6 +28,7 @@ export {
27
28
  commitSnapshot,
28
29
  traverseApply,
29
30
  findParent,
31
+ findParentErrorBoundary,
30
32
  assertValidElementProps,
31
33
  isValidElementKeyProp,
32
34
  isValidElementRefProp,
@@ -54,9 +56,7 @@ function isVNode(thing: unknown): thing is Kiru.VNode {
54
56
 
55
57
  function isExoticType(type: Kiru.VNode["type"]): type is Kiru.ExoticSymbol {
56
58
  return (
57
- type === $FRAGMENT ||
58
- type === $CONTEXT_PROVIDER ||
59
- type === $HYDRATION_BOUNDARY
59
+ type === $FRAGMENT || type === $CONTEXT_PROVIDER || type === $ERROR_BOUNDARY
60
60
  )
61
61
  }
62
62
 
@@ -153,6 +153,13 @@ function findParent(vNode: Kiru.VNode, predicate: (n: Kiru.VNode) => boolean) {
153
153
  return null
154
154
  }
155
155
 
156
+ function findParentErrorBoundary(vNode: Kiru.VNode): ErrorBoundaryNode | null {
157
+ return findParent(
158
+ vNode,
159
+ (n) => n.type === $ERROR_BOUNDARY
160
+ ) as ErrorBoundaryNode | null
161
+ }
162
+
156
163
  function assertValidElementProps(vNode: Kiru.VNode) {
157
164
  if ("children" in vNode.props && vNode.props.innerHTML) {
158
165
  throw new KiruError({
@@ -1,3 +0,0 @@
1
- export { Router, useRouter, navigate, Link, type LinkProps } from "./router.js";
2
- export { Route } from "./route.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
@@ -1,3 +0,0 @@
1
- export { Router, useRouter, navigate, Link } from "./router.js";
2
- export { Route } from "./route.js";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
@@ -1,46 +0,0 @@
1
- interface RouteProps {
2
- /**
3
- * The path to match.
4
- * @example
5
- * ```tsx
6
- * <Router>
7
- * <Route path="/" element={<h1>Home</h1>} />
8
- * <Route path="/:id" element={<UserProfile />} />
9
- * </Router>
10
- * //
11
- * const UserProfile = () => {
12
- * const router = useRouter()
13
- * const { id } = router.params
14
- * return <h1>{id}</h1>
15
- * }
16
- * ```
17
- */
18
- path: string;
19
- /**
20
- * Allow url with additional segments being matched. Useful with nested routers.
21
- * @example
22
- * ```tsx
23
- * <Route path="/profile" fallthrough element={<UserProfile />} />
24
- * //
25
- * const UserProfile = () => {
26
- * return (
27
- * <Router>
28
- * <Route path="/" element={<UserDetails />} />
29
- * <Route path="/update" element={<UserUpdateForm />} />
30
- * </Router>
31
- * )
32
- * }
33
- * ```
34
- */
35
- fallthrough?: boolean;
36
- /**
37
- * The element to render.
38
- */
39
- element: JSX.Element;
40
- }
41
- export declare function Route({ element }: RouteProps): JSX.Element;
42
- export declare function isRoute(thing: unknown): thing is Kiru.VNode & {
43
- props: RouteProps;
44
- };
45
- export {};
46
- //# sourceMappingURL=route.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/components/router/route.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IAClB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,OAAO,CAAA;CACrB;AACD,wBAAgB,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,UAAU,eAE5C;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAE7C"}
@@ -1,8 +0,0 @@
1
- import { isVNode } from "../../utils/index.js";
2
- export function Route({ element }) {
3
- return element;
4
- }
5
- export function isRoute(thing) {
6
- return isVNode(thing) && thing.type === Route;
7
- }
8
- //# sourceMappingURL=route.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/components/router/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AA0C9C,MAAM,UAAU,KAAK,CAAC,EAAE,OAAO,EAAc;IAC3C,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAAc;IAEd,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAA;AAC/C,CAAC"}
@@ -1,62 +0,0 @@
1
- import type { ElementProps } from "../../types.js";
2
- export interface LinkProps extends Omit<ElementProps<"a">, "href"> {
3
- /**
4
- * The relative path to navigate to. If `inherit` is true,
5
- * the path will be relative to the parent <Route> component.
6
- */
7
- to: string;
8
- /**
9
- * Event handler called when the link is clicked.
10
- * If you call `e.preventDefault()`, the navigation will not happen.
11
- */
12
- onclick?: (e: Event) => void;
13
- /**
14
- * Specifies whether to replace the current history entry
15
- * instead of adding a new one.
16
- */
17
- replace?: boolean;
18
- /**
19
- * If true, the path used for `to` will be relative to the parent <Route> component.
20
- * @default false
21
- */
22
- inherit?: boolean;
23
- }
24
- export declare function Link({ to, onclick, replace, inherit, ...props }: LinkProps): Kiru.VNode;
25
- declare function setQuery(query: Record<string, string>): void;
26
- /**
27
- * Gets state and methods provided by a parent <Router>.
28
- *
29
- * @see https://kirujs.dev/docs/api/routing
30
- */
31
- export declare function useRouter(): {
32
- viewTransition: Kiru.RefObject<ViewTransition>;
33
- params: Record<string, string>;
34
- query: Record<string, string>;
35
- setQuery: typeof setQuery;
36
- };
37
- export declare function navigate(to: string, options?: {
38
- replace?: boolean;
39
- }): null;
40
- export interface RouterProps {
41
- /**
42
- * Base path for all routes in this router. Use this
43
- * to add a prefix to all routes
44
- */
45
- basePath?: string;
46
- /**
47
- * Enable ViewTransition API for navigations
48
- */
49
- transition?: boolean;
50
- /**
51
- * Children to render - the only supported children are <Route> components
52
- */
53
- children?: JSX.Children;
54
- }
55
- /**
56
- * Main router component.
57
- *
58
- * @see https://kirujs.dev/docs/api/routing
59
- */
60
- export declare function Router(props: RouterProps): JSX.Element;
61
- export {};
62
- //# sourceMappingURL=router.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/components/router/router.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQlD,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAChE;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,cAuB1E;AAuBD,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAK9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS;;;;;EAGxB;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,QAwBnE;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAA;CACxB;AAMD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,eA0HxC"}
@@ -1,181 +0,0 @@
1
- import { createElement } from "../../element.js";
2
- import { useState, useMemo, useContext, useLayoutEffect, useRef, } from "../../hooks/index.js";
3
- import { __DEV__ } from "../../env.js";
4
- import { createContext } from "../../context.js";
5
- import { isRoute } from "./route.js";
6
- import { noop } from "../../utils/index.js";
7
- import { node } from "../../globals.js";
8
- import { flushSync, nextIdle } from "../../scheduler.js";
9
- import { parsePathParams, parseSearchParams, routeMatchesPath, } from "./routerUtils.js";
10
- export function Link({ to, onclick, replace, inherit, ...props }) {
11
- const router = useContext(RouterContext, false);
12
- const href = useMemo(() => {
13
- if (!inherit || router.isDefault)
14
- return to;
15
- const parentPath = Object.entries(router.params).reduce((acc, [k, v]) => acc.replace(`:${k}`, v), router.routePath);
16
- if (to === "/")
17
- return parentPath;
18
- return (parentPath + to).replaceAll(/\/+/g, "/");
19
- }, [router.params, to, inherit]);
20
- return createElement("a", {
21
- ...props,
22
- href,
23
- onclick: (e) => {
24
- onclick?.(e);
25
- if (e.defaultPrevented)
26
- return;
27
- e.preventDefault();
28
- navigate(href, { replace });
29
- },
30
- });
31
- }
32
- const RouterContext = createContext({
33
- transitionsEnabled: false,
34
- viewTransition: { current: null },
35
- queueSyncNav: noop,
36
- params: {},
37
- query: {},
38
- routePath: "/",
39
- isDefault: true,
40
- });
41
- RouterContext.displayName = "Router";
42
- function setQuery(query) {
43
- const url = new URL(window.location.href);
44
- Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
45
- window.history.pushState({}, "", url.toString());
46
- window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
47
- }
48
- /**
49
- * Gets state and methods provided by a parent <Router>.
50
- *
51
- * @see https://kirujs.dev/docs/api/routing
52
- */
53
- export function useRouter() {
54
- const { viewTransition, params, query } = useContext(RouterContext);
55
- return { viewTransition, params, query, setQuery };
56
- }
57
- export function navigate(to, options) {
58
- const doNav = () => {
59
- window.history[options?.replace ? "replaceState" : "pushState"]({}, "", to);
60
- window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
61
- };
62
- // not called during render, just do the navigation
63
- if (!node.current)
64
- return doNav(), null;
65
- const routerCtx = useContext(RouterContext, false);
66
- if (routerCtx.isDefault) {
67
- /**
68
- * called from a non-router-decendant - postpone
69
- * until next tick to avoid race conditions
70
- */
71
- return nextIdle(doNav), null;
72
- }
73
- /**
74
- * set the value of our router's syncNavCallback,
75
- * causing it to be executed synchronously
76
- * during the router's useLayoutEffect.
77
- * consecutive calls to navigate will overwrite
78
- * the previous value.
79
- */
80
- return routerCtx.queueSyncNav(doNav), null;
81
- }
82
- const initLoc = () => ({
83
- pathname: window.location.pathname,
84
- search: window.location.search,
85
- });
86
- /**
87
- * Main router component.
88
- *
89
- * @see https://kirujs.dev/docs/api/routing
90
- */
91
- export function Router(props) {
92
- const viewTransition = useRef(null);
93
- const syncNavCallback = useRef(null);
94
- const parentRouterContext = useContext(RouterContext, false);
95
- const dynamicParentPath = parentRouterContext.isDefault
96
- ? null
97
- : parentRouterContext.routePath;
98
- const dynamicParentPathSegments = useMemo(() => dynamicParentPath?.split("/").filter(Boolean) || [], [dynamicParentPath]);
99
- const [loc, setLoc] = useState(initLoc);
100
- const query = useMemo(() => parseSearchParams(loc.search), [loc.search]);
101
- const realPathSegments = useMemo(() => loc.pathname.split("/").filter(Boolean), [loc.pathname]);
102
- useLayoutEffect(() => {
103
- const handler = () => {
104
- if (!document.startViewTransition ||
105
- !props.transition ||
106
- !parentRouterContext.isDefault) {
107
- return setLoc({
108
- pathname: window.location.pathname,
109
- search: window.location.search,
110
- });
111
- }
112
- viewTransition.current = document.startViewTransition(() => {
113
- setLoc({
114
- pathname: window.location.pathname,
115
- search: window.location.search,
116
- });
117
- flushSync();
118
- });
119
- viewTransition.current.finished.then(() => {
120
- viewTransition.current = null;
121
- });
122
- };
123
- window.addEventListener("popstate", handler);
124
- return () => window.removeEventListener("popstate", handler);
125
- }, []);
126
- useLayoutEffect(() => {
127
- if (syncNavCallback.current) {
128
- syncNavCallback.current();
129
- syncNavCallback.current = null;
130
- }
131
- });
132
- let fallbackRoute;
133
- let route;
134
- const _children = (Array.isArray(props.children) ? props.children : [props.children]).flat();
135
- for (const child of _children) {
136
- if (!isRoute(child))
137
- continue;
138
- if (child.props.path === "*") {
139
- if (__DEV__) {
140
- if (fallbackRoute) {
141
- console.warn("[kiru]: More than one fallback route defined. Only the last one will be used.");
142
- }
143
- }
144
- fallbackRoute = child;
145
- continue;
146
- }
147
- const dynamicChildPathSegments = ((props.basePath || "") + child.props.path)
148
- .split("/")
149
- .filter(Boolean);
150
- if (routeMatchesPath(dynamicParentPathSegments.concat(dynamicChildPathSegments), realPathSegments, child.props.fallthrough)) {
151
- route = child;
152
- break;
153
- }
154
- }
155
- let parsedParams = {};
156
- if (route) {
157
- const dynamicChildPathSegments = ((props.basePath || "") + route.props.path)
158
- .split("/")
159
- .filter(Boolean);
160
- parsedParams = parsePathParams(dynamicParentPathSegments.concat(dynamicChildPathSegments), realPathSegments);
161
- }
162
- const params = { ...parentRouterContext.params, ...parsedParams };
163
- return RouterContext.Provider({
164
- value: {
165
- params,
166
- query,
167
- routePath: (dynamicParentPath || "") +
168
- (props.basePath || "") +
169
- (route?.props.path || ""),
170
- basePath: props.basePath,
171
- isDefault: false,
172
- queueSyncNav: (callback) => {
173
- syncNavCallback.current = callback;
174
- },
175
- viewTransition: viewTransition,
176
- transitionsEnabled: !!props.transition,
177
- },
178
- children: route ?? fallbackRoute ?? null,
179
- });
180
- }
181
- //# sourceMappingURL=router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/components/router/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,eAAe,EACf,MAAM,GACP,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAS,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AAwBzB,MAAM,UAAU,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OA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G,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;aACzE,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,OAAO,CAAC,CAAA;QAClB,YAAY,GAAG,eAAe,CAC5B,yBAAyB,CAAC,MAAM,CAAC,wBAAwB,CAAC,EAC1D,gBAAgB,CACjB,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,EAAE,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,YAAY,EAAE,CAAA;IAEjE,OAAO,aAAa,CAAC,QAAQ,CAAC;QAC5B,KAAK,EAAE;YACL,MAAM;YACN,KAAK;YACL,SAAS,EACP,CAAC,iBAAiB,IAAI,EAAE,CAAC;gBACzB,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACtB,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;YAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,CAAC,QAAoB,EAAE,EAAE;gBACrC,eAAe,CAAC,OAAO,GAAG,QAAQ,CAAA;YACpC,CAAC;YACD,cAAc,EAAE,cAAc;YAC9B,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU;SACvC;QACD,QAAQ,EAAE,KAAK,IAAI,aAAa,IAAI,IAAI;KACzC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,5 +0,0 @@
1
- export { routeMatchesPath, parsePathParams, parseSearchParams };
2
- declare function routeMatchesPath(dynamicPathSegments: string[], realPathSegments: string[], fallthrough?: boolean): boolean;
3
- declare function parsePathParams(dynamicPathSegments: string[], realPathSegments: string[]): Record<string, string>;
4
- declare function parseSearchParams(search: string): Record<string, string>;
5
- //# sourceMappingURL=routerUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routerUtils.d.ts","sourceRoot":"","sources":["../../../src/components/router/routerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAA;AAE/D,iBAAS,gBAAgB,CACvB,mBAAmB,EAAE,MAAM,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,WAAW,CAAC,EAAE,OAAO,WAgBtB;AAED,iBAAS,eAAe,CACtB,mBAAmB,EAAE,MAAM,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,0BAU3B;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,0BAWxC"}