A long-lived process that survives an in-place upgrade keeps the previous pi-natives NAPI addon resident. A tab worker spawned afterwards runs the new JS loader, which expects the new version sentinel, but require returns the resident old exports carrying the prior sentinel. validateLoadedBindings previously reported "reinstall to re-sync" for this case even though disk was already consistent, so only a restart helped. Detect a versioned __piNativesV* export other than the expected one on the loaded bindings and report that omp was upgraded mid-session and must be restarted, reserving the reinstall guidance for genuinely disk-stale addons. Fixes #4812
102 lines
2.6 KiB
TypeScript
102 lines
2.6 KiB
TypeScript
export interface EmbeddedAddonFile {
|
|
variant: "modern" | "baseline" | "default";
|
|
filename: string;
|
|
size?: number;
|
|
filePath?: string;
|
|
}
|
|
|
|
export interface EmbeddedAddonArchive {
|
|
format: "tar.gz";
|
|
filename: string;
|
|
filePath: string;
|
|
}
|
|
|
|
export interface EmbeddedAddon {
|
|
platformTag: string;
|
|
version: string;
|
|
files: EmbeddedAddonFile[];
|
|
archive?: EmbeddedAddonArchive;
|
|
}
|
|
|
|
export interface DetectCompiledBinaryInput {
|
|
embeddedAddon: EmbeddedAddon | null | undefined;
|
|
env: Record<string, string | undefined>;
|
|
importMetaUrl: string | null | undefined;
|
|
}
|
|
|
|
export function detectCompiledBinary(input: DetectCompiledBinaryInput): boolean;
|
|
|
|
export interface GetAddonFilenamesInput {
|
|
tag: string;
|
|
arch: string;
|
|
variant: "modern" | "baseline" | null | undefined;
|
|
}
|
|
|
|
export function getAddonFilenames(input: GetAddonFilenamesInput): string[];
|
|
|
|
export interface ShouldStageNodeModulesAddonInput {
|
|
platform: NodeJS.Platform | string;
|
|
isCompiledBinary: boolean;
|
|
nativeDir: string;
|
|
}
|
|
|
|
export function shouldStageNodeModulesAddon(input: ShouldStageNodeModulesAddonInput): boolean;
|
|
|
|
export interface ResolveLoaderCandidatesInput {
|
|
addonFilenames: string[];
|
|
isCompiledBinary: boolean;
|
|
stageFromNodeModules?: boolean;
|
|
nativeDir: string;
|
|
leafPackageDir?: string | null;
|
|
execDir: string;
|
|
versionedDir: string;
|
|
userDataDir: string;
|
|
}
|
|
|
|
export function resolveLoaderCandidates(input: ResolveLoaderCandidatesInput): string[];
|
|
|
|
export interface CleanupStaleNativeVersionsInput {
|
|
nativesDir: string;
|
|
currentVersion: string;
|
|
}
|
|
|
|
export function cleanupStaleNativeVersions(input: CleanupStaleNativeVersionsInput): string[];
|
|
|
|
export interface ExtractEmbeddedAddonArchiveInput {
|
|
archivePath: string;
|
|
files: EmbeddedAddonFile[];
|
|
targetDir: string;
|
|
}
|
|
|
|
export function extractEmbeddedAddonArchive(input: ExtractEmbeddedAddonArchiveInput): string[];
|
|
|
|
export interface SelectCpuVariantInput {
|
|
arch: string;
|
|
override: "modern" | "baseline" | null | undefined;
|
|
env: Record<string, string | undefined>;
|
|
detectAvx2: () => boolean;
|
|
}
|
|
|
|
export interface SelectCpuVariantResult {
|
|
variant: "modern" | "baseline" | null;
|
|
source: "non-x64" | "override" | "cache" | "detect";
|
|
cacheEnvKey?: string;
|
|
cacheEnvValue?: string;
|
|
}
|
|
|
|
export function selectCpuVariant(input: SelectCpuVariantInput): SelectCpuVariantResult;
|
|
|
|
export interface ValidateLoadedBindingsContext {
|
|
isWorkspaceLoad: boolean;
|
|
packageVersion: string;
|
|
versionSentinelExport: string;
|
|
}
|
|
|
|
export function validateLoadedBindings(
|
|
ctx: ValidateLoadedBindingsContext,
|
|
bindings: Record<string, unknown>,
|
|
candidate: string,
|
|
): void;
|
|
|
|
export function loadNative(): Record<string, unknown>;
|