@pnpm/deps.graph-hasher 1100.2.0 → 1100.2.2

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.
package/lib/index.d.ts CHANGED
@@ -101,6 +101,14 @@ export declare function calcGraphNodeHash<T extends PkgMeta>({ graph, cache, bui
101
101
  nodeVersion?: string;
102
102
  }, pkgMeta: T): string;
103
103
  export declare function calcLeafGlobalVirtualStorePath(fullPkgId: string, name: string, version: string): string;
104
+ /**
105
+ * `subdepIds` maps each direct child's alias to its full pkg id
106
+ * (`${name}@${version}:${integrity}`). Each child contributes a leaf hash
107
+ * (no transitive walk) to the parent's hash, so the resulting path differs
108
+ * whenever the set or versions of children change. One level deep only —
109
+ * use {@link calcGraphNodeHash} when full graph traversal is needed.
110
+ */
111
+ export declare function calcGlobalVirtualStorePathWithSubdeps(fullPkgId: string, name: string, version: string, subdepIds: Record<string, string>): string;
104
112
  export interface PkgMetaAndSnapshot extends PkgMeta {
105
113
  pkgSnapshot: PackageSnapshot;
106
114
  pkgIdWithPatchHash: PkgIdWithPatchHash;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { hashObject, hashObjectWithoutSorting } from '@pnpm/crypto.object-hasher';
2
2
  import { getPkgIdWithPatchHash, refToRelative } from '@pnpm/deps.path';
3
- import { engineName } from '@pnpm/engine.runtime.system-node-version';
3
+ import { engineName } from '@pnpm/engine.runtime.system-version';
4
4
  import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils';
5
5
  import { resolvePlatformSelector, selectPlatformVariant } from '@pnpm/resolving.resolver-base';
6
6
  import { familySync } from 'detect-libc';
@@ -177,6 +177,22 @@ export function calcLeafGlobalVirtualStorePath(fullPkgId, name, version) {
177
177
  const hexDigest = hashObjectWithoutSorting({ engine: null, deps: depsHash }, { encoding: 'hex' });
178
178
  return formatGlobalVirtualStorePath(name, version, hexDigest);
179
179
  }
180
+ /**
181
+ * `subdepIds` maps each direct child's alias to its full pkg id
182
+ * (`${name}@${version}:${integrity}`). Each child contributes a leaf hash
183
+ * (no transitive walk) to the parent's hash, so the resulting path differs
184
+ * whenever the set or versions of children change. One level deep only —
185
+ * use {@link calcGraphNodeHash} when full graph traversal is needed.
186
+ */
187
+ export function calcGlobalVirtualStorePathWithSubdeps(fullPkgId, name, version, subdepIds) {
188
+ const childHashes = {};
189
+ for (const [alias, childFullPkgId] of Object.entries(subdepIds)) {
190
+ childHashes[alias] = hashObject({ id: childFullPkgId, deps: {} });
191
+ }
192
+ const depsHash = hashObject({ id: fullPkgId, deps: childHashes });
193
+ const hexDigest = hashObjectWithoutSorting({ engine: null, deps: depsHash }, { encoding: 'hex' });
194
+ return formatGlobalVirtualStorePath(name, version, hexDigest);
195
+ }
180
196
  // Use @/ prefix for unscoped packages to maintain uniform 4-level directory depth
181
197
  // Scoped: @scope/pkg/version/hash
182
198
  // Unscoped: @/pkg/version/hash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/deps.graph-hasher",
3
- "version": "1100.2.0",
3
+ "version": "1100.2.2",
4
4
  "description": "Calculates the state of a dependency",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -24,18 +24,18 @@
24
24
  "!*.map"
25
25
  ],
26
26
  "dependencies": {
27
- "detect-libc": "^2.0.3",
27
+ "detect-libc": "^2.1.2",
28
28
  "@pnpm/crypto.object-hasher": "1100.0.0",
29
- "@pnpm/deps.path": "1100.0.3",
30
- "@pnpm/lockfile.types": "1100.0.6",
31
- "@pnpm/engine.runtime.system-node-version": "1100.1.0",
32
- "@pnpm/resolving.resolver-base": "1100.2.0",
33
- "@pnpm/types": "1101.1.0",
34
- "@pnpm/lockfile.utils": "1100.0.8"
29
+ "@pnpm/deps.path": "1100.0.5",
30
+ "@pnpm/engine.runtime.system-version": "1100.0.0",
31
+ "@pnpm/lockfile.types": "1100.0.8",
32
+ "@pnpm/lockfile.utils": "1100.0.10",
33
+ "@pnpm/types": "1101.2.0",
34
+ "@pnpm/resolving.resolver-base": "1100.3.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "30.3.0",
38
- "@pnpm/deps.graph-hasher": "1100.2.0"
38
+ "@pnpm/deps.graph-hasher": "1100.2.2"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.13"