148 lines
5.5 KiB
TypeScript
148 lines
5.5 KiB
TypeScript
import { M as MaybePromise, F as FilterPattern, p as ServerStorageName, l as SuccessResponse, m as FailResponse } from './env-config-3be2ee5d.js';
|
|
import * as _kvs_storage from '@kvs/storage';
|
|
import { Response } from 'express';
|
|
import { z } from 'zod';
|
|
|
|
interface TunnelOptions {
|
|
remoteHost?: string;
|
|
remotePort?: number;
|
|
localHost?: string;
|
|
localPort: number;
|
|
shareToken?: string;
|
|
}
|
|
declare class Tunnel {
|
|
private tunnelProcess;
|
|
GRADIO_API_SERVER_URL: string;
|
|
url: string | null;
|
|
private remoteHost;
|
|
private remotePort;
|
|
private localHost;
|
|
private localPort;
|
|
private shareToken;
|
|
constructor(options: TunnelOptions);
|
|
initProcess(): Promise<void>;
|
|
startTunnel(): Promise<string>;
|
|
kill(): void;
|
|
}
|
|
|
|
declare function compareVersion(a: string, b: string): 1 | 0 | -1;
|
|
declare function checkNodeVersion(): string | undefined;
|
|
declare function canUseNodeFetchWithoutCliFlag(): boolean;
|
|
declare function getRunServerEnv(): {
|
|
NODE_OPTIONS: string;
|
|
NODE_NO_WARNINGS: string;
|
|
} | {
|
|
NODE_OPTIONS?: undefined;
|
|
NODE_NO_WARNINGS?: undefined;
|
|
};
|
|
|
|
type LaunchEditorName = 'Atom' | 'Atom Beta' | 'subl' | 'sublime' | 'sublime_text' | 'wstorm' | 'charm' | 'notepad++' | 'vim' | 'mvim' | 'joe' | 'gvim' | 'emacs' | 'emacsclient' | 'rmate' | 'mate' | 'mine' | 'Code' | 'Code - Insiders' | 'codium' | 'vscodium' | 'VSCodium' | 'appcode' | 'clion' | 'clion64' | 'idea' | 'idea64' | 'phpstorm' | 'phpstorm64' | 'pycharm' | 'pycharm64' | 'rubymine' | 'rubymine64' | 'webstorm' | 'webstorm64' | 'goland' | 'goland64' | 'rider' | 'rider64';
|
|
interface LaunchEditorParams {
|
|
path: string;
|
|
lineNum?: number;
|
|
columnNum?: number;
|
|
editorName?: LaunchEditorName;
|
|
onError?: (error: any) => void;
|
|
}
|
|
declare function launchEditor(params: LaunchEditorParams): Promise<void>;
|
|
interface LaunchEditorByPathAndContentParams {
|
|
path: string;
|
|
matchContent?: string;
|
|
editorName?: LaunchEditorName;
|
|
onError?: (error: any) => void;
|
|
}
|
|
declare function launchEditorByPathAndContent(params: LaunchEditorByPathAndContentParams): Promise<{
|
|
lineNum: number;
|
|
columnNum: number;
|
|
}>;
|
|
|
|
interface ReadFileParams {
|
|
filePath: string | undefined;
|
|
valid?: boolean;
|
|
}
|
|
interface WriteFileParams {
|
|
filePath: string;
|
|
content: string;
|
|
overwrite?: boolean;
|
|
valid?: boolean;
|
|
}
|
|
interface EnsurePathParams {
|
|
filePath: string;
|
|
}
|
|
interface MovePathParams {
|
|
oldPath: string;
|
|
newPath: string;
|
|
}
|
|
interface TravelFilesParams {
|
|
filePath: string;
|
|
isValidPath: (filePath: string) => MaybePromise<boolean>;
|
|
callback: (filePath: string) => MaybePromise<void>;
|
|
}
|
|
interface TravelFilesByFilterPatternParams extends TravelFilesParams {
|
|
/**
|
|
* @default []
|
|
*/
|
|
exts?: string[];
|
|
/**
|
|
* @default null
|
|
*/
|
|
includes?: FilterPattern;
|
|
/**
|
|
* @default null
|
|
*/
|
|
excludes?: FilterPattern;
|
|
}
|
|
declare class FileUtils {
|
|
static readFile(params: ReadFileParams): Promise<string>;
|
|
static writeFile(params: WriteFileParams): Promise<void>;
|
|
static deletePath(fullPath: string): Promise<void>;
|
|
static ensurePath(params: EnsurePathParams): Promise<void>;
|
|
static movePath(params: MovePathParams): Promise<void>;
|
|
static travelFiles(params: TravelFilesParams): Promise<void>;
|
|
static travelFilesByFilterPattern(params: TravelFilesByFilterPatternParams): Promise<void>;
|
|
}
|
|
|
|
declare function getGlobalCacheDir(name: string): Promise<string>;
|
|
|
|
declare function getStorage(storageName: ServerStorageName): Promise<{
|
|
cacheDir: string;
|
|
storage: _kvs_storage.KvsStorage<Record<string, Record<string, any> | null>>;
|
|
}>;
|
|
|
|
interface OpenInBrowserProps {
|
|
url: string;
|
|
}
|
|
declare function openInBrowser(props: OpenInBrowserProps): void;
|
|
interface GetPortProps {
|
|
defaultPort?: number;
|
|
autoFreePort?: boolean;
|
|
excludePorts?: number[];
|
|
}
|
|
declare function getPort(props: GetPortProps): Promise<number>;
|
|
declare function getLocalHostname(): string;
|
|
|
|
declare class PathUtils {
|
|
static getCurrentDirName(importMetaUrl: string, getDirname: () => string): string;
|
|
static join(...paths: string[]): string;
|
|
static resolve(...paths: string[]): string;
|
|
static relative(from: string, to: string): string;
|
|
static dirname(filePath: string): string;
|
|
static extname(filePath: string): string;
|
|
static isFile(filePath: string): boolean;
|
|
static isDirectory(filePath: string): boolean;
|
|
static includeExt(filePath: string, exts: string[] | undefined | null): boolean;
|
|
static isExit(filePath: string): boolean;
|
|
static isAccessible(filePath: string, mode?: 'F' | 'R' | 'W' | 'X'): boolean;
|
|
static getDirPath(filePath: string): string;
|
|
}
|
|
|
|
declare function addNodejsPolyfill(): void;
|
|
|
|
declare function getDefaultProxyUrl(): Promise<string>;
|
|
|
|
declare function sendSuccessResponse<T>(res: Response, options: Omit<SuccessResponse<T>, 'type'>): Response;
|
|
declare function sendFailResponse<T>(res: Response, options: Omit<FailResponse<T>, 'type'>): Response;
|
|
declare function verifyParamsByZod<T>(params: T, schema: z.ZodSchema<T>): void;
|
|
|
|
export { EnsurePathParams, FileUtils, GetPortProps, LaunchEditorByPathAndContentParams, LaunchEditorName, LaunchEditorParams, MovePathParams, OpenInBrowserProps, PathUtils, ReadFileParams, TravelFilesByFilterPatternParams, TravelFilesParams, Tunnel, WriteFileParams, addNodejsPolyfill, canUseNodeFetchWithoutCliFlag, checkNodeVersion, compareVersion, getDefaultProxyUrl, getGlobalCacheDir, getLocalHostname, getPort, getRunServerEnv, getStorage, launchEditor, launchEditorByPathAndContent, openInBrowser, sendFailResponse, sendSuccessResponse, verifyParamsByZod };
|