purecontext-mcp 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FRAMEWORK-ADAPTERS.md +368 -351
- package/dist/adapters/astro-preprocessor.d.ts +25 -0
- package/dist/adapters/astro-preprocessor.d.ts.map +1 -0
- package/dist/adapters/astro-preprocessor.js +50 -0
- package/dist/adapters/astro-preprocessor.js.map +1 -0
- package/dist/adapters/astro.d.ts +13 -0
- package/dist/adapters/astro.d.ts.map +1 -0
- package/dist/adapters/astro.js +83 -0
- package/dist/adapters/astro.js.map +1 -0
- package/dist/adapters/detect-utils.d.ts +38 -0
- package/dist/adapters/detect-utils.d.ts.map +1 -0
- package/dist/adapters/detect-utils.js +95 -0
- package/dist/adapters/detect-utils.js.map +1 -0
- package/dist/adapters/nuxt.d.ts +20 -0
- package/dist/adapters/nuxt.d.ts.map +1 -1
- package/dist/adapters/nuxt.js +128 -13
- package/dist/adapters/nuxt.js.map +1 -1
- package/dist/adapters/svelte-preprocessor.d.ts +29 -0
- package/dist/adapters/svelte-preprocessor.d.ts.map +1 -0
- package/dist/adapters/svelte-preprocessor.js +83 -0
- package/dist/adapters/svelte-preprocessor.js.map +1 -0
- package/dist/adapters/svelte.d.ts +13 -0
- package/dist/adapters/svelte.d.ts.map +1 -0
- package/dist/adapters/svelte.js +96 -0
- package/dist/adapters/svelte.js.map +1 -0
- package/dist/adapters/vue.d.ts.map +1 -1
- package/dist/adapters/vue.js +87 -20
- package/dist/adapters/vue.js.map +1 -1
- package/dist/cli/hooks.d.ts +2 -2
- package/dist/cli/hooks.d.ts.map +1 -1
- package/dist/cli/hooks.js +104 -121
- package/dist/cli/hooks.js.map +1 -1
- package/dist/core/index-manager.d.ts.map +1 -1
- package/dist/core/index-manager.js +9 -2
- package/dist/core/index-manager.js.map +1 -1
- package/dist/core/indexing-worker.d.ts +2 -0
- package/dist/core/indexing-worker.d.ts.map +1 -1
- package/dist/core/indexing-worker.js +2 -0
- package/dist/core/indexing-worker.js.map +1 -1
- package/dist/core/watcher/file-watcher.d.ts +6 -0
- package/dist/core/watcher/file-watcher.d.ts.map +1 -1
- package/dist/core/watcher/file-watcher.js +11 -1
- package/dist/core/watcher/file-watcher.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/server/tools/index-repo.d.ts.map +1 -1
- package/dist/server/tools/index-repo.js +8 -2
- package/dist/server/tools/index-repo.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro component pre-processor.
|
|
3
|
+
*
|
|
4
|
+
* An .astro file begins with an optional "frontmatter" block fenced by `---`
|
|
5
|
+
* lines at the very top of the file; its contents are TypeScript. The remainder
|
|
6
|
+
* is HTML-like template with JSX-style expressions and component usage, which we
|
|
7
|
+
* do not index for symbols.
|
|
8
|
+
*
|
|
9
|
+
* This extracts the leading frontmatter as a single TypeScript ProcessedBlock.
|
|
10
|
+
*
|
|
11
|
+
* Byte-offset correctness:
|
|
12
|
+
* offsetInOriginal is computed from Buffer.byteLength() of the prefix up to and
|
|
13
|
+
* including the opening fence, never from string character indices.
|
|
14
|
+
*/
|
|
15
|
+
import type { ProcessedBlock } from '../core/types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Extract the leading `---`-fenced frontmatter of an Astro component as a single
|
|
18
|
+
* TypeScript block. The fence must be the first non-whitespace content in the
|
|
19
|
+
* file (`---` appearing later in markup is ignored).
|
|
20
|
+
*
|
|
21
|
+
* Returns [] when there is no leading frontmatter.
|
|
22
|
+
* Throws ParseError when a leading fence is opened but never closed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function splitAstroSFC(source: Buffer, filePath: string): ProcessedBlock[];
|
|
25
|
+
//# sourceMappingURL=astro-preprocessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-preprocessor.d.ts","sourceRoot":"","sources":["../../src/adapters/astro-preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CA6BhF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro component pre-processor.
|
|
3
|
+
*
|
|
4
|
+
* An .astro file begins with an optional "frontmatter" block fenced by `---`
|
|
5
|
+
* lines at the very top of the file; its contents are TypeScript. The remainder
|
|
6
|
+
* is HTML-like template with JSX-style expressions and component usage, which we
|
|
7
|
+
* do not index for symbols.
|
|
8
|
+
*
|
|
9
|
+
* This extracts the leading frontmatter as a single TypeScript ProcessedBlock.
|
|
10
|
+
*
|
|
11
|
+
* Byte-offset correctness:
|
|
12
|
+
* offsetInOriginal is computed from Buffer.byteLength() of the prefix up to and
|
|
13
|
+
* including the opening fence, never from string character indices.
|
|
14
|
+
*/
|
|
15
|
+
import { ParseError } from '../core/errors.js';
|
|
16
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* Extract the leading `---`-fenced frontmatter of an Astro component as a single
|
|
19
|
+
* TypeScript block. The fence must be the first non-whitespace content in the
|
|
20
|
+
* file (`---` appearing later in markup is ignored).
|
|
21
|
+
*
|
|
22
|
+
* Returns [] when there is no leading frontmatter.
|
|
23
|
+
* Throws ParseError when a leading fence is opened but never closed.
|
|
24
|
+
*/
|
|
25
|
+
export function splitAstroSFC(source, filePath) {
|
|
26
|
+
const str = source.toString('utf8');
|
|
27
|
+
// The opening fence must be the first non-whitespace content. A line of
|
|
28
|
+
// exactly `---` (optionally with trailing spaces) starting the file.
|
|
29
|
+
const openMatch = str.match(/^\s*---[ \t]*\r?\n/);
|
|
30
|
+
if (!openMatch) {
|
|
31
|
+
return []; // no frontmatter
|
|
32
|
+
}
|
|
33
|
+
const openLen = openMatch[0].length; // chars consumed by leading ws + `---` + newline
|
|
34
|
+
const rest = str.slice(openLen);
|
|
35
|
+
// Closing fence: a line that is exactly `---` (optionally trailing spaces).
|
|
36
|
+
const closeMatch = rest.match(/\r?\n[ \t]*---[ \t]*(?:\r?\n|$)/);
|
|
37
|
+
if (!closeMatch) {
|
|
38
|
+
throw new ParseError(`Malformed Astro component: unterminated frontmatter fence`, filePath);
|
|
39
|
+
}
|
|
40
|
+
const innerContent = rest.slice(0, closeMatch.index);
|
|
41
|
+
const offsetInOriginal = Buffer.byteLength(str.slice(0, openLen), 'utf8');
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
content: Buffer.from(innerContent, 'utf8'),
|
|
45
|
+
language: 'typescript',
|
|
46
|
+
offsetInOriginal,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=astro-preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-preprocessor.js","sourceRoot":"","sources":["../../src/adapters/astro-preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,iFAAiF;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,QAAgB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEpC,wEAAwE;IACxE,qEAAqE;IACrE,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAClD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,iBAAiB;IAC9B,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,iDAAiD;IACtF,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEhC,4EAA4E;IAC5E,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACjE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,UAAU,CAAC,2DAA2D,EAAE,QAAQ,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;IAE1E,OAAO;QACL;YACE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;YAC1C,QAAQ,EAAE,YAAY;YACtB,gBAAgB;SACjB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro framework adapter.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* 1. Detect Astro projects (package.json declares `astro`/`@astrojs/*`,
|
|
6
|
+
* an astro.config.* file, or `.astro` files present — incl. monorepo sub-apps).
|
|
7
|
+
* 2. Pre-process .astro components: extract the leading `---` frontmatter as a
|
|
8
|
+
* TypeScript block via astro-preprocessor.
|
|
9
|
+
* 3. Emit one `component` symbol per .astro file (name derived from filename).
|
|
10
|
+
*/
|
|
11
|
+
import type { FrameworkAdapter } from '../core/types.js';
|
|
12
|
+
export declare const astroAdapter: FrameworkAdapter;
|
|
13
|
+
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/adapters/astro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAC;AAyB7E,eAAO,MAAM,YAAY,EAAE,gBA0D1B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro framework adapter.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* 1. Detect Astro projects (package.json declares `astro`/`@astrojs/*`,
|
|
6
|
+
* an astro.config.* file, or `.astro` files present — incl. monorepo sub-apps).
|
|
7
|
+
* 2. Pre-process .astro components: extract the leading `---` frontmatter as a
|
|
8
|
+
* TypeScript block via astro-preprocessor.
|
|
9
|
+
* 3. Emit one `component` symbol per .astro file (name derived from filename).
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from 'crypto';
|
|
12
|
+
import { basename } from 'path';
|
|
13
|
+
import { existsSync, readFileSync } from 'fs';
|
|
14
|
+
import { splitAstroSFC } from './astro-preprocessor.js';
|
|
15
|
+
import { registerAdapter } from './adapter-registry.js';
|
|
16
|
+
import { scanForFramework, pkgDepMatches, toPascalCase } from './detect-utils.js';
|
|
17
|
+
import { logger } from '../core/logger.js';
|
|
18
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
19
|
+
function makeId(filePath, name, kind) {
|
|
20
|
+
return createHash('sha256').update(`${filePath}:${name}:${kind}`).digest('hex').slice(0, 16);
|
|
21
|
+
}
|
|
22
|
+
function componentNameFromPath(filePath) {
|
|
23
|
+
return toPascalCase(basename(filePath, '.astro'));
|
|
24
|
+
}
|
|
25
|
+
/** Returns true if a package.json declares an astro / @astrojs/* dependency. */
|
|
26
|
+
function pkgDeclaresAstro(raw) {
|
|
27
|
+
return pkgDepMatches(raw, (k) => k === 'astro' || k.startsWith('@astrojs/'));
|
|
28
|
+
}
|
|
29
|
+
const ASTRO_CONFIG_NAMES = ['astro.config.mjs', 'astro.config.ts', 'astro.config.js', 'astro.config.cjs'];
|
|
30
|
+
// ─── Astro adapter ──────────────────────────────────────────────────────────────
|
|
31
|
+
export const astroAdapter = {
|
|
32
|
+
name: 'astro',
|
|
33
|
+
extensions: () => ['.astro'],
|
|
34
|
+
// ── Detection ───────────────────────────────────────────────────────────────
|
|
35
|
+
async detect(projectRoot) {
|
|
36
|
+
try {
|
|
37
|
+
if (pkgDeclaresAstro(readFileSync(`${projectRoot}/package.json`, 'utf8')))
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// no package.json — fall through
|
|
42
|
+
}
|
|
43
|
+
if (ASTRO_CONFIG_NAMES.some((n) => existsSync(`${projectRoot}/${n}`)))
|
|
44
|
+
return true;
|
|
45
|
+
return scanForFramework(projectRoot, {
|
|
46
|
+
matchesFile: (name) => name.endsWith('.astro'),
|
|
47
|
+
pkgDeclares: pkgDeclaresAstro,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
// ── File routing ─────────────────────────────────────────────────────────────
|
|
51
|
+
fileFilter: (filePath) => filePath.endsWith('.astro'),
|
|
52
|
+
// ── Pre-processing ───────────────────────────────────────────────────────────
|
|
53
|
+
preProcess: splitAstroSFC,
|
|
54
|
+
// ── Framework symbol extraction ──────────────────────────────────────────────
|
|
55
|
+
/** Emit one `component` symbol per .astro file. */
|
|
56
|
+
extractFrameworkSymbols(tree, source, filePath) {
|
|
57
|
+
const name = componentNameFromPath(filePath);
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
id: makeId(filePath, name, 'component'),
|
|
61
|
+
name,
|
|
62
|
+
kind: 'component',
|
|
63
|
+
filePath,
|
|
64
|
+
startByte: 0,
|
|
65
|
+
endByte: source.length,
|
|
66
|
+
signature: `<${name}>`,
|
|
67
|
+
summary: `Astro component ${name}`,
|
|
68
|
+
frameworkMeta: { astro_component: true },
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
},
|
|
72
|
+
// ── Metadata enrichment ──────────────────────────────────────────────────────
|
|
73
|
+
enrichMetadata(symbol) {
|
|
74
|
+
if (symbol.kind === 'component') {
|
|
75
|
+
return { ...symbol, frameworkMeta: { ...symbol.frameworkMeta, astro_component: true } };
|
|
76
|
+
}
|
|
77
|
+
return symbol;
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
// ─── Self-registration ────────────────────────────────────────────────────────
|
|
81
|
+
registerAdapter(astroAdapter);
|
|
82
|
+
logger.debug("Adapter 'astro' registered");
|
|
83
|
+
//# sourceMappingURL=astro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.js","sourceRoot":"","sources":["../../src/adapters/astro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,iFAAiF;AAEjF,SAAS,MAAM,CAAC,QAAgB,EAAE,IAAY,EAAE,IAAY;IAC1D,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,QAAQ,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpD,C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AM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC7C,OAAO;YACL;gBACE,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC;gBACvC,IAAI;gBACJ,IAAI,EAAE,WAAW;gBACjB,QAAQ;gBACR,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,MAAM,CAAC,MAAM;gBACtB,SAAS,EAAE,IAAI,IAAI,GAAG;gBACtB,OAAO,EAAE,mBAAmB,IAAI,EAAE;gBAClC,aAAa,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;aACzC;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAEhF,cAAc,CAAC,MAAoB;QACjC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC;QAC1F,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,iFAAiF;AAEjF,eAAe,CAAC,YAAY,CAAC,CAAC;AAC9B,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared bounded-recursive project detection for framework adapters.
|
|
3
|
+
*
|
|
4
|
+
* Adapters detect their framework by scanning the indexed root for marker files
|
|
5
|
+
* (e.g. a `.svelte`/`.astro` file or a package.json declaring the framework).
|
|
6
|
+
* In monorepos the framework app often lives in a subdirectory, so a root-only
|
|
7
|
+
* check misses it. `scanForFramework` walks the tree with hard bounds (depth +
|
|
8
|
+
* total directories) and skips heavy/irrelevant directories, so it stays cheap
|
|
9
|
+
* even on large repos. Symlinked directories are not followed (Dirent.isDirectory()
|
|
10
|
+
* is false for symlinks), avoiding cycles.
|
|
11
|
+
*
|
|
12
|
+
* Vue/Nuxt predate this helper and keep their own inline copies; new adapters use
|
|
13
|
+
* this shared version.
|
|
14
|
+
*/
|
|
15
|
+
/** Directory names that never contain first-party framework source. */
|
|
16
|
+
export declare const DETECT_IGNORE_DIRS: Set<string>;
|
|
17
|
+
/** Max directory depth and total directories visited by a detection scan. */
|
|
18
|
+
export declare const DETECT_MAX_DEPTH = 6;
|
|
19
|
+
export declare const DETECT_MAX_DIRS = 2000;
|
|
20
|
+
export interface FrameworkScanOptions {
|
|
21
|
+
/** Returns true if a file name marks the framework (e.g. ends with `.svelte`). */
|
|
22
|
+
matchesFile: (name: string) => boolean;
|
|
23
|
+
/** Returns true if a package.json's raw text declares the framework dependency. */
|
|
24
|
+
pkgDeclares: (raw: string) => boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true on the first sign of the framework — a matching file or a
|
|
28
|
+
* (possibly nested) package.json declaring it. Bounded in depth and total
|
|
29
|
+
* directories visited.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scanForFramework(dir: string, opts: FrameworkScanOptions, depth?: number, budget?: {
|
|
32
|
+
dirs: number;
|
|
33
|
+
}): boolean;
|
|
34
|
+
/** Parse a package.json's raw text and test its merged deps against a predicate. */
|
|
35
|
+
export declare function pkgDepMatches(raw: string, pred: (depName: string) => boolean): boolean;
|
|
36
|
+
/** Convert a kebab/camel/snake filename stem to PascalCase ('user-card' → 'UserCard'). */
|
|
37
|
+
export declare function toPascalCase(str: string): string;
|
|
38
|
+
//# sourceMappingURL=detect-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-utils.d.ts","sourceRoot":"","sources":["../../src/adapters/detect-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,aAgB7B,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,mFAAmF;IACnF,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,oBAAoB,EAC1B,KAAK,SAAI,EACT,MAAM,GAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAgB,GACrC,OAAO,CAgCT;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAYtF;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared bounded-recursive project detection for framework adapters.
|
|
3
|
+
*
|
|
4
|
+
* Adapters detect their framework by scanning the indexed root for marker files
|
|
5
|
+
* (e.g. a `.svelte`/`.astro` file or a package.json declaring the framework).
|
|
6
|
+
* In monorepos the framework app often lives in a subdirectory, so a root-only
|
|
7
|
+
* check misses it. `scanForFramework` walks the tree with hard bounds (depth +
|
|
8
|
+
* total directories) and skips heavy/irrelevant directories, so it stays cheap
|
|
9
|
+
* even on large repos. Symlinked directories are not followed (Dirent.isDirectory()
|
|
10
|
+
* is false for symlinks), avoiding cycles.
|
|
11
|
+
*
|
|
12
|
+
* Vue/Nuxt predate this helper and keep their own inline copies; new adapters use
|
|
13
|
+
* this shared version.
|
|
14
|
+
*/
|
|
15
|
+
import { readdirSync, readFileSync } from 'fs';
|
|
16
|
+
/** Directory names that never contain first-party framework source. */
|
|
17
|
+
export const DETECT_IGNORE_DIRS = new Set([
|
|
18
|
+
'node_modules',
|
|
19
|
+
'.git',
|
|
20
|
+
'dist',
|
|
21
|
+
'build',
|
|
22
|
+
'out',
|
|
23
|
+
'.nuxt',
|
|
24
|
+
'.output',
|
|
25
|
+
'.next',
|
|
26
|
+
'.svelte-kit',
|
|
27
|
+
'.astro',
|
|
28
|
+
'coverage',
|
|
29
|
+
'vendor',
|
|
30
|
+
'target',
|
|
31
|
+
'.cache',
|
|
32
|
+
'.turbo',
|
|
33
|
+
]);
|
|
34
|
+
/** Max directory depth and total directories visited by a detection scan. */
|
|
35
|
+
export const DETECT_MAX_DEPTH = 6;
|
|
36
|
+
export const DETECT_MAX_DIRS = 2000;
|
|
37
|
+
/**
|
|
38
|
+
* Returns true on the first sign of the framework — a matching file or a
|
|
39
|
+
* (possibly nested) package.json declaring it. Bounded in depth and total
|
|
40
|
+
* directories visited.
|
|
41
|
+
*/
|
|
42
|
+
export function scanForFramework(dir, opts, depth = 0, budget = { dirs: 0 }) {
|
|
43
|
+
if (depth > DETECT_MAX_DEPTH || budget.dirs >= DETECT_MAX_DIRS)
|
|
44
|
+
return false;
|
|
45
|
+
budget.dirs++;
|
|
46
|
+
let entries;
|
|
47
|
+
try {
|
|
48
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false; // unreadable directory — skip
|
|
52
|
+
}
|
|
53
|
+
const subDirs = [];
|
|
54
|
+
for (const e of entries) {
|
|
55
|
+
if (e.isFile()) {
|
|
56
|
+
if (opts.matchesFile(e.name))
|
|
57
|
+
return true;
|
|
58
|
+
if (e.name === 'package.json') {
|
|
59
|
+
try {
|
|
60
|
+
if (opts.pkgDeclares(readFileSync(`${dir}/${e.name}`, 'utf8')))
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// unreadable package.json — ignore
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (e.isDirectory() && !DETECT_IGNORE_DIRS.has(e.name)) {
|
|
69
|
+
subDirs.push(e.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const name of subDirs) {
|
|
73
|
+
if (scanForFramework(`${dir}/${name}`, opts, depth + 1, budget))
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
/** Parse a package.json's raw text and test its merged deps against a predicate. */
|
|
79
|
+
export function pkgDepMatches(raw, pred) {
|
|
80
|
+
try {
|
|
81
|
+
const pkg = JSON.parse(raw);
|
|
82
|
+
const deps = Object.assign({}, pkg['dependencies'], pkg['devDependencies']);
|
|
83
|
+
return Object.keys(deps).some(pred);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Convert a kebab/camel/snake filename stem to PascalCase ('user-card' → 'UserCard'). */
|
|
90
|
+
export function toPascalCase(str) {
|
|
91
|
+
return str
|
|
92
|
+
.replace(/[-_](.)/g, (_, c) => c.toUpperCase())
|
|
93
|
+
.replace(/^(.)/, (_, c) => c.toUpperCase());
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=detect-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-utils.js","sourceRoot":"","sources":["../../src/adapters/detect-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAe,MAAM,IAAI,CAAC;AAE5D,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;IACP,SAAS;IACT,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,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AC;IAED,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,gBAAgB,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IAC/E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,IAAkC;IAC3E,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB,EAAE,EACF,GAAG,CAAC,cAAc,CAAuC,EACzD,GAAG,CAAC,iBAAiB,CAAuC,CAC7D,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG;SACP,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACtD,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/adapters/nuxt.d.ts
CHANGED
|
@@ -40,5 +40,25 @@ export declare function deriveServerRoute(filePath: string): {
|
|
|
40
40
|
routePath: string;
|
|
41
41
|
method: string | null;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the path of a file relative to its Nuxt app root.
|
|
45
|
+
*
|
|
46
|
+
* When indexing a monorepo, file paths are relative to the indexed repo root
|
|
47
|
+
* (e.g. `apps/web/server/api/users.ts`), but Nuxt category detection and route
|
|
48
|
+
* derivation expect paths relative to the Nuxt app root (`server/api/users.ts`).
|
|
49
|
+
* This finds the first recognized Nuxt convention-directory boundary and returns
|
|
50
|
+
* the path from there. Returns null when no boundary is found.
|
|
51
|
+
*
|
|
52
|
+
* Stateless by design: the parallel worker pool resolves adapters from its own
|
|
53
|
+
* registry, so the app root cannot be cached during detect() — it must be
|
|
54
|
+
* derivable from the file path alone.
|
|
55
|
+
*
|
|
56
|
+
* 'server/api/users.ts' → 'server/api/users.ts' (no-op, non-monorepo)
|
|
57
|
+
* 'apps/web/server/api/users.ts' → 'server/api/users.ts'
|
|
58
|
+
* 'packages/site/pages/index.vue' → 'pages/index.vue'
|
|
59
|
+
* 'server/plugins/foo.ts' → 'server/plugins/foo.ts' (categoryOf → null)
|
|
60
|
+
* 'src/utils/helpers.ts' → null
|
|
61
|
+
*/
|
|
62
|
+
export declare function toNuxtRelative(filePath: string): string | null;
|
|
43
63
|
export declare const nuxtAdapter: FrameworkAdapter;
|
|
44
64
|
//# sourceMappingURL=nuxt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../src/adapters/nuxt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../src/adapters/nuxt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAC;AA8F7E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAyBhG;AAqBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ9D;AA6BD,eAAO,MAAM,WAAW,EAAE,gBAuJzB,CAAC"}
|
package/dist/adapters/nuxt.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { createHash } from 'crypto';
|
|
22
22
|
import { basename } from 'path';
|
|
23
|
-
import { existsSync } from 'fs';
|
|
23
|
+
import { existsSync, readdirSync } from 'fs';
|
|
24
24
|
import { registerAdapter } from './adapter-registry.js';
|
|
25
25
|
import { logger } from '../core/logger.js';
|
|
26
26
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
@@ -31,6 +31,67 @@ const NUXT_CONFIG_NAMES = [
|
|
|
31
31
|
'nuxt.config.js',
|
|
32
32
|
'nuxt.config.mjs',
|
|
33
33
|
];
|
|
34
|
+
// ─── Detection helpers ──────────────────────────────────────────────────────
|
|
35
|
+
/**
|
|
36
|
+
* Directory names that never contain a first-party Nuxt app root — skipped
|
|
37
|
+
* during the recursive detection scan to keep it fast and avoid false positives
|
|
38
|
+
* from bundled dependencies.
|
|
39
|
+
*/
|
|
40
|
+
const DETECT_IGNORE_DIRS = new Set([
|
|
41
|
+
'node_modules',
|
|
42
|
+
'.git',
|
|
43
|
+
'dist',
|
|
44
|
+
'build',
|
|
45
|
+
'out',
|
|
46
|
+
'.nuxt',
|
|
47
|
+
'.output',
|
|
48
|
+
'.next',
|
|
49
|
+
'coverage',
|
|
50
|
+
'vendor',
|
|
51
|
+
'target',
|
|
52
|
+
'.cache',
|
|
53
|
+
'.turbo',
|
|
54
|
+
'.svelte-kit',
|
|
55
|
+
]);
|
|
56
|
+
/** Max directory depth and total directories visited by the detection scan. */
|
|
57
|
+
const DETECT_MAX_DEPTH = 6;
|
|
58
|
+
const DETECT_MAX_DIRS = 2000;
|
|
59
|
+
const NUXT_CONFIG_SET = new Set(NUXT_CONFIG_NAMES);
|
|
60
|
+
/**
|
|
61
|
+
* Bounded recursive scan: returns true on the first `nuxt.config.{ts,mts,js,mjs}`
|
|
62
|
+
* found anywhere in the tree. Handles monorepos where the Nuxt app lives in a
|
|
63
|
+
* subdirectory (apps/web/, frontend/, …) rather than the indexed root. Skips
|
|
64
|
+
* heavy/irrelevant directories and caps depth + total directories so the scan
|
|
65
|
+
* stays cheap. Symlinked directories are not followed (Dirent.isDirectory() is
|
|
66
|
+
* false for symlinks), avoiding cycles.
|
|
67
|
+
*/
|
|
68
|
+
function scanForNuxtConfig(dir, depth, budget) {
|
|
69
|
+
if (depth > DETECT_MAX_DEPTH || budget.dirs >= DETECT_MAX_DIRS)
|
|
70
|
+
return false;
|
|
71
|
+
budget.dirs++;
|
|
72
|
+
let entries;
|
|
73
|
+
try {
|
|
74
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false; // unreadable directory — skip
|
|
78
|
+
}
|
|
79
|
+
const subDirs = [];
|
|
80
|
+
for (const e of entries) {
|
|
81
|
+
if (e.isFile()) {
|
|
82
|
+
if (NUXT_CONFIG_SET.has(e.name))
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
else if (e.isDirectory() && !DETECT_IGNORE_DIRS.has(e.name)) {
|
|
86
|
+
subDirs.push(e.name);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const name of subDirs) {
|
|
90
|
+
if (scanForNuxtConfig(`${dir}/${name}`, depth + 1, budget))
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
34
95
|
// ─── Route path helpers ───────────────────────────────────────────────────────
|
|
35
96
|
/**
|
|
36
97
|
* Convert a single path segment with Nuxt dynamic syntax to a URL parameter.
|
|
@@ -103,19 +164,60 @@ function makeId(filePath, name, kind) {
|
|
|
103
164
|
.digest('hex')
|
|
104
165
|
.slice(0, 16);
|
|
105
166
|
}
|
|
106
|
-
|
|
107
|
-
|
|
167
|
+
// ─── Nuxt-relative path resolution ──────────────────────────────────────────
|
|
168
|
+
/**
|
|
169
|
+
* Top-level Nuxt convention directories that sit directly under the app root.
|
|
170
|
+
* The first occurrence of one of these marks the app-root boundary. `server` is
|
|
171
|
+
* included so that a path like `server/plugins/foo.ts` resolves relative to the
|
|
172
|
+
* `server/` tree (and is correctly *not* treated as an app-root `plugins/` file).
|
|
173
|
+
*/
|
|
174
|
+
const NUXT_ROOT_SEGMENTS = new Set(['server', 'plugins', 'middleware', 'composables', 'pages']);
|
|
175
|
+
/**
|
|
176
|
+
* Resolve the path of a file relative to its Nuxt app root.
|
|
177
|
+
*
|
|
178
|
+
* When indexing a monorepo, file paths are relative to the indexed repo root
|
|
179
|
+
* (e.g. `apps/web/server/api/users.ts`), but Nuxt category detection and route
|
|
180
|
+
* derivation expect paths relative to the Nuxt app root (`server/api/users.ts`).
|
|
181
|
+
* This finds the first recognized Nuxt convention-directory boundary and returns
|
|
182
|
+
* the path from there. Returns null when no boundary is found.
|
|
183
|
+
*
|
|
184
|
+
* Stateless by design: the parallel worker pool resolves adapters from its own
|
|
185
|
+
* registry, so the app root cannot be cached during detect() — it must be
|
|
186
|
+
* derivable from the file path alone.
|
|
187
|
+
*
|
|
188
|
+
* 'server/api/users.ts' → 'server/api/users.ts' (no-op, non-monorepo)
|
|
189
|
+
* 'apps/web/server/api/users.ts' → 'server/api/users.ts'
|
|
190
|
+
* 'packages/site/pages/index.vue' → 'pages/index.vue'
|
|
191
|
+
* 'server/plugins/foo.ts' → 'server/plugins/foo.ts' (categoryOf → null)
|
|
192
|
+
* 'src/utils/helpers.ts' → null
|
|
193
|
+
*/
|
|
194
|
+
export function toNuxtRelative(filePath) {
|
|
195
|
+
const segments = filePath.replace(/\\/g, '/').split('/');
|
|
196
|
+
for (let i = 0; i < segments.length; i++) {
|
|
197
|
+
if (NUXT_ROOT_SEGMENTS.has(segments[i])) {
|
|
198
|
+
return segments.slice(i).join('/');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/** Classify an already-Nuxt-relative path into a file category. */
|
|
204
|
+
function categoryOf(rel) {
|
|
205
|
+
if (rel.startsWith('server/api/') && rel.endsWith('.ts'))
|
|
108
206
|
return 'server-api';
|
|
109
|
-
if (
|
|
207
|
+
if (rel.startsWith('server/routes/') && rel.endsWith('.ts'))
|
|
110
208
|
return 'server-route';
|
|
111
|
-
if (
|
|
209
|
+
if (rel.startsWith('plugins/') && rel.endsWith('.ts'))
|
|
112
210
|
return 'plugin';
|
|
113
|
-
if (
|
|
211
|
+
if (rel.startsWith('middleware/') && rel.endsWith('.ts'))
|
|
114
212
|
return 'middleware';
|
|
115
|
-
if (
|
|
213
|
+
if (rel.startsWith('composables/') && rel.endsWith('.ts'))
|
|
116
214
|
return 'composable';
|
|
117
215
|
return null;
|
|
118
216
|
}
|
|
217
|
+
function getCategory(filePath) {
|
|
218
|
+
const rel = toNuxtRelative(filePath);
|
|
219
|
+
return rel ? categoryOf(rel) : null;
|
|
220
|
+
}
|
|
119
221
|
// ─── Nuxt adapter ─────────────────────────────────────────────────────────────
|
|
120
222
|
export const nuxtAdapter = {
|
|
121
223
|
name: 'nuxt',
|
|
@@ -126,7 +228,14 @@ export const nuxtAdapter = {
|
|
|
126
228
|
extensions: () => [],
|
|
127
229
|
// ── Detection ───────────────────────────────────────────────────────────────
|
|
128
230
|
async detect(projectRoot) {
|
|
129
|
-
|
|
231
|
+
// Fast path: nuxt.config.* in the indexed root (common case).
|
|
232
|
+
if (NUXT_CONFIG_NAMES.some((name) => existsSync(`${projectRoot}/${name}`))) {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
// Monorepo / sub-app fallback: bounded recursive scan for a nuxt.config.*
|
|
236
|
+
// anywhere in the tree (e.g. apps/web/, frontend/). Skips heavy dirs and
|
|
237
|
+
// caps depth + total directories.
|
|
238
|
+
return scanForNuxtConfig(projectRoot, 0, { dirs: 0 });
|
|
130
239
|
},
|
|
131
240
|
// ── File routing ─────────────────────────────────────────────────────────────
|
|
132
241
|
fileFilter(filePath) {
|
|
@@ -137,11 +246,14 @@ export const nuxtAdapter = {
|
|
|
137
246
|
// the file path (route paths, plugin names, etc.).
|
|
138
247
|
// ── Framework symbol extraction ──────────────────────────────────────────────
|
|
139
248
|
extractFrameworkSymbols(tree, source, filePath) {
|
|
140
|
-
|
|
249
|
+
// `rel` is the path relative to the Nuxt app root (handles monorepo sub-apps).
|
|
250
|
+
// The stored symbol filePath stays repo-relative so files can still be opened.
|
|
251
|
+
const rel = toNuxtRelative(filePath);
|
|
252
|
+
const category = rel ? categoryOf(rel) : null;
|
|
141
253
|
switch (category) {
|
|
142
254
|
case 'server-api':
|
|
143
255
|
case 'server-route': {
|
|
144
|
-
const { routePath, method } = deriveServerRoute(
|
|
256
|
+
const { routePath, method } = deriveServerRoute(rel);
|
|
145
257
|
const name = routePath;
|
|
146
258
|
const methodLabel = method ? `${method} ` : '';
|
|
147
259
|
return [
|
|
@@ -212,9 +324,12 @@ export const nuxtAdapter = {
|
|
|
212
324
|
* - Any symbol in composables/ gets nuxt_auto_import: true.
|
|
213
325
|
*/
|
|
214
326
|
enrichMetadata(symbol) {
|
|
327
|
+
// Resolve to the Nuxt-app-root-relative path so monorepo sub-app symbols
|
|
328
|
+
// (e.g. apps/web/pages/index.vue) are enriched the same as root-level ones.
|
|
329
|
+
const rel = toNuxtRelative(symbol.filePath);
|
|
215
330
|
// Page component: add route metadata
|
|
216
|
-
if (symbol.kind === 'component' &&
|
|
217
|
-
const routePath = derivePageRoutePath(
|
|
331
|
+
if (symbol.kind === 'component' && rel && rel.startsWith('pages/')) {
|
|
332
|
+
const routePath = derivePageRoutePath(rel);
|
|
218
333
|
return {
|
|
219
334
|
...symbol,
|
|
220
335
|
frameworkMeta: {
|
|
@@ -225,7 +340,7 @@ export const nuxtAdapter = {
|
|
|
225
340
|
};
|
|
226
341
|
}
|
|
227
342
|
// Composable (or any symbol) in composables/ — mark as auto-imported
|
|
228
|
-
if (
|
|
343
|
+
if (rel && rel.startsWith('composables/')) {
|
|
229
344
|
return {
|
|
230
345
|
...symbol,
|
|
231
346
|
frameworkMeta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.js","sourceRoot":"","sources":["../../src/adapters/nuxt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"nuxt.js","sourceRoot":"","sources":["../../src/adapters/nuxt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAe,MAAM,IAAI,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,iFAAiF;AAEjF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAE3F,MAAM,iBAAiB,GAAG;IACxB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IAC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ACvB,UAAU,EAAE,SAAS;oBACrB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;QAED,qEAAqE;QACrE,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YAC1C,OAAO;gBACL,GAAG,MAAM;gBACT,aAAa,EAAE;oBACb,GAAG,MAAM,CAAC,aAAa;oBACvB,gBAAgB,EAAE,IAAI;iBACvB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC;AAEF,iFAAiF;AAEjF,eAAe,CAAC,WAAW,CAAC,CAAC;AAC7B,MAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte component pre-processor.
|
|
3
|
+
*
|
|
4
|
+
* Splits a raw .svelte file buffer into typed ProcessedBlock[] so the TypeScript/
|
|
5
|
+
* JavaScript language handlers can parse each <script> block independently.
|
|
6
|
+
* Markup and <style> blocks are intentionally omitted — they don't contain
|
|
7
|
+
* symbols we want to index.
|
|
8
|
+
*
|
|
9
|
+
* Svelte components may contain an instance <script> and an optional module
|
|
10
|
+
* script (`<script context="module">` or `<script module>` in Svelte 5). Both
|
|
11
|
+
* are extracted.
|
|
12
|
+
*
|
|
13
|
+
* Byte-offset correctness:
|
|
14
|
+
* offsetInOriginal is always computed from Buffer.byteLength(), never from
|
|
15
|
+
* string character indices, so symbols inside multi-byte content that precedes
|
|
16
|
+
* a script block are positioned correctly.
|
|
17
|
+
*/
|
|
18
|
+
import type { ProcessedBlock } from '../core/types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Split a Svelte component buffer into its typed script blocks.
|
|
21
|
+
*
|
|
22
|
+
* Returns one ProcessedBlock per <script> block found, with language set to
|
|
23
|
+
* 'typescript' when lang="ts"/lang="tsx" is present and 'javascript' otherwise.
|
|
24
|
+
*
|
|
25
|
+
* Returns [] for markup-only components (no <script>).
|
|
26
|
+
* Throws ParseError for mismatched <script> open/close tags.
|
|
27
|
+
*/
|
|
28
|
+
export declare function splitSvelteSFC(source: Buffer, filePath: string): ProcessedBlock[];
|
|
29
|
+
//# sourceMappingURL=svelte-preprocessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte-preprocessor.d.ts","sourceRoot":"","sources":["../../src/adapters/svelte-preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CA+CjF"}
|