@deepseek-ai/dsh-app-boot 0.1.6-alpha.2 → 0.1.7-alpha.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/README.i18n.yaml +2 -2
- package/README.md +34 -14
- package/README.zh.md +34 -14
- package/lib/index.js +1683 -693
- package/lib/types/config-schema/collect.d.ts +16 -0
- package/lib/types/config-schema/document.d.ts +13 -0
- package/lib/types/config-schema/index.d.ts +20 -0
- package/lib/types/config-schema/native.d.ts +9 -0
- package/lib/types/config-schema/pattern.d.ts +8 -0
- package/lib/types/config-schema/projector.d.ts +20 -0
- package/lib/types/config-schema/types.d.ts +95 -0
- package/lib/types/index.d.ts +34 -9
- package/lib/types/package-meta.d.ts +25 -0
- package/lib/types/profile-resolution/legacy-links.d.ts +1 -28
- package/lib/types/profile-resolution/resolver.d.ts +18 -19
- package/lib/types/profile-resolution/service.d.ts +17 -12
- package/lib/types/profile-resolution/worker-bootstrap.d.ts +1 -1
- package/lib/types/profile.d.ts +71 -63
- package/lib/worker/profile-resolution-bootstrap.js +255 -357
- package/package.json +20 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire, isBuiltin } from "node:module";
|
|
2
2
|
import { getEnvironmentData } from "node:worker_threads";
|
|
3
|
-
import { existsSync,
|
|
3
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
//#region ../../../node_modules/.pnpm/resolve.exports@2.0.3/node_modules/resolve.exports/dist/index.mjs
|
|
@@ -41,70 +41,6 @@ function f(e, r, t) {
|
|
|
41
41
|
if (e.imports) return n(e.name, e.imports, r, t);
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region lib/types/profile-resolution/legacy-links.js
|
|
45
|
-
/** Legacy profile-link inspection shared by the disk materializer and runtime resolver. */
|
|
46
|
-
/** Profile-private package links projected into its pnpm-managed node_modules. */
|
|
47
|
-
const PROFILE_MODULE_FALLBACK_DIR = ".dsh-module-fallback";
|
|
48
|
-
/**
|
|
49
|
-
* Return whether the process reads application modules from pkg's virtual filesystem.
|
|
50
|
-
* @returns whether pkg owns the module filesystem.
|
|
51
|
-
*/
|
|
52
|
-
function isPackagedExecutable() {
|
|
53
|
-
return process.pkg !== void 0;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Resolve a directory through the active carrier's filesystem implementation.
|
|
57
|
-
* @param path - directory path to canonicalize.
|
|
58
|
-
* @returns the canonical directory path.
|
|
59
|
-
*/
|
|
60
|
-
function realModuleDirectory(path) {
|
|
61
|
-
return isPackagedExecutable() ? realpathSync(path) : realpathSync.native(path);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolve a link target without following the final path component.
|
|
65
|
-
* @param path - candidate path whose parent is canonicalized.
|
|
66
|
-
* @returns the canonical candidate, or undefined when its parent is absent.
|
|
67
|
-
*/
|
|
68
|
-
function canonicalLinkPath(path) {
|
|
69
|
-
try {
|
|
70
|
-
return join(realModuleDirectory(dirname(path)), basename(path));
|
|
71
|
-
} catch (error) {
|
|
72
|
-
/* v8 ignore next 2 -- a non-ENOENT realpath failure requires a host filesystem fault */
|
|
73
|
-
if (error.code === "ENOENT") return void 0;
|
|
74
|
-
/* v8 ignore next -- see the host-filesystem exception above */
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Return whether a symlink or junction points at the same path as `target`.
|
|
80
|
-
* @param link - symlink or junction to inspect.
|
|
81
|
-
* @param target - expected target path.
|
|
82
|
-
* @returns whether both paths identify the same entry.
|
|
83
|
-
*/
|
|
84
|
-
function symlinkPointsTo(link, target) {
|
|
85
|
-
const canonicalActual = canonicalLinkPath(resolve(dirname(link), readlinkSync(link)));
|
|
86
|
-
const canonicalTarget = canonicalLinkPath(resolve(target));
|
|
87
|
-
return canonicalActual !== void 0 && canonicalActual === canonicalTarget;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Return whether an observed profile package must not claim local precedence.
|
|
91
|
-
* @param profileDir - profile directory containing the package projection.
|
|
92
|
-
* @param packageName - bare package name to inspect.
|
|
93
|
-
* @returns whether the entry is a managed fallback link or disappeared during inspection.
|
|
94
|
-
*/
|
|
95
|
-
function isProfileModuleFallbackLink(profileDir, packageName) {
|
|
96
|
-
const link = join(profileDir, "node_modules", packageName);
|
|
97
|
-
const target = join(profileDir, PROFILE_MODULE_FALLBACK_DIR, "node_modules", packageName);
|
|
98
|
-
try {
|
|
99
|
-
return lstatSync(link).isSymbolicLink() && symlinkPointsTo(link, target);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
/* v8 ignore next 2 -- a vanished candidate cannot claim local precedence */
|
|
102
|
-
if (error.code === "ENOENT") return true;
|
|
103
|
-
/* v8 ignore next -- non-ENOENT lstat/readlink failures require a host filesystem fault */
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
44
|
//#region lib/types/profile-resolution/resolver.js
|
|
109
45
|
/** In-memory profile package routing for Node's default ESM and CommonJS loaders. */
|
|
110
46
|
const EMPTY_ATTRIBUTES = Object.freeze({});
|
|
@@ -133,27 +69,68 @@ function prefixes(path) {
|
|
|
133
69
|
const canonical = canonicalPath(path) + sep;
|
|
134
70
|
return canonical === configured ? [configured] : [configured, canonical];
|
|
135
71
|
}
|
|
136
|
-
function
|
|
137
|
-
const profilePaths = prefixes(generation.profilesDir);
|
|
138
|
-
const profile = generation.profileDir === void 0 ? [] : prefixes(generation.profileDir);
|
|
72
|
+
function compileResolution(resolution) {
|
|
139
73
|
return {
|
|
140
|
-
entries: new Map(
|
|
141
|
-
profilesDir:
|
|
142
|
-
profileDir:
|
|
143
|
-
profilePaths,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
localPackageNames: new Set(
|
|
148
|
-
shared: new Set(profilePaths.map((prefix) => join(prefix, "node_modules"))),
|
|
74
|
+
entries: new Map(resolution.entries.map((entry) => [entry.name, entry])),
|
|
75
|
+
profilesDir: resolution.profilesDir,
|
|
76
|
+
profileDir: resolution.profileDir,
|
|
77
|
+
profilePaths: prefixes(resolution.profilesDir),
|
|
78
|
+
profile: resolution.profileDir === void 0 ? [] : prefixes(resolution.profileDir),
|
|
79
|
+
installationPaths: [...new Set(resolution.entries.filter((entry) => entry.scope === "installation").flatMap((entry) => prefixes(entry.packageDir)))],
|
|
80
|
+
linkedPaths: resolution.linkedRoots.flatMap((root) => prefixes(root.realPath)),
|
|
81
|
+
localPackageNames: new Set(resolution.localPackageNames),
|
|
149
82
|
esmRoutes: /* @__PURE__ */ new Map(),
|
|
150
83
|
cjsRoutes: /* @__PURE__ */ new Map()
|
|
151
84
|
};
|
|
152
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* The interception layer of a profile is `<profileParent>/node_modules`: an entry occupies its name there, so its
|
|
88
|
+
* subpath misses continue above it, and a name without an entry continues at it.
|
|
89
|
+
*/
|
|
90
|
+
function computeProfileLayer(dir, active) {
|
|
91
|
+
const profileParent = dirname(dir);
|
|
92
|
+
return {
|
|
93
|
+
kind: "profile",
|
|
94
|
+
active,
|
|
95
|
+
localPrefix: dir + sep,
|
|
96
|
+
nativeAfter: join(profileParent, "package.json"),
|
|
97
|
+
after: join(dirname(profileParent), "package.json")
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The interception layer of a module path: from its profile directory inside a profiles tree, or its linked root. */
|
|
101
|
+
function findInterceptionLayer(path, resolution) {
|
|
102
|
+
const treeRoot = resolution.profilePaths.find((prefix) => path.startsWith(prefix));
|
|
103
|
+
const activeProfile = resolution.profile.find((prefix) => path.startsWith(prefix));
|
|
104
|
+
const dir = treeRoot !== void 0 ? profileChild(path, treeRoot) : activeProfile?.slice(0, -1);
|
|
105
|
+
if (dir !== void 0) return computeProfileLayer(dir, activeProfile !== void 0);
|
|
106
|
+
if (!startsWithin(path, resolution.linkedPaths)) return void 0;
|
|
107
|
+
if (startsWithin(path, resolution.installationPaths)) return void 0;
|
|
108
|
+
return { kind: "linked" };
|
|
109
|
+
}
|
|
110
|
+
/** Package names a directory's current manifest lists as peers; an unreadable manifest lists none. */
|
|
111
|
+
function readPeerNames(directory) {
|
|
112
|
+
try {
|
|
113
|
+
const peers = JSON.parse(readFileSync(join(directory, "package.json"), "utf8")).peerDependencies;
|
|
114
|
+
return new Set(peers !== null && typeof peers === "object" ? Object.keys(peers) : []);
|
|
115
|
+
} catch (_error) {
|
|
116
|
+
return /* @__PURE__ */ new Set();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
153
119
|
function startsWithin(path, roots) {
|
|
154
120
|
for (const root of roots) if (path.startsWith(root)) return true;
|
|
155
121
|
return false;
|
|
156
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The profile directory owning a module inside the profiles tree: the first path segment below the tree root.
|
|
125
|
+
* @param path - module path below `treePrefix`.
|
|
126
|
+
* @param treePrefix - profiles directory with a trailing separator.
|
|
127
|
+
* @returns the profile directory without a trailing separator.
|
|
128
|
+
*/
|
|
129
|
+
function profileChild(path, treePrefix) {
|
|
130
|
+
const rest = path.slice(treePrefix.length);
|
|
131
|
+
const end = rest.indexOf(sep);
|
|
132
|
+
return treePrefix + (end < 0 ? rest : rest.slice(0, end));
|
|
133
|
+
}
|
|
157
134
|
function nativePackageDir(parent, name) {
|
|
158
135
|
for (const searchPath of createRequire(parent).resolve.paths(name)) {
|
|
159
136
|
const candidate = join(searchPath, name);
|
|
@@ -167,10 +144,7 @@ function localPackageCandidate(searchPath, name, flavor) {
|
|
|
167
144
|
".js",
|
|
168
145
|
".json",
|
|
169
146
|
".node"
|
|
170
|
-
].some((extension) => existsSync(candidate + extension))) ?
|
|
171
|
-
packageDir: candidate,
|
|
172
|
-
canBeManagedLink: stat !== void 0
|
|
173
|
-
} : void 0;
|
|
147
|
+
].some((extension) => existsSync(candidate + extension))) ? candidate : void 0;
|
|
174
148
|
}
|
|
175
149
|
function selfReferenceName(parent) {
|
|
176
150
|
let current = dirname(parent);
|
|
@@ -227,7 +201,7 @@ function packageImportsTarget(parent, request, conditions) {
|
|
|
227
201
|
}
|
|
228
202
|
function packageSearchPaths(entry, request, cjs) {
|
|
229
203
|
const name = barePackageName(request);
|
|
230
|
-
/* v8 ignore next --
|
|
204
|
+
/* v8 ignore next -- interception routes are created only for bare package requests */
|
|
231
205
|
if (name === void 0) return cjs._nodeModulePaths(dirname(entry.declarer));
|
|
232
206
|
const suffix = sep + name.split("/").join(sep);
|
|
233
207
|
return entry.packageDir.endsWith(suffix) ? [entry.packageDir.slice(0, -suffix.length)] : cjs._nodeModulePaths(dirname(entry.declarer));
|
|
@@ -258,62 +232,100 @@ function isUnselectedPackageMiss(error) {
|
|
|
258
232
|
}
|
|
259
233
|
function sameResolution(left, right) {
|
|
260
234
|
if (left === right) return true;
|
|
261
|
-
|
|
262
|
-
const rightPath = right.startsWith("file:") ? fileURLToPath(right) : right;
|
|
263
|
-
return canonicalPath(leftPath) === canonicalPath(rightPath);
|
|
235
|
+
return canonicalPath(left) === canonicalPath(right);
|
|
264
236
|
}
|
|
265
|
-
/** One mutable pointer to immutable
|
|
237
|
+
/** One mutable pointer to the immutable runtime resolution. */
|
|
266
238
|
var ResolutionRouter = class {
|
|
239
|
+
nodeModulePaths;
|
|
267
240
|
current;
|
|
268
|
-
|
|
269
|
-
|
|
241
|
+
linkedTargets;
|
|
242
|
+
constructor(resolution, nodeModulePaths) {
|
|
243
|
+
this.nodeModulePaths = nodeModulePaths;
|
|
244
|
+
this.current = compileResolution(resolution);
|
|
245
|
+
this.linkedTargets = new Map(resolution.linkedRoots.map((root) => [root.name, root.realPath]));
|
|
270
246
|
}
|
|
271
|
-
replace(
|
|
272
|
-
const entries = new Map(
|
|
273
|
-
if (
|
|
247
|
+
replace(successor) {
|
|
248
|
+
const entries = new Map(successor.entries.map((entry) => [entry.name, entry]));
|
|
249
|
+
if (successor.profilesDir !== this.current.profilesDir || successor.profileDir !== this.current.profileDir) throw new Error("profile resolution: a successor cannot change its profile scope");
|
|
274
250
|
for (const [name, current] of this.current.entries) {
|
|
275
251
|
const next = entries.get(name);
|
|
276
252
|
if (next === void 0 || !sameResolution(current.packageDir, next.packageDir) || !sameResolution(current.declarer, next.declarer) || current.version !== next.version || current.scope !== next.scope) throw new Error(`profile resolution: replacing ${JSON.stringify(name)} requires a process restart`);
|
|
277
253
|
}
|
|
278
|
-
const localPackageNames = new Set(
|
|
254
|
+
const localPackageNames = new Set(successor.localPackageNames);
|
|
279
255
|
for (const name of this.current.localPackageNames) if (!localPackageNames.has(name)) throw new Error(`profile resolution: removing local package ${JSON.stringify(name)} requires a process restart`);
|
|
280
256
|
for (const name of localPackageNames) if (!this.current.localPackageNames.has(name) && this.current.entries.has(name)) throw new Error(`profile resolution: overriding ${JSON.stringify(name)} locally requires a process restart`);
|
|
281
|
-
|
|
257
|
+
for (const root of successor.linkedRoots) {
|
|
258
|
+
const previous = this.linkedTargets.get(root.name);
|
|
259
|
+
if (previous !== void 0 && !sameResolution(previous, root.realPath)) throw new Error(`profile resolution: relinking ${JSON.stringify(root.name)} requires a process restart`);
|
|
260
|
+
}
|
|
261
|
+
const next = compileResolution(successor);
|
|
262
|
+
for (const { name, realPath } of successor.linkedRoots) if (!this.linkedTargets.has(name)) this.linkedTargets.set(name, realPath);
|
|
263
|
+
this.current = next;
|
|
264
|
+
}
|
|
265
|
+
/** Whether a module path has an interception layer: it lies in the profiles tree, the active profile, or a linked root. */
|
|
266
|
+
hasInterceptionLayerForPath(path) {
|
|
267
|
+
return findInterceptionLayer(path, this.current) !== void 0;
|
|
268
|
+
}
|
|
269
|
+
/** Whether an importer URL is scoped; the answer is memoized with the importer's routes. */
|
|
270
|
+
hasInterceptionLayerForUrl(parentURL) {
|
|
271
|
+
return this.getOrCreateParentRoutesForUrl(parentURL) !== false;
|
|
272
|
+
}
|
|
273
|
+
createParentRoutes(parent, resolution) {
|
|
274
|
+
const layer = findInterceptionLayer(parent, resolution);
|
|
275
|
+
return layer === void 0 ? void 0 : {
|
|
276
|
+
parent,
|
|
277
|
+
layer,
|
|
278
|
+
requests: /* @__PURE__ */ new Map()
|
|
279
|
+
};
|
|
282
280
|
}
|
|
283
|
-
|
|
284
|
-
const
|
|
281
|
+
getOrCreateParentRoutesForUrl(parentURL) {
|
|
282
|
+
const resolution = this.current;
|
|
283
|
+
let parentRoutes = resolution.esmRoutes.get(parentURL);
|
|
284
|
+
if (parentRoutes !== void 0) return parentRoutes;
|
|
285
|
+
let parent;
|
|
286
|
+
try {
|
|
287
|
+
parent = fileURLToPath(parentURL);
|
|
288
|
+
} catch {
|
|
289
|
+
parent = void 0;
|
|
290
|
+
}
|
|
291
|
+
parentRoutes = parent === void 0 ? false : this.createParentRoutes(parent, resolution) ?? false;
|
|
292
|
+
resolution.esmRoutes.set(parentURL, parentRoutes);
|
|
293
|
+
return parentRoutes;
|
|
294
|
+
}
|
|
295
|
+
routeScoped(request, parentRoutes, resolution, flavor, cjs) {
|
|
296
|
+
const { parent, layer, requests } = parentRoutes;
|
|
297
|
+
const memo = layer.kind === "profile" && (cjs === void 0 || cjs.cacheable);
|
|
285
298
|
const name = barePackageName(request);
|
|
286
299
|
if (name === void 0) return void 0;
|
|
287
|
-
if (parentRoutes.selfReferenceName === void 0) parentRoutes.selfReferenceName = selfReferenceName(parent);
|
|
300
|
+
if (parentRoutes.selfReferenceName === void 0 || !memo) parentRoutes.selfReferenceName = selfReferenceName(parent);
|
|
288
301
|
if (parentRoutes.selfReferenceName === name || parentRoutes.selfReferenceName === null) {
|
|
289
302
|
const state = { route: { kind: "native" } };
|
|
290
|
-
requests.set(request, state);
|
|
303
|
+
if (memo) requests.set(request, state);
|
|
291
304
|
return state;
|
|
292
305
|
}
|
|
293
|
-
|
|
306
|
+
if (layer.kind === "linked") return this.routeLinked(request, name, parent, resolution, flavor, cjs);
|
|
307
|
+
const target = resolution.entries.get(name);
|
|
294
308
|
const candidates = [];
|
|
295
309
|
const localSearchPaths = [];
|
|
296
310
|
for (const searchPath of createRequire(parent).resolve.paths(name)) {
|
|
297
|
-
if (
|
|
311
|
+
if (!searchPath.startsWith(layer.localPrefix)) break;
|
|
298
312
|
localSearchPaths.push(searchPath);
|
|
299
313
|
const candidate = localPackageCandidate(searchPath, name, flavor);
|
|
300
|
-
if (candidate !== void 0)
|
|
301
|
-
if (!(candidate.canBeManagedLink && generation.profile.some((prefix) => candidate.packageDir === join(prefix, "node_modules", name) && isProfileModuleFallbackLink(prefix.slice(0, -1), name)))) candidates.push(candidate);
|
|
302
|
-
}
|
|
314
|
+
if (candidate !== void 0) candidates.push(candidate);
|
|
303
315
|
}
|
|
304
|
-
if (candidates.length > 0) if (
|
|
305
|
-
const resolved =
|
|
306
|
-
const selected = candidates.find((candidate) => localCandidateOwnsResolution(candidate
|
|
316
|
+
if (candidates.length > 0) if (cjs !== void 0) try {
|
|
317
|
+
const resolved = cjs.resolveNative(localSearchPaths);
|
|
318
|
+
const selected = candidates.find((candidate) => localCandidateOwnsResolution(candidate, resolved, request, name));
|
|
307
319
|
if (selected !== void 0) {
|
|
308
320
|
const state = {
|
|
309
321
|
route: {
|
|
310
322
|
kind: "native",
|
|
311
|
-
packageDir: selected
|
|
323
|
+
packageDir: selected
|
|
312
324
|
},
|
|
313
|
-
packageDir: selected
|
|
314
|
-
|
|
325
|
+
packageDir: selected,
|
|
326
|
+
cjs: resolved
|
|
315
327
|
};
|
|
316
|
-
requests.set(request, state);
|
|
328
|
+
if (memo) requests.set(request, state);
|
|
317
329
|
return state;
|
|
318
330
|
}
|
|
319
331
|
} catch (error) {
|
|
@@ -324,122 +336,120 @@ var ResolutionRouter = class {
|
|
|
324
336
|
const state = {
|
|
325
337
|
route: {
|
|
326
338
|
kind: "native",
|
|
327
|
-
packageDir: selected
|
|
339
|
+
packageDir: selected
|
|
328
340
|
},
|
|
329
|
-
packageDir: selected
|
|
341
|
+
packageDir: selected
|
|
330
342
|
};
|
|
331
343
|
requests.set(request, state);
|
|
332
344
|
return state;
|
|
333
345
|
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
const route = eligible ? {
|
|
337
|
-
kind: "fallback",
|
|
346
|
+
const route = target !== void 0 && (target.scope === "installation" || layer.active) ? {
|
|
347
|
+
kind: "interception",
|
|
338
348
|
entry: target,
|
|
339
|
-
after
|
|
349
|
+
after: layer.after
|
|
340
350
|
} : {
|
|
341
|
-
kind: "after-
|
|
342
|
-
parent:
|
|
351
|
+
kind: "native-after-interception",
|
|
352
|
+
parent: layer.nativeAfter
|
|
343
353
|
};
|
|
344
354
|
const state = { route };
|
|
345
|
-
if (route.kind === "
|
|
355
|
+
if (route.kind === "interception" && memo) requests.set(request, state);
|
|
346
356
|
return state;
|
|
347
357
|
}
|
|
348
|
-
|
|
358
|
+
routeLinked(request, name, parent, resolution, flavor, cjs) {
|
|
359
|
+
const target = resolution.entries.get(name);
|
|
360
|
+
if (target === void 0) return { route: { kind: "native" } };
|
|
361
|
+
const ancestors = this.nodeModulePaths(dirname(parent));
|
|
362
|
+
const ancestorSet = new Set(ancestors);
|
|
363
|
+
const searchPaths = flavor === "esm" ? ancestors : createRequire(parent).resolve.paths(name);
|
|
364
|
+
for (const searchPath of searchPaths) {
|
|
365
|
+
const directory = dirname(searchPath);
|
|
366
|
+
if (ancestorSet.has(searchPath) && readPeerNames(directory).has(name)) {
|
|
367
|
+
const route = {
|
|
368
|
+
kind: "interception",
|
|
369
|
+
entry: target,
|
|
370
|
+
after: join(dirname(directory), "package.json")
|
|
371
|
+
};
|
|
372
|
+
if (cjs === void 0) return { route };
|
|
373
|
+
try {
|
|
374
|
+
const resolved = cjs.resolveEntry(target, route.after);
|
|
375
|
+
if (localCandidateOwnsResolution(target.packageDir, resolved, request, name)) return {
|
|
376
|
+
route,
|
|
377
|
+
packageDir: target.packageDir,
|
|
378
|
+
cjs: resolved
|
|
379
|
+
};
|
|
380
|
+
} catch (error) {
|
|
381
|
+
if (!isUnselectedPackageMiss(error)) throw error;
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const candidate = localPackageCandidate(searchPath, name, flavor);
|
|
386
|
+
if (candidate === void 0) continue;
|
|
387
|
+
if (cjs === void 0) return {
|
|
388
|
+
route: {
|
|
389
|
+
kind: "native",
|
|
390
|
+
packageDir: candidate
|
|
391
|
+
},
|
|
392
|
+
packageDir: candidate
|
|
393
|
+
};
|
|
394
|
+
try {
|
|
395
|
+
const resolved = cjs.resolveNative([searchPath]);
|
|
396
|
+
if (localCandidateOwnsResolution(candidate, resolved, request, name)) return {
|
|
397
|
+
route: {
|
|
398
|
+
kind: "native",
|
|
399
|
+
packageDir: candidate
|
|
400
|
+
},
|
|
401
|
+
packageDir: candidate,
|
|
402
|
+
cjs: resolved
|
|
403
|
+
};
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (!isUnselectedPackageMiss(error)) throw error;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return cjs === void 0 ? { route: { kind: "native" } } : {
|
|
409
|
+
route: { kind: "native" },
|
|
410
|
+
cjs: cjs.resolveNative([])
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
routeLocalPackage(request, parentRoutes, resolution) {
|
|
349
414
|
const name = barePackageName(request);
|
|
350
|
-
|
|
415
|
+
const { layer } = parentRoutes;
|
|
416
|
+
if (name === void 0 || layer.kind !== "profile" || !layer.active || !resolution.localPackageNames.has(name)) return void 0;
|
|
351
417
|
const state = { route: { kind: "native" } };
|
|
352
418
|
parentRoutes.requests.set(request, state);
|
|
353
419
|
return state;
|
|
354
420
|
}
|
|
355
421
|
routeUrl(request, parentURL) {
|
|
356
|
-
const
|
|
357
|
-
|
|
422
|
+
const resolution = this.current;
|
|
423
|
+
const parentRoutes = this.getOrCreateParentRoutesForUrl(parentURL);
|
|
358
424
|
if (parentRoutes === false) return void 0;
|
|
359
|
-
const cached = parentRoutes
|
|
425
|
+
const cached = parentRoutes.requests.get(request);
|
|
360
426
|
if (cached !== void 0) return cached;
|
|
361
|
-
|
|
362
|
-
const profileIndex = generation.profileUrls.findIndex((prefix) => parentURL.startsWith(prefix));
|
|
363
|
-
const activeProfileIndex = generation.activeProfileUrls.findIndex((prefix) => parentURL.startsWith(prefix));
|
|
364
|
-
if (profileIndex < 0 && activeProfileIndex < 0) {
|
|
365
|
-
generation.esmRoutes.set(parentURL, false);
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
let parent;
|
|
369
|
-
try {
|
|
370
|
-
parent = fileURLToPath(parentURL);
|
|
371
|
-
} catch {
|
|
372
|
-
generation.esmRoutes.set(parentURL, false);
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
const profileRoot = profileIndex >= 0 ? generation.profilePaths[profileIndex] : generation.profile[activeProfileIndex];
|
|
376
|
-
/* v8 ignore next -- one matching index was established above */
|
|
377
|
-
if (profileRoot === void 0) return void 0;
|
|
378
|
-
parentRoutes = {
|
|
379
|
-
parent,
|
|
380
|
-
profilesDir: profileRoot.slice(0, -1),
|
|
381
|
-
activeProfile: activeProfileIndex >= 0,
|
|
382
|
-
requests: /* @__PURE__ */ new Map()
|
|
383
|
-
};
|
|
384
|
-
generation.esmRoutes.set(parentURL, parentRoutes);
|
|
385
|
-
}
|
|
386
|
-
const local = this.routeLocalPackage(request, parentRoutes, generation);
|
|
427
|
+
const local = this.routeLocalPackage(request, parentRoutes, resolution);
|
|
387
428
|
if (local !== void 0) return local;
|
|
388
|
-
return this.routeScoped(request, parentRoutes,
|
|
429
|
+
return this.routeScoped(request, parentRoutes, resolution, "esm");
|
|
389
430
|
}
|
|
390
|
-
routePath(request, parent,
|
|
391
|
-
const
|
|
392
|
-
let parentRoutes =
|
|
431
|
+
routePath(request, parent, cjs) {
|
|
432
|
+
const resolution = this.current;
|
|
433
|
+
let parentRoutes = resolution.cjsRoutes.get(parent);
|
|
393
434
|
if (parentRoutes === false) return void 0;
|
|
394
|
-
const cached = parentRoutes?.requests.get(request);
|
|
435
|
+
const cached = cjs.cacheable ? parentRoutes?.requests.get(request) : void 0;
|
|
395
436
|
if (cached !== void 0) return cached;
|
|
396
437
|
if (parentRoutes === void 0) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
if (
|
|
400
|
-
const profileRoot = profilesDir ?? activeProfile;
|
|
401
|
-
/* v8 ignore next -- one matching root was established above */
|
|
402
|
-
if (profileRoot === void 0) return void 0;
|
|
403
|
-
parentRoutes = {
|
|
404
|
-
parent,
|
|
405
|
-
profilesDir: profileRoot.slice(0, -1),
|
|
406
|
-
activeProfile: activeProfile !== void 0,
|
|
407
|
-
requests: /* @__PURE__ */ new Map()
|
|
408
|
-
};
|
|
409
|
-
generation.cjsRoutes.set(parent, parentRoutes);
|
|
410
|
-
}
|
|
438
|
+
parentRoutes = this.createParentRoutes(parent, resolution) ?? false;
|
|
439
|
+
resolution.cjsRoutes.set(parent, parentRoutes);
|
|
440
|
+
if (parentRoutes === false) return void 0;
|
|
411
441
|
}
|
|
412
|
-
|
|
413
|
-
generation.cjsRoutes.set(parent, false);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
return this.routeScoped(request, parentRoutes, generation, "cjs", nativeResolve, cacheable);
|
|
417
|
-
}
|
|
418
|
-
explicitRoute(request, paths) {
|
|
419
|
-
if (barePackageName(request) === void 0) return void 0;
|
|
420
|
-
for (const [index, path] of paths.entries()) {
|
|
421
|
-
const parent = join(resolve(path), ".dsh-profile-resolution.cjs");
|
|
422
|
-
if (startsWithin(parent, this.current.profilePaths) || startsWithin(parent, this.current.profile)) return {
|
|
423
|
-
index,
|
|
424
|
-
parent
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
nativeSelfReference(request, parent) {
|
|
429
|
-
const name = barePackageName(request);
|
|
430
|
-
if (name === void 0) return false;
|
|
431
|
-
const self = selfReferenceName(parent);
|
|
432
|
-
return self === name || self === null;
|
|
442
|
+
return this.routeScoped(request, parentRoutes, resolution, "cjs", cjs);
|
|
433
443
|
}
|
|
434
444
|
packageDir(specifier, parentURL) {
|
|
435
445
|
const name = barePackageName(specifier);
|
|
436
446
|
if (name === void 0) return void 0;
|
|
437
|
-
const state = this.routeUrl(
|
|
438
|
-
if (state?.route.kind === "
|
|
447
|
+
const state = this.routeUrl(name, parentURL);
|
|
448
|
+
if (state?.route.kind === "interception") return state.route.entry.packageDir;
|
|
439
449
|
if (state?.packageDir !== void 0) return state.packageDir;
|
|
440
450
|
let parent;
|
|
441
451
|
try {
|
|
442
|
-
parent = state?.route.kind === "after-
|
|
452
|
+
parent = state?.route.kind === "native-after-interception" ? state.route.parent : fileURLToPath(parentURL);
|
|
443
453
|
} catch {
|
|
444
454
|
return;
|
|
445
455
|
}
|
|
@@ -500,46 +510,21 @@ function throwWithoutCjsAnchor(error, anchor) {
|
|
|
500
510
|
}
|
|
501
511
|
throw error;
|
|
502
512
|
}
|
|
503
|
-
function assertEquivalent(actual, expected, request, parent) {
|
|
504
|
-
if (sameResolution(actual, expected)) return;
|
|
505
|
-
throw new Error(`profile resolution mismatch for ${JSON.stringify(request)} from ${parent}: disk resolved ${actual}, generation resolved ${expected}`);
|
|
506
|
-
}
|
|
507
|
-
function assertOptionalEquivalent(actual, expected, request, parent) {
|
|
508
|
-
if (actual === void 0 && expected === void 0) return;
|
|
509
|
-
if (actual !== void 0 && expected !== void 0 && sameResolution(actual, expected)) return;
|
|
510
|
-
throw new Error(`profile resolution mismatch for ${JSON.stringify(request)} from ${parent}: disk selected ${actual ?? "nothing"}, generation selected ${expected ?? "nothing"}`);
|
|
511
|
-
}
|
|
512
513
|
/**
|
|
513
|
-
* Install one
|
|
514
|
-
* @param
|
|
515
|
-
* @
|
|
516
|
-
* @returns a registration that replaces the generation or restores the native methods.
|
|
514
|
+
* Install one runtime resolution as the interception on Node's default ESM and CommonJS resolvers.
|
|
515
|
+
* @param resolution - complete package table and profile scope.
|
|
516
|
+
* @returns an interception that publishes a successor or restores the native methods.
|
|
517
517
|
*/
|
|
518
|
-
function
|
|
519
|
-
const router = new ResolutionRouter(generation);
|
|
518
|
+
function installRuntimeInterception(resolution) {
|
|
520
519
|
const { esm, esmDefaultResolve, esmConditions, cjs, cjsConditions, modern } = internalModules();
|
|
521
|
-
const
|
|
522
|
-
const profilePaths = [...prefixes(generation.profilesDir), ...generation.profileDir === void 0 ? [] : prefixes(generation.profileDir)];
|
|
523
|
-
const profileUrls = profilePaths.map((path) => pathToFileURL(path).href);
|
|
524
|
-
let recentEsmParent;
|
|
525
|
-
let recentEsmScoped = false;
|
|
520
|
+
const router = new ResolutionRouter(resolution, (directory) => cjs._nodeModulePaths(directory));
|
|
526
521
|
let delegatedEsm;
|
|
527
522
|
const adaptEsm = (native) => {
|
|
528
523
|
const adapted = (request, parent, attributes) => {
|
|
529
524
|
const delegated = delegatedEsm;
|
|
530
525
|
/* v8 ignore next -- reentry requires a separate synchronous Node hook; supported launches install none */
|
|
531
526
|
if (delegated !== void 0 && delegated.parent === parent && delegated.request === request) return native(request, parent, attributes);
|
|
532
|
-
if (parent === void 0) return native(request, parent, attributes);
|
|
533
|
-
let scoped = recentEsmParent === parent ? recentEsmScoped : esmScope.get(parent);
|
|
534
|
-
if (scoped === void 0) {
|
|
535
|
-
scoped = startsWithin(parent, profileUrls);
|
|
536
|
-
esmScope.set(parent, scoped);
|
|
537
|
-
}
|
|
538
|
-
if (recentEsmParent !== parent) {
|
|
539
|
-
recentEsmParent = parent;
|
|
540
|
-
recentEsmScoped = scoped;
|
|
541
|
-
}
|
|
542
|
-
if (!scoped) return native(request, parent, attributes);
|
|
527
|
+
if (parent === void 0 || !router.hasInterceptionLayerForUrl(parent)) return native(request, parent, attributes);
|
|
543
528
|
const state = router.routeUrl(request, parent);
|
|
544
529
|
if (state === void 0) {
|
|
545
530
|
const target = request[0] === "#" ? packageImportsTarget(fileURLToPath(parent), request, esmConditions) : void 0;
|
|
@@ -553,16 +538,7 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
553
538
|
} catch (error) {
|
|
554
539
|
return restoreImporter(error);
|
|
555
540
|
}
|
|
556
|
-
|
|
557
|
-
const actual = native(request, parent, attributes);
|
|
558
|
-
/* v8 ignore start -- Node 22 is the asynchronous adapter and is covered by the external version matrix */
|
|
559
|
-
if (expected instanceof Promise || actual instanceof Promise) return Promise.all([actual, expected]).then(([resolved, wanted]) => {
|
|
560
|
-
assertEquivalent(resolved.url, wanted.url, request, parent);
|
|
561
|
-
return resolved;
|
|
562
|
-
});
|
|
563
|
-
/* v8 ignore stop */
|
|
564
|
-
assertEquivalent(actual.url, expected.url, request, parent);
|
|
565
|
-
return actual;
|
|
541
|
+
return expected;
|
|
566
542
|
}
|
|
567
543
|
const cacheable = attributes === EMPTY_ATTRIBUTES || Object.keys(attributes).length === 0;
|
|
568
544
|
if (cacheable && state.esm !== void 0) return state.esm;
|
|
@@ -572,30 +548,7 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
572
548
|
if (cacheable && !(result instanceof Promise)) state.esm = result;
|
|
573
549
|
return result;
|
|
574
550
|
}
|
|
575
|
-
const routedParent = pathToFileURL(route.kind === "
|
|
576
|
-
if (behavior === "enforce") {
|
|
577
|
-
const previous = delegatedEsm;
|
|
578
|
-
delegatedEsm = {
|
|
579
|
-
parent: routedParent,
|
|
580
|
-
request
|
|
581
|
-
};
|
|
582
|
-
const restoreImporter = (error) => throwWithImporter(error, routedParent, parent);
|
|
583
|
-
try {
|
|
584
|
-
let result;
|
|
585
|
-
try {
|
|
586
|
-
result = native(request, routedParent, attributes);
|
|
587
|
-
} catch (error) {
|
|
588
|
-
return restoreImporter(error);
|
|
589
|
-
}
|
|
590
|
-
/* v8 ignore next -- Node 24+ resolves synchronously; the Node 22 matrix covers its Promise result */
|
|
591
|
-
if (result instanceof Promise) return result.catch(restoreImporter);
|
|
592
|
-
if (cacheable) state.esm = result;
|
|
593
|
-
return result;
|
|
594
|
-
} finally {
|
|
595
|
-
delegatedEsm = previous;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const actual = native(request, parent, attributes);
|
|
551
|
+
const routedParent = pathToFileURL(route.kind === "interception" ? route.entry.declarer : route.parent).href;
|
|
599
552
|
const previous = delegatedEsm;
|
|
600
553
|
delegatedEsm = {
|
|
601
554
|
parent: routedParent,
|
|
@@ -603,25 +556,16 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
603
556
|
};
|
|
604
557
|
const restoreImporter = (error) => throwWithImporter(error, routedParent, parent);
|
|
605
558
|
try {
|
|
606
|
-
let
|
|
559
|
+
let result;
|
|
607
560
|
try {
|
|
608
|
-
|
|
609
|
-
expected = result;
|
|
610
|
-
/* v8 ignore next -- Node 24+ resolves synchronously; the Node 22 matrix covers its Promise result */
|
|
611
|
-
if (result instanceof Promise) expected = result.catch(restoreImporter);
|
|
561
|
+
result = native(request, routedParent, attributes);
|
|
612
562
|
} catch (error) {
|
|
613
563
|
return restoreImporter(error);
|
|
614
564
|
}
|
|
615
|
-
/* v8 ignore
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
return resolved;
|
|
620
|
-
});
|
|
621
|
-
/* v8 ignore stop */
|
|
622
|
-
assertEquivalent(actual.url, expected.url, request, parent);
|
|
623
|
-
if (cacheable) state.esm = actual;
|
|
624
|
-
return actual;
|
|
565
|
+
/* v8 ignore next -- Node 24+ resolves synchronously; the Node 22 matrix covers its Promise result */
|
|
566
|
+
if (result instanceof Promise) return result.catch(restoreImporter);
|
|
567
|
+
if (cacheable) state.esm = result;
|
|
568
|
+
return result;
|
|
625
569
|
} finally {
|
|
626
570
|
delegatedEsm = previous;
|
|
627
571
|
}
|
|
@@ -644,7 +588,7 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
644
588
|
]) : resolveRequest(request.specifier, parent, request.attributes ?? EMPTY_ATTRIBUTES);
|
|
645
589
|
loader.resolveSync = wrapped;
|
|
646
590
|
restoreEsm = () => {
|
|
647
|
-
/* v8 ignore else --
|
|
591
|
+
/* v8 ignore else -- interceptions are disposed in reverse installation order */
|
|
648
592
|
if (loader.resolveSync === wrapped) loader.resolveSync = original;
|
|
649
593
|
};
|
|
650
594
|
} else {
|
|
@@ -665,11 +609,11 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
665
609
|
const originalFilename = Reflect.get(cjs, "_resolveFilename");
|
|
666
610
|
let delegatedCjs = 0;
|
|
667
611
|
const resolveRoutedCjs = (request, routed, parent, main, options) => {
|
|
668
|
-
const anchor = routed.kind === "
|
|
612
|
+
const anchor = routed.kind === "interception" ? routed.entry.declarer : routed.parent;
|
|
669
613
|
const synthetic = new cjs(anchor);
|
|
670
614
|
synthetic.parent = parent;
|
|
671
615
|
synthetic.filename = anchor;
|
|
672
|
-
synthetic.paths = routed.kind === "
|
|
616
|
+
synthetic.paths = routed.kind === "interception" ? packageSearchPaths(routed.entry, request, cjs) : cjs._nodeModulePaths(dirname(anchor));
|
|
673
617
|
try {
|
|
674
618
|
return originalFilename.call(cjs, request, synthetic, main, options);
|
|
675
619
|
} catch (error) {
|
|
@@ -678,7 +622,7 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
678
622
|
};
|
|
679
623
|
const resolveNativeCjs = (request, searchPaths, parent, parentFilename, main, conditions) => {
|
|
680
624
|
const synthetic = new cjs(parentFilename);
|
|
681
|
-
synthetic.parent = parent;
|
|
625
|
+
if (parent.parent !== void 0) synthetic.parent = parent.parent;
|
|
682
626
|
synthetic.filename = parentFilename;
|
|
683
627
|
synthetic.paths = [...searchPaths];
|
|
684
628
|
const options = conditions === void 0 ? void 0 : { conditions };
|
|
@@ -694,93 +638,58 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
694
638
|
if (state === void 0) return resolveFrom(target.parentURL);
|
|
695
639
|
if (state.route.kind === "native") return resolveFrom(target.parentURL);
|
|
696
640
|
const route = state.route;
|
|
697
|
-
if (route.kind === "after-
|
|
641
|
+
if (route.kind === "native-after-interception") return resolveFrom(pathToFileURL(route.parent).href);
|
|
698
642
|
return resolveFrom(pathToFileURL(route.entry.declarer).href);
|
|
699
643
|
};
|
|
700
644
|
const wrappedFilename = (request, parent, main, options) => {
|
|
701
|
-
if (delegatedCjs || !parent?.filename) return originalFilename.call(cjs, request, parent, main, options);
|
|
645
|
+
if (delegatedCjs || !parent?.filename || options?.paths !== void 0) return originalFilename.call(cjs, request, parent, main, options);
|
|
702
646
|
const parentFilename = parent.filename;
|
|
703
|
-
const cacheable = options?.
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
647
|
+
const cacheable = options?.conditions === void 0;
|
|
648
|
+
const routedOptions = options?.conditions === void 0 ? void 0 : { conditions: options.conditions };
|
|
649
|
+
const state = router.routePath(request, parentFilename, {
|
|
650
|
+
cacheable,
|
|
651
|
+
resolveNative: (searchPaths) => resolveNativeCjs(request, searchPaths, parent, parentFilename, main, options?.conditions),
|
|
652
|
+
resolveEntry: (entry, after) => {
|
|
653
|
+
delegatedCjs++;
|
|
654
|
+
try {
|
|
655
|
+
return resolveRoutedCjs(request, {
|
|
656
|
+
kind: "interception",
|
|
657
|
+
entry,
|
|
658
|
+
after
|
|
659
|
+
}, parent, main, routedOptions);
|
|
660
|
+
} finally {
|
|
661
|
+
delegatedCjs--;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
});
|
|
717
665
|
if (state === void 0) {
|
|
718
|
-
const scoped =
|
|
666
|
+
const scoped = router.hasInterceptionLayerForPath(parentFilename);
|
|
719
667
|
const conditions = options?.conditions ?? cjsConditions;
|
|
720
668
|
const target = request[0] === "#" && scoped ? packageImportsTarget(parentFilename, request, conditions) : void 0;
|
|
721
669
|
if (target === void 0) return originalFilename.call(cjs, request, parent, main, options);
|
|
722
|
-
|
|
723
|
-
if (behavior === "enforce") return expected;
|
|
724
|
-
const actual = originalFilename.call(cjs, request, parent, main, options);
|
|
725
|
-
assertEquivalent(actual, expected, request, parentFilename);
|
|
726
|
-
return actual;
|
|
670
|
+
return resolvePackageImportCjs(target, conditions);
|
|
727
671
|
}
|
|
728
|
-
if (
|
|
672
|
+
if (state.cjs !== void 0) return state.cjs;
|
|
729
673
|
const route = state.route;
|
|
730
674
|
if (route.kind === "native") {
|
|
731
675
|
const result = originalFilename.call(cjs, request, parent, main, options);
|
|
732
676
|
if (cacheable) state.cjs = result;
|
|
733
677
|
return result;
|
|
734
678
|
}
|
|
735
|
-
if (route.kind === "after-fallback" && explicit !== void 0 && explicitPaths !== void 0) try {
|
|
736
|
-
return originalFilename.call(cjs, request, parent, main, {
|
|
737
|
-
...options,
|
|
738
|
-
paths: [dirname(route.parent)]
|
|
739
|
-
});
|
|
740
|
-
} catch (error) {
|
|
741
|
-
if (!isUnselectedPackageMiss(error)) throw error;
|
|
742
|
-
const remaining = explicitPaths.slice(explicit.index + 1);
|
|
743
|
-
if (remaining.length === 0) throw error;
|
|
744
|
-
return wrappedFilename(request, parent, main, {
|
|
745
|
-
...options,
|
|
746
|
-
paths: remaining
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
679
|
delegatedCjs++;
|
|
750
680
|
try {
|
|
751
|
-
const routedOptions = options?.conditions === void 0 ? void 0 : { conditions: options.conditions };
|
|
752
681
|
let expected;
|
|
753
682
|
try {
|
|
754
683
|
expected = resolveRoutedCjs(request, route, parent, main, routedOptions);
|
|
755
684
|
} catch (error) {
|
|
756
|
-
if (route.kind !== "
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}, parent, main, routedOptions);
|
|
762
|
-
} catch (afterError) {
|
|
763
|
-
const remaining = explicit === void 0 || explicitPaths === void 0 ? [] : explicitPaths.slice(explicit.index + 1);
|
|
764
|
-
if (!isUnselectedPackageMiss(afterError) || remaining.length === 0) throw afterError;
|
|
765
|
-
delegatedCjs--;
|
|
766
|
-
try {
|
|
767
|
-
return wrappedFilename(request, parent, main, {
|
|
768
|
-
...options,
|
|
769
|
-
paths: remaining
|
|
770
|
-
});
|
|
771
|
-
} finally {
|
|
772
|
-
delegatedCjs++;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
685
|
+
if (route.kind !== "interception" || !isUnselectedPackageMiss(error)) throw error;
|
|
686
|
+
expected = resolveRoutedCjs(request, {
|
|
687
|
+
kind: "native-after-interception",
|
|
688
|
+
parent: route.after
|
|
689
|
+
}, parent, main, routedOptions);
|
|
775
690
|
}
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
return expected;
|
|
779
|
-
}
|
|
780
|
-
const actual = originalFilename.call(cjs, request, parent, main, options);
|
|
781
|
-
assertEquivalent(actual, expected, request, parentFilename);
|
|
782
|
-
if (cacheable) state.cjs = actual;
|
|
783
|
-
return actual;
|
|
691
|
+
if (cacheable) state.cjs = expected;
|
|
692
|
+
return expected;
|
|
784
693
|
} finally {
|
|
785
694
|
delegatedCjs--;
|
|
786
695
|
}
|
|
@@ -788,24 +697,13 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
788
697
|
cjs._resolveFilename = wrappedFilename;
|
|
789
698
|
return {
|
|
790
699
|
packageDir(specifier, parentURL) {
|
|
791
|
-
|
|
792
|
-
if (behavior !== "verify" || !startsWithin(parentURL, profileUrls)) return expected;
|
|
793
|
-
const name = barePackageName(specifier);
|
|
794
|
-
if (name === void 0) return expected;
|
|
795
|
-
let parent;
|
|
796
|
-
try {
|
|
797
|
-
parent = fileURLToPath(parentURL);
|
|
798
|
-
} catch {
|
|
799
|
-
return expected;
|
|
800
|
-
}
|
|
801
|
-
assertOptionalEquivalent(nativePackageDir(parent, name), expected, specifier, parentURL);
|
|
802
|
-
return expected;
|
|
700
|
+
return router.packageDir(specifier, parentURL);
|
|
803
701
|
},
|
|
804
702
|
replace(next) {
|
|
805
703
|
router.replace(next);
|
|
806
704
|
},
|
|
807
705
|
dispose() {
|
|
808
|
-
/* v8 ignore else --
|
|
706
|
+
/* v8 ignore else -- interceptions are disposed in reverse installation order */
|
|
809
707
|
if (cjs._resolveFilename === wrappedFilename) cjs._resolveFilename = originalFilename;
|
|
810
708
|
restoreEsm();
|
|
811
709
|
}
|
|
@@ -813,8 +711,8 @@ function installProfileResolution(generation, behavior = "enforce") {
|
|
|
813
711
|
}
|
|
814
712
|
//#endregion
|
|
815
713
|
//#region lib/types/profile-resolution/worker-bootstrap.js
|
|
816
|
-
/** Install
|
|
714
|
+
/** Install the inherited runtime resolution in one Harness-owned Worker. */
|
|
817
715
|
const registration = getEnvironmentData("@deepseek-ai/dsh-app-boot/profile-resolution");
|
|
818
|
-
if (registration !== void 0)
|
|
716
|
+
if (registration !== void 0) installRuntimeInterception(registration.resolution);
|
|
819
717
|
//#endregion
|
|
820
718
|
export {};
|