gitnexus 1.6.13-rc.20 → 1.6.13-rc.22
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/dist/core/ingestion/import-resolvers/configs/swift.d.ts +12 -9
- package/dist/core/ingestion/import-resolvers/configs/swift.js +35 -27
- package/dist/core/ingestion/language-config.d.ts +32 -0
- package/dist/core/ingestion/language-config.js +809 -7
- package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +8 -5
- package/dist/core/ingestion/languages/swift/implicit-imports.js +14 -13
- package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +9 -13
- package/dist/core/ingestion/languages/swift/import-decomposer.js +213 -23
- package/dist/core/ingestion/languages/swift/import-target.d.ts +9 -21
- package/dist/core/ingestion/languages/swift/import-target.js +140 -34
- package/dist/core/ingestion/languages/swift/interpret.js +11 -7
- package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +8 -7
- package/dist/core/ingestion/languages/swift/scope-resolver.js +19 -12
- package/dist/core/ingestion/languages/swift/sdk-modules.d.ts +9 -0
- package/dist/core/ingestion/languages/swift/sdk-modules.js +28 -0
- package/dist/core/ingestion/languages/swift/target-grouping.d.ts +13 -16
- package/dist/core/ingestion/languages/swift/target-grouping.js +23 -20
- package/dist/core/ingestion/languages/swift/target-siblings.d.ts +7 -4
- package/dist/core/ingestion/languages/swift/target-siblings.js +297 -14
- package/package.json +1 -1
|
@@ -13,15 +13,18 @@
|
|
|
13
13
|
* every strategy invocation, per `import-processor`'s build-once
|
|
14
14
|
* context). Lookup per import is then O(1).
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* starts with `<targetDir
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* A file is attributed to a target iff its **forward-slash
|
|
17
|
+
* (backslash-normalized), case-sensitive** path matches at a
|
|
18
|
+
* **segment boundary**: it starts with `<targetDir>/` or contains
|
|
19
|
+
* `/<targetDir>/`. `normalizedFileList` is
|
|
20
|
+
* only backslash→forward-slash normalized — NOT lowercased — so the
|
|
21
|
+
* match is case-sensitive. The returned paths are the original-case
|
|
22
|
+
* `allFileList` entries, and the per-target file ORDER follows
|
|
23
|
+
* `allFileList`.
|
|
24
|
+
*
|
|
25
|
+
* Import-config fans a file to every matching declared target. Grouping
|
|
26
|
+
* (`groupSwiftFilesBySpmTarget`) is first-target-wins. That divergence
|
|
27
|
+
* is intentional.
|
|
25
28
|
*/
|
|
26
29
|
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
27
30
|
/** Swift Package.swift target map resolution strategy. */
|
|
@@ -13,17 +13,21 @@
|
|
|
13
13
|
* every strategy invocation, per `import-processor`'s build-once
|
|
14
14
|
* context). Lookup per import is then O(1).
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* starts with `<targetDir
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* A file is attributed to a target iff its **forward-slash
|
|
17
|
+
* (backslash-normalized), case-sensitive** path matches at a
|
|
18
|
+
* **segment boundary**: it starts with `<targetDir>/` or contains
|
|
19
|
+
* `/<targetDir>/`. `normalizedFileList` is
|
|
20
|
+
* only backslash→forward-slash normalized — NOT lowercased — so the
|
|
21
|
+
* match is case-sensitive. The returned paths are the original-case
|
|
22
|
+
* `allFileList` entries, and the per-target file ORDER follows
|
|
23
|
+
* `allFileList`.
|
|
24
|
+
*
|
|
25
|
+
* Import-config fans a file to every matching declared target. Grouping
|
|
26
|
+
* (`groupSwiftFilesBySpmTarget`) is first-target-wins. That divergence
|
|
27
|
+
* is intentional.
|
|
25
28
|
*/
|
|
26
29
|
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
30
|
+
import { coerceDeclaredSwiftTargets, swiftDeclaredTargetPrefix } from '../../language-config.js';
|
|
27
31
|
/**
|
|
28
32
|
* Memoized on the `allFileList` array identity. `import-processor` builds
|
|
29
33
|
* the `ResolveCtx` once per run and threads the same object (and the same
|
|
@@ -54,10 +58,10 @@ function getSwiftTargetIndex(ctx, targets) {
|
|
|
54
58
|
// Pre-compute each target's directory prefix once (original case, to
|
|
55
59
|
// match the legacy comparison against the forward-slash-normalized,
|
|
56
60
|
// case-sensitive file list — see module docstring).
|
|
57
|
-
const
|
|
61
|
+
const targetDirs = [];
|
|
58
62
|
const byTarget = new Map();
|
|
59
63
|
for (const [name, dir] of targets) {
|
|
60
|
-
|
|
64
|
+
targetDirs.push({ name, prefix: swiftDeclaredTargetPrefix(dir) });
|
|
61
65
|
byTarget.set(name, []);
|
|
62
66
|
}
|
|
63
67
|
// Single pass over the file list. `normalizedFileList` is forward-slash
|
|
@@ -70,10 +74,12 @@ function getSwiftTargetIndex(ctx, targets) {
|
|
|
70
74
|
const norm = ctx.normalizedFileList[i];
|
|
71
75
|
if (!norm.endsWith('.swift'))
|
|
72
76
|
continue;
|
|
73
|
-
for (const { name, prefix } of
|
|
74
|
-
if (norm.startsWith(prefix)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
for (const { name, prefix } of targetDirs) {
|
|
78
|
+
if (!norm.startsWith(prefix) && !norm.includes(`/${prefix}`))
|
|
79
|
+
continue;
|
|
80
|
+
const bucket = byTarget.get(name);
|
|
81
|
+
if (bucket !== undefined)
|
|
82
|
+
bucket.push(ctx.allFileList[i]);
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
const index = { byTarget };
|
|
@@ -83,19 +89,21 @@ function getSwiftTargetIndex(ctx, targets) {
|
|
|
83
89
|
/** Swift Package.swift target map resolution strategy. */
|
|
84
90
|
export const swiftPackageStrategy = (rawImportPath, _filePath, ctx) => {
|
|
85
91
|
const swiftPackageConfig = ctx.configs.swiftPackageConfig;
|
|
86
|
-
if (swiftPackageConfig)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
if (swiftPackageConfig == null)
|
|
93
|
+
return null;
|
|
94
|
+
const declared = coerceDeclaredSwiftTargets(swiftPackageConfig);
|
|
95
|
+
if (declared == null)
|
|
96
|
+
return null;
|
|
97
|
+
const moduleName = rawImportPath.split('.')[0];
|
|
98
|
+
if (moduleName === '' || !declared.has(moduleName)) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const index = getSwiftTargetIndex(ctx, declared);
|
|
102
|
+
const files = index.byTarget.get(moduleName);
|
|
103
|
+
if (files !== undefined && files.length > 0) {
|
|
104
|
+
return { kind: 'files', files: [...files] };
|
|
97
105
|
}
|
|
98
|
-
return null;
|
|
106
|
+
return null;
|
|
99
107
|
};
|
|
100
108
|
export const swiftImportConfig = {
|
|
101
109
|
language: SupportedLanguages.Swift,
|
|
@@ -64,10 +64,37 @@ export interface CSharpProjectScan {
|
|
|
64
64
|
* Keeps the field mapping in one place so the two carriers can't drift. */
|
|
65
65
|
export declare function csharpScanToEvidence(scan: CSharpProjectScan): CSharpNamespaceEvidence;
|
|
66
66
|
/** Swift Package Manager module config */
|
|
67
|
+
export type SwiftPackageConfigOrigin = 'package.swift' | 'directories';
|
|
67
68
|
export interface SwiftPackageConfig {
|
|
68
69
|
/** Map of target name -> source directory path (e.g., "SiuperModel" -> "Package/Sources/SiuperModel") */
|
|
69
70
|
targets: Map<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* `package.swift` — extracted from a readable Package.swift with no
|
|
73
|
+
* completeness hazards. Explicit import resolve may treat this as a
|
|
74
|
+
* declaration map (empty means every name is external).
|
|
75
|
+
* `directories` — inferred from `Sources/*` (or Package/Sources / src)
|
|
76
|
+
* when no usable declaration exists. Grouping uses this; import resolve
|
|
77
|
+
* must not.
|
|
78
|
+
* Omitted on hand-built test configs: treated as a declaration map so
|
|
79
|
+
* existing `{ targets }` fixtures stay valid.
|
|
80
|
+
*/
|
|
81
|
+
origin?: SwiftPackageConfigOrigin;
|
|
82
|
+
/**
|
|
83
|
+
* Declaration map when `origin` is `package.swift` (may be empty).
|
|
84
|
+
* Grouping uses `targets`, which is this map when it is non-empty and the
|
|
85
|
+
* inferred `Sources/*` map when the declaration is empty — so a
|
|
86
|
+
* binary-only Package.swift does not collapse every file into `__default__`.
|
|
87
|
+
*/
|
|
88
|
+
declaredTargets?: Map<string, string>;
|
|
70
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Declaration view for explicit import resolve. `origin: 'directories'`
|
|
92
|
+
* is grouping-only. A hand-built `{ targets }` with no origin stays a
|
|
93
|
+
* declaration so existing fixtures keep working.
|
|
94
|
+
*/
|
|
95
|
+
export declare function coerceDeclaredSwiftTargets(resolutionConfig: unknown): ReadonlyMap<string, string> | null;
|
|
96
|
+
/** Segment-boundary prefix for a Package.swift `path:`. `"."` / `"./"` is the package root. */
|
|
97
|
+
export declare function swiftDeclaredTargetPrefix(dir: string): string;
|
|
71
98
|
/** Zig package config parsed from build.zig.zon and the root build.zig */
|
|
72
99
|
export interface ZigBuildZonConfig {
|
|
73
100
|
/**
|
|
@@ -185,6 +212,11 @@ export declare function loadComposerConfig(repoRoot: string): Promise<ComposerCo
|
|
|
185
212
|
* windows (see below); directories are still visited breadth-first.
|
|
186
213
|
*/
|
|
187
214
|
export declare function scanCSharpProject(repoRoot: string): Promise<CSharpProjectScan>;
|
|
215
|
+
/** Heuristic Package.swift scan. Never shells out to `swift package dump-package`. */
|
|
216
|
+
export declare function parseSwiftPackageManifest(source: string): {
|
|
217
|
+
targets: Map<string, string>;
|
|
218
|
+
complete: boolean;
|
|
219
|
+
};
|
|
188
220
|
export declare function loadSwiftPackageConfig(repoRoot: string): Promise<SwiftPackageConfig | null>;
|
|
189
221
|
/**
|
|
190
222
|
* Load the Zig build configuration a repo's `build.zig.zon` + root `build.zig`
|