onejs-react 0.1.30 → 0.1.31
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 +1 -1
- package/src/renderer.ts +23 -2
package/package.json
CHANGED
package/src/renderer.ts
CHANGED
|
@@ -19,6 +19,25 @@ reconciler.injectIntoDevTools({
|
|
|
19
19
|
// Track roots for hot reload / re-render
|
|
20
20
|
const roots = new Map<RenderContainer, ReturnType<typeof reconciler.createContainer>>();
|
|
21
21
|
|
|
22
|
+
// react-reconciler 0.31 (React 19) inserted onUncaughtError/onCaughtError ahead of
|
|
23
|
+
// onRecoverableError in createContainer's signature. @types/react-reconciler (0.28.x)
|
|
24
|
+
// predates them, so the call is typed manually here; with the 0.28-shaped arg list the
|
|
25
|
+
// root's onCaughtError slot is left null at runtime and any error boundary catch
|
|
26
|
+
// throws "onCaughtError is not a function".
|
|
27
|
+
type RootErrorHandler = (error: unknown, errorInfo: unknown) => void;
|
|
28
|
+
const createContainer = reconciler.createContainer as unknown as (
|
|
29
|
+
containerInfo: Container,
|
|
30
|
+
tag: number,
|
|
31
|
+
hydrationCallbacks: null,
|
|
32
|
+
isStrictMode: boolean,
|
|
33
|
+
concurrentUpdatesByDefaultOverride: null,
|
|
34
|
+
identifierPrefix: string,
|
|
35
|
+
onUncaughtError: RootErrorHandler,
|
|
36
|
+
onCaughtError: RootErrorHandler,
|
|
37
|
+
onRecoverableError: RootErrorHandler,
|
|
38
|
+
transitionCallbacks: null
|
|
39
|
+
) => ReturnType<typeof reconciler.createContainer>;
|
|
40
|
+
|
|
22
41
|
// Register unmountAll as a runtime teardown hook exactly once. The OneJS runtime
|
|
23
42
|
// (QuickJSUIBridge.Dispose) invokes __runTeardown() right before destroying the JS
|
|
24
43
|
// context on hot reload / stop. Unmounting here fires useEffect/useLayoutEffect
|
|
@@ -40,14 +59,16 @@ export function render(element: ReactNode, container: RenderContainer): void {
|
|
|
40
59
|
let root = roots.get(container);
|
|
41
60
|
|
|
42
61
|
if (!root) {
|
|
43
|
-
root =
|
|
62
|
+
root = createContainer(
|
|
44
63
|
container as Container,
|
|
45
64
|
0, // LegacyRoot (0) vs ConcurrentRoot (1)
|
|
46
65
|
null, // hydrationCallbacks
|
|
47
66
|
false, // isStrictMode
|
|
48
67
|
null, // concurrentUpdatesByDefaultOverride
|
|
49
68
|
'', // identifierPrefix
|
|
50
|
-
(error
|
|
69
|
+
(error) => console.error('[OneJS React] Uncaught error:', error),
|
|
70
|
+
(error) => console.error('[OneJS React] Error caught by boundary:', error),
|
|
71
|
+
(error) => console.error('[OneJS React] Recoverable error:', error),
|
|
51
72
|
null // transitionCallbacks
|
|
52
73
|
);
|
|
53
74
|
roots.set(container, root);
|