@kubb/react-fabric 0.9.0 → 0.9.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.",
5
5
  "keywords": [
6
6
  "react",
@@ -111,7 +111,7 @@
111
111
  "react-devtools-core": "6.1.2",
112
112
  "signal-exit": "^4.1.0",
113
113
  "ws": "8.18.0",
114
- "@kubb/fabric-core": "0.9.0"
114
+ "@kubb/fabric-core": "0.9.2"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@types/react": "^19.2.7",
package/src/Runtime.tsx CHANGED
@@ -25,6 +25,7 @@ type Options = {
25
25
  export class Runtime {
26
26
  readonly #options: Options
27
27
  #isUnmounted: boolean
28
+ #renderError?: Error
28
29
 
29
30
  exitPromise?: Promise<void>
30
31
  readonly #container: FiberRoot
@@ -39,7 +40,6 @@ export class Runtime {
39
40
  this.unmount.bind(this)
40
41
 
41
42
  // Intercept noisy React errors
42
- const originalError = console.error
43
43
  console.error = (data: string | Error) => {
44
44
  const message = typeof data === 'string' ? data : data?.message
45
45
  if (
@@ -51,7 +51,7 @@ export class Runtime {
51
51
  ) {
52
52
  return
53
53
  }
54
- originalError(data)
54
+ console.log(data)
55
55
  }
56
56
 
57
57
  const logRecoverableError = typeof reportError === 'function' ? reportError : console.error
@@ -128,7 +128,6 @@ export class Runtime {
128
128
 
129
129
  this.#renderPromise = task.catch((error) => {
130
130
  this.onError(error as Error)
131
- throw error
132
131
  })
133
132
 
134
133
  return this.#renderPromise
@@ -139,7 +138,8 @@ export class Runtime {
139
138
  console.warn(error)
140
139
  }
141
140
 
142
- throw error
141
+ // Store the error to be thrown after render completes
142
+ this.#renderError = error
143
143
  }
144
144
 
145
145
  onExit(error?: Error): void {
@@ -176,6 +176,13 @@ export class Runtime {
176
176
  Renderer.updateContainerSync(element, this.#container, null, null)
177
177
  Renderer.flushSyncWork()
178
178
  await this.#renderPromise
179
+
180
+ // Throw any errors that occurred during rendering
181
+ if (this.#renderError) {
182
+ const error = this.#renderError
183
+ this.#renderError = undefined
184
+ throw error
185
+ }
179
186
  }
180
187
 
181
188
  async renderToString(node: ReactNode): Promise<string> {
@@ -191,6 +198,13 @@ export class Runtime {
191
198
  await this.#renderPromise
192
199
  this.fileManager.clear()
193
200
 
201
+ // Throw any errors that occurred during rendering
202
+ if (this.#renderError) {
203
+ const error = this.#renderError
204
+ this.#renderError = undefined
205
+ throw error
206
+ }
207
+
194
208
  return this.#getOutput(this.#rootNode)
195
209
  }
196
210
 
@@ -56,19 +56,15 @@ type RootProps = {
56
56
  }
57
57
 
58
58
  export function Root({ onError, onExit, children }: RootProps) {
59
- try {
60
- return (
61
- <ErrorBoundary
62
- onError={(error) => {
63
- onError(error)
64
- }}
65
- >
66
- <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>
67
- </ErrorBoundary>
68
- )
69
- } catch (_e) {
70
- return null
71
- }
59
+ return (
60
+ <ErrorBoundary
61
+ onError={(error) => {
62
+ onError(error)
63
+ }}
64
+ >
65
+ <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>
66
+ </ErrorBoundary>
67
+ )
72
68
  }
73
69
 
74
70
  Root.Context = RootContext