{
  "version": 3,
  "sources": ["../../../../src/packages/tarball-fetcher/index.ts"],
  "sourcesContent": ["import { PnpmError } from '../error/index.ts';\nimport type { FetchFunction, FetchOptions } from '../fetcher-base/index.ts';\nimport type { Cafs, PackageFiles } from '../cafs-types/index.ts';\nimport type {\n  FetchFromRegistry,\n  GetAuthHeader,\n  RetryTimeoutOptions,\n} from '../fetching-types/index.ts';\nimport { TarballIntegrityError, type AddFilesResult } from '../worker/index.ts';\nimport {\n  createDownloader,\n  type DownloadFunction,\n} from './remoteTarballFetcher.ts';\nimport { createLocalTarballFetcher } from './localTarballFetcher.ts';\nimport { createGitHostedTarballFetcher } from './gitHostedTarballFetcher.ts';\nimport type { DependencyManifest } from '../types/package.ts';\nimport type { Resolution } from '../resolver-base/index.ts';\n\nexport { BadTarballError } from './errorTypes/index.ts';\n\nexport { TarballIntegrityError };\n\nexport type TarballFetchers = {\n  localTarball: FetchFunction<Resolution, FetchOptions, AddFilesResult>;\n  remoteTarball: FetchFunction<Resolution, FetchOptions, AddFilesResult>;\n  gitHostedTarball: FetchFunction<\n    Resolution,\n    FetchOptions,\n    {\n      filesIndex: PackageFiles | Record<string, string>;\n      manifest: DependencyManifest | undefined;\n      requiresBuild: boolean;\n    }\n  >;\n};\n\nexport function createTarballFetcher(\n  fetchFromRegistry: FetchFromRegistry,\n  getAuthHeader: GetAuthHeader,\n  opts: {\n    rawConfig: Record<string, unknown>;\n    unsafePerm?: boolean | undefined;\n    ignoreScripts?: boolean | undefined;\n    timeout?: number | undefined;\n    retry?: RetryTimeoutOptions | undefined;\n    offline?: boolean | undefined;\n  }\n): TarballFetchers {\n  const download = createDownloader(fetchFromRegistry, {\n    retry: opts.retry,\n    timeout: opts.timeout,\n  });\n\n  const remoteTarballFetcher = fetchFromTarball.bind(null, {\n    download,\n    getAuthHeaderByURI: getAuthHeader,\n    offline: opts.offline ?? false,\n  });\n\n  return {\n    localTarball: createLocalTarballFetcher(),\n    remoteTarball: remoteTarballFetcher,\n    gitHostedTarball: createGitHostedTarballFetcher(remoteTarballFetcher, opts),\n  };\n}\n\nasync function fetchFromTarball(\n  ctx: {\n    download: DownloadFunction;\n    getAuthHeaderByURI: (registry: string) => string | undefined;\n    offline?: boolean | undefined;\n  },\n  cafs: Cafs,\n  resolution: {\n    integrity?: string | undefined;\n    registry?: string | undefined;\n    tarball?: string | undefined;\n  },\n  opts: FetchOptions\n): Promise<AddFilesResult> {\n  if (ctx.offline === true) {\n    throw new PnpmError(\n      'NO_OFFLINE_TARBALL',\n      `A package is missing from the store but cannot download it in offline mode. The missing package may be downloaded from ${resolution.tarball}.`\n    );\n  }\n\n  if (typeof resolution.tarball !== 'string' || resolution.tarball === '') {\n    throw new PnpmError('NO_TARBALL', 'No tarball found');\n  }\n\n  return ctx.download(resolution.tarball, {\n    getAuthHeaderByURI: ctx.getAuthHeaderByURI,\n    cafs,\n    integrity: resolution.integrity,\n    readManifest: opts.readManifest,\n    onProgress: opts.onProgress,\n    onStart: opts.onStart,\n    registry: resolution.registry,\n    filesIndexFile: opts.filesIndexFile,\n    pkg: opts.pkg,\n  });\n}\n"],
  "mappings": "AAAA,SAAS,iBAAiB;AAQ1B,SAAS,6BAAkD;AAC3D;AAAA,EACE;AAAA,OAEK;AACP,SAAS,iCAAiC;AAC1C,SAAS,qCAAqC;AAI9C,SAAS,uBAAuB;AAkBzB,SAAS,qBACd,mBACA,eACA,MAQiB;AACjB,QAAM,WAAW,iBAAiB,mBAAmB;AAAA,IACnD,OAAO,KAAK;AAAA,IACZ,SAAS,KAAK;AAAA,EAChB,CAAC;AAED,QAAM,uBAAuB,iBAAiB,KAAK,MAAM;AAAA,IACvD;AAAA,IACA,oBAAoB;AAAA,IACpB,SAAS,KAAK,WAAW;AAAA,EAC3B,CAAC;AAED,SAAO;AAAA,IACL,cAAc,0BAA0B;AAAA,IACxC,eAAe;AAAA,IACf,kBAAkB,8BAA8B,sBAAsB,IAAI;AAAA,EAC5E;AACF;AAEA,eAAe,iBACb,KAKA,MACA,YAKA,MACyB;AACzB,MAAI,IAAI,YAAY,MAAM;AACxB,UAAM,IAAI;AAAA,MACR;AAAA,MACA,0HAA0H,WAAW,OAAO;AAAA,IAC9I;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,YAAY,YAAY,WAAW,YAAY,IAAI;AACvE,UAAM,IAAI,UAAU,cAAc,kBAAkB;AAAA,EACtD;AAEA,SAAO,IAAI,SAAS,WAAW,SAAS;AAAA,IACtC,oBAAoB,IAAI;AAAA,IACxB;AAAA,IACA,WAAW,WAAW;AAAA,IACtB,cAAc,KAAK;AAAA,IACnB,YAAY,KAAK;AAAA,IACjB,SAAS,KAAK;AAAA,IACd,UAAU,WAAW;AAAA,IACrB,gBAAgB,KAAK;AAAA,IACrB,KAAK,KAAK;AAAA,EACZ,CAAC;AACH;",
  "names": []
}
