app-builder-lib 26.16.0 → 26.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/out/codeSign/macCodeSign.js +5 -3
  2. package/out/codeSign/macCodeSign.js.map +1 -1
  3. package/out/codeSign/windowsCodeSign.js +0 -3
  4. package/out/codeSign/windowsCodeSign.js.map +1 -1
  5. package/out/codeSign/windowsSignToolManager.js +4 -1
  6. package/out/codeSign/windowsSignToolManager.js.map +1 -1
  7. package/out/electron/ElectronFramework.d.ts +2 -1
  8. package/out/electron/ElectronFramework.js +13 -5
  9. package/out/electron/ElectronFramework.js.map +1 -1
  10. package/out/electron/electronMac.js +1 -5
  11. package/out/electron/electronMac.js.map +1 -1
  12. package/out/node-module-collector/index.js +48 -15
  13. package/out/node-module-collector/index.js.map +1 -1
  14. package/out/node-module-collector/moduleManager.d.ts +7 -1
  15. package/out/node-module-collector/moduleManager.js +2 -2
  16. package/out/node-module-collector/moduleManager.js.map +1 -1
  17. package/out/node-module-collector/nodeModulesCollector.d.ts +7 -3
  18. package/out/node-module-collector/nodeModulesCollector.js +26 -8
  19. package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
  20. package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +42 -0
  21. package/out/node-module-collector/pnpmNodeModulesCollector.js +146 -0
  22. package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  23. package/out/packager.d.ts +2 -0
  24. package/out/packager.js +15 -0
  25. package/out/packager.js.map +1 -1
  26. package/out/platformPackager.d.ts +1 -0
  27. package/out/platformPackager.js +3 -0
  28. package/out/platformPackager.js.map +1 -1
  29. package/out/targets/FlatpakTarget.js +6 -1
  30. package/out/targets/FlatpakTarget.js.map +1 -1
  31. package/out/targets/archive.d.ts +12 -0
  32. package/out/targets/archive.js +45 -1
  33. package/out/targets/archive.js.map +1 -1
  34. package/out/targets/nsis/NsisTarget.d.ts +2 -2
  35. package/out/targets/nsis/NsisTarget.js +13 -1
  36. package/out/targets/nsis/NsisTarget.js.map +1 -1
  37. package/out/targets/nsis/nsisOptions.d.ts +15 -2
  38. package/out/targets/nsis/nsisOptions.js.map +1 -1
  39. package/out/targets/nsis/nsisUtil.d.ts +5 -2
  40. package/out/targets/nsis/nsisUtil.js +48 -24
  41. package/out/targets/nsis/nsisUtil.js.map +1 -1
  42. package/out/targets/pkg.d.ts +16 -0
  43. package/out/targets/pkg.js +27 -0
  44. package/out/targets/pkg.js.map +1 -1
  45. package/out/util/appFileCopier.d.ts +5 -0
  46. package/out/util/appFileCopier.js +19 -1
  47. package/out/util/appFileCopier.js.map +1 -1
  48. package/out/version.d.ts +1 -1
  49. package/out/version.js +1 -1
  50. package/out/version.js.map +1 -1
  51. package/package.json +7 -7
  52. package/scheme.json +16 -4
@@ -1 +1 @@
1
- {"version":3,"file":"FlatpakTarget.js","sourceRoot":"","sources":["../../src/targets/FlatpakTarget.ts"],"names":[],"mappings":";;AAAA,6DAA8G;AAC9G,+CAAgE;AAChE,uCAA4C;AAC5C,6BAA4B;AAC5B,kCAAgC;AAGhC,6CAA4D;AAE5D,6CAAuD;AACvD,+DAA0D;AAE1D,MAAqB,aAAc,SAAQ,aAAM;IAG/C,YACE,IAAY,EACK,QAAuB,EAChC,MAAyB,EACxB,MAAc;QAEvB,KAAK,CAAC,IAAI,CAAC,CAAA;QAJM,aAAQ,GAAR,QAAQ,CAAe;QAChC,WAAM,GAAN,MAAM,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAQ;QANhB,YAAO,GAAmB,IAAA,iCAAU,EAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAAG,IAAI,CAAC,QAAQ,CAAC,MAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IASvI,CAAC;IAED,IAAI,KAAK;QACP,OAAO,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC7D,CAA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,cAAc,KAAK,yBAAyB;CAC5D,CAAA;AACD,CAAC;AAED,SAAS,0BAA0B,CAAC,UAAkB;IACpD,sGAAsG;IACtG,6FAA6F;IAC7F,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { bundle as bundleFlatpak, FlatpakBundlerBuildOptions, FlatpakManifest } from \"@malept/flatpak-bundler\"\nimport { Arch, copyFile, toLinuxArchString } from \"builder-util\"\nimport { chmod, outputFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { FlatpakOptions } from \"../options/linuxOptions\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDir, StageDir } from \"./targetUtil\"\nimport { deepAssign, Nullish } from \"builder-util-runtime\"\n\nexport default class FlatpakTarget extends Target {\n readonly options: FlatpakOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, (this.packager.config as any)[this.name])\n\n constructor(\n name: string,\n private readonly packager: LinuxPackager,\n private helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(name)\n }\n\n get appId(): string {\n return filterFlatpakAppIdentifier(this.packager.appInfo.id)\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const { packager, options } = this\n const artifactName = packager.expandArtifactNamePattern(options, \"flatpak\", arch, undefined, false)\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"flatpak\",\n file: artifactPath,\n arch,\n })\n\n const stageDir = await this.prepareStageDir(arch)\n\n const { manifest, buildOptions } = this.getFlatpakBuilderOptions(appOutDir, stageDir.dir, artifactName, arch)\n await bundleFlatpak(manifest, buildOptions)\n\n await stageDir.cleanup()\n\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"flatpak\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: false,\n })\n }\n\n private async prepareStageDir(arch: Arch): Promise<StageDir> {\n const stageDir = await createStageDir(this, this.packager, arch)\n\n await Promise.all([this.createSandboxBinWrapper(stageDir), this.createDesktopFile(stageDir), this.copyLicenseFile(stageDir), this.copyIcons(stageDir)])\n\n return stageDir\n }\n\n private async createSandboxBinWrapper(stageDir: StageDir) {\n const useWaylandFlags = !!this.options.useWaylandFlags\n const electronWrapperPath = stageDir.getTempFile(path.join(\"bin\", \"electron-wrapper\"))\n await outputFile(electronWrapperPath, getElectronWrapperScript(this.packager.executableName, this.options.executableArgs, useWaylandFlags))\n await chmod(electronWrapperPath, 0o755)\n }\n\n private async createDesktopFile(stageDir: StageDir) {\n const appIdentifier = this.appId\n const desktopFile = stageDir.getTempFile(path.join(\"share\", \"applications\", `${appIdentifier}.desktop`))\n await this.helper.writeDesktopEntry(this.options, \"electron-wrapper %U\", desktopFile, { Icon: appIdentifier })\n }\n\n private async copyLicenseFile(stageDir: StageDir) {\n const licenseSrc = await getNotLocalizedLicenseFile(this.options.license, this.packager, [\"txt\", \"html\"])\n if (licenseSrc) {\n const licenseDst = stageDir.getTempFile(path.join(\"share\", \"doc\", this.appId, \"copyright\"))\n await copyFile(licenseSrc, licenseDst)\n }\n }\n\n private async copyIcons(stageDir: StageDir) {\n const icons = await this.helper.icons\n const copyIcons = icons.map(async icon => {\n if (icon.size > 512) {\n // Flatpak does not allow icons larger than 512 pixels\n return Promise.resolve()\n }\n const extWithDot = path.extname(icon.file)\n const sizeName = extWithDot === \".svg\" ? \"scalable\" : `${icon.size}x${icon.size}`\n const iconDst = stageDir.getTempFile(path.join(\"share\", \"icons\", \"hicolor\", sizeName, \"apps\", `${this.appId}${extWithDot}`))\n\n return copyFile(icon.file, iconDst)\n })\n\n await Promise.all(copyIcons)\n }\n\n private getFlatpakBuilderOptions(appOutDir: string, stageDir: string, artifactName: string, arch: Arch): { manifest: FlatpakManifest; buildOptions: FlatpakBundlerBuildOptions } {\n const appIdentifier = this.appId\n const { executableName } = this.packager\n const flatpakArch = toLinuxArchString(arch, \"flatpak\")\n\n const manifest: FlatpakManifest = {\n id: appIdentifier,\n command: \"electron-wrapper\",\n runtime: this.options.runtime || flatpakBuilderDefaults.runtime,\n runtimeVersion: this.options.runtimeVersion || flatpakBuilderDefaults.runtimeVersion,\n sdk: this.options.sdk || flatpakBuilderDefaults.sdk,\n base: this.options.base || flatpakBuilderDefaults.base,\n baseVersion: this.options.baseVersion || flatpakBuilderDefaults.baseVersion,\n finishArgs: this.options.finishArgs || flatpakBuilderDefaults.finishArgs,\n branch: this.options.branch,\n modules: this.options.modules,\n }\n\n const buildOptions: FlatpakBundlerBuildOptions = {\n baseFlatpakref: `app/${manifest.base}/${flatpakArch}/${manifest.baseVersion}`,\n runtimeFlatpakref: `runtime/${manifest.runtime}/${flatpakArch}/${manifest.runtimeVersion}`,\n sdkFlatpakref: `runtime/${manifest.sdk}/${flatpakArch}/${manifest.runtimeVersion}`,\n arch: flatpakArch as any,\n bundlePath: path.join(this.outDir, artifactName),\n files: [[stageDir, \"/\"], [appOutDir, path.join(\"/lib\", appIdentifier)], ...(this.options.files || [])],\n symlinks: [[path.join(\"/lib\", appIdentifier, executableName), path.join(\"/bin\", executableName)], ...(this.options.symlinks || [])],\n }\n\n return { manifest, buildOptions }\n }\n}\n\nconst flatpakBuilderDefaults: Omit<FlatpakManifest, \"id\" | \"command\"> = {\n runtime: \"org.freedesktop.Platform\",\n runtimeVersion: \"20.08\",\n sdk: \"org.freedesktop.Sdk\",\n base: \"org.electronjs.Electron2.BaseApp\",\n baseVersion: \"20.08\",\n finishArgs: [\n // Wayland/X11 Rendering\n \"--socket=wayland\",\n \"--socket=x11\",\n \"--share=ipc\",\n // Open GL\n \"--device=dri\",\n // Audio output\n \"--socket=pulseaudio\",\n // Read/write home directory access\n \"--filesystem=home\",\n // Allow communication with network\n \"--share=network\",\n // System notifications with libnotify\n \"--talk-name=org.freedesktop.Notifications\",\n ],\n}\n\nfunction getElectronWrapperScript(executableName: string, executableArgs: string[] | Nullish, useWaylandFlags: boolean): string {\n const stringifiedExecutableArgs = executableArgs?.join(\" \") || \"\"\n if (useWaylandFlags) {\n return `#!/bin/sh\n\nexport TMPDIR=\"$XDG_RUNTIME_DIR/app/$FLATPAK_ID\"\n\nif [ \"\\${XDG_SESSION_TYPE}\" == \"wayland\" ]; then\n zypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} --enable-features=UseOzonePlatform --ozone-platform=wayland \"$@\"\nelse\n zypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} \"$@\"\nfi\n`\n }\n return `#!/bin/sh\n\nexport TMPDIR=\"$XDG_RUNTIME_DIR/app/$FLATPAK_ID\"\n\nzypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} \"$@\"\n`\n}\n\nfunction filterFlatpakAppIdentifier(identifier: string) {\n // Remove special characters and allow only alphanumeric (A-Z,a-z,0-9), underscore (_), and period (.)\n // Flatpak documentation: https://docs.flatpak.org/en/latest/conventions.html#application-ids\n return identifier.replace(/-/g, \"_\").replace(/[^a-zA-Z0-9._]/g, \"\")\n}\n"]}
1
+ {"version":3,"file":"FlatpakTarget.js","sourceRoot":"","sources":["../../src/targets/FlatpakTarget.ts"],"names":[],"mappings":";;AAAA,6DAA8G;AAC9G,+CAAgE;AAChE,uCAA4C;AAC5C,6BAA4B;AAC5B,kCAAgC;AAGhC,6CAA4D;AAE5D,6CAAuD;AACvD,+DAA0D;AAE1D,MAAqB,aAAc,SAAQ,aAAM;IAG/C,YACE,IAAY,EACK,QAAuB,EAChC,MAAyB,EACxB,MAAc;QAEvB,KAAK,CAAC,IAAI,CAAC,CAAA;QAJM,aAAQ,GAAR,QAAQ,CAAe;QAChC,WAAM,GAAN,MAAM,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAQ;QANhB,YAAO,GAAmB,IAAA,iCAAU,EAAC,E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QACtC,2CAA2C;KAC5C;CACF,CAAA;AAED,SAAS,wBAAwB,CAAC,cAAsB,EAAE,cAAkC,EAAE,eAAwB;IACpH,MAAM,yBAAyB,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,GAAG,CAAC,KAAI,EAAE,CAAA;IACjE,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO;;;;;qBAKU,cAAc,KAAK,yBAAyB;;qBAE5C,cAAc,KAAK,yBAAyB;;CAEhE,CAAA;IACC,CAAC;IACD,OAAO;;;;iBAIQ,cAAc,KAAK,yBAAyB;CAC5D,CAAA;AACD,CAAC;AAED,SAAS,0BAA0B,CAAC,UAAkB;IACpD,sGAAsG;IACtG,6FAA6F;IAC7F,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { bundle as bundleFlatpak, FlatpakBundlerBuildOptions, FlatpakManifest } from \"@malept/flatpak-bundler\"\nimport { Arch, copyFile, toLinuxArchString } from \"builder-util\"\nimport { chmod, outputFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { FlatpakOptions } from \"../options/linuxOptions\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDir, StageDir } from \"./targetUtil\"\nimport { deepAssign, Nullish } from \"builder-util-runtime\"\n\nexport default class FlatpakTarget extends Target {\n readonly options: FlatpakOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, (this.packager.config as any)[this.name])\n\n constructor(\n name: string,\n private readonly packager: LinuxPackager,\n private helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(name)\n }\n\n get appId(): string {\n return filterFlatpakAppIdentifier(this.packager.appInfo.id)\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const { packager, options } = this\n const artifactName = packager.expandArtifactNamePattern(options, \"flatpak\", arch, undefined, false)\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"flatpak\",\n file: artifactPath,\n arch,\n })\n\n const stageDir = await this.prepareStageDir(arch)\n\n const { manifest, buildOptions } = this.getFlatpakBuilderOptions(appOutDir, stageDir.dir, artifactName, arch)\n await bundleFlatpak(manifest, buildOptions)\n\n await stageDir.cleanup()\n\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"flatpak\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: false,\n })\n }\n\n private async prepareStageDir(arch: Arch): Promise<StageDir> {\n const stageDir = await createStageDir(this, this.packager, arch)\n\n await Promise.all([this.createSandboxBinWrapper(stageDir), this.createDesktopFile(stageDir), this.copyLicenseFile(stageDir), this.copyIcons(stageDir)])\n\n return stageDir\n }\n\n private async createSandboxBinWrapper(stageDir: StageDir) {\n const useWaylandFlags = !!this.options.useWaylandFlags\n const electronWrapperPath = stageDir.getTempFile(path.join(\"bin\", \"electron-wrapper\"))\n await outputFile(electronWrapperPath, getElectronWrapperScript(this.packager.executableName, this.options.executableArgs, useWaylandFlags))\n await chmod(electronWrapperPath, 0o755)\n }\n\n private async createDesktopFile(stageDir: StageDir) {\n const appIdentifier = this.appId\n const desktopFile = stageDir.getTempFile(path.join(\"share\", \"applications\", `${appIdentifier}.desktop`))\n await this.helper.writeDesktopEntry(this.options, \"electron-wrapper %U\", desktopFile, { Icon: appIdentifier })\n }\n\n private async copyLicenseFile(stageDir: StageDir) {\n const licenseSrc = await getNotLocalizedLicenseFile(this.options.license, this.packager, [\"txt\", \"html\"])\n if (licenseSrc) {\n const licenseDst = stageDir.getTempFile(path.join(\"share\", \"doc\", this.appId, \"copyright\"))\n await copyFile(licenseSrc, licenseDst)\n }\n }\n\n private async copyIcons(stageDir: StageDir) {\n const icons = await this.helper.icons\n const copyIcons = icons.map(async icon => {\n if (icon.size > 512) {\n // Flatpak does not allow icons larger than 512 pixels\n return Promise.resolve()\n }\n const extWithDot = path.extname(icon.file)\n const sizeName = extWithDot === \".svg\" ? \"scalable\" : `${icon.size}x${icon.size}`\n const iconDst = stageDir.getTempFile(path.join(\"share\", \"icons\", \"hicolor\", sizeName, \"apps\", `${this.appId}${extWithDot}`))\n\n return copyFile(icon.file, iconDst)\n })\n\n await Promise.all(copyIcons)\n }\n\n private getFlatpakBuilderOptions(appOutDir: string, stageDir: string, artifactName: string, arch: Arch): { manifest: FlatpakManifest; buildOptions: FlatpakBundlerBuildOptions } {\n const appIdentifier = this.appId\n const { executableName } = this.packager\n const flatpakArch = toLinuxArchString(arch, \"flatpak\")\n\n const manifest: FlatpakManifest = {\n id: appIdentifier,\n command: \"electron-wrapper\",\n runtime: this.options.runtime || flatpakBuilderDefaults.runtime,\n runtimeVersion: this.options.runtimeVersion || flatpakBuilderDefaults.runtimeVersion,\n sdk: this.options.sdk || flatpakBuilderDefaults.sdk,\n base: this.options.base || flatpakBuilderDefaults.base,\n baseVersion: this.options.baseVersion || flatpakBuilderDefaults.baseVersion,\n finishArgs: this.options.finishArgs || flatpakBuilderDefaults.finishArgs,\n branch: this.options.branch,\n modules: this.options.modules,\n }\n\n // `this.options` is `linux` deep-merged with `flatpak`, and deepAssign concatenates arrays, so the\n // shared `linux.files` globs (string | FileSet | array of either) would leak into this [src, dest] tuple\n // list. Read the flatpak-specific list from the raw config instead of the merged options.\n const extraFiles = this.packager.config.flatpak?.files ?? []\n\n const buildOptions: FlatpakBundlerBuildOptions = {\n baseFlatpakref: `app/${manifest.base}/${flatpakArch}/${manifest.baseVersion}`,\n runtimeFlatpakref: `runtime/${manifest.runtime}/${flatpakArch}/${manifest.runtimeVersion}`,\n sdkFlatpakref: `runtime/${manifest.sdk}/${flatpakArch}/${manifest.runtimeVersion}`,\n arch: flatpakArch as any,\n bundlePath: path.join(this.outDir, artifactName),\n files: [[stageDir, \"/\"], [appOutDir, path.join(\"/lib\", appIdentifier)], ...extraFiles],\n symlinks: [[path.join(\"/lib\", appIdentifier, executableName), path.join(\"/bin\", executableName)], ...(this.options.symlinks || [])],\n }\n\n return { manifest, buildOptions }\n }\n}\n\nconst flatpakBuilderDefaults: Omit<FlatpakManifest, \"id\" | \"command\"> = {\n runtime: \"org.freedesktop.Platform\",\n runtimeVersion: \"20.08\",\n sdk: \"org.freedesktop.Sdk\",\n base: \"org.electronjs.Electron2.BaseApp\",\n baseVersion: \"20.08\",\n finishArgs: [\n // Wayland/X11 Rendering\n \"--socket=wayland\",\n \"--socket=x11\",\n \"--share=ipc\",\n // Open GL\n \"--device=dri\",\n // Audio output\n \"--socket=pulseaudio\",\n // Read/write home directory access\n \"--filesystem=home\",\n // Allow communication with network\n \"--share=network\",\n // System notifications with libnotify\n \"--talk-name=org.freedesktop.Notifications\",\n ],\n}\n\nfunction getElectronWrapperScript(executableName: string, executableArgs: string[] | Nullish, useWaylandFlags: boolean): string {\n const stringifiedExecutableArgs = executableArgs?.join(\" \") || \"\"\n if (useWaylandFlags) {\n return `#!/bin/sh\n\nexport TMPDIR=\"$XDG_RUNTIME_DIR/app/$FLATPAK_ID\"\n\nif [ \"\\${XDG_SESSION_TYPE}\" == \"wayland\" ]; then\n zypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} --enable-features=UseOzonePlatform --ozone-platform=wayland \"$@\"\nelse\n zypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} \"$@\"\nfi\n`\n }\n return `#!/bin/sh\n\nexport TMPDIR=\"$XDG_RUNTIME_DIR/app/$FLATPAK_ID\"\n\nzypak-wrapper \"${executableName}\" ${stringifiedExecutableArgs} \"$@\"\n`\n}\n\nfunction filterFlatpakAppIdentifier(identifier: string) {\n // Remove special characters and allow only alphanumeric (A-Z,a-z,0-9), underscore (_), and period (.)\n // Flatpak documentation: https://docs.flatpak.org/en/latest/conventions.html#application-ids\n return identifier.replace(/-/g, \"_\").replace(/[^a-zA-Z0-9._]/g, \"\")\n}\n"]}
@@ -23,6 +23,18 @@ export interface ArchiveOptions {
23
23
  * @default false
24
24
  */
25
25
  preserveSymlinks?: boolean;
26
+ /**
27
+ * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of
28
+ * compressing them with the rest of the archive. Differential updates diff the *compressed* archive
29
+ * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from
30
+ * its previous version on any change — storing it keeps unchanged regions byte-identical between
31
+ * builds, so the delta stays proportional to what actually changed. The stored members are excluded
32
+ * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the
33
+ * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability
34
+ * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the
35
+ * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.
36
+ */
37
+ storedPaths?: Array<string> | null;
26
38
  /**
27
39
  * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can
28
40
  * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at
@@ -150,6 +150,7 @@ function compute7zCompressArgs(format, options = {}) {
150
150
  // 7z is very fast, so, use ultra compression
151
151
  /** @internal */
152
152
  async function archive(format, outFile, dirToArchive, options = {}) {
153
+ var _a;
153
154
  const outFileStat = await (0, builder_util_1.statOrNull)(outFile);
154
155
  const dirStat = await (0, builder_util_1.statOrNull)(dirToArchive);
155
156
  if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {
@@ -163,6 +164,21 @@ async function archive(format, outFile, dirToArchive, options = {}) {
163
164
  builder_util_1.log.warn({ reason: "7z doesn't support NFD-normalized filenames" }, `using zip`);
164
165
  use7z = false;
165
166
  }
167
+ // Resolve storedPaths before the main pass so they can be excluded from it. Member names are
168
+ // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string
169
+ // works as both the exact `-x!` exclude mask and the append argument.
170
+ const storedMembers = [];
171
+ for (const storedPath of (_a = options.storedPaths) !== null && _a !== void 0 ? _a : []) {
172
+ if (storedPath.includes("..")) {
173
+ throw new Error(`Stored archive path contains path traversal sequence: "${storedPath}"`);
174
+ }
175
+ if (await (0, builder_util_1.exists)(path.join(dirToArchive, storedPath))) {
176
+ storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)));
177
+ }
178
+ }
179
+ if (storedMembers.length > 0 && !use7z) {
180
+ throw new Error("storedPaths is not supported with the native zip fallback");
181
+ }
166
182
  if (use7z) {
167
183
  const args = compute7zCompressArgs(format, options);
168
184
  // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before
@@ -175,8 +191,11 @@ async function archive(format, outFile, dirToArchive, options = {}) {
175
191
  await (0, builder_util_1.unlinkIfExists)(outFile);
176
192
  args.push(outFile, options.withoutDir ? "." : path.basename(dirToArchive));
177
193
  args.push(...buildExcludeArgs(options.excluded, "-xr!"));
194
+ // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling
195
+ args.push(...storedMembers.map(member => `-x!${member}`));
196
+ const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive);
178
197
  try {
179
- await (0, builder_util_1.exec)(await (0, _7zip_1.getPath7za)(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, builder_util_1.debug7z.enabled);
198
+ await (0, builder_util_1.exec)(await (0, _7zip_1.getPath7za)(), args, { cwd }, builder_util_1.debug7z.enabled);
180
199
  }
181
200
  catch (e) {
182
201
  if (e.code === "ENOENT" && !(await (0, builder_util_1.exists)(dirToArchive))) {
@@ -186,6 +205,31 @@ async function archive(format, outFile, dirToArchive, options = {}) {
186
205
  throw e;
187
206
  }
188
207
  }
208
+ if (storedMembers.length > 0) {
209
+ // Second pass: append the stored members with no compression. -mx=0 unconditionally — the
210
+ // compression-level env override must not reach these members (see storedPaths docs). The
211
+ // main pass's symlink, timestamp, and header-compression flags are mirrored so the option
212
+ // stays generic: the append rewrites the archive header and may itself store a symlink.
213
+ const appendArgs = debug7zArgs("a");
214
+ appendArgs.push("-mx=0");
215
+ if (options.preserveSymlinks) {
216
+ appendArgs.push("-snl");
217
+ }
218
+ if (!options.isRegularFile) {
219
+ appendArgs.push("-mtc=off");
220
+ }
221
+ if (format === "7z" || format.endsWith(".7z")) {
222
+ if (options.isArchiveHeaderCompressed === false) {
223
+ appendArgs.push("-mhc=off");
224
+ }
225
+ appendArgs.push("-mtm=off", "-mta=off");
226
+ }
227
+ else if (format === "zip") {
228
+ appendArgs.push("-mm=Copy", "-mcu");
229
+ }
230
+ appendArgs.push(outFile, ...storedMembers);
231
+ await (0, builder_util_1.exec)(await (0, _7zip_1.getPath7za)(), appendArgs, { cwd }, builder_util_1.debug7z.enabled);
232
+ }
189
233
  }
190
234
  else {
191
235
  // macOS native zip (NFD fallback): -y preserves symlinks
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AAsDD,wDAEC;AAkBD,sDA2EC;AAID,0BAwDC;AAjRD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1G,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wEAAwE,KAAK,GAAG,CAAC,CAAA;IACnG,CAAC;AACH,CAAC;AAWD,gBAAgB;AACT,KAAK,UAAU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AAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,IAAA,6BAAc,EAAC,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACtD,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,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"]}
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AAmED,wDAEC;AAkBD,sDA2EC;AAID,0BAoGC;AA1UD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK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,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACtD,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,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 * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of\n * compressing them with the rest of the archive. Differential updates diff the *compressed* archive\n * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from\n * its previous version on any change — storing it keeps unchanged regions byte-identical between\n * builds, so the delta stays proportional to what actually changed. The stored members are excluded\n * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the\n * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability\n * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the\n * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.\n */\n storedPaths?: Array<string> | null\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 // Resolve storedPaths before the main pass so they can be excluded from it. Member names are\n // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string\n // works as both the exact `-x!` exclude mask and the append argument.\n const storedMembers: Array<string> = []\n for (const storedPath of options.storedPaths ?? []) {\n if (storedPath.includes(\"..\")) {\n throw new Error(`Stored archive path contains path traversal sequence: \"${storedPath}\"`)\n }\n if (await exists(path.join(dirToArchive, storedPath))) {\n storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)))\n }\n }\n if (storedMembers.length > 0 && !use7z) {\n throw new Error(\"storedPaths is not supported with the native zip fallback\")\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 // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling\n args.push(...storedMembers.map(member => `-x!${member}`))\n\n const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive)\n try {\n await exec(await getPath7za(), args, { cwd }, 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\n if (storedMembers.length > 0) {\n // Second pass: append the stored members with no compression. -mx=0 unconditionally — the\n // compression-level env override must not reach these members (see storedPaths docs). The\n // main pass's symlink, timestamp, and header-compression flags are mirrored so the option\n // stays generic: the append rewrites the archive header and may itself store a symlink.\n const appendArgs = debug7zArgs(\"a\")\n appendArgs.push(\"-mx=0\")\n if (options.preserveSymlinks) {\n appendArgs.push(\"-snl\")\n }\n if (!options.isRegularFile) {\n appendArgs.push(\"-mtc=off\")\n }\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.isArchiveHeaderCompressed === false) {\n appendArgs.push(\"-mhc=off\")\n }\n appendArgs.push(\"-mtm=off\", \"-mta=off\")\n } else if (format === \"zip\") {\n appendArgs.push(\"-mm=Copy\", \"-mcu\")\n }\n appendArgs.push(outFile, ...storedMembers)\n await exec(await getPath7za(), appendArgs, { cwd }, debug7z.enabled)\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"]}
@@ -4,7 +4,7 @@ import { Target } from "../../core";
4
4
  import { WinPackager } from "../../winPackager";
5
5
  import { Defines } from "./Defines";
6
6
  import { NsisOptions } from "./nsisOptions";
7
- import { AppPackageHelper } from "./nsisUtil";
7
+ import { AppPackageHelper, CopyElevateHelper } from "./nsisUtil";
8
8
  export declare class NsisTarget extends Target {
9
9
  readonly packager: WinPackager;
10
10
  readonly outDir: string;
@@ -19,7 +19,7 @@ export declare class NsisTarget extends Target {
19
19
  get isBuildDifferentialAware(): boolean;
20
20
  private getPreCompressedFileExtensions;
21
21
  /** @private */
22
- buildAppPackage(appOutDir: string, arch: Arch): Promise<PackageFileInfo>;
22
+ buildAppPackage(appOutDir: string, arch: Arch, elevateHelper?: CopyElevateHelper | null): Promise<PackageFileInfo>;
23
23
  protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string;
24
24
  private get isPortable();
25
25
  finishBuild(): Promise<any>;
@@ -71,7 +71,7 @@ class NsisTarget extends core_1.Target {
71
71
  return result == null ? null : (0, builder_util_1.asArray)(result).map(it => (it.startsWith(".") ? it : `.${it}`));
72
72
  }
73
73
  /** @private */
74
- async buildAppPackage(appOutDir, arch) {
74
+ async buildAppPackage(appOutDir, arch, elevateHelper) {
75
75
  const options = this.options;
76
76
  const packager = this.packager;
77
77
  const isBuildDifferentialAware = this.isBuildDifferentialAware;
@@ -87,10 +87,22 @@ class NsisTarget extends core_1.Target {
87
87
  // install. Pin the payload to a filter it can decode. See #9983.
88
88
  installTimeDecodable: true,
89
89
  excluded: preCompressedFileExtensions == null ? null : preCompressedFileExtensions.map(it => `*${it}`),
90
+ // Opt-in via differentialPackage: "store-asar" — keep the asar a byte-stable Copy member so a
91
+ // differential update pays only for its changed blocks instead of re-downloading the whole
92
+ // recompressed asar (see nsisOptions docs).
93
+ storedPaths: isBuildDifferentialAware && options.differentialPackage === "store-asar" ? ["resources/app.asar"] : null,
90
94
  };
91
95
  const timer = (0, timer_1.time)(`nsis package, ${builder_util_1.Arch[arch]}`);
92
96
  await (0, archive_1.archive)(format, archiveFile, appOutDir, isBuildDifferentialAware ? (0, differentialUpdateInfoBuilder_1.configureDifferentialAwareArchiveOptions)(archiveOptions) : archiveOptions);
93
97
  timer.end();
98
+ // Inject elevate.exe into the archive via a temp staging dir, never by mutating appOutDir
99
+ // during packaging. The copy into win-unpacked is deferred until all targets finish, so
100
+ // concurrent targets (Squirrel, ZIP, etc.) never pick up elevate.exe non-deterministically.
101
+ // `archiveOptions` was mutated in place by configureDifferentialAwareArchiveOptions above
102
+ // (when differential-aware), so it already reflects the effective compression settings.
103
+ if (elevateHelper) {
104
+ await elevateHelper.addToArchive(archiveFile, this, format, archiveOptions, appOutDir);
105
+ }
94
106
  if (isBuildDifferentialAware && this.isWebInstaller) {
95
107
  const data = await (0, differentialUpdateInfoBuilder_1.appendBlockmap)(archiveFile);
96
108
  return {