* 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, onYield: MaybeYield)
| 2043 | * its loader. |
| 2044 | */ |
| 2045 | async function svelteKitLoadEdges(ctx: ResolutionContext, onYield: MaybeYield): Promise<Edge[]> { |
| 2046 | let scannedFiles = 0; |
| 2047 | const edges: Edge[] = []; |
| 2048 | const allFiles = new Set(ctx.getAllFiles()); |
| 2049 | const HOOKS = new Set(['load', 'actions']); |
| 2050 | const HOOK_KINDS = new Set(['function', 'method', 'constant', 'variable']); |
| 2051 | for (const file of allFiles) { |
| 2052 | if ((++scannedFiles & 255) === 0) await onYield(); |
| 2053 | const m = file.match(/(.*\/)(\+(?:page|layout))\.svelte$/); |
| 2054 | if (!m) continue; |
| 2055 | const dir = m[1]!; |
| 2056 | const prefix = m[2]!; |
| 2057 | const page = ctx.getNodesInFile(file).find((n) => n.kind === 'component'); |
| 2058 | if (!page) continue; |
| 2059 | for (const ext of ['.server.ts', '.server.js', '.ts', '.js']) { |
| 2060 | const loaderFile = `${dir}${prefix}${ext}`; |
| 2061 | if (!allFiles.has(loaderFile)) continue; |
| 2062 | for (const hook of ctx.getNodesInFile(loaderFile)) { |
| 2063 | if (!HOOK_KINDS.has(hook.kind) || !HOOKS.has(hook.name)) continue; |
| 2064 | edges.push({ |
| 2065 | source: page.id, |
| 2066 | target: hook.id, |
| 2067 | kind: 'references', |
| 2068 | line: page.startLine, |
| 2069 | provenance: 'heuristic', |
| 2070 | metadata: { |
| 2071 | synthesizedBy: 'sveltekit-load', |
| 2072 | via: hook.name, |
| 2073 | registeredAt: `${loaderFile}:${hook.startLine ?? 0}`, |
| 2074 | }, |
| 2075 | }); |
| 2076 | } |
| 2077 | } |
| 2078 | } |
| 2079 | return edges; |
| 2080 | } |
| 2081 | |
| 2082 | /** |
| 2083 | * Redux-thunk dispatch chain. `export const X = createAsyncThunk(prefix, async (a, api) => {...})` |
no test coverage detected