mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
export TypingsInstaller from tsserverlibrary (#53394)
This commit is contained in:
@@ -31,7 +31,6 @@ import {
|
||||
versionMajorMinor,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
/** @internal */
|
||||
export interface TypingResolutionHost {
|
||||
directoryExists(path: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
|
||||
@@ -99,7 +99,6 @@ export interface EndInstallTypes extends InstallTypes {
|
||||
readonly installSuccess: boolean;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
writeFile(path: string, content: string): void;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* Generated file to emulate the ts.server namespace. */
|
||||
|
||||
export * from "../../jsTyping/_namespaces/ts.server";
|
||||
export * from "../../typingsInstallerCore/_namespaces/ts.server";
|
||||
export * from "../types";
|
||||
export * from "../utilitiesPublic";
|
||||
export * from "../utilities";
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"references": [
|
||||
{ "path": "../compiler" },
|
||||
{ "path": "../jsTyping" },
|
||||
{ "path": "../typingsInstallerCore" },
|
||||
{ "path": "../services" },
|
||||
{ "path": "../deprecatedCompat" }
|
||||
],
|
||||
|
||||
@@ -107,7 +107,8 @@ export function getNpmCommandForInstallation(npmPath: string, tsVersion: string,
|
||||
}
|
||||
|
||||
export type RequestCompletedAction = (success: boolean) => void;
|
||||
interface PendingRequest {
|
||||
|
||||
export interface PendingRequest {
|
||||
requestId: number;
|
||||
packageNames: string[];
|
||||
cwd: string;
|
||||
@@ -146,6 +147,7 @@ export abstract class TypingsInstaller {
|
||||
private readonly knownCachesSet = new Set<string>();
|
||||
private readonly projectWatchers = new Map<string, ProjectWatchers>();
|
||||
private safeList: JsTyping.SafeList | undefined;
|
||||
/** @internal */
|
||||
readonly pendingRunRequests: PendingRequest[] = [];
|
||||
private readonly toCanonicalFileName: GetCanonicalFileName;
|
||||
private readonly globalCachePackageJsonPath: string;
|
||||
|
||||
@@ -79,6 +79,14 @@ declare namespace ts {
|
||||
readonly kind: EventEndInstallTypes;
|
||||
readonly installSuccess: boolean;
|
||||
}
|
||||
interface InstallTypingHost extends JsTyping.TypingResolutionHost {
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
writeFile(path: string, content: string): void;
|
||||
createDirectory(path: string): void;
|
||||
getCurrentDirectory?(): string;
|
||||
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
|
||||
}
|
||||
interface SetTypings extends ProjectResponse {
|
||||
readonly typeAcquisition: TypeAcquisition;
|
||||
readonly compilerOptions: CompilerOptions;
|
||||
@@ -2965,6 +2973,54 @@ declare namespace ts {
|
||||
bigintLiteral = 25
|
||||
}
|
||||
}
|
||||
namespace typingsInstaller {
|
||||
interface Log {
|
||||
isEnabled(): boolean;
|
||||
writeLine(text: string): void;
|
||||
}
|
||||
type RequestCompletedAction = (success: boolean) => void;
|
||||
interface PendingRequest {
|
||||
requestId: number;
|
||||
packageNames: string[];
|
||||
cwd: string;
|
||||
onRequestCompleted: RequestCompletedAction;
|
||||
}
|
||||
abstract class TypingsInstaller {
|
||||
protected readonly installTypingHost: InstallTypingHost;
|
||||
private readonly globalCachePath;
|
||||
private readonly safeListPath;
|
||||
private readonly typesMapLocation;
|
||||
private readonly throttleLimit;
|
||||
protected readonly log: Log;
|
||||
private readonly packageNameToTypingLocation;
|
||||
private readonly missingTypingsSet;
|
||||
private readonly knownCachesSet;
|
||||
private readonly projectWatchers;
|
||||
private safeList;
|
||||
private readonly toCanonicalFileName;
|
||||
private readonly globalCachePackageJsonPath;
|
||||
private installRunCount;
|
||||
private inFlightRequestCount;
|
||||
abstract readonly typesRegistry: Map<string, MapLike<string>>;
|
||||
constructor(installTypingHost: InstallTypingHost, globalCachePath: string, safeListPath: Path, typesMapLocation: Path, throttleLimit: number, log?: Log);
|
||||
closeProject(req: CloseProject): void;
|
||||
private closeWatchers;
|
||||
install(req: DiscoverTypings): void;
|
||||
private initializeSafeList;
|
||||
private processCacheLocation;
|
||||
private filterTypings;
|
||||
protected ensurePackageDirectoryExists(directory: string): void;
|
||||
private installTypings;
|
||||
private ensureDirectoryExists;
|
||||
private watchFiles;
|
||||
private createSetTypings;
|
||||
private installTypingsAsync;
|
||||
private executeWithThrottling;
|
||||
protected abstract installWorker(requestId: number, packageNames: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
|
||||
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes): void;
|
||||
protected readonly latestDistTag = "latest";
|
||||
}
|
||||
}
|
||||
interface CompressedData {
|
||||
length: number;
|
||||
compressionKind: string;
|
||||
@@ -9790,6 +9846,14 @@ declare namespace ts {
|
||||
emit(writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): EmitResult | BuildInvalidedProject<T> | undefined;
|
||||
}
|
||||
type InvalidatedProject<T extends BuilderProgram> = UpdateOutputFileStampsProject | BuildInvalidedProject<T> | UpdateBundleProject<T>;
|
||||
namespace JsTyping {
|
||||
interface TypingResolutionHost {
|
||||
directoryExists(path: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(path: string, encoding?: string): string | undefined;
|
||||
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
|
||||
}
|
||||
}
|
||||
function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings;
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
|
||||
+16
@@ -5847,6 +5847,14 @@ declare namespace ts {
|
||||
emit(writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): EmitResult | BuildInvalidedProject<T> | undefined;
|
||||
}
|
||||
type InvalidatedProject<T extends BuilderProgram> = UpdateOutputFileStampsProject | BuildInvalidedProject<T> | UpdateBundleProject<T>;
|
||||
namespace JsTyping {
|
||||
interface TypingResolutionHost {
|
||||
directoryExists(path: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(path: string, encoding?: string): string | undefined;
|
||||
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
|
||||
}
|
||||
}
|
||||
namespace server {
|
||||
type ActionSet = "action::set";
|
||||
type ActionInvalidate = "action::invalidate";
|
||||
@@ -5912,6 +5920,14 @@ declare namespace ts {
|
||||
readonly kind: EventEndInstallTypes;
|
||||
readonly installSuccess: boolean;
|
||||
}
|
||||
interface InstallTypingHost extends JsTyping.TypingResolutionHost {
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
writeFile(path: string, content: string): void;
|
||||
createDirectory(path: string): void;
|
||||
getCurrentDirectory?(): string;
|
||||
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
|
||||
}
|
||||
interface SetTypings extends ProjectResponse {
|
||||
readonly typeAcquisition: TypeAcquisition;
|
||||
readonly compilerOptions: CompilerOptions;
|
||||
|
||||
Reference in New Issue
Block a user