restty 0.1.23 → 0.1.25
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/{chunk-mkkhfg0z.js → chunk-pab3ge3d.js} +11446 -7806
- package/dist/fonts/index.d.ts +4 -1
- package/dist/fonts/manager/classification.d.ts +13 -0
- package/dist/fonts/manager/entries.d.ts +13 -0
- package/dist/fonts/manager/picker.d.ts +6 -0
- package/dist/fonts/manager/sources.d.ts +16 -0
- package/dist/fonts/types.d.ts +20 -10
- package/dist/grid/grid.d.ts +5 -3
- package/dist/ime/ime.d.ts +13 -0
- package/dist/index.d.ts +3 -3
- package/dist/input/index.d.ts +1 -1
- package/dist/input/keymap/before-input.d.ts +4 -0
- package/dist/input/keymap/constants.d.ts +13 -0
- package/dist/input/keymap/control.d.ts +2 -0
- package/dist/input/keymap/default-mapping.d.ts +1 -0
- package/dist/input/keymap/kitty.d.ts +1 -0
- package/dist/input/keymap/normalization.d.ts +4 -0
- package/dist/input/keymap/pty-map.d.ts +4 -0
- package/dist/input/keymap.d.ts +2 -11
- package/dist/input/output/csi.d.ts +33 -0
- package/dist/input/{output.d.ts → output/index.d.ts} +6 -9
- package/dist/input/output/osc.d.ts +15 -0
- package/dist/input/output/prompt.d.ts +11 -0
- package/dist/input/types.d.ts +13 -0
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +13 -150
- package/dist/renderer/index.d.ts +7 -2
- package/dist/renderer/shaders/glyph-gl.d.ts +4 -0
- package/dist/renderer/{shaders.d.ts → shaders/glyph-wgsl.d.ts} +0 -10
- package/dist/renderer/shaders/rect.d.ts +6 -0
- package/dist/renderer/shapes/block-elements.d.ts +3 -0
- package/dist/renderer/shapes/box-drawing/dashed-lines.d.ts +3 -0
- package/dist/renderer/shapes/box-drawing/diagonal.d.ts +2 -0
- package/dist/renderer/shapes/box-drawing/draw-box-drawing.d.ts +6 -0
- package/dist/renderer/shapes/box-drawing/fallback.d.ts +2 -0
- package/dist/renderer/shapes/box-drawing/mapped.d.ts +2 -0
- package/dist/renderer/shapes/box-drawing/rounded-corner.d.ts +2 -0
- package/dist/renderer/shapes/braille.d.ts +3 -0
- package/dist/renderer/shapes/classify.d.ts +18 -0
- package/dist/renderer/shapes/geometry.d.ts +9 -0
- package/dist/renderer/shapes/glyph-box.d.ts +7 -0
- package/dist/renderer/shapes/powerline.d.ts +3 -0
- package/dist/renderer/shapes/types.d.ts +38 -0
- package/dist/renderer/shapes.d.ts +8 -81
- package/dist/renderer/webgpu/buffers.d.ts +7 -0
- package/dist/renderer/webgpu/setup.d.ts +10 -0
- package/dist/renderer/webgpu/state.d.ts +15 -0
- package/dist/renderer/webgpu/webgl.d.ts +3 -0
- package/dist/restty.js +1 -1
- package/dist/{app → runtime}/atlas-builder.d.ts +53 -18
- package/dist/runtime/codepoint-utils.d.ts +12 -0
- package/dist/runtime/create-app-io-utils.d.ts +9 -0
- package/dist/runtime/create-app-symbols.d.ts +11 -0
- package/dist/runtime/create-app-types.d.ts +72 -0
- package/dist/runtime/create-runtime/atlas-debug-utils.d.ts +5 -0
- package/dist/runtime/create-runtime/blend-utils.d.ts +11 -0
- package/dist/runtime/create-runtime/color-glyph-atlas.d.ts +11 -0
- package/dist/runtime/create-runtime/debug-tools/create-dump-glyph-render.d.ts +2 -0
- package/dist/runtime/create-runtime/debug-tools/diagnose-codepoint.d.ts +2 -0
- package/dist/runtime/create-runtime/debug-tools/dump-atlas-for-codepoint.d.ts +2 -0
- package/dist/runtime/create-runtime/debug-tools/read-texture-to-image-data.d.ts +1 -0
- package/dist/runtime/create-runtime/debug-tools/setup-debug-expose.d.ts +2 -0
- package/dist/runtime/create-runtime/debug-tools/types.d.ts +63 -0
- package/dist/runtime/create-runtime/debug-tools.d.ts +6 -0
- package/dist/runtime/create-runtime/font-runtime-grid-helpers.d.ts +39 -0
- package/dist/runtime/create-runtime/font-runtime-helpers.d.ts +20 -0
- package/dist/runtime/create-runtime/font-runtime-helpers.types.d.ts +108 -0
- package/dist/runtime/create-runtime/font-runtime-text-helpers.d.ts +21 -0
- package/dist/runtime/create-runtime/font-runtime-webgpu-atlas.d.ts +26 -0
- package/dist/runtime/create-runtime/format-utils.d.ts +2 -0
- package/dist/runtime/create-runtime/input-hooks.d.ts +12 -0
- package/dist/runtime/create-runtime/interaction-runtime/bind-ime-events.d.ts +12 -0
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-aux-handlers.d.ts +28 -0
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-events.d.ts +41 -0
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-up-handler.d.ts +28 -0
- package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.d.ts +18 -0
- package/dist/runtime/create-runtime/interaction-runtime/kitty-overlay-runtime.d.ts +15 -0
- package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.d.ts +30 -0
- package/dist/runtime/create-runtime/interaction-runtime/types.d.ts +110 -0
- package/dist/runtime/create-runtime/interaction-runtime.d.ts +3 -0
- package/dist/runtime/create-runtime/kitty-overlay-utils.d.ts +26 -0
- package/dist/runtime/create-runtime/lifecycle-theme-size-canvas.d.ts +13 -0
- package/dist/runtime/create-runtime/lifecycle-theme-size-theme.d.ts +6 -0
- package/dist/runtime/create-runtime/lifecycle-theme-size.d.ts +16 -0
- package/dist/runtime/create-runtime/lifecycle-theme-size.types.d.ts +85 -0
- package/dist/runtime/create-runtime/pty-input-runtime.d.ts +45 -0
- package/dist/runtime/create-runtime/render-tick-webgl-context.d.ts +4 -0
- package/dist/runtime/create-runtime/render-tick-webgl-glyph-pipeline.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgl-overlays.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgl-scene.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgl.d.ts +3 -0
- package/dist/runtime/create-runtime/render-tick-webgl.types.d.ts +162 -0
- package/dist/runtime/create-runtime/render-tick-webgpu-cell-pass.d.ts +25 -0
- package/dist/runtime/create-runtime/render-tick-webgpu-draw-pass.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgpu-emit-glyphs.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgpu-overlays-atlas.d.ts +2 -0
- package/dist/runtime/create-runtime/render-tick-webgpu.d.ts +3 -0
- package/dist/runtime/create-runtime/render-tick-webgpu.types.d.ts +386 -0
- package/dist/runtime/create-runtime/render-ticks.d.ts +9 -0
- package/dist/runtime/create-runtime/runtime-app-api.d.ts +103 -0
- package/dist/runtime/create-runtime/runtime-logger.d.ts +17 -0
- package/dist/runtime/create-runtime/runtime-reporting.d.ts +40 -0
- package/dist/runtime/create-runtime/shader-stage-runtime.d.ts +29 -0
- package/dist/runtime/create-runtime.d.ts +7 -0
- package/dist/runtime/font-atlas-utils/bitmap-utils.d.ts +5 -0
- package/dist/runtime/font-atlas-utils/glyph-atlas-builder.d.ts +29 -0
- package/dist/runtime/font-atlas-utils/nerd-metrics-utils.d.ts +25 -0
- package/dist/runtime/font-atlas-utils/packing-utils.d.ts +13 -0
- package/dist/runtime/overlay-scrollbar.d.ts +24 -0
- package/dist/runtime/pty-output-buffer.d.ts +12 -0
- package/dist/runtime/render-color-utils.d.ts +6 -0
- package/dist/runtime/render-stage-runtime.d.ts +18 -0
- package/dist/runtime/render-stage-shaders.d.ts +6 -0
- package/dist/runtime/shader-stages.d.ts +9 -0
- package/dist/runtime/text-decoration.d.ts +4 -0
- package/dist/{app → runtime}/types.d.ts +39 -1
- package/dist/selection/clipboard.d.ts +4 -0
- package/dist/selection/{selection.d.ts → core.d.ts} +0 -11
- package/dist/selection/index.d.ts +3 -1
- package/dist/selection/text.d.ts +8 -0
- package/dist/surface/app-factory.d.ts +3 -0
- package/dist/{app → surface}/pane-app-manager.d.ts +2 -2
- package/dist/surface/panes/default-context-menu-items.d.ts +8 -0
- package/dist/surface/panes/layout.d.ts +9 -0
- package/dist/surface/panes/manager.d.ts +2 -0
- package/dist/surface/panes/pane-interactions.d.ts +11 -0
- package/dist/surface/panes/window-events.d.ts +10 -0
- package/dist/{app → surface}/panes-types.d.ts +1 -1
- package/dist/surface/restty/active-pane-api.d.ts +23 -0
- package/dist/surface/restty/manager-options.d.ts +24 -0
- package/dist/surface/restty/pane-ops.d.ts +42 -0
- package/dist/surface/restty/plugin-dispatcher.d.ts +39 -0
- package/dist/surface/restty/plugin-ops.d.ts +24 -0
- package/dist/surface/restty/shader-ops.d.ts +27 -0
- package/dist/surface/restty-pane-handle.d.ts +70 -0
- package/dist/surface/restty-plugin-runtime.d.ts +57 -0
- package/dist/surface/restty-plugin-types.d.ts +164 -0
- package/dist/surface/restty-plugin-utils.d.ts +22 -0
- package/dist/surface/restty.d.ts +93 -0
- package/dist/utils/base64.d.ts +12 -0
- package/dist/wasm/index.d.ts +2 -1
- package/dist/wasm/runtime/abi.d.ts +7 -0
- package/dist/wasm/runtime/kitty.d.ts +2 -0
- package/dist/wasm/runtime/render-state.d.ts +2 -0
- package/dist/wasm/runtime/restty-wasm.d.ts +42 -0
- package/dist/wasm/{runtime.d.ts → runtime/types.d.ts} +48 -41
- package/dist/wasm/runtime/view-cache.d.ts +4 -0
- package/dist/xterm/app-options.d.ts +2 -0
- package/dist/xterm/dimensions.d.ts +1 -0
- package/dist/xterm/listeners.d.ts +5 -0
- package/dist/xterm.d.ts +1 -6
- package/dist/xterm.js +61 -63
- package/package.json +1 -1
- package/dist/app/index.d.ts +0 -9
- package/dist/app/panes.d.ts +0 -15
- package/dist/app/restty.d.ts +0 -336
- package/dist/fonts/manager.d.ts +0 -45
- package/dist/renderer/webgpu.d.ts +0 -33
- package/dist/restty-input.d.ts +0 -1
- /package/dist/{app → runtime}/clipboard-paste.d.ts +0 -0
- /package/dist/{app → runtime}/font-sources.d.ts +0 -0
- /package/dist/{app → runtime}/session.d.ts +0 -0
- /package/dist/{app → surface}/panes-context-menu.d.ts +0 -0
- /package/dist/{app → surface}/panes-styles.d.ts +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { ResttyPaneSplitDirection } from "./panes-types";
|
|
2
|
+
import type { ResttyShaderStage } from "../runtime/types";
|
|
3
|
+
import type { ResttyPaneHandle } from "./restty-pane-handle";
|
|
4
|
+
import type { Restty } from "./restty";
|
|
5
|
+
/** Current Restty plugin API version. */
|
|
6
|
+
export declare const RESTTY_PLUGIN_API_VERSION = 1;
|
|
7
|
+
/** Plugin API version requirements. */
|
|
8
|
+
export type ResttyPluginApiRange = {
|
|
9
|
+
min: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
};
|
|
12
|
+
/** Optional compatibility requirements declared by plugins. */
|
|
13
|
+
export type ResttyPluginRequires = {
|
|
14
|
+
pluginApi?: number | ResttyPluginApiRange;
|
|
15
|
+
};
|
|
16
|
+
/** Diagnostics snapshot for a plugin. */
|
|
17
|
+
export type ResttyPluginInfo = {
|
|
18
|
+
id: string;
|
|
19
|
+
version: string | null;
|
|
20
|
+
apiVersion: number | null;
|
|
21
|
+
requires: ResttyPluginRequires | null;
|
|
22
|
+
active: boolean;
|
|
23
|
+
activatedAt: number | null;
|
|
24
|
+
lastError: string | null;
|
|
25
|
+
listeners: number;
|
|
26
|
+
inputInterceptors: number;
|
|
27
|
+
outputInterceptors: number;
|
|
28
|
+
lifecycleHooks: number;
|
|
29
|
+
renderHooks: number;
|
|
30
|
+
renderStages: number;
|
|
31
|
+
};
|
|
32
|
+
/** Declarative plugin manifest entry for registry-based loading. */
|
|
33
|
+
export type ResttyPluginManifestEntry = {
|
|
34
|
+
id: string;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
options?: unknown;
|
|
37
|
+
};
|
|
38
|
+
/** Provider entry for plugin registry lookups. */
|
|
39
|
+
export type ResttyPluginRegistryEntry = ResttyPlugin | (() => ResttyPlugin | Promise<ResttyPlugin>);
|
|
40
|
+
/** Registry shape accepted by loadPlugins. */
|
|
41
|
+
export type ResttyPluginRegistry = ReadonlyMap<string, ResttyPluginRegistryEntry> | Record<string, ResttyPluginRegistryEntry>;
|
|
42
|
+
/** Status for manifest-driven plugin load attempts. */
|
|
43
|
+
export type ResttyPluginLoadStatus = "loaded" | "skipped" | "missing" | "failed";
|
|
44
|
+
/** Result row returned by loadPlugins. */
|
|
45
|
+
export type ResttyPluginLoadResult = {
|
|
46
|
+
id: string;
|
|
47
|
+
status: ResttyPluginLoadStatus;
|
|
48
|
+
error: string | null;
|
|
49
|
+
};
|
|
50
|
+
/** Event payloads emitted by the Restty plugin host. */
|
|
51
|
+
export type ResttyPluginEvents = {
|
|
52
|
+
"plugin:activated": {
|
|
53
|
+
pluginId: string;
|
|
54
|
+
};
|
|
55
|
+
"plugin:deactivated": {
|
|
56
|
+
pluginId: string;
|
|
57
|
+
};
|
|
58
|
+
"pane:created": {
|
|
59
|
+
paneId: number;
|
|
60
|
+
};
|
|
61
|
+
"pane:closed": {
|
|
62
|
+
paneId: number;
|
|
63
|
+
};
|
|
64
|
+
"pane:split": {
|
|
65
|
+
sourcePaneId: number;
|
|
66
|
+
createdPaneId: number;
|
|
67
|
+
direction: ResttyPaneSplitDirection;
|
|
68
|
+
};
|
|
69
|
+
"pane:active-changed": {
|
|
70
|
+
paneId: number | null;
|
|
71
|
+
};
|
|
72
|
+
"layout:changed": {};
|
|
73
|
+
"pane:resized": {
|
|
74
|
+
paneId: number;
|
|
75
|
+
cols: number;
|
|
76
|
+
rows: number;
|
|
77
|
+
};
|
|
78
|
+
"pane:focused": {
|
|
79
|
+
paneId: number;
|
|
80
|
+
};
|
|
81
|
+
"pane:blurred": {
|
|
82
|
+
paneId: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/** A disposable resource returned by plugin APIs. */
|
|
86
|
+
export type ResttyPluginDisposable = {
|
|
87
|
+
dispose: () => void;
|
|
88
|
+
};
|
|
89
|
+
/** Optional cleanup return supported by plugin activation. */
|
|
90
|
+
export type ResttyPluginCleanup = void | (() => void) | ResttyPluginDisposable;
|
|
91
|
+
/** Payload passed to input interceptors before terminal/program input is written. */
|
|
92
|
+
export type ResttyInputInterceptorPayload = {
|
|
93
|
+
paneId: number;
|
|
94
|
+
text: string;
|
|
95
|
+
source: string;
|
|
96
|
+
};
|
|
97
|
+
/** Payload passed to output interceptors before PTY data is rendered. */
|
|
98
|
+
export type ResttyOutputInterceptorPayload = {
|
|
99
|
+
paneId: number;
|
|
100
|
+
text: string;
|
|
101
|
+
source: string;
|
|
102
|
+
};
|
|
103
|
+
/** Input interceptor contract. */
|
|
104
|
+
export type ResttyInputInterceptor = (payload: ResttyInputInterceptorPayload) => string | null | void;
|
|
105
|
+
/** Output interceptor contract. */
|
|
106
|
+
export type ResttyOutputInterceptor = (payload: ResttyOutputInterceptorPayload) => string | null | void;
|
|
107
|
+
/** Payload passed to lifecycle hooks registered by plugins. */
|
|
108
|
+
export type ResttyLifecycleHookPayload = {
|
|
109
|
+
phase: "before" | "after";
|
|
110
|
+
action: "create-initial-pane" | "split-active-pane" | "split-pane" | "close-pane" | "set-active-pane" | "mark-pane-focused" | "connect-pty" | "disconnect-pty" | "resize" | "focus" | "blur";
|
|
111
|
+
paneId?: number | null;
|
|
112
|
+
sourcePaneId?: number;
|
|
113
|
+
createdPaneId?: number | null;
|
|
114
|
+
direction?: ResttyPaneSplitDirection;
|
|
115
|
+
cols?: number;
|
|
116
|
+
rows?: number;
|
|
117
|
+
ok?: boolean;
|
|
118
|
+
error?: string | null;
|
|
119
|
+
};
|
|
120
|
+
/** Lifecycle hook contract. */
|
|
121
|
+
export type ResttyLifecycleHook = (payload: ResttyLifecycleHookPayload) => void;
|
|
122
|
+
/** Payload passed to render hooks registered by plugins. */
|
|
123
|
+
export type ResttyRenderHookPayload = {
|
|
124
|
+
phase: "before" | "after";
|
|
125
|
+
paneId: number;
|
|
126
|
+
text: string;
|
|
127
|
+
source: string;
|
|
128
|
+
dropped: boolean;
|
|
129
|
+
};
|
|
130
|
+
/** Render hook contract. */
|
|
131
|
+
export type ResttyRenderHook = (payload: ResttyRenderHookPayload) => void;
|
|
132
|
+
/** Shared options for interceptor ordering. */
|
|
133
|
+
export type ResttyInterceptorOptions = {
|
|
134
|
+
priority?: number;
|
|
135
|
+
};
|
|
136
|
+
export type ResttyRenderStageHandle = {
|
|
137
|
+
id: string;
|
|
138
|
+
setUniforms: (uniforms: number[]) => void;
|
|
139
|
+
setEnabled: (value: boolean) => void;
|
|
140
|
+
dispose: () => void;
|
|
141
|
+
};
|
|
142
|
+
/** Context object provided to each plugin on activation. */
|
|
143
|
+
export type ResttyPluginContext = {
|
|
144
|
+
restty: Restty;
|
|
145
|
+
options: unknown;
|
|
146
|
+
panes: () => ResttyPaneHandle[];
|
|
147
|
+
pane: (id: number) => ResttyPaneHandle | null;
|
|
148
|
+
activePane: () => ResttyPaneHandle | null;
|
|
149
|
+
focusedPane: () => ResttyPaneHandle | null;
|
|
150
|
+
on: <E extends keyof ResttyPluginEvents>(event: E, listener: (payload: ResttyPluginEvents[E]) => void) => ResttyPluginDisposable;
|
|
151
|
+
addInputInterceptor: (interceptor: ResttyInputInterceptor, options?: ResttyInterceptorOptions) => ResttyPluginDisposable;
|
|
152
|
+
addOutputInterceptor: (interceptor: ResttyOutputInterceptor, options?: ResttyInterceptorOptions) => ResttyPluginDisposable;
|
|
153
|
+
addLifecycleHook: (hook: ResttyLifecycleHook, options?: ResttyInterceptorOptions) => ResttyPluginDisposable;
|
|
154
|
+
addRenderHook: (hook: ResttyRenderHook, options?: ResttyInterceptorOptions) => ResttyPluginDisposable;
|
|
155
|
+
addRenderStage: (stage: ResttyShaderStage) => ResttyRenderStageHandle;
|
|
156
|
+
};
|
|
157
|
+
/** Plugin contract for extending Restty behavior. */
|
|
158
|
+
export type ResttyPlugin = {
|
|
159
|
+
id: string;
|
|
160
|
+
version?: string;
|
|
161
|
+
apiVersion?: number;
|
|
162
|
+
requires?: ResttyPluginRequires;
|
|
163
|
+
activate: (context: ResttyPluginContext, options?: unknown) => ResttyPluginCleanup | Promise<ResttyPluginCleanup>;
|
|
164
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ResttyPluginApiRangeLike = {
|
|
2
|
+
min: number;
|
|
3
|
+
max?: number;
|
|
4
|
+
};
|
|
5
|
+
export type ResttyPluginRequiresLike = {
|
|
6
|
+
pluginApi?: number | ResttyPluginApiRangeLike;
|
|
7
|
+
};
|
|
8
|
+
export type ResttyPluginLike = {
|
|
9
|
+
id: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
apiVersion?: number;
|
|
12
|
+
requires?: ResttyPluginRequiresLike;
|
|
13
|
+
};
|
|
14
|
+
export type ResttyPluginCleanupLike = void | (() => void) | {
|
|
15
|
+
dispose: () => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function errorToMessage(error: unknown): string;
|
|
18
|
+
export declare function normalizePluginMetadata<T extends ResttyPluginLike>(plugin: T, pluginId: string): T;
|
|
19
|
+
export declare function assertPluginCompatibility(pluginId: string, plugin: ResttyPluginLike, pluginApiVersion: number): void;
|
|
20
|
+
export declare function lookupPluginRegistryEntry<T>(registry: ReadonlyMap<string, T> | Record<string, T>, pluginId: string): T | null;
|
|
21
|
+
export declare function resolvePluginRegistryEntry<T>(entry: T | (() => T | Promise<T>)): Promise<T>;
|
|
22
|
+
export declare function normalizePluginCleanup(cleanup: ResttyPluginCleanupLike): (() => void) | null;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { DesktopNotification } from "../input";
|
|
2
|
+
import { type CreateResttyAppPaneManagerOptions, type ResttyManagedAppPane, type ResttyManagedPaneStyleOptions, type ResttyPaneAppOptionsInput } from "./pane-app-manager";
|
|
3
|
+
import type { ResttyPaneManager, ResttyPaneSplitDirection } from "./panes-types";
|
|
4
|
+
import type { ResttyFontSource, ResttyShaderStage } from "../runtime/types";
|
|
5
|
+
import { ResttyPaneHandle } from "./restty-pane-handle";
|
|
6
|
+
import { ResttyActivePaneApi } from "./restty/active-pane-api";
|
|
7
|
+
import { type ResttyPluginInfo, type ResttyPluginManifestEntry, type ResttyPluginRegistry, type ResttyPluginLoadResult, type ResttyRenderStageHandle, type ResttyPlugin } from "./restty-plugin-types";
|
|
8
|
+
export { ResttyPaneHandle } from "./restty-pane-handle";
|
|
9
|
+
export type { ResttyPaneApi } from "./restty-pane-handle";
|
|
10
|
+
export { RESTTY_PLUGIN_API_VERSION } from "./restty-plugin-types";
|
|
11
|
+
export type { ResttyPluginApiRange, ResttyPluginRequires, ResttyPluginInfo, ResttyPluginManifestEntry, ResttyPluginRegistryEntry, ResttyPluginRegistry, ResttyPluginLoadStatus, ResttyPluginLoadResult, ResttyPluginEvents, ResttyPluginDisposable, ResttyPluginCleanup, ResttyInputInterceptorPayload, ResttyOutputInterceptorPayload, ResttyInputInterceptor, ResttyOutputInterceptor, ResttyLifecycleHookPayload, ResttyLifecycleHook, ResttyRenderHookPayload, ResttyRenderHook, ResttyInterceptorOptions, ResttyRenderStageHandle, ResttyPluginContext, ResttyPlugin, } from "./restty-plugin-types";
|
|
12
|
+
/**
|
|
13
|
+
* Top-level configuration for creating a Restty instance.
|
|
14
|
+
*/
|
|
15
|
+
export type ResttyOptions = Omit<CreateResttyAppPaneManagerOptions, "appOptions"> & {
|
|
16
|
+
/** Per-pane app options, static or factory. */
|
|
17
|
+
appOptions?: CreateResttyAppPaneManagerOptions["appOptions"];
|
|
18
|
+
/** Font sources applied to every pane. */
|
|
19
|
+
fontSources?: ResttyPaneAppOptionsInput["fontSources"];
|
|
20
|
+
/** Global shader stages synchronized to all panes. */
|
|
21
|
+
shaderStages?: ResttyShaderStage[];
|
|
22
|
+
/** Global handler for desktop notifications emitted by any pane. */
|
|
23
|
+
onDesktopNotification?: (notification: DesktopNotification & {
|
|
24
|
+
paneId: number;
|
|
25
|
+
}) => void;
|
|
26
|
+
/** Whether to create the first pane automatically (default true). */
|
|
27
|
+
createInitialPane?: boolean | {
|
|
28
|
+
focus?: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Main entry point for the restty terminal widget. Manages a set of
|
|
33
|
+
* split panes, each running its own terminal app, and exposes
|
|
34
|
+
* convenience methods that operate on the active pane.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Restty extends ResttyActivePaneApi {
|
|
37
|
+
readonly paneManager: ResttyPaneManager<ResttyManagedAppPane>;
|
|
38
|
+
private fontSources;
|
|
39
|
+
private readonly shaderOps;
|
|
40
|
+
private readonly pluginOps;
|
|
41
|
+
constructor(options: ResttyOptions);
|
|
42
|
+
getPanes(): ResttyManagedAppPane[];
|
|
43
|
+
getPaneById(id: number): ResttyManagedAppPane | null;
|
|
44
|
+
getActivePane(): ResttyManagedAppPane | null;
|
|
45
|
+
getFocusedPane(): ResttyManagedAppPane | null;
|
|
46
|
+
panes(): ResttyPaneHandle[];
|
|
47
|
+
pane(id: number): ResttyPaneHandle | null;
|
|
48
|
+
activePane(): ResttyPaneHandle | null;
|
|
49
|
+
focusedPane(): ResttyPaneHandle | null;
|
|
50
|
+
forEachPane(visitor: (pane: ResttyPaneHandle) => void): void;
|
|
51
|
+
setFontSources(sources: ResttyFontSource[]): Promise<void>;
|
|
52
|
+
setShaderStages(stages: ResttyShaderStage[]): void;
|
|
53
|
+
getShaderStages(): ResttyShaderStage[];
|
|
54
|
+
addShaderStage(stage: ResttyShaderStage): ResttyRenderStageHandle;
|
|
55
|
+
removeShaderStage(id: string): boolean;
|
|
56
|
+
createInitialPane(options?: {
|
|
57
|
+
focus?: boolean;
|
|
58
|
+
}): ResttyManagedAppPane;
|
|
59
|
+
splitActivePane(direction: ResttyPaneSplitDirection): ResttyManagedAppPane | null;
|
|
60
|
+
splitPane(id: number, direction: ResttyPaneSplitDirection): ResttyManagedAppPane | null;
|
|
61
|
+
closePane(id: number): boolean;
|
|
62
|
+
getPaneStyleOptions(): Readonly<Required<ResttyManagedPaneStyleOptions>>;
|
|
63
|
+
setPaneStyleOptions(options: ResttyManagedPaneStyleOptions): void;
|
|
64
|
+
setActivePane(id: number, options?: {
|
|
65
|
+
focus?: boolean;
|
|
66
|
+
}): void;
|
|
67
|
+
markPaneFocused(id: number, options?: {
|
|
68
|
+
focus?: boolean;
|
|
69
|
+
}): void;
|
|
70
|
+
requestLayoutSync(): void;
|
|
71
|
+
hideContextMenu(): void;
|
|
72
|
+
use(plugin: ResttyPlugin, options?: unknown): Promise<void>;
|
|
73
|
+
loadPlugins(manifest: ReadonlyArray<ResttyPluginManifestEntry>, registry: ResttyPluginRegistry): Promise<ResttyPluginLoadResult[]>;
|
|
74
|
+
unuse(pluginId: string): boolean;
|
|
75
|
+
plugins(): string[];
|
|
76
|
+
pluginInfo(pluginId: string): ResttyPluginInfo | null;
|
|
77
|
+
pluginInfo(): ResttyPluginInfo[];
|
|
78
|
+
destroy(): void;
|
|
79
|
+
connectPty(url?: string): void;
|
|
80
|
+
disconnectPty(): void;
|
|
81
|
+
resize(cols: number, rows: number): void;
|
|
82
|
+
focus(): void;
|
|
83
|
+
blur(): void;
|
|
84
|
+
private paneLookup;
|
|
85
|
+
private lifecycleHooks;
|
|
86
|
+
private lifecycleAndPluginHooks;
|
|
87
|
+
protected requireActivePaneHandle(): ResttyPaneHandle;
|
|
88
|
+
private runLifecycleHooks;
|
|
89
|
+
private runRenderHooks;
|
|
90
|
+
private emitPluginEvent;
|
|
91
|
+
}
|
|
92
|
+
/** Create a new Restty instance with the given options. */
|
|
93
|
+
export declare function createRestty(options: ResttyOptions): Restty;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode base64 text into bytes. Throws when no decoder is available in
|
|
3
|
+
* the current runtime.
|
|
4
|
+
*/
|
|
5
|
+
export declare function decodeBase64Bytes(text: string): Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* Encode bytes to base64 text. Throws when no encoder is available in the
|
|
8
|
+
* current runtime.
|
|
9
|
+
*/
|
|
10
|
+
export declare function encodeBase64Bytes(bytes: Uint8Array): string;
|
|
11
|
+
/** Decode base64 text payloads to UTF-8 text, returning empty text on errors. */
|
|
12
|
+
export declare function decodeBase64Text(text: string): string;
|
package/dist/wasm/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type { CursorInfo, KittyPlacement, RenderState, ResttyWasmExports, ResttyWasmOptions, WasmAbi, WasmAbiKind, } from "./runtime/types";
|
|
2
|
+
export { ResttyWasm, loadResttyWasm } from "./runtime/restty-wasm";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CursorInfo, RenderPtrs, ResttyWasmExports, WasmAbi } from "./types";
|
|
2
|
+
export declare function resolveWasmAbi(exports: ResttyWasmExports): WasmAbi | null;
|
|
3
|
+
export declare function unpackCursor(buffer: ArrayBufferLike, ptr: number): CursorInfo | null;
|
|
4
|
+
export declare function readRenderInfo(exports: ResttyWasmExports, handle: number): RenderPtrs | null;
|
|
5
|
+
export declare function readRenderPtrs(exports: ResttyWasmExports, handle: number): RenderPtrs;
|
|
6
|
+
export declare function readCellPtrs(exports: ResttyWasmExports, handle: number): RenderPtrs;
|
|
7
|
+
export declare function readRenderStatePtrs(abi: WasmAbi, exports: ResttyWasmExports, handle: number): RenderPtrs | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { KittyPlacement, RenderState, ResttyWasmExports, ResttyWasmOptions, WasmAbi } from "./types";
|
|
2
|
+
/** WASM terminal core runtime with memory management and typed array caching. */
|
|
3
|
+
export declare class ResttyWasm {
|
|
4
|
+
readonly exports: ResttyWasmExports;
|
|
5
|
+
readonly abi: WasmAbi;
|
|
6
|
+
readonly memory: WebAssembly.Memory;
|
|
7
|
+
private readonly renderViewCaches;
|
|
8
|
+
private constructor();
|
|
9
|
+
/** Load and instantiate the embedded WASM module. */
|
|
10
|
+
static load(options?: ResttyWasmOptions): Promise<ResttyWasm>;
|
|
11
|
+
/** Create a new terminal instance and return its handle. */
|
|
12
|
+
create(cols: number, rows: number, maxScrollback: number): number;
|
|
13
|
+
/** Destroy a terminal instance and free its resources. */
|
|
14
|
+
destroy(handle: number): void;
|
|
15
|
+
private getRenderViewCache;
|
|
16
|
+
/** Resize the terminal grid. */
|
|
17
|
+
resize(handle: number, cols: number, rows: number): void;
|
|
18
|
+
/** Set pixel dimensions for Kitty graphics protocol. */
|
|
19
|
+
setPixelSize(handle: number, widthPx: number, heightPx: number): void;
|
|
20
|
+
/** Update internal render buffers after state changes. */
|
|
21
|
+
renderUpdate(handle: number): void;
|
|
22
|
+
/** Scroll the viewport by delta rows. */
|
|
23
|
+
scrollViewport(handle: number, delta: number): void;
|
|
24
|
+
/** Read and clear pending output replies from terminal. */
|
|
25
|
+
drainOutput(handle: number): string;
|
|
26
|
+
/** Get active Kitty keyboard protocol flags. */
|
|
27
|
+
getKittyKeyboardFlags(handle: number): number;
|
|
28
|
+
/** Get all active Kitty graphics placements. */
|
|
29
|
+
getKittyPlacements(handle: number): KittyPlacement[];
|
|
30
|
+
/** Write text to terminal for processing. */
|
|
31
|
+
write(handle: number, text: string): void;
|
|
32
|
+
/** Set default colors for terminal (RGB packed as 0xRRGGBB). */
|
|
33
|
+
setDefaultColors(handle: number, fg: number, bg: number, cursor: number): void;
|
|
34
|
+
/** Set terminal color palette (RGB triples). */
|
|
35
|
+
setPalette(handle: number, colors: Uint8Array, count: number): void;
|
|
36
|
+
/** Reset terminal palette to defaults. */
|
|
37
|
+
resetPalette(handle: number): void;
|
|
38
|
+
/** Get current render state with cached typed array views. */
|
|
39
|
+
getRenderState(handle: number): RenderState | null;
|
|
40
|
+
}
|
|
41
|
+
/** Load and instantiate the embedded WASM module (convenience function). */
|
|
42
|
+
export declare function loadResttyWasm(options?: ResttyWasmOptions): Promise<ResttyWasm>;
|
|
@@ -141,44 +141,51 @@ export type ResttyWasmExports = WebAssembly.Exports & {
|
|
|
141
141
|
export type ResttyWasmOptions = {
|
|
142
142
|
log?: (message: string) => void;
|
|
143
143
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
144
|
+
export type RenderPtrs = {
|
|
145
|
+
rows: number;
|
|
146
|
+
cols: number;
|
|
147
|
+
codepointsPtr: number;
|
|
148
|
+
contentTagsPtr: number;
|
|
149
|
+
widePtr: number;
|
|
150
|
+
flagsPtr: number;
|
|
151
|
+
styleFlagsPtr: number;
|
|
152
|
+
linkIdsPtr: number;
|
|
153
|
+
fgPtr: number;
|
|
154
|
+
bgPtr: number;
|
|
155
|
+
ulPtr: number;
|
|
156
|
+
ulStylePtr: number;
|
|
157
|
+
graphemeOffsetPtr: number;
|
|
158
|
+
graphemeLenPtr: number;
|
|
159
|
+
graphemeBufferPtr: number;
|
|
160
|
+
graphemeBufferLen: number;
|
|
161
|
+
selectionStartPtr: number;
|
|
162
|
+
selectionEndPtr: number;
|
|
163
|
+
cursorPtr: number;
|
|
164
|
+
};
|
|
165
|
+
export type ViewEntry<T extends ArrayBufferView> = {
|
|
166
|
+
buffer: ArrayBufferLike | null;
|
|
167
|
+
ptr: number;
|
|
168
|
+
len: number;
|
|
169
|
+
view: T | null;
|
|
170
|
+
};
|
|
171
|
+
export type RenderViewCache = {
|
|
172
|
+
codepoints: ViewEntry<Uint32Array>;
|
|
173
|
+
contentTags: ViewEntry<Uint8Array>;
|
|
174
|
+
wide: ViewEntry<Uint8Array>;
|
|
175
|
+
cellFlags: ViewEntry<Uint16Array>;
|
|
176
|
+
styleFlags: ViewEntry<Uint16Array>;
|
|
177
|
+
linkIds: ViewEntry<Uint32Array>;
|
|
178
|
+
fgBytes: ViewEntry<Uint8Array>;
|
|
179
|
+
bgBytes: ViewEntry<Uint8Array>;
|
|
180
|
+
ulBytes: ViewEntry<Uint8Array>;
|
|
181
|
+
ulStyle: ViewEntry<Uint8Array>;
|
|
182
|
+
linkOffsets: ViewEntry<Uint32Array>;
|
|
183
|
+
linkLengths: ViewEntry<Uint32Array>;
|
|
184
|
+
linkBuffer: ViewEntry<Uint8Array>;
|
|
185
|
+
graphemeOffset: ViewEntry<Uint32Array>;
|
|
186
|
+
graphemeLen: ViewEntry<Uint32Array>;
|
|
187
|
+
graphemeBuffer: ViewEntry<Uint32Array>;
|
|
188
|
+
selectionStart: ViewEntry<Int16Array>;
|
|
189
|
+
selectionEnd: ViewEntry<Int16Array>;
|
|
190
|
+
};
|
|
191
|
+
export type TypedArrayCtor<T extends ArrayBufferView> = new (buffer: ArrayBufferLike, byteOffset: number, length: number) => T;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RenderViewCache, TypedArrayCtor, ViewEntry } from "./types";
|
|
2
|
+
export declare function makeViewEntry<T extends ArrayBufferView>(): ViewEntry<T>;
|
|
3
|
+
export declare function makeRenderViewCache(): RenderViewCache;
|
|
4
|
+
export declare function getCachedView<T extends ArrayBufferView>(entry: ViewEntry<T>, buffer: ArrayBufferLike, ptr: number, len: number, Ctor: TypedArrayCtor<T>): T | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeDimension(value: number | undefined, fallback: number): number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type Listener<T> = (payload: T) => void;
|
|
2
|
+
export declare function addListener<T>(bucket: Set<Listener<T>>, listener: Listener<T>): {
|
|
3
|
+
dispose: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function emitWithGuard<T>(bucket: Set<Listener<T>>, payload: T, label: "onData" | "onResize"): void;
|
package/dist/xterm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Restty, type ResttyOptions } from "./
|
|
1
|
+
import { type Restty, type ResttyOptions } from "./surface/restty";
|
|
2
2
|
export type IDisposable = {
|
|
3
3
|
dispose: () => void;
|
|
4
4
|
};
|
|
@@ -69,9 +69,4 @@ export declare class Terminal {
|
|
|
69
69
|
dispose(): void;
|
|
70
70
|
private ensureUsable;
|
|
71
71
|
private applyOptions;
|
|
72
|
-
private createCompatAppOptions;
|
|
73
|
-
private emitData;
|
|
74
|
-
private emitResize;
|
|
75
|
-
private addListener;
|
|
76
|
-
private normalizeDimension;
|
|
77
72
|
}
|
package/dist/xterm.js
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRestty
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-pab3ge3d.js";
|
|
4
|
+
|
|
5
|
+
// src/xterm/app-options.ts
|
|
6
|
+
function createCompatAppOptions(userAppOptions, emitData) {
|
|
7
|
+
return (context) => {
|
|
8
|
+
const resolved = typeof userAppOptions === "function" ? userAppOptions(context) : userAppOptions ?? {};
|
|
9
|
+
const userBeforeInput = resolved.beforeInput;
|
|
10
|
+
return {
|
|
11
|
+
...resolved,
|
|
12
|
+
beforeInput: ({ text, source }) => {
|
|
13
|
+
const maybeNext = userBeforeInput?.({ text, source });
|
|
14
|
+
if (maybeNext === null)
|
|
15
|
+
return null;
|
|
16
|
+
const nextText = maybeNext === undefined ? text : maybeNext;
|
|
17
|
+
if (source !== "pty" && nextText) {
|
|
18
|
+
emitData(nextText);
|
|
19
|
+
}
|
|
20
|
+
return nextText;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/xterm/dimensions.ts
|
|
27
|
+
function normalizeDimension(value, fallback) {
|
|
28
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
|
|
29
|
+
return fallback;
|
|
30
|
+
return Math.max(1, Math.trunc(value));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/xterm/listeners.ts
|
|
34
|
+
function addListener(bucket, listener) {
|
|
35
|
+
bucket.add(listener);
|
|
36
|
+
return {
|
|
37
|
+
dispose: () => {
|
|
38
|
+
bucket.delete(listener);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function emitWithGuard(bucket, payload, label) {
|
|
43
|
+
const listeners = Array.from(bucket);
|
|
44
|
+
for (let i = 0;i < listeners.length; i += 1) {
|
|
45
|
+
try {
|
|
46
|
+
listeners[i](payload);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(`[restty/xterm] ${label} listener error:`, error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
4
52
|
|
|
5
53
|
// src/xterm.ts
|
|
6
54
|
class Terminal {
|
|
@@ -25,8 +73,8 @@ class Terminal {
|
|
|
25
73
|
this.optionValues = { ...options };
|
|
26
74
|
delete this.optionValues.cols;
|
|
27
75
|
delete this.optionValues.rows;
|
|
28
|
-
this.cols =
|
|
29
|
-
this.rows =
|
|
76
|
+
this.cols = normalizeDimension(cols, 80);
|
|
77
|
+
this.rows = normalizeDimension(rows, 24);
|
|
30
78
|
if (Number.isFinite(cols) && Number.isFinite(rows)) {
|
|
31
79
|
this.pendingSize = { cols: this.cols, rows: this.rows };
|
|
32
80
|
}
|
|
@@ -57,7 +105,9 @@ class Terminal {
|
|
|
57
105
|
this.elementRef = parent;
|
|
58
106
|
this.resttyInstance = createRestty({
|
|
59
107
|
...this.resttyOptionsBase,
|
|
60
|
-
appOptions: this.
|
|
108
|
+
appOptions: createCompatAppOptions(this.userAppOptions, (data) => {
|
|
109
|
+
emitWithGuard(this.dataListeners, data, "onData");
|
|
110
|
+
}),
|
|
61
111
|
root: parent
|
|
62
112
|
});
|
|
63
113
|
if (this.pendingSize) {
|
|
@@ -90,14 +140,14 @@ class Terminal {
|
|
|
90
140
|
resize(cols, rows) {
|
|
91
141
|
this.ensureUsable();
|
|
92
142
|
const next = {
|
|
93
|
-
cols:
|
|
94
|
-
rows:
|
|
143
|
+
cols: normalizeDimension(cols, this.cols),
|
|
144
|
+
rows: normalizeDimension(rows, this.rows)
|
|
95
145
|
};
|
|
96
146
|
this.cols = next.cols;
|
|
97
147
|
this.rows = next.rows;
|
|
98
148
|
this.pendingSize = next;
|
|
99
149
|
this.resttyInstance?.resize(next.cols, next.rows);
|
|
100
|
-
this.
|
|
150
|
+
emitWithGuard(this.resizeListeners, next, "onResize");
|
|
101
151
|
}
|
|
102
152
|
focus() {
|
|
103
153
|
if (this.disposed)
|
|
@@ -126,11 +176,11 @@ class Terminal {
|
|
|
126
176
|
}
|
|
127
177
|
onData(listener) {
|
|
128
178
|
this.ensureUsable();
|
|
129
|
-
return
|
|
179
|
+
return addListener(this.dataListeners, listener);
|
|
130
180
|
}
|
|
131
181
|
onResize(listener) {
|
|
132
182
|
this.ensureUsable();
|
|
133
|
-
return
|
|
183
|
+
return addListener(this.resizeListeners, listener);
|
|
134
184
|
}
|
|
135
185
|
setOption(key, value) {
|
|
136
186
|
this.ensureUsable();
|
|
@@ -184,8 +234,8 @@ class Terminal {
|
|
|
184
234
|
const hasCols = Object.prototype.hasOwnProperty.call(next, "cols");
|
|
185
235
|
const hasRows = Object.prototype.hasOwnProperty.call(next, "rows");
|
|
186
236
|
if (hasCols || hasRows) {
|
|
187
|
-
const cols = hasCols ?
|
|
188
|
-
const rows = hasRows ?
|
|
237
|
+
const cols = hasCols ? normalizeDimension(next.cols, this.cols) : this.cols;
|
|
238
|
+
const rows = hasRows ? normalizeDimension(next.rows, this.rows) : this.rows;
|
|
189
239
|
this.resize(cols, rows);
|
|
190
240
|
}
|
|
191
241
|
const keys = Object.keys(next);
|
|
@@ -196,58 +246,6 @@ class Terminal {
|
|
|
196
246
|
this.optionValues[key] = next[key];
|
|
197
247
|
}
|
|
198
248
|
}
|
|
199
|
-
createCompatAppOptions() {
|
|
200
|
-
return (context) => {
|
|
201
|
-
const resolved = typeof this.userAppOptions === "function" ? this.userAppOptions(context) : this.userAppOptions ?? {};
|
|
202
|
-
const userBeforeInput = resolved.beforeInput;
|
|
203
|
-
return {
|
|
204
|
-
...resolved,
|
|
205
|
-
beforeInput: ({ text, source }) => {
|
|
206
|
-
const maybeNext = userBeforeInput?.({ text, source });
|
|
207
|
-
if (maybeNext === null)
|
|
208
|
-
return null;
|
|
209
|
-
const nextText = maybeNext === undefined ? text : maybeNext;
|
|
210
|
-
if (source !== "pty" && nextText) {
|
|
211
|
-
this.emitData(nextText);
|
|
212
|
-
}
|
|
213
|
-
return nextText;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
emitData(data) {
|
|
219
|
-
const listeners = Array.from(this.dataListeners);
|
|
220
|
-
for (let i = 0;i < listeners.length; i += 1) {
|
|
221
|
-
try {
|
|
222
|
-
listeners[i](data);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
console.error("[restty/xterm] onData listener error:", error);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
emitResize(size) {
|
|
229
|
-
const listeners = Array.from(this.resizeListeners);
|
|
230
|
-
for (let i = 0;i < listeners.length; i += 1) {
|
|
231
|
-
try {
|
|
232
|
-
listeners[i](size);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error("[restty/xterm] onResize listener error:", error);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
addListener(bucket, listener) {
|
|
239
|
-
bucket.add(listener);
|
|
240
|
-
return {
|
|
241
|
-
dispose: () => {
|
|
242
|
-
bucket.delete(listener);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
normalizeDimension(value, fallback) {
|
|
247
|
-
if (!Number.isFinite(value) || value <= 0)
|
|
248
|
-
return fallback;
|
|
249
|
-
return Math.max(1, Math.trunc(value));
|
|
250
|
-
}
|
|
251
249
|
}
|
|
252
250
|
export {
|
|
253
251
|
Terminal
|