@opentui/react 0.0.0-20260518-4a54e2dc → 0.0.0-20260528-8a59fd68
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/README.md +2 -0
- package/{chunk-necf154t.js → chunk-75k1srcj.js} +1 -1
- package/index.js +1 -1
- package/package.json +4 -8
- package/scripts/runtime-plugin-support-configure.ts +99 -0
- package/scripts/runtime-plugin-support.ts +6 -0
- package/src/test-utils.d.ts +1 -9
- package/test-utils.js +1 -1
- package/scripts/runtime-plugin-support-configure.js +0 -61
- package/scripts/runtime-plugin-support-configure.js.map +0 -1
- package/scripts/runtime-plugin-support-configure.node.js +0 -7
- package/scripts/runtime-plugin-support.js +0 -4
- package/scripts/runtime-plugin-support.js.map +0 -1
- package/scripts/runtime-plugin-support.node.js +0 -7
package/README.md
CHANGED
|
@@ -102,6 +102,8 @@ OpenTUI React provides several built-in components that map to OpenTUI core rend
|
|
|
102
102
|
- **`<scrollbox>`** - A scrollable box
|
|
103
103
|
- **`<ascii-font>`** - Display ASCII art text with different font styles
|
|
104
104
|
|
|
105
|
+
QR code support is available from `@opentui/qrcode/react` and must be registered explicitly with `registerQRCode()`.
|
|
106
|
+
|
|
105
107
|
**Input Components:**
|
|
106
108
|
|
|
107
109
|
- **`<input>`** - Text input field
|
|
@@ -166,7 +166,7 @@ import { TextNodeRenderable as TextNodeRenderable2 } from "@opentui/core";
|
|
|
166
166
|
// package.json
|
|
167
167
|
var package_default = {
|
|
168
168
|
name: "@opentui/react",
|
|
169
|
-
version: "0.0.0-
|
|
169
|
+
version: "0.0.0-20260528-8a59fd68",
|
|
170
170
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
171
171
|
license: "MIT",
|
|
172
172
|
repository: {
|
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.0.0-
|
|
7
|
+
"version": "0.0.0-20260528-8a59fd68",
|
|
8
8
|
"description": "React renderer for building terminal user interfaces using OpenTUI core",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -30,15 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"./runtime-plugin-support": {
|
|
32
32
|
"types": "./scripts/runtime-plugin-support.d.ts",
|
|
33
|
-
"
|
|
34
|
-
"node": "./scripts/runtime-plugin-support.node.js",
|
|
35
|
-
"default": "./scripts/runtime-plugin-support.node.js"
|
|
33
|
+
"import": "./scripts/runtime-plugin-support.ts"
|
|
36
34
|
},
|
|
37
35
|
"./runtime-plugin-support/configure": {
|
|
38
36
|
"types": "./scripts/runtime-plugin-support-configure.d.ts",
|
|
39
|
-
"
|
|
40
|
-
"node": "./scripts/runtime-plugin-support-configure.node.js",
|
|
41
|
-
"default": "./scripts/runtime-plugin-support-configure.node.js"
|
|
37
|
+
"import": "./scripts/runtime-plugin-support-configure.ts"
|
|
42
38
|
},
|
|
43
39
|
"./jsx-runtime": {
|
|
44
40
|
"types": "./jsx-runtime.d.ts",
|
|
@@ -52,7 +48,7 @@
|
|
|
52
48
|
}
|
|
53
49
|
},
|
|
54
50
|
"dependencies": {
|
|
55
|
-
"@opentui/core": "0.0.0-
|
|
51
|
+
"@opentui/core": "0.0.0-20260528-8a59fd68",
|
|
56
52
|
"react-reconciler": "^0.33.0"
|
|
57
53
|
},
|
|
58
54
|
"devDependencies": {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { plugin as registerBunPlugin } from "bun"
|
|
2
|
+
import * as coreRuntime from "@opentui/core"
|
|
3
|
+
import {
|
|
4
|
+
createRuntimePlugin,
|
|
5
|
+
type RuntimeModuleEntry,
|
|
6
|
+
type RuntimePluginRewriteOptions,
|
|
7
|
+
} from "@opentui/core/runtime-plugin"
|
|
8
|
+
import * as reactRuntime from "react"
|
|
9
|
+
import * as reactJsxRuntime from "react/jsx-runtime"
|
|
10
|
+
import * as reactJsxDevRuntime from "react/jsx-dev-runtime"
|
|
11
|
+
import * as opentuiReactRuntime from "../index.js"
|
|
12
|
+
|
|
13
|
+
const runtimePluginSupportInstalledKey = "__opentuiReactRuntimePluginSupportInstalled__"
|
|
14
|
+
|
|
15
|
+
export interface ReactRuntimePluginSupportOptions {
|
|
16
|
+
additional?: Record<string, RuntimeModuleEntry>
|
|
17
|
+
core?: RuntimeModuleEntry
|
|
18
|
+
rewrite?: RuntimePluginRewriteOptions
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface RuntimePluginSupportInstall {
|
|
22
|
+
specifiers: ReadonlySet<string>
|
|
23
|
+
core: RuntimeModuleEntry
|
|
24
|
+
rewriteKey: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type RuntimePluginSupportState = typeof globalThis & {
|
|
28
|
+
[runtimePluginSupportInstalledKey]?: RuntimePluginSupportInstall
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const defaultRuntimeModules: Record<string, RuntimeModuleEntry> = {
|
|
32
|
+
"@opentui/react": opentuiReactRuntime as Record<string, unknown>,
|
|
33
|
+
"@opentui/react/jsx-runtime": reactJsxRuntime as Record<string, unknown>,
|
|
34
|
+
"@opentui/react/jsx-dev-runtime": reactJsxDevRuntime as Record<string, unknown>,
|
|
35
|
+
react: reactRuntime as Record<string, unknown>,
|
|
36
|
+
"react/jsx-runtime": reactJsxRuntime as Record<string, unknown>,
|
|
37
|
+
"react/jsx-dev-runtime": reactJsxDevRuntime as Record<string, unknown>,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function normalizeRewriteKey(rewrite: RuntimePluginRewriteOptions | undefined): string {
|
|
41
|
+
return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function createRuntimeModules(options?: ReactRuntimePluginSupportOptions): Record<string, RuntimeModuleEntry> {
|
|
45
|
+
return {
|
|
46
|
+
...defaultRuntimeModules,
|
|
47
|
+
...(options?.additional ?? {}),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assertCompatibleInstall(
|
|
52
|
+
install: RuntimePluginSupportInstall,
|
|
53
|
+
modules: Record<string, RuntimeModuleEntry>,
|
|
54
|
+
options?: ReactRuntimePluginSupportOptions,
|
|
55
|
+
): void {
|
|
56
|
+
for (const specifier of Object.keys(modules)) {
|
|
57
|
+
if (!install.specifiers.has(specifier)) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`OpenTUI React runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/react/runtime-plugin-support/configure before importing @opentui/react/runtime-plugin-support.`,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (options?.core && options.core !== install.core) {
|
|
65
|
+
throw new Error("OpenTUI React runtime plugin support is already installed with a different core runtime module.")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (options?.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {
|
|
69
|
+
throw new Error("OpenTUI React runtime plugin support is already installed with different rewrite options.")
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ensureRuntimePluginSupport(options: ReactRuntimePluginSupportOptions = {}): boolean {
|
|
74
|
+
const state = globalThis as RuntimePluginSupportState
|
|
75
|
+
const modules = createRuntimeModules(options)
|
|
76
|
+
const core = options.core ?? (coreRuntime as Record<string, unknown>)
|
|
77
|
+
const rewriteKey = normalizeRewriteKey(options.rewrite)
|
|
78
|
+
|
|
79
|
+
const install = state[runtimePluginSupportInstalledKey]
|
|
80
|
+
if (install) {
|
|
81
|
+
assertCompatibleInstall(install, modules, options)
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
registerBunPlugin(
|
|
86
|
+
createRuntimePlugin({
|
|
87
|
+
core,
|
|
88
|
+
additional: modules,
|
|
89
|
+
rewrite: options.rewrite,
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
state[runtimePluginSupportInstalledKey] = {
|
|
94
|
+
specifiers: new Set(Object.keys(modules)),
|
|
95
|
+
core,
|
|
96
|
+
rewriteKey,
|
|
97
|
+
}
|
|
98
|
+
return true
|
|
99
|
+
}
|
package/src/test-utils.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import { type TestRendererOptions } from "@opentui/core/testing";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
export declare function testRender(node: ReactNode, testRendererOptions: TestRendererOptions): Promise<
|
|
4
|
-
renderer: import("@opentui/core/testing").TestRenderer;
|
|
5
|
-
mockInput: import("@opentui/core/testing").MockInput;
|
|
6
|
-
mockMouse: import("@opentui/core/testing").MockMouse;
|
|
7
|
-
renderOnce: () => Promise<void>;
|
|
8
|
-
captureCharFrame: () => string;
|
|
9
|
-
captureSpans: () => import("@opentui/core").CapturedFrame;
|
|
10
|
-
resize: (width: number, height: number) => void;
|
|
11
|
-
}>;
|
|
3
|
+
export declare function testRender(node: ReactNode, testRendererOptions: TestRendererOptions): Promise<import("@opentui/core/testing").TestRendererSetup>;
|
package/test-utils.js
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { plugin as registerBunPlugin } from "bun";
|
|
2
|
-
import * as coreRuntime from "@opentui/core";
|
|
3
|
-
import { createRuntimePlugin, } from "@opentui/core/runtime-plugin";
|
|
4
|
-
import * as reactRuntime from "react";
|
|
5
|
-
import * as reactJsxRuntime from "react/jsx-runtime";
|
|
6
|
-
import * as reactJsxDevRuntime from "react/jsx-dev-runtime";
|
|
7
|
-
import * as opentuiReactRuntime from "../index.js";
|
|
8
|
-
const runtimePluginSupportInstalledKey = "__opentuiReactRuntimePluginSupportInstalled__";
|
|
9
|
-
const defaultRuntimeModules = {
|
|
10
|
-
"@opentui/react": opentuiReactRuntime,
|
|
11
|
-
"@opentui/react/jsx-runtime": reactJsxRuntime,
|
|
12
|
-
"@opentui/react/jsx-dev-runtime": reactJsxDevRuntime,
|
|
13
|
-
react: reactRuntime,
|
|
14
|
-
"react/jsx-runtime": reactJsxRuntime,
|
|
15
|
-
"react/jsx-dev-runtime": reactJsxDevRuntime,
|
|
16
|
-
};
|
|
17
|
-
function normalizeRewriteKey(rewrite) {
|
|
18
|
-
return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`;
|
|
19
|
-
}
|
|
20
|
-
function createRuntimeModules(options) {
|
|
21
|
-
return {
|
|
22
|
-
...defaultRuntimeModules,
|
|
23
|
-
...(options?.additional ?? {}),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function assertCompatibleInstall(install, modules, options) {
|
|
27
|
-
for (const specifier of Object.keys(modules)) {
|
|
28
|
-
if (!install.specifiers.has(specifier)) {
|
|
29
|
-
throw new Error(`OpenTUI React runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/react/runtime-plugin-support/configure before importing @opentui/react/runtime-plugin-support.`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (options?.core && options.core !== install.core) {
|
|
33
|
-
throw new Error("OpenTUI React runtime plugin support is already installed with a different core runtime module.");
|
|
34
|
-
}
|
|
35
|
-
if (options?.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {
|
|
36
|
-
throw new Error("OpenTUI React runtime plugin support is already installed with different rewrite options.");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export function ensureRuntimePluginSupport(options = {}) {
|
|
40
|
-
const state = globalThis;
|
|
41
|
-
const modules = createRuntimeModules(options);
|
|
42
|
-
const core = options.core ?? coreRuntime;
|
|
43
|
-
const rewriteKey = normalizeRewriteKey(options.rewrite);
|
|
44
|
-
const install = state[runtimePluginSupportInstalledKey];
|
|
45
|
-
if (install) {
|
|
46
|
-
assertCompatibleInstall(install, modules, options);
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
registerBunPlugin(createRuntimePlugin({
|
|
50
|
-
core,
|
|
51
|
-
additional: modules,
|
|
52
|
-
rewrite: options.rewrite,
|
|
53
|
-
}));
|
|
54
|
-
state[runtimePluginSupportInstalledKey] = {
|
|
55
|
-
specifiers: new Set(Object.keys(modules)),
|
|
56
|
-
core,
|
|
57
|
-
rewriteKey,
|
|
58
|
-
};
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=runtime-plugin-support-configure.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-plugin-support-configure.js","sourceRoot":"","sources":["runtime-plugin-support-configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,KAAK,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,eAAe,CAAA;AAC5C,OAAO,EACL,mBAAmB,GAGpB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,mBAAmB,MAAM,aAAa,CAAA;AAElD,MAAM,gCAAgC,GAAG,+CAA+C,CAAA;AAkBxF,MAAM,qBAAqB,GAAuC;IAChE,gBAAgB,EAAE,mBAA8C;IAChE,4BAA4B,EAAE,eAA0C;IACxE,gCAAgC,EAAE,kBAA6C;IAC/E,KAAK,EAAE,YAAuC;IAC9C,mBAAmB,EAAE,eAA0C;IAC/D,uBAAuB,EAAE,kBAA6C;CACvE,CAAA;AAED,SAAS,mBAAmB,CAAC,OAAgD;IAC3E,OAAO,GAAG,OAAO,EAAE,4BAA4B,IAAI,IAAI,IAAI,OAAO,EAAE,yBAAyB,IAAI,KAAK,EAAE,CAAA;AAC1G,CAAC;A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CAAC;IAED,iBAAiB,CACf,mBAAmB,CAAC;QAClB,IAAI;QACJ,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CACH,CAAA;IAED,KAAK,CAAC,gCAAgC,CAAC,GAAG;QACxC,UAAU,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI;QACJ,UAAU;KACX,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const errorMessage = "@opentui/react/runtime-plugin-support/configure is Bun-only and is not available in Node.js. Use Bun to import this entrypoint."
|
|
2
|
-
|
|
3
|
-
export function ensureRuntimePluginSupport() {
|
|
4
|
-
throw new Error(errorMessage)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
throw new Error(errorMessage)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-plugin-support.js","sourceRoot":"","sources":["runtime-plugin-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAElF,OAAO,EAAE,0BAA0B,EAAE,CAAA;AAGrC,0BAA0B,EAAE,CAAA"}
|