@opentui/solid 0.1.11 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @opentui/solid
2
2
 
3
- Solid.js support for OpenTUI.
3
+ Solid.js support for [OpenTUI](https://github.com/sst/opentui).
4
4
 
5
5
  ## Installation
6
6
 
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(getNextId(GHOST_NODE_TAG), {});
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(id, options) {
246
- super(id, options);
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 element = new elements[tagName](id, {});
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.11",
7
+ "version": "0.1.12",
8
8
  "description": "SolidJS renderer for OpenTUI",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "./jsx-dev-runtime": "./jsx-runtime.d.ts"
31
31
  },
32
32
  "dependencies": {
33
- "@opentui/core": "0.1.11",
33
+ "@opentui/core": "0.1.12",
34
34
  "babel-plugin-module-resolver": "5.0.2",
35
35
  "@babel/core": "7.28.0",
36
36
  "@babel/preset-typescript": "7.27.1",
@@ -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, K extends Renderable = Renderable, NonStyleKeys extends keyof T = RenderableNonStyleKeys> = {
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(id: string, options: TextOptions);
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(getNextId(GHOST_NODE_TAG), {});
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(id, options) {
171
- super(id, options);
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 element = new elements[tagName](id, {});
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
  },