@cascadetui/react 0.1.4 → 0.1.6
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.
|
@@ -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,
|
|
@@ -144,6 +145,9 @@ class ErrorBoundary extends React.Component {
|
|
|
144
145
|
static getDerivedStateFromError(error) {
|
|
145
146
|
return { hasError: true, error };
|
|
146
147
|
}
|
|
148
|
+
componentDidCatch(error, info) {
|
|
149
|
+
this.props.onCrash?.(error, info);
|
|
150
|
+
}
|
|
147
151
|
render() {
|
|
148
152
|
if (this.state.hasError && this.state.error) {
|
|
149
153
|
return /* @__PURE__ */ jsxDEV("box", {
|
|
@@ -163,11 +167,11 @@ import ReactReconciler from "react-reconciler";
|
|
|
163
167
|
import { ConcurrentRoot } from "react-reconciler/constants";
|
|
164
168
|
|
|
165
169
|
// src/reconciler/host-config.ts
|
|
166
|
-
import { TextNodeRenderable as TextNodeRenderable2 } from "@cascadetui/core";
|
|
170
|
+
import { ASCIIFont, TextNodeRenderable as TextNodeRenderable2, instantiate } from "@cascadetui/core";
|
|
167
171
|
// package.json
|
|
168
172
|
var package_default = {
|
|
169
173
|
name: "@cascadetui/react",
|
|
170
|
-
version: "0.1.
|
|
174
|
+
version: "0.1.6",
|
|
171
175
|
description: "React renderer for building terminal user interfaces using Cascade core",
|
|
172
176
|
license: "MIT",
|
|
173
177
|
repository: {
|
|
@@ -373,6 +377,9 @@ var hostConfig = {
|
|
|
373
377
|
throw new Error(`Component of type "${type}" must be created inside of a text node`);
|
|
374
378
|
}
|
|
375
379
|
const id = getNextId(type);
|
|
380
|
+
if (type === "asciifont") {
|
|
381
|
+
return instantiate(rootContainerInstance.ctx, ASCIIFont({ id, ...props }));
|
|
382
|
+
}
|
|
376
383
|
const components = getComponentCatalogue();
|
|
377
384
|
if (!components[type]) {
|
|
378
385
|
throw new Error(`Unknown component type: ${type}`);
|
|
@@ -564,7 +571,13 @@ function createRoot(renderer) {
|
|
|
564
571
|
return {
|
|
565
572
|
render: (node) => {
|
|
566
573
|
engine.attach(renderer);
|
|
567
|
-
container = _render(React2.createElement(AppContext.Provider, { value: { keyHandler: renderer.keyInput, renderer } }, React2.createElement(ErrorBoundary,
|
|
574
|
+
container = _render(React2.createElement(AppContext.Provider, { value: { keyHandler: renderer.keyInput, renderer } }, React2.createElement(ErrorBoundary, {
|
|
575
|
+
onCrash: (error, info) => {
|
|
576
|
+
renderer.reportCrash(error, "react-error-boundary", {
|
|
577
|
+
componentStack: info.componentStack
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}, node)), renderer.root);
|
|
568
581
|
},
|
|
569
582
|
unmount: cleanup
|
|
570
583
|
};
|
package/index.js
CHANGED
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.6",
|
|
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.6",
|
|
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;
|
|
@@ -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 & {
|