@opentui/react 0.6.5 → 0.6.7
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.
|
@@ -134,15 +134,15 @@ import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
|
|
|
134
134
|
|
|
135
135
|
// src/components/error-boundary.tsx
|
|
136
136
|
class ErrorBoundary extends React.Component {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
state = { error: null };
|
|
138
|
+
static getDerivedStateFromProps(props, state) {
|
|
139
|
+
return props.resetKey === state.resetKey ? null : { error: null, resetKey: props.resetKey };
|
|
140
140
|
}
|
|
141
141
|
static getDerivedStateFromError(error) {
|
|
142
|
-
return {
|
|
142
|
+
return { error };
|
|
143
143
|
}
|
|
144
144
|
render() {
|
|
145
|
-
if (this.state.
|
|
145
|
+
if (this.state.error) {
|
|
146
146
|
return /* @__PURE__ */ jsxDEV("box", {
|
|
147
147
|
style: { flexDirection: "column", padding: 2 },
|
|
148
148
|
children: /* @__PURE__ */ jsxDEV("text", {
|
|
@@ -164,7 +164,7 @@ import { ImageRenderable as ImageRenderable2, TextNodeRenderable as TextNodeRend
|
|
|
164
164
|
// package.json
|
|
165
165
|
var package_default = {
|
|
166
166
|
name: "@opentui/react",
|
|
167
|
-
version: "0.6.
|
|
167
|
+
version: "0.6.7",
|
|
168
168
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
169
169
|
license: "MIT",
|
|
170
170
|
repository: {
|
|
@@ -565,10 +565,8 @@ $ bun add react-devtools-core@7 -d
|
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
reconciler.injectIntoDevTools();
|
|
568
|
-
function
|
|
569
|
-
|
|
570
|
-
reconciler.updateContainer(element, container, null, () => {});
|
|
571
|
-
return container;
|
|
568
|
+
function createContainer(root) {
|
|
569
|
+
return reconciler.createContainer(root, ConcurrentRoot, null, false, null, "", console.error, console.error, console.error, () => {});
|
|
572
570
|
}
|
|
573
571
|
|
|
574
572
|
// src/reconciler/renderer.ts
|
|
@@ -577,21 +575,28 @@ var flushSync2 = _r.flushSyncFromReconciler ?? _r.flushSync;
|
|
|
577
575
|
var { createPortal: createPortal2 } = reconciler;
|
|
578
576
|
function createRoot2(renderer) {
|
|
579
577
|
let container = null;
|
|
578
|
+
let renderVersion = 0;
|
|
579
|
+
const appContext = { keyHandler: renderer.keyInput, renderer };
|
|
580
580
|
const cleanup = () => {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
581
|
+
const current = container;
|
|
582
|
+
if (!current)
|
|
583
|
+
return;
|
|
584
|
+
container = null;
|
|
585
|
+
renderer.off(CliRenderEvents.DESTROY, cleanup);
|
|
586
|
+
reconciler.updateContainerSync(null, current, null, () => {});
|
|
587
|
+
reconciler.flushSyncWork();
|
|
586
588
|
};
|
|
587
|
-
if (!renderer.isDestroyed)
|
|
588
|
-
renderer.once(CliRenderEvents.DESTROY, cleanup);
|
|
589
589
|
return {
|
|
590
590
|
render: (node) => {
|
|
591
591
|
if (renderer.isDestroyed)
|
|
592
592
|
return;
|
|
593
593
|
engine.attach(renderer);
|
|
594
|
-
|
|
594
|
+
if (!container) {
|
|
595
|
+
container = createContainer(renderer.root);
|
|
596
|
+
renderer.once(CliRenderEvents.DESTROY, cleanup);
|
|
597
|
+
}
|
|
598
|
+
const element = React2.createElement(AppContext2.Provider, { value: appContext }, React2.createElement(ErrorBoundary, { resetKey: ++renderVersion, children: node }));
|
|
599
|
+
reconciler.updateContainer(element, container, null, () => {});
|
|
595
600
|
},
|
|
596
601
|
unmount: cleanup
|
|
597
602
|
};
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.6.
|
|
7
|
+
"version": "0.6.7",
|
|
8
8
|
"description": "React renderer for building terminal user interfaces using OpenTUI core",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@opentui/core": "0.6.
|
|
55
|
+
"@opentui/core": "0.6.7",
|
|
56
56
|
"react-reconciler": "^0.33.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
type ErrorBoundaryProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
resetKey: number;
|
|
5
|
+
};
|
|
6
|
+
type ErrorBoundaryState = {
|
|
6
7
|
error: Error | null;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
error: Error;
|
|
14
|
-
};
|
|
8
|
+
resetKey?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
11
|
+
state: ErrorBoundaryState;
|
|
12
|
+
static getDerivedStateFromProps(props: ErrorBoundaryProps, state: ErrorBoundaryState): ErrorBoundaryState | null;
|
|
13
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
15
14
|
render(): any;
|
|
16
15
|
}
|
|
16
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RootRenderable } from "@opentui/core";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import ReactReconciler from "react-reconciler";
|
|
4
3
|
export declare const reconciler: ReactReconciler.Reconciler<RootRenderable, import("@opentui/core").BaseRenderable, import("@opentui/core").TextNodeRenderable, unknown, unknown, import("@opentui/core").BaseRenderable>;
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function createContainer(root: RootRenderable): any;
|