* SvelteKit file-convention data flow. A route directory's `+page.svelte` (a * `component` node) receives its `data` from the sibling `+page.server.{ts,js}` * / `+page.{ts,js}` `load` function and posts forms to its `actions` — wired by * the framework BY FILE PATH, with no static import between
(ctx: ResolutionContext)
| 1626 | * its loader. |
| 1627 | */ |
| 1628 | function svelteKitLoadEdges(ctx: ResolutionContext): Edge[] { |
| 1629 | const edges: Edge[] = []; |
| 1630 | const allFiles = new Set(ctx.getAllFiles()); |
| 1631 | const HOOKS = new Set(['load', 'actions']); |
| 1632 | const HOOK_KINDS = new Set(['function', 'method', 'constant', 'variable']); |
| 1633 | for (const file of allFiles) { |
| 1634 | const m = file.match(/(.*\/)(\+(?:page|layout))\.svelte$/); |
| 1635 | if (!m) continue; |
| 1636 | const dir = m[1]!; |
| 1637 | const prefix = m[2]!; |
| 1638 | const page = ctx.getNodesInFile(file).find((n) => n.kind === 'component'); |
| 1639 | if (!page) continue; |
| 1640 | for (const ext of ['.server.ts', '.server.js', '.ts', '.js']) { |
| 1641 | const loaderFile = `${dir}${prefix}${ext}`; |
| 1642 | if (!allFiles.has(loaderFile)) continue; |
| 1643 | for (const hook of ctx.getNodesInFile(loaderFile)) { |
| 1644 | if (!HOOK_KINDS.has(hook.kind) || !HOOKS.has(hook.name)) continue; |
| 1645 | edges.push({ |
| 1646 | source: page.id, |
| 1647 | target: hook.id, |
| 1648 | kind: 'references', |
| 1649 | line: page.startLine, |
| 1650 | provenance: 'heuristic', |
| 1651 | metadata: { |
| 1652 | synthesizedBy: 'sveltekit-load', |
| 1653 | via: hook.name, |
| 1654 | registeredAt: `${loaderFile}:${hook.startLine ?? 0}`, |
| 1655 | }, |
| 1656 | }); |
| 1657 | } |
| 1658 | } |
| 1659 | } |
| 1660 | return edges; |
| 1661 | } |
| 1662 | |
| 1663 | /** |
| 1664 | * Redux-thunk dispatch chain. `export const X = createAsyncThunk(prefix, async (a, api) => {...})` |
no test coverage detected