app-builder-lib 27.0.0-alpha.2 → 27.0.0-alpha.3

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 (175) hide show
  1. package/dist/Framework.d.ts +2 -0
  2. package/dist/Framework.d.ts.map +1 -1
  3. package/dist/Framework.js.map +1 -1
  4. package/dist/asar/asarFileChecker.d.ts +4 -2
  5. package/dist/asar/asarFileChecker.d.ts.map +1 -1
  6. package/dist/asar/asarFileChecker.js +2 -3
  7. package/dist/asar/asarFileChecker.js.map +1 -1
  8. package/dist/codeSign/certInfo.d.ts +14 -0
  9. package/dist/codeSign/certInfo.d.ts.map +1 -1
  10. package/dist/codeSign/certInfo.js +49 -0
  11. package/dist/codeSign/certInfo.js.map +1 -1
  12. package/dist/codeSign/mac/macCodeSign.d.ts +3 -3
  13. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  14. package/dist/codeSign/mac/macCodeSign.js +40 -14
  15. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  16. package/dist/codeSign/win/hsmSignManager.d.ts +10 -0
  17. package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -0
  18. package/dist/codeSign/win/hsmSignManager.js +50 -0
  19. package/dist/codeSign/win/hsmSignManager.js.map +1 -0
  20. package/dist/codeSign/win/pkcs11SignManager.d.ts +14 -0
  21. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -0
  22. package/dist/codeSign/win/pkcs11SignManager.js +82 -0
  23. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -0
  24. package/dist/codeSign/{signManager.d.ts → win/signManager.d.ts} +8 -6
  25. package/dist/codeSign/win/signManager.d.ts.map +1 -0
  26. package/dist/codeSign/win/signManager.js +19 -0
  27. package/dist/codeSign/win/signManager.js.map +1 -0
  28. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +71 -0
  29. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -0
  30. package/dist/codeSign/win/signtoolBaseSignManager.js +407 -0
  31. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -0
  32. package/dist/codeSign/win/windowsCodeSign.d.ts.map +1 -1
  33. package/dist/codeSign/win/windowsCodeSign.js +9 -4
  34. package/dist/codeSign/win/windowsCodeSign.js.map +1 -1
  35. package/dist/codeSign/win/windowsSignAzureManager.d.ts +9 -3
  36. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  37. package/dist/codeSign/win/windowsSignAzureManager.js +130 -36
  38. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  39. package/dist/codeSign/win/windowsSignToolManager.d.ts +1 -58
  40. package/dist/codeSign/win/windowsSignToolManager.d.ts.map +1 -1
  41. package/dist/codeSign/win/windowsSignToolManager.js +3 -363
  42. package/dist/codeSign/win/windowsSignToolManager.js.map +1 -1
  43. package/dist/configuration.d.ts +19 -120
  44. package/dist/configuration.d.ts.map +1 -1
  45. package/dist/configuration.js.map +1 -1
  46. package/dist/electron/ElectronFramework.d.ts +0 -2
  47. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  48. package/dist/electron/ElectronFramework.js +15 -27
  49. package/dist/electron/ElectronFramework.js.map +1 -1
  50. package/dist/electron/injectFFMPEG.js +2 -2
  51. package/dist/electron/injectFFMPEG.js.map +1 -1
  52. package/dist/electron/mac/electronMac.js +10 -8
  53. package/dist/electron/mac/electronMac.js.map +1 -1
  54. package/dist/electron/win/electronWin.js +1 -2
  55. package/dist/electron/win/electronWin.js.map +1 -1
  56. package/dist/index.d.ts +8 -4
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +3 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/indexInternal.d.ts +2 -2
  61. package/dist/indexInternal.d.ts.map +1 -1
  62. package/dist/indexInternal.js +1 -1
  63. package/dist/indexInternal.js.map +1 -1
  64. package/dist/macPackager.d.ts +14 -10
  65. package/dist/macPackager.d.ts.map +1 -1
  66. package/dist/macPackager.js +114 -121
  67. package/dist/macPackager.js.map +1 -1
  68. package/dist/node-module-collector/moduleManager.d.ts +7 -1
  69. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  70. package/dist/node-module-collector/moduleManager.js +2 -2
  71. package/dist/node-module-collector/moduleManager.js.map +1 -1
  72. package/dist/node-module-collector/nodeModulesCollector.js +1 -1
  73. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  74. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +48 -1
  75. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
  76. package/dist/node-module-collector/pnpmNodeModulesCollector.js +216 -17
  77. package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  78. package/dist/options/FuseOptionsV1.d.ts +137 -0
  79. package/dist/options/FuseOptionsV1.d.ts.map +1 -0
  80. package/dist/options/FuseOptionsV1.js +2 -0
  81. package/dist/options/FuseOptionsV1.js.map +1 -0
  82. package/dist/options/PlatformSpecificBuildOptions.d.ts +1 -1
  83. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  84. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  85. package/dist/options/macOptions.d.ts +93 -126
  86. package/dist/options/macOptions.d.ts.map +1 -1
  87. package/dist/options/macOptions.js.map +1 -1
  88. package/dist/options/winOptions.d.ts +137 -63
  89. package/dist/options/winOptions.d.ts.map +1 -1
  90. package/dist/options/winOptions.js +12 -1
  91. package/dist/options/winOptions.js.map +1 -1
  92. package/dist/platformPackager.d.ts +4 -2
  93. package/dist/platformPackager.d.ts.map +1 -1
  94. package/dist/platformPackager.js +11 -7
  95. package/dist/platformPackager.js.map +1 -1
  96. package/dist/targets/ArchiveTarget.js +2 -2
  97. package/dist/targets/ArchiveTarget.js.map +1 -1
  98. package/dist/targets/archive.d.ts +10 -2
  99. package/dist/targets/archive.d.ts.map +1 -1
  100. package/dist/targets/archive.js +25 -6
  101. package/dist/targets/archive.js.map +1 -1
  102. package/dist/targets/linux/snap/core24.d.ts +2 -0
  103. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  104. package/dist/targets/linux/snap/core24.js +48 -8
  105. package/dist/targets/linux/snap/core24.js.map +1 -1
  106. package/dist/targets/linux/snap/coreLegacy.d.ts +2 -2
  107. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  108. package/dist/targets/linux/snap/coreLegacy.js +3 -4
  109. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  110. package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
  111. package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
  112. package/dist/targets/linux/snap/snapCommand.js +27 -0
  113. package/dist/targets/linux/snap/snapCommand.js.map +1 -0
  114. package/dist/targets/mac/MacTargetHelper.d.ts +12 -12
  115. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  116. package/dist/targets/mac/MacTargetHelper.js +72 -67
  117. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  118. package/dist/targets/mac/pkg.d.ts.map +1 -1
  119. package/dist/targets/mac/pkg.js +4 -4
  120. package/dist/targets/mac/pkg.js.map +1 -1
  121. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  122. package/dist/targets/win/AppxTarget.js +4 -4
  123. package/dist/targets/win/AppxTarget.js.map +1 -1
  124. package/dist/targets/win/nsis/NsisTarget.js +2 -2
  125. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  126. package/dist/targets/win/nsis/nsisScriptGenerator.js +1 -1
  127. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  128. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  129. package/dist/targets/win/nsis/nsisUtil.js +2 -2
  130. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  131. package/dist/toolsets/custom.d.ts +1 -0
  132. package/dist/toolsets/custom.d.ts.map +1 -1
  133. package/dist/toolsets/custom.js +19 -8
  134. package/dist/toolsets/custom.js.map +1 -1
  135. package/dist/toolsets/icons.js +1 -1
  136. package/dist/toolsets/icons.js.map +1 -1
  137. package/dist/toolsets/winCodeSign.d.ts +36 -0
  138. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  139. package/dist/toolsets/winCodeSign.js +84 -30
  140. package/dist/toolsets/winCodeSign.js.map +1 -1
  141. package/dist/toolsets/wine.d.ts.map +1 -1
  142. package/dist/toolsets/wine.js +20 -12
  143. package/dist/toolsets/wine.js.map +1 -1
  144. package/dist/util/config/schemaValidator.d.ts.map +1 -1
  145. package/dist/util/config/schemaValidator.js +1 -1
  146. package/dist/util/config/schemaValidator.js.map +1 -1
  147. package/dist/util/electronGet.d.ts +8 -25
  148. package/dist/util/electronGet.d.ts.map +1 -1
  149. package/dist/util/electronGet.js +107 -87
  150. package/dist/util/electronGet.js.map +1 -1
  151. package/dist/util/flags.d.ts +0 -3
  152. package/dist/util/flags.d.ts.map +1 -1
  153. package/dist/util/flags.js +0 -9
  154. package/dist/util/flags.js.map +1 -1
  155. package/dist/util/license.d.ts.map +1 -1
  156. package/dist/util/license.js +4 -1
  157. package/dist/util/license.js.map +1 -1
  158. package/dist/version.d.ts +1 -1
  159. package/dist/version.js +1 -1
  160. package/dist/version.js.map +1 -1
  161. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  162. package/dist/vm/ParallelsVm.js +13 -2
  163. package/dist/vm/ParallelsVm.js.map +1 -1
  164. package/dist/vm/vm.d.ts.map +1 -1
  165. package/dist/vm/vm.js +4 -1
  166. package/dist/vm/vm.js.map +1 -1
  167. package/dist/winPackager.d.ts +1 -2
  168. package/dist/winPackager.d.ts.map +1 -1
  169. package/dist/winPackager.js +17 -22
  170. package/dist/winPackager.js.map +1 -1
  171. package/package.json +15 -14
  172. package/scheme.json +484 -432
  173. package/dist/codeSign/signManager.d.ts.map +0 -1
  174. package/dist/codeSign/signManager.js +0 -2
  175. package/dist/codeSign/signManager.js.map +0 -1
@@ -1,6 +1,7 @@
1
+ import { Lazy } from "lazy-val";
1
2
  import { NodeModulesCollector } from "./nodeModulesCollector.js";
2
3
  import { PM } from "./packageManager.js";
3
- import { PnpmDependency } from "./types.js";
4
+ import type { PnpmDependency } from "./types.js";
4
5
  export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {
5
6
  readonly installOptions: {
6
7
  manager: PM;
@@ -9,6 +10,21 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
9
10
  private _allWorkspacePackages;
10
11
  private _pnpmMajorVersion;
11
12
  private readonly pnpmVersion;
13
+ /**
14
+ * Detect pnpm's installed layout from the on-disk structure rather than `pnpm config list`.
15
+ * pnpm 11 no longer echoes `node-linker` (from `.npmrc`) in `config list`, so the base-class
16
+ * config-parsing detection silently reports "not hoisted" for a hoisted install, which would
17
+ * disable the downward search needed to find version-conflicted nested deps.
18
+ *
19
+ * In the default isolated store every regular top-level package resolves — through a symlink
20
+ * on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.
21
+ * In a hoisted layout the same package is a real directory directly under `node_modules`.
22
+ * `realpath` transparently follows both symlinks and junctions, so a layout is isolated iff
23
+ * *any* top-level package's real path routes through `.pnpm`. We scan rather than sample the
24
+ * first entry because `link:` packages resolve to their source (never under `.pnpm`) and could
25
+ * otherwise mask an isolated store.
26
+ */
27
+ protected isHoisted: Lazy<boolean>;
12
28
  /**
13
29
  * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual
14
30
  * store guarantees that any given `name@version` resolves to a single location on disk, so
@@ -22,6 +38,9 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
22
38
  * every shared subtree of the pnpm list output, exploding work in deep workspaces.
23
39
  */
24
40
  private readonly collectedDeps;
41
+ /** Reverse index of `allDependencies` keyed by package name (without version). Built once on
42
+ * first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */
43
+ private _allDepsByName;
25
44
  /**
26
45
  * Returns the workspace packages to iterate over, gated by detected pnpm version:
27
46
  * - pnpm v11+: multi-entry workspace output → return the full parsed array
@@ -29,6 +48,7 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
29
48
  */
30
49
  private get allWorkspacePackages();
31
50
  protected getArgs(): string[];
51
+ private getAllDepsByName;
32
52
  /**
33
53
  * Locate a package version, preferring the dep's own reported path before falling back to rootDir.
34
54
  * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own
@@ -38,7 +58,34 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
38
58
  private locateFromDepOrRoot;
39
59
  protected extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string): Promise<void>;
40
60
  protected collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void>;
61
+ /**
62
+ * Resolve a `link:` dependency to its real on-disk source directory — never the `node_modules`
63
+ * junction pnpm creates for it. Returns null for non-link deps.
64
+ *
65
+ * Why this matters: resolving a link: dep through `node_modules` (locateFromDepOrRoot) yields the
66
+ * junction, which CI cannot read across drives. CI checks out the repo on `D:` but installs the
67
+ * app under `C:\…\Temp`, so the junction is a cross-volume link that `realpath`/`stat` fail on,
68
+ * silently dropping the package from the asar. The link target is a plain directory that reads
69
+ * fine from any drive, so we resolve straight to it.
70
+ */
71
+ private resolveLinkTarget;
72
+ private readPackageJsonAt;
73
+ /**
74
+ * Visit a single dependency node, adding it and its transitive deps to allDependencies.
75
+ *
76
+ * For packages that pnpm list did NOT expand (link: packages and the synthetic entries
77
+ * derived from them), the tree has empty dependencies/optionalDependencies. In that case
78
+ * we fall back to the on-disk package.json to discover transitive deps, resolving each one
79
+ * from the package's own node_modules first (where pnpm placed them).
80
+ */
81
+ private visitDep;
41
82
  private collectDepsRecursively;
83
+ /**
84
+ * pnpm excludes link: packages from `pnpm list --prod` output. Read the app's package.json
85
+ * directly to find any link: deps that were silently omitted and visit them so their
86
+ * transitive deps end up in allDependencies.
87
+ */
88
+ private collectOmittedLinkPackages;
42
89
  protected getTreeFromWorkspaces(tree: PnpmDependency, packageName: string): PnpmDependency;
43
90
  protected parseDependenciesTree(jsonBlob: string): Promise<PnpmDependency>;
44
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pnpmNodeModulesCollector.d.ts","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAA4B,EAAE,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,qBAAa,wBAAyB,SAAQ,oBAAoB,CAAC,cAAc,EAAE,cAAc,CAAC;IAChG,SAAgB,cAAc;;;MAG7B;IAGD,OAAO,CAAC,qBAAqB,CAAuB;IAEpD,OAAO,CAAC,iBAAiB,CAAI;IAE7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAI1B;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkD;IAE7E;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD;;;;OAIG;IACH,OAAO,KAAK,oBAAoB,GAK/B;IAED,SAAS,CAAC,OAAO,IAAI,MAAM,EAAE;IAI7B;;;;;OAKG;YACW,mBAAmB;cAqCjB,gCAAgC,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM;cAsD3E,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAMvF,sBAAsB;cAyBjB,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc;cAYnF,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAMjF"}
1
+ {"version":3,"file":"pnpmNodeModulesCollector.d.ts","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,I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7 +1,10 @@
1
+ import _fsExtra from "fs-extra";
1
2
  import { Lazy } from "lazy-val";
3
+ import * as path from "path";
2
4
  import { LogMessageByKey } from "./moduleManager.js";
3
5
  import { NodeModulesCollector } from "./nodeModulesCollector.js";
4
6
  import { getPackageManagerCommand, PM } from "./packageManager.js";
7
+ import { isValidKey } from "builder-util";
5
8
  export class PnpmNodeModulesCollector extends NodeModulesCollector {
6
9
  constructor() {
7
10
  super(...arguments);
@@ -19,6 +22,45 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
19
22
  const major = parseInt((result.stdout ?? "0").split(".")[0], 10);
20
23
  return isNaN(major) ? 0 : major;
21
24
  });
25
+ /**
26
+ * Detect pnpm's installed layout from the on-disk structure rather than `pnpm config list`.
27
+ * pnpm 11 no longer echoes `node-linker` (from `.npmrc`) in `config list`, so the base-class
28
+ * config-parsing detection silently reports "not hoisted" for a hoisted install, which would
29
+ * disable the downward search needed to find version-conflicted nested deps.
30
+ *
31
+ * In the default isolated store every regular top-level package resolves — through a symlink
32
+ * on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.
33
+ * In a hoisted layout the same package is a real directory directly under `node_modules`.
34
+ * `realpath` transparently follows both symlinks and junctions, so a layout is isolated iff
35
+ * *any* top-level package's real path routes through `.pnpm`. We scan rather than sample the
36
+ * first entry because `link:` packages resolve to their source (never under `.pnpm`) and could
37
+ * otherwise mask an isolated store.
38
+ */
39
+ this.isHoisted = new Lazy(async () => {
40
+ const nmDir = path.join(this.rootDir, "node_modules");
41
+ const entries = await _fsExtra.readdir(nmDir).catch(() => []);
42
+ let sawPackage = false;
43
+ for (const name of entries) {
44
+ if (name.startsWith(".")) {
45
+ continue; // .pnpm, .bin, .modules.yaml
46
+ }
47
+ const entryPath = path.join(nmDir, name);
48
+ // A scoped dir (@scope) is not a package itself; descend to its packages.
49
+ const candidates = name.startsWith("@") ? (await _fsExtra.readdir(entryPath).catch(() => [])).map(s => path.join(entryPath, s)) : [entryPath];
50
+ for (const candidate of candidates) {
51
+ const real = await _fsExtra.realpath(candidate).catch(() => null);
52
+ if (real == null) {
53
+ continue;
54
+ }
55
+ sawPackage = true;
56
+ if (real.split(path.sep).includes(".pnpm")) {
57
+ return false; // isolated store: a package routes through the virtual store
58
+ }
59
+ }
60
+ }
61
+ // Packages exist and none route through `.pnpm` → hoisted. No packages → flat default.
62
+ return sawPackage;
63
+ });
22
64
  /**
23
65
  * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual
24
66
  * store guarantees that any given `name@version` resolves to a single location on disk, so
@@ -32,6 +74,9 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
32
74
  * every shared subtree of the pnpm list output, exploding work in deep workspaces.
33
75
  */
34
76
  this.collectedDeps = new Set();
77
+ /** Reverse index of `allDependencies` keyed by package name (without version). Built once on
78
+ * first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */
79
+ this._allDepsByName = null;
35
80
  }
36
81
  /**
37
82
  * Returns the workspace packages to iterate over, gated by detected pnpm version:
@@ -47,6 +92,18 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
47
92
  getArgs() {
48
93
  return ["list", "--prod", "--json", "--depth", "Infinity", "--silent", "--loglevel=error"];
49
94
  }
95
+ getAllDepsByName() {
96
+ if (!this._allDepsByName) {
97
+ this._allDepsByName = new Map();
98
+ for (const [id, dep] of this.allDependencies.entries()) {
99
+ const { name } = this.parseNameVersion(id);
100
+ if (!this._allDepsByName.has(name)) {
101
+ this._allDepsByName.set(name, dep);
102
+ }
103
+ }
104
+ }
105
+ return this._allDepsByName;
106
+ }
50
107
  /**
51
108
  * Locate a package version, preferring the dep's own reported path before falling back to rootDir.
52
109
  * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own
@@ -72,6 +129,24 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
72
129
  // land at `<root>/node_modules/A/node_modules/B` — downward BFS is needed to find them.
73
130
  const skipDownwardSearch = !(await this.isHoisted.value);
74
131
  const promise = (async () => {
132
+ // Phase 1: find a version that SATISFIES requiredRange, trying the dep's own location
133
+ // first, then the workspace root. Crucially, neither pass accepts an out-of-range override
134
+ // here — so a wrong-version copy reachable via upward search from `parentPath` (e.g. a
135
+ // hoisted top-level dep) can't shadow the correct nested copy under root. Without this, a
136
+ // package that pnpm deduped to a peer's node_modules resolves its transitive deps to the
137
+ // wrong hoisted version (see jsonfile under two fs-extra majors). The root pass uses the
138
+ // same `skipDownwardSearch` as everywhere else: in a hoisted layout it is already false, so
139
+ // the nested `<root>/node_modules/A/node_modules/B` copy is found via BFS; in the flat
140
+ // `.pnpm` virtual store it stays true (forcing it on there would burn thousands of
141
+ // readdir/lstat calls — and on Windows, where pnpm uses junctions that `lstat` reports as
142
+ // directories, the BFS walks the entire store and resolves the wrong paths).
143
+ const satisfying = (parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch, skipOverrideFallback: true }) : null) ??
144
+ (await this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch, skipOverrideFallback: true }));
145
+ if (satisfying) {
146
+ return satisfying;
147
+ }
148
+ // Phase 2: no version satisfies requiredRange (package-manager override, or no range
149
+ // given). Fall back to the original dep-then-root order, now allowing override versions.
75
150
  const fromDep = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch }) : null;
76
151
  if (fromDep) {
77
152
  return fromDep;
@@ -104,10 +179,27 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
104
179
  }
105
180
  }
106
181
  const packageName = tree.name || tree.from;
107
- const { packageJson } = (await this.locateFromDepOrRoot(packageName, tree.path, tree.version)) || {};
182
+ const { packageJson: locatedJson } = (await this.locateFromDepOrRoot(packageName, tree.path, tree.version)) || {};
183
+ // Fallback: the app root package is never installed inside a node_modules directory, so
184
+ // the name-based lookup above returns null. Reading directly from tree.path ensures that
185
+ // link: dependencies — which some pnpm versions omit from `pnpm list --prod` output —
186
+ // still appear in `all` and therefore reach the production graph.
187
+ const packageJson = locatedJson ?? (tree.path ? (await _fsExtra.readJson(path.join(tree.path, "package.json")).catch(() => null)) : null);
108
188
  const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies };
109
189
  const optional = packageJson ? { ...packageJson.optionalDependencies } : {};
110
190
  const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) };
191
+ // pnpm --prod omits sub-deps for link: packages (and synthetic entries derived from them).
192
+ // For any dep declared in the package.json (all) that pnpm left out of the tree, recover
193
+ // the resolved entry from allDependencies so it lands in the production graph.
194
+ const byName = this.getAllDepsByName();
195
+ for (const depName of Object.keys(all)) {
196
+ if (!deps[depName]) {
197
+ const dep = byName.get(depName);
198
+ if (dep && isValidKey(depName)) {
199
+ deps[depName] = dep;
200
+ }
201
+ }
202
+ }
111
203
  this.productionGraph[dependencyId] = { dependencies: [] };
112
204
  const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {
113
205
  // First check if it's in production dependencies
@@ -139,28 +231,135 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector {
139
231
  for (const root of this.allWorkspacePackages) {
140
232
  await this.collectDepsRecursively(root);
141
233
  }
234
+ // pnpm --prod omits link: packages from its JSON output entirely; pick them up from the
235
+ // app's package.json so their transitive deps are included in allDependencies.
236
+ await this.collectOmittedLinkPackages();
142
237
  }
143
- async collectDepsRecursively(tree) {
144
- const visit = async (key, value) => {
145
- if ((value?.dedupedDependenciesCount ?? 0) > 0) {
146
- return;
147
- }
148
- const id = `${key}@${value.version}`;
149
- // The pnpm list output can include the same `name@version` thousands of times across a
150
- // deep workspace; without this guard we re-resolve and re-recurse each occurrence.
151
- if (this.collectedDeps.has(id)) {
152
- return;
238
+ /**
239
+ * Resolve a `link:` dependency to its real on-disk source directory — never the `node_modules`
240
+ * junction pnpm creates for it. Returns null for non-link deps.
241
+ *
242
+ * Why this matters: resolving a link: dep through `node_modules` (locateFromDepOrRoot) yields the
243
+ * junction, which CI cannot read across drives. CI checks out the repo on `D:` but installs the
244
+ * app under `C:\…\Temp`, so the junction is a cross-volume link that `realpath`/`stat` fail on,
245
+ * silently dropping the package from the asar. The link target is a plain directory that reads
246
+ * fine from any drive, so we resolve straight to it.
247
+ */
248
+ resolveLinkTarget(value) {
249
+ const version = value.version;
250
+ if (typeof version !== "string" || !version.startsWith("link:")) {
251
+ return null;
252
+ }
253
+ const spec = version.slice("link:".length);
254
+ // A cross-drive link cannot be expressed relative, so pnpm reports it as an absolute path —
255
+ // use it directly. Otherwise prefer pnpm's already-resolved absolute `path` (the source dir,
256
+ // never the junction), falling back to resolving the relative spec against the workspace root.
257
+ if (path.isAbsolute(spec)) {
258
+ return path.normalize(spec);
259
+ }
260
+ if (value.path && path.isAbsolute(value.path)) {
261
+ return path.normalize(value.path);
262
+ }
263
+ return path.resolve(this.rootDir, spec);
264
+ }
265
+ async readPackageJsonAt(dir) {
266
+ const packageJson = (await _fsExtra.readJson(path.join(dir, "package.json")).catch(() => null));
267
+ return packageJson ? { packageDir: dir, packageJson } : null;
268
+ }
269
+ /**
270
+ * Visit a single dependency node, adding it and its transitive deps to allDependencies.
271
+ *
272
+ * For packages that pnpm list did NOT expand (link: packages and the synthetic entries
273
+ * derived from them), the tree has empty dependencies/optionalDependencies. In that case
274
+ * we fall back to the on-disk package.json to discover transitive deps, resolving each one
275
+ * from the package's own node_modules first (where pnpm placed them).
276
+ */
277
+ async visitDep(key, value) {
278
+ const id = `${key}@${value.version}`;
279
+ // The pnpm list output can include the same `name@version` thousands of times across a
280
+ // deep workspace; without this guard we re-resolve and re-recurse each occurrence.
281
+ if (this.collectedDeps.has(id)) {
282
+ return;
283
+ }
284
+ this.collectedDeps.add(id);
285
+ const located = await this.locateFromDepOrRoot(key, value.path, value.version);
286
+ // For a link: dep, store the real source dir (the link target) rather than the located path,
287
+ // which is the node_modules junction. Across drives that junction is unreadable (see
288
+ // resolveLinkTarget), so storing it makes the package vanish from the asar.
289
+ const linkTarget = this.resolveLinkTarget(value);
290
+ const resolvedPath = linkTarget ?? located?.packageDir ?? value.path;
291
+ this.allDependencies.set(id, { ...value, path: resolvedPath });
292
+ // For transitive-dep discovery of entries pnpm did not expand (link: packages), use the
293
+ // located package.json; fall back to the link target's own package.json when the junction
294
+ // could not be resolved (again, the cross-drive case).
295
+ const pkg = located ?? (linkTarget != null ? await this.readPackageJsonAt(linkTarget) : null);
296
+ const hasTreeDeps = Object.keys(value.dependencies ?? {}).length > 0 || Object.keys(value.optionalDependencies ?? {}).length > 0;
297
+ if (!hasTreeDeps && pkg?.packageJson) {
298
+ // pnpm list omits sub-deps for link: packages and for entries where the reported path
299
+ // doesn't expand transitive deps (e.g. a link: package's nested dep). Use the on-disk
300
+ // package.json to discover what to include, and pass the declared version range so that
301
+ // resolution skips wrong-version hoisted packages and finds the correct nested copy.
302
+ const pkgDepsDecl = { ...(pkg.packageJson.dependencies || {}), ...(pkg.packageJson.optionalDependencies || {}) };
303
+ for (const [depName, depRange] of Object.entries(pkgDepsDecl)) {
304
+ const resolved = await this.locateFromDepOrRoot(depName, pkg.packageDir, typeof depRange === "string" ? depRange : undefined);
305
+ if (!resolved) {
306
+ continue;
307
+ }
308
+ await this.visitDep(depName, {
309
+ from: depName,
310
+ name: depName,
311
+ version: resolved.packageJson.version,
312
+ path: resolved.packageDir,
313
+ dependencies: {},
314
+ optionalDependencies: {},
315
+ });
153
316
  }
154
- this.collectedDeps.add(id);
155
- const pkg = await this.locateFromDepOrRoot(key, value.path, value.version);
156
- this.allDependencies.set(id, { ...value, path: pkg?.packageDir ?? value.path });
317
+ }
318
+ else {
157
319
  await this.collectDepsRecursively(value);
158
- };
320
+ }
321
+ }
322
+ async collectDepsRecursively(tree) {
159
323
  for (const [key, value] of Object.entries(tree.dependencies || {})) {
160
- await visit(key, value);
324
+ await this.visitDep(key, value);
161
325
  }
162
326
  for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {
163
- await visit(key, value);
327
+ await this.visitDep(key, value);
328
+ }
329
+ }
330
+ /**
331
+ * pnpm excludes link: packages from `pnpm list --prod` output. Read the app's package.json
332
+ * directly to find any link: deps that were silently omitted and visit them so their
333
+ * transitive deps end up in allDependencies.
334
+ */
335
+ async collectOmittedLinkPackages() {
336
+ const appPkgJson = (await _fsExtra.readJson(path.join(this.rootDir, "package.json")).catch(() => null));
337
+ if (!appPkgJson) {
338
+ return;
339
+ }
340
+ const allDeps = { ...(appPkgJson.dependencies || {}), ...(appPkgJson.optionalDependencies || {}) };
341
+ for (const [name, version] of Object.entries(allDeps)) {
342
+ if (typeof version !== "string" || !version.startsWith("link:")) {
343
+ continue;
344
+ }
345
+ // Resolve the link: target path directly — bypasses potentially broken cross-drive
346
+ // Windows junctions (C:→D:) that locateFromDepOrRoot would traverse through
347
+ // node_modules and silently fail on (readJson returns null via .catch).
348
+ const linkRelPath = version.slice("link:".length);
349
+ const linkTarget = path.isAbsolute(linkRelPath) ? linkRelPath : path.resolve(this.rootDir, linkRelPath);
350
+ const directPkg = (await _fsExtra.readJson(path.join(linkTarget, "package.json")).catch(() => null));
351
+ const resolved = directPkg ? { packageDir: linkTarget, packageJson: directPkg } : await this.locateFromDepOrRoot(name, this.rootDir, undefined);
352
+ if (!resolved) {
353
+ continue;
354
+ }
355
+ await this.visitDep(name, {
356
+ from: name,
357
+ name,
358
+ version: resolved.packageJson.version,
359
+ path: resolved.packageDir,
360
+ dependencies: {},
361
+ optionalDependencies: {},
362
+ });
164
363
  }
165
364
  }
166
365
  getTreeFromWorkspaces(tree, packageName) {
@@ -1 +1 @@
1
- {"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,oBAAoB,EA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QAC3C,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAA;QACrD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import { Lazy } from \"lazy-val\"\nimport { LogMessageByKey, type Package } from \"./moduleManager.js\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector.js\"\nimport { getPackageManagerCommand, PM } from \"./packageManager.js\"\nimport { PnpmDependency } from \"./types.js\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {\n public readonly installOptions = {\n manager: PM.PNPM,\n lockfile: \"pnpm-lock.yaml\",\n }\n\n // Raw backing field — all entries from `pnpm list --json`\n private _allWorkspacePackages: PnpmDependency[] = []\n // Cached after parseDependenciesTree resolves the Lazy; 0 = safe default (treated as < v11)\n private _pnpmMajorVersion = 0\n // Runs `pnpm --version` once and caches the major version number\n private readonly pnpmVersion = new Lazy<number>(async () => {\n const result = await this.asyncExec(getPackageManagerCommand(PM.PNPM), [\"--version\"])\n const major = parseInt((result.stdout ?? \"0\").split(\".\")[0], 10)\n return isNaN(major) ? 0 : major\n })\n\n /**\n * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual\n * store guarantees that any given `name@version` resolves to a single location on disk, so\n * once we've resolved a package we can short-circuit every subsequent lookup. This is the\n * dominant speedup for large workspaces where the `pnpm list --json` tree contains the same\n * `name@version` thousands of times (one entry per dependent).\n */\n private readonly locateMemo: Map<string, Promise<Package | null>> = new Map()\n\n /**\n * Visited set for `collectDepsRecursively`, keyed by `name@version`. Without this we re-walk\n * every shared subtree of the pnpm list output, exploding work in deep workspaces.\n */\n private readonly collectedDeps: Set<string> = new Set()\n\n /**\n * Returns the workspace packages to iterate over, gated by detected pnpm version:\n * - pnpm v11+: multi-entry workspace output → return the full parsed array\n * - pnpm < v11 / non-workspace / detection failure: single-tree behavior → return only [0]\n */\n private get allWorkspacePackages(): PnpmDependency[] {\n if (this._pnpmMajorVersion >= 11) {\n return this._allWorkspacePackages\n }\n return this._allWorkspacePackages.slice(0, 1)\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n /**\n * Locate a package version, preferring the dep's own reported path before falling back to rootDir.\n * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own\n * nested node_modules. Searching only from rootDir can resolve the wrong version when multiple\n * versions of a dep exist in the workspace.\n */\n private async locateFromDepOrRoot(pkgName: string, parentPath: string | undefined, requiredRange?: string) {\n // pnpm's virtual store is content-addressed: every `name@version` lookup is deterministic,\n // so memoize on the exact version. `requiredRange` is normally an exact version coming from\n // the pnpm list output (e.g. `value.version`), which makes this cache hit on duplicates.\n // Only memoize when we have a concrete version — semver ranges could resolve differently\n // depending on what's installed at `parentPath` vs root, so skip the cache for those.\n const memoKey = requiredRange && /^\\d/.test(requiredRange) ? `${pkgName}@${requiredRange}` : null\n if (memoKey != null) {\n const cached = this.locateMemo.get(memoKey)\n if (cached != null) {\n return cached\n }\n }\n\n // pnpm's default `.pnpm` virtual store is flat, so `downwardSearch` would burn thousands\n // of `readdir`/`lstat` calls finding nothing. With `nodeLinker: hoisted`, however, the\n // layout is a traditional nested `node_modules` tree where version-conflicted packages\n // land at `<root>/node_modules/A/node_modules/B` — downward BFS is needed to find them.\n const skipDownwardSearch = !(await this.isHoisted.value)\n const promise = (async (): Promise<Package | null> => {\n const fromDep = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch }) : null\n if (fromDep) {\n return fromDep\n }\n return this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch })\n })()\n\n if (memoKey != null) {\n this.locateMemo.set(memoKey, promise)\n }\n return promise\n }\n\n // pnpm 10+ does not automatically preserve transitive optional platform-specific\n // packages (e.g. sass-embedded-linux-x64) across lock file regeneration. Users\n // must list them as direct optionalDependencies. Missing ones are emitted as\n // PKG_OPTIONAL_PLATFORM_NOT_INSTALLED warnings in the log summary.\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n if ((tree.dedupedDependenciesCount ?? 0) > 0) {\n const realDep = this.allDependencies.get(dependencyId)\n if (realDep) {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF].push(dependencyId)\n tree = realDep\n } else {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED].push(dependencyId)\n return\n }\n }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.locateFromDepOrRoot(packageName, tree.path, tree.version)) || {}\n\n const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies }\n const optional = packageJson ? { ...packageJson.optionalDependencies } : {}\n\n const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n this.productionGraph[dependencyId] = { dependencies: [] }\n const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {\n // First check if it's in production dependencies\n if (!all[packageName]) {\n return undefined\n }\n\n // Then check if optional dependency path exists (using actual resolved path)\n if (optional[packageName]) {\n const pkg = await this.locateFromDepOrRoot(packageName, tree.path, dependency.version)\n if (!pkg) {\n this.logMissingDependency(`${packageName}@${dependency.version}`)\n return undefined\n }\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void> {\n for (const root of this.allWorkspacePackages) {\n await this.collectDepsRecursively(root)\n }\n }\n\n private async collectDepsRecursively(tree: PnpmDependency): Promise<void> {\n const visit = async (key: string, value: PnpmDependency) => {\n if ((value?.dedupedDependenciesCount ?? 0) > 0) {\n return\n }\n const id = `${key}@${value.version}`\n // The pnpm list output can include the same `name@version` thousands of times across a\n // deep workspace; without this guard we re-resolve and re-recurse each occurrence.\n if (this.collectedDeps.has(id)) {\n return\n }\n this.collectedDeps.add(id)\n const pkg = await this.locateFromDepOrRoot(key, value.path, value.version)\n this.allDependencies.set(id, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectDepsRecursively(value)\n }\n\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n await visit(key, value)\n }\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n await visit(key, value)\n }\n }\n\n protected override getTreeFromWorkspaces(tree: PnpmDependency, packageName: string): PnpmDependency {\n // pnpm v10 workspace: app is nested as a dependency of root — handled by base class\n const result = super.getTreeFromWorkspaces(tree, packageName)\n if (result !== tree) {\n return result\n }\n // pnpm v11 workspace: each workspace package is a separate top-level array entry;\n // non-workspace (single-tree): find returns the one entry or undefined → falls back to tree\n const match = this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName)\n return match ?? tree\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<PnpmDependency> {\n const dependencyTree = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n this._allWorkspacePackages = dependencyTree\n this._pnpmMajorVersion = await this.pnpmVersion.value\n return dependencyTree[0]\n }\n}\n"]}
1
+ {"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAA;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AM,CAAA;QACf,CAAC;QACD,kFAAkF;QAClF,4FAA4F;QAC5F,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;QACzG,OAAO,KAAK,IAAI,IAAI,CAAA;IACtB,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,QAAgB;QACpD,MAAM,cAAc,GAAG,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACrF,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAA;QAC3C,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAA;QACrD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import _fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { LogMessageByKey, type Package } from \"./moduleManager.js\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector.js\"\nimport { getPackageManagerCommand, PM } from \"./packageManager.js\"\nimport type { PackageJson, PnpmDependency } from \"./types.js\"\nimport { isValidKey } from \"builder-util\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {\n public readonly installOptions = {\n manager: PM.PNPM,\n lockfile: \"pnpm-lock.yaml\",\n }\n\n // Raw backing field — all entries from `pnpm list --json`\n private _allWorkspacePackages: PnpmDependency[] = []\n // Cached after parseDependenciesTree resolves the Lazy; 0 = safe default (treated as < v11)\n private _pnpmMajorVersion = 0\n // Runs `pnpm --version` once and caches the major version number\n private readonly pnpmVersion = new Lazy<number>(async () => {\n const result = await this.asyncExec(getPackageManagerCommand(PM.PNPM), [\"--version\"])\n const major = parseInt((result.stdout ?? \"0\").split(\".\")[0], 10)\n return isNaN(major) ? 0 : major\n })\n\n /**\n * Detect pnpm's installed layout from the on-disk structure rather than `pnpm config list`.\n * pnpm 11 no longer echoes `node-linker` (from `.npmrc`) in `config list`, so the base-class\n * config-parsing detection silently reports \"not hoisted\" for a hoisted install, which would\n * disable the downward search needed to find version-conflicted nested deps.\n *\n * In the default isolated store every regular top-level package resolves — through a symlink\n * on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.\n * In a hoisted layout the same package is a real directory directly under `node_modules`.\n * `realpath` transparently follows both symlinks and junctions, so a layout is isolated iff\n * *any* top-level package's real path routes through `.pnpm`. We scan rather than sample the\n * first entry because `link:` packages resolve to their source (never under `.pnpm`) and could\n * otherwise mask an isolated store.\n */\n protected override isHoisted = new Lazy<boolean>(async () => {\n const nmDir = path.join(this.rootDir, \"node_modules\")\n const entries = await _fsExtra.readdir(nmDir).catch(() => [] as string[])\n let sawPackage = false\n for (const name of entries) {\n if (name.startsWith(\".\")) {\n continue // .pnpm, .bin, .modules.yaml\n }\n const entryPath = path.join(nmDir, name)\n // A scoped dir (@scope) is not a package itself; descend to its packages.\n const candidates = name.startsWith(\"@\") ? (await _fsExtra.readdir(entryPath).catch(() => [] as string[])).map(s => path.join(entryPath, s)) : [entryPath]\n for (const candidate of candidates) {\n const real = await _fsExtra.realpath(candidate).catch(() => null)\n if (real == null) {\n continue\n }\n sawPackage = true\n if (real.split(path.sep).includes(\".pnpm\")) {\n return false // isolated store: a package routes through the virtual store\n }\n }\n }\n // Packages exist and none route through `.pnpm` → hoisted. No packages → flat default.\n return sawPackage\n })\n\n /**\n * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual\n * store guarantees that any given `name@version` resolves to a single location on disk, so\n * once we've resolved a package we can short-circuit every subsequent lookup. This is the\n * dominant speedup for large workspaces where the `pnpm list --json` tree contains the same\n * `name@version` thousands of times (one entry per dependent).\n */\n private readonly locateMemo: Map<string, Promise<Package | null>> = new Map()\n\n /**\n * Visited set for `collectDepsRecursively`, keyed by `name@version`. Without this we re-walk\n * every shared subtree of the pnpm list output, exploding work in deep workspaces.\n */\n private readonly collectedDeps: Set<string> = new Set()\n\n /** Reverse index of `allDependencies` keyed by package name (without version). Built once on\n * first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */\n private _allDepsByName: Map<string, PnpmDependency> | null = null\n\n /**\n * Returns the workspace packages to iterate over, gated by detected pnpm version:\n * - pnpm v11+: multi-entry workspace output → return the full parsed array\n * - pnpm < v11 / non-workspace / detection failure: single-tree behavior → return only [0]\n */\n private get allWorkspacePackages(): PnpmDependency[] {\n if (this._pnpmMajorVersion >= 11) {\n return this._allWorkspacePackages\n }\n return this._allWorkspacePackages.slice(0, 1)\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n private getAllDepsByName(): Map<string, PnpmDependency> {\n if (!this._allDepsByName) {\n this._allDepsByName = new Map()\n for (const [id, dep] of this.allDependencies.entries()) {\n const { name } = this.parseNameVersion(id)\n if (!this._allDepsByName.has(name)) {\n this._allDepsByName.set(name, dep)\n }\n }\n }\n return this._allDepsByName\n }\n\n /**\n * Locate a package version, preferring the dep's own reported path before falling back to rootDir.\n * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own\n * nested node_modules. Searching only from rootDir can resolve the wrong version when multiple\n * versions of a dep exist in the workspace.\n */\n private async locateFromDepOrRoot(pkgName: string, parentPath: string | undefined, requiredRange?: string) {\n // pnpm's virtual store is content-addressed: every `name@version` lookup is deterministic,\n // so memoize on the exact version. `requiredRange` is normally an exact version coming from\n // the pnpm list output (e.g. `value.version`), which makes this cache hit on duplicates.\n // Only memoize when we have a concrete version — semver ranges could resolve differently\n // depending on what's installed at `parentPath` vs root, so skip the cache for those.\n const memoKey = requiredRange && /^\\d/.test(requiredRange) ? `${pkgName}@${requiredRange}` : null\n if (memoKey != null) {\n const cached = this.locateMemo.get(memoKey)\n if (cached != null) {\n return cached\n }\n }\n\n // pnpm's default `.pnpm` virtual store is flat, so `downwardSearch` would burn thousands\n // of `readdir`/`lstat` calls finding nothing. With `nodeLinker: hoisted`, however, the\n // layout is a traditional nested `node_modules` tree where version-conflicted packages\n // land at `<root>/node_modules/A/node_modules/B` — downward BFS is needed to find them.\n const skipDownwardSearch = !(await this.isHoisted.value)\n const promise = (async (): Promise<Package | null> => {\n // Phase 1: find a version that SATISFIES requiredRange, trying the dep's own location\n // first, then the workspace root. Crucially, neither pass accepts an out-of-range override\n // here — so a wrong-version copy reachable via upward search from `parentPath` (e.g. a\n // hoisted top-level dep) can't shadow the correct nested copy under root. Without this, a\n // package that pnpm deduped to a peer's node_modules resolves its transitive deps to the\n // wrong hoisted version (see jsonfile under two fs-extra majors). The root pass uses the\n // same `skipDownwardSearch` as everywhere else: in a hoisted layout it is already false, so\n // the nested `<root>/node_modules/A/node_modules/B` copy is found via BFS; in the flat\n // `.pnpm` virtual store it stays true (forcing it on there would burn thousands of\n // readdir/lstat calls — and on Windows, where pnpm uses junctions that `lstat` reports as\n // directories, the BFS walks the entire store and resolves the wrong paths).\n const satisfying =\n (parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch, skipOverrideFallback: true }) : null) ??\n (await this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch, skipOverrideFallback: true }))\n if (satisfying) {\n return satisfying\n }\n // Phase 2: no version satisfies requiredRange (package-manager override, or no range\n // given). Fall back to the original dep-then-root order, now allowing override versions.\n const fromDep = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch }) : null\n if (fromDep) {\n return fromDep\n }\n return this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch })\n })()\n\n if (memoKey != null) {\n this.locateMemo.set(memoKey, promise)\n }\n return promise\n }\n\n // pnpm 10+ does not automatically preserve transitive optional platform-specific\n // packages (e.g. sass-embedded-linux-x64) across lock file regeneration. Users\n // must list them as direct optionalDependencies. Missing ones are emitted as\n // PKG_OPTIONAL_PLATFORM_NOT_INSTALLED warnings in the log summary.\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n if ((tree.dedupedDependenciesCount ?? 0) > 0) {\n const realDep = this.allDependencies.get(dependencyId)\n if (realDep) {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF].push(dependencyId)\n tree = realDep\n } else {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED].push(dependencyId)\n return\n }\n }\n\n const packageName = tree.name || tree.from\n const { packageJson: locatedJson } = (await this.locateFromDepOrRoot(packageName, tree.path, tree.version)) || {}\n // Fallback: the app root package is never installed inside a node_modules directory, so\n // the name-based lookup above returns null. Reading directly from tree.path ensures that\n // link: dependencies — which some pnpm versions omit from `pnpm list --prod` output —\n // still appear in `all` and therefore reach the production graph.\n const packageJson = locatedJson ?? (tree.path ? ((await _fsExtra.readJson(path.join(tree.path, \"package.json\")).catch(() => null)) as PackageJson | null) : null)\n\n const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies }\n const optional = packageJson ? { ...packageJson.optionalDependencies } : {}\n\n const deps: Record<string, PnpmDependency> = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n\n // pnpm --prod omits sub-deps for link: packages (and synthetic entries derived from them).\n // For any dep declared in the package.json (all) that pnpm left out of the tree, recover\n // the resolved entry from allDependencies so it lands in the production graph.\n const byName = this.getAllDepsByName()\n for (const depName of Object.keys(all)) {\n if (!deps[depName]) {\n const dep = byName.get(depName)\n if (dep && isValidKey(depName)) {\n deps[depName] = dep\n }\n }\n }\n\n this.productionGraph[dependencyId] = { dependencies: [] }\n const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {\n // First check if it's in production dependencies\n if (!all[packageName]) {\n return undefined\n }\n\n // Then check if optional dependency path exists (using actual resolved path)\n if (optional[packageName]) {\n const pkg = await this.locateFromDepOrRoot(packageName, tree.path, dependency.version)\n if (!pkg) {\n this.logMissingDependency(`${packageName}@${dependency.version}`)\n return undefined\n }\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void> {\n for (const root of this.allWorkspacePackages) {\n await this.collectDepsRecursively(root)\n }\n // pnpm --prod omits link: packages from its JSON output entirely; pick them up from the\n // app's package.json so their transitive deps are included in allDependencies.\n await this.collectOmittedLinkPackages()\n }\n\n /**\n * Resolve a `link:` dependency to its real on-disk source directory — never the `node_modules`\n * junction pnpm creates for it. Returns null for non-link deps.\n *\n * Why this matters: resolving a link: dep through `node_modules` (locateFromDepOrRoot) yields the\n * junction, which CI cannot read across drives. CI checks out the repo on `D:` but installs the\n * app under `C:\\…\\Temp`, so the junction is a cross-volume link that `realpath`/`stat` fail on,\n * silently dropping the package from the asar. The link target is a plain directory that reads\n * fine from any drive, so we resolve straight to it.\n */\n private resolveLinkTarget(value: PnpmDependency): string | null {\n const version = value.version\n if (typeof version !== \"string\" || !version.startsWith(\"link:\")) {\n return null\n }\n const spec = version.slice(\"link:\".length)\n // A cross-drive link cannot be expressed relative, so pnpm reports it as an absolute path —\n // use it directly. Otherwise prefer pnpm's already-resolved absolute `path` (the source dir,\n // never the junction), falling back to resolving the relative spec against the workspace root.\n if (path.isAbsolute(spec)) {\n return path.normalize(spec)\n }\n if (value.path && path.isAbsolute(value.path)) {\n return path.normalize(value.path)\n }\n return path.resolve(this.rootDir, spec)\n }\n\n private async readPackageJsonAt(dir: string): Promise<Package | null> {\n const packageJson = (await _fsExtra.readJson(path.join(dir, \"package.json\")).catch(() => null)) as PackageJson | null\n return packageJson ? { packageDir: dir, packageJson } : null\n }\n\n /**\n * Visit a single dependency node, adding it and its transitive deps to allDependencies.\n *\n * For packages that pnpm list did NOT expand (link: packages and the synthetic entries\n * derived from them), the tree has empty dependencies/optionalDependencies. In that case\n * we fall back to the on-disk package.json to discover transitive deps, resolving each one\n * from the package's own node_modules first (where pnpm placed them).\n */\n private async visitDep(key: string, value: PnpmDependency): Promise<void> {\n const id = `${key}@${value.version}`\n // The pnpm list output can include the same `name@version` thousands of times across a\n // deep workspace; without this guard we re-resolve and re-recurse each occurrence.\n if (this.collectedDeps.has(id)) {\n return\n }\n this.collectedDeps.add(id)\n\n const located = await this.locateFromDepOrRoot(key, value.path, value.version)\n // For a link: dep, store the real source dir (the link target) rather than the located path,\n // which is the node_modules junction. Across drives that junction is unreadable (see\n // resolveLinkTarget), so storing it makes the package vanish from the asar.\n const linkTarget = this.resolveLinkTarget(value)\n const resolvedPath = linkTarget ?? located?.packageDir ?? value.path\n this.allDependencies.set(id, { ...value, path: resolvedPath })\n\n // For transitive-dep discovery of entries pnpm did not expand (link: packages), use the\n // located package.json; fall back to the link target's own package.json when the junction\n // could not be resolved (again, the cross-drive case).\n const pkg = located ?? (linkTarget != null ? await this.readPackageJsonAt(linkTarget) : null)\n const hasTreeDeps = Object.keys(value.dependencies ?? {}).length > 0 || Object.keys(value.optionalDependencies ?? {}).length > 0\n if (!hasTreeDeps && pkg?.packageJson) {\n // pnpm list omits sub-deps for link: packages and for entries where the reported path\n // doesn't expand transitive deps (e.g. a link: package's nested dep). Use the on-disk\n // package.json to discover what to include, and pass the declared version range so that\n // resolution skips wrong-version hoisted packages and finds the correct nested copy.\n const pkgDepsDecl = { ...(pkg.packageJson.dependencies || {}), ...(pkg.packageJson.optionalDependencies || {}) }\n for (const [depName, depRange] of Object.entries(pkgDepsDecl)) {\n const resolved = await this.locateFromDepOrRoot(depName, pkg.packageDir, typeof depRange === \"string\" ? depRange : undefined)\n if (!resolved) {\n continue\n }\n await this.visitDep(depName, {\n from: depName,\n name: depName,\n version: resolved.packageJson.version,\n path: resolved.packageDir,\n dependencies: {},\n optionalDependencies: {},\n } as unknown as PnpmDependency)\n }\n } else {\n await this.collectDepsRecursively(value)\n }\n }\n\n private async collectDepsRecursively(tree: PnpmDependency): Promise<void> {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n await this.visitDep(key, value)\n }\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n await this.visitDep(key, value)\n }\n }\n\n /**\n * pnpm excludes link: packages from `pnpm list --prod` output. Read the app's package.json\n * directly to find any link: deps that were silently omitted and visit them so their\n * transitive deps end up in allDependencies.\n */\n private async collectOmittedLinkPackages(): Promise<void> {\n const appPkgJson = (await _fsExtra.readJson(path.join(this.rootDir, \"package.json\")).catch(() => null)) as PackageJson | null\n if (!appPkgJson) {\n return\n }\n const allDeps = { ...(appPkgJson.dependencies || {}), ...(appPkgJson.optionalDependencies || {}) }\n for (const [name, version] of Object.entries(allDeps)) {\n if (typeof version !== \"string\" || !version.startsWith(\"link:\")) {\n continue\n }\n // Resolve the link: target path directly — bypasses potentially broken cross-drive\n // Windows junctions (C:→D:) that locateFromDepOrRoot would traverse through\n // node_modules and silently fail on (readJson returns null via .catch).\n const linkRelPath = version.slice(\"link:\".length)\n const linkTarget = path.isAbsolute(linkRelPath) ? linkRelPath : path.resolve(this.rootDir, linkRelPath)\n const directPkg = (await _fsExtra.readJson(path.join(linkTarget, \"package.json\")).catch(() => null)) as PackageJson | null\n const resolved = directPkg ? { packageDir: linkTarget, packageJson: directPkg } : await this.locateFromDepOrRoot(name, this.rootDir, undefined)\n if (!resolved) {\n continue\n }\n await this.visitDep(name, {\n from: name,\n name,\n version: resolved.packageJson.version,\n path: resolved.packageDir,\n dependencies: {},\n optionalDependencies: {},\n } as unknown as PnpmDependency)\n }\n }\n\n protected override getTreeFromWorkspaces(tree: PnpmDependency, packageName: string): PnpmDependency {\n // pnpm v10 workspace: app is nested as a dependency of root — handled by base class\n const result = super.getTreeFromWorkspaces(tree, packageName)\n if (result !== tree) {\n return result\n }\n // pnpm v11 workspace: each workspace package is a separate top-level array entry;\n // non-workspace (single-tree): find returns the one entry or undefined → falls back to tree\n const match = this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName)\n return match ?? tree\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<PnpmDependency> {\n const dependencyTree = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n this._allWorkspacePackages = dependencyTree\n this._pnpmMajorVersion = await this.pnpmVersion.value\n return dependencyTree[0]\n }\n}\n"]}
@@ -0,0 +1,137 @@
1
+ import type { FuseV1Options } from "@electron/fuses";
2
+ /**
3
+ * Feature flags ("fuses") baked into the Electron binary at build time.
4
+ *
5
+ * All options map 1:1 to the flags documented by
6
+ * [`@electron/fuses`](https://github.com/electron/fuses) and the upstream
7
+ * [Electron fuses guide](https://www.electronjs.org/docs/latest/tutorial/fuses).
8
+ *
9
+ * electron-builder flips fuses after packaging and **before** signing so that the final
10
+ * code signature covers the modified binary. On Apple Silicon, the ad-hoc signature is
11
+ * re-applied automatically after flipping fuses.
12
+ */
13
+ export interface FuseOptionsV1 extends Partial<Record<Uncapitalize<keyof typeof FuseV1Options>, boolean>> {
14
+ /**
15
+ * Controls whether the `ELECTRON_RUN_AS_NODE` environment variable is respected.
16
+ *
17
+ * When `true` (the Electron default), setting `ELECTRON_RUN_AS_NODE=1` in the environment
18
+ * makes Electron behave like a plain Node.js process, bypassing the app entirely. Disable
19
+ * this fuse in production apps to prevent that escape path.
20
+ *
21
+ * **Note:** Disabling this fuse also breaks `process.fork()` in the main process because
22
+ * it relies on `ELECTRON_RUN_AS_NODE` internally. Use
23
+ * [Utility Processes](https://www.electronjs.org/docs/latest/api/utility-process) as a
24
+ * replacement.
25
+ *
26
+ * @see https://github.com/electron/fuses
27
+ */
28
+ runAsNode?: boolean;
29
+ /**
30
+ * Controls whether the Chromium cookie store is encrypted using OS-level cryptography keys.
31
+ *
32
+ * When enabled, cookies are stored encrypted on disk (the same mechanism Chrome uses).
33
+ * **This is a one-way transition**: existing unencrypted cookies are re-encrypted on write, but
34
+ * disabling the fuse afterwards will leave the cookie database unreadable.
35
+ *
36
+ * Most production apps can safely enable this fuse.
37
+ *
38
+ * @see https://github.com/electron/fuses
39
+ */
40
+ enableCookieEncryption?: boolean;
41
+ /**
42
+ * Controls whether the [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions)
43
+ * and `NODE_EXTRA_CA_CERTS` environment variables are respected.
44
+ *
45
+ * `NODE_OPTIONS` allows injecting arbitrary Node.js runtime flags (e.g. `--require`) and is
46
+ * rarely needed in production. Most apps can safely disable this fuse.
47
+ *
48
+ * @see https://github.com/electron/fuses
49
+ */
50
+ enableNodeOptionsEnvironmentVariable?: boolean;
51
+ /**
52
+ * Controls whether the `--inspect`, `--inspect-brk`, and related Node.js debugger flags are
53
+ * honoured.
54
+ *
55
+ * When disabled, `SIGUSR1` no longer opens the V8 inspector in the main process either.
56
+ * Most production apps can safely disable this fuse.
57
+ *
58
+ * @see https://github.com/electron/fuses
59
+ */
60
+ enableNodeCliInspectArguments?: boolean;
61
+ /**
62
+ * Enables ASAR integrity validation — Electron verifies the embedded SHA-256 hash of
63
+ * `app.asar` before loading it.
64
+ *
65
+ * Platform support:
66
+ * - macOS: Electron ≥ 16.0.0
67
+ * - Windows: Electron ≥ 30.0.0
68
+ *
69
+ * For this fuse to be meaningful, `asar.disableIntegrity` must **not** be
70
+ * `true` (otherwise the hash is not embedded).
71
+ *
72
+ * @see https://www.electronjs.org/docs/latest/tutorial/asar-integrity
73
+ */
74
+ enableEmbeddedAsarIntegrityValidation?: boolean;
75
+ /**
76
+ * When enabled, Electron searches for the app exclusively in `app.asar`, skipping the `app`
77
+ * directory and `default_app.asar` fallbacks.
78
+ *
79
+ * Combined with `enableEmbeddedAsarIntegrityValidation`, this makes it impossible to side-load
80
+ * unverified code by replacing `app.asar` with an unarchived `app/` directory.
81
+ *
82
+ * @see https://github.com/electron/fuses
83
+ */
84
+ onlyLoadAppFromAsar?: boolean;
85
+ /**
86
+ * When enabled, the browser (main) process uses a separate V8 snapshot file
87
+ * (`browser_v8_context_snapshot.bin`) instead of the shared one.
88
+ *
89
+ * This is only useful when you ship a custom V8 snapshot for the main process that differs
90
+ * from the renderer snapshot. Standard apps do not need this.
91
+ *
92
+ * @see https://github.com/electron/fuses
93
+ */
94
+ loadBrowserProcessSpecificV8Snapshot?: boolean;
95
+ /**
96
+ * Controls whether pages loaded from the `file://` protocol receive elevated privileges
97
+ * beyond what a standard web browser would grant.
98
+ *
99
+ * These extra privileges include `fetch` to other `file://` URLs, service workers, and
100
+ * universal frame access for child frames also on `file://`. This behaviour pre-dates modern
101
+ * Electron security best practices.
102
+ *
103
+ * Disable this fuse if your app does not load content directly from `file://` (i.e. you use
104
+ * a [custom protocol](https://www.electronjs.org/docs/latest/tutorial/security#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols)).
105
+ *
106
+ * @see https://github.com/electron/fuses
107
+ */
108
+ grantFileProtocolExtraPrivileges?: boolean;
109
+ /**
110
+ * Enables V8 signal-based trap handlers for out-of-bounds WebAssembly memory accesses.
111
+ *
112
+ * When enabled, Electron uses OS signals (e.g. `SIGSEGV` on Linux/macOS) to catch Wasm
113
+ * OOB accesses at the hardware level rather than inserting explicit bounds checks in JIT'd
114
+ * code. This improves Wasm performance and is enabled by default in Electron.
115
+ *
116
+ * Disable only if the host environment restricts signal handlers (e.g. certain sandboxing
117
+ * configurations) and you observe crashes in Wasm-heavy workloads.
118
+ *
119
+ * @see https://github.com/electron/fuses
120
+ */
121
+ wasmTrapHandlers?: boolean;
122
+ /**
123
+ * Re-applies the ad-hoc codesignature on macOS after fuses are flipped.
124
+ *
125
+ * electron-builder already re-signs the app after flipping fuses, so this flag is
126
+ * generally not needed and exists only as a compatibility shim for edge cases.
127
+ *
128
+ * @see https://github.com/electron/fuses?tab=readme-ov-file#apple-silicon
129
+ */
130
+ resetAdHocDarwinSignature?: boolean;
131
+ }
132
+ type _AssertTrue<T extends true> = T;
133
+ export type _FuseOptionsV1Exhaustive = _AssertTrue<[
134
+ Exclude<Uncapitalize<keyof typeof FuseV1Options>, keyof FuseOptionsV1>
135
+ ] extends [never] ? true : ["FuseOptionsV1 is missing documented key(s) — add them with JSDoc above", Exclude<Uncapitalize<keyof typeof FuseV1Options>, keyof FuseOptionsV1>]>;
136
+ export {};
137
+ //# sourceMappingURL=FuseOptionsV1.d.ts.map