/** * Swift SPM-target file grouping for the registry-primary same-module * hooks (`implicit-imports.ts`, `target-siblings.ts`, * `sibling-type-bindings.ts`). * * A Swift module is an SPM *target* — a directory *subtree* * (`Sources//…`), not a single immediate directory. Grouping by * the immediate containing directory (the prior `containingDir` proxy) * drops cross-directory same-module edges and can mis-resolve a * constructor call to a wrong same-simple-named type in another target. * * This module duplicates the legacy `groupSwiftFilesByTarget` * (`languages/swift.ts`) semantics **verbatim** so the registry-primary * path matches legacy SPM-subtree grouping without touching the legacy * pipeline (hard constraint: legacy stays byte-identical). The SPM target * map is threaded in via the `resolutionConfig` channel * (`loadSwiftPackageConfig` → `resolutionConfig` → these hooks); see * `scope-resolver.ts` and `scope-resolution/pipeline/run.ts`. * * NOTE: This intentionally differs from the import-config module's * leading-`startsWith` (`import-resolvers/configs/swift.ts`): that module * fans a file out to EVERY matching target (a nested file can belong to * multiple configured target dirs there), whereas legacy module grouping * assigns each file to the FIRST matching target only (legacy `break`s) — * one bucket per file. Do not copy the import-config behavior here. */ /** * Group `items` by SPM target subtree, replicating legacy * `groupSwiftFilesByTarget` semantics exactly: * * - `targets` null/empty (no scanned source dir found) → ALL items go to * a single `__default__` bucket (single-Xcode-project assumption). * - Otherwise: a file matches a target when its normalized path either * starts with `/` (`indexOf === 0`) OR contains it at a `/` * boundary (`norm[idx - 1] === '/'`). Each file is assigned to the * FIRST matching target only (one bucket per file, no fan-out). * - Files matching no target fall into the `__default__` bucket. * * `targets` is `name → directory` (the `SwiftPackageConfig.targets` map). */ export declare function groupSwiftFilesBySpmTarget(items: readonly T[], getPath: (item: T) => string, targets: ReadonlyMap | null): Map; /** * Duck-type the opaque `resolutionConfig` (loaded by * `loadSwiftPackageConfig` and threaded through the orchestrator) into the * SPM `targets` map, or `null` when no Swift package config is present. * * Uses structural duck-typing (no `instanceof`) because the value crosses * the `unknown`-typed `resolutionConfig` channel and may be `null`, * `undefined`, or a config object whose `targets` is a `Map`. */ export declare function coerceSwiftTargets(resolutionConfig: unknown): ReadonlyMap | null;