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