@generaltranslation/vue-extractor 0.0.0 → 0.1.0-iris.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +18 -102
- package/dist/detect.d.ts +8 -0
- package/dist/detect.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/inspect.d.ts +9 -0
- package/dist/inspect.js +2 -0
- package/dist/integration.d.ts +69 -0
- package/dist/integration.js +162 -0
- package/dist/integration.js.map +1 -0
- package/dist/internal/config/configFiles.d.ts +6 -0
- package/dist/internal/config/configFiles.js +34 -0
- package/dist/internal/config/configFiles.js.map +1 -0
- package/dist/internal/config/resolveVueCompilerOptions.d.ts +6 -0
- package/dist/internal/config/resolveVueCompilerOptions.js +74 -56
- package/dist/internal/config/resolveVueCompilerOptions.js.map +1 -1
- package/dist/internal/extractFromVueSource.d.ts +4 -3
- package/dist/internal/extractFromVueSource.js +255 -12
- package/dist/internal/extractFromVueSource.js.map +1 -1
- package/dist/internal/project/consumerUsage.d.ts +34 -0
- package/dist/internal/project/consumerUsage.js +1220 -0
- package/dist/internal/project/consumerUsage.js.map +1 -0
- package/dist/internal/project/detectVueProject.d.ts +13 -0
- package/dist/internal/project/detectVueProject.js +65 -0
- package/dist/internal/project/detectVueProject.js.map +1 -0
- package/dist/internal/project/extractFromVueProject.d.ts +10 -0
- package/dist/internal/project/extractFromVueProject.js +579 -0
- package/dist/internal/project/extractFromVueProject.js.map +1 -0
- package/dist/internal/project/inspectVueProject.d.ts +48 -0
- package/dist/internal/project/inspectVueProject.js +143 -0
- package/dist/internal/project/inspectVueProject.js.map +1 -0
- package/dist/internal/project/manifest.d.ts +64 -0
- package/dist/internal/project/manifest.js +270 -0
- package/dist/internal/project/manifest.js.map +1 -0
- package/dist/internal/project/mergeVueProjectExtraction.d.ts +18 -0
- package/dist/internal/project/mergeVueProjectExtraction.js +79 -0
- package/dist/internal/project/mergeVueProjectExtraction.js.map +1 -0
- package/dist/internal/project/moduleResolver.d.ts +18 -0
- package/dist/internal/project/moduleResolver.js +325 -0
- package/dist/internal/project/moduleResolver.js.map +1 -0
- package/dist/internal/project/scopes.d.ts +31 -0
- package/dist/internal/project/scopes.js +182 -0
- package/dist/internal/project/scopes.js.map +1 -0
- package/dist/internal/project/sourcePatterns.d.ts +4 -0
- package/dist/internal/project/sourcePatterns.js +32 -0
- package/dist/internal/project/sourcePatterns.js.map +1 -0
- package/dist/internal/project/viteAliases.d.ts +42 -0
- package/dist/internal/project/viteAliases.js +1020 -0
- package/dist/internal/project/viteAliases.js.map +1 -0
- package/dist/internal/project/vueSourceClassification.d.ts +13 -0
- package/dist/internal/project/vueSourceClassification.js +146 -0
- package/dist/internal/project/vueSourceClassification.js.map +1 -0
- package/dist/internal/project/workspaces.d.ts +31 -0
- package/dist/internal/project/workspaces.js +326 -0
- package/dist/internal/project/workspaces.js.map +1 -0
- package/dist/internal/project/wrapperProvenance.d.ts +21 -0
- package/dist/internal/project/wrapperProvenance.js +287 -0
- package/dist/internal/project/wrapperProvenance.js.map +1 -0
- package/dist/internal/script/analyze.js +252 -85
- package/dist/internal/script/analyze.js.map +1 -1
- package/dist/internal/script/jsx.d.ts +7 -4
- package/dist/internal/script/jsx.js +351 -79
- package/dist/internal/script/jsx.js.map +1 -1
- package/dist/internal/script/localModules.d.ts +23 -2
- package/dist/internal/script/localModules.js +533 -20
- package/dist/internal/script/localModules.js.map +1 -1
- package/dist/internal/script/model.d.ts +9 -2
- package/dist/internal/script/parser.js +2 -1
- package/dist/internal/script/parser.js.map +1 -1
- package/dist/internal/script/runtimeModules.d.ts +10 -0
- package/dist/internal/script/runtimeModules.js +27 -0
- package/dist/internal/script/runtimeModules.js.map +1 -0
- package/dist/internal/stringCalls.js +1 -1
- package/dist/internal/stringCalls.js.map +1 -1
- package/dist/internal/template.js +263 -141
- package/dist/internal/template.js.map +1 -1
- package/dist/internal/types.d.ts +4 -1
- package/dist/internal/utils.d.ts +14 -3
- package/dist/internal/utils.js +63 -3
- package/dist/internal/utils.js.map +1 -1
- package/dist/internal/vueCompiler.d.ts +9 -1
- package/dist/internal/vueCompiler.js +37 -14
- package/dist/internal/vueCompiler.js.map +1 -1
- package/dist/project.d.ts +11 -0
- package/dist/project.js +3 -0
- package/dist/types.d.ts +95 -4
- package/package.json +30 -4
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { readJavaScriptPackageManifest, resolveInstalledJavaScriptPackage } from "./manifest.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import enhancedResolve from "enhanced-resolve";
|
|
5
|
+
import { createMatchPath } from "tsconfig-paths";
|
|
6
|
+
import { configLoader } from "tsconfig-paths/lib/config-loader.js";
|
|
7
|
+
import { loadTsconfig, walkForTsConfig } from "tsconfig-paths/lib/tsconfig-loader.js";
|
|
8
|
+
//#region src/internal/project/moduleResolver.ts
|
|
9
|
+
const { ResolverFactory } = enhancedResolve;
|
|
10
|
+
const SOURCE_EXTENSIONS = [
|
|
11
|
+
".mjs",
|
|
12
|
+
".js",
|
|
13
|
+
".mts",
|
|
14
|
+
".ts",
|
|
15
|
+
".jsx",
|
|
16
|
+
".tsx",
|
|
17
|
+
".json"
|
|
18
|
+
];
|
|
19
|
+
const SOURCE_EXTENSION_ALIASES = {
|
|
20
|
+
".cjs": [".cjs", ".cts"],
|
|
21
|
+
".js": [
|
|
22
|
+
".js",
|
|
23
|
+
".ts",
|
|
24
|
+
".tsx"
|
|
25
|
+
],
|
|
26
|
+
".jsx": [".jsx", ".tsx"],
|
|
27
|
+
".mjs": [".mjs", ".mts"]
|
|
28
|
+
};
|
|
29
|
+
const VITE_MAIN_FIELDS = [
|
|
30
|
+
"browser",
|
|
31
|
+
"module",
|
|
32
|
+
"jsnext:main",
|
|
33
|
+
"jsnext",
|
|
34
|
+
"main"
|
|
35
|
+
];
|
|
36
|
+
const COMMONJS_SOURCE_EXTENSIONS = new Set([".cjs", ".cts"]);
|
|
37
|
+
const ESM_SYNTAX = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
38
|
+
/** Conditions used by the CLI when no project override is supplied. */
|
|
39
|
+
const DEFAULT_RESOLUTION_CONDITIONS = [
|
|
40
|
+
"module",
|
|
41
|
+
"browser",
|
|
42
|
+
"development|production"
|
|
43
|
+
];
|
|
44
|
+
/** Loads one explicit config without honoring ambient ts-node overrides. */
|
|
45
|
+
function loadExplicitTypeScriptConfig(configPath) {
|
|
46
|
+
const config = loadTsconfig(configPath);
|
|
47
|
+
if (!isUnknownRecord(config)) return invalidTypeScriptConfig("The config root must be an object");
|
|
48
|
+
const compilerOptions = config.compilerOptions;
|
|
49
|
+
if (compilerOptions !== void 0 && !isUnknownRecord(compilerOptions)) return invalidTypeScriptConfig("compilerOptions must be an object");
|
|
50
|
+
const baseUrl = compilerOptions?.baseUrl;
|
|
51
|
+
if (baseUrl !== void 0 && typeof baseUrl !== "string") return invalidTypeScriptConfig("compilerOptions.baseUrl must be a string");
|
|
52
|
+
const configuredPaths = compilerOptions?.paths;
|
|
53
|
+
if (configuredPaths !== void 0 && !isUnknownRecord(configuredPaths)) return invalidTypeScriptConfig("compilerOptions.paths must be an object");
|
|
54
|
+
const paths = {};
|
|
55
|
+
for (const [alias, targets] of Object.entries(configuredPaths ?? {})) {
|
|
56
|
+
if (!Array.isArray(targets) || !targets.every((target) => typeof target === "string")) return invalidTypeScriptConfig(`compilerOptions.paths.${alias} must be an array of strings`);
|
|
57
|
+
paths[alias] = targets;
|
|
58
|
+
}
|
|
59
|
+
return configLoader({
|
|
60
|
+
cwd: path.dirname(configPath),
|
|
61
|
+
tsConfigLoader: () => ({
|
|
62
|
+
tsConfigPath: configPath,
|
|
63
|
+
baseUrl,
|
|
64
|
+
paths
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function invalidTypeScriptConfig(message) {
|
|
69
|
+
return {
|
|
70
|
+
resultType: "failed",
|
|
71
|
+
message
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Creates a deterministic, source-first resolver scoped to one extraction. */
|
|
75
|
+
function createProjectModuleResolver(conditionNames = DEFAULT_RESOLUTION_CONDITIONS, options = {}) {
|
|
76
|
+
const cache = /* @__PURE__ */ new Map();
|
|
77
|
+
const discoveredTsConfigs = /* @__PURE__ */ new Map();
|
|
78
|
+
const explicitTsConfig = options.tsconfigPath === void 0 ? void 0 : loadExplicitTypeScriptConfig(options.tsconfigPath);
|
|
79
|
+
return (specifier, importer) => {
|
|
80
|
+
const cacheKey = `${importer}::${specifier}`;
|
|
81
|
+
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
|
82
|
+
const result = resolveProjectModule(specifier, importer, conditionNames, options, explicitTsConfig, discoveredTsConfigs);
|
|
83
|
+
cache.set(cacheKey, result);
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Resolves local barrels, TypeScript paths, and package export maps. */
|
|
88
|
+
function resolveProjectModule(specifier, importer, conditionNames, options, explicitTsConfig, discoveredTsConfigs) {
|
|
89
|
+
const basedir = path.dirname(importer);
|
|
90
|
+
const extensions = [...SOURCE_EXTENSIONS];
|
|
91
|
+
const isRequire = COMMONJS_SOURCE_EXTENSIONS.has(path.extname(importer).toLowerCase());
|
|
92
|
+
const mainFields = resolveViteMainFields(specifier, basedir, isRequire, options);
|
|
93
|
+
const resolvedConditions = resolveConditionsForImporter(conditionNames, isRequire);
|
|
94
|
+
const tsConfigResult = explicitTsConfig ?? loadNearestTypeScriptConfig(basedir, discoveredTsConfigs);
|
|
95
|
+
if (tsConfigResult.resultType === "success") {
|
|
96
|
+
const matchPath = createMatchPath(tsConfigResult.absoluteBaseUrl, tsConfigResult.paths, mainFields);
|
|
97
|
+
const directMatch = resolveExistingPath(matchPath(specifier, void 0, void 0, extensions), extensions);
|
|
98
|
+
if (directMatch) return directMatch;
|
|
99
|
+
const baseMatch = matchPath(specifier);
|
|
100
|
+
for (const extension of extensions) {
|
|
101
|
+
const explicitMatch = resolveExistingPath(matchPath(`${specifier}${extension}`), extensions);
|
|
102
|
+
if (explicitMatch) return explicitMatch;
|
|
103
|
+
const baseWithExtension = resolveExistingPath(baseMatch ? `${baseMatch}${extension}` : void 0, extensions);
|
|
104
|
+
if (baseWithExtension) return baseWithExtension;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const result = ResolverFactory.createResolver({
|
|
109
|
+
useSyncFileSystemCalls: true,
|
|
110
|
+
fileSystem: fs,
|
|
111
|
+
extensions,
|
|
112
|
+
aliasFields: ["browser"],
|
|
113
|
+
conditionNames: resolvedConditions,
|
|
114
|
+
extensionAlias: SOURCE_EXTENSION_ALIASES,
|
|
115
|
+
exportsFields: ["exports"],
|
|
116
|
+
mainFields
|
|
117
|
+
}).resolveSync({}, basedir, specifier);
|
|
118
|
+
if (typeof result === "string") return result;
|
|
119
|
+
} catch {}
|
|
120
|
+
return resolvePackageExportSourceAlternative(specifier, basedir, resolvedConditions, options);
|
|
121
|
+
}
|
|
122
|
+
/** Discovers the nearest project file without honoring ts-node environment. */
|
|
123
|
+
function loadNearestTypeScriptConfig(basedir, cache) {
|
|
124
|
+
const cached = cache.get(basedir);
|
|
125
|
+
if (cached) return cached;
|
|
126
|
+
const configPath = walkForTsConfig(basedir);
|
|
127
|
+
const result = configPath ? loadExplicitTypeScriptConfig(configPath) : loadConfigWithoutProject();
|
|
128
|
+
if (configPath && result.resultType === "failed") throw new Error(result.message);
|
|
129
|
+
cache.set(basedir, result);
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
function loadConfigWithoutProject() {
|
|
133
|
+
return {
|
|
134
|
+
resultType: "failed",
|
|
135
|
+
message: "Couldn't find tsconfig.json"
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Adds the import kind and expands Vite's mode placeholder deterministically. */
|
|
139
|
+
function resolveConditionsForImporter(conditionNames, isRequire) {
|
|
140
|
+
const modeCondition = conditionNames.includes("production") && !conditionNames.includes("development") ? "production" : "development";
|
|
141
|
+
const conditions = conditionNames.filter((condition) => condition !== "import" && condition !== "require").map((condition) => condition === "development|production" ? modeCondition : condition);
|
|
142
|
+
conditions.push(isRequire ? "require" : "import", "default");
|
|
143
|
+
return [...new Set(conditions)];
|
|
144
|
+
}
|
|
145
|
+
/** Mirrors Vite's browser-entry versus ESM-module compatibility heuristic. */
|
|
146
|
+
function resolveViteMainFields(specifier, basedir, isRequire, options) {
|
|
147
|
+
if (isRequire) return [...VITE_MAIN_FIELDS];
|
|
148
|
+
const packageData = readImportedPackageData(specifier, basedir, options);
|
|
149
|
+
if (!packageData) return [...VITE_MAIN_FIELDS];
|
|
150
|
+
const { directory, manifest } = packageData;
|
|
151
|
+
const browserEntry = typeof manifest.browser === "string" ? manifest.browser : isUnknownRecord(manifest.browser) && typeof manifest.browser["."] === "string" ? manifest.browser["."] : void 0;
|
|
152
|
+
if (!browserEntry || typeof manifest.module !== "string" || manifest.module === browserEntry) return [...VITE_MAIN_FIELDS];
|
|
153
|
+
const browserEntryPath = path.resolve(directory, browserEntry);
|
|
154
|
+
const resolvedBrowserEntry = resolveExistingPath(browserEntryPath, SOURCE_EXTENSIONS) ?? resolveSourceOutputPath(browserEntryPath);
|
|
155
|
+
if (!resolvedBrowserEntry) return [...VITE_MAIN_FIELDS];
|
|
156
|
+
try {
|
|
157
|
+
if (ESM_SYNTAX.test(fs.readFileSync(resolvedBrowserEntry, "utf8"))) return [...VITE_MAIN_FIELDS];
|
|
158
|
+
} catch {
|
|
159
|
+
return [...VITE_MAIN_FIELDS];
|
|
160
|
+
}
|
|
161
|
+
return [
|
|
162
|
+
"module",
|
|
163
|
+
"browser",
|
|
164
|
+
"jsnext:main",
|
|
165
|
+
"jsnext",
|
|
166
|
+
"main"
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
/** Reads the package selected by Node's nearest-node_modules precedence. */
|
|
170
|
+
function readImportedPackageData(specifier, basedir, options = {}) {
|
|
171
|
+
const packageName = readPackageName(specifier);
|
|
172
|
+
if (!packageName) return void 0;
|
|
173
|
+
const selfPackage = options.selfPackage;
|
|
174
|
+
if (selfPackage?.manifest.name === packageName && isWithinDirectory(selfPackage.directory, basedir)) return {
|
|
175
|
+
directory: selfPackage.directory,
|
|
176
|
+
manifest: selfPackage.manifest
|
|
177
|
+
};
|
|
178
|
+
const nearestPackage = readNearestPackageData(basedir);
|
|
179
|
+
if (nearestPackage?.manifest.name === packageName) return nearestPackage;
|
|
180
|
+
const installed = resolveInstalledJavaScriptPackage(basedir, packageName);
|
|
181
|
+
return installed ? {
|
|
182
|
+
directory: installed.directory,
|
|
183
|
+
manifest: installed.manifest
|
|
184
|
+
} : void 0;
|
|
185
|
+
}
|
|
186
|
+
/** Reads only the importer's nearest package scope for self-reference lookup. */
|
|
187
|
+
function readNearestPackageData(basedir) {
|
|
188
|
+
let current = path.resolve(basedir);
|
|
189
|
+
while (true) {
|
|
190
|
+
const manifestPath = path.join(current, "package.json");
|
|
191
|
+
if (fs.existsSync(manifestPath)) {
|
|
192
|
+
const manifest = readJavaScriptPackageManifest(manifestPath);
|
|
193
|
+
return manifest ? {
|
|
194
|
+
directory: current,
|
|
195
|
+
manifest
|
|
196
|
+
} : void 0;
|
|
197
|
+
}
|
|
198
|
+
const parent = path.dirname(current);
|
|
199
|
+
if (parent === current) return void 0;
|
|
200
|
+
current = parent;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Recovers TypeScript source behind a JavaScript package export target.
|
|
205
|
+
*
|
|
206
|
+
* This fallback interprets the package's export map instead of probing its
|
|
207
|
+
* filesystem by subpath. That distinction preserves package encapsulation:
|
|
208
|
+
* an unexported file remains unresolved even when it physically exists.
|
|
209
|
+
*/
|
|
210
|
+
function resolvePackageExportSourceAlternative(specifier, basedir, conditions, options) {
|
|
211
|
+
const packageName = readPackageName(specifier);
|
|
212
|
+
const packageData = readImportedPackageData(specifier, basedir, options);
|
|
213
|
+
if (!packageName || !packageData || packageData.manifest.exports === void 0) return;
|
|
214
|
+
const subpath = specifier === packageName ? "." : `.${specifier.slice(packageName.length)}`;
|
|
215
|
+
const target = resolveExportsTarget(packageData.manifest.exports, subpath, new Set(conditions));
|
|
216
|
+
if (!target || !target.startsWith("./")) return void 0;
|
|
217
|
+
const mappedTarget = applyPackageBrowserMap(target, packageData.manifest);
|
|
218
|
+
if (!mappedTarget || !mappedTarget.startsWith("./")) return void 0;
|
|
219
|
+
const candidate = path.resolve(packageData.directory, mappedTarget);
|
|
220
|
+
const relative = path.relative(packageData.directory, candidate);
|
|
221
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) return;
|
|
222
|
+
return resolveSourceOutputPath(candidate);
|
|
223
|
+
}
|
|
224
|
+
function isWithinDirectory(directory, candidate) {
|
|
225
|
+
const relative = path.relative(path.resolve(directory), path.resolve(candidate));
|
|
226
|
+
return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
227
|
+
}
|
|
228
|
+
/** Resolves the exact or best-pattern subpath before evaluating conditions. */
|
|
229
|
+
function resolveExportsTarget(exportsField, subpath, conditions) {
|
|
230
|
+
if (!isUnknownRecord(exportsField) || isConditionalExports(exportsField)) return subpath === "." ? resolveConditionalTarget(exportsField, conditions) : void 0;
|
|
231
|
+
if (Object.prototype.hasOwnProperty.call(exportsField, subpath)) return resolveConditionalTarget(exportsField[subpath], conditions);
|
|
232
|
+
const pattern = Object.keys(exportsField).filter((key) => key.startsWith("./") && key.includes("*")).map((key) => {
|
|
233
|
+
const star = key.indexOf("*");
|
|
234
|
+
const prefix = key.slice(0, star);
|
|
235
|
+
const suffix = key.slice(star + 1);
|
|
236
|
+
return subpath.startsWith(prefix) && subpath.endsWith(suffix) ? {
|
|
237
|
+
key,
|
|
238
|
+
match: subpath.slice(prefix.length, subpath.length - suffix.length),
|
|
239
|
+
prefixLength: prefix.length,
|
|
240
|
+
suffixLength: suffix.length
|
|
241
|
+
} : void 0;
|
|
242
|
+
}).filter((entry) => entry !== void 0).sort((left, right) => right.prefixLength - left.prefixLength || right.suffixLength - left.suffixLength || right.key.length - left.key.length)[0];
|
|
243
|
+
if (!pattern) return void 0;
|
|
244
|
+
return resolveConditionalTarget(exportsField[pattern.key], conditions)?.replaceAll("*", pattern.match);
|
|
245
|
+
}
|
|
246
|
+
/** Evaluates export conditions in declaration order, matching Node and Vite. */
|
|
247
|
+
function resolveConditionalTarget(target, conditions) {
|
|
248
|
+
if (typeof target === "string") return target;
|
|
249
|
+
if (Array.isArray(target)) {
|
|
250
|
+
for (const candidate of target) {
|
|
251
|
+
const resolved = resolveConditionalTarget(candidate, conditions);
|
|
252
|
+
if (resolved) return resolved;
|
|
253
|
+
}
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!isUnknownRecord(target)) return void 0;
|
|
257
|
+
for (const [condition, candidate] of Object.entries(target)) {
|
|
258
|
+
if (condition !== "default" && !conditions.has(condition)) continue;
|
|
259
|
+
const resolved = resolveConditionalTarget(candidate, conditions);
|
|
260
|
+
if (resolved) return resolved;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function isConditionalExports(exportsField) {
|
|
264
|
+
return Object.keys(exportsField).every((key) => !key.startsWith("."));
|
|
265
|
+
}
|
|
266
|
+
/** Applies the object form of a package browser map to an export target. */
|
|
267
|
+
function applyPackageBrowserMap(target, manifest) {
|
|
268
|
+
if (!isUnknownRecord(manifest.browser)) return target;
|
|
269
|
+
const normalizedTarget = path.posix.normalize(target);
|
|
270
|
+
for (const [key, mapped] of Object.entries(manifest.browser)) {
|
|
271
|
+
const normalizedKey = path.posix.normalize(key);
|
|
272
|
+
if (normalizedTarget !== normalizedKey && !equalWithoutSuffix(normalizedTarget, normalizedKey, ".js") && !equalWithoutSuffix(normalizedTarget, normalizedKey, "/index.js")) continue;
|
|
273
|
+
return typeof mapped === "string" ? mapped : void 0;
|
|
274
|
+
}
|
|
275
|
+
return target;
|
|
276
|
+
}
|
|
277
|
+
function equalWithoutSuffix(target, key, suffix) {
|
|
278
|
+
return key.endsWith(suffix) && key.slice(0, -suffix.length) === target;
|
|
279
|
+
}
|
|
280
|
+
/** Maps emitted JS-family file names to their source equivalents like Vite. */
|
|
281
|
+
function resolveSourceOutputPath(candidate) {
|
|
282
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
|
|
283
|
+
const extension = path.extname(candidate).toLowerCase();
|
|
284
|
+
const alternatives = SOURCE_EXTENSION_ALIASES[extension];
|
|
285
|
+
if (!alternatives) return void 0;
|
|
286
|
+
const stem = candidate.slice(0, -extension.length);
|
|
287
|
+
for (const alternative of alternatives.slice(1)) {
|
|
288
|
+
const source = `${stem}${alternative}`;
|
|
289
|
+
try {
|
|
290
|
+
if (fs.statSync(source).isFile()) return source;
|
|
291
|
+
} catch {}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function readPackageName(specifier) {
|
|
295
|
+
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#")) return;
|
|
296
|
+
const segments = specifier.split("/");
|
|
297
|
+
if (specifier.startsWith("@")) return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : void 0;
|
|
298
|
+
return segments[0];
|
|
299
|
+
}
|
|
300
|
+
function isUnknownRecord(value) {
|
|
301
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
302
|
+
}
|
|
303
|
+
function resolveExistingPath(filePath, extensions) {
|
|
304
|
+
if (!filePath) return void 0;
|
|
305
|
+
try {
|
|
306
|
+
if (fs.existsSync(filePath)) {
|
|
307
|
+
const stats = fs.statSync(filePath);
|
|
308
|
+
if (stats.isFile()) return filePath;
|
|
309
|
+
if (stats.isDirectory()) for (const extension of extensions) {
|
|
310
|
+
const indexPath = path.join(filePath, `index${extension}`);
|
|
311
|
+
if (fs.existsSync(indexPath) && fs.statSync(indexPath).isFile()) return indexPath;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
for (const extension of extensions) {
|
|
315
|
+
const candidate = `${filePath}${extension}`;
|
|
316
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
|
|
317
|
+
}
|
|
318
|
+
} catch {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
export { DEFAULT_RESOLUTION_CONDITIONS, createProjectModuleResolver, loadExplicitTypeScriptConfig };
|
|
324
|
+
|
|
325
|
+
//# sourceMappingURL=moduleResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.js","names":[],"sources":["../../../src/internal/project/moduleResolver.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport enhancedResolve, { type FileSystem } from 'enhanced-resolve';\nimport { createMatchPath, type ConfigLoaderResult } from 'tsconfig-paths';\nimport { configLoader } from 'tsconfig-paths/lib/config-loader.js';\nimport {\n loadTsconfig,\n walkForTsConfig,\n} from 'tsconfig-paths/lib/tsconfig-loader.js';\nimport {\n readJavaScriptPackageManifest,\n resolveInstalledJavaScriptPackage,\n type JavaScriptPackageManifest,\n} from './manifest.js';\n\nconst { ResolverFactory } = enhancedResolve;\n\nconst SOURCE_EXTENSIONS = [\n '.mjs',\n '.js',\n '.mts',\n '.ts',\n '.jsx',\n '.tsx',\n '.json',\n] as const;\n\nconst SOURCE_EXTENSION_ALIASES = {\n '.cjs': ['.cjs', '.cts'],\n '.js': ['.js', '.ts', '.tsx'],\n '.jsx': ['.jsx', '.tsx'],\n '.mjs': ['.mjs', '.mts'],\n};\n\nconst VITE_MAIN_FIELDS = [\n 'browser',\n 'module',\n 'jsnext:main',\n 'jsnext',\n 'main',\n] as const;\n\nconst COMMONJS_SOURCE_EXTENSIONS = new Set(['.cjs', '.cts']);\n\n// Keep this in step with Vite's entry-point heuristic. A package may publish\n// a CommonJS browser build alongside an ESM `module` build; Vite deliberately\n// selects the module build for an ESM importer in that case.\nconst ESM_SYNTAX =\n /(?:[\\s;]|^)(?:import[\\s\\w*,{}]*from|import\\s*[\"'*{]|export\\b\\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\\.meta\\b)/m;\n\n/** Conditions used by the CLI when no project override is supplied. */\nexport const DEFAULT_RESOLUTION_CONDITIONS = [\n 'module',\n 'browser',\n 'development|production',\n] as const;\n\ntype ProjectModuleResolverOptions = {\n /** Package currently being inspected, for standards-compliant self imports. */\n selfPackage?: {\n directory: string;\n manifest: JavaScriptPackageManifest;\n };\n /** Explicit tsconfig.json or jsconfig.json used for every importer. */\n tsconfigPath?: string;\n};\n\n/** Loads one explicit config without honoring ambient ts-node overrides. */\nexport function loadExplicitTypeScriptConfig(\n configPath: string\n): ConfigLoaderResult {\n const config = loadTsconfig(configPath) as unknown;\n if (!isUnknownRecord(config)) {\n return invalidTypeScriptConfig('The config root must be an object');\n }\n const compilerOptions = config.compilerOptions;\n if (compilerOptions !== undefined && !isUnknownRecord(compilerOptions)) {\n return invalidTypeScriptConfig('compilerOptions must be an object');\n }\n const baseUrl = compilerOptions?.baseUrl;\n if (baseUrl !== undefined && typeof baseUrl !== 'string') {\n return invalidTypeScriptConfig('compilerOptions.baseUrl must be a string');\n }\n const configuredPaths = compilerOptions?.paths;\n if (configuredPaths !== undefined && !isUnknownRecord(configuredPaths)) {\n return invalidTypeScriptConfig('compilerOptions.paths must be an object');\n }\n const paths: Record<string, string[]> = {};\n for (const [alias, targets] of Object.entries(configuredPaths ?? {})) {\n if (\n !Array.isArray(targets) ||\n !targets.every((target) => typeof target === 'string')\n ) {\n return invalidTypeScriptConfig(\n `compilerOptions.paths.${alias} must be an array of strings`\n );\n }\n paths[alias] = targets;\n }\n\n return configLoader({\n cwd: path.dirname(configPath),\n tsConfigLoader: () => ({\n tsConfigPath: configPath,\n baseUrl,\n paths,\n }),\n });\n}\n\nfunction invalidTypeScriptConfig(message: string): ConfigLoaderResult {\n return { resultType: 'failed', message };\n}\n\n/** Creates a deterministic, source-first resolver scoped to one extraction. */\nexport function createProjectModuleResolver(\n conditionNames: readonly string[] = DEFAULT_RESOLUTION_CONDITIONS,\n options: ProjectModuleResolverOptions = {}\n): (specifier: string, importer: string) => string | undefined {\n const cache = new Map<string, string | undefined>();\n const discoveredTsConfigs = new Map<string, ConfigLoaderResult>();\n const explicitTsConfig =\n options.tsconfigPath === undefined\n ? undefined\n : loadExplicitTypeScriptConfig(options.tsconfigPath);\n return (specifier, importer) => {\n const cacheKey = `${importer}::${specifier}`;\n if (cache.has(cacheKey)) return cache.get(cacheKey);\n const result = resolveProjectModule(\n specifier,\n importer,\n conditionNames,\n options,\n explicitTsConfig,\n discoveredTsConfigs\n );\n cache.set(cacheKey, result);\n return result;\n };\n}\n\n/** Resolves local barrels, TypeScript paths, and package export maps. */\nfunction resolveProjectModule(\n specifier: string,\n importer: string,\n conditionNames: readonly string[],\n options: ProjectModuleResolverOptions,\n explicitTsConfig: ConfigLoaderResult | undefined,\n discoveredTsConfigs: Map<string, ConfigLoaderResult>\n): string | undefined {\n const basedir = path.dirname(importer);\n const extensions = [...SOURCE_EXTENSIONS];\n const isRequire = COMMONJS_SOURCE_EXTENSIONS.has(\n path.extname(importer).toLowerCase()\n );\n const mainFields = resolveViteMainFields(\n specifier,\n basedir,\n isRequire,\n options\n );\n const resolvedConditions = resolveConditionsForImporter(\n conditionNames,\n isRequire\n );\n\n const tsConfigResult =\n explicitTsConfig ??\n loadNearestTypeScriptConfig(basedir, discoveredTsConfigs);\n if (tsConfigResult.resultType === 'success') {\n const matchPath = createMatchPath(\n tsConfigResult.absoluteBaseUrl,\n tsConfigResult.paths,\n mainFields\n );\n const directMatch = resolveExistingPath(\n matchPath(specifier, undefined, undefined, extensions),\n extensions\n );\n if (directMatch) return directMatch;\n\n const baseMatch = matchPath(specifier);\n for (const extension of extensions) {\n const explicitMatch = resolveExistingPath(\n matchPath(`${specifier}${extension}`),\n extensions\n );\n if (explicitMatch) return explicitMatch;\n const baseWithExtension = resolveExistingPath(\n baseMatch ? `${baseMatch}${extension}` : undefined,\n extensions\n );\n if (baseWithExtension) return baseWithExtension;\n }\n }\n\n try {\n const resolver = ResolverFactory.createResolver({\n useSyncFileSystemCalls: true,\n fileSystem: fs as unknown as FileSystem,\n extensions,\n aliasFields: ['browser'],\n conditionNames: resolvedConditions,\n extensionAlias: SOURCE_EXTENSION_ALIASES,\n exportsFields: ['exports'],\n mainFields,\n });\n const result = resolver.resolveSync({}, basedir, specifier);\n if (typeof result === 'string') return result;\n } catch {\n // Resolution is intentionally final. Falling back to a resolver that\n // ignores `exports` would expose package-private modules that Vite rejects.\n }\n return resolvePackageExportSourceAlternative(\n specifier,\n basedir,\n resolvedConditions,\n options\n );\n}\n\n/** Discovers the nearest project file without honoring ts-node environment. */\nfunction loadNearestTypeScriptConfig(\n basedir: string,\n cache: Map<string, ConfigLoaderResult>\n): ConfigLoaderResult {\n const cached = cache.get(basedir);\n if (cached) return cached;\n const configPath = walkForTsConfig(basedir);\n const result = configPath\n ? loadExplicitTypeScriptConfig(configPath)\n : loadConfigWithoutProject();\n if (configPath && result.resultType === 'failed') {\n throw new Error(result.message);\n }\n cache.set(basedir, result);\n return result;\n}\n\nfunction loadConfigWithoutProject(): ConfigLoaderResult {\n return { resultType: 'failed', message: \"Couldn't find tsconfig.json\" };\n}\n\n/** Adds the import kind and expands Vite's mode placeholder deterministically. */\nfunction resolveConditionsForImporter(\n conditionNames: readonly string[],\n isRequire: boolean\n): string[] {\n const useProduction =\n conditionNames.includes('production') &&\n !conditionNames.includes('development');\n const modeCondition = useProduction ? 'production' : 'development';\n const conditions = conditionNames\n .filter((condition) => condition !== 'import' && condition !== 'require')\n .map((condition) =>\n condition === 'development|production' ? modeCondition : condition\n );\n conditions.push(isRequire ? 'require' : 'import', 'default');\n return [...new Set(conditions)];\n}\n\n/** Mirrors Vite's browser-entry versus ESM-module compatibility heuristic. */\nfunction resolveViteMainFields(\n specifier: string,\n basedir: string,\n isRequire: boolean,\n options: ProjectModuleResolverOptions\n): string[] {\n if (isRequire) return [...VITE_MAIN_FIELDS];\n const packageData = readImportedPackageData(specifier, basedir, options);\n if (!packageData) return [...VITE_MAIN_FIELDS];\n const { directory, manifest } = packageData;\n const browserEntry =\n typeof manifest.browser === 'string'\n ? manifest.browser\n : isUnknownRecord(manifest.browser) &&\n typeof manifest.browser['.'] === 'string'\n ? manifest.browser['.']\n : undefined;\n if (\n !browserEntry ||\n typeof manifest.module !== 'string' ||\n manifest.module === browserEntry\n ) {\n return [...VITE_MAIN_FIELDS];\n }\n const browserEntryPath = path.resolve(directory, browserEntry);\n const resolvedBrowserEntry =\n resolveExistingPath(browserEntryPath, SOURCE_EXTENSIONS) ??\n resolveSourceOutputPath(browserEntryPath);\n if (!resolvedBrowserEntry) return [...VITE_MAIN_FIELDS];\n try {\n if (ESM_SYNTAX.test(fs.readFileSync(resolvedBrowserEntry, 'utf8'))) {\n return [...VITE_MAIN_FIELDS];\n }\n } catch {\n return [...VITE_MAIN_FIELDS];\n }\n return ['module', 'browser', 'jsnext:main', 'jsnext', 'main'];\n}\n\ntype ImportedPackageData = {\n directory: string;\n manifest: Record<string, unknown>;\n};\n\n/** Reads the package selected by Node's nearest-node_modules precedence. */\nfunction readImportedPackageData(\n specifier: string,\n basedir: string,\n options: ProjectModuleResolverOptions = {}\n): ImportedPackageData | undefined {\n const packageName = readPackageName(specifier);\n if (!packageName) return undefined;\n const selfPackage = options.selfPackage;\n if (\n selfPackage?.manifest.name === packageName &&\n isWithinDirectory(selfPackage.directory, basedir)\n ) {\n return {\n directory: selfPackage.directory,\n manifest: selfPackage.manifest as Record<string, unknown>,\n };\n }\n const nearestPackage = readNearestPackageData(basedir);\n if (nearestPackage?.manifest.name === packageName) return nearestPackage;\n const installed = resolveInstalledJavaScriptPackage(basedir, packageName);\n return installed\n ? {\n directory: installed.directory,\n manifest: installed.manifest as Record<string, unknown>,\n }\n : undefined;\n}\n\n/** Reads only the importer's nearest package scope for self-reference lookup. */\nfunction readNearestPackageData(\n basedir: string\n): ImportedPackageData | undefined {\n let current = path.resolve(basedir);\n while (true) {\n const manifestPath = path.join(current, 'package.json');\n if (fs.existsSync(manifestPath)) {\n const manifest = readJavaScriptPackageManifest(manifestPath);\n return manifest\n ? { directory: current, manifest: manifest as Record<string, unknown> }\n : undefined;\n }\n const parent = path.dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n}\n\n/**\n * Recovers TypeScript source behind a JavaScript package export target.\n *\n * This fallback interprets the package's export map instead of probing its\n * filesystem by subpath. That distinction preserves package encapsulation:\n * an unexported file remains unresolved even when it physically exists.\n */\nfunction resolvePackageExportSourceAlternative(\n specifier: string,\n basedir: string,\n conditions: readonly string[],\n options: ProjectModuleResolverOptions\n): string | undefined {\n const packageName = readPackageName(specifier);\n const packageData = readImportedPackageData(specifier, basedir, options);\n if (\n !packageName ||\n !packageData ||\n packageData.manifest.exports === undefined\n ) {\n return undefined;\n }\n const subpath =\n specifier === packageName ? '.' : `.${specifier.slice(packageName.length)}`;\n const target = resolveExportsTarget(\n packageData.manifest.exports,\n subpath,\n new Set(conditions)\n );\n if (!target || !target.startsWith('./')) return undefined;\n const mappedTarget = applyPackageBrowserMap(target, packageData.manifest);\n if (!mappedTarget || !mappedTarget.startsWith('./')) return undefined;\n const candidate = path.resolve(packageData.directory, mappedTarget);\n const relative = path.relative(packageData.directory, candidate);\n if (\n relative === '..' ||\n relative.startsWith(`..${path.sep}`) ||\n path.isAbsolute(relative)\n ) {\n return undefined;\n }\n return resolveSourceOutputPath(candidate);\n}\n\nfunction isWithinDirectory(directory: string, candidate: string): boolean {\n const relative = path.relative(\n path.resolve(directory),\n path.resolve(candidate)\n );\n return (\n relative !== '..' &&\n !relative.startsWith(`..${path.sep}`) &&\n !path.isAbsolute(relative)\n );\n}\n\n/** Resolves the exact or best-pattern subpath before evaluating conditions. */\nfunction resolveExportsTarget(\n exportsField: unknown,\n subpath: string,\n conditions: ReadonlySet<string>\n): string | undefined {\n if (!isUnknownRecord(exportsField) || isConditionalExports(exportsField)) {\n return subpath === '.'\n ? resolveConditionalTarget(exportsField, conditions)\n : undefined;\n }\n if (Object.prototype.hasOwnProperty.call(exportsField, subpath)) {\n return resolveConditionalTarget(exportsField[subpath], conditions);\n }\n const pattern = Object.keys(exportsField)\n .filter((key) => key.startsWith('./') && key.includes('*'))\n .map((key) => {\n const star = key.indexOf('*');\n const prefix = key.slice(0, star);\n const suffix = key.slice(star + 1);\n return subpath.startsWith(prefix) && subpath.endsWith(suffix)\n ? {\n key,\n match: subpath.slice(prefix.length, subpath.length - suffix.length),\n prefixLength: prefix.length,\n suffixLength: suffix.length,\n }\n : undefined;\n })\n .filter((entry): entry is NonNullable<typeof entry> => entry !== undefined)\n .sort(\n (left, right) =>\n right.prefixLength - left.prefixLength ||\n right.suffixLength - left.suffixLength ||\n right.key.length - left.key.length\n )[0];\n if (!pattern) return undefined;\n const target = resolveConditionalTarget(\n exportsField[pattern.key],\n conditions\n );\n return target?.replaceAll('*', pattern.match);\n}\n\n/** Evaluates export conditions in declaration order, matching Node and Vite. */\nfunction resolveConditionalTarget(\n target: unknown,\n conditions: ReadonlySet<string>\n): string | undefined {\n if (typeof target === 'string') return target;\n if (Array.isArray(target)) {\n for (const candidate of target) {\n const resolved = resolveConditionalTarget(candidate, conditions);\n if (resolved) return resolved;\n }\n return undefined;\n }\n if (!isUnknownRecord(target)) return undefined;\n for (const [condition, candidate] of Object.entries(target)) {\n if (condition !== 'default' && !conditions.has(condition)) continue;\n const resolved = resolveConditionalTarget(candidate, conditions);\n if (resolved) return resolved;\n }\n return undefined;\n}\n\nfunction isConditionalExports(exportsField: Record<string, unknown>): boolean {\n return Object.keys(exportsField).every((key) => !key.startsWith('.'));\n}\n\n/** Applies the object form of a package browser map to an export target. */\nfunction applyPackageBrowserMap(\n target: string,\n manifest: Record<string, unknown>\n): string | undefined {\n if (!isUnknownRecord(manifest.browser)) return target;\n const normalizedTarget = path.posix.normalize(target);\n for (const [key, mapped] of Object.entries(manifest.browser)) {\n const normalizedKey = path.posix.normalize(key);\n if (\n normalizedTarget !== normalizedKey &&\n !equalWithoutSuffix(normalizedTarget, normalizedKey, '.js') &&\n !equalWithoutSuffix(normalizedTarget, normalizedKey, '/index.js')\n ) {\n continue;\n }\n return typeof mapped === 'string' ? mapped : undefined;\n }\n return target;\n}\n\nfunction equalWithoutSuffix(\n target: string,\n key: string,\n suffix: string\n): boolean {\n return key.endsWith(suffix) && key.slice(0, -suffix.length) === target;\n}\n\n/** Maps emitted JS-family file names to their source equivalents like Vite. */\nfunction resolveSourceOutputPath(candidate: string): string | undefined {\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return candidate;\n }\n const extension = path.extname(candidate).toLowerCase();\n const alternatives =\n SOURCE_EXTENSION_ALIASES[\n extension as keyof typeof SOURCE_EXTENSION_ALIASES\n ];\n if (!alternatives) return undefined;\n const stem = candidate.slice(0, -extension.length);\n for (const alternative of alternatives.slice(1)) {\n const source = `${stem}${alternative}`;\n try {\n if (fs.statSync(source).isFile()) return source;\n } catch {\n // Try the next source extension.\n }\n }\n return undefined;\n}\n\nfunction readPackageName(specifier: string): string | undefined {\n if (\n !specifier ||\n specifier.startsWith('.') ||\n specifier.startsWith('/') ||\n specifier.startsWith('#')\n ) {\n return undefined;\n }\n const segments = specifier.split('/');\n if (specifier.startsWith('@')) {\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : undefined;\n }\n return segments[0];\n}\n\nfunction isUnknownRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === 'object' && !Array.isArray(value));\n}\n\nfunction resolveExistingPath(\n filePath: string | undefined,\n extensions: readonly string[]\n): string | undefined {\n if (!filePath) return undefined;\n try {\n if (fs.existsSync(filePath)) {\n const stats = fs.statSync(filePath);\n if (stats.isFile()) return filePath;\n if (stats.isDirectory()) {\n for (const extension of extensions) {\n const indexPath = path.join(filePath, `index${extension}`);\n if (fs.existsSync(indexPath) && fs.statSync(indexPath).isFile()) {\n return indexPath;\n }\n }\n }\n }\n for (const extension of extensions) {\n const candidate = `${filePath}${extension}`;\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return candidate;\n }\n }\n } catch {\n return undefined;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,EAAE,oBAAoB;AAE5B,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,2BAA2B;CAC/B,QAAQ,CAAC,QAAQ,OAAO;CACxB,OAAO;EAAC;EAAO;EAAO;EAAO;CAC7B,QAAQ,CAAC,QAAQ,OAAO;CACxB,QAAQ,CAAC,QAAQ,OAAO;CACzB;AAED,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,6BAA6B,IAAI,IAAI,CAAC,QAAQ,OAAO,CAAC;AAK5D,MAAM,aACJ;;AAGF,MAAa,gCAAgC;CAC3C;CACA;CACA;CACD;;AAaD,SAAgB,6BACd,YACoB;CACpB,MAAM,SAAS,aAAa,WAAW;AACvC,KAAI,CAAC,gBAAgB,OAAO,CAC1B,QAAO,wBAAwB,oCAAoC;CAErE,MAAM,kBAAkB,OAAO;AAC/B,KAAI,oBAAoB,KAAA,KAAa,CAAC,gBAAgB,gBAAgB,CACpE,QAAO,wBAAwB,oCAAoC;CAErE,MAAM,UAAU,iBAAiB;AACjC,KAAI,YAAY,KAAA,KAAa,OAAO,YAAY,SAC9C,QAAO,wBAAwB,2CAA2C;CAE5E,MAAM,kBAAkB,iBAAiB;AACzC,KAAI,oBAAoB,KAAA,KAAa,CAAC,gBAAgB,gBAAgB,CACpE,QAAO,wBAAwB,0CAA0C;CAE3E,MAAM,QAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,mBAAmB,EAAE,CAAC,EAAE;AACpE,MACE,CAAC,MAAM,QAAQ,QAAQ,IACvB,CAAC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gBAAgB,WAAuC;AAC9D,KACE,CAAC,aACD,UAAU,WAAW,IAAI,IACzB,UAAU,WAAW,IAAI,IACzB,UAAU,WAAW,IAAI,CAEzB;CAEF,MAAM,WAAW,UAAU,MAAM,IAAI;AACrC,KAAI,UAAU,WAAW,IAAI,CAC3B,QAAO,SAAS,UAAU,IAAI,GAAG,SAAS,GAAG,GAAG,SAAS,OAAO,KAAA;AAElE,QAAO,SAAS;;AAGlB,SAAS,gBAAgB,OAAkD;AACzE,QAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC;;AAG7E,SAAS,oBACP,UACA,YACoB;AACpB,KAAI,CAAC,SAAU,QAAO,KAAA;AACtB,KAAI;AACF,MAAI,GAAG,WAAW,SAAS,EAAE;GAC3B,MAAM,QAAQ,GAAG,SAAS,SAAS;AACnC,OAAI,MAAM,QAAQ,CAAE,QAAO;AAC3B,OAAI,MAAM,aAAa,CACrB,MAAK,MAAM,aAAa,YAAY;IAClC,MAAM,YAAY,KAAK,KAAK,UAAU,QAAQ,YAAY;AAC1D,QAAI,GAAG,WAAW,UAAU,IAAI,GAAG,SAAS,UAAU,CAAC,QAAQ,CAC7D,QAAO;;;AAKf,OAAK,MAAM,aAAa,YAAY;GAClC,MAAM,YAAY,GAAG,WAAW;AAChC,OAAI,GAAG,WAAW,UAAU,IAAI,GAAG,SAAS,UAAU,CAAC,QAAQ,CAC7D,QAAO;;SAGL;AACN"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type WorkspaceDiscoveryCache } from './workspaces.js';
|
|
2
|
+
import { type JavaScriptPackageManifest } from './manifest.js';
|
|
3
|
+
export { DEFAULT_VUE_SOURCE_PATTERNS } from './sourcePatterns.js';
|
|
4
|
+
/** One package boundary whose sources share Vue build configuration. */
|
|
5
|
+
export type VueSourceScope = {
|
|
6
|
+
directory: string;
|
|
7
|
+
includeByDefault: boolean;
|
|
8
|
+
relativeDirectory: string;
|
|
9
|
+
};
|
|
10
|
+
/** Project discovery result reused by detection and extraction. */
|
|
11
|
+
export type VueProjectDiscovery = {
|
|
12
|
+
projectRoot: string;
|
|
13
|
+
rootOwnsVue: boolean;
|
|
14
|
+
rootManifest?: JavaScriptPackageManifest;
|
|
15
|
+
scopes: VueSourceScope[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Discovers only packages that own gt-vue or consume a selected local wrapper.
|
|
19
|
+
*
|
|
20
|
+
* An aggregator root is not scanned merely because one child uses Vue. It is
|
|
21
|
+
* included only when it directly declares gt-vue or depends on a proven local
|
|
22
|
+
* wrapper. This is the boundary that prevents Vue support from broadening
|
|
23
|
+
* existing React source discovery.
|
|
24
|
+
*/
|
|
25
|
+
export declare function discoverVueProject(cwd: string, cache?: WorkspaceDiscoveryCache): VueProjectDiscovery;
|
|
26
|
+
/** Canonicalizes existing roots so macOS path aliases share one ownership tree. */
|
|
27
|
+
export declare function resolveProjectDirectory(directory: string): string;
|
|
28
|
+
/** Returns safe project-root-relative default globs for selected Vue scopes. */
|
|
29
|
+
export declare function readDefaultVueSourcePatterns(scopes: readonly VueSourceScope[]): string[];
|
|
30
|
+
/** Selects the deepest declared Vue package containing a source file. */
|
|
31
|
+
export declare function findVueSourceScope(file: string, scopes: readonly VueSourceScope[]): VueSourceScope | undefined;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { GT_VUE_PACKAGE, declaresAvailableJavaScriptDependency, declaresWorkspaceJavaScriptDependency, dependencyBindingAcceptsPackageVersion, parseLocalDependencyPath, parseNpmDependencyAlias, parseWorkspaceDependencyAlias, readJavaScriptPackageManifest, readPropagatingDependencyBindings, readWorkspaceDependencyBindings, readWorkspaceDependencyNames, resolveInstalledJavaScriptPackage } from "./manifest.js";
|
|
2
|
+
import { DEFAULT_VUE_SOURCE_PATTERNS } from "./sourcePatterns.js";
|
|
3
|
+
import { createConsumerUsageCache, packageConsumesPublicGT, packageExposesPublicGT } from "./consumerUsage.js";
|
|
4
|
+
import { localDependencyGraphDeclaresVue } from "./detectVueProject.js";
|
|
5
|
+
import { createWorkspaceDiscoveryCache, readDeclaredWorkspacePackages } from "./workspaces.js";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import fg from "fast-glob";
|
|
9
|
+
//#region src/internal/project/scopes.ts
|
|
10
|
+
/**
|
|
11
|
+
* Discovers only packages that own gt-vue or consume a selected local wrapper.
|
|
12
|
+
*
|
|
13
|
+
* An aggregator root is not scanned merely because one child uses Vue. It is
|
|
14
|
+
* included only when it directly declares gt-vue or depends on a proven local
|
|
15
|
+
* wrapper. This is the boundary that prevents Vue support from broadening
|
|
16
|
+
* existing React source discovery.
|
|
17
|
+
*/
|
|
18
|
+
function discoverVueProject(cwd, cache = createWorkspaceDiscoveryCache()) {
|
|
19
|
+
const projectRoot = resolveProjectDirectory(cwd);
|
|
20
|
+
const rootManifest = readJavaScriptPackageManifest(path.join(projectRoot, "package.json"));
|
|
21
|
+
if (!rootManifest) return {
|
|
22
|
+
projectRoot,
|
|
23
|
+
rootOwnsVue: false,
|
|
24
|
+
scopes: []
|
|
25
|
+
};
|
|
26
|
+
const workspacePackages = readDeclaredWorkspacePackages(projectRoot, rootManifest, cache);
|
|
27
|
+
const consumerUsageCache = createConsumerUsageCache();
|
|
28
|
+
const workspaceSelection = selectVueWorkspacePackages(workspacePackages, rootManifest, projectRoot, consumerUsageCache);
|
|
29
|
+
const selectedWorkspacePackages = workspaceSelection.packages;
|
|
30
|
+
const rootDeclaresVue = declaresAvailableJavaScriptDependency(rootManifest, GT_VUE_PACKAGE, projectRoot);
|
|
31
|
+
const rootConsumesVueWrapper = consumesSelectedWorkspace({
|
|
32
|
+
directory: projectRoot,
|
|
33
|
+
manifest: rootManifest
|
|
34
|
+
}, selectedWorkspacePackages.filter(({ directory }) => workspaceSelection.propagatingDirectories.has(directory)), consumerUsageCache);
|
|
35
|
+
const rootConsumesLocalVueWrapper = localDependencyGraphDeclaresVue(rootManifest, projectRoot, consumerUsageCache);
|
|
36
|
+
const scopes = [];
|
|
37
|
+
const rootOwnsVue = rootDeclaresVue || rootConsumesVueWrapper || rootConsumesLocalVueWrapper;
|
|
38
|
+
if (rootOwnsVue) scopes.push({
|
|
39
|
+
directory: projectRoot,
|
|
40
|
+
includeByDefault: true,
|
|
41
|
+
relativeDirectory: ""
|
|
42
|
+
});
|
|
43
|
+
for (const { directory } of selectedWorkspacePackages) {
|
|
44
|
+
const relativeDirectory = toPosixPath(path.relative(projectRoot, directory));
|
|
45
|
+
if (!relativeDirectory || relativeDirectory === ".." || relativeDirectory.startsWith("../")) continue;
|
|
46
|
+
scopes.push({
|
|
47
|
+
directory,
|
|
48
|
+
includeByDefault: true,
|
|
49
|
+
relativeDirectory
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
projectRoot,
|
|
54
|
+
rootManifest,
|
|
55
|
+
rootOwnsVue,
|
|
56
|
+
scopes
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Canonicalizes existing roots so macOS path aliases share one ownership tree. */
|
|
60
|
+
function resolveProjectDirectory(directory) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.realpathSync(path.resolve(directory));
|
|
63
|
+
} catch {
|
|
64
|
+
return path.resolve(directory);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Returns safe project-root-relative default globs for selected Vue scopes. */
|
|
68
|
+
function readDefaultVueSourcePatterns(scopes) {
|
|
69
|
+
const patterns = scopes.flatMap(({ includeByDefault, relativeDirectory }) => {
|
|
70
|
+
if (!includeByDefault) return [];
|
|
71
|
+
if (!relativeDirectory) return [...DEFAULT_VUE_SOURCE_PATTERNS];
|
|
72
|
+
const literalDirectory = fg.escapePath(relativeDirectory);
|
|
73
|
+
return DEFAULT_VUE_SOURCE_PATTERNS.map((pattern) => `${literalDirectory}/${pattern}`);
|
|
74
|
+
});
|
|
75
|
+
return [...new Set(patterns)];
|
|
76
|
+
}
|
|
77
|
+
/** Selects the deepest declared Vue package containing a source file. */
|
|
78
|
+
function findVueSourceScope(file, scopes) {
|
|
79
|
+
return [...scopes].sort((left, right) => right.directory.length - left.directory.length).find(({ directory }) => isWithin(directory, file));
|
|
80
|
+
}
|
|
81
|
+
function selectVueWorkspacePackages(workspacePackages, rootManifest, projectRoot, consumerUsageCache) {
|
|
82
|
+
const selectedDirectories = /* @__PURE__ */ new Set();
|
|
83
|
+
const propagatingDirectories = /* @__PURE__ */ new Set();
|
|
84
|
+
const queuedPropagators = /* @__PURE__ */ new Set();
|
|
85
|
+
const pendingPackages = [];
|
|
86
|
+
const publicGTByDirectory = /* @__PURE__ */ new Map();
|
|
87
|
+
const publiclyExposesGT = ({ directory, manifest }) => {
|
|
88
|
+
const cached = publicGTByDirectory.get(directory);
|
|
89
|
+
if (cached !== void 0) return cached;
|
|
90
|
+
const exposesGT = packageExposesPublicGT(directory, manifest, consumerUsageCache);
|
|
91
|
+
publicGTByDirectory.set(directory, exposesGT);
|
|
92
|
+
return exposesGT;
|
|
93
|
+
};
|
|
94
|
+
const selectPackage = (selectedPackage, propagates) => {
|
|
95
|
+
selectedDirectories.add(selectedPackage.directory);
|
|
96
|
+
if (!propagates || queuedPropagators.has(selectedPackage.directory)) return;
|
|
97
|
+
propagatingDirectories.add(selectedPackage.directory);
|
|
98
|
+
queuedPropagators.add(selectedPackage.directory);
|
|
99
|
+
pendingPackages.push(selectedPackage);
|
|
100
|
+
};
|
|
101
|
+
if (declaresAvailableJavaScriptDependency(rootManifest, "gt-vue", projectRoot)) selectPackage({
|
|
102
|
+
directory: projectRoot,
|
|
103
|
+
manifest: rootManifest
|
|
104
|
+
}, publiclyExposesGT({
|
|
105
|
+
directory: projectRoot,
|
|
106
|
+
manifest: rootManifest
|
|
107
|
+
}));
|
|
108
|
+
for (const workspacePackage of workspacePackages) {
|
|
109
|
+
if (!declaresWorkspaceJavaScriptDependency(workspacePackage.manifest, "gt-vue", workspacePackage.directory)) continue;
|
|
110
|
+
selectPackage(workspacePackage, publiclyExposesGT(workspacePackage));
|
|
111
|
+
}
|
|
112
|
+
if (pendingPackages.length === 0) return {
|
|
113
|
+
packages: workspacePackages.filter(({ directory }) => selectedDirectories.has(directory)),
|
|
114
|
+
propagatingDirectories
|
|
115
|
+
};
|
|
116
|
+
const consumersByDependency = /* @__PURE__ */ new Map();
|
|
117
|
+
for (const workspacePackage of workspacePackages) for (const dependencyName of readWorkspaceDependencyNames(workspacePackage.manifest, workspacePackage.directory)) {
|
|
118
|
+
const consumers = consumersByDependency.get(dependencyName) ?? [];
|
|
119
|
+
consumers.push(workspacePackage);
|
|
120
|
+
consumersByDependency.set(dependencyName, consumers);
|
|
121
|
+
}
|
|
122
|
+
for (let index = 0; index < pendingPackages.length; index += 1) {
|
|
123
|
+
const selectedPackage = pendingPackages[index];
|
|
124
|
+
const selectedName = readPackageName(selectedPackage.manifest);
|
|
125
|
+
if (!selectedName) continue;
|
|
126
|
+
for (const consumer of consumersByDependency.get(selectedName) ?? []) {
|
|
127
|
+
if (propagatingDirectories.has(consumer.directory)) continue;
|
|
128
|
+
if (!consumesCompatibleWorkspace(consumer, selectedPackage, false, consumerUsageCache)) continue;
|
|
129
|
+
selectPackage(consumer, consumesCompatibleWorkspace(consumer, selectedPackage, true, consumerUsageCache) && publiclyExposesGT(consumer));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
packages: workspacePackages.filter(({ directory }) => selectedDirectories.has(directory)),
|
|
134
|
+
propagatingDirectories
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function consumesSelectedWorkspace(consumer, selectedPackages, consumerUsageCache) {
|
|
138
|
+
return selectedPackages.some((selectedPackage) => consumesCompatibleWorkspace(consumer, selectedPackage, false, consumerUsageCache));
|
|
139
|
+
}
|
|
140
|
+
/** Checks that a compatible dependency edge is used by consumer source. */
|
|
141
|
+
function consumesCompatibleWorkspace(consumer, selected, propagatingOnly, consumerUsageCache) {
|
|
142
|
+
const packageName = readPackageName(selected.manifest);
|
|
143
|
+
if (!packageName) return false;
|
|
144
|
+
return (propagatingOnly ? readPropagatingDependencyBindings(consumer.manifest, consumer.directory) : readWorkspaceDependencyBindings(consumer.manifest, consumer.directory)).some((binding) => dependencyBindingMatchesWorkspace(binding, packageName, selected, consumer.directory) && packageConsumesPublicGT(consumer.directory, binding.name, selected.directory, selected.manifest, consumerUsageCache));
|
|
145
|
+
}
|
|
146
|
+
function dependencyBindingMatchesWorkspace(binding, workspaceName, selected, consumerDirectory) {
|
|
147
|
+
const workspaceAlias = parseWorkspaceDependencyAlias(binding.specifier);
|
|
148
|
+
const npmAlias = parseNpmDependencyAlias(binding.specifier);
|
|
149
|
+
const catalogPackage = binding.specifier.startsWith("catalog:") ? resolveInstalledJavaScriptPackage(consumerDirectory, binding.name) : void 0;
|
|
150
|
+
const namesWorkspace = binding.name === workspaceName;
|
|
151
|
+
const aliasesWorkspace = workspaceAlias?.packageName === workspaceName || npmAlias?.packageName === workspaceName || catalogPackage?.manifest.name === workspaceName;
|
|
152
|
+
const localPath = parseLocalDependencyPath(binding.specifier);
|
|
153
|
+
if (localPath) return pathsIdentifySameDirectory(path.resolve(consumerDirectory, localPath), selected.directory);
|
|
154
|
+
if (!namesWorkspace && !aliasesWorkspace) return false;
|
|
155
|
+
if (!dependencyBindingAcceptsPackageVersion(binding, workspaceName, selected.manifest.version)) return false;
|
|
156
|
+
const installed = catalogPackage ?? resolveInstalledJavaScriptPackage(consumerDirectory, binding.name);
|
|
157
|
+
if (installed && pathsIdentifySameDirectory(installed.directory, selected.directory)) return true;
|
|
158
|
+
if (workspaceAlias?.packageName === workspaceName) return true;
|
|
159
|
+
if (namesWorkspace && binding.specifier.startsWith("workspace:")) return true;
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
function pathsIdentifySameDirectory(left, right) {
|
|
163
|
+
try {
|
|
164
|
+
return fs.realpathSync(left) === fs.realpathSync(right);
|
|
165
|
+
} catch {
|
|
166
|
+
return path.resolve(left) === path.resolve(right);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function readPackageName(manifest) {
|
|
170
|
+
return typeof manifest.name === "string" && manifest.name ? manifest.name : void 0;
|
|
171
|
+
}
|
|
172
|
+
function isWithin(directory, file) {
|
|
173
|
+
const relative = path.relative(path.resolve(directory), path.resolve(file));
|
|
174
|
+
return relative !== "" && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
175
|
+
}
|
|
176
|
+
function toPosixPath(filePath) {
|
|
177
|
+
return filePath.split(path.sep).join(path.posix.sep);
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { DEFAULT_VUE_SOURCE_PATTERNS, discoverVueProject, findVueSourceScope, readDefaultVueSourcePatterns, resolveProjectDirectory };
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.js","names":[],"sources":["../../../src/internal/project/scopes.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport fg from 'fast-glob';\nimport {\n createWorkspaceDiscoveryCache,\n readDeclaredWorkspacePackages,\n type DeclaredWorkspacePackage,\n type WorkspaceDiscoveryCache,\n} from './workspaces.js';\nimport {\n dependencyBindingAcceptsPackageVersion,\n declaresAvailableJavaScriptDependency,\n declaresWorkspaceJavaScriptDependency,\n GT_VUE_PACKAGE,\n parseLocalDependencyPath,\n parseNpmDependencyAlias,\n parseWorkspaceDependencyAlias,\n readPropagatingDependencyBindings,\n readWorkspaceDependencyBindings,\n readWorkspaceDependencyNames,\n readJavaScriptPackageManifest,\n resolveInstalledJavaScriptPackage,\n type JavaScriptDependencyBinding,\n type JavaScriptPackageManifest,\n} from './manifest.js';\nimport { localDependencyGraphDeclaresVue } from './detectVueProject.js';\nimport {\n createConsumerUsageCache,\n packageConsumesPublicGT,\n packageExposesPublicGT,\n type ConsumerUsageCache,\n} from './consumerUsage.js';\nimport { DEFAULT_VUE_SOURCE_PATTERNS } from './sourcePatterns.js';\n\nexport { DEFAULT_VUE_SOURCE_PATTERNS } from './sourcePatterns.js';\n\n/** One package boundary whose sources share Vue build configuration. */\nexport type VueSourceScope = {\n directory: string;\n includeByDefault: boolean;\n relativeDirectory: string;\n};\n\n/** Project discovery result reused by detection and extraction. */\nexport type VueProjectDiscovery = {\n projectRoot: string;\n rootOwnsVue: boolean;\n rootManifest?: JavaScriptPackageManifest;\n scopes: VueSourceScope[];\n};\n\n/**\n * Discovers only packages that own gt-vue or consume a selected local wrapper.\n *\n * An aggregator root is not scanned merely because one child uses Vue. It is\n * included only when it directly declares gt-vue or depends on a proven local\n * wrapper. This is the boundary that prevents Vue support from broadening\n * existing React source discovery.\n */\nexport function discoverVueProject(\n cwd: string,\n cache: WorkspaceDiscoveryCache = createWorkspaceDiscoveryCache()\n): VueProjectDiscovery {\n const projectRoot = resolveProjectDirectory(cwd);\n const rootManifest = readJavaScriptPackageManifest(\n path.join(projectRoot, 'package.json')\n );\n if (!rootManifest) {\n return { projectRoot, rootOwnsVue: false, scopes: [] };\n }\n\n const workspacePackages = readDeclaredWorkspacePackages(\n projectRoot,\n rootManifest,\n cache\n );\n const consumerUsageCache = createConsumerUsageCache();\n const workspaceSelection = selectVueWorkspacePackages(\n workspacePackages,\n rootManifest,\n projectRoot,\n consumerUsageCache\n );\n const selectedWorkspacePackages = workspaceSelection.packages;\n const rootDeclaresVue = declaresAvailableJavaScriptDependency(\n rootManifest,\n GT_VUE_PACKAGE,\n projectRoot\n );\n const rootConsumesVueWrapper = consumesSelectedWorkspace(\n { directory: projectRoot, manifest: rootManifest },\n selectedWorkspacePackages.filter(({ directory }) =>\n workspaceSelection.propagatingDirectories.has(directory)\n ),\n consumerUsageCache\n );\n const rootConsumesLocalVueWrapper = localDependencyGraphDeclaresVue(\n rootManifest,\n projectRoot,\n consumerUsageCache\n );\n const scopes: VueSourceScope[] = [];\n\n const rootOwnsVue =\n rootDeclaresVue || rootConsumesVueWrapper || rootConsumesLocalVueWrapper;\n if (rootOwnsVue) {\n scopes.push({\n directory: projectRoot,\n includeByDefault: true,\n relativeDirectory: '',\n });\n }\n for (const { directory } of selectedWorkspacePackages) {\n const relativeDirectory = toPosixPath(\n path.relative(projectRoot, directory)\n );\n if (\n !relativeDirectory ||\n relativeDirectory === '..' ||\n relativeDirectory.startsWith('../')\n ) {\n continue;\n }\n scopes.push({\n directory,\n includeByDefault: true,\n relativeDirectory,\n });\n }\n\n return { projectRoot, rootManifest, rootOwnsVue, scopes };\n}\n\n/** Canonicalizes existing roots so macOS path aliases share one ownership tree. */\nexport function resolveProjectDirectory(directory: string): string {\n try {\n return fs.realpathSync(path.resolve(directory));\n } catch {\n return path.resolve(directory);\n }\n}\n\n/** Returns safe project-root-relative default globs for selected Vue scopes. */\nexport function readDefaultVueSourcePatterns(\n scopes: readonly VueSourceScope[]\n): string[] {\n const patterns = scopes.flatMap(({ includeByDefault, relativeDirectory }) => {\n if (!includeByDefault) return [];\n if (!relativeDirectory) return [...DEFAULT_VUE_SOURCE_PATTERNS];\n const literalDirectory = fg.escapePath(relativeDirectory);\n return DEFAULT_VUE_SOURCE_PATTERNS.map(\n (pattern) => `${literalDirectory}/${pattern}`\n );\n });\n return [...new Set(patterns)];\n}\n\n/** Selects the deepest declared Vue package containing a source file. */\nexport function findVueSourceScope(\n file: string,\n scopes: readonly VueSourceScope[]\n): VueSourceScope | undefined {\n return [...scopes]\n .sort((left, right) => right.directory.length - left.directory.length)\n .find(({ directory }) => isWithin(directory, file));\n}\n\nfunction selectVueWorkspacePackages(\n workspacePackages: readonly DeclaredWorkspacePackage[],\n rootManifest: JavaScriptPackageManifest,\n projectRoot: string,\n consumerUsageCache: ConsumerUsageCache\n): {\n packages: DeclaredWorkspacePackage[];\n propagatingDirectories: Set<string>;\n} {\n const selectedDirectories = new Set<string>();\n const propagatingDirectories = new Set<string>();\n const queuedPropagators = new Set<string>();\n const pendingPackages: DeclaredWorkspacePackage[] = [];\n const publicGTByDirectory = new Map<string, boolean>();\n const publiclyExposesGT = ({\n directory,\n manifest,\n }: DeclaredWorkspacePackage): boolean => {\n const cached = publicGTByDirectory.get(directory);\n if (cached !== undefined) return cached;\n const exposesGT = packageExposesPublicGT(\n directory,\n manifest,\n consumerUsageCache\n );\n publicGTByDirectory.set(directory, exposesGT);\n return exposesGT;\n };\n const selectPackage = (\n selectedPackage: DeclaredWorkspacePackage,\n propagates: boolean\n ) => {\n selectedDirectories.add(selectedPackage.directory);\n if (!propagates || queuedPropagators.has(selectedPackage.directory)) {\n return;\n }\n propagatingDirectories.add(selectedPackage.directory);\n queuedPropagators.add(selectedPackage.directory);\n pendingPackages.push(selectedPackage);\n };\n if (\n declaresAvailableJavaScriptDependency(\n rootManifest,\n GT_VUE_PACKAGE,\n projectRoot\n )\n ) {\n selectPackage(\n { directory: projectRoot, manifest: rootManifest },\n publiclyExposesGT({ directory: projectRoot, manifest: rootManifest })\n );\n }\n for (const workspacePackage of workspacePackages) {\n if (\n !declaresWorkspaceJavaScriptDependency(\n workspacePackage.manifest,\n GT_VUE_PACKAGE,\n workspacePackage.directory\n )\n ) {\n continue;\n }\n selectPackage(workspacePackage, publiclyExposesGT(workspacePackage));\n }\n\n // A pure non-Vue workspace has no ownership seed to propagate. Avoid\n // walking every dependency edge after the manifest scan has already proved\n // that no package directly owns gt-vue.\n if (pendingPackages.length === 0) {\n return {\n packages: workspacePackages.filter(({ directory }) =>\n selectedDirectories.has(directory)\n ),\n propagatingDirectories,\n };\n }\n\n const consumersByDependency = new Map<string, DeclaredWorkspacePackage[]>();\n for (const workspacePackage of workspacePackages) {\n for (const dependencyName of readWorkspaceDependencyNames(\n workspacePackage.manifest,\n workspacePackage.directory\n )) {\n const consumers = consumersByDependency.get(dependencyName) ?? [];\n consumers.push(workspacePackage);\n consumersByDependency.set(dependencyName, consumers);\n }\n }\n\n for (let index = 0; index < pendingPackages.length; index += 1) {\n const selectedPackage = pendingPackages[index]!;\n const selectedName = readPackageName(selectedPackage.manifest);\n if (!selectedName) continue;\n for (const consumer of consumersByDependency.get(selectedName) ?? []) {\n if (propagatingDirectories.has(consumer.directory)) continue;\n if (\n !consumesCompatibleWorkspace(\n consumer,\n selectedPackage,\n false,\n consumerUsageCache\n )\n ) {\n continue;\n }\n selectPackage(\n consumer,\n consumesCompatibleWorkspace(\n consumer,\n selectedPackage,\n true,\n consumerUsageCache\n ) && publiclyExposesGT(consumer)\n );\n }\n }\n\n return {\n packages: workspacePackages.filter(({ directory }) =>\n selectedDirectories.has(directory)\n ),\n propagatingDirectories,\n };\n}\n\nfunction consumesSelectedWorkspace(\n consumer: DeclaredWorkspacePackage,\n selectedPackages: readonly DeclaredWorkspacePackage[],\n consumerUsageCache: ConsumerUsageCache\n): boolean {\n return selectedPackages.some((selectedPackage) =>\n consumesCompatibleWorkspace(\n consumer,\n selectedPackage,\n false,\n consumerUsageCache\n )\n );\n}\n\n/** Checks that a compatible dependency edge is used by consumer source. */\nfunction consumesCompatibleWorkspace(\n consumer: DeclaredWorkspacePackage,\n selected: DeclaredWorkspacePackage,\n propagatingOnly: boolean,\n consumerUsageCache: ConsumerUsageCache\n): boolean {\n const packageName = readPackageName(selected.manifest);\n if (!packageName) return false;\n const bindings = propagatingOnly\n ? readPropagatingDependencyBindings(consumer.manifest, consumer.directory)\n : readWorkspaceDependencyBindings(consumer.manifest, consumer.directory);\n return bindings.some(\n (binding) =>\n dependencyBindingMatchesWorkspace(\n binding,\n packageName,\n selected,\n consumer.directory\n ) &&\n packageConsumesPublicGT(\n consumer.directory,\n binding.name,\n selected.directory,\n selected.manifest,\n consumerUsageCache\n )\n );\n}\n\nfunction dependencyBindingMatchesWorkspace(\n binding: JavaScriptDependencyBinding,\n workspaceName: string,\n selected: DeclaredWorkspacePackage,\n consumerDirectory: string\n): boolean {\n const workspaceAlias = parseWorkspaceDependencyAlias(binding.specifier);\n const npmAlias = parseNpmDependencyAlias(binding.specifier);\n const catalogPackage = binding.specifier.startsWith('catalog:')\n ? resolveInstalledJavaScriptPackage(consumerDirectory, binding.name)\n : undefined;\n const namesWorkspace = binding.name === workspaceName;\n const aliasesWorkspace =\n workspaceAlias?.packageName === workspaceName ||\n npmAlias?.packageName === workspaceName ||\n catalogPackage?.manifest.name === workspaceName;\n const localPath = parseLocalDependencyPath(binding.specifier);\n\n if (localPath) {\n return pathsIdentifySameDirectory(\n path.resolve(consumerDirectory, localPath),\n selected.directory\n );\n }\n if (!namesWorkspace && !aliasesWorkspace) return false;\n if (\n !dependencyBindingAcceptsPackageVersion(\n binding,\n workspaceName,\n selected.manifest.version\n )\n ) {\n return false;\n }\n\n const installed =\n catalogPackage ??\n resolveInstalledJavaScriptPackage(consumerDirectory, binding.name);\n if (\n installed &&\n pathsIdentifySameDirectory(installed.directory, selected.directory)\n ) {\n return true;\n }\n\n if (workspaceAlias?.packageName === workspaceName) {\n return true;\n }\n if (namesWorkspace && binding.specifier.startsWith('workspace:')) {\n return true;\n }\n // Bare semver, catalogs, and npm aliases may resolve to a registry package.\n // They select a local wrapper only when the installed binding proves it.\n return false;\n}\n\nfunction pathsIdentifySameDirectory(left: string, right: string): boolean {\n try {\n return fs.realpathSync(left) === fs.realpathSync(right);\n } catch {\n return path.resolve(left) === path.resolve(right);\n }\n}\n\nfunction readPackageName(\n manifest: JavaScriptPackageManifest\n): string | undefined {\n return typeof manifest.name === 'string' && manifest.name\n ? manifest.name\n : undefined;\n}\n\nfunction isWithin(directory: string, file: string): boolean {\n const relative = path.relative(path.resolve(directory), path.resolve(file));\n return (\n relative !== '' &&\n relative !== '..' &&\n !relative.startsWith(`..${path.sep}`) &&\n !path.isAbsolute(relative)\n );\n}\n\nfunction toPosixPath(filePath: string): string {\n return filePath.split(path.sep).join(path.posix.sep);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2DA,SAAgB,mBACd,KACA,QAAiC,+BAA+B,EAC3C;CACrB,MAAM,cAAc,wBAAwB,IAAI;CAChD,MAAM,eAAe,8BACnB,KAAK,KAAK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UAA0B;AAC7C,QAAO,SAAS,MAAM,KAAK,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Conventional source directories searched by default for Vue applications. */
|
|
2
|
+
export declare const DEFAULT_VUE_SOURCE_DIRECTORIES: readonly ["src", "app", "pages", "components", "composables", "layers", "layouts", "middleware", "modules", "plugins", "server", "shared", "stores", "utils", "views"];
|
|
3
|
+
/** Default Vue source patterns, including conventional Vue and Nuxt folders. */
|
|
4
|
+
export declare const DEFAULT_VUE_SOURCE_PATTERNS: readonly ["*.vue", "src/**/*.{vue,js,jsx,mjs,cjs,ts,tsx,mts,cts}", "app/**/*.{vue,js,jsx,mjs,cjs,ts,tsx,mts,cts}", "pages/**/*.{vue,js,jsx,mjs,cjs,ts,tsx,mts,cts}", "components/**/*.{vue,js,jsx,mjs,cjs,ts,tsx,mts,cts}", "{composables,layers,layouts,middleware,modules,plugins,server,shared,stores,utils,views}/**/*.{vue,js,jsx,mjs,cjs,ts,tsx,mts,cts}"];
|