@opentui/solid 0.1.25 → 0.1.27

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export function useTimeline(timeline: any, initialValue: any, targetValue: any, options: any, startTime?: number): import("solid-js").Accessor<any>;
1
+ export function useTimeline(options?: {}): Timeline;
2
2
  export function useTerminalDimensions(): import("solid-js").Accessor<{
3
3
  width: any;
4
4
  height: any;
@@ -34,6 +34,7 @@ export function getComponentCatalogue(): {
34
34
  ascii_font: typeof ASCIIFontRenderable;
35
35
  tab_select: typeof TabSelectRenderable2;
36
36
  scrollbox: typeof ScrollBoxRenderable;
37
+ code: typeof CodeRenderable;
37
38
  span: typeof SpanRenderable;
38
39
  strong: typeof BoldSpanRenderable;
39
40
  b: typeof BoldSpanRenderable;
@@ -48,7 +49,6 @@ export var createTextNode: any;
48
49
  export function createSlotNode(): SlotRenderable;
49
50
  export var createElement: any;
50
51
  export function createDynamic(component: any, props: any): import("solid-js").Accessor<any>;
51
- export function createComponentTimeline(options?: {}): Timeline;
52
52
  declare var createComponent2: typeof createComponent;
53
53
  export namespace componentCatalogue {
54
54
  export { BoxRenderable as box };
@@ -58,6 +58,7 @@ export namespace componentCatalogue {
58
58
  export { ASCIIFontRenderable as ascii_font };
59
59
  export { TabSelectRenderable2 as tab_select };
60
60
  export { ScrollBoxRenderable as scrollbox };
61
+ export { CodeRenderable as code };
61
62
  export { SpanRenderable as span };
62
63
  export { BoldSpanRenderable as strong };
63
64
  export { BoldSpanRenderable as b };
@@ -104,6 +105,7 @@ export function Dynamic(props: any): import("solid-js").Accessor<any>;
104
105
  export class BoldSpanRenderable extends TextModifierRenderable {
105
106
  constructor(options: any);
106
107
  }
108
+ import { Timeline } from "@opentui/core";
107
109
  import { mergeProps } from "solid-js";
108
110
  import { BoxRenderable } from "@opentui/core";
109
111
  import { TextRenderable as TextRenderable3 } from "@opentui/core";
@@ -112,12 +114,12 @@ import { SelectRenderable as SelectRenderable2 } from "@opentui/core";
112
114
  import { ASCIIFontRenderable } from "@opentui/core";
113
115
  import { TabSelectRenderable as TabSelectRenderable2 } from "@opentui/core";
114
116
  import { ScrollBoxRenderable } from "@opentui/core";
117
+ import { CodeRenderable } from "@opentui/core";
115
118
  declare class SpanRenderable extends TextNodeRenderable3 {
116
119
  constructor(_ctx: any, options: any);
117
120
  _ctx: any;
118
121
  }
119
122
  import { createRenderEffect } from "solid-js";
120
- import { Timeline } from "@opentui/core";
121
123
  import { createComponent } from "solid-js";
122
124
  declare class TextModifierRenderable extends SpanRenderable {
123
125
  }
@@ -128,6 +130,7 @@ declare class SlotBaseRenderable extends BaseRenderable {
128
130
  remove(id: any): void;
129
131
  insertBefore(obj: any, anchor: any): void;
130
132
  getRenderable(id: any): void;
133
+ findDescendantById(id: any): void;
131
134
  }
132
135
  import { Yoga } from "@opentui/core";
133
136
  import { BaseRenderable } from "@opentui/core";
package/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  // @bun
2
2
  // index.ts
3
- import { createCliRenderer } from "@opentui/core";
3
+ import { createCliRenderer, engine as engine2 } from "@opentui/core";
4
4
  import { createTestRenderer } from "@opentui/core/testing";
5
5
 
6
6
  // src/elements/index.ts
7
7
  import {
8
8
  ASCIIFontRenderable,
9
9
  BoxRenderable,
10
+ CodeRenderable,
10
11
  InputRenderable as InputRenderable2,
11
12
  ScrollBoxRenderable,
12
13
  SelectRenderable as SelectRenderable2,
@@ -18,6 +19,7 @@ import {
18
19
 
19
20
  // src/elements/hooks.ts
20
21
  import {
22
+ engine,
21
23
  Timeline
22
24
  } from "@opentui/core";
23
25
  import { createContext, createSignal, onCleanup, onMount, useContext } from "solid-js";
@@ -77,35 +79,20 @@ var useSelectionHandler = (callback) => {
77
79
  renderer.off("selection", callback);
78
80
  });
79
81
  };
80
- var createComponentTimeline = (options = {}) => {
81
- const renderer = useRenderer();
82
+ var useTimeline = (options = {}) => {
82
83
  const timeline = new Timeline(options);
83
- const frameCallback = async (dt) => timeline.update(dt);
84
84
  onMount(() => {
85
85
  if (options.autoplay !== false) {
86
86
  timeline.play();
87
87
  }
88
- renderer.setFrameCallback(frameCallback);
88
+ engine.register(timeline);
89
89
  });
90
90
  onCleanup(() => {
91
- renderer.removeFrameCallback(frameCallback);
92
91
  timeline.pause();
92
+ engine.unregister(timeline);
93
93
  });
94
94
  return timeline;
95
95
  };
96
- var useTimeline = (timeline, initialValue, targetValue, options, startTime = 0) => {
97
- const [store, setStore] = createSignal(initialValue);
98
- const { onUpdate, ...animationOptions } = options;
99
- timeline.add(store(), {
100
- ...targetValue,
101
- ...animationOptions,
102
- onUpdate: (values) => {
103
- setStore({ ...values.targets[0] });
104
- onUpdate?.(values);
105
- }
106
- }, startTime);
107
- return store;
108
- };
109
96
  // src/elements/extras.ts
110
97
  import { createEffect, createMemo as createMemo2, getOwner, onCleanup as onCleanup2, runWithOwner, splitProps, untrack as untrack2 } from "solid-js";
111
98
 
@@ -470,15 +457,7 @@ function _removeNode(parent, node) {
470
457
  node.parent = null;
471
458
  node = node.getSlotChild(parent);
472
459
  }
473
- if (isTextNodeRenderable(parent)) {
474
- if (typeof node !== "string" && !isTextNodeRenderable(node)) {
475
- console.warn("Node not a valid child of TextNode");
476
- } else {
477
- parent.remove(node);
478
- }
479
- } else {
480
- parent.remove(node.id);
481
- }
460
+ parent.remove(node.id);
482
461
  process.nextTick(() => {
483
462
  if (node instanceof BaseRenderable && !node.parent) {
484
463
  node.destroyRecursively();
@@ -756,6 +735,9 @@ class SlotBaseRenderable extends BaseRenderable2 {
756
735
  return 0;
757
736
  }
758
737
  requestRender() {}
738
+ findDescendantById(id) {
739
+ return;
740
+ }
759
741
  }
760
742
 
761
743
  class TextSlotRenderable extends TextNodeRenderable2 {
@@ -896,6 +878,7 @@ var baseComponents = {
896
878
  ascii_font: ASCIIFontRenderable,
897
879
  tab_select: TabSelectRenderable2,
898
880
  scrollbox: ScrollBoxRenderable,
881
+ code: CodeRenderable,
899
882
  span: SpanRenderable,
900
883
  strong: BoldSpanRenderable,
901
884
  b: BoldSpanRenderable,
@@ -915,6 +898,7 @@ function getComponentCatalogue() {
915
898
  // index.ts
916
899
  var render = async (node, renderConfig = {}) => {
917
900
  const renderer = await createCliRenderer(renderConfig);
901
+ engine2.attach(renderer);
918
902
  _render(() => createComponent2(RendererContext.Provider, {
919
903
  get value() {
920
904
  return renderer;
@@ -926,6 +910,7 @@ var render = async (node, renderConfig = {}) => {
926
910
  };
927
911
  var testRender = async (node, renderConfig = {}) => {
928
912
  const testSetup = await createTestRenderer(renderConfig);
913
+ engine2.attach(testSetup.renderer);
929
914
  _render(() => createComponent2(RendererContext.Provider, {
930
915
  get value() {
931
916
  return testSetup.renderer;
@@ -962,7 +947,6 @@ export {
962
947
  createSlotNode,
963
948
  createElement,
964
949
  createDynamic,
965
- createComponentTimeline,
966
950
  createComponent2 as createComponent,
967
951
  componentCatalogue,
968
952
  baseComponents,
package/jsx-runtime.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Renderable } from "@opentui/core"
2
2
  import type {
3
3
  AsciiFontProps,
4
4
  BoxProps,
5
+ CodeProps,
5
6
  ExtendedIntrinsicElements,
6
7
  InputProps,
7
8
  OpenTUIComponents,
@@ -28,6 +29,7 @@ declare namespace JSX {
28
29
  ascii_font: AsciiFontProps
29
30
  tab_select: TabSelectProps
30
31
  scrollbox: ScrollBoxProps
32
+ code: CodeProps
31
33
 
32
34
  b: SpanProps
33
35
  strong: SpanProps
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.25",
7
+ "version": "0.1.27",
8
8
  "description": "SolidJS renderer for OpenTUI",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@babel/core": "7.28.0",
29
29
  "@babel/preset-typescript": "7.27.1",
30
- "@opentui/core": "0.1.25",
30
+ "@opentui/core": "0.1.27",
31
31
  "babel-plugin-module-resolver": "5.0.2",
32
32
  "babel-preset-solid": "1.9.9",
33
33
  "s-js": "^0.4.9"
@@ -35,6 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@types/babel__core": "7.20.5",
37
37
  "@types/bun": "latest",
38
+ "@types/node": "latest",
38
39
  "typescript": "^5"
39
40
  },
40
41
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import { Selection, Timeline, type AnimationOptions, type CliRenderer, type JSAnimation, type ParsedKey, type TimelineOptions } from "@opentui/core";
1
+ import { PasteEvent, Selection, Timeline, type CliRenderer, type KeyEvent, type TimelineOptions } from "@opentui/core";
2
2
  export declare const RendererContext: import("solid-js").Context<CliRenderer | undefined>;
3
3
  export declare const useRenderer: () => CliRenderer;
4
4
  export declare const onResize: (callback: (width: number, height: number) => void) => void;
@@ -6,16 +6,11 @@ export declare const useTerminalDimensions: () => import("solid-js").Accessor<{
6
6
  width: number;
7
7
  height: number;
8
8
  }>;
9
- export declare const useKeyboard: (callback: (key: ParsedKey) => void) => void;
10
- export declare const usePaste: (callback: (text: string) => void) => void;
9
+ export declare const useKeyboard: (callback: (key: KeyEvent) => void) => void;
10
+ export declare const usePaste: (callback: (event: PasteEvent) => void) => void;
11
11
  /**
12
12
  * @deprecated renamed to useKeyboard
13
13
  */
14
- export declare const useKeyHandler: (callback: (key: ParsedKey) => void) => void;
14
+ export declare const useKeyHandler: (callback: (key: KeyEvent) => void) => void;
15
15
  export declare const useSelectionHandler: (callback: (selection: Selection) => void) => void;
16
- export declare const createComponentTimeline: (options?: TimelineOptions) => Timeline;
17
- export declare const useTimeline: <T extends Record<string, number>>(timeline: Timeline, initialValue: T, targetValue: T, options: AnimationOptions & {
18
- onUpdate?: (values: JSAnimation & {
19
- targets: T[];
20
- }) => void;
21
- }, startTime?: number | string) => import("solid-js").Accessor<T>;
16
+ export declare const useTimeline: (options?: TimelineOptions) => Timeline;
@@ -1,4 +1,4 @@
1
- import { ASCIIFontRenderable, BoxRenderable, InputRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextNodeRenderable, TextRenderable, type RenderContext, type TextNodeOptions } from "@opentui/core";
1
+ import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, InputRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextNodeRenderable, TextRenderable, type RenderContext, type TextNodeOptions } from "@opentui/core";
2
2
  import type { RenderableConstructor } from "../types/elements";
3
3
  export * from "./hooks";
4
4
  export * from "./extras";
@@ -33,6 +33,7 @@ export declare const baseComponents: {
33
33
  ascii_font: typeof ASCIIFontRenderable;
34
34
  tab_select: typeof TabSelectRenderable;
35
35
  scrollbox: typeof ScrollBoxRenderable;
36
+ code: typeof CodeRenderable;
36
37
  span: typeof SpanRenderable;
37
38
  strong: typeof BoldSpanRenderable;
38
39
  b: typeof BoldSpanRenderable;
@@ -8,6 +8,7 @@ declare class SlotBaseRenderable extends BaseRenderable {
8
8
  getRenderable(id: string): BaseRenderable | undefined;
9
9
  getChildrenCount(): number;
10
10
  requestRender(): void;
11
+ findDescendantById(id: string): BaseRenderable | undefined;
11
12
  }
12
13
  export declare class TextSlotRenderable extends TextNodeRenderable {
13
14
  protected slotParent?: SlotRenderable;
@@ -1,4 +1,4 @@
1
- import type { ASCIIFontOptions, ASCIIFontRenderable, BaseRenderable, BoxOptions, BoxRenderable, InputRenderable, InputRenderableOptions, RenderableOptions, RenderContext, ScrollBoxOptions, ScrollBoxRenderable, SelectOption, SelectRenderable, SelectRenderableOptions, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextNodeRenderable, TextOptions, TextRenderable } from "@opentui/core";
1
+ import type { ASCIIFontOptions, ASCIIFontRenderable, BaseRenderable, BoxOptions, BoxRenderable, CodeOptions, CodeRenderable, InputRenderable, InputRenderableOptions, RenderableOptions, RenderContext, ScrollBoxOptions, ScrollBoxRenderable, SelectOption, SelectRenderable, SelectRenderableOptions, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextNodeRenderable, TextOptions, TextRenderable } from "@opentui/core";
2
2
  import type { Ref } from "solid-js";
3
3
  import type { JSX } from "../../jsx-runtime";
4
4
  /** Properties that should not be included in the style prop */
@@ -14,7 +14,7 @@ type ExtractRenderableOptions<TConstructor> = TConstructor extends new (ctx: Ren
14
14
  /** Extract the renderable type from a constructor */
15
15
  type ExtractRenderable<TConstructor> = TConstructor extends new (ctx: RenderContext, options: any) => infer TRenderable ? TRenderable : never;
16
16
  /** Determine which properties should be excluded from styling for different renderable types */
17
- export type GetNonStyledProperties<TConstructor> = TConstructor extends RenderableConstructor<TextRenderable> ? NonStyledProps | "content" : TConstructor extends RenderableConstructor<BoxRenderable> ? NonStyledProps | "title" : TConstructor extends RenderableConstructor<ASCIIFontRenderable> ? NonStyledProps | "text" | "selectable" : TConstructor extends RenderableConstructor<InputRenderable> ? NonStyledProps | "placeholder" | "value" : NonStyledProps;
17
+ export type GetNonStyledProperties<TConstructor> = TConstructor extends RenderableConstructor<TextRenderable> ? NonStyledProps | "content" : TConstructor extends RenderableConstructor<BoxRenderable> ? NonStyledProps | "title" : TConstructor extends RenderableConstructor<ASCIIFontRenderable> ? NonStyledProps | "text" | "selectable" : TConstructor extends RenderableConstructor<InputRenderable> ? NonStyledProps | "placeholder" | "value" : TConstructor extends RenderableConstructor<CodeRenderable> ? NonStyledProps | "content" | "filetype" | "syntaxStyle" | "treeSitterClient" : NonStyledProps;
18
18
  /** Base props for container components that accept children */
19
19
  type ContainerProps<TOptions> = TOptions & {
20
20
  children?: JSX.Element;
@@ -54,6 +54,7 @@ export type ScrollBoxProps = ComponentProps<ContainerProps<ScrollBoxOptions>, Sc
54
54
  stickyScroll?: boolean;
55
55
  stickyStart?: "bottom" | "top" | "left" | "right";
56
56
  };
57
+ export type CodeProps = ComponentProps<CodeOptions, CodeRenderable>;
57
58
  /** Convert renderable constructor to component props with proper style exclusions */
58
59
  export type ExtendedComponentProps<TConstructor extends RenderableConstructor, TOptions = ExtractRenderableOptions<TConstructor>> = TOptions & {
59
60
  children?: JSX.Element;