@kubb/renderer-jsx 5.0.0-beta.75 → 5.0.0-beta.76

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 (47) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +135 -0
  3. package/dist/index.cjs +385 -17926
  4. package/dist/index.d.ts +248 -165
  5. package/dist/index.js +370 -17908
  6. package/dist/jsx-dev-runtime.cjs +3 -10
  7. package/dist/jsx-dev-runtime.d.ts +4 -8
  8. package/dist/jsx-dev-runtime.js +1 -9
  9. package/dist/jsx-runtime.cjs +24 -6
  10. package/dist/jsx-runtime.d.ts +59 -10
  11. package/dist/jsx-runtime.js +24 -7
  12. package/dist/rolldown-runtime-C0LytTxp.js +8 -0
  13. package/dist/rolldown-runtime-ClG-MNz_.cjs +13 -0
  14. package/dist/types-OZ23urxc.d.ts +119 -0
  15. package/dist/types.d.ts +2 -2
  16. package/package.json +8 -37
  17. package/dist/chunk-Bb7HlUDG.js +0 -28
  18. package/dist/index.cjs.map +0 -1
  19. package/dist/index.js.map +0 -1
  20. package/dist/jsx-dev-runtime.cjs.map +0 -1
  21. package/dist/jsx-dev-runtime.js.map +0 -1
  22. package/dist/jsx-namespace-CNp0arTN.d.ts +0 -39
  23. package/dist/jsx-runtime-Cvu_ZYgL.js +0 -1448
  24. package/dist/jsx-runtime-Cvu_ZYgL.js.map +0 -1
  25. package/dist/jsx-runtime-DdmO3p0U.cjs +0 -1503
  26. package/dist/jsx-runtime-DdmO3p0U.cjs.map +0 -1
  27. package/dist/jsx-runtime.cjs.map +0 -1
  28. package/dist/jsx-runtime.js.map +0 -1
  29. package/dist/types-nAFMiWFw.d.ts +0 -168
  30. package/src/Renderer.ts +0 -184
  31. package/src/Runtime.tsx +0 -170
  32. package/src/components/Const.tsx +0 -72
  33. package/src/components/File.tsx +0 -186
  34. package/src/components/Function.tsx +0 -152
  35. package/src/components/Jsx.tsx +0 -34
  36. package/src/components/Root.tsx +0 -70
  37. package/src/components/Type.tsx +0 -66
  38. package/src/constants.ts +0 -28
  39. package/src/createRenderer.tsx +0 -93
  40. package/src/dom.ts +0 -105
  41. package/src/globals.ts +0 -34
  42. package/src/index.ts +0 -8
  43. package/src/jsx-dev-runtime.ts +0 -10
  44. package/src/jsx-namespace.d.ts +0 -52
  45. package/src/jsx-runtime.ts +0 -12
  46. package/src/types.ts +0 -207
  47. package/src/utils.ts +0 -267
package/src/Runtime.tsx DELETED
@@ -1,170 +0,0 @@
1
- import { onProcessExit } from '@internals/utils'
2
- import type { FileNode } from '@kubb/ast'
3
- import { ConcurrentRoot } from 'react-reconciler/constants.js'
4
- import { Root } from './components/Root.tsx'
5
- import { createNode } from './dom.ts'
6
- import type { FiberRoot } from './Renderer.ts'
7
- import { Renderer } from './Renderer.ts'
8
- import type { DOMElement, KubbReactElement } from './types.ts'
9
- import { processFiles } from './utils.ts'
10
-
11
- type Options = {
12
- /**
13
- * Set this to true to always see the result of the render in the console(line per render)
14
- */
15
- debug?: boolean
16
- }
17
-
18
- export class Runtime {
19
- readonly #options: Options
20
- #isUnmounted: boolean
21
- #renderError?: Error
22
-
23
- exitPromise?: Promise<void>
24
-
25
- nodes: FileNode[] = []
26
- readonly #container: FiberRoot
27
- readonly #rootNode: DOMElement
28
-
29
- constructor(options: Options) {
30
- this.#options = options
31
- this.#rootNode = createNode('kubb-root')
32
- this.#rootNode.onRender = this.onRender
33
- this.#rootNode.onImmediateRender = this.onRender
34
- this.#isUnmounted = false
35
- this.unmount.bind(this)
36
-
37
- // Intercept noisy React errors
38
- console.error = (data: string | Error) => {
39
- const message = typeof data === 'string' ? data : data?.message
40
- if (
41
- message?.match(/Encountered two children with the same key/gi) ||
42
- message?.match(/React will try to recreat/gi) ||
43
- message?.match(/Each child in a list should have a unique/gi) ||
44
- message?.match(/The above error occurred in the <KubbErrorBoundary/gi) ||
45
- message?.match(/A React Element from an older version of React was render/gi)
46
- ) {
47
- return
48
- }
49
- console.log(data)
50
- }
51
-
52
- const logRecoverableError = typeof reportError === 'function' ? reportError : console.error
53
-
54
- const rootTag = ConcurrentRoot
55
- this.#container = Renderer.createContainer(
56
- this.#rootNode,
57
- rootTag,
58
- null,
59
- false,
60
- false,
61
- 'id',
62
- logRecoverableError,
63
- logRecoverableError,
64
- logRecoverableError,
65
- null,
66
- )
67
-
68
- // Unmount when process exits
69
- this.unsubscribeExit = onProcessExit((code) => {
70
- this.unmount(code)
71
- })
72
- }
73
-
74
- #renderPromise: Promise<void> = Promise.resolve()
75
- resolveExitPromise: () => void = () => {}
76
- rejectExitPromise: (reason?: Error) => void = () => {}
77
- unsubscribeExit: () => void = () => {}
78
-
79
- onRender: () => Promise<void> = () => {
80
- const previous = this.#renderPromise
81
-
82
- const task = previous
83
- .catch(() => {})
84
- .then(() => {
85
- if (this.#isUnmounted) {
86
- return
87
- }
88
-
89
- const files = processFiles(this.#rootNode)
90
-
91
- this.nodes.push(...files)
92
-
93
- if (!this.#options?.debug) {
94
- return
95
- }
96
- })
97
-
98
- this.#renderPromise = task.catch((error) => {
99
- this.onError(error as Error)
100
- })
101
-
102
- return this.#renderPromise
103
- }
104
-
105
- onError(error: Error): void {
106
- // Store the error to be thrown after render completes
107
- this.#renderError = error
108
- }
109
-
110
- onExit(error?: Error): void {
111
- setTimeout(() => {
112
- this.unmount(error)
113
- }, 0)
114
- }
115
-
116
- async render(node: KubbReactElement): Promise<void> {
117
- const props = {
118
- onExit: this.onExit.bind(this),
119
- onError: this.onError.bind(this),
120
- }
121
-
122
- const element = <Root {...props}>{node}</Root>
123
-
124
- Renderer.updateContainerSync(element, this.#container, null, null)
125
- Renderer.flushSyncWork()
126
- await this.#renderPromise
127
-
128
- // Throw any errors that occurred during rendering
129
- if (this.#renderError) {
130
- const error = this.#renderError
131
- this.#renderError = undefined
132
- throw error
133
- }
134
- }
135
-
136
- unmount(error?: Error | number | null): void {
137
- if (this.#isUnmounted) {
138
- return
139
- }
140
-
141
- if (this.#options?.debug) {
142
- console.log('Unmount', error)
143
- }
144
-
145
- this.onRender()
146
- this.unsubscribeExit()
147
-
148
- this.#isUnmounted = true
149
-
150
- Renderer.updateContainerSync(null, this.#container, null, null)
151
-
152
- if (error instanceof Error) {
153
- this.rejectExitPromise(error)
154
- return
155
- }
156
-
157
- this.resolveExitPromise()
158
- }
159
-
160
- async waitUntilExit(): Promise<void> {
161
- if (!this.exitPromise) {
162
- this.exitPromise = new Promise((resolve, reject) => {
163
- this.resolveExitPromise = resolve
164
- this.rejectExitPromise = reject
165
- })
166
- }
167
-
168
- return this.exitPromise
169
- }
170
- }
@@ -1,72 +0,0 @@
1
- import type { JSDoc, Key, KubbReactElement, KubbReactNode } from '../types.ts'
2
-
3
- type ConstProps = {
4
- key?: Key
5
- /**
6
- * Identifier of the generated constant declaration.
7
- *
8
- * @example
9
- * `name: 'petSchema'`
10
- */
11
- name: string
12
- /**
13
- * Emit the `export` keyword before the `const` declaration.
14
- * - `true` generates `export const name = …`
15
- * - `false` generates `const name = …`
16
- * @default false
17
- */
18
- export?: boolean
19
- /**
20
- * TypeScript type annotation for the constant, written verbatim after `const name:`.
21
- *
22
- * @example
23
- * `type: 'Pet'` → `const pet: Pet = …`
24
- */
25
- type?: string
26
- /**
27
- * JSDoc block to prepend to the constant declaration.
28
- * Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
29
- */
30
- JSDoc?: JSDoc
31
- /**
32
- * Append `as const` after the initialiser, enabling TypeScript const assertions.
33
- * - `true` generates `const name = … as const`
34
- * - `false` generates `const name = …`
35
- * @default false
36
- */
37
- asConst?: boolean
38
- /**
39
- * Child nodes rendered as the initialiser expression of the constant.
40
- */
41
- children?: KubbReactNode
42
- }
43
-
44
- /**
45
- * Generates a TypeScript constant declaration.
46
- *
47
- * @example Named export with type annotation
48
- * ```tsx
49
- * <Const export name="petSchema" type="z.ZodType<Pet>">
50
- * {`z.object({ id: z.number() })`}
51
- * </Const>
52
- * // export const petSchema: z.ZodType<Pet> = z.object({ id: z.number() })
53
- * ```
54
- *
55
- * @example With JSDoc and const assertion
56
- * ```tsx
57
- * <Const name="HTTP_METHODS" asConst JSDoc={{ comments: ['@description Supported HTTP methods.'] }}>
58
- * {`['GET', 'POST', 'PUT', 'DELETE']`}
59
- * </Const>
60
- * ```
61
- */
62
- export function Const({ children, ...props }: ConstProps): KubbReactElement {
63
- const { name, export: canExport, type, JSDoc, asConst } = props
64
-
65
- return (
66
- <kubb-const name={name} type={type} export={canExport} asConst={asConst} JSDoc={JSDoc}>
67
- {children}
68
- </kubb-const>
69
- )
70
- }
71
-
72
- Const.displayName = 'Const'
@@ -1,186 +0,0 @@
1
- import type { ExportNode, ImportNode, SourceNode } from '@kubb/ast'
2
- import type { Key, KubbReactElement, KubbReactNode } from '../types.ts'
3
-
4
- type BasePropsWithBaseName = {
5
- /**
6
- * Base file name including extension, derived from the input path.
7
- * Based on UNIX basename convention: `${name}${extname}`.
8
- *
9
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
10
- *
11
- * @example
12
- * `baseName: 'petStore.ts'`
13
- */
14
- baseName: `${string}.${string}`
15
- /**
16
- * Fully qualified path to the generated file.
17
- *
18
- * @example
19
- * `path: 'src/models/petStore.ts'`
20
- */
21
- path: string
22
- }
23
-
24
- type BasePropsWithoutBaseName = {
25
- baseName?: never
26
- /**
27
- * Fully qualified path to the generated file.
28
- * Optional when `baseName` is omitted — the component renders its children inline.
29
- */
30
- path?: string
31
- }
32
-
33
- type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName
34
-
35
- type Props<TMeta> = BaseProps & {
36
- key?: Key
37
- /**
38
- * Arbitrary metadata attached to the file node.
39
- * Used by plugins for barrel generation and custom post-processing.
40
- */
41
- meta?: TMeta
42
- /**
43
- * Text prepended to the generated file content before any source blocks.
44
- */
45
- banner?: string
46
- /**
47
- * Text appended to the generated file content after all source blocks.
48
- */
49
- footer?: string
50
- /**
51
- * Child nodes rendered as the content of this file (source blocks, imports, exports).
52
- */
53
- children?: KubbReactNode
54
- }
55
-
56
- /**
57
- * Declares a generated file entry to be collected by the renderer.
58
- *
59
- * When both `baseName` and `path` are provided, the component registers a new
60
- * `FileNode` and passes its children through as source blocks.
61
- * When either is omitted the children are rendered inline without creating a file entry.
62
- *
63
- * @example Basic file with a source block
64
- * ```tsx
65
- * <File baseName="petStore.ts" path="src/models/petStore.ts">
66
- * <File.Source name="Pet" isExportable isIndexable>
67
- * {`export type Pet = { id: number; name: string }`}
68
- * </File.Source>
69
- * </File>
70
- * ```
71
- */
72
- export function File<TMeta extends object = object>({ children, ...props }: Props<TMeta>): KubbReactElement {
73
- const { baseName, path } = props
74
-
75
- if (!baseName || !path) {
76
- return <>{children}</>
77
- }
78
-
79
- return <kubb-file {...props}>{children}</kubb-file>
80
- }
81
-
82
- File.displayName = 'File'
83
-
84
- type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
85
- key?: Key
86
- /**
87
- * Child nodes rendered as the source content of this block.
88
- */
89
- children?: KubbReactNode
90
- }
91
-
92
- /**
93
- * Marks a block of source text to be associated with the enclosing {@link File}.
94
- *
95
- * Children are treated as the source string. When `isExportable` is `true` the
96
- * `name` is used for deduplication and barrel generation.
97
- *
98
- * @example Exportable, indexable source block
99
- * ```tsx
100
- * <File.Source name="Pet" isExportable isIndexable>
101
- * {`export type Pet = { id: number; name: string }`}
102
- * </File.Source>
103
- * ```
104
- *
105
- * @example Type-only source block
106
- * ```tsx
107
- * <File.Source name="PetId" isTypeOnly isExportable>
108
- * {`export type PetId = string`}
109
- * </File.Source>
110
- * ```
111
- */
112
- function FileSource({ children, ...props }: FileSourceProps): KubbReactElement {
113
- const { name, isExportable, isIndexable, isTypeOnly } = props
114
-
115
- return (
116
- <kubb-source name={name} isTypeOnly={isTypeOnly} isExportable={isExportable} isIndexable={isIndexable}>
117
- {children}
118
- </kubb-source>
119
- )
120
- }
121
-
122
- FileSource.displayName = 'FileSource'
123
-
124
- type FileExportProps = Omit<ExportNode, 'kind'> & { key?: Key }
125
-
126
- /**
127
- * Declares an export entry for the enclosing {@link File}.
128
- *
129
- * The export is collected by the renderer and emitted at the top of the generated file.
130
- *
131
- * @example Named export
132
- * ```tsx
133
- * <File.Export name={['Pet']} path="./models/petStore" />
134
- * // export { Pet } from './models/petStore'
135
- * ```
136
- *
137
- * @example Type-only wildcard export
138
- * ```tsx
139
- * <File.Export path="./models/petStore" isTypeOnly />
140
- * // export type * from './models/petStore'
141
- * ```
142
- */
143
- function FileExport(props: FileExportProps): KubbReactElement {
144
- const { name, path, isTypeOnly, asAlias } = props
145
-
146
- return <kubb-export name={name} path={path} isTypeOnly={isTypeOnly} asAlias={asAlias} />
147
- }
148
-
149
- FileExport.displayName = 'FileExport'
150
-
151
- type FileImportProps = Omit<ImportNode, 'kind'> & { key?: Key }
152
-
153
- /**
154
- * Declares an import entry for the enclosing {@link File}.
155
- *
156
- * The import is collected by the renderer and emitted at the top of the generated file.
157
- *
158
- * @example Named import
159
- * ```tsx
160
- * <File.Import name={['useState']} path="react" />
161
- * // import { useState } from 'react'
162
- * ```
163
- *
164
- * @example Type-only import
165
- * ```tsx
166
- * <File.Import name={['Pet']} path="./models" isTypeOnly />
167
- * // import type { Pet } from './models'
168
- * ```
169
- *
170
- * @example Namespace import
171
- * ```tsx
172
- * <File.Import name="z" path="zod" isNameSpace />
173
- * // import * as z from 'zod'
174
- * ```
175
- */
176
- function FileImport(props: FileImportProps): KubbReactElement {
177
- const { name, root, path, isTypeOnly, isNameSpace } = props
178
-
179
- return <kubb-import name={name} root={root} path={path} isNameSpace={isNameSpace} isTypeOnly={isTypeOnly} />
180
- }
181
-
182
- FileImport.displayName = 'FileImport'
183
-
184
- File.Export = FileExport
185
- File.Import = FileImport
186
- File.Source = FileSource
@@ -1,152 +0,0 @@
1
- import type { JSDoc, Key, KubbReactElement, KubbReactNode } from '../types.ts'
2
-
3
- type Props = {
4
- key?: Key
5
- /**
6
- * Identifier of the generated function declaration.
7
- *
8
- * @example
9
- * `name: 'getPet'`
10
- */
11
- name: string
12
- /**
13
- * Emit `default` after the `export` keyword, making this the module's default export.
14
- * Requires `export` to also be `true`.
15
- * @default false
16
- */
17
- default?: boolean
18
- /**
19
- * Parameter list written verbatim between the function's parentheses.
20
- *
21
- * @example
22
- * `params: 'petId: string, options?: RequestOptions'`
23
- */
24
- params?: string
25
- /**
26
- * Emit the `export` keyword before the function declaration.
27
- * - `true` generates `export function name(…) { … }`
28
- * - `false` generates `function name(…) { … }`
29
- * @default false
30
- */
31
- export?: boolean
32
- /**
33
- * Emit the `async` keyword, making this an async function.
34
- * The return type is automatically wrapped in `Promise<returnType>` when both
35
- * `async` and `returnType` are set.
36
- * @default false
37
- */
38
- async?: boolean
39
- /**
40
- * TypeScript generic type parameters written verbatim between `<` and `>`.
41
- * Pass an array to emit multiple parameters separated by commas.
42
- *
43
- * @example Single generic
44
- * `generics: 'TData'`
45
- *
46
- * @example Multiple generics
47
- * `generics: ['TData', 'TError = unknown']`
48
- */
49
- generics?: string | string[]
50
- /**
51
- * TypeScript return type annotation written verbatim after `:`.
52
- * When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
53
- *
54
- * @example
55
- * `returnType: 'Pet'`
56
- */
57
- returnType?: string
58
- /**
59
- * JSDoc block to prepend to the function declaration.
60
- * Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
61
- */
62
- JSDoc?: JSDoc
63
- /**
64
- * Child nodes rendered as the body of the function.
65
- */
66
- children?: KubbReactNode
67
- }
68
-
69
- /**
70
- * Generates a TypeScript function declaration.
71
- *
72
- * @example Async exported function with generics
73
- * ```tsx
74
- * <Function export async name="getPet" generics={['TData = Pet']} params="petId: string" returnType="TData">
75
- * {`return client.get(\`/pets/\${petId}\`)`}
76
- * </Function>
77
- * // export async function getPet<TData = Pet>(petId: string): Promise<TData> {
78
- * // return client.get(`/pets/${petId}`)
79
- * // }
80
- * ```
81
- */
82
- export function Function({ children, ...props }: Props): KubbReactElement {
83
- const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props
84
-
85
- // Normalize generics array to comma-separated string for DOM attribute storage
86
- const genericsString = Array.isArray(generics) ? generics.join(', ').trim() : generics
87
-
88
- return (
89
- <kubb-function
90
- name={name}
91
- params={params}
92
- export={canExport}
93
- default={isDefault}
94
- async={isAsync}
95
- generics={genericsString}
96
- returnType={returnType}
97
- JSDoc={JSDoc}
98
- >
99
- {children}
100
- </kubb-function>
101
- )
102
- }
103
-
104
- Function.displayName = 'Function'
105
-
106
- type ArrowFunctionProps = Props & {
107
- /**
108
- * Render the arrow function as a single-line expression (no braces around the body).
109
- * - `true` generates `const name = (…) => expression`
110
- * - `false` generates `const name = (…) => { … }`
111
- * @default false
112
- */
113
- singleLine?: boolean
114
- }
115
-
116
- /**
117
- * Generates an arrow function expression assigned to a `const`.
118
- * Supports the same flags as {@link Function}.
119
- * Use `singleLine` to render the body as a concise expression rather than a block.
120
- *
121
- * @example Single-line arrow function
122
- * ```tsx
123
- * <Function.Arrow export name="double" params="n: number" returnType="number" singleLine>
124
- * {`n * 2`}
125
- * </Function.Arrow>
126
- * // export const double = (n: number): number => n * 2
127
- * ```
128
- */
129
- function ArrowFunction({ children, ...props }: ArrowFunctionProps) {
130
- const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props
131
-
132
- const genericsString = Array.isArray(generics) ? generics.join(', ').trim() : generics
133
-
134
- return (
135
- <kubb-arrow-function
136
- name={name}
137
- params={params}
138
- export={canExport}
139
- default={isDefault}
140
- async={async}
141
- generics={genericsString}
142
- returnType={returnType}
143
- singleLine={singleLine}
144
- JSDoc={JSDoc}
145
- >
146
- {children}
147
- </kubb-arrow-function>
148
- )
149
- }
150
-
151
- ArrowFunction.displayName = 'ArrowFunction'
152
- Function.Arrow = ArrowFunction
@@ -1,34 +0,0 @@
1
- import type { KubbReactElement } from '../types.ts'
2
-
3
- type Props = {
4
- /**
5
- * Raw JSX string to embed verbatim in the generated code.
6
- * Supports JSX fragments (`<>…</>`), elements, and any valid JSX syntax.
7
- * @example
8
- * ```tsx
9
- * <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
10
- * ```
11
- */
12
- children?: string
13
- }
14
-
15
- /**
16
- * Embeds a raw JSX string verbatim in the generated source code.
17
- *
18
- * Use this component when you need to include JSX markup (including fragments
19
- * `<>…</>`) in the body of a generated function or component. The `children`
20
- * prop must be a plain string — expression attributes that reference runtime
21
- * values should be written as template literals.
22
- *
23
- * @example
24
- * ```tsx
25
- * <Function name="MyComponent" export>
26
- * <Jsx>{'return (\n <>\n <div>Hello</div>\n </>\n)'}</Jsx>
27
- * </Function>
28
- * ```
29
- */
30
- export function Jsx({ children }: Props): KubbReactElement {
31
- return <kubb-jsx>{children}</kubb-jsx>
32
- }
33
-
34
- Jsx.displayName = 'Jsx'
@@ -1,70 +0,0 @@
1
- import { Component } from 'react'
2
- import type { KubbReactElement, KubbReactNode } from '../types.ts'
3
-
4
- type ErrorBoundaryProps = {
5
- onError: (error: Error) => void
6
- children?: KubbReactNode
7
- }
8
-
9
- class ErrorBoundary extends Component<{
10
- onError: ErrorBoundaryProps['onError']
11
- children?: KubbReactNode
12
- }> {
13
- state = { hasError: false }
14
-
15
- static displayName = 'ErrorBoundary'
16
- static getDerivedStateFromError(_error: Error) {
17
- return { hasError: true }
18
- }
19
-
20
- componentDidCatch(error: Error) {
21
- if (error) {
22
- this.props.onError(error)
23
- }
24
- }
25
-
26
- render() {
27
- if (this.state.hasError) {
28
- return null
29
- }
30
- return this.props.children
31
- }
32
- }
33
-
34
- type RootProps = {
35
- /**
36
- * Callback invoked to unmount the entire renderer tree.
37
- * Called with an `Error` when the exit is caused by a render error,
38
- * or with `undefined` for a clean shutdown.
39
- */
40
- onExit: (error?: Error) => void
41
- /**
42
- * Callback invoked whenever a render error is caught by the error boundary.
43
- * Use this to propagate errors up to the caller of {@link createRenderer}.
44
- */
45
- onError: (error: Error) => void
46
- /**
47
- * Child nodes rendered inside the error boundary.
48
- */
49
- children?: KubbReactNode
50
- }
51
-
52
- /**
53
- * Root component for the Kubb renderer tree.
54
- *
55
- * Wraps all children in an `ErrorBoundary` so that render errors are caught
56
- * and forwarded to `onError` rather than crashing the process.
57
- */
58
- export function Root({ onError, children }: RootProps): KubbReactElement {
59
- return (
60
- <ErrorBoundary
61
- onError={(error) => {
62
- onError(error)
63
- }}
64
- >
65
- {children}
66
- </ErrorBoundary>
67
- )
68
- }
69
-
70
- Root.displayName = 'Root'