import { ICommandInfo, WebTerm, parseCommand } from 'web-term-ui'; /* * @Author: chenzhongsheng * @Date: 2024-11-30 11:30:49 * @Description: Coding something */ export type IPromiseData> = T extends Promise ? U : any; export type IPromiseMaybe = Promise | T; export type IFnMaybe = T | (() => T); export type IOprateResult = {}> = { success: boolean; info: string; } & T; export interface ICommand { name: string; helpDetails?: IFnMaybe; version?: IFnMaybe; helpInfo?: IFnMaybe; run(cmd: ICommandInfo, context: { commands: ICommandInfo[]; disk: T; data: string; term: WebTerm; run: (line: string | ICommandInfo[]) => Promise; }): IPromiseMaybe; activate?(disk: T, provider: ICommandProvider): void; dispose?(): void; } export interface ICommandProvider { getPwd: () => string; onTab?: (value: string, full: string) => IPromiseMaybe<({ line?: string; result: string; })>; onCommand: (commands: ICommandInfo[], methods: { setPwd: (v: string) => void; clearTerminal: () => void; getHeader: () => string; openEditor: (options: { path: string; content: string; save: (v: string) => void; }) => void; }) => IPromiseMaybe; registerCommand?(command: ICommand): IOprateResult; removeCommand?(name: string): IOprateResult; } export interface IPos { x: number; y: number; } export declare const TerminalControlKey: { readonly "\r": "Enter"; readonly "": "Backspace"; readonly "\u001B[A": "Up"; readonly "\u001B[B": "Down"; readonly "\u001B[D": "Left"; readonly "\u001B[C": "Right"; readonly "\t": "Tab"; }; export declare const TerminalKeys: ("Enter" | "Tab" | "Backspace" | "Up" | "Down" | "Left" | "Right")[]; export declare const TerminalKeysSet: Set<"Enter" | "Tab" | "Backspace" | "Up" | "Down" | "Left" | "Right">; export type ITerminalKey = typeof TerminalKeys[number]; export interface ITerminalEditor { addRecord(v: string): void; clearRecord(): void; edit(v: string): void; back(): void; onKey(key: ITerminalKey, v?: string): boolean; initTerminalManager(manager: ITerminalManager): void; isEditing: boolean; } export interface ITerminalInfo { x: number; y: number; length: number; rows: number; cols: number; } export interface ITerminalProvider { editor?: ITerminalEditor; title?: string; write(data: string): void; getHeader(): string; onTab?(value: string, full: string): IPromiseMaybe; onCommand?(commands: ICommandInfo[]): IPromiseMaybe; onEnter?(line: string): IPromiseMaybe; onData(ln: (data: string) => void): void; getTermInfo(): ITerminalInfo; } export interface ITerminalManager { name: string; line: string; cursorIndex: number; provider: ITerminalProvider; get header(): string; clear(pure?: boolean): void; setCursorPos(x: number, y: number): void; write(data: string): void; writeLine(text: string, lines?: number): void; writeEmptyLine(): void; cursorMove(count?: number): number; cursorMoveToTail(): void; cursorMoveToHead(): void; replaceCurrentLine(value: string): void; delete(count?: number): void; deleteAll(): void; onHandleTerminalData(data: string): Promise; insertLine(content: string): void; } export declare function notImplemented(): void; export declare function notImplementedAsync(): Promise; export declare function attachTarget(obj: any, target: any): void; export declare function withResolve(): { ready: Promise; resolve: (data?: T) => void; reject: (Err?: Err) => void; }; export declare function mergeU8s(...u8s: Uint8Array[]): Uint8Array; export declare function isU8sEqual(u8s1: Uint8Array, u8s2: Uint8Array | null): boolean; export declare function copyU8s(u8s: Uint8Array): Uint8Array; export declare function io>(promise: T): Promise<[ IPromiseData, any ]>; export declare function encode(v: string): Uint8Array; export declare function decode(v: Uint8Array): string; export declare function runPromises(ps: (() => Promise)[]): Promise; export declare function createPromises(): { add: (v: Promise) => void; run: () => Promise[]>; }; export type DebounceFunction any> = (this: ThisParameterType, ...args: Parameters) => void; export declare function debounce any>(func: T, delay: number): DebounceFunction; export declare function splitPathInfo(path: string): { path: string; parent: string; name: string; }; export declare function asyncAll(): { add(pro: Promise): void; run(): Promise[]>; }; export declare function runPromiseMaybe(v: IPromiseMaybe): Promise; export declare function runFnMaybe(v: T | (() => T)): T; export declare function mergePositions(...ps: IPos[]): IPos; export declare function mergeText(target: string, addon: string, index?: number): string; export declare function removeText(text: string, index: number): string; export declare function geneText(size: number, fill: string): string; export declare function isMac(): boolean; export declare function isHttpLink(v: string): boolean; export declare function fetchJson = Record>(url: string): Promise; export declare function fetchText(url: string): Promise; export declare function executeJS(code: string): Promise; export declare function executeJSWithFn(code: string, args?: Record): T; export interface ICommandOptions { commands: ICommandInfo[]; disk: T; data: string; term: WebTerm; run: (line: string | ICommandInfo[]) => Promise; } export declare class BaseCommand implements ICommand { name: string; helpInfo: IFnMaybe; helpDetails: IFnMaybe; term: WebTerm; disk: T; provider: ICommandProvider; activate(disk: T, provider: ICommandProvider): void; run(cmd: ICommandInfo, options: ICommandOptions): IPromiseMaybe; } export declare function parseGithubFile(v: string, dfFile?: string): string; export declare function parseNPMFile(v: string, useUnpkg?: boolean): string; export { ICommandInfo, WebTerm, parseCommand, }; export {};