@opentui/core 0.1.87 → 0.1.89
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/3d/ThreeRenderable.d.ts +4 -4
- package/3d/WGPURenderer.d.ts +4 -4
- package/3d/animation/ExplodingSpriteEffect.d.ts +2 -2
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +3 -3
- package/3d/animation/SpriteAnimator.d.ts +1 -1
- package/3d/animation/SpriteParticleGenerator.d.ts +1 -1
- package/3d/canvas.d.ts +2 -2
- package/3d/index.d.ts +12 -12
- package/3d/physics/PlanckPhysicsAdapter.d.ts +1 -1
- package/3d/physics/RapierPhysicsAdapter.d.ts +1 -1
- package/3d.d.ts +1 -1
- package/3d.js +1 -1
- package/3d.js.map +12 -12
- package/Renderable.d.ts +7 -7
- package/animation/Timeline.d.ts +1 -1
- package/buffer.d.ts +6 -4
- package/console.d.ts +7 -4
- package/edit-buffer.d.ts +4 -4
- package/editor-view.d.ts +3 -3
- package/{index-0wbvecnk.js → index-e89anq5x.js} +864 -175
- package/index-e89anq5x.js.map +64 -0
- package/index-rs5zwr4j.js +12373 -0
- package/index-rs5zwr4j.js.map +43 -0
- package/index-tae5jwnc.js +188 -0
- package/index-tae5jwnc.js.map +10 -0
- package/index.d.ts +20 -17
- package/index.js +86 -11596
- package/index.js.map +3 -35
- package/lib/KeyHandler.d.ts +7 -4
- package/lib/ascii.font.d.ts +2 -2
- package/lib/border.d.ts +1 -1
- package/lib/clipboard.d.ts +1 -1
- package/lib/clock.d.ts +4 -0
- package/lib/extmarks-history.d.ts +1 -1
- package/lib/extmarks.d.ts +2 -2
- package/lib/hast-styled-text.d.ts +3 -3
- package/lib/index.d.ts +21 -20
- package/lib/objects-in-viewport.d.ts +1 -1
- package/lib/parse.keypress-kitty.d.ts +1 -1
- package/lib/paste.d.ts +7 -0
- package/lib/renderable.validations.d.ts +2 -2
- package/lib/selection.d.ts +2 -2
- package/lib/stdin-parser.d.ts +14 -2
- package/lib/styled-text.d.ts +2 -2
- package/lib/terminal-palette.d.ts +4 -2
- package/lib/tree-sitter/client.d.ts +1 -1
- package/lib/tree-sitter/index.d.ts +7 -7
- package/lib/tree-sitter/parsers-config.d.ts +15 -0
- package/lib/tree-sitter/resolve-ft.d.ts +3 -0
- package/lib/tree-sitter/types.d.ts +1 -0
- package/lib/tree-sitter-styled-text.d.ts +5 -5
- package/package.json +17 -7
- package/parser.worker.js +52 -18
- package/parser.worker.js.map +3 -3
- package/plugins/core-slot.d.ts +72 -0
- package/plugins/registry.d.ts +38 -0
- package/plugins/types.d.ts +34 -0
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +28 -68
- package/post/matrices.d.ts +20 -0
- package/renderables/ASCIIFont.d.ts +6 -6
- package/renderables/Box.d.ts +5 -5
- package/renderables/Code.d.ts +10 -8
- package/renderables/Diff.d.ts +7 -7
- package/renderables/EditBufferRenderable.d.ts +8 -8
- package/renderables/FrameBuffer.d.ts +3 -3
- package/renderables/Input.d.ts +3 -3
- package/renderables/LineNumberRenderable.d.ts +4 -4
- package/renderables/Markdown.d.ts +17 -9
- package/renderables/ScrollBar.d.ts +6 -6
- package/renderables/ScrollBox.d.ts +9 -8
- package/renderables/Select.d.ts +7 -7
- package/renderables/Slider.d.ts +1 -1
- package/renderables/TabSelect.d.ts +6 -6
- package/renderables/Text.d.ts +7 -7
- package/renderables/TextBufferRenderable.d.ts +9 -9
- package/renderables/TextNode.d.ts +6 -6
- package/renderables/Textarea.d.ts +7 -7
- package/renderables/__tests__/renderable-test-utils.d.ts +8 -3
- package/renderables/composition/VRenderable.d.ts +3 -3
- package/renderables/composition/constructs.d.ts +14 -14
- package/renderables/composition/vnode.d.ts +2 -2
- package/renderables/index.d.ts +22 -22
- package/renderer.d.ts +28 -16
- package/runtime-plugin-support.d.ts +3 -0
- package/runtime-plugin-support.js +29 -0
- package/runtime-plugin-support.js.map +10 -0
- package/runtime-plugin.d.ts +11 -0
- package/runtime-plugin.js +16 -0
- package/runtime-plugin.js.map +9 -0
- package/syntax-style.d.ts +2 -2
- package/testing/manual-clock.d.ts +1 -0
- package/testing/mock-keys.d.ts +2 -1
- package/testing/mock-mouse.d.ts +1 -1
- package/testing/mock-tree-sitter-client.d.ts +2 -2
- package/testing/test-recorder.d.ts +1 -1
- package/testing/test-renderer.d.ts +4 -4
- package/testing.d.ts +6 -6
- package/testing.js +12 -7
- package/testing.js.map +7 -7
- package/text-buffer-view.d.ts +3 -3
- package/text-buffer.d.ts +5 -5
- package/types.d.ts +9 -4
- package/utils.d.ts +1 -1
- package/zig-structs.d.ts +1 -1
- package/zig.d.ts +7 -5
- package/index-0wbvecnk.js.map +0 -63
package/renderables/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export * from "./ASCIIFont";
|
|
2
|
-
export * from "./Box";
|
|
3
|
-
export * from "./Code";
|
|
4
|
-
export * from "./composition/constructs";
|
|
5
|
-
export * from "./composition/VRenderable";
|
|
6
|
-
export * from "./composition/vnode";
|
|
7
|
-
export * from "./Diff";
|
|
8
|
-
export * from "./FrameBuffer";
|
|
9
|
-
export * from "./Input";
|
|
10
|
-
export * from "./LineNumberRenderable";
|
|
11
|
-
export * from "./Markdown";
|
|
12
|
-
export * from "./ScrollBar";
|
|
13
|
-
export * from "./ScrollBox";
|
|
14
|
-
export * from "./Select";
|
|
15
|
-
export * from "./Slider";
|
|
16
|
-
export * from "./TextTable";
|
|
17
|
-
export * from "./TabSelect";
|
|
18
|
-
export * from "./Text";
|
|
19
|
-
export * from "./TimeToFirstDraw";
|
|
20
|
-
export * from "./TextBufferRenderable";
|
|
21
|
-
export * from "./TextNode";
|
|
22
|
-
export * from "./Textarea";
|
|
1
|
+
export * from "./ASCIIFont.js";
|
|
2
|
+
export * from "./Box.js";
|
|
3
|
+
export * from "./Code.js";
|
|
4
|
+
export * from "./composition/constructs.js";
|
|
5
|
+
export * from "./composition/VRenderable.js";
|
|
6
|
+
export * from "./composition/vnode.js";
|
|
7
|
+
export * from "./Diff.js";
|
|
8
|
+
export * from "./FrameBuffer.js";
|
|
9
|
+
export * from "./Input.js";
|
|
10
|
+
export * from "./LineNumberRenderable.js";
|
|
11
|
+
export * from "./Markdown.js";
|
|
12
|
+
export * from "./ScrollBar.js";
|
|
13
|
+
export * from "./ScrollBox.js";
|
|
14
|
+
export * from "./Select.js";
|
|
15
|
+
export * from "./Slider.js";
|
|
16
|
+
export * from "./TextTable.js";
|
|
17
|
+
export * from "./TabSelect.js";
|
|
18
|
+
export * from "./Text.js";
|
|
19
|
+
export * from "./TimeToFirstDraw.js";
|
|
20
|
+
export * from "./TextBufferRenderable.js";
|
|
21
|
+
export * from "./TextNode.js";
|
|
22
|
+
export * from "./Textarea.js";
|
package/renderer.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Renderable, RootRenderable } from "./Renderable";
|
|
2
|
-
import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type RenderContext, type ThemeMode, type WidthMethod } from "./types";
|
|
3
|
-
import { RGBA, type ColorInput } from "./lib/RGBA";
|
|
1
|
+
import { Renderable, RootRenderable } from "./Renderable.js";
|
|
2
|
+
import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type RenderContext, type ThemeMode, type WidthMethod } from "./types.js";
|
|
3
|
+
import { RGBA, type ColorInput } from "./lib/RGBA.js";
|
|
4
4
|
import type { Pointer } from "bun:ffi";
|
|
5
|
-
import { OptimizedBuffer } from "./buffer";
|
|
6
|
-
import { type RenderLib } from "./zig";
|
|
7
|
-
import { TerminalConsole, type ConsoleOptions } from "./console";
|
|
8
|
-
import { type MouseEventType, type RawMouseEvent, type ScrollInfo } from "./lib/parse.mouse";
|
|
9
|
-
import { Selection } from "./lib/selection";
|
|
10
|
-
import { type ClipboardTarget } from "./lib/clipboard";
|
|
5
|
+
import { OptimizedBuffer } from "./buffer.js";
|
|
6
|
+
import { type RenderLib } from "./zig.js";
|
|
7
|
+
import { TerminalConsole, type ConsoleOptions } from "./console.js";
|
|
8
|
+
import { type MouseEventType, type RawMouseEvent, type ScrollInfo } from "./lib/parse.mouse.js";
|
|
9
|
+
import { Selection } from "./lib/selection.js";
|
|
10
|
+
import { type ClipboardTarget } from "./lib/clipboard.js";
|
|
11
11
|
import { EventEmitter } from "events";
|
|
12
|
-
import { KeyHandler, InternalKeyHandler } from "./lib/KeyHandler";
|
|
13
|
-
import { type TerminalColors, type GetPaletteOptions } from "./lib/terminal-palette";
|
|
14
|
-
import { type Clock } from "./lib/clock";
|
|
12
|
+
import { KeyHandler, InternalKeyHandler } from "./lib/KeyHandler.js";
|
|
13
|
+
import { type TerminalColors, type GetPaletteOptions } from "./lib/terminal-palette.js";
|
|
14
|
+
import { type Clock } from "./lib/clock.js";
|
|
15
15
|
export interface CliRendererConfig {
|
|
16
16
|
stdin?: NodeJS.ReadStream;
|
|
17
17
|
stdout?: NodeJS.WriteStream;
|
|
@@ -27,7 +27,7 @@ export interface CliRendererConfig {
|
|
|
27
27
|
useThread?: boolean;
|
|
28
28
|
gatherStats?: boolean;
|
|
29
29
|
maxStatSamples?: number;
|
|
30
|
-
consoleOptions?: ConsoleOptions
|
|
30
|
+
consoleOptions?: Omit<ConsoleOptions, "clock">;
|
|
31
31
|
postProcessFns?: ((buffer: OptimizedBuffer, deltaTime: number) => void)[];
|
|
32
32
|
enableMouseMovement?: boolean;
|
|
33
33
|
useMouse?: boolean;
|
|
@@ -40,7 +40,7 @@ export interface CliRendererConfig {
|
|
|
40
40
|
openConsoleOnError?: boolean;
|
|
41
41
|
prependInputHandlers?: ((sequence: string) => boolean)[];
|
|
42
42
|
stdinParserMaxBufferBytes?: number;
|
|
43
|
-
|
|
43
|
+
clock?: Clock;
|
|
44
44
|
onDestroy?: () => void;
|
|
45
45
|
}
|
|
46
46
|
export type PixelResolution = {
|
|
@@ -104,8 +104,15 @@ export declare enum MouseButton {
|
|
|
104
104
|
}
|
|
105
105
|
export declare function createCliRenderer(config?: CliRendererConfig): Promise<CliRenderer>;
|
|
106
106
|
export declare enum CliRenderEvents {
|
|
107
|
+
RESIZE = "resize",
|
|
108
|
+
FOCUS = "focus",
|
|
109
|
+
BLUR = "blur",
|
|
110
|
+
THEME_MODE = "theme_mode",
|
|
111
|
+
CAPABILITIES = "capabilities",
|
|
112
|
+
SELECTION = "selection",
|
|
107
113
|
DEBUG_OVERLAY_TOGGLE = "debugOverlay:toggle",
|
|
108
|
-
DESTROY = "destroy"
|
|
114
|
+
DESTROY = "destroy",
|
|
115
|
+
MEMORY_SNAPSHOT = "memory:snapshot"
|
|
109
116
|
}
|
|
110
117
|
export declare enum RendererControlState {
|
|
111
118
|
IDLE = "idle",
|
|
@@ -146,6 +153,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
146
153
|
private postProcessFns;
|
|
147
154
|
private backgroundColor;
|
|
148
155
|
private waitingForPixelResolution;
|
|
156
|
+
private readonly clock;
|
|
149
157
|
private rendering;
|
|
150
158
|
private renderingNative;
|
|
151
159
|
private renderTimeout;
|
|
@@ -209,6 +217,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
209
217
|
private _paletteDetectionPromise;
|
|
210
218
|
private _onDestroy?;
|
|
211
219
|
private _themeMode;
|
|
220
|
+
private _terminalFocusState;
|
|
212
221
|
private sequenceHandlers;
|
|
213
222
|
private prependedInputHandlers;
|
|
214
223
|
private shouldRestoreModesOnNextFocus;
|
|
@@ -228,6 +237,8 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
228
237
|
unregisterLifecyclePass(renderable: Renderable): void;
|
|
229
238
|
getLifecyclePasses(): Set<Renderable>;
|
|
230
239
|
get currentFocusedRenderable(): Renderable | null;
|
|
240
|
+
private normalizeClockTime;
|
|
241
|
+
private getElapsedMs;
|
|
231
242
|
focusRenderable(renderable: Renderable): void;
|
|
232
243
|
private setCapturedRenderable;
|
|
233
244
|
addToHitGrid(x: number, y: number, width: number, height: number, id: number): void;
|
|
@@ -278,6 +289,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
278
289
|
addInputHandler(handler: (sequence: string) => boolean): void;
|
|
279
290
|
prependInputHandler(handler: (sequence: string) => boolean): void;
|
|
280
291
|
removeInputHandler(handler: (sequence: string) => boolean): void;
|
|
292
|
+
private updateStdinParserProtocolContext;
|
|
281
293
|
subscribeOsc(handler: (sequence: string) => void): () => void;
|
|
282
294
|
private capabilityHandler;
|
|
283
295
|
private focusHandler;
|
|
@@ -323,7 +335,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
323
335
|
setCursorPosition(x: number, y: number, visible?: boolean): void;
|
|
324
336
|
setCursorStyle(options: CursorStyleOptions): void;
|
|
325
337
|
setCursorColor(color: RGBA): void;
|
|
326
|
-
getCursorState(): import("./zig").CursorState;
|
|
338
|
+
getCursorState(): import("./zig.js").CursorState;
|
|
327
339
|
addPostProcessFn(processFn: (buffer: OptimizedBuffer, deltaTime: number) => void): void;
|
|
328
340
|
removePostProcessFn(processFn: (buffer: OptimizedBuffer, deltaTime: number) => void): void;
|
|
329
341
|
clearPostProcessFns(): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRuntimePlugin, runtimeModuleIdForSpecifier, type CreateRuntimePluginOptions, type RuntimeModuleEntry, type RuntimeModuleExports, type RuntimeModuleLoader } from "./runtime-plugin";
|
|
2
|
+
export declare function ensureRuntimePluginSupport(options?: CreateRuntimePluginOptions): boolean;
|
|
3
|
+
export { createRuntimePlugin, runtimeModuleIdForSpecifier, type CreateRuntimePluginOptions, type RuntimeModuleEntry, type RuntimeModuleExports, type RuntimeModuleLoader, };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createRuntimePlugin,
|
|
4
|
+
runtimeModuleIdForSpecifier
|
|
5
|
+
} from "./index-tae5jwnc.js";
|
|
6
|
+
import"./index-rs5zwr4j.js";
|
|
7
|
+
import"./index-e89anq5x.js";
|
|
8
|
+
|
|
9
|
+
// 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
|
+
ensureRuntimePluginSupport();
|
|
22
|
+
export {
|
|
23
|
+
runtimeModuleIdForSpecifier,
|
|
24
|
+
ensureRuntimePluginSupport,
|
|
25
|
+
createRuntimePlugin
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# debugId=7487C2BFD13C698664756E2164756E21
|
|
29
|
+
//# sourceMappingURL=runtime-plugin-support.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtime-plugin-support.ts"],
|
|
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\"\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"
|
|
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",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type BunPlugin } from "bun";
|
|
2
|
+
export type RuntimeModuleExports = Record<string, unknown>;
|
|
3
|
+
export type RuntimeModuleLoader = () => RuntimeModuleExports | Promise<RuntimeModuleExports>;
|
|
4
|
+
export type RuntimeModuleEntry = RuntimeModuleExports | RuntimeModuleLoader;
|
|
5
|
+
export interface CreateRuntimePluginOptions {
|
|
6
|
+
core?: RuntimeModuleEntry;
|
|
7
|
+
additional?: Record<string, RuntimeModuleEntry>;
|
|
8
|
+
}
|
|
9
|
+
export declare const isCoreRuntimeModuleSpecifier: (specifier: string) => boolean;
|
|
10
|
+
export declare const runtimeModuleIdForSpecifier: (specifier: string) => string;
|
|
11
|
+
export declare function createRuntimePlugin(input?: CreateRuntimePluginOptions): BunPlugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createRuntimePlugin,
|
|
4
|
+
isCoreRuntimeModuleSpecifier,
|
|
5
|
+
runtimeModuleIdForSpecifier
|
|
6
|
+
} from "./index-tae5jwnc.js";
|
|
7
|
+
import"./index-rs5zwr4j.js";
|
|
8
|
+
import"./index-e89anq5x.js";
|
|
9
|
+
export {
|
|
10
|
+
runtimeModuleIdForSpecifier,
|
|
11
|
+
isCoreRuntimeModuleSpecifier,
|
|
12
|
+
createRuntimePlugin
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# debugId=54AC4E2ADFC3366A64756E2164756E21
|
|
16
|
+
//# sourceMappingURL=runtime-plugin.js.map
|
package/syntax-style.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RGBA, type ColorInput } from "./lib/RGBA";
|
|
2
|
-
import { type RenderLib } from "./zig";
|
|
1
|
+
import { RGBA, type ColorInput } from "./lib/RGBA.js";
|
|
2
|
+
import { type RenderLib } from "./zig.js";
|
|
3
3
|
import { type Pointer } from "bun:ffi";
|
|
4
4
|
export interface StyleDefinition {
|
|
5
5
|
fg?: RGBA;
|
|
@@ -5,6 +5,7 @@ export declare class ManualClock implements Clock {
|
|
|
5
5
|
private nextOrder;
|
|
6
6
|
private readonly timers;
|
|
7
7
|
now(): number;
|
|
8
|
+
setTime(time: number): void;
|
|
8
9
|
setTimeout(fn: () => void, delayMs: number): TimerHandle;
|
|
9
10
|
clearTimeout(handle: TimerHandle): void;
|
|
10
11
|
setInterval(fn: () => void, delayMs: number): TimerHandle;
|
package/testing/mock-keys.d.ts
CHANGED
package/testing/mock-mouse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TreeSitterClient } from "../lib/tree-sitter";
|
|
2
|
-
import type { SimpleHighlight } from "../lib/tree-sitter/types";
|
|
1
|
+
import { TreeSitterClient } from "../lib/tree-sitter/index.js";
|
|
2
|
+
import type { SimpleHighlight } from "../lib/tree-sitter/types.js";
|
|
3
3
|
export declare class MockTreeSitterClient extends TreeSitterClient {
|
|
4
4
|
private _highlightPromises;
|
|
5
5
|
private _mockResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CliRenderer, type CliRendererConfig } from "../renderer";
|
|
2
|
-
import { createMockKeys } from "./mock-keys";
|
|
3
|
-
import { createMockMouse } from "./mock-mouse";
|
|
4
|
-
import type { CapturedFrame } from "../types";
|
|
1
|
+
import { CliRenderer, type CliRendererConfig } from "../renderer.js";
|
|
2
|
+
import { createMockKeys } from "./mock-keys.js";
|
|
3
|
+
import { createMockMouse } from "./mock-mouse.js";
|
|
4
|
+
import type { CapturedFrame } from "../types.js";
|
|
5
5
|
export interface TestRendererOptions extends CliRendererConfig {
|
|
6
6
|
width?: number;
|
|
7
7
|
height?: number;
|
package/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./testing/test-renderer";
|
|
2
|
-
export * from "./testing/mock-keys";
|
|
3
|
-
export * from "./testing/mock-mouse";
|
|
4
|
-
export * from "./testing/mock-tree-sitter-client";
|
|
5
|
-
export * from "./testing/spy";
|
|
6
|
-
export { TestRecorder, type RecordedFrame } from "./testing/test-recorder";
|
|
1
|
+
export * from "./testing/test-renderer.js";
|
|
2
|
+
export * from "./testing/mock-keys.js";
|
|
3
|
+
export * from "./testing/mock-mouse.js";
|
|
4
|
+
export * from "./testing/mock-tree-sitter-client.js";
|
|
5
|
+
export * from "./testing/spy.js";
|
|
6
|
+
export { TestRecorder, type RecordedFrame } from "./testing/test-recorder.js";
|
package/testing.js
CHANGED
|
@@ -4,12 +4,16 @@ import {
|
|
|
4
4
|
CliRenderer,
|
|
5
5
|
TreeSitterClient,
|
|
6
6
|
resolveRenderLib
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-e89anq5x.js";
|
|
8
8
|
|
|
9
9
|
// src/testing/test-renderer.ts
|
|
10
10
|
import { Readable } from "stream";
|
|
11
11
|
|
|
12
12
|
// src/testing/mock-keys.ts
|
|
13
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
14
|
+
function pasteBytes(text) {
|
|
15
|
+
return Uint8Array.from(Buffer2.from(text));
|
|
16
|
+
}
|
|
13
17
|
var KeyCodes = {
|
|
14
18
|
RETURN: "\r",
|
|
15
19
|
LINEFEED: `
|
|
@@ -127,7 +131,7 @@ function createMockKeys(renderer, options) {
|
|
|
127
131
|
const pressKeys = async (keys, delayMs = 0) => {
|
|
128
132
|
for (const key of keys) {
|
|
129
133
|
const { keyValue: keyCode } = resolveKeyInput(key);
|
|
130
|
-
renderer.stdin.emit("data",
|
|
134
|
+
renderer.stdin.emit("data", Buffer2.from(keyCode));
|
|
131
135
|
if (delayMs > 0) {
|
|
132
136
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
133
137
|
}
|
|
@@ -159,14 +163,14 @@ function createMockKeys(renderer, options) {
|
|
|
159
163
|
if (keyName && kittyKeyCodeMap[keyName]) {
|
|
160
164
|
const kittyCode = kittyKeyCodeMap[keyName];
|
|
161
165
|
const sequence = encodeKittySequence(kittyCode, modifiers);
|
|
162
|
-
renderer.stdin.emit("data",
|
|
166
|
+
renderer.stdin.emit("data", Buffer2.from(sequence));
|
|
163
167
|
return;
|
|
164
168
|
}
|
|
165
169
|
if (keyValue && keyValue.length === 1 && !keyValue.startsWith("\x1B")) {
|
|
166
170
|
const codepoint = keyValue.codePointAt(0);
|
|
167
171
|
if (codepoint) {
|
|
168
172
|
const sequence = encodeKittySequence(codepoint, modifiers);
|
|
169
|
-
renderer.stdin.emit("data",
|
|
173
|
+
renderer.stdin.emit("data", Buffer2.from(sequence));
|
|
170
174
|
return;
|
|
171
175
|
}
|
|
172
176
|
}
|
|
@@ -189,7 +193,7 @@ function createMockKeys(renderer, options) {
|
|
|
189
193
|
}
|
|
190
194
|
if (charCode !== undefined) {
|
|
191
195
|
const sequence = encodeModifyOtherKeysSequence(charCode, modifiers);
|
|
192
|
-
renderer.stdin.emit("data",
|
|
196
|
+
renderer.stdin.emit("data", Buffer2.from(sequence));
|
|
193
197
|
return;
|
|
194
198
|
}
|
|
195
199
|
}
|
|
@@ -252,7 +256,7 @@ function createMockKeys(renderer, options) {
|
|
|
252
256
|
keyCode = `\x1B${keyCode}`;
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
|
-
renderer.stdin.emit("data",
|
|
259
|
+
renderer.stdin.emit("data", Buffer2.from(keyCode));
|
|
256
260
|
};
|
|
257
261
|
const typeText = async (text, delayMs = 0) => {
|
|
258
262
|
const keys = text.split("");
|
|
@@ -656,6 +660,7 @@ class TestRecorder {
|
|
|
656
660
|
}
|
|
657
661
|
}
|
|
658
662
|
export {
|
|
663
|
+
pasteBytes,
|
|
659
664
|
createTestRenderer,
|
|
660
665
|
createSpy,
|
|
661
666
|
createMockMouse,
|
|
@@ -666,5 +671,5 @@ export {
|
|
|
666
671
|
KeyCodes
|
|
667
672
|
};
|
|
668
673
|
|
|
669
|
-
//# debugId=
|
|
674
|
+
//# debugId=57274CA1B04AC89E64756E2164756E21
|
|
670
675
|
//# sourceMappingURL=testing.js.map
|