Make Terminal a native feature
- Move the Terminal plugin into src/lib/features/terminal/ on the host Svelte runtime, with xterm 6.0.0 and addon-fit 0.11.0. - Buttons, shortcuts, Help rows, and the close guard follow the Terminal switch. The first use loads the module. - Add Settings → Terminal and the terminal settings section. The first start copies the old runestone.terminal key. - The 16 ANSI colors come from the --rs-ansi-* tokens. - Off asks first when a shell runs in any window (pty_running). - Rust: no pty-data or pty-exit events, an owner check for write, resize, and close, output joined up to 64 KiB or 8 ms, and the sessions of a reloaded page close. - Remove api.pty, the terminal contribution, TerminalSlot, and the plugin loader of the smoke harness. - Check only the tested switches in the Background smoke test. - Update the tests, the menu inventory, the docs, and UI-058.
This commit is contained in:
@@ -20,34 +20,6 @@ export interface PluginDocumentType {
|
||||
create?: { label: string; defaultName: string; extension: string; contents(): string };
|
||||
mount(container: HTMLElement, document: PluginDocumentContext): void | Dispose | Promise<void | Dispose>;
|
||||
}
|
||||
export interface PtyProfile { id: string; title: string; kind: string }
|
||||
export interface PtyOpenOptions {
|
||||
/** The workspace root of the window. The host rejects the request when the workspace changed. */
|
||||
cwd: string;
|
||||
cols: number;
|
||||
rows: number;
|
||||
profile?: string;
|
||||
/** A start folder other than the workspace root. */
|
||||
directory?: string;
|
||||
/** Receives raw terminal output. UTF-8 characters can be split between two calls. */
|
||||
onData(data: Uint8Array): void;
|
||||
onExit?(code: number | null): void;
|
||||
}
|
||||
export interface PtySession {
|
||||
readonly id: string;
|
||||
write(data: string): Promise<void>;
|
||||
resize(cols: number, rows: number): Promise<void>;
|
||||
/** Stops the shell. Repeated calls return the same promise. */
|
||||
close(): Promise<void>;
|
||||
}
|
||||
/** Terminal sessions. The host closes the sessions of a plugin when the plugin stops. */
|
||||
export interface PtyApi {
|
||||
readonly version: 1;
|
||||
profiles(): Promise<PtyProfile[]>;
|
||||
open(options: PtyOpenOptions): Promise<PtySession>;
|
||||
openWindow(): Promise<void>;
|
||||
dictation(): Promise<void>;
|
||||
}
|
||||
export interface FolderGrant { id: string; path: string; name: string }
|
||||
export interface FolderEntry { name: string; size: number }
|
||||
/** Folders outside the workspace that the user granted to this plugin. */
|
||||
@@ -89,7 +61,6 @@ export interface AssetsApi { read(path: string): Promise<Uint8Array> }
|
||||
/** Interface parts that the host draws. */
|
||||
export interface UiApi { showActionMenu(options: ActionMenuOptions): { close(): void } }
|
||||
export interface PluginApi {
|
||||
pty?: PtyApi;
|
||||
files?: FilesApi;
|
||||
services?: ServicesApi;
|
||||
backgrounds?: BackgroundApi;
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
import type { Dispose } from "./api.ts";
|
||||
|
||||
export type TerminalAction = "toggle" | "new" | "window" | "split" | "previous" | "next" | "commands" | "directories";
|
||||
export interface TerminalProps {
|
||||
cwd: string; visible: boolean; maximized?: boolean; standalone?: boolean;
|
||||
onClose: () => void; onMaximize?: () => void; activeFile?: boolean;
|
||||
onRunFile?: () => Promise<string | null>; getSelection?: () => string; onConfigureTasks?: () => Promise<void>;
|
||||
}
|
||||
export interface TerminalMount {
|
||||
update(props: TerminalProps): void;
|
||||
command(action: Exclude<TerminalAction, "toggle">): void | Promise<void>;
|
||||
dispose: Dispose;
|
||||
}
|
||||
/** Host features that `api.contribute(key, value)` registers. Only one enabled plugin can own each key. */
|
||||
export interface Contributions {
|
||||
browser: {
|
||||
@@ -21,8 +10,4 @@ export interface Contributions {
|
||||
/** Opens a web link from a document. False means that the system browser opens it. */
|
||||
open(url: string): Promise<boolean>;
|
||||
};
|
||||
terminal: {
|
||||
mount(container: HTMLElement, props: TerminalProps): TerminalMount;
|
||||
shortcut(event: Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey" | "shiftKey" | "code" | "key">): TerminalAction | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FilesApi, PluginApi, PtyApi, ServicesApi, SettingsApi, UiApi, WorkspaceApi } from "./api.ts";
|
||||
import type { FilesApi, PluginApi, ServicesApi, SettingsApi, UiApi, WorkspaceApi } from "./api.ts";
|
||||
import type { BackgroundApi } from "./backgrounds.ts";
|
||||
import type { CompletionApi } from "./completion.ts";
|
||||
|
||||
@@ -7,7 +7,6 @@ import type { CompletionApi } from "./completion.ts";
|
||||
* Older RuneStone hosts can omit these members. Required members, such as `workspace.read`, are not listed.
|
||||
*/
|
||||
export interface PluginFeatures {
|
||||
pty: PtyApi;
|
||||
files: FilesApi;
|
||||
services: ServicesApi;
|
||||
backgrounds: BackgroundApi;
|
||||
@@ -33,7 +32,6 @@ export interface PluginFeatures {
|
||||
export type PluginFeature = keyof PluginFeatures;
|
||||
|
||||
const descriptions: { [K in PluginFeature]: string } = {
|
||||
pty: "the terminal API",
|
||||
files: "the folder grant API",
|
||||
services: "the plugin service API",
|
||||
backgrounds: "the background API",
|
||||
|
||||
Reference in New Issue
Block a user