@opentui/solid 0.1.7 → 0.1.8
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 +5 -3
- package/index.js +7 -9
- package/jsx-runtime.d.ts +11 -11
- package/package.json +8 -8
- package/scripts/preload.ts +3 -3
- package/scripts/solid-plugin.ts +11 -11
- package/src/reconciler.js +7 -9
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ bun install solid-js @opentui/solid
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
1. Add jsx config to tsconfig.json:
|
|
14
|
+
|
|
14
15
|
```json
|
|
15
16
|
{
|
|
16
17
|
"compilerOptions": {
|
|
@@ -21,16 +22,17 @@ bun install solid-js @opentui/solid
|
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
2. Add preload script to bunfig.toml:
|
|
25
|
+
|
|
24
26
|
```toml
|
|
25
27
|
preload = ["@opentui/solid/preload"]
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
3. Add render function to index.tsx:
|
|
31
|
+
|
|
29
32
|
```tsx
|
|
30
|
-
import { render } from "@opentui/solid"
|
|
33
|
+
import { render } from "@opentui/solid"
|
|
31
34
|
|
|
32
|
-
render(() => <text>Hello, World!</text>)
|
|
35
|
+
render(() => <text>Hello, World!</text>)
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
|
|
36
38
|
4. Run with `bun --conditions=browser index.tsx`.
|
package/index.js
CHANGED
|
@@ -179,20 +179,20 @@ function insertTextNode(parent, node, anchor) {
|
|
|
179
179
|
textParent = parent;
|
|
180
180
|
}
|
|
181
181
|
node.textParent = textParent;
|
|
182
|
-
|
|
182
|
+
let styledText = textParent.content;
|
|
183
183
|
if (anchor && anchor instanceof TextNode) {
|
|
184
184
|
const anchorIndex = styledText.chunks.indexOf(anchor.chunk);
|
|
185
185
|
if (anchorIndex == -1) {
|
|
186
186
|
console.log("anchor not found");
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
styledText.insert(node.chunk, anchorIndex);
|
|
189
|
+
styledText = styledText.insert(node.chunk, anchorIndex);
|
|
190
190
|
} else {
|
|
191
191
|
const firstChunk = textParent.content.chunks[0];
|
|
192
192
|
if (firstChunk && !ChunkToTextNodeMap.has(firstChunk)) {
|
|
193
|
-
styledText.replace(node.chunk, firstChunk);
|
|
193
|
+
styledText = styledText.replace(node.chunk, firstChunk);
|
|
194
194
|
} else {
|
|
195
|
-
styledText.insert(node.chunk);
|
|
195
|
+
styledText = styledText.insert(node.chunk);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
textParent.content = styledText;
|
|
@@ -206,13 +206,11 @@ function removeTextNode(parent, node) {
|
|
|
206
206
|
}
|
|
207
207
|
if (parent === node.textParent && parent instanceof TextRenderable2) {
|
|
208
208
|
ChunkToTextNodeMap.delete(node.chunk);
|
|
209
|
-
|
|
210
|
-
styledText.remove(node.chunk);
|
|
211
|
-
parent.content = styledText;
|
|
209
|
+
parent.content = parent.content.remove(node.chunk);
|
|
212
210
|
} else if (node.textParent) {
|
|
213
211
|
ChunkToTextNodeMap.delete(node.chunk);
|
|
214
|
-
|
|
215
|
-
styledText.remove(node.chunk);
|
|
212
|
+
let styledText = node.textParent.content;
|
|
213
|
+
styledText = styledText.remove(node.chunk);
|
|
216
214
|
if (styledText.chunks.length > 0) {
|
|
217
215
|
node.textParent.content = styledText;
|
|
218
216
|
} else {
|
package/jsx-runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Renderable } from "@opentui/core"
|
|
1
|
+
import { Renderable } from "@opentui/core"
|
|
2
2
|
import {
|
|
3
3
|
ASCIIFontElementProps,
|
|
4
4
|
BoxElementProps,
|
|
@@ -7,25 +7,25 @@ import {
|
|
|
7
7
|
SelectElementProps,
|
|
8
8
|
TabSelectElementProps,
|
|
9
9
|
TextElementProps,
|
|
10
|
-
} from "./src/elements/index"
|
|
10
|
+
} from "./src/elements/index"
|
|
11
11
|
|
|
12
12
|
declare namespace JSX {
|
|
13
13
|
// Replace Node with Renderable
|
|
14
|
-
type Element = Renderable | ArrayElement | (string & {}) | number | boolean | null | undefined
|
|
14
|
+
type Element = Renderable | ArrayElement | (string & {}) | number | boolean | null | undefined
|
|
15
15
|
|
|
16
16
|
interface ArrayElement extends Array<Element> {}
|
|
17
17
|
|
|
18
18
|
interface IntrinsicElements {
|
|
19
|
-
ascii_font: ASCIIFontElementProps
|
|
20
|
-
box: BoxElementProps
|
|
21
|
-
group: GroupElementProps
|
|
22
|
-
input: InputElementProps
|
|
23
|
-
select: SelectElementProps
|
|
24
|
-
tab_select: TabSelectElementProps
|
|
25
|
-
text: TextElementProps
|
|
19
|
+
ascii_font: ASCIIFontElementProps
|
|
20
|
+
box: BoxElementProps
|
|
21
|
+
group: GroupElementProps
|
|
22
|
+
input: InputElementProps
|
|
23
|
+
select: SelectElementProps
|
|
24
|
+
tab_select: TabSelectElementProps
|
|
25
|
+
text: TextElementProps
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
interface ElementChildrenAttribute {
|
|
29
|
-
children: {}
|
|
29
|
+
children: {}
|
|
30
30
|
}
|
|
31
31
|
}
|
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.1.
|
|
7
|
+
"version": "0.1.8",
|
|
8
8
|
"description": "SolidJS renderer for OpenTUI",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"./jsx-dev-runtime": "./jsx-runtime.d.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@opentui/core": "0.1.
|
|
33
|
+
"@opentui/core": "0.1.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/babel__core": "
|
|
37
|
-
"babel-plugin-module-resolver": "
|
|
38
|
-
"@babel/core": "
|
|
39
|
-
"@babel/preset-typescript": "
|
|
40
|
-
"babel-preset-solid": "
|
|
36
|
+
"@types/babel__core": "7.20.5",
|
|
37
|
+
"babel-plugin-module-resolver": "5.0.2",
|
|
38
|
+
"@babel/core": "7.28.0",
|
|
39
|
+
"@babel/preset-typescript": "7.27.1",
|
|
40
|
+
"babel-preset-solid": "1.9.9",
|
|
41
41
|
"@types/bun": "latest"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"solid-js": "
|
|
44
|
+
"solid-js": "1.9.9",
|
|
45
45
|
"typescript": "^5"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/scripts/preload.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import solidTransformPlugin from "./solid-plugin"
|
|
2
|
-
import { plugin, type BunPlugin } from "bun"
|
|
1
|
+
import solidTransformPlugin from "./solid-plugin"
|
|
2
|
+
import { plugin, type BunPlugin } from "bun"
|
|
3
3
|
|
|
4
|
-
plugin(solidTransformPlugin)
|
|
4
|
+
plugin(solidTransformPlugin)
|
package/scripts/solid-plugin.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { transformAsync } from "@babel/core"
|
|
1
|
+
import { transformAsync } from "@babel/core"
|
|
2
2
|
// @ts-expect-error - Types not important.
|
|
3
|
-
import ts from "@babel/preset-typescript"
|
|
3
|
+
import ts from "@babel/preset-typescript"
|
|
4
4
|
// @ts-expect-error - Types not important.
|
|
5
|
-
import solid from "babel-preset-solid"
|
|
6
|
-
import { type BunPlugin } from "bun"
|
|
5
|
+
import solid from "babel-preset-solid"
|
|
6
|
+
import { type BunPlugin } from "bun"
|
|
7
7
|
|
|
8
8
|
const solidTransformPlugin: BunPlugin = {
|
|
9
9
|
name: "bun-plugin-solid",
|
|
@@ -26,8 +26,8 @@ const solidTransformPlugin: BunPlugin = {
|
|
|
26
26
|
// };
|
|
27
27
|
// });
|
|
28
28
|
build.onLoad({ filter: /\.(js|ts)x$/ }, async (args) => {
|
|
29
|
-
const { readFile } = await import("node:fs/promises")
|
|
30
|
-
const code = await readFile(args.path, "utf8")
|
|
29
|
+
const { readFile } = await import("node:fs/promises")
|
|
30
|
+
const code = await readFile(args.path, "utf8")
|
|
31
31
|
const transforms = await transformAsync(code, {
|
|
32
32
|
filename: args.path,
|
|
33
33
|
// env: {
|
|
@@ -46,13 +46,13 @@ const solidTransformPlugin: BunPlugin = {
|
|
|
46
46
|
],
|
|
47
47
|
[ts],
|
|
48
48
|
],
|
|
49
|
-
})
|
|
49
|
+
})
|
|
50
50
|
return {
|
|
51
51
|
contents: transforms?.code ?? "",
|
|
52
52
|
loader: "js",
|
|
53
|
-
}
|
|
54
|
-
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
55
|
},
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
export default solidTransformPlugin
|
|
58
|
+
export default solidTransformPlugin
|
package/src/reconciler.js
CHANGED
|
@@ -104,20 +104,20 @@ function insertTextNode(parent, node, anchor) {
|
|
|
104
104
|
textParent = parent;
|
|
105
105
|
}
|
|
106
106
|
node.textParent = textParent;
|
|
107
|
-
|
|
107
|
+
let styledText = textParent.content;
|
|
108
108
|
if (anchor && anchor instanceof TextNode) {
|
|
109
109
|
const anchorIndex = styledText.chunks.indexOf(anchor.chunk);
|
|
110
110
|
if (anchorIndex == -1) {
|
|
111
111
|
console.log("anchor not found");
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
-
styledText.insert(node.chunk, anchorIndex);
|
|
114
|
+
styledText = styledText.insert(node.chunk, anchorIndex);
|
|
115
115
|
} else {
|
|
116
116
|
const firstChunk = textParent.content.chunks[0];
|
|
117
117
|
if (firstChunk && !ChunkToTextNodeMap.has(firstChunk)) {
|
|
118
|
-
styledText.replace(node.chunk, firstChunk);
|
|
118
|
+
styledText = styledText.replace(node.chunk, firstChunk);
|
|
119
119
|
} else {
|
|
120
|
-
styledText.insert(node.chunk);
|
|
120
|
+
styledText = styledText.insert(node.chunk);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
textParent.content = styledText;
|
|
@@ -131,13 +131,11 @@ function removeTextNode(parent, node) {
|
|
|
131
131
|
}
|
|
132
132
|
if (parent === node.textParent && parent instanceof TextRenderable2) {
|
|
133
133
|
ChunkToTextNodeMap.delete(node.chunk);
|
|
134
|
-
|
|
135
|
-
styledText.remove(node.chunk);
|
|
136
|
-
parent.content = styledText;
|
|
134
|
+
parent.content = parent.content.remove(node.chunk);
|
|
137
135
|
} else if (node.textParent) {
|
|
138
136
|
ChunkToTextNodeMap.delete(node.chunk);
|
|
139
|
-
|
|
140
|
-
styledText.remove(node.chunk);
|
|
137
|
+
let styledText = node.textParent.content;
|
|
138
|
+
styledText = styledText.remove(node.chunk);
|
|
141
139
|
if (styledText.chunks.length > 0) {
|
|
142
140
|
node.textParent.content = styledText;
|
|
143
141
|
} else {
|