@opentui/solid 0.0.0-20260310-a34fbfd3 → 0.0.0-20260312-4e5c6783
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/index.d.ts +5 -5
- package/jsx-runtime.d.ts +1 -1
- package/package.json +2 -2
- package/scripts/preload.ts +1 -1
- package/scripts/runtime-plugin-support.ts +30 -6
- package/scripts/solid-plugin.d.ts +6 -11
- package/scripts/solid-plugin.ts +11 -118
- package/src/elements/extras.d.ts +1 -1
- package/src/elements/index.d.ts +5 -5
- package/src/reconciler.d.ts +1 -1
package/index.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export declare const testRender: (node: () => JSX.Element, renderConfig?: TestRe
|
|
|
11
11
|
captureSpans: () => import("@opentui/core").CapturedFrame;
|
|
12
12
|
resize: (width: number, height: number) => void;
|
|
13
13
|
}>;
|
|
14
|
-
export * from "./src/reconciler";
|
|
15
|
-
export * from "./src/elements";
|
|
16
|
-
export * from "./src/time-to-first-draw";
|
|
17
|
-
export * from "./src/plugins/slot";
|
|
18
|
-
export * from "./src/types/elements";
|
|
14
|
+
export * from "./src/reconciler.js";
|
|
15
|
+
export * from "./src/elements/index.js";
|
|
16
|
+
export * from "./src/time-to-first-draw.js";
|
|
17
|
+
export * from "./src/plugins/slot.js";
|
|
18
|
+
export * from "./src/types/elements.js";
|
|
19
19
|
export { type JSX };
|
package/jsx-runtime.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.0-
|
|
7
|
+
"version": "0.0.0-20260312-4e5c6783",
|
|
8
8
|
"description": "SolidJS renderer for OpenTUI",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/core": "7.28.0",
|
|
37
37
|
"@babel/preset-typescript": "7.27.1",
|
|
38
|
-
"@opentui/core": "0.0.0-
|
|
38
|
+
"@opentui/core": "0.0.0-20260312-4e5c6783",
|
|
39
39
|
"babel-plugin-module-resolver": "5.0.2",
|
|
40
40
|
"babel-preset-solid": "1.9.10",
|
|
41
41
|
"entities": "7.0.1",
|
package/scripts/preload.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { plugin as registerBunPlugin } from "bun"
|
|
2
2
|
import * as coreRuntime from "@opentui/core"
|
|
3
|
+
import {
|
|
4
|
+
createRuntimePlugin,
|
|
5
|
+
isCoreRuntimeModuleSpecifier,
|
|
6
|
+
runtimeModuleIdForSpecifier,
|
|
7
|
+
type RuntimeModuleEntry,
|
|
8
|
+
} from "@opentui/core/runtime-plugin"
|
|
3
9
|
import * as solidJsRuntime from "solid-js"
|
|
4
10
|
import * as solidJsStoreRuntime from "solid-js/store"
|
|
5
11
|
import * as solidRuntime from "../index"
|
|
@@ -11,6 +17,20 @@ type RuntimePluginSupportState = typeof globalThis & {
|
|
|
11
17
|
[runtimePluginSupportInstalledKey]?: boolean
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
const additionalRuntimeModules: Record<string, RuntimeModuleEntry> = {
|
|
21
|
+
"@opentui/solid": solidRuntime as Record<string, unknown>,
|
|
22
|
+
"solid-js": solidJsRuntime as Record<string, unknown>,
|
|
23
|
+
"solid-js/store": solidJsStoreRuntime as Record<string, unknown>,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const resolveRuntimeSpecifier = (specifier: string): string | null => {
|
|
27
|
+
if (!isCoreRuntimeModuleSpecifier(specifier) && !additionalRuntimeModules[specifier]) {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return runtimeModuleIdForSpecifier(specifier)
|
|
32
|
+
}
|
|
33
|
+
|
|
14
34
|
export function ensureRuntimePluginSupport(): boolean {
|
|
15
35
|
const state = globalThis as RuntimePluginSupportState
|
|
16
36
|
|
|
@@ -20,16 +40,20 @@ export function ensureRuntimePluginSupport(): boolean {
|
|
|
20
40
|
|
|
21
41
|
registerBunPlugin(
|
|
22
42
|
createSolidTransformPlugin({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
core: coreRuntime as Record<string, unknown>,
|
|
27
|
-
solidJs: solidJsRuntime as Record<string, unknown>,
|
|
28
|
-
solidJsStore: solidJsStoreRuntime as Record<string, unknown>,
|
|
43
|
+
moduleName: runtimeModuleIdForSpecifier("@opentui/solid"),
|
|
44
|
+
resolvePath(specifier) {
|
|
45
|
+
return resolveRuntimeSpecifier(specifier)
|
|
29
46
|
},
|
|
30
47
|
}),
|
|
31
48
|
)
|
|
32
49
|
|
|
50
|
+
registerBunPlugin(
|
|
51
|
+
createRuntimePlugin({
|
|
52
|
+
core: coreRuntime as Record<string, unknown>,
|
|
53
|
+
additional: additionalRuntimeModules,
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
|
|
33
57
|
state[runtimePluginSupportInstalledKey] = true
|
|
34
58
|
return true
|
|
35
59
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { type BunPlugin } from "bun";
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export declare function createSolidTransformPlugin(input?: {
|
|
10
|
-
mode?: Mode;
|
|
11
|
-
runtimeModules?: RuntimeModuleMap;
|
|
12
|
-
}): BunPlugin;
|
|
2
|
+
export type ResolveImportPath = (specifier: string) => string | null;
|
|
3
|
+
export interface CreateSolidTransformPluginOptions {
|
|
4
|
+
moduleName?: string;
|
|
5
|
+
resolvePath?: ResolveImportPath;
|
|
6
|
+
}
|
|
7
|
+
export declare function createSolidTransformPlugin(input?: CreateSolidTransformPluginOptions): BunPlugin;
|
|
13
8
|
declare const solidTransformPlugin: BunPlugin;
|
|
14
9
|
export default solidTransformPlugin;
|
package/scripts/solid-plugin.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { transformAsync } from "@babel/core"
|
|
2
|
+
import { readFile } from "node:fs/promises"
|
|
2
3
|
// @ts-expect-error - Types not important.
|
|
3
4
|
import ts from "@babel/preset-typescript"
|
|
4
5
|
// @ts-expect-error - Types not important.
|
|
@@ -7,127 +8,20 @@ import moduleResolver from "babel-plugin-module-resolver"
|
|
|
7
8
|
import solid from "babel-preset-solid"
|
|
8
9
|
import { type BunPlugin } from "bun"
|
|
9
10
|
|
|
10
|
-
type
|
|
11
|
+
export type ResolveImportPath = (specifier: string) => string | null
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
solidJs?: Record<string, unknown>
|
|
16
|
-
solidJsStore?: Record<string, unknown>
|
|
13
|
+
export interface CreateSolidTransformPluginOptions {
|
|
14
|
+
moduleName?: string
|
|
15
|
+
resolvePath?: ResolveImportPath
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const SOLID_JS_STORE_RUNTIME_MODULE = "opentui:solid-js-store-runtime"
|
|
23
|
-
|
|
24
|
-
// runtime mode is used by @opentui/solid/preload inside apps.
|
|
25
|
-
// It canonicalizes @opentui/* imports so external TSX/plugin modules resolve
|
|
26
|
-
// to the same runtime instance and share RendererContext.
|
|
27
|
-
// build mode is used only when building this package for npm.
|
|
28
|
-
// It avoids runtime canonicalization so dist output keeps normal externals
|
|
29
|
-
// and does not bake resolved paths into the published artifact.
|
|
30
|
-
|
|
31
|
-
const resolved = (specifier: string): string => {
|
|
32
|
-
return import.meta.resolve(specifier)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createSolidTransformPlugin(input: { mode?: Mode; runtimeModules?: RuntimeModuleMap } = {}): BunPlugin {
|
|
36
|
-
const mode = input.mode ?? "runtime"
|
|
37
|
-
const runtime = mode === "runtime"
|
|
38
|
-
const runtimeModules = input.runtimeModules
|
|
39
|
-
const injectedSolidRuntime = runtime && Boolean(runtimeModules?.solid)
|
|
18
|
+
export function createSolidTransformPlugin(input: CreateSolidTransformPluginOptions = {}): BunPlugin {
|
|
19
|
+
const moduleName = input.moduleName ?? "@opentui/solid"
|
|
20
|
+
const resolvePath = input.resolvePath
|
|
40
21
|
|
|
41
22
|
return {
|
|
42
23
|
name: "bun-plugin-solid",
|
|
43
24
|
setup: (build) => {
|
|
44
|
-
const moduleName = runtime
|
|
45
|
-
? injectedSolidRuntime
|
|
46
|
-
? SOLID_RUNTIME_MODULE
|
|
47
|
-
: resolved("@opentui/solid")
|
|
48
|
-
: "@opentui/solid"
|
|
49
|
-
|
|
50
|
-
// Runtime transform points JSX factories at the host-resolved module.
|
|
51
|
-
// Build transform must keep the public package specifier.
|
|
52
|
-
|
|
53
|
-
if (runtime && runtimeModules?.solid) {
|
|
54
|
-
const solidModuleExports = runtimeModules.solid
|
|
55
|
-
build.module(SOLID_RUNTIME_MODULE, () => ({ exports: solidModuleExports, loader: "object" }))
|
|
56
|
-
|
|
57
|
-
if (runtimeModules?.core) {
|
|
58
|
-
build.module(CORE_RUNTIME_MODULE, () => ({ exports: runtimeModules.core ?? {}, loader: "object" }))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (runtimeModules?.solidJs) {
|
|
62
|
-
build.module(SOLID_JS_RUNTIME_MODULE, () => ({ exports: runtimeModules.solidJs ?? {}, loader: "object" }))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (runtimeModules?.solidJsStore) {
|
|
66
|
-
build.module(SOLID_JS_STORE_RUNTIME_MODULE, () => ({
|
|
67
|
-
exports: runtimeModules.solidJsStore ?? {},
|
|
68
|
-
loader: "object",
|
|
69
|
-
}))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
build.onResolve({ filter: /^@opentui\/solid(?:\/.*)?$/ }, () => ({ path: SOLID_RUNTIME_MODULE }))
|
|
73
|
-
|
|
74
|
-
if (runtimeModules?.core) {
|
|
75
|
-
build.onResolve({ filter: /^@opentui\/core(?:\/.*)?$/ }, () => ({ path: CORE_RUNTIME_MODULE }))
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (runtimeModules?.solidJs) {
|
|
79
|
-
build.onResolve({ filter: /^solid-js$/ }, () => ({ path: SOLID_JS_RUNTIME_MODULE }))
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (runtimeModules?.solidJsStore) {
|
|
83
|
-
build.onResolve({ filter: /^solid-js\/store(?:\/.*)?$/ }, () => ({ path: SOLID_JS_STORE_RUNTIME_MODULE }))
|
|
84
|
-
}
|
|
85
|
-
} else if (runtime) {
|
|
86
|
-
const canonical = [/^@opentui\/solid(?:\/.*)?$/, /^@opentui\/core(?:\/.*)?$/]
|
|
87
|
-
|
|
88
|
-
for (const filter of canonical) {
|
|
89
|
-
build.onResolve({ filter }, (args) => {
|
|
90
|
-
return {
|
|
91
|
-
path: resolved(args.path),
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const resolve = (path: string) => {
|
|
98
|
-
if (!runtime) return null
|
|
99
|
-
|
|
100
|
-
if (injectedSolidRuntime) {
|
|
101
|
-
if (path.startsWith("@opentui/solid")) {
|
|
102
|
-
return SOLID_RUNTIME_MODULE
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (path.startsWith("@opentui/core") && runtimeModules?.core) {
|
|
106
|
-
return CORE_RUNTIME_MODULE
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (path === "solid-js" && runtimeModules?.solidJs) {
|
|
110
|
-
return SOLID_JS_RUNTIME_MODULE
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if ((path === "solid-js/store" || path.startsWith("solid-js/store/")) && runtimeModules?.solidJsStore) {
|
|
114
|
-
return SOLID_JS_STORE_RUNTIME_MODULE
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return null
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (path.startsWith("@opentui/solid")) {
|
|
121
|
-
return resolved(path)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (path.startsWith("@opentui/core")) {
|
|
125
|
-
return resolved(path)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return null
|
|
129
|
-
}
|
|
130
|
-
|
|
131
25
|
build.onLoad({ filter: /\/node_modules\/solid-js\/dist\/server\.js$/ }, async (args) => {
|
|
132
26
|
const path = args.path.replace("server.js", "solid.js")
|
|
133
27
|
const file = Bun.file(path)
|
|
@@ -145,14 +39,13 @@ export function createSolidTransformPlugin(input: { mode?: Mode; runtimeModules?
|
|
|
145
39
|
build.onLoad({ filter: /\.(js|ts)x$/ }, async (args) => {
|
|
146
40
|
const file = Bun.file(args.path)
|
|
147
41
|
const code = await file.text()
|
|
148
|
-
|
|
149
|
-
const plugins = runtime
|
|
42
|
+
const plugins = resolvePath
|
|
150
43
|
? [
|
|
151
44
|
[
|
|
152
45
|
moduleResolver,
|
|
153
46
|
{
|
|
154
|
-
resolvePath(
|
|
155
|
-
return
|
|
47
|
+
resolvePath(specifier: string) {
|
|
48
|
+
return resolvePath(specifier) ?? specifier
|
|
156
49
|
},
|
|
157
50
|
},
|
|
158
51
|
],
|
package/src/elements/extras.d.ts
CHANGED
package/src/elements/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, DiffRenderable, InputRenderable, LineNumberRenderable, MarkdownRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextareaRenderable, TextNodeRenderable, TextRenderable, type RenderContext, type TextNodeOptions } from "@opentui/core";
|
|
2
|
-
import type { RenderableConstructor } from "../types/elements";
|
|
3
|
-
export * from "./hooks";
|
|
4
|
-
export * from "./extras";
|
|
5
|
-
export * from "./slot";
|
|
2
|
+
import type { RenderableConstructor } from "../types/elements.js";
|
|
3
|
+
export * from "./hooks.js";
|
|
4
|
+
export * from "./extras.js";
|
|
5
|
+
export * from "./slot.js";
|
|
6
6
|
declare class SpanRenderable extends TextNodeRenderable {
|
|
7
7
|
private readonly _ctx;
|
|
8
8
|
constructor(_ctx: RenderContext | null, options: TextNodeOptions);
|
|
@@ -69,4 +69,4 @@ export declare const componentCatalogue: ComponentCatalogue;
|
|
|
69
69
|
*/
|
|
70
70
|
export declare function extend<T extends ComponentCatalogue>(objects: T): void;
|
|
71
71
|
export declare function getComponentCatalogue(): ComponentCatalogue;
|
|
72
|
-
export type { ExtendedComponentProps, ExtendedIntrinsicElements, RenderableConstructor } from "../types/elements";
|
|
72
|
+
export type { ExtendedComponentProps, ExtendedIntrinsicElements, RenderableConstructor } from "../types/elements.js";
|
package/src/reconciler.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseRenderable } from "@opentui/core";
|
|
2
|
-
import { SlotRenderable } from "./elements";
|
|
2
|
+
import { SlotRenderable } from "./elements/index.js";
|
|
3
3
|
export type DomNode = BaseRenderable;
|
|
4
4
|
export declare function createSlotNode(): SlotRenderable;
|
|
5
5
|
export declare const _render: (code: () => BaseRenderable, node: BaseRenderable) => () => void, effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) => BaseRenderable, props: T) => BaseRenderable, createElement: (tag: string) => BaseRenderable, createTextNode: (value: string) => BaseRenderable, insertNode: (parent: BaseRenderable, node: BaseRenderable, anchor?: BaseRenderable | undefined) => void, insert: <T>(parent: any, accessor: T | (() => T), marker?: any | null, initial?: any) => BaseRenderable, spread: <T>(node: any, accessor: (() => T) | T, skipChildren?: boolean) => void, setProp: <T>(node: BaseRenderable, name: string, value: T, prev?: T | undefined) => T, mergeProps: (...sources: unknown[]) => unknown, use: <A, T>(fn: (element: BaseRenderable, arg: A) => T, element: BaseRenderable, arg: A) => T;
|