@opentui/solid 0.1.10 → 0.1.12
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 +1 -1
- package/index.js +11 -4
- package/package.json +6 -6
- package/scripts/solid-plugin.ts +0 -2
- package/src/elements/index.d.ts +1 -1
- package/src/elements/text-node.d.ts +2 -2
- package/src/reconciler.js +11 -4
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -235,15 +235,17 @@ class TextNode {
|
|
|
235
235
|
if (lastChild instanceof GhostTextRenderable) {
|
|
236
236
|
return lastChild;
|
|
237
237
|
}
|
|
238
|
-
const ghostNode = new GhostTextRenderable(
|
|
238
|
+
const ghostNode = new GhostTextRenderable(parent.ctx, {
|
|
239
|
+
id: getNextId(GHOST_NODE_TAG)
|
|
240
|
+
});
|
|
239
241
|
insertNode(parent, ghostNode, anchor);
|
|
240
242
|
return ghostNode;
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
class GhostTextRenderable extends TextRenderable2 {
|
|
245
|
-
constructor(
|
|
246
|
-
super(
|
|
247
|
+
constructor(ctx, options) {
|
|
248
|
+
super(ctx, options);
|
|
247
249
|
}
|
|
248
250
|
static isGhostNode(node) {
|
|
249
251
|
return node instanceof GhostTextRenderable;
|
|
@@ -251,6 +253,7 @@ class GhostTextRenderable extends TextRenderable2 {
|
|
|
251
253
|
}
|
|
252
254
|
|
|
253
255
|
// src/reconciler.ts
|
|
256
|
+
import { useContext as useContext2 } from "solid-js";
|
|
254
257
|
function _insertNode(parent, node, anchor) {
|
|
255
258
|
log("Inserting node:", node.id, "into parent:", parent.id, "with anchor:", anchor?.id);
|
|
256
259
|
if (node instanceof TextNode) {
|
|
@@ -298,7 +301,11 @@ var {
|
|
|
298
301
|
createElement(tagName) {
|
|
299
302
|
log("Creating element:", tagName);
|
|
300
303
|
const id = getNextId(tagName);
|
|
301
|
-
const
|
|
304
|
+
const solidRenderer = useContext2(RendererContext);
|
|
305
|
+
if (!solidRenderer) {
|
|
306
|
+
throw new Error("No renderer found");
|
|
307
|
+
}
|
|
308
|
+
const element = new elements[tagName](solidRenderer, { id });
|
|
302
309
|
log("Element created with id:", id);
|
|
303
310
|
return element;
|
|
304
311
|
},
|
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.12",
|
|
8
8
|
"description": "SolidJS renderer for OpenTUI",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"./jsx-dev-runtime": "./jsx-runtime.d.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@opentui/core": "0.1.
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/babel__core": "7.20.5",
|
|
33
|
+
"@opentui/core": "0.1.12",
|
|
37
34
|
"babel-plugin-module-resolver": "5.0.2",
|
|
38
35
|
"@babel/core": "7.28.0",
|
|
39
36
|
"@babel/preset-typescript": "7.27.1",
|
|
40
|
-
"babel-preset-solid": "1.9.9"
|
|
37
|
+
"babel-preset-solid": "1.9.9"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/babel__core": "7.20.5",
|
|
41
41
|
"@types/bun": "latest"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
package/scripts/solid-plugin.ts
CHANGED
|
@@ -9,14 +9,12 @@ const solidTransformPlugin: BunPlugin = {
|
|
|
9
9
|
name: "bun-plugin-solid",
|
|
10
10
|
setup: (build) => {
|
|
11
11
|
build.onLoad({ filter: /\/node_modules\/solid-js\/dist\/server\.js$/ }, async (args) => {
|
|
12
|
-
const { readFile } = await import("node:fs/promises")
|
|
13
12
|
const path = args.path.replace("server.js", "solid.js")
|
|
14
13
|
const file = Bun.file(path)
|
|
15
14
|
const code = await file.text()
|
|
16
15
|
return { contents: code, loader: "js" }
|
|
17
16
|
})
|
|
18
17
|
build.onLoad({ filter: /\.(js|ts)x$/ }, async (args) => {
|
|
19
|
-
const { readFile } = await import("node:fs/promises")
|
|
20
18
|
const file = Bun.file(args.path)
|
|
21
19
|
const code = await file.text()
|
|
22
20
|
const transforms = await transformAsync(code, {
|
package/src/elements/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const elements: {
|
|
|
13
13
|
};
|
|
14
14
|
export type Element = keyof typeof elements;
|
|
15
15
|
type RenderableNonStyleKeys = "buffered";
|
|
16
|
-
type ElementProps<T extends RenderableOptions
|
|
16
|
+
type ElementProps<T extends RenderableOptions<K>, K extends Renderable = Renderable, NonStyleKeys extends keyof T = RenderableNonStyleKeys> = {
|
|
17
17
|
style?: Omit<T, NonStyleKeys | RenderableNonStyleKeys>;
|
|
18
18
|
ref?: Ref<K>;
|
|
19
19
|
} & T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Renderable, TextRenderable, type TextChunk, type TextOptions } from "@opentui/core";
|
|
1
|
+
import { Renderable, TextRenderable, type RenderContext, type TextChunk, type TextOptions } from "@opentui/core";
|
|
2
2
|
import { type DomNode } from "../reconciler";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a text node in the SolidJS reconciler.
|
|
@@ -41,7 +41,7 @@ export declare class TextNode {
|
|
|
41
41
|
private getOrCreateTextGhostNode;
|
|
42
42
|
}
|
|
43
43
|
declare class GhostTextRenderable extends TextRenderable {
|
|
44
|
-
constructor(
|
|
44
|
+
constructor(ctx: RenderContext, options: TextOptions);
|
|
45
45
|
static isGhostNode(node: DomNode): node is GhostTextRenderable;
|
|
46
46
|
}
|
|
47
47
|
export {};
|
package/src/reconciler.js
CHANGED
|
@@ -160,15 +160,17 @@ class TextNode {
|
|
|
160
160
|
if (lastChild instanceof GhostTextRenderable) {
|
|
161
161
|
return lastChild;
|
|
162
162
|
}
|
|
163
|
-
const ghostNode = new GhostTextRenderable(
|
|
163
|
+
const ghostNode = new GhostTextRenderable(parent.ctx, {
|
|
164
|
+
id: getNextId(GHOST_NODE_TAG)
|
|
165
|
+
});
|
|
164
166
|
insertNode(parent, ghostNode, anchor);
|
|
165
167
|
return ghostNode;
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
class GhostTextRenderable extends TextRenderable2 {
|
|
170
|
-
constructor(
|
|
171
|
-
super(
|
|
172
|
+
constructor(ctx, options) {
|
|
173
|
+
super(ctx, options);
|
|
172
174
|
}
|
|
173
175
|
static isGhostNode(node) {
|
|
174
176
|
return node instanceof GhostTextRenderable;
|
|
@@ -176,6 +178,7 @@ class GhostTextRenderable extends TextRenderable2 {
|
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
// src/reconciler.ts
|
|
181
|
+
import { useContext as useContext2 } from "solid-js";
|
|
179
182
|
function _insertNode(parent, node, anchor) {
|
|
180
183
|
log("Inserting node:", node.id, "into parent:", parent.id, "with anchor:", anchor?.id);
|
|
181
184
|
if (node instanceof TextNode) {
|
|
@@ -223,7 +226,11 @@ var {
|
|
|
223
226
|
createElement(tagName) {
|
|
224
227
|
log("Creating element:", tagName);
|
|
225
228
|
const id = getNextId(tagName);
|
|
226
|
-
const
|
|
229
|
+
const solidRenderer = useContext2(RendererContext);
|
|
230
|
+
if (!solidRenderer) {
|
|
231
|
+
throw new Error("No renderer found");
|
|
232
|
+
}
|
|
233
|
+
const element = new elements[tagName](solidRenderer, { id });
|
|
227
234
|
log("Element created with id:", id);
|
|
228
235
|
return element;
|
|
229
236
|
},
|