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C,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n  if (!/^[0-9]$/.test(level)) {\n    throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n  }\n}\n\ntype TarConfig = {\n  compression: CompressionLevel | null | undefined\n  format: string\n  outFile: string\n  dirToArchive: string\n  isMacApp: boolean\n  tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n  const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n  const tarArgs: TarOptionsWithAliasesAsync = {\n    file: tarFile,\n    portable: true,\n    cwd: dirToArchive,\n    prefix: path.basename(outFile, `.${format}`),\n  }\n  let tarDirectory = \".\"\n  if (isMacApp) {\n    delete tarArgs.prefix\n    tarArgs.cwd = path.dirname(dirToArchive)\n    tarDirectory = path.basename(dirToArchive)\n  }\n\n  await Promise.all([\n    create(tarArgs, [tarDirectory]),\n    // remove file before - 7z doesn't overwrite file, but update\n    unlinkIfExists(outFile),\n  ])\n\n  if (format === \"tar.lz\") {\n    const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n    await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n    // lzip creates the output file in the same directory as the input with a .lz suffix\n    await move(`${tarFile}.lz`, outFile)\n    return\n  }\n\n  const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n  const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n  args.push(outFile, tarFile)\n  await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n  compression?: CompressionLevel | null\n\n  /**\n   * @default false\n   */\n  withoutDir?: boolean\n\n  /**\n   * @default true\n   */\n  solid?: boolean\n\n  /**\n   * @default true\n   */\n  isArchiveHeaderCompressed?: boolean\n\n  dictSize?: number\n  excluded?: Array<string> | null\n\n  // DEFAULT allows to disable custom logic and do not pass method switch at all\n  method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n  isRegularFile?: boolean\n\n  /**\n   * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n   * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n   * @default false\n   */\n  preserveSymlinks?: boolean\n\n  /**\n   * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n   * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n   * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n   * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n   * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n   * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n   * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n   * @default false\n   */\n  installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n  return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n  if (excluded == null) {\n    return []\n  }\n  return excluded.map(mask => {\n    if (mask.includes(\"..\")) {\n      throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n    }\n    return `${prefix}${mask}`\n  })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n  let storeOnly = options.compression === \"store\"\n  const args = debug7zArgs(\"a\")\n\n  const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n  if (compressionLevel != null) {\n    validateCompressionLevel(compressionLevel)\n    storeOnly = false // env var overrides \"store\" config\n    args.push(`-mx=${compressionLevel}`)\n  } else if (storeOnly) {\n    // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n    // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n    args.push(\"-mx=0\")\n  } else {\n    const isZip = format === \"zip\"\n    // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n    args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n    if (isZip && options.compression === \"maximum\") {\n      // http://superuser.com/a/742034\n      args.push(\"-mfb=258\", \"-mpass=15\")\n    }\n  }\n\n  if (options.dictSize != null) {\n    args.push(`-md=${options.dictSize}m`)\n  }\n\n  // Disable NTFS timestamps for reproducible archives\n  if (!options.isRegularFile) {\n    args.push(\"-mtc=off\")\n  }\n\n  if (format === \"7z\" || format.endsWith(\".7z\")) {\n    if (options.solid === false) {\n      args.push(\"-ms=off\")\n    }\n\n    if (options.isArchiveHeaderCompressed === false) {\n      args.push(\"-mhc=off\")\n    }\n\n    // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n    // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n    // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n    // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n    // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n    // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n    if (options.installTimeDecodable) {\n      if (!storeOnly) {\n        args.push(\"-mf=BCJ\")\n      }\n    } else {\n      const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n      if (sevenZFilter) {\n        const canonicalFilter = sevenZFilter.toUpperCase()\n        if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n          throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n        }\n        args.push(`-mf=${canonicalFilter}`)\n      }\n    }\n\n    args.push(\"-mtm=off\", \"-mta=off\")\n  }\n\n  if (options.method != null && options.method !== \"DEFAULT\") {\n    args.push(`-mm=${options.method}`)\n  } else if (format === \"zip\") {\n    // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n    // For all other formats the codec is implicit from the output file extension.\n    args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n    args.push(\"-mcu\")\n  }\n\n  return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n  const outFileStat = await statOrNull(outFile)\n  const dirStat = await statOrNull(dirToArchive)\n  if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n    log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n    return outFile\n  }\n\n  // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n  // fallback for NFD-normalized filenames, which 7za mangles.\n  let use7z = true\n  if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n    log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n    use7z = false\n  }\n\n  if (use7z) {\n    const args = compute7zCompressArgs(format, options)\n    // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n    // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n    // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n    // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n    if (options.preserveSymlinks) {\n      args.push(\"-snl\")\n    }\n    await unlinkIfExists(outFile)\n    args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n    args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n\n    try {\n      await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n    } catch (e: any) {\n      if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n        throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n      } else {\n        throw e\n      }\n    }\n  } else {\n    // macOS native zip (NFD fallback): -y preserves symlinks\n    const args = [\"-q\", \"-r\", \"-y\"]\n    if (debug7z.enabled) {\n      args.push(\"-v\")\n    }\n    if (options.compression === \"store\") {\n      args.push(\"-0\")\n    } else {\n      args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n    }\n    await unlinkIfExists(outFile)\n    args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n    args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n    await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n  }\n\n  return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n  const args = [command, \"-bd\"]\n  if (debug7z.enabled) {\n    args.push(\"-bb\")\n  }\n  return args\n}\n"]}