@opentui/solid 0.1.11 → 0.1.13

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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type CliRendererConfig } from "@opentui/core";
2
2
  import type { JSX } from "./jsx-runtime";
3
- export * from "./src/elements";
4
3
  export declare const render: (node: () => JSX.Element, renderConfig?: CliRendererConfig) => Promise<void>;
4
+ export * from "./src/reconciler";
5
+ export * from "./src/elements";
5
6
  export { type JSX };
package/index.js CHANGED
@@ -6,7 +6,6 @@ import { createCliRenderer } from "@opentui/core";
6
6
  import {
7
7
  ASCIIFontRenderable,
8
8
  BoxRenderable,
9
- GroupRenderable,
10
9
  InputRenderable,
11
10
  SelectRenderable,
12
11
  TabSelectRenderable,
@@ -97,7 +96,6 @@ var useTimeline = (timeline, initialValue, targetValue, options, startTime = 0)
97
96
  var elements = {
98
97
  ascii_font: ASCIIFontRenderable,
99
98
  box: BoxRenderable,
100
- group: GroupRenderable,
101
99
  input: InputRenderable,
102
100
  select: SelectRenderable,
103
101
  tab_select: TabSelectRenderable,
@@ -235,15 +233,17 @@ class TextNode {
235
233
  if (lastChild instanceof GhostTextRenderable) {
236
234
  return lastChild;
237
235
  }
238
- const ghostNode = new GhostTextRenderable(getNextId(GHOST_NODE_TAG), {});
236
+ const ghostNode = new GhostTextRenderable(parent.ctx, {
237
+ id: getNextId(GHOST_NODE_TAG)
238
+ });
239
239
  insertNode(parent, ghostNode, anchor);
240
240
  return ghostNode;
241
241
  }
242
242
  }
243
243
 
244
244
  class GhostTextRenderable extends TextRenderable2 {
245
- constructor(id, options) {
246
- super(id, options);
245
+ constructor(ctx, options) {
246
+ super(ctx, options);
247
247
  }
248
248
  static isGhostNode(node) {
249
249
  return node instanceof GhostTextRenderable;
@@ -251,6 +251,7 @@ class GhostTextRenderable extends TextRenderable2 {
251
251
  }
252
252
 
253
253
  // src/reconciler.ts
254
+ import { useContext as useContext2 } from "solid-js";
254
255
  function _insertNode(parent, node, anchor) {
255
256
  log("Inserting node:", node.id, "into parent:", parent.id, "with anchor:", anchor?.id);
256
257
  if (node instanceof TextNode) {
@@ -298,7 +299,11 @@ var {
298
299
  createElement(tagName) {
299
300
  log("Creating element:", tagName);
300
301
  const id = getNextId(tagName);
301
- const element = new elements[tagName](id, {});
302
+ const solidRenderer = useContext2(RendererContext);
303
+ if (!solidRenderer) {
304
+ throw new Error("No renderer found");
305
+ }
306
+ const element = new elements[tagName](solidRenderer, { id });
302
307
  log("Element created with id:", id);
303
308
  return element;
304
309
  },
@@ -493,6 +498,45 @@ var {
493
498
  return nextSibling;
494
499
  }
495
500
  });
501
+ var insertStyledText = (parent, value, current, marker) => {
502
+ while (typeof current === "function")
503
+ current = current();
504
+ if (value === current)
505
+ return current;
506
+ if (current) {
507
+ if (typeof current === "object" && "__isChunk" in current) {
508
+ const node = TextNode.getTextNodeFromChunk(current);
509
+ if (node) {
510
+ _removeNode(parent, node);
511
+ }
512
+ } else if (current instanceof StyledText) {
513
+ for (const chunk of current.chunks) {
514
+ const chunkNode = TextNode.getTextNodeFromChunk(chunk);
515
+ if (!chunkNode)
516
+ continue;
517
+ _removeNode(parent, chunkNode);
518
+ }
519
+ }
520
+ }
521
+ if (value instanceof StyledText) {
522
+ log("Inserting styled text:", value.toString());
523
+ for (const chunk of value.chunks) {
524
+ insertNode(parent, createTextNode(chunk), marker);
525
+ }
526
+ return value;
527
+ } else if (value && typeof value === "object" && "__isChunk" in value) {
528
+ insertNode(parent, createTextNode(value), marker);
529
+ return value;
530
+ }
531
+ return solidUniversalInsert(parent, value, marker, current);
532
+ };
533
+ var insert = (parent, accessor, marker, initial) => {
534
+ if (marker !== undefined && !initial)
535
+ initial = [];
536
+ if (typeof accessor !== "function")
537
+ return insertStyledText(parent, accessor, initial, marker);
538
+ effect((current) => insertStyledText(parent, accessor(), current, marker), initial);
539
+ };
496
540
 
497
541
  // index.ts
498
542
  var render = async (node, renderConfig = {}) => {
@@ -512,9 +556,22 @@ export {
512
556
  useSelectionHandler,
513
557
  useRenderer,
514
558
  useKeyHandler,
559
+ use,
560
+ spread,
561
+ solidUniversalInsert,
562
+ setProp,
515
563
  render,
516
564
  onResize,
565
+ mergeProps,
566
+ memo,
567
+ insertNode,
568
+ insert,
517
569
  elements,
570
+ effect,
571
+ createTextNode,
572
+ createElement,
518
573
  createComponentTimeline,
574
+ createComponent,
575
+ _render,
519
576
  RendererContext
520
577
  };
package/jsx-runtime.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Renderable } from "@opentui/core"
2
2
  import {
3
3
  ASCIIFontElementProps,
4
4
  BoxElementProps,
5
- GroupElementProps,
6
5
  InputElementProps,
7
6
  SelectElementProps,
8
7
  TabSelectElementProps,
@@ -18,7 +17,6 @@ declare namespace JSX {
18
17
  interface IntrinsicElements {
19
18
  ascii_font: ASCIIFontElementProps
20
19
  box: BoxElementProps
21
- group: GroupElementProps
22
20
  input: InputElementProps
23
21
  select: SelectElementProps
24
22
  tab_select: TabSelectElementProps
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.13",
8
8
  "description": "SolidJS renderer for OpenTUI",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -18,11 +18,6 @@
18
18
  "import": "./index.js",
19
19
  "require": "./index.js"
20
20
  },
21
- "./reconciler": {
22
- "types": "./src/reconciler.d.ts",
23
- "import": "./src/reconciler.js",
24
- "require": "./src/reconciler.js"
25
- },
26
21
  "./preload": {
27
22
  "import": "./scripts/preload.ts"
28
23
  },
@@ -30,7 +25,7 @@
30
25
  "./jsx-dev-runtime": "./jsx-runtime.d.ts"
31
26
  },
32
27
  "dependencies": {
33
- "@opentui/core": "0.1.11",
28
+ "@opentui/core": "0.1.13",
34
29
  "babel-plugin-module-resolver": "5.0.2",
35
30
  "@babel/core": "7.28.0",
36
31
  "@babel/preset-typescript": "7.27.1",
@@ -29,7 +29,7 @@ const solidTransformPlugin: BunPlugin = {
29
29
  [
30
30
  solid,
31
31
  {
32
- moduleName: "@opentui/solid/reconciler",
32
+ moduleName: "@opentui/solid",
33
33
  generate: "universal",
34
34
  },
35
35
  ],
@@ -1,11 +1,10 @@
1
1
  import type { ASCIIFontOptions, BoxOptions, InputRenderableOptions, Renderable, RenderableOptions, SelectOption, SelectRenderableOptions, StyledText, TabSelectOption, TabSelectRenderableOptions, TextChunk, TextOptions } from "@opentui/core";
2
- import { ASCIIFontRenderable, BoxRenderable, GroupRenderable, InputRenderable, SelectRenderable, TabSelectRenderable, TextRenderable } from "@opentui/core";
2
+ import { ASCIIFontRenderable, BoxRenderable, InputRenderable, SelectRenderable, TabSelectRenderable, TextRenderable } from "@opentui/core";
3
3
  import type { JSX, Ref } from "solid-js";
4
4
  export * from "./hooks";
5
5
  export declare const elements: {
6
6
  ascii_font: typeof ASCIIFontRenderable;
7
7
  box: typeof BoxRenderable;
8
- group: typeof GroupRenderable;
9
8
  input: typeof InputRenderable;
10
9
  select: typeof SelectRenderable;
11
10
  tab_select: typeof TabSelectRenderable;
@@ -13,7 +12,7 @@ export declare const elements: {
13
12
  };
14
13
  export type Element = keyof typeof elements;
15
14
  type RenderableNonStyleKeys = "buffered";
16
- type ElementProps<T extends RenderableOptions, K extends Renderable = Renderable, NonStyleKeys extends keyof T = RenderableNonStyleKeys> = {
15
+ type ElementProps<T extends RenderableOptions<K>, K extends Renderable = Renderable, NonStyleKeys extends keyof T = RenderableNonStyleKeys> = {
17
16
  style?: Omit<T, NonStyleKeys | RenderableNonStyleKeys>;
18
17
  ref?: Ref<K>;
19
18
  } & T;
@@ -22,8 +21,6 @@ type ContainerProps = {
22
21
  };
23
22
  export type BoxElementProps = ElementProps<BoxOptions, BoxRenderable, "title"> & ContainerProps;
24
23
  export type BoxStyle = BoxElementProps["style"];
25
- export type GroupElementProps = ElementProps<RenderableOptions, GroupRenderable> & ContainerProps;
26
- export type GroupStyle = GroupElementProps["style"];
27
24
  export type InputElementProps = ElementProps<InputRenderableOptions, InputRenderable, "value" | "maxLength" | "placeholder"> & {
28
25
  onInput?: (value: string) => void;
29
26
  onSubmit?: (value: string) => void;
@@ -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 DELETED
@@ -1,474 +0,0 @@
1
- // @bun
2
- // src/reconciler.ts
3
- import {
4
- InputRenderable as InputRenderable2,
5
- InputRenderableEvents,
6
- Renderable as Renderable2,
7
- SelectRenderable as SelectRenderable2,
8
- SelectRenderableEvents,
9
- StyledText,
10
- TabSelectRenderable as TabSelectRenderable2,
11
- TabSelectRenderableEvents,
12
- TextRenderable as TextRenderable3
13
- } from "@opentui/core";
14
- import { createRenderer } from "solid-js/universal";
15
-
16
- // src/elements/index.ts
17
- import {
18
- ASCIIFontRenderable,
19
- BoxRenderable,
20
- GroupRenderable,
21
- InputRenderable,
22
- SelectRenderable,
23
- TabSelectRenderable,
24
- TextRenderable
25
- } from "@opentui/core";
26
-
27
- // src/elements/hooks.ts
28
- import {
29
- getKeyHandler,
30
- Timeline
31
- } from "@opentui/core";
32
- import { createContext, createSignal, onCleanup, onMount, useContext } from "solid-js";
33
- var RendererContext = createContext();
34
-
35
- // src/elements/index.ts
36
- var elements = {
37
- ascii_font: ASCIIFontRenderable,
38
- box: BoxRenderable,
39
- group: GroupRenderable,
40
- input: InputRenderable,
41
- select: SelectRenderable,
42
- tab_select: TabSelectRenderable,
43
- text: TextRenderable
44
- };
45
-
46
- // src/elements/text-node.ts
47
- import { Renderable, TextRenderable as TextRenderable2 } from "@opentui/core";
48
-
49
- // src/utils/id-counter.ts
50
- var idCounter = new Map;
51
- function getNextId(elementType) {
52
- if (!idCounter.has(elementType)) {
53
- idCounter.set(elementType, 0);
54
- }
55
- const value = idCounter.get(elementType) + 1;
56
- idCounter.set(elementType, value);
57
- return `${elementType}-${value}`;
58
- }
59
-
60
- // src/utils/log.ts
61
- var log = (...args) => {
62
- if (process.env.DEBUG) {
63
- console.log("[Reconciler]", ...args);
64
- }
65
- };
66
-
67
- // src/elements/text-node.ts
68
- var GHOST_NODE_TAG = "text-ghost";
69
- var ChunkToTextNodeMap = new WeakMap;
70
-
71
- class TextNode {
72
- id;
73
- chunk;
74
- parent;
75
- textParent;
76
- constructor(chunk) {
77
- this.id = getNextId("text-node");
78
- this.chunk = chunk;
79
- ChunkToTextNodeMap.set(chunk, this);
80
- }
81
- replaceText(newChunk) {
82
- const textParent = this.textParent;
83
- if (!textParent) {
84
- log("No parent found for text node:", this.id);
85
- return;
86
- }
87
- textParent.content = textParent.content.replace(newChunk, this.chunk);
88
- this.chunk = newChunk;
89
- ChunkToTextNodeMap.set(newChunk, this);
90
- }
91
- static getTextNodeFromChunk(chunk) {
92
- return ChunkToTextNodeMap.get(chunk);
93
- }
94
- insert(parent, anchor) {
95
- if (!(parent instanceof Renderable)) {
96
- log("Attaching text node to parent text node, impossible");
97
- return;
98
- }
99
- let textParent;
100
- if (!(parent instanceof TextRenderable2)) {
101
- textParent = this.getOrCreateTextGhostNode(parent, anchor);
102
- } else {
103
- textParent = parent;
104
- }
105
- this.textParent = textParent;
106
- let styledText = textParent.content;
107
- if (anchor && anchor instanceof TextNode) {
108
- const anchorIndex = styledText.chunks.indexOf(anchor.chunk);
109
- if (anchorIndex === -1) {
110
- log("anchor not found");
111
- return;
112
- }
113
- styledText = styledText.insert(this.chunk, anchorIndex);
114
- } else {
115
- const firstChunk = textParent.content.chunks[0];
116
- if (firstChunk && !ChunkToTextNodeMap.has(firstChunk)) {
117
- styledText = styledText.replace(this.chunk, firstChunk);
118
- } else {
119
- styledText = styledText.insert(this.chunk);
120
- }
121
- }
122
- textParent.content = styledText;
123
- this.parent = parent;
124
- }
125
- remove(parent) {
126
- if (!(parent instanceof Renderable)) {
127
- ChunkToTextNodeMap.delete(this.chunk);
128
- return;
129
- }
130
- if (parent === this.textParent && parent instanceof TextRenderable2) {
131
- ChunkToTextNodeMap.delete(this.chunk);
132
- parent.content = parent.content.remove(this.chunk);
133
- return;
134
- }
135
- if (this.textParent) {
136
- ChunkToTextNodeMap.delete(this.chunk);
137
- let styledText = this.textParent.content;
138
- styledText = styledText.remove(this.chunk);
139
- if (styledText.chunks.length > 0) {
140
- this.textParent.content = styledText;
141
- } else {
142
- this.parent?.remove(this.textParent.id);
143
- this.textParent.destroyRecursively();
144
- }
145
- }
146
- }
147
- getOrCreateTextGhostNode(parent, anchor) {
148
- if (anchor instanceof TextNode && anchor.textParent) {
149
- return anchor.textParent;
150
- }
151
- const children = parent.getChildren();
152
- if (anchor instanceof Renderable) {
153
- const anchorIndex = children.findIndex((el) => el.id === anchor.id);
154
- const beforeAnchor = children[anchorIndex - 1];
155
- if (beforeAnchor instanceof GhostTextRenderable) {
156
- return beforeAnchor;
157
- }
158
- }
159
- const lastChild = children.at(-1);
160
- if (lastChild instanceof GhostTextRenderable) {
161
- return lastChild;
162
- }
163
- const ghostNode = new GhostTextRenderable(getNextId(GHOST_NODE_TAG), {});
164
- insertNode(parent, ghostNode, anchor);
165
- return ghostNode;
166
- }
167
- }
168
-
169
- class GhostTextRenderable extends TextRenderable2 {
170
- constructor(id, options) {
171
- super(id, options);
172
- }
173
- static isGhostNode(node) {
174
- return node instanceof GhostTextRenderable;
175
- }
176
- }
177
-
178
- // src/reconciler.ts
179
- function _insertNode(parent, node, anchor) {
180
- log("Inserting node:", node.id, "into parent:", parent.id, "with anchor:", anchor?.id);
181
- if (node instanceof TextNode) {
182
- return node.insert(parent, anchor);
183
- }
184
- if (!(parent instanceof Renderable2)) {
185
- return;
186
- }
187
- if (anchor) {
188
- const anchorIndex = parent.getChildren().findIndex((el) => {
189
- if (anchor instanceof TextNode) {
190
- return el.id === anchor.textParent?.id;
191
- }
192
- return el.id === anchor.id;
193
- });
194
- parent.add(node, anchorIndex);
195
- } else {
196
- parent.add(node);
197
- }
198
- }
199
- function _removeNode(parent, node) {
200
- log("Removing node:", node.id, "from parent:", parent.id);
201
- if (node instanceof TextNode) {
202
- return node.remove(parent);
203
- }
204
- if (parent instanceof Renderable2 && node instanceof Renderable2) {
205
- parent.remove(node.id);
206
- node.destroyRecursively();
207
- }
208
- }
209
- var {
210
- render: _render,
211
- effect,
212
- memo,
213
- createComponent,
214
- createElement,
215
- createTextNode,
216
- insertNode,
217
- insert: solidUniversalInsert,
218
- spread,
219
- setProp,
220
- mergeProps,
221
- use
222
- } = createRenderer({
223
- createElement(tagName) {
224
- log("Creating element:", tagName);
225
- const id = getNextId(tagName);
226
- const element = new elements[tagName](id, {});
227
- log("Element created with id:", id);
228
- return element;
229
- },
230
- createTextNode(value) {
231
- log("Creating text node:", value);
232
- const chunk = typeof value === "object" && "__isChunk" in value ? value : {
233
- __isChunk: true,
234
- text: new TextEncoder().encode(`${value}`),
235
- plainText: `${value}`
236
- };
237
- const textNode = new TextNode(chunk);
238
- return textNode;
239
- },
240
- replaceText(textNode, value) {
241
- log("Replacing text:", value, "in node:", textNode.id);
242
- if (textNode instanceof Renderable2)
243
- return;
244
- const newChunk = {
245
- __isChunk: true,
246
- text: new TextEncoder().encode(value),
247
- plainText: value
248
- };
249
- textNode.replaceText(newChunk);
250
- },
251
- setProperty(node, name, value, prev) {
252
- if (node instanceof TextNode) {
253
- console.warn("Cannot set property on text node:", node.id);
254
- return;
255
- }
256
- if (name.startsWith("on:")) {
257
- const eventName = name.slice(3);
258
- if (value) {
259
- node.on(eventName, value);
260
- }
261
- if (prev) {
262
- node.off(eventName, prev);
263
- }
264
- return;
265
- }
266
- switch (name) {
267
- case "focused":
268
- if (value) {
269
- node.focus();
270
- } else {
271
- node.blur();
272
- }
273
- break;
274
- case "onChange":
275
- let event = undefined;
276
- if (node instanceof SelectRenderable2) {
277
- event = SelectRenderableEvents.SELECTION_CHANGED;
278
- } else if (node instanceof TabSelectRenderable2) {
279
- event = TabSelectRenderableEvents.SELECTION_CHANGED;
280
- } else if (node instanceof InputRenderable2) {
281
- event = InputRenderableEvents.CHANGE;
282
- }
283
- if (!event)
284
- break;
285
- if (value) {
286
- node.on(event, value);
287
- }
288
- if (prev) {
289
- node.off(event, prev);
290
- }
291
- break;
292
- case "onInput":
293
- if (node instanceof InputRenderable2) {
294
- if (value) {
295
- node.on(InputRenderableEvents.INPUT, value);
296
- }
297
- if (prev) {
298
- node.off(InputRenderableEvents.INPUT, prev);
299
- }
300
- }
301
- break;
302
- case "onSubmit":
303
- if (node instanceof InputRenderable2) {
304
- if (value) {
305
- node.on(InputRenderableEvents.ENTER, value);
306
- }
307
- if (prev) {
308
- node.off(InputRenderableEvents.ENTER, prev);
309
- }
310
- }
311
- break;
312
- case "onSelect":
313
- if (node instanceof SelectRenderable2) {
314
- if (value) {
315
- node.on(SelectRenderableEvents.ITEM_SELECTED, value);
316
- }
317
- if (prev) {
318
- node.off(SelectRenderableEvents.ITEM_SELECTED, prev);
319
- }
320
- } else if (node instanceof TabSelectRenderable2) {
321
- if (value) {
322
- node.on(TabSelectRenderableEvents.ITEM_SELECTED, value);
323
- }
324
- if (prev) {
325
- node.off(TabSelectRenderableEvents.ITEM_SELECTED, prev);
326
- }
327
- }
328
- break;
329
- case "style":
330
- for (const prop in value) {
331
- const propVal = value[prop];
332
- if (prev !== undefined && propVal === prev[prop])
333
- continue;
334
- node[prop] = propVal;
335
- }
336
- break;
337
- case "text":
338
- case "content":
339
- node[name] = typeof value === "string" ? value : Array.isArray(value) ? value.join("") : `${value}`;
340
- break;
341
- default:
342
- node[name] = value;
343
- }
344
- },
345
- isTextNode(node) {
346
- return node instanceof TextNode;
347
- },
348
- insertNode: _insertNode,
349
- removeNode: _removeNode,
350
- getParentNode(node) {
351
- log("Getting parent of node:", node.id);
352
- const parent = node.parent;
353
- if (!parent) {
354
- log("No parent found for node:", node.id);
355
- return;
356
- }
357
- log("Parent found:", parent.id, "for node:", node.id);
358
- return parent;
359
- },
360
- getFirstChild(node) {
361
- log("Getting first child of node:", node.id);
362
- if (node instanceof TextRenderable3) {
363
- const chunk = node.content.chunks[0];
364
- if (chunk) {
365
- return TextNode.getTextNodeFromChunk(chunk);
366
- } else {
367
- return;
368
- }
369
- }
370
- if (node instanceof TextNode) {
371
- return;
372
- }
373
- const firstChild = node.getChildren()[0];
374
- if (!firstChild) {
375
- log("No first child found for node:", node.id);
376
- return;
377
- }
378
- log("First child found:", firstChild.id, "for node:", node.id);
379
- return firstChild;
380
- },
381
- getNextSibling(node) {
382
- log("Getting next sibling of node:", node.id);
383
- const parent = node.parent;
384
- if (!parent) {
385
- log("No parent found for node:", node.id);
386
- return;
387
- }
388
- if (node instanceof TextNode) {
389
- if (parent instanceof TextRenderable3) {
390
- const siblings2 = parent.content.chunks;
391
- const index2 = siblings2.indexOf(node.chunk);
392
- if (index2 === -1 || index2 === siblings2.length - 1) {
393
- log("No next sibling found for node:", node.id);
394
- return;
395
- }
396
- const nextSibling2 = siblings2[index2 + 1];
397
- if (!nextSibling2) {
398
- log("Next sibling is null for node:", node.id);
399
- return;
400
- }
401
- return TextNode.getTextNodeFromChunk(nextSibling2);
402
- }
403
- console.warn("Text parent is not a text node:", node.id);
404
- return;
405
- }
406
- const siblings = parent.getChildren();
407
- const index = siblings.indexOf(node);
408
- if (index === -1 || index === siblings.length - 1) {
409
- log("No next sibling found for node:", node.id);
410
- return;
411
- }
412
- const nextSibling = siblings[index + 1];
413
- if (!nextSibling) {
414
- log("Next sibling is null for node:", node.id);
415
- return;
416
- }
417
- log("Next sibling found:", nextSibling.id, "for node:", node.id);
418
- return nextSibling;
419
- }
420
- });
421
- var insertStyledText = (parent, value, current, marker) => {
422
- while (typeof current === "function")
423
- current = current();
424
- if (value === current)
425
- return current;
426
- if (current) {
427
- if (typeof current === "object" && "__isChunk" in current) {
428
- const node = TextNode.getTextNodeFromChunk(current);
429
- if (node) {
430
- _removeNode(parent, node);
431
- }
432
- } else if (current instanceof StyledText) {
433
- for (const chunk of current.chunks) {
434
- const chunkNode = TextNode.getTextNodeFromChunk(chunk);
435
- if (!chunkNode)
436
- continue;
437
- _removeNode(parent, chunkNode);
438
- }
439
- }
440
- }
441
- if (value instanceof StyledText) {
442
- log("Inserting styled text:", value.toString());
443
- for (const chunk of value.chunks) {
444
- insertNode(parent, createTextNode(chunk), marker);
445
- }
446
- return value;
447
- } else if (value && typeof value === "object" && "__isChunk" in value) {
448
- insertNode(parent, createTextNode(value), marker);
449
- return value;
450
- }
451
- return solidUniversalInsert(parent, value, marker, current);
452
- };
453
- var insert = (parent, accessor, marker, initial) => {
454
- if (marker !== undefined && !initial)
455
- initial = [];
456
- if (typeof accessor !== "function")
457
- return insertStyledText(parent, accessor, initial, marker);
458
- effect((current) => insertStyledText(parent, accessor(), current, marker), initial);
459
- };
460
- export {
461
- use,
462
- spread,
463
- solidUniversalInsert,
464
- setProp,
465
- mergeProps,
466
- memo,
467
- insertNode,
468
- insert,
469
- effect,
470
- createTextNode,
471
- createElement,
472
- createComponent,
473
- _render
474
- };