@cascadetui/react 0.1.5 → 0.1.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.
- package/{chunk-emgt0q8h.js → chunk-c79msnsf.js} +24 -15
- package/index.js +1 -3
- package/jsx-namespace.d.ts +4 -3
- package/package.json +2 -2
- package/src/components/error-boundary.d.ts +5 -2
- package/src/components/index.d.ts +1 -0
- package/src/components/text.d.ts +1 -1
- package/src/reconciler/renderer.d.ts +1 -2
- package/src/types/components.d.ts +13 -2
- package/test-utils.js +1 -1
|
@@ -96,6 +96,7 @@ var baseComponents = {
|
|
|
96
96
|
textarea: TextareaRenderable,
|
|
97
97
|
scrollbox: ScrollBoxRenderable,
|
|
98
98
|
"ascii-font": ASCIIFontRenderable,
|
|
99
|
+
asciifont: ASCIIFontRenderable,
|
|
99
100
|
"tab-select": TabSelectRenderable,
|
|
100
101
|
"line-number": LineNumberRenderable,
|
|
101
102
|
span: SpanRenderable,
|
|
@@ -128,6 +129,7 @@ var useAppContext = () => {
|
|
|
128
129
|
// src/reconciler/renderer.ts
|
|
129
130
|
import { CliRenderEvents, engine } from "@cascadetui/core";
|
|
130
131
|
import React2 from "react";
|
|
132
|
+
import { ConcurrentRoot as ConcurrentRoot2 } from "react-reconciler/constants";
|
|
131
133
|
|
|
132
134
|
// src/components/error-boundary.tsx
|
|
133
135
|
import React from "react";
|
|
@@ -144,13 +146,16 @@ class ErrorBoundary extends React.Component {
|
|
|
144
146
|
static getDerivedStateFromError(error) {
|
|
145
147
|
return { hasError: true, error };
|
|
146
148
|
}
|
|
149
|
+
componentDidCatch(error, info) {
|
|
150
|
+
this.props.onCrash?.(error, info);
|
|
151
|
+
}
|
|
147
152
|
render() {
|
|
148
153
|
if (this.state.hasError && this.state.error) {
|
|
149
154
|
return /* @__PURE__ */ jsxDEV("box", {
|
|
150
155
|
style: { flexDirection: "column", padding: 2 },
|
|
151
156
|
children: /* @__PURE__ */ jsxDEV("text", {
|
|
152
157
|
fg: "red",
|
|
153
|
-
|
|
158
|
+
content: this.state.error.stack || this.state.error.message
|
|
154
159
|
}, undefined, false, undefined, this)
|
|
155
160
|
}, undefined, false, undefined, this);
|
|
156
161
|
}
|
|
@@ -163,11 +168,11 @@ import ReactReconciler from "react-reconciler";
|
|
|
163
168
|
import { ConcurrentRoot } from "react-reconciler/constants";
|
|
164
169
|
|
|
165
170
|
// src/reconciler/host-config.ts
|
|
166
|
-
import { TextNodeRenderable as TextNodeRenderable2 } from "@cascadetui/core";
|
|
171
|
+
import { ASCIIFont, TextNodeRenderable as TextNodeRenderable2, instantiate } from "@cascadetui/core";
|
|
167
172
|
// package.json
|
|
168
173
|
var package_default = {
|
|
169
174
|
name: "@cascadetui/react",
|
|
170
|
-
version: "0.1.
|
|
175
|
+
version: "0.1.7",
|
|
171
176
|
description: "React renderer for building terminal user interfaces using Cascade core",
|
|
172
177
|
license: "MIT",
|
|
173
178
|
repository: {
|
|
@@ -373,6 +378,9 @@ var hostConfig = {
|
|
|
373
378
|
throw new Error(`Component of type "${type}" must be created inside of a text node`);
|
|
374
379
|
}
|
|
375
380
|
const id = getNextId(type);
|
|
381
|
+
if (type === "asciifont") {
|
|
382
|
+
return instantiate(rootContainerInstance.ctx, ASCIIFont({ id, ...props }));
|
|
383
|
+
}
|
|
376
384
|
const components = getComponentCatalogue();
|
|
377
385
|
if (!components[type]) {
|
|
378
386
|
throw new Error(`Unknown component type: ${type}`);
|
|
@@ -493,12 +501,9 @@ var hostConfig = {
|
|
|
493
501
|
},
|
|
494
502
|
startSuspendingCommit() {},
|
|
495
503
|
suspendInstance() {},
|
|
496
|
-
waitForCommitToBeReady() {
|
|
497
|
-
return null;
|
|
498
|
-
},
|
|
499
504
|
detachDeletedInstance(instance) {
|
|
500
505
|
if (!instance.parent) {
|
|
501
|
-
instance.
|
|
506
|
+
instance.destroy();
|
|
502
507
|
}
|
|
503
508
|
},
|
|
504
509
|
getPublicInstance(instance) {
|
|
@@ -541,16 +546,10 @@ $ bun add react-devtools-core@7 -d
|
|
|
541
546
|
}
|
|
542
547
|
}
|
|
543
548
|
reconciler.injectIntoDevTools();
|
|
544
|
-
function _render(element, root) {
|
|
545
|
-
const container = reconciler.createContainer(root, ConcurrentRoot, null, false, null, "", console.error, console.error, console.error, console.error, null);
|
|
546
|
-
reconciler.updateContainer(element, container, null, () => {});
|
|
547
|
-
return container;
|
|
548
|
-
}
|
|
549
549
|
|
|
550
550
|
// src/reconciler/renderer.ts
|
|
551
551
|
var _r = reconciler;
|
|
552
552
|
var flushSync = _r.flushSyncFromReconciler ?? _r.flushSync;
|
|
553
|
-
var { createPortal } = reconciler;
|
|
554
553
|
function createRoot(renderer) {
|
|
555
554
|
let container = null;
|
|
556
555
|
const cleanup = () => {
|
|
@@ -564,10 +563,20 @@ function createRoot(renderer) {
|
|
|
564
563
|
return {
|
|
565
564
|
render: (node) => {
|
|
566
565
|
engine.attach(renderer);
|
|
567
|
-
|
|
566
|
+
const element = React2.createElement(AppContext.Provider, { value: { keyHandler: renderer.keyInput, renderer } }, React2.createElement(ErrorBoundary, {
|
|
567
|
+
onCrash: (error, info) => {
|
|
568
|
+
renderer.reportCrash(error, "react-error-boundary", {
|
|
569
|
+
componentStack: info.componentStack
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}, node));
|
|
573
|
+
if (!container) {
|
|
574
|
+
container = reconciler.createContainer(renderer.root, ConcurrentRoot2, null, false, null, "", console.error, console.error, console.error, console.error, null);
|
|
575
|
+
}
|
|
576
|
+
reconciler.updateContainer(element, container, null, () => {});
|
|
568
577
|
},
|
|
569
578
|
unmount: cleanup
|
|
570
579
|
};
|
|
571
580
|
}
|
|
572
581
|
|
|
573
|
-
export { baseComponents, componentCatalogue, extend, getComponentCatalogue, AppContext, useAppContext, flushSync,
|
|
582
|
+
export { baseComponents, componentCatalogue, extend, getComponentCatalogue, AppContext, useAppContext, flushSync, createRoot };
|
package/index.js
CHANGED
|
@@ -3,13 +3,12 @@ import {
|
|
|
3
3
|
AppContext,
|
|
4
4
|
baseComponents,
|
|
5
5
|
componentCatalogue,
|
|
6
|
-
createPortal,
|
|
7
6
|
createRoot,
|
|
8
7
|
extend,
|
|
9
8
|
flushSync,
|
|
10
9
|
getComponentCatalogue,
|
|
11
10
|
useAppContext
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-c79msnsf.js";
|
|
13
12
|
import"./chunk-e11q5a3p.js";
|
|
14
13
|
// src/hooks/use-keyboard.ts
|
|
15
14
|
import { useEffect } from "react";
|
|
@@ -109,7 +108,6 @@ export {
|
|
|
109
108
|
flushSync,
|
|
110
109
|
extend,
|
|
111
110
|
createRoot,
|
|
112
|
-
createPortal,
|
|
113
111
|
createElement,
|
|
114
112
|
componentCatalogue,
|
|
115
113
|
baseComponents,
|
package/jsx-namespace.d.ts
CHANGED
|
@@ -46,9 +46,10 @@ export namespace JSX {
|
|
|
46
46
|
input: InputProps
|
|
47
47
|
textarea: TextareaProps
|
|
48
48
|
select: SelectProps
|
|
49
|
-
scrollbox: ScrollBoxProps
|
|
50
|
-
"ascii-font": AsciiFontProps
|
|
51
|
-
|
|
49
|
+
scrollbox: ScrollBoxProps
|
|
50
|
+
"ascii-font": AsciiFontProps
|
|
51
|
+
asciifont: AsciiFontProps
|
|
52
|
+
"tab-select": TabSelectProps
|
|
52
53
|
"line-number": LineNumberProps
|
|
53
54
|
// Text modifiers
|
|
54
55
|
b: SpanProps
|
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.1.
|
|
7
|
+
"version": "0.1.7",
|
|
8
8
|
"description": "React renderer for building terminal user interfaces using Cascade core",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cascadetui/core": "0.1.
|
|
43
|
+
"@cascadetui/core": "0.1.7",
|
|
44
44
|
"react-reconciler": "^0.32.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export declare class ErrorBoundary extends React.Component<{
|
|
3
|
-
children
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
onCrash?: (error: Error, info: React.ErrorInfo) => void;
|
|
4
5
|
}, {
|
|
5
6
|
hasError: boolean;
|
|
6
7
|
error: Error | null;
|
|
7
8
|
}> {
|
|
8
9
|
constructor(props: {
|
|
9
|
-
children
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
onCrash?: (error: Error, info: React.ErrorInfo) => void;
|
|
10
12
|
});
|
|
11
13
|
static getDerivedStateFromError(error: Error): {
|
|
12
14
|
hasError: boolean;
|
|
13
15
|
error: Error;
|
|
14
16
|
};
|
|
17
|
+
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
15
18
|
render(): any;
|
|
16
19
|
}
|
|
@@ -12,6 +12,7 @@ export declare const baseComponents: {
|
|
|
12
12
|
textarea: typeof TextareaRenderable;
|
|
13
13
|
scrollbox: typeof ScrollBoxRenderable;
|
|
14
14
|
"ascii-font": typeof ASCIIFontRenderable;
|
|
15
|
+
asciifont: typeof ASCIIFontRenderable;
|
|
15
16
|
"tab-select": typeof TabSelectRenderable;
|
|
16
17
|
"line-number": typeof LineNumberRenderable;
|
|
17
18
|
span: typeof SpanRenderable;
|
package/src/components/text.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class LineBreakRenderable extends SpanRenderable {
|
|
|
21
21
|
constructor(_ctx: RenderContext | null, options: TextNodeOptions);
|
|
22
22
|
add(): number;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
interface LinkOptions extends TextNodeOptions {
|
|
25
25
|
href: string;
|
|
26
26
|
}
|
|
27
27
|
export declare class LinkRenderable extends SpanRenderable {
|
|
@@ -4,7 +4,6 @@ declare const flushSync: {
|
|
|
4
4
|
(): void;
|
|
5
5
|
<R>(fn: () => R): R;
|
|
6
6
|
};
|
|
7
|
-
declare const createPortal: (children: ReactNode, containerInfo: any, implementation: any, key?: string | null) => import("react-reconciler").ReactPortal;
|
|
8
7
|
export type Root = {
|
|
9
8
|
render: (node: ReactNode) => void;
|
|
10
9
|
unmount: () => void;
|
|
@@ -20,4 +19,4 @@ export type Root = {
|
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
21
|
export declare function createRoot(renderer: CliRenderer): Root;
|
|
23
|
-
export {
|
|
22
|
+
export { flushSync };
|
|
@@ -25,10 +25,21 @@ type ComponentProps<TOptions extends RenderableOptions<TRenderable>, TRenderable
|
|
|
25
25
|
} & ReactProps<TRenderable>;
|
|
26
26
|
/** Valid text content types for Text component children */
|
|
27
27
|
type TextChildren = string | number | boolean | null | undefined | React.ReactNode;
|
|
28
|
-
|
|
28
|
+
type TextStyleFlags = {
|
|
29
|
+
bold?: boolean;
|
|
30
|
+
italic?: boolean;
|
|
31
|
+
underline?: boolean;
|
|
32
|
+
dim?: boolean;
|
|
33
|
+
blink?: boolean;
|
|
34
|
+
inverse?: boolean;
|
|
35
|
+
hidden?: boolean;
|
|
36
|
+
strikethrough?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type TextProps = ComponentProps<TextOptions, TextRenderable> & TextStyleFlags & {
|
|
29
39
|
children?: TextChildren;
|
|
30
40
|
};
|
|
31
|
-
export type SpanProps = ComponentProps<TextNodeOptions, TextNodeRenderable> & {
|
|
41
|
+
export type SpanProps = Omit<ComponentProps<TextNodeOptions, TextNodeRenderable>, "style"> & {
|
|
42
|
+
style?: Partial<Omit<TextNodeOptions, GetNonStyledProperties<RenderableConstructor<TextNodeRenderable>>>> & TextStyleFlags;
|
|
32
43
|
children?: TextChildren;
|
|
33
44
|
};
|
|
34
45
|
export type LinkProps = SpanProps & {
|