@nuasite/cms-marker 0.0.71 → 0.0.73
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/dist/types/build-processor.d.ts.map +1 -1
- package/dist/types/dev-middleware.d.ts.map +1 -1
- package/dist/types/source-finder/ast-extractors.d.ts +35 -0
- package/dist/types/source-finder/ast-extractors.d.ts.map +1 -0
- package/dist/types/source-finder/ast-parser.d.ts +16 -0
- package/dist/types/source-finder/ast-parser.d.ts.map +1 -0
- package/dist/types/source-finder/cache.d.ts +18 -0
- package/dist/types/source-finder/cache.d.ts.map +1 -0
- package/dist/types/source-finder/collection-finder.d.ts +24 -0
- package/dist/types/source-finder/collection-finder.d.ts.map +1 -0
- package/dist/types/source-finder/cross-file-tracker.d.ts +29 -0
- package/dist/types/source-finder/cross-file-tracker.d.ts.map +1 -0
- package/dist/types/source-finder/element-finder.d.ts +42 -0
- package/dist/types/source-finder/element-finder.d.ts.map +1 -0
- package/dist/types/source-finder/image-finder.d.ts +16 -0
- package/dist/types/source-finder/image-finder.d.ts.map +1 -0
- package/dist/types/source-finder/index.d.ts +8 -0
- package/dist/types/source-finder/index.d.ts.map +1 -0
- package/dist/types/source-finder/search-index.d.ts +27 -0
- package/dist/types/source-finder/search-index.d.ts.map +1 -0
- package/dist/types/source-finder/snippet-utils.d.ts +49 -0
- package/dist/types/source-finder/snippet-utils.d.ts.map +1 -0
- package/dist/types/source-finder/source-lookup.d.ts +16 -0
- package/dist/types/source-finder/source-lookup.d.ts.map +1 -0
- package/dist/types/source-finder/types.d.ts +163 -0
- package/dist/types/source-finder/types.d.ts.map +1 -0
- package/dist/types/source-finder/variable-extraction.d.ts +37 -0
- package/dist/types/source-finder/variable-extraction.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/build-processor.ts +33 -1
- package/src/dev-middleware.ts +33 -1
- package/src/source-finder/ast-extractors.ts +175 -0
- package/src/source-finder/ast-parser.ts +127 -0
- package/src/source-finder/cache.ts +75 -0
- package/src/source-finder/collection-finder.ts +321 -0
- package/src/source-finder/cross-file-tracker.ts +337 -0
- package/src/source-finder/element-finder.ts +383 -0
- package/src/source-finder/image-finder.ts +189 -0
- package/src/source-finder/index.ts +26 -0
- package/src/source-finder/search-index.ts +418 -0
- package/src/source-finder/snippet-utils.ts +268 -0
- package/src/source-finder/source-lookup.ts +197 -0
- package/src/source-finder/types.ts +206 -0
- package/src/source-finder/variable-extraction.ts +355 -0
- package/dist/types/source-finder.d.ts +0 -117
- package/dist/types/source-finder.d.ts.map +0 -1
- package/src/source-finder.ts +0 -1784
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-processor.d.ts","sourceRoot":"","sources":["../../src/build-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"build-processor.d.ts","sourceRoot":"","sources":["../../src/build-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAMnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAUvD,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAA;AA4OhE;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAClC,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5B,MAAM,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiDf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-middleware.d.ts","sourceRoot":"","sources":["../../src/dev-middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev-middleware.d.ts","sourceRoot":"","sources":["../../src/dev-middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAmB,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAErF,4GAA4G;AAC5G,UAAU,iBAAiB;IAC1B,WAAW,EAAE;QACZ,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,CAAA;KAChG,CAAA;IACD,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAClE;AAkBD,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAClC,cAAc,EAAE,cAAc,EAC9B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACzD,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,QA6H5B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BabelNode, LineTransformer, VariableDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Extract string value from a Babel node (StringLiteral or simple TemplateLiteral)
|
|
4
|
+
*/
|
|
5
|
+
export declare function getStringValue(node: BabelNode): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Recursively extract properties from an object expression
|
|
8
|
+
* @param objNode - The ObjectExpression node
|
|
9
|
+
* @param parentPath - The full path to this object (e.g., 'config' or 'config.nav')
|
|
10
|
+
* @param definitions - Array to collect definitions into
|
|
11
|
+
* @param lineTransformer - Transforms Babel line numbers to file line numbers
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractObjectProperties(objNode: BabelNode, parentPath: string, definitions: VariableDefinition[], lineTransformer: LineTransformer): void;
|
|
14
|
+
/**
|
|
15
|
+
* Extract elements from an array expression
|
|
16
|
+
* @param arrNode - The ArrayExpression node
|
|
17
|
+
* @param parentPath - The full path to this array (e.g., 'items' or 'config.items')
|
|
18
|
+
* @param definitions - Array to collect definitions into
|
|
19
|
+
* @param lineTransformer - Transforms Babel line numbers to file line numbers
|
|
20
|
+
* @param defaultLine - Fallback line if element has no location
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractArrayElements(arrNode: BabelNode, parentPath: string, definitions: VariableDefinition[], lineTransformer: LineTransformer, defaultLine: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Build the full path for a variable definition.
|
|
25
|
+
* For array indices (numeric names), uses bracket notation: items[0]
|
|
26
|
+
* For object properties, uses dot notation: config.nav.title
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildDefinitionPath(def: VariableDefinition): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parse an expression path and extract the full path for variable lookup.
|
|
31
|
+
* Handles patterns like: varName, obj.prop, items[0], config.nav.title, links[0].text
|
|
32
|
+
* @returns The full expression path or null if not a simple variable reference
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseExpressionPath(exprText: string): string | null;
|
|
35
|
+
//# sourceMappingURL=ast-extractors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-extractors.d.ts","sourceRoot":"","sources":["../../../src/source-finder/ast-extractors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAM7E;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAY7D;AAMD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,SAAS,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,kBAAkB,EAAE,EACjC,eAAe,EAAE,eAAe,GAC9B,IAAI,CAiCN;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,SAAS,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,kBAAkB,EAAE,EACjC,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,MAAM,GACjB,IAAI,CAmDN;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CASnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQnE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BabelFile, CachedParsedFile, ParsedAstroFile } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse an Astro file and return both template AST and frontmatter content
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseAstroFile(content: string): Promise<ParsedAstroFile>;
|
|
6
|
+
/**
|
|
7
|
+
* Parse frontmatter JavaScript/TypeScript with Babel
|
|
8
|
+
* @param content - The frontmatter content to parse
|
|
9
|
+
* @param filePath - Optional file path for error reporting
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseFrontmatter(content: string, filePath?: string): BabelFile | null;
|
|
12
|
+
/**
|
|
13
|
+
* Get a cached parsed file, parsing it if not cached
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCachedParsedFile(filePath: string): Promise<CachedParsedFile | null>;
|
|
16
|
+
//# sourceMappingURL=ast-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-parser.d.ts","sourceRoot":"","sources":["../../../src/source-finder/ast-parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO3E;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB9E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAiBrF;AAMD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAwD5F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CachedParsedFile, ImageIndexEntry, SearchIndexEntry } from './types';
|
|
2
|
+
export declare function getParsedFileCache(): Map<string, CachedParsedFile>;
|
|
3
|
+
export declare function getDirectoryCache(): Map<string, string[]>;
|
|
4
|
+
export declare function getMarkdownFileCache(): Map<string, {
|
|
5
|
+
content: string;
|
|
6
|
+
lines: string[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare function getTextSearchIndex(): SearchIndexEntry[];
|
|
9
|
+
export declare function getImageSearchIndex(): ImageIndexEntry[];
|
|
10
|
+
export declare function isSearchIndexInitialized(): boolean;
|
|
11
|
+
export declare function setSearchIndexInitialized(value: boolean): void;
|
|
12
|
+
export declare function addToTextSearchIndex(entry: SearchIndexEntry): void;
|
|
13
|
+
export declare function addToImageSearchIndex(entry: ImageIndexEntry): void;
|
|
14
|
+
/**
|
|
15
|
+
* Clear all caches - call at start of each build
|
|
16
|
+
*/
|
|
17
|
+
export declare function clearSourceFinderCache(): void;
|
|
18
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/source-finder/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAwBlF,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAElE;AAED,wBAAgB,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAEzD;AAED,wBAAgB,oBAAoB,IAAI,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAExF;AAED,wBAAgB,kBAAkB,IAAI,gBAAgB,EAAE,CAEvD;AAED,wBAAgB,mBAAmB,IAAI,eAAe,EAAE,CAEvD;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE9D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAElE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAElE;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAO7C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CollectionInfo, MarkdownContent, SourceLocation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Find markdown collection file for a given page path
|
|
4
|
+
* @param pagePath - The URL path of the page (e.g., '/services/3d-tisk')
|
|
5
|
+
* @param contentDir - The content directory (default: 'src/content')
|
|
6
|
+
* @returns Collection info if found, undefined otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function findCollectionSource(pagePath: string, contentDir?: string): Promise<CollectionInfo | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* Find text content in a markdown file and return source location
|
|
11
|
+
* Only matches frontmatter fields, not body content (body is handled separately as a whole)
|
|
12
|
+
* @param textContent - The text content to search for
|
|
13
|
+
* @param collectionInfo - Collection information (name, slug, file path)
|
|
14
|
+
* @returns Source location if found in frontmatter
|
|
15
|
+
*/
|
|
16
|
+
export declare function findMarkdownSourceLocation(textContent: string, collectionInfo: CollectionInfo): Promise<SourceLocation | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Parse markdown file and extract frontmatter fields and full body content.
|
|
19
|
+
* Uses caching for better performance.
|
|
20
|
+
* @param collectionInfo - Collection information (name, slug, file path)
|
|
21
|
+
* @returns Parsed markdown content with frontmatter and body
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseMarkdownContent(collectionInfo: CollectionInfo): Promise<MarkdownContent | undefined>;
|
|
24
|
+
//# sourceMappingURL=collection-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-finder.d.ts","sourceRoot":"","sources":["../../../src/source-finder/collection-finder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AA6B9E;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,MAAsB,GAChC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAoDrC;AA8DD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC/C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAmErC;AAMD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAuEtC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImportInfo, SourceLocation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Search for a component usage with an expression prop across all files.
|
|
4
|
+
* When we find an expression like {items[0]} in a component where items comes from props,
|
|
5
|
+
* we search for where that component is used and track the expression prop back.
|
|
6
|
+
* Supports multi-level prop drilling with a depth limit.
|
|
7
|
+
*
|
|
8
|
+
* @param componentFileName - The file name of the component (e.g., 'Nav.astro')
|
|
9
|
+
* @param propName - The prop name we're looking for (e.g., 'items')
|
|
10
|
+
* @param expressionPath - The full expression path (e.g., 'items[0]')
|
|
11
|
+
* @param searchText - The text content we're searching for
|
|
12
|
+
* @param depth - Current recursion depth (default 0, max 5)
|
|
13
|
+
* @returns Source location if found
|
|
14
|
+
*/
|
|
15
|
+
export declare function searchForExpressionProp(componentFileName: string, propName: string, expressionPath: string, searchText: string, depth?: number): Promise<SourceLocation | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Search for a value in an imported file.
|
|
18
|
+
* @param fromFile - The file that contains the import
|
|
19
|
+
* @param importInfo - Information about the import
|
|
20
|
+
* @param expressionPath - The full expression path (e.g., 'config.title' or 'navItems[0]')
|
|
21
|
+
* @param searchText - The text content we're searching for
|
|
22
|
+
*/
|
|
23
|
+
export declare function searchForImportedValue(fromFile: string, importInfo: ImportInfo, expressionPath: string, searchText: string): Promise<SourceLocation | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Search for prop values passed to components using AST parsing.
|
|
26
|
+
* Uses caching for better performance.
|
|
27
|
+
*/
|
|
28
|
+
export declare function searchForPropInParents(dir: string, textContent: string): Promise<SourceLocation | undefined>;
|
|
29
|
+
//# sourceMappingURL=cross-file-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-file-tracker.d.ts","sourceRoot":"","sources":["../../../src/source-finder/cross-file-tracker.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAOzD;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC5C,iBAAiB,EAAE,MAAM,EACzB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,MAAU,GACf,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAiCrC;AAwID;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC3C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAkDrC;AAMD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA6DlH"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Node as AstroNode } from '@astrojs/compiler/types';
|
|
2
|
+
import type { ComponentPropMatch, ExpressionPropMatch, FindElementResult, ImportInfo, SpreadPropMatch, VariableDefinition } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Get text content from an AST node recursively.
|
|
5
|
+
* Treats <br> elements as whitespace to match rendered HTML behavior.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getTextContent(node: AstroNode): string;
|
|
8
|
+
/**
|
|
9
|
+
* Check for expression children and extract variable names
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasExpressionChild(node: AstroNode): {
|
|
12
|
+
found: boolean;
|
|
13
|
+
varNames: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Walk the Astro AST to find elements matching a tag with specific text content.
|
|
17
|
+
* Returns the best match (local variables or static content) AND all prop/import candidates
|
|
18
|
+
* that need cross-file verification for multiple same-tag elements.
|
|
19
|
+
* @param propAliases - Map of local variable names to prop names from Astro.props (for cross-file tracking)
|
|
20
|
+
* @param imports - Import information from frontmatter (for cross-file tracking)
|
|
21
|
+
*/
|
|
22
|
+
export declare function findElementWithText(ast: AstroNode, tag: string, searchText: string, variableDefinitions: VariableDefinition[], propAliases?: Map<string, string>, imports?: ImportInfo[]): FindElementResult;
|
|
23
|
+
/**
|
|
24
|
+
* Walk the Astro AST to find component props with specific text value
|
|
25
|
+
*/
|
|
26
|
+
export declare function findComponentProp(ast: AstroNode, searchText: string): ComponentPropMatch | null;
|
|
27
|
+
/**
|
|
28
|
+
* Walk the Astro AST to find component usages with expression props.
|
|
29
|
+
* Looks for patterns like: <Nav items={navItems} />
|
|
30
|
+
* @param ast - The Astro AST
|
|
31
|
+
* @param componentName - The component name to search for (e.g., 'Nav')
|
|
32
|
+
* @param propName - The prop name to find (e.g., 'items')
|
|
33
|
+
*/
|
|
34
|
+
export declare function findExpressionProp(ast: AstroNode, componentName: string, propName: string): ExpressionPropMatch | null;
|
|
35
|
+
/**
|
|
36
|
+
* Walk the Astro AST to find component usages with spread props.
|
|
37
|
+
* Looks for patterns like: <Card {...cardProps} />
|
|
38
|
+
* @param ast - The Astro AST
|
|
39
|
+
* @param componentName - The component name to search for (e.g., 'Card')
|
|
40
|
+
*/
|
|
41
|
+
export declare function findSpreadProp(ast: AstroNode, componentName: string): SpreadPropMatch | null;
|
|
42
|
+
//# sourceMappingURL=element-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-finder.d.ts","sourceRoot":"","sources":["../../../src/source-finder/element-finder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,IAAI,IAAI,SAAS,EAAY,MAAM,yBAAyB,CAAA;AAItG,OAAO,KAAK,EACX,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,kBAAkB,EAClB,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAYtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAsB1F;AAMD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,kBAAkB,EAAE,EACzC,WAAW,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,EAC5C,OAAO,GAAE,UAAU,EAAO,GACxB,iBAAiB,CAoKnB;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,MAAM,GAChB,kBAAkB,GAAG,IAAI,CAiC3B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,SAAS,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACd,mBAAmB,GAAG,IAAI,CAoC5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,SAAS,EACd,aAAa,EAAE,MAAM,GACnB,eAAe,GAAG,IAAI,CAgCxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Node as AstroNode } from '@astrojs/compiler/types';
|
|
2
|
+
import type { ImageMatch, SourceLocation } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Walk the Astro AST to find img elements with specific src
|
|
5
|
+
*/
|
|
6
|
+
export declare function findImageElement(ast: AstroNode, imageSrc: string, lines: string[]): ImageMatch | null;
|
|
7
|
+
/**
|
|
8
|
+
* Find source file and line number for an image by its src attribute.
|
|
9
|
+
* Uses pre-built search index for fast lookups.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findImageSourceLocation(imageSrc: string): Promise<SourceLocation | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Recursively search directory for image with matching src
|
|
14
|
+
*/
|
|
15
|
+
export declare function searchDirectoryForImage(dir: string, imageSrc: string): Promise<SourceLocation | undefined>;
|
|
16
|
+
//# sourceMappingURL=image-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-finder.d.ts","sourceRoot":"","sources":["../../../src/source-finder/image-finder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,IAAI,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAS7E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAMzD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EAAE,GACb,UAAU,GAAG,IAAI,CA+BnB;AAMD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC5C,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA+BrC;AAMD;;GAEG;AACH,wBAAsB,uBAAuB,CAC5C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAoBrC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { CollectionInfo, MarkdownContent, SourceLocation, VariableReference } from './types';
|
|
2
|
+
export { clearSourceFinderCache } from './cache';
|
|
3
|
+
export { initializeSearchIndex } from './search-index';
|
|
4
|
+
export { findSourceLocation } from './source-lookup';
|
|
5
|
+
export { findImageSourceLocation } from './image-finder';
|
|
6
|
+
export { findCollectionSource, findMarkdownSourceLocation, parseMarkdownContent } from './collection-finder';
|
|
7
|
+
export { enhanceManifestWithSourceSnippets, extractCompleteTagSnippet, extractInnerHtmlFromSnippet, extractSourceInnerHtml } from './snippet-utils';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/source-finder/index.ts"],"names":[],"mappings":"AAOA,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAGxD,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG5G,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CachedParsedFile, SourceLocation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Collect all .astro files in a directory recursively
|
|
4
|
+
*/
|
|
5
|
+
export declare function collectAstroFiles(dir: string): Promise<string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Initialize search index by pre-scanning all source files.
|
|
8
|
+
* This is much faster than searching per-entry.
|
|
9
|
+
*/
|
|
10
|
+
export declare function initializeSearchIndex(): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Index all searchable text content from a parsed file
|
|
13
|
+
*/
|
|
14
|
+
export declare function indexFileContent(cached: CachedParsedFile, relFile: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Index all images from a parsed file
|
|
17
|
+
*/
|
|
18
|
+
export declare function indexFileImages(cached: CachedParsedFile, relFile: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Fast text lookup using pre-built index
|
|
21
|
+
*/
|
|
22
|
+
export declare function findInTextIndex(textContent: string, tag: string): SourceLocation | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Fast image lookup using pre-built index
|
|
25
|
+
*/
|
|
26
|
+
export declare function findInImageIndex(imageSrc: string): SourceLocation | undefined;
|
|
27
|
+
//# sourceMappingURL=search-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index.d.ts","sourceRoot":"","sources":["../../../src/source-finder/search-index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM/D;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyBtE;AAMD;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwC3D;AA8FD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAqFhF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAmD/E;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAmD5F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAa7E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ManifestEntry } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalize text for comparison (handles escaping and entities)
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeText(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Strip markdown syntax for text comparison
|
|
8
|
+
*/
|
|
9
|
+
export declare function stripMarkdownSyntax(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Extract complete tag snippet including content and indentation.
|
|
12
|
+
* Exported for use in html-processor to populate sourceSnippet.
|
|
13
|
+
*
|
|
14
|
+
* When startLine points to a line inside the element (e.g., the text content line),
|
|
15
|
+
* this function searches backwards to find the opening tag first.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractCompleteTagSnippet(lines: string[], startLine: number, tag: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Extract innerHTML from a complete tag snippet.
|
|
20
|
+
* Given `<p class="foo">content here</p>`, returns `content here`.
|
|
21
|
+
*
|
|
22
|
+
* @param snippet - The complete tag snippet from source
|
|
23
|
+
* @param tag - The tag name (e.g., 'p', 'h1')
|
|
24
|
+
* @returns The innerHTML portion, or undefined if can't extract
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractInnerHtmlFromSnippet(snippet: string, tag: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Extract the full <img> tag snippet from source lines
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractImageSnippet(lines: string[], startLine: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Read source file and extract the innerHTML at the specified line.
|
|
33
|
+
*
|
|
34
|
+
* @param sourceFile - Path to source file (relative to cwd)
|
|
35
|
+
* @param sourceLine - 1-indexed line number
|
|
36
|
+
* @param tag - The tag name
|
|
37
|
+
* @returns The innerHTML from source, or undefined if can't extract
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractSourceInnerHtml(sourceFile: string, sourceLine: number, tag: string): Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Enhance manifest entries with actual source snippets from source files.
|
|
42
|
+
* This reads the source files and extracts the innerHTML at the specified locations.
|
|
43
|
+
* For images, it finds the correct line containing the src attribute.
|
|
44
|
+
*
|
|
45
|
+
* @param entries - Manifest entries to enhance
|
|
46
|
+
* @returns Enhanced entries with sourceSnippet populated
|
|
47
|
+
*/
|
|
48
|
+
export declare function enhanceManifestWithSourceSnippets(entries: Record<string, ManifestEntry>): Promise<Record<string, ManifestEntry>>;
|
|
49
|
+
//# sourceMappingURL=snippet-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet-utils.d.ts","sourceRoot":"","sources":["../../../src/source-finder/snippet-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAQ7C;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYxD;AAMD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAyDjG;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAqB5F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAuB9E;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiB7B;AAMD;;;;;;;GAOG;AACH,wBAAsB,iCAAiC,CACtD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAgDxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SourceLocation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Find source file and line number for text content.
|
|
4
|
+
* Uses pre-built search index for fast lookups.
|
|
5
|
+
*/
|
|
6
|
+
export declare function findSourceLocation(textContent: string, tag: string): Promise<SourceLocation | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Recursively search directory for matching content
|
|
9
|
+
*/
|
|
10
|
+
export declare function searchDirectory(dir: string, textContent: string, tag: string): Promise<SourceLocation | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Search a single Astro file for matching content using AST parsing.
|
|
13
|
+
* Uses caching for better performance.
|
|
14
|
+
*/
|
|
15
|
+
export declare function searchAstroFile(filePath: string, textContent: string, tag: string): Promise<SourceLocation | undefined>;
|
|
16
|
+
//# sourceMappingURL=source-lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-lookup.d.ts","sourceRoot":"","sources":["../../../src/source-finder/source-lookup.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA2CrC;AAMD;;GAEG;AACH,wBAAsB,eAAe,CACpC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAoBrC;AAMD;;;GAGG;AACH,wBAAsB,eAAe,CACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAmFrC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { Node as AstroNode } from '@astrojs/compiler/types';
|
|
2
|
+
/** Import information from frontmatter */
|
|
3
|
+
export interface ImportInfo {
|
|
4
|
+
/** Local name of the imported binding */
|
|
5
|
+
localName: string;
|
|
6
|
+
/** Original exported name (or 'default' for default imports) */
|
|
7
|
+
importedName: string;
|
|
8
|
+
/** The import source path (e.g., './config', '../data/nav') */
|
|
9
|
+
source: string;
|
|
10
|
+
}
|
|
11
|
+
export interface VariableDefinition {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
line: number;
|
|
15
|
+
/** For object properties, the parent variable name */
|
|
16
|
+
parentName?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CachedParsedFile {
|
|
19
|
+
content: string;
|
|
20
|
+
lines: string[];
|
|
21
|
+
ast: AstroNode;
|
|
22
|
+
frontmatterContent: string | null;
|
|
23
|
+
frontmatterStartLine: number;
|
|
24
|
+
variableDefinitions: VariableDefinition[];
|
|
25
|
+
/** Mapping of local variable names to prop names from Astro.props destructuring
|
|
26
|
+
* e.g., { navItems: 'items' } for `const { items: navItems } = Astro.props` */
|
|
27
|
+
propAliases: Map<string, string>;
|
|
28
|
+
/** Import information from frontmatter */
|
|
29
|
+
imports: ImportInfo[];
|
|
30
|
+
}
|
|
31
|
+
/** Pre-built search index for fast lookups */
|
|
32
|
+
export interface SearchIndexEntry {
|
|
33
|
+
file: string;
|
|
34
|
+
line: number;
|
|
35
|
+
snippet: string;
|
|
36
|
+
type: 'static' | 'variable' | 'prop' | 'computed';
|
|
37
|
+
variableName?: string;
|
|
38
|
+
definitionLine?: number;
|
|
39
|
+
normalizedText: string;
|
|
40
|
+
tag: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ImageIndexEntry {
|
|
43
|
+
file: string;
|
|
44
|
+
line: number;
|
|
45
|
+
snippet: string;
|
|
46
|
+
src: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SourceLocation {
|
|
49
|
+
file: string;
|
|
50
|
+
line: number;
|
|
51
|
+
snippet?: string;
|
|
52
|
+
type?: 'static' | 'variable' | 'prop' | 'computed' | 'collection';
|
|
53
|
+
variableName?: string;
|
|
54
|
+
definitionLine?: number;
|
|
55
|
+
/** Collection name for collection entries */
|
|
56
|
+
collectionName?: string;
|
|
57
|
+
/** Entry slug for collection entries */
|
|
58
|
+
collectionSlug?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface VariableReference {
|
|
61
|
+
name: string;
|
|
62
|
+
pattern: string;
|
|
63
|
+
definitionLine: number;
|
|
64
|
+
}
|
|
65
|
+
export interface CollectionInfo {
|
|
66
|
+
name: string;
|
|
67
|
+
slug: string;
|
|
68
|
+
file: string;
|
|
69
|
+
}
|
|
70
|
+
export interface MarkdownContent {
|
|
71
|
+
/** Frontmatter fields as key-value pairs with line numbers */
|
|
72
|
+
frontmatter: Record<string, {
|
|
73
|
+
value: string;
|
|
74
|
+
line: number;
|
|
75
|
+
}>;
|
|
76
|
+
/** The full markdown body content */
|
|
77
|
+
body: string;
|
|
78
|
+
/** Line number where body starts */
|
|
79
|
+
bodyStartLine: number;
|
|
80
|
+
/** File path relative to cwd */
|
|
81
|
+
file: string;
|
|
82
|
+
/** Collection name */
|
|
83
|
+
collectionName: string;
|
|
84
|
+
/** Collection slug */
|
|
85
|
+
collectionSlug: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ParsedAstroFile {
|
|
88
|
+
ast: AstroNode;
|
|
89
|
+
frontmatterContent: string | null;
|
|
90
|
+
frontmatterStartLine: number;
|
|
91
|
+
}
|
|
92
|
+
/** Minimal Babel AST node type for our usage */
|
|
93
|
+
export interface BabelNode {
|
|
94
|
+
type: string;
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
}
|
|
97
|
+
/** Minimal Babel File type */
|
|
98
|
+
export interface BabelFile {
|
|
99
|
+
type: 'File';
|
|
100
|
+
program: BabelNode & {
|
|
101
|
+
body: BabelNode[];
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export interface TemplateMatch {
|
|
105
|
+
line: number;
|
|
106
|
+
type: 'static' | 'variable' | 'computed';
|
|
107
|
+
variableName?: string;
|
|
108
|
+
/** For variables, the definition line in frontmatter */
|
|
109
|
+
definitionLine?: number;
|
|
110
|
+
/** If true, the expression uses a variable from props that needs cross-file tracking */
|
|
111
|
+
usesProp?: boolean;
|
|
112
|
+
/** The prop name if usesProp is true */
|
|
113
|
+
propName?: string;
|
|
114
|
+
/** The full expression path if usesProp is true (e.g., 'items[0]') */
|
|
115
|
+
expressionPath?: string;
|
|
116
|
+
/** If true, the expression uses a variable from an import */
|
|
117
|
+
usesImport?: boolean;
|
|
118
|
+
/** The import info if usesImport is true */
|
|
119
|
+
importInfo?: ImportInfo;
|
|
120
|
+
}
|
|
121
|
+
/** Result type for findElementWithText - returns best match and all prop/import candidates */
|
|
122
|
+
export interface FindElementResult {
|
|
123
|
+
/** The best match found (local variables or static content) */
|
|
124
|
+
bestMatch: TemplateMatch | null;
|
|
125
|
+
/** All prop-based matches for the tag (need cross-file verification) */
|
|
126
|
+
propCandidates: TemplateMatch[];
|
|
127
|
+
/** All import-based matches for the tag (need cross-file verification) */
|
|
128
|
+
importCandidates: TemplateMatch[];
|
|
129
|
+
}
|
|
130
|
+
export interface ComponentPropMatch {
|
|
131
|
+
line: number;
|
|
132
|
+
propName: string;
|
|
133
|
+
propValue: string;
|
|
134
|
+
}
|
|
135
|
+
export interface ExpressionPropMatch {
|
|
136
|
+
componentName: string;
|
|
137
|
+
propName: string;
|
|
138
|
+
/** The expression text (e.g., 'navItems' from items={navItems}) */
|
|
139
|
+
expressionText: string;
|
|
140
|
+
line: number;
|
|
141
|
+
}
|
|
142
|
+
export interface SpreadPropMatch {
|
|
143
|
+
componentName: string;
|
|
144
|
+
/** The variable name being spread (e.g., 'cardProps' from {...cardProps}) */
|
|
145
|
+
spreadVarName: string;
|
|
146
|
+
line: number;
|
|
147
|
+
}
|
|
148
|
+
export interface ImageMatch {
|
|
149
|
+
line: number;
|
|
150
|
+
src: string;
|
|
151
|
+
snippet: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Transforms Babel line numbers to actual file line numbers.
|
|
155
|
+
* Babel parses content starting at line 1, but frontmatter content
|
|
156
|
+
* may start at a different line in the actual file.
|
|
157
|
+
*/
|
|
158
|
+
export type LineTransformer = (babelLine: number) => number;
|
|
159
|
+
/** Identity transformer - use for standalone files where Babel line = file line */
|
|
160
|
+
export declare const identityLine: LineTransformer;
|
|
161
|
+
/** Create a transformer for frontmatter content that starts at a specific line */
|
|
162
|
+
export declare const createFrontmatterLineTransformer: (startLine: number) => LineTransformer;
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/source-finder/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAMhE,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IAC1B,yCAAyC;IACzC,SAAS,EA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AAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;CACf;AAMD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;AAE3D,mFAAmF;AACnF,eAAO,MAAM,YAAY,EAAE,eAAgC,CAAA;AAE3D,kFAAkF;AAClF,eAAO,MAAM,gCAAgC,GAAI,WAAW,MAAM,KAAG,eAA6D,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BabelFile, ImportInfo, VariableDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Extract variable definitions from Babel AST
|
|
4
|
+
* Finds const/let/var declarations with string literal values
|
|
5
|
+
*
|
|
6
|
+
* Note: Babel parses the frontmatter content (without --- delimiters) starting at line 1.
|
|
7
|
+
* frontmatterStartLine is the actual file line where the content begins (after first ---).
|
|
8
|
+
* So we convert: file_line = (babel_line - 1) + frontmatterStartLine
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractVariableDefinitions(ast: BabelFile, frontmatterStartLine: number): VariableDefinition[];
|
|
11
|
+
/**
|
|
12
|
+
* Extract prop aliases from Astro.props destructuring patterns.
|
|
13
|
+
* Returns a Map of local variable name -> prop name.
|
|
14
|
+
* Examples:
|
|
15
|
+
* const { title } = Astro.props -> Map { 'title' => 'title' }
|
|
16
|
+
* const { items: navItems } = Astro.props -> Map { 'navItems' => 'items' }
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractPropAliases(ast: BabelFile): Map<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Extract import information from Babel AST.
|
|
21
|
+
* Handles:
|
|
22
|
+
* import { foo } from './file' -> { localName: 'foo', importedName: 'foo', source: './file' }
|
|
23
|
+
* import { foo as bar } from './file' -> { localName: 'bar', importedName: 'foo', source: './file' }
|
|
24
|
+
* import foo from './file' -> { localName: 'foo', importedName: 'default', source: './file' }
|
|
25
|
+
* import * as foo from './file' -> { localName: 'foo', importedName: '*', source: './file' }
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractImports(ast: BabelFile): ImportInfo[];
|
|
28
|
+
/**
|
|
29
|
+
* Resolve an import source path to an absolute file path.
|
|
30
|
+
* Handles relative paths and tries common extensions.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveImportPath(source: string, fromFile: string): Promise<string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Parse a TypeScript/JavaScript file and extract exported variable definitions.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getExportedDefinitions(filePath: string): Promise<VariableDefinition[]>;
|
|
37
|
+
//# sourceMappingURL=variable-extraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-extraction.d.ts","sourceRoot":"","sources":["../../../src/source-finder/variable-extraction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAa,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAOnF;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAqD7G;AAMD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgFtE;AAMD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,UAAU,EAAE,CA+C3D;AAMD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiChG;AAMD;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA2E5F"}
|