(ref: UnresolvedRef, context: ResolutionContext)
| 49 | }, |
| 50 | |
| 51 | resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null { |
| 52 | // A page route names the component its file is. |
| 53 | const page = resolvePageComponent(ref, context); |
| 54 | if (page) return page; |
| 55 | |
| 56 | // Pattern 1: the `Astro` global (Astro.props, Astro.url, Astro.params, …) |
| 57 | // — runtime-provided in every component's frontmatter. Resolving it as |
| 58 | // framework-provided keeps it from name-matching a user symbol named Astro. |
| 59 | if (ref.referenceName === 'Astro' || ref.referenceName.startsWith('Astro.')) { |
| 60 | return { |
| 61 | original: ref, |
| 62 | targetNodeId: ref.fromNodeId, |
| 63 | confidence: 1.0, |
| 64 | resolvedBy: 'framework', |
| 65 | }; |
| 66 | } |
| 67 | |
| 68 | // Pattern 2: astro:* virtual module imports (astro:content, astro:assets, …) |
| 69 | if (ref.referenceKind === 'imports' && ref.referenceName.startsWith('astro:')) { |
| 70 | if (ASTRO_VIRTUAL_MODULES.some((prefix) => ref.referenceName.startsWith(prefix))) { |
| 71 | return { |
| 72 | original: ref, |
| 73 | targetNodeId: ref.fromNodeId, |
| 74 | confidence: 1.0, |
| 75 | resolvedBy: 'framework', |
| 76 | }; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Pattern 3: Component references (PascalCase) — resolve to component |
| 81 | // nodes. Template tags arrive as `references`, frontmatter expression |
| 82 | // usages as `calls`. |
| 83 | // Only from Astro markup: a `.ts` file's `Page` (Playwright's) or a |
| 84 | // declaration file's `image?: Image` is no `Page.astro` / `Image.astro`. |
| 85 | if ( |
| 86 | ref.filePath.endsWith('.astro') && |
| 87 | isPascalCase(ref.referenceName) && |
| 88 | (ref.referenceKind === 'references' || ref.referenceKind === 'calls') |
| 89 | ) { |
| 90 | const result = resolveComponent(ref.referenceName, ref.filePath, context); |
| 91 | if (result) { |
| 92 | return { |
| 93 | original: ref, |
| 94 | targetNodeId: result, |
| 95 | confidence: 0.8, |
| 96 | resolvedBy: 'framework', |
| 97 | }; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return null; |
| 102 | }, |
| 103 | |
| 104 | extract(filePath: string, content: string) { |
| 105 | const nodes: Node[] = []; |
nothing calls this directly
no test coverage detected