@opentui/core 0.2.1 → 0.2.3

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/index.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  registerCorePlugin,
71
71
  resolveCoreSlot,
72
72
  vstyles
73
- } from "./index-hxymw48q.js";
73
+ } from "./index-4w8751xf.js";
74
74
  import {
75
75
  ASCIIFontSelectionHelper,
76
76
  ATTRIBUTE_BASE_BITS,
@@ -245,7 +245,7 @@ import {
245
245
  white,
246
246
  wrapWithDelegates,
247
247
  yellow
248
- } from "./index-b9g14b8c.js";
248
+ } from "./index-hmk8xzt3.js";
249
249
  export {
250
250
  yellow,
251
251
  wrapWithDelegates,
@@ -1,4 +1,4 @@
1
- import type { Pointer } from "bun:ffi";
1
+ import type { Pointer } from "../platform/ffi.js";
2
2
  import type { RenderLib } from "../zig.js";
3
3
  export declare enum ClipboardTarget {
4
4
  Clipboard = 0,
@@ -31,18 +31,25 @@ export interface NormalizedTerminalPalette {
31
31
  export type OscSubscriptionSource = {
32
32
  subscribeOsc(handler: (sequence: string) => void): () => void;
33
33
  };
34
+ export interface TerminalPaletteOptions {
35
+ stdin: NodeJS.ReadStream;
36
+ stdout: NodeJS.WriteStream;
37
+ writeFn?: WriteFunction;
38
+ isLegacyTmux?: boolean;
39
+ isTmux?: boolean;
40
+ oscSource?: OscSubscriptionSource;
41
+ clock?: Clock;
42
+ }
34
43
  export declare class TerminalPalette implements TerminalPaletteDetector {
35
44
  private stdin;
36
45
  private stdout;
37
46
  private writeFn;
38
47
  private activeQuerySessions;
39
48
  private inLegacyTmux;
49
+ private inTmux;
40
50
  private oscSource?;
41
51
  private readonly clock;
42
- constructor(stdin: NodeJS.ReadStream, stdout: NodeJS.WriteStream, writeFn?: WriteFunction, isLegacyTmux?: boolean, oscSource?: OscSubscriptionSource, clock?: Clock);
43
- /**
44
- * Write an OSC sequence, wrapping for tmux if needed
45
- */
52
+ constructor(options: TerminalPaletteOptions);
46
53
  private writeOsc;
47
54
  cleanup(): void;
48
55
  private subscribeInput;
@@ -52,7 +59,7 @@ export declare class TerminalPalette implements TerminalPaletteDetector {
52
59
  private querySpecialColors;
53
60
  detect(options?: GetPaletteOptions): Promise<TerminalColors>;
54
61
  }
55
- export declare function createTerminalPalette(stdin: NodeJS.ReadStream, stdout: NodeJS.WriteStream, writeFn?: WriteFunction, isLegacyTmux?: boolean, oscSource?: OscSubscriptionSource, clock?: Clock): TerminalPaletteDetector;
62
+ export declare function createTerminalPalette(options: TerminalPaletteOptions): TerminalPaletteDetector;
56
63
  export declare function normalizeTerminalPalette(colors?: TerminalColors | null): NormalizedTerminalPalette;
57
64
  export declare function buildTerminalPaletteSignature(colors?: TerminalColors | null): string;
58
65
  export {};
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.2.1",
7
+ "version": "0.2.3",
8
8
  "description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -33,6 +33,11 @@
33
33
  "require": "./runtime-plugin-support.js",
34
34
  "types": "./runtime-plugin-support.d.ts"
35
35
  },
36
+ "./runtime-plugin-support/configure": {
37
+ "import": "./runtime-plugin-support-configure.js",
38
+ "require": "./runtime-plugin-support-configure.js",
39
+ "types": "./runtime-plugin-support-configure.d.ts"
40
+ },
36
41
  "./parser.worker": {
37
42
  "import": "./lib/tree-sitter/parser.worker.js",
38
43
  "require": "./lib/tree-sitter/parser.worker.js",
@@ -40,7 +45,7 @@
40
45
  }
41
46
  },
42
47
  "dependencies": {
43
- "bun-ffi-structs": "0.1.2",
48
+ "bun-ffi-structs": "0.2.2",
44
49
  "diff": "9.0.0",
45
50
  "marked": "17.0.1",
46
51
  "string-width": "7.2.0",
@@ -59,11 +64,11 @@
59
64
  "web-tree-sitter": "0.25.10"
60
65
  },
61
66
  "optionalDependencies": {
62
- "@opentui/core-darwin-x64": "0.2.1",
63
- "@opentui/core-darwin-arm64": "0.2.1",
64
- "@opentui/core-linux-x64": "0.2.1",
65
- "@opentui/core-linux-arm64": "0.2.1",
66
- "@opentui/core-win32-x64": "0.2.1",
67
- "@opentui/core-win32-arm64": "0.2.1"
67
+ "@opentui/core-darwin-x64": "0.2.3",
68
+ "@opentui/core-darwin-arm64": "0.2.3",
69
+ "@opentui/core-linux-x64": "0.2.3",
70
+ "@opentui/core-linux-arm64": "0.2.3",
71
+ "@opentui/core-win32-x64": "0.2.3",
72
+ "@opentui/core-win32-arm64": "0.2.3"
68
73
  }
69
74
  }
package/platform/ffi.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  declare const pointerBrand: unique symbol;
2
- export type Pointer = (number | bigint) & {
2
+ export type PointerInput = number | bigint;
3
+ export type Pointer = PointerInput & {
3
4
  readonly [pointerBrand]: "Pointer";
4
5
  };
5
- type PointerSource = ArrayBuffer | (ArrayBufferView & {
6
- buffer: ArrayBuffer;
7
- });
6
+ type PointerSource = ArrayBufferLike | ArrayBufferView;
8
7
  type BunPointer = number;
9
8
  export declare const FFIType: {
10
9
  readonly char: "char";
@@ -116,7 +115,8 @@ export declare const NODE_STRING_RETURN = "Node FFI backend does not normalize s
116
115
  export declare const NODE_USIZE_UNSUPPORTED = "Node FFI backend does not support usize until (yet)";
117
116
  export declare const POINTER_NEGATIVE = "Pointer must be non-negative";
118
117
  export declare const POINTER_UNSAFE = "Pointer exceeds safe integer range";
119
- export declare function toPointer(value: number | bigint): Pointer;
118
+ export declare function toPointer(value: PointerInput): Pointer;
119
+ export declare function ffiBool(value: boolean): 0 | 1;
120
120
  export declare function createBunBackend(bun: BunFfiBackend): FfiBackend;
121
121
  export declare function createNodeBackend(nodeFfi: NodeFfiBackend): FfiBackend;
122
122
  export declare const dlopen: <Fns extends Record<string, FFIFunction>>(path: string | URL, symbols: Fns) => Library<Fns>;
package/renderer.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Renderable, RootRenderable } from "./Renderable.js";
2
2
  import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type RenderContext, type ThemeMode, type WidthMethod } from "./types.js";
3
3
  import { RGBA, type ColorInput } from "./lib/RGBA.js";
4
- import type { Pointer } from "bun:ffi";
4
+ import type { Pointer } from "./platform/ffi.js";
5
5
  import { OptimizedBuffer } from "./buffer.js";
6
6
  import { type RenderLib } from "./zig.js";
7
7
  import { TerminalConsole, type ConsoleOptions } from "./console.js";
@@ -150,6 +150,7 @@ export declare enum CliRenderEvents {
150
150
  FOCUSED_RENDERABLE = "focused_renderable",
151
151
  FOCUSED_EDITOR = "focused_editor",
152
152
  THEME_MODE = "theme_mode",
153
+ PALETTE = "palette",
153
154
  CAPABILITIES = "capabilities",
154
155
  SELECTION = "selection",
155
156
  DEBUG_OVERLAY_TOGGLE = "debugOverlay:toggle",
@@ -226,6 +227,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
226
227
  private animationRequest;
227
228
  private resizeTimeoutId;
228
229
  private capabilityTimeoutId;
230
+ private xtVersionWaiters;
229
231
  private splitStartupSeedTimeoutId;
230
232
  private pendingSplitStartupCursorSeed;
231
233
  private resizeDebounceDelay;
@@ -267,11 +269,11 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
267
269
  private _openConsoleOnError;
268
270
  private _paletteDetector;
269
271
  private _paletteCache;
270
- private _cachedPalette;
271
272
  private _paletteDetectionPromise;
272
273
  private _paletteDetectionSize;
273
274
  private _paletteEpoch;
274
- private _publishedPaletteSignature;
275
+ private _nativePaletteSignature;
276
+ private _emittedPaletteSignature;
275
277
  private _palettePublishGeneration;
276
278
  private _onDestroy?;
277
279
  private themeModeState;
@@ -492,7 +494,11 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
492
494
  private getCachedPaletteBySize;
493
495
  private ensurePaletteDetector;
494
496
  private syncNativePaletteState;
495
- private ensureNativePaletteState;
497
+ private emitPaletteChange;
498
+ private resolveXtVersionWaiters;
499
+ private waitForXtVersion;
500
+ private shouldSyncNativePaletteState;
501
+ private refreshPalette;
496
502
  clearPaletteCache(): void;
497
503
  /**
498
504
  * Detects the terminal's color palette
@@ -0,0 +1,4 @@
1
+ import { type CreateRuntimePluginOptions } from "./runtime-plugin.js";
2
+ export declare function ensureRuntimePluginSupport(options?: CreateRuntimePluginOptions): boolean;
3
+ export { createRuntimePlugin, runtimeModuleIdForSpecifier } from "./runtime-plugin.js";
4
+ export type { CreateRuntimePluginOptions, RuntimeModuleEntry, RuntimeModuleExports, RuntimeModuleLoader, } from "./runtime-plugin.js";
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import {
3
+ ensureRuntimePluginSupport
4
+ } from "./index-gdtdtsgp.js";
5
+ import {
6
+ createRuntimePlugin,
7
+ runtimeModuleIdForSpecifier
8
+ } from "./index-8csdw3z7.js";
9
+ import"./index-4w8751xf.js";
10
+ import"./index-hmk8xzt3.js";
11
+ export {
12
+ runtimeModuleIdForSpecifier,
13
+ ensureRuntimePluginSupport,
14
+ createRuntimePlugin
15
+ };
16
+
17
+ //# debugId=20E180CC53AAFA2A64756E2164756E21
18
+ //# sourceMappingURL=runtime-plugin-support-configure.js.map
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "20E180CC53AAFA2A64756E2164756E21",
8
+ "names": []
9
+ }
@@ -1,3 +1,3 @@
1
- import { createRuntimePlugin, runtimeModuleIdForSpecifier, type CreateRuntimePluginOptions, type RuntimeModuleEntry, type RuntimeModuleExports, type RuntimeModuleLoader } from "./runtime-plugin.js";
2
- export declare function ensureRuntimePluginSupport(options?: CreateRuntimePluginOptions): boolean;
3
- export { createRuntimePlugin, runtimeModuleIdForSpecifier, type CreateRuntimePluginOptions, type RuntimeModuleEntry, type RuntimeModuleExports, type RuntimeModuleLoader, };
1
+ import { ensureRuntimePluginSupport } from "./runtime-plugin-support-configure.js";
2
+ export { ensureRuntimePluginSupport };
3
+ export { createRuntimePlugin, runtimeModuleIdForSpecifier, type CreateRuntimePluginOptions, type RuntimeModuleEntry, type RuntimeModuleExports, type RuntimeModuleLoader, } from "./runtime-plugin-support-configure.js";
@@ -1,23 +1,14 @@
1
1
  // @bun
2
+ import {
3
+ ensureRuntimePluginSupport
4
+ } from "./index-gdtdtsgp.js";
2
5
  import {
3
6
  createRuntimePlugin,
4
7
  runtimeModuleIdForSpecifier
5
- } from "./index-htg1x5tj.js";
6
- import"./index-hxymw48q.js";
7
- import"./index-b9g14b8c.js";
8
-
8
+ } from "./index-8csdw3z7.js";
9
+ import"./index-4w8751xf.js";
10
+ import"./index-hmk8xzt3.js";
9
11
  // src/runtime-plugin-support.ts
10
- var {plugin: registerBunPlugin } = globalThis.Bun;
11
- var runtimePluginSupportInstalledKey = "__opentuiCoreRuntimePluginSupportInstalled__";
12
- function ensureRuntimePluginSupport(options = {}) {
13
- const state = globalThis;
14
- if (state[runtimePluginSupportInstalledKey]) {
15
- return false;
16
- }
17
- registerBunPlugin(createRuntimePlugin(options));
18
- state[runtimePluginSupportInstalledKey] = true;
19
- return true;
20
- }
21
12
  ensureRuntimePluginSupport();
22
13
  export {
23
14
  runtimeModuleIdForSpecifier,
@@ -25,5 +16,5 @@ export {
25
16
  createRuntimePlugin
26
17
  };
27
18
 
28
- //# debugId=7487C2BFD13C698664756E2164756E21
19
+ //# debugId=77F70D7DCCE5C8F764756E2164756E21
29
20
  //# sourceMappingURL=runtime-plugin-support.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/runtime-plugin-support.ts"],
4
4
  "sourcesContent": [
5
- "import { plugin as registerBunPlugin } from \"bun\"\nimport {\n createRuntimePlugin,\n runtimeModuleIdForSpecifier,\n type CreateRuntimePluginOptions,\n type RuntimeModuleEntry,\n type RuntimeModuleExports,\n type RuntimeModuleLoader,\n} from \"./runtime-plugin.js\"\n\nconst runtimePluginSupportInstalledKey = \"__opentuiCoreRuntimePluginSupportInstalled__\"\n\ntype RuntimePluginSupportState = typeof globalThis & {\n [runtimePluginSupportInstalledKey]?: boolean\n}\n\nexport function ensureRuntimePluginSupport(options: CreateRuntimePluginOptions = {}): boolean {\n const state = globalThis as RuntimePluginSupportState\n\n if (state[runtimePluginSupportInstalledKey]) {\n return false\n }\n\n registerBunPlugin(createRuntimePlugin(options))\n\n state[runtimePluginSupportInstalledKey] = true\n return true\n}\n\nensureRuntimePluginSupport()\n\nexport {\n createRuntimePlugin,\n runtimeModuleIdForSpecifier,\n type CreateRuntimePluginOptions,\n type RuntimeModuleEntry,\n type RuntimeModuleExports,\n type RuntimeModuleLoader,\n}\n"
5
+ "import { ensureRuntimePluginSupport } from \"./runtime-plugin-support-configure.js\"\n\nexport { ensureRuntimePluginSupport }\nexport {\n createRuntimePlugin,\n runtimeModuleIdForSpecifier,\n type CreateRuntimePluginOptions,\n type RuntimeModuleEntry,\n type RuntimeModuleExports,\n type RuntimeModuleLoader,\n} from \"./runtime-plugin-support-configure.js\"\n\nensureRuntimePluginSupport()\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;AAAA;AAUA,IAAM,mCAAmC;AAMlC,SAAS,0BAA0B,CAAC,UAAsC,CAAC,GAAY;AAAA,EAC5F,MAAM,QAAQ;AAAA,EAEd,IAAI,MAAM,mCAAmC;AAAA,IAC3C,OAAO;AAAA,EACT;AAAA,EAEA,kBAAkB,oBAAoB,OAAO,CAAC;AAAA,EAE9C,MAAM,oCAAoC;AAAA,EAC1C,OAAO;AAAA;AAGT,2BAA2B;",
8
- "debugId": "7487C2BFD13C698664756E2164756E21",
7
+ "mappings": ";;;;;;;;;;;AAYA,2BAA2B;",
8
+ "debugId": "77F70D7DCCE5C8F764756E2164756E21",
9
9
  "names": []
10
10
  }
package/runtime-plugin.js CHANGED
@@ -3,9 +3,9 @@ import {
3
3
  createRuntimePlugin,
4
4
  isCoreRuntimeModuleSpecifier,
5
5
  runtimeModuleIdForSpecifier
6
- } from "./index-htg1x5tj.js";
7
- import"./index-hxymw48q.js";
8
- import"./index-b9g14b8c.js";
6
+ } from "./index-8csdw3z7.js";
7
+ import"./index-4w8751xf.js";
8
+ import"./index-hmk8xzt3.js";
9
9
  export {
10
10
  runtimeModuleIdForSpecifier,
11
11
  isCoreRuntimeModuleSpecifier,
package/syntax-style.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RGBA, type ColorInput } from "./lib/RGBA.js";
2
2
  import { type RenderLib } from "./zig.js";
3
- import { type Pointer } from "bun:ffi";
3
+ import { type Pointer } from "./platform/ffi.js";
4
4
  export interface StyleDefinition {
5
5
  fg?: RGBA;
6
6
  bg?: RGBA;
package/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  TreeSitterClient,
6
6
  calculateRenderGeometry,
7
7
  resolveRenderLib
8
- } from "./index-b9g14b8c.js";
8
+ } from "./index-hmk8xzt3.js";
9
9
 
10
10
  // src/testing/test-renderer.ts
11
11
  import { Readable, Writable } from "stream";
@@ -1,6 +1,6 @@
1
1
  import { RGBA } from "./lib/RGBA.js";
2
2
  import { type LineInfo, type RenderLib } from "./zig.js";
3
- import { type Pointer } from "bun:ffi";
3
+ import { type Pointer } from "./platform/ffi.js";
4
4
  import type { TextBuffer } from "./text-buffer.js";
5
5
  export declare class TextBufferView {
6
6
  private lib;
package/text-buffer.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { StyledText } from "./lib/styled-text.js";
2
2
  import { RGBA } from "./lib/RGBA.js";
3
3
  import { type RenderLib } from "./zig.js";
4
- import { type Pointer } from "bun:ffi";
4
+ import { type Pointer } from "./platform/ffi.js";
5
5
  import { type WidthMethod, type Highlight } from "./types.js";
6
6
  import type { SyntaxStyle } from "./syntax-style.js";
7
7
  export interface TextChunk {
package/zig-structs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Pointer } from "bun:ffi";
1
+ import { type Pointer } from "./platform/ffi.js";
2
2
  import { RGBA } from "./lib/RGBA.js";
3
3
  type StyledChunkInput = {
4
4
  text: string;
@@ -38,7 +38,7 @@ export declare const VisualCursorStruct: import("bun-ffi-structs").DefineStructR
38
38
  export declare const TerminalCapabilitiesStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["kitty_keyboard", "bool_u8"], readonly ["kitty_graphics", "bool_u8"], readonly ["rgb", "bool_u8"], readonly ["ansi256", "bool_u8"], readonly ["unicode", import("bun-ffi-structs").EnumDef<{
39
39
  wcwidth: number;
40
40
  unicode: number;
41
- }>], readonly ["sgr_pixels", "bool_u8"], readonly ["color_scheme_updates", "bool_u8"], readonly ["explicit_width", "bool_u8"], readonly ["scaled_text", "bool_u8"], readonly ["sixel", "bool_u8"], readonly ["focus_tracking", "bool_u8"], readonly ["sync", "bool_u8"], readonly ["bracketed_paste", "bool_u8"], readonly ["hyperlinks", "bool_u8"], readonly ["osc52", "bool_u8"], readonly ["explicit_cursor_positioning", "bool_u8"], readonly ["term_name", "char*"], readonly ["term_name_len", "u64", {
41
+ }>], readonly ["sgr_pixels", "bool_u8"], readonly ["color_scheme_updates", "bool_u8"], readonly ["explicit_width", "bool_u8"], readonly ["scaled_text", "bool_u8"], readonly ["sixel", "bool_u8"], readonly ["focus_tracking", "bool_u8"], readonly ["sync", "bool_u8"], readonly ["bracketed_paste", "bool_u8"], readonly ["hyperlinks", "bool_u8"], readonly ["osc52", "bool_u8"], readonly ["explicit_cursor_positioning", "bool_u8"], readonly ["in_tmux", "bool_u8"], readonly ["term_name", "char*"], readonly ["term_name_len", "u64", {
42
42
  readonly lengthOf: "term_name";
43
43
  }], readonly ["term_version", "char*"], readonly ["term_version_len", "u64", {
44
44
  readonly lengthOf: "term_version";
package/zig.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Pointer } from "bun:ffi";
1
+ import { type Pointer } from "./platform/ffi.js";
2
2
  import { type CursorStyle, type CursorStyleOptions, type TargetChannel, type DebugOverlayCorner, type WidthMethod, type Highlight, type LineInfo } from "./types.js";
3
3
  export type { LineInfo, AllocatorStats, BuildOptions };
4
4
  import { RGBA } from "./lib/RGBA.js";