/** * Source-span replacement helpers for import rewrites. * * @module transforms/mdx/esm-module-loader/utils/source-spans */ export interface SourceSpanReplacement { start: number; end: number; replacement: string; expected?: string; } export interface StaticImportSpan { original: string; path: string; start: number; end: number; /** Whether TypeScript erases the complete static import or export edge. */ typeOnly?: boolean; } type SpecifierMatcher = (specifier: string) => string | null | undefined; export declare function replaceSourceSpans(source: string, replacements: SourceSpanReplacement[]): string; /** * Whether the word ending at `previousTokenIndex` is a member name, not a keyword. * * Every keyword the classifier accepts as a regex prefix is also a legal * property name in ES5+, so `metrics.in / 2` and `metrics.return / 2` are * ordinary code in which the slash divides. Reading the word as a keyword * opens a regex literal that never closes, and the scan then swallows the rest * of the module — every later import disappears from nested materialization * and from dependency collection alike. * * Covers `.name`, optional chaining `?.name` (the character before the word is * `.` either way) and private fields `#name`. */ export declare function isMemberNameBefore(source: string, previousTokenIndex: number): boolean; export declare function findStaticImportFromSpans(source: string, matcher: SpecifierMatcher, maxMatches: number): StaticImportSpan[]; /** * Find `import("…")` expressions with a literal specifier. * * The returned span covers the quoted specifier itself (quotes included), not * the surrounding `import(...)`, so a replacement is a bare quoted string. * * A literal here is a single- or double-quoted string, or a backtick template * with no `${}` substitution — the three forms whose target is fully known at * scan time. An interpolated template and any other expression are skipped, * since their target is only known at runtime. So is an argument the literal * merely starts: rewriting the `"./foo"` in `import("./foo" + suffix)` would * build a path out of a resolved prefix and an unresolved tail. * * The scan also runs inside template substitutions, so a dynamic import nested * in a `${…}` expression is found. * * `maxMatches` bounds the scan on the same terms as * {@link findStaticImportFromSpans}. */ export declare function findDynamicImportSpans(source: string, matcher: SpecifierMatcher, maxMatches: number): StaticImportSpan[]; /** * Find bare `import "…"` side-effect statements. * * `maxMatches` bounds the scan on the same terms as * {@link findStaticImportFromSpans}. */ export declare function findStaticSideEffectImportSpans(source: string, matcher: SpecifierMatcher, maxMatches: number): StaticImportSpan[]; export {}; //# sourceMappingURL=source-spans.d.ts.map