export type UpdateChannel = "stable" | "canary"; export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise; /** Build service origin used when `PI_BUILD_URL` is unset. */ export declare const DEFAULT_BUILD_URL = "https://build.stencil.so"; /** Build service origin: `PI_BUILD_URL` without trailing slashes, else {@link DEFAULT_BUILD_URL}. */ export declare function buildServiceUrl(): string; /** Where this host's builds live on the build service. */ export interface BuildHost { /** Build service target, e.g. `macos-arm64` or `linux-musl-x86_64`. */ target: string; /** Name of the target's file, the release asset name (e.g. `omp-darwin-arm64`). */ fileName: string; } /** The build service target and file name for a platform, architecture, and libc. */ export declare function resolveBuildHost(platform: NodeJS.Platform, arch: string, musl: boolean): BuildHost; /** * Detect a musl-libc Linux host (Alpine, Void-musl) so self-update replaces a * musl binary with the musl build instead of the glibc one, which would fail * to start on the next run. The loader file alone is not sufficient: glibc * hosts may have musl installed for cross-compilation. */ interface MuslDetectionOptions { platform: NodeJS.Platform; alpineRelease: boolean; lddOutput: string; } /** Test seam for libc detection. */ export declare function isMuslLinuxForTest(options: MuslDetectionOptions): boolean; /** This host's {@link BuildHost}, detected once per process. */ export declare function currentBuildHost(): Promise; /** The answered build's file for this host. */ export interface BuildFile { name: string; size: number; /** Lowercase hex SHA-256. */ sha256: string; } /** HDiffPatch single-stream patch (`HDIFFSF20`) from an installed file to {@link BuildFile}. */ export interface BuildPatch { /** Lowercase hex SHA-256 of the file the patch applies to. */ fromSha256: string; /** Version the check named as installed (`from_version`), for progress output. */ fromVersion?: string; size: number; /** Lowercase hex SHA-256 of the patch itself. */ sha256: string; /** Presigned HTTPS URL of the patch. */ url: string; } /** A checked build service answer. */ export interface BuildAnswer { version: string; file: BuildFile; /** Presigned HTTPS URL of the whole file, valid for minutes. */ download: string; patch?: BuildPatch; } /** * Check a build service answer for the file named `fileName`. * * Throws when the answer cannot be installed safely: a version that is not * semver, a file other than `fileName`, a size or SHA-256 that is not exact, * or a download that is not HTTPS. A `patch` is kept only when it is a * complete `format: "file"` patch; any other patch is dropped, not an error. * `fromVersion` is the `from_version` the check sent. */ export declare function parseBuildAnswer(body: unknown, fileName: string, fromVersion?: string): BuildAnswer; /** Which build to ask for: the newest on a channel, or one exact version. */ export type BuildSelector = { channel: UpdateChannel; } | { version: string; }; export interface FetchBuildOptions { /** Installed version to ask a patch from (`from_version`). */ fromVersion?: string; timeoutMs?: number; fetchImpl?: Fetch; /** Defaults to {@link currentBuildHost}. */ host?: BuildHost; } /** Ask the build service for a build of this host's target ({@link BuildSelector}). */ export declare function fetchBuild(selector: BuildSelector, options?: FetchBuildOptions): Promise; export {};