From 399e2226ca1b2abce2d273706848df2db304efd2 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:00:26 +0800 Subject: [PATCH] refactor(resources): remove redundant helper exports and lease aliases Keep ASAR header details and the Godot header parser module-local. Use the canonical lease types in Hopper consumers, including release-cache publication, while preserving acquisition and cleanup behavior. --- src/application/LinuxHopperPublisher.ts | 8 +++----- src/artifacts/AsarHeader.ts | 4 ++-- src/artifacts/GodotPckArtifactReader.ts | 2 +- src/hopper/BridgeLauncher.ts | 6 +++--- src/process/HopperLease.ts | 13 ++++--------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/application/LinuxHopperPublisher.ts b/src/application/LinuxHopperPublisher.ts index 7b6eb5573a..5fb01f5679 100644 --- a/src/application/LinuxHopperPublisher.ts +++ b/src/application/LinuxHopperPublisher.ts @@ -29,10 +29,8 @@ import { verifyDetachedPgpSignature } from "../process/DetachedPgpSignature.js"; import { execFileOutput } from "../process/ExecFileOutput.js"; import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js"; import { waitForAbortableDelay } from "../process/ProviderDeadline.js"; -import { - acquireHopperReleaseCacheLease, - type HopperTargetLease, -} from "../process/HopperLease.js"; +import { acquireHopperReleaseCacheLease } from "../process/HopperLease.js"; +import type { OwnedLease } from "../process/OwnedLease.js"; import { downloadHopperPackage, HOPPER_DOWNLOAD_BYTES, @@ -412,7 +410,7 @@ export class LinuxHopperPublisher { async #acquireCacheLease( digest: string, signal?: AbortSignal, - ): Promise { + ): Promise { const deadline = performance.now() + 120_000; const runId = randomUUID(); let delay = 25; diff --git a/src/artifacts/AsarHeader.ts b/src/artifacts/AsarHeader.ts index c1fa9635b5..bba53a3319 100644 --- a/src/artifacts/AsarHeader.ts +++ b/src/artifacts/AsarHeader.ts @@ -59,7 +59,7 @@ export const asarHeaderAdmissionFailure = ( }); /** Absolute archive prefix required to inspect a header under this admission. */ -export const asarHeaderProbeBytes = (admission: AsarHeaderAdmission): number => +const asarHeaderProbeBytes = (admission: AsarHeaderAdmission): number => admission.maximumBytes + 8; export interface AsarHeaderExtents { @@ -113,7 +113,7 @@ export type FinalAsarHeaderProbeObservation = Exclude< * observed archive size. This establishes byte extents only; JSON validity and * the ASAR header schema belong to the decoder at the interpretation boundary. */ -export const parseAsarHeaderExtents = ( +const parseAsarHeaderExtents = ( prefix: Uint8Array, archiveBytes?: number, ): Result, ArtifactReaderFailure> => { diff --git a/src/artifacts/GodotPckArtifactReader.ts b/src/artifacts/GodotPckArtifactReader.ts index 70c7ad7da1..962241e0eb 100644 --- a/src/artifacts/GodotPckArtifactReader.ts +++ b/src/artifacts/GodotPckArtifactReader.ts @@ -384,7 +384,7 @@ export class GodotPckArtifactReader implements ArtifactReader { } /** Decode header fields once; unsupported content does not erase observed headers. */ -export const readGodotPckHeader = async ( +const readGodotPckHeader = async ( handle: FileHandle, size: number, signal?: AbortSignal, diff --git a/src/hopper/BridgeLauncher.ts b/src/hopper/BridgeLauncher.ts index b988a483d9..9f0afb780b 100644 --- a/src/hopper/BridgeLauncher.ts +++ b/src/hopper/BridgeLauncher.ts @@ -49,7 +49,7 @@ import { acquireHopperTargetLease, acquireLinuxHopperApplicationLease, } from "../process/HopperLease.js"; -import type { HopperTargetLease } from "../process/HopperLease.js"; +import type { OwnedLease } from "../process/OwnedLease.js"; import { MAXIMUM_BRIDGE_MAX_REQUEST_BYTES, MINIMUM_BRIDGE_MAX_REQUEST_BYTES, @@ -367,7 +367,7 @@ export class HopperApplicationLauncher implements BridgeLauncher { readonly bootstrapPath: string; readonly loadedPath: string; readonly ownsProcessLifetime: boolean; - readonly lease: HopperTargetLease | undefined; + readonly lease: OwnedLease | undefined; }): Promise< Result< BridgeLaunch, @@ -497,7 +497,7 @@ export class HopperApplicationLauncher implements BridgeLauncher { async #acquireLaunchLease( runId: string, - ): Promise> { + ): Promise> { const platform = this.dependencies.platform ?? process.platform; const applicationLease = platform === "linux" && usesLinuxDemo(this.options); diff --git a/src/process/HopperLease.ts b/src/process/HopperLease.ts index dd4bd6741a..382acd3e25 100644 --- a/src/process/HopperLease.ts +++ b/src/process/HopperLease.ts @@ -5,13 +5,8 @@ import { acquireOwnedLease, type LeaseAcquisition, type LeaseFailure, - type OwnedLease, } from "./OwnedLease.js"; -export type HopperTargetLease = OwnedLease; - -export type HopperTargetLeaseAcquisition = LeaseAcquisition; - /** Shared private parent of Hopper lease sockets; it outlives individual sessions. */ export const HOPPER_TARGET_LEASE_DIRECTORY = join( "/tmp", @@ -25,7 +20,7 @@ export const acquireHopperTargetLease = async (input: { readonly loaderArgs: readonly string[]; readonly runId: string; readonly directory?: string; -}): Promise => { +}): Promise => { // Canonicalization is required for lease identity. A lexical fallback could // let two aliases reserve independent sockets for the same Hopper document. let targetPath: string; @@ -51,7 +46,7 @@ export const acquireHopperTargetLease = async (input: { export const acquireLinuxHopperApplicationLease = (input: { readonly runId: string; readonly directory?: string; -}): Promise => +}): Promise => acquireLease({ ...input, identity: { application: "linux-hopper-demo" } }); /** Serialize approved publication/repair of one canonical signed-package entry. */ @@ -59,7 +54,7 @@ export const acquireHopperReleaseCacheLease = async (input: { readonly cacheDirectory: string; readonly launcherSha256: string; readonly runId: string; -}): Promise => +}): Promise => acquireLease({ runId: input.runId, identity: { @@ -73,7 +68,7 @@ const acquireLease = async (input: { readonly identity: Readonly>; readonly runId: string; readonly directory?: string; -}): Promise => +}): Promise => acquireOwnedLease({ identity: input.identity, runId: input.runId,