@nuasite/cms-marker 0.0.72 → 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 -2765
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { parse as parseBabel } from '@babel/parser'
|
|
2
|
+
import fs from 'node:fs/promises'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { extractArrayElements, extractObjectProperties, getStringValue } from './ast-extractors'
|
|
6
|
+
import type { BabelFile, BabelNode, ImportInfo, VariableDefinition } from './types'
|
|
7
|
+
import { createFrontmatterLineTransformer, identityLine } from './types'
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Variable Definition Extraction
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Extract variable definitions from Babel AST
|
|
15
|
+
* Finds const/let/var declarations with string literal values
|
|
16
|
+
*
|
|
17
|
+
* Note: Babel parses the frontmatter content (without --- delimiters) starting at line 1.
|
|
18
|
+
* frontmatterStartLine is the actual file line where the content begins (after first ---).
|
|
19
|
+
* So we convert: file_line = (babel_line - 1) + frontmatterStartLine
|
|
20
|
+
*/
|
|
21
|
+
export function extractVariableDefinitions(ast: BabelFile, frontmatterStartLine: number): VariableDefinition[] {
|
|
22
|
+
const definitions: VariableDefinition[] = []
|
|
23
|
+
const lineTransformer = createFrontmatterLineTransformer(frontmatterStartLine)
|
|
24
|
+
|
|
25
|
+
function visitNode(node: BabelNode) {
|
|
26
|
+
if (node.type === 'VariableDeclaration') {
|
|
27
|
+
const declarations = node.declarations as BabelNode[] | undefined
|
|
28
|
+
for (const decl of declarations ?? []) {
|
|
29
|
+
const id = decl.id as BabelNode | undefined
|
|
30
|
+
const init = decl.init as BabelNode | undefined
|
|
31
|
+
if (id?.type === 'Identifier' && init) {
|
|
32
|
+
const varName = id.name as string
|
|
33
|
+
const loc = decl.loc as { start: { line: number } } | undefined
|
|
34
|
+
const line = lineTransformer(loc?.start.line ?? 1)
|
|
35
|
+
|
|
36
|
+
// Simple string value
|
|
37
|
+
const stringValue = getStringValue(init)
|
|
38
|
+
if (stringValue !== null) {
|
|
39
|
+
definitions.push({ name: varName, value: stringValue, line })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Object expression - extract properties recursively
|
|
43
|
+
if (init.type === 'ObjectExpression') {
|
|
44
|
+
extractObjectProperties(init, varName, definitions, lineTransformer)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Array expression - extract elements
|
|
48
|
+
if (init.type === 'ArrayExpression') {
|
|
49
|
+
extractArrayElements(init, varName, definitions, lineTransformer, line)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Recursively visit child nodes
|
|
56
|
+
for (const key of Object.keys(node)) {
|
|
57
|
+
const value = node[key]
|
|
58
|
+
if (value && typeof value === 'object') {
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
for (const item of value) {
|
|
61
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
62
|
+
visitNode(item as BabelNode)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else if ('type' in value) {
|
|
66
|
+
visitNode(value as BabelNode)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
visitNode(ast.program)
|
|
73
|
+
return definitions
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Prop Alias Extraction
|
|
78
|
+
// ============================================================================
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Extract prop aliases from Astro.props destructuring patterns.
|
|
82
|
+
* Returns a Map of local variable name -> prop name.
|
|
83
|
+
* Examples:
|
|
84
|
+
* const { title } = Astro.props -> Map { 'title' => 'title' }
|
|
85
|
+
* const { items: navItems } = Astro.props -> Map { 'navItems' => 'items' }
|
|
86
|
+
*/
|
|
87
|
+
export function extractPropAliases(ast: BabelFile): Map<string, string> {
|
|
88
|
+
const propAliases = new Map<string, string>()
|
|
89
|
+
|
|
90
|
+
function visitNode(node: BabelNode) {
|
|
91
|
+
if (node.type === 'VariableDeclaration') {
|
|
92
|
+
const declarations = node.declarations as BabelNode[] | undefined
|
|
93
|
+
for (const decl of declarations ?? []) {
|
|
94
|
+
const id = decl.id as BabelNode | undefined
|
|
95
|
+
const init = decl.init as BabelNode | undefined
|
|
96
|
+
|
|
97
|
+
// Check for destructuring from Astro.props
|
|
98
|
+
// Pattern: const { x, y } = Astro.props;
|
|
99
|
+
if (id?.type === 'ObjectPattern' && init?.type === 'MemberExpression') {
|
|
100
|
+
const object = init.object as BabelNode | undefined
|
|
101
|
+
const property = init.property as BabelNode | undefined
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
object?.type === 'Identifier'
|
|
105
|
+
&& (object.name as string) === 'Astro'
|
|
106
|
+
&& property?.type === 'Identifier'
|
|
107
|
+
&& (property.name as string) === 'props'
|
|
108
|
+
) {
|
|
109
|
+
// Extract property names from the destructuring pattern
|
|
110
|
+
const properties = id.properties as BabelNode[] | undefined
|
|
111
|
+
for (const prop of properties ?? []) {
|
|
112
|
+
if (prop.type === 'ObjectProperty') {
|
|
113
|
+
const key = prop.key as BabelNode | undefined
|
|
114
|
+
const value = prop.value as BabelNode | undefined
|
|
115
|
+
|
|
116
|
+
if (key?.type === 'Identifier') {
|
|
117
|
+
const propName = key.name as string
|
|
118
|
+
// Check for renaming: { items: navItems }
|
|
119
|
+
// key is the prop name (items), value is the local name (navItems)
|
|
120
|
+
if (value?.type === 'Identifier') {
|
|
121
|
+
const localName = value.name as string
|
|
122
|
+
propAliases.set(localName, propName)
|
|
123
|
+
} else if (value?.type === 'AssignmentPattern') {
|
|
124
|
+
// Handle default values: { items: navItems = [] } or { items = [] }
|
|
125
|
+
const left = value.left as BabelNode | undefined
|
|
126
|
+
if (left?.type === 'Identifier') {
|
|
127
|
+
propAliases.set(left.name as string, propName)
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
// Simple case: { items } - key and value are the same
|
|
131
|
+
propAliases.set(propName, propName)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} else if (prop.type === 'RestElement') {
|
|
135
|
+
// Handle rest pattern: const { x, ...rest } = Astro.props;
|
|
136
|
+
const argument = prop.argument as BabelNode | undefined
|
|
137
|
+
if (argument?.type === 'Identifier') {
|
|
138
|
+
// Rest element captures all remaining props
|
|
139
|
+
propAliases.set(argument.name as string, '...')
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Recursively visit child nodes
|
|
149
|
+
for (const key of Object.keys(node)) {
|
|
150
|
+
const value = node[key]
|
|
151
|
+
if (value && typeof value === 'object') {
|
|
152
|
+
if (Array.isArray(value)) {
|
|
153
|
+
for (const item of value) {
|
|
154
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
155
|
+
visitNode(item as BabelNode)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} else if ('type' in value) {
|
|
159
|
+
visitNode(value as BabelNode)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
visitNode(ast.program)
|
|
166
|
+
return propAliases
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// Import Extraction
|
|
171
|
+
// ============================================================================
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Extract import information from Babel AST.
|
|
175
|
+
* Handles:
|
|
176
|
+
* import { foo } from './file' -> { localName: 'foo', importedName: 'foo', source: './file' }
|
|
177
|
+
* import { foo as bar } from './file' -> { localName: 'bar', importedName: 'foo', source: './file' }
|
|
178
|
+
* import foo from './file' -> { localName: 'foo', importedName: 'default', source: './file' }
|
|
179
|
+
* import * as foo from './file' -> { localName: 'foo', importedName: '*', source: './file' }
|
|
180
|
+
*/
|
|
181
|
+
export function extractImports(ast: BabelFile): ImportInfo[] {
|
|
182
|
+
const imports: ImportInfo[] = []
|
|
183
|
+
|
|
184
|
+
for (const node of ast.program.body) {
|
|
185
|
+
if (node.type === 'ImportDeclaration') {
|
|
186
|
+
const source = (node.source as BabelNode)?.value as string
|
|
187
|
+
if (!source) continue
|
|
188
|
+
|
|
189
|
+
const specifiers = node.specifiers as BabelNode[] | undefined
|
|
190
|
+
for (const spec of specifiers ?? []) {
|
|
191
|
+
if (spec.type === 'ImportSpecifier') {
|
|
192
|
+
// Named import: import { foo } from './file' or import { foo as bar } from './file'
|
|
193
|
+
const imported = spec.imported as BabelNode | undefined
|
|
194
|
+
const local = spec.local as BabelNode | undefined
|
|
195
|
+
if (imported?.type === 'Identifier' && local?.type === 'Identifier') {
|
|
196
|
+
imports.push({
|
|
197
|
+
localName: local.name as string,
|
|
198
|
+
importedName: imported.name as string,
|
|
199
|
+
source,
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
} else if (spec.type === 'ImportDefaultSpecifier') {
|
|
203
|
+
// Default import: import foo from './file'
|
|
204
|
+
const local = spec.local as BabelNode | undefined
|
|
205
|
+
if (local?.type === 'Identifier') {
|
|
206
|
+
imports.push({
|
|
207
|
+
localName: local.name as string,
|
|
208
|
+
importedName: 'default',
|
|
209
|
+
source,
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
} else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
213
|
+
// Namespace import: import * as foo from './file'
|
|
214
|
+
const local = spec.local as BabelNode | undefined
|
|
215
|
+
if (local?.type === 'Identifier') {
|
|
216
|
+
imports.push({
|
|
217
|
+
localName: local.name as string,
|
|
218
|
+
importedName: '*',
|
|
219
|
+
source,
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return imports
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ============================================================================
|
|
231
|
+
// Import Resolution
|
|
232
|
+
// ============================================================================
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Resolve an import source path to an absolute file path.
|
|
236
|
+
* Handles relative paths and tries common extensions.
|
|
237
|
+
*/
|
|
238
|
+
export async function resolveImportPath(source: string, fromFile: string): Promise<string | null> {
|
|
239
|
+
// Only handle relative imports
|
|
240
|
+
if (!source.startsWith('.')) {
|
|
241
|
+
return null
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const fromDir = path.dirname(fromFile)
|
|
245
|
+
const basePath = path.resolve(fromDir, source)
|
|
246
|
+
|
|
247
|
+
// Try different extensions
|
|
248
|
+
const extensions = ['.ts', '.js', '.astro', '.tsx', '.jsx', '']
|
|
249
|
+
for (const ext of extensions) {
|
|
250
|
+
const fullPath = basePath + ext
|
|
251
|
+
try {
|
|
252
|
+
await fs.access(fullPath)
|
|
253
|
+
return fullPath
|
|
254
|
+
} catch {
|
|
255
|
+
// File doesn't exist with this extension
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Try index files
|
|
260
|
+
for (const ext of ['.ts', '.js', '.tsx', '.jsx']) {
|
|
261
|
+
const indexPath = path.join(basePath, `index${ext}`)
|
|
262
|
+
try {
|
|
263
|
+
await fs.access(indexPath)
|
|
264
|
+
return indexPath
|
|
265
|
+
} catch {
|
|
266
|
+
// File doesn't exist
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return null
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ============================================================================
|
|
274
|
+
// Export Extraction (for external files)
|
|
275
|
+
// ============================================================================
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Parse a TypeScript/JavaScript file and extract exported variable definitions.
|
|
279
|
+
*/
|
|
280
|
+
export async function getExportedDefinitions(filePath: string): Promise<VariableDefinition[]> {
|
|
281
|
+
try {
|
|
282
|
+
const content = await fs.readFile(filePath, 'utf-8')
|
|
283
|
+
const ast = parseBabel(content, {
|
|
284
|
+
sourceType: 'module',
|
|
285
|
+
plugins: ['typescript'],
|
|
286
|
+
errorRecovery: true,
|
|
287
|
+
}) as unknown as BabelFile
|
|
288
|
+
|
|
289
|
+
const definitions: VariableDefinition[] = []
|
|
290
|
+
|
|
291
|
+
for (const node of ast.program.body) {
|
|
292
|
+
// Handle: export const foo = 'value'
|
|
293
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
294
|
+
const declaration = node.declaration as BabelNode | undefined
|
|
295
|
+
if (declaration?.type === 'VariableDeclaration') {
|
|
296
|
+
const declarations = declaration.declarations as BabelNode[] | undefined
|
|
297
|
+
for (const decl of declarations ?? []) {
|
|
298
|
+
const id = decl.id as BabelNode | undefined
|
|
299
|
+
const init = decl.init as BabelNode | undefined
|
|
300
|
+
if (id?.type === 'Identifier' && init) {
|
|
301
|
+
const varName = id.name as string
|
|
302
|
+
const loc = decl.loc as { start: { line: number } } | undefined
|
|
303
|
+
const line = loc?.start.line ?? 1
|
|
304
|
+
|
|
305
|
+
const stringValue = getStringValue(init)
|
|
306
|
+
if (stringValue !== null) {
|
|
307
|
+
definitions.push({ name: varName, value: stringValue, line })
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (init.type === 'ObjectExpression') {
|
|
311
|
+
extractObjectProperties(init, varName, definitions, identityLine)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (init.type === 'ArrayExpression') {
|
|
315
|
+
extractArrayElements(init, varName, definitions, identityLine, line)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Handle: const foo = 'value'; export { foo }
|
|
323
|
+
// First collect all variable declarations
|
|
324
|
+
if (node.type === 'VariableDeclaration') {
|
|
325
|
+
const declarations = node.declarations as BabelNode[] | undefined
|
|
326
|
+
for (const decl of declarations ?? []) {
|
|
327
|
+
const id = decl.id as BabelNode | undefined
|
|
328
|
+
const init = decl.init as BabelNode | undefined
|
|
329
|
+
if (id?.type === 'Identifier' && init) {
|
|
330
|
+
const varName = id.name as string
|
|
331
|
+
const loc = decl.loc as { start: { line: number } } | undefined
|
|
332
|
+
const line = loc?.start.line ?? 1
|
|
333
|
+
|
|
334
|
+
const stringValue = getStringValue(init)
|
|
335
|
+
if (stringValue !== null) {
|
|
336
|
+
definitions.push({ name: varName, value: stringValue, line })
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (init.type === 'ObjectExpression') {
|
|
340
|
+
extractObjectProperties(init, varName, definitions, identityLine)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (init.type === 'ArrayExpression') {
|
|
344
|
+
extractArrayElements(init, varName, definitions, identityLine, line)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return definitions
|
|
352
|
+
} catch {
|
|
353
|
+
return []
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { ManifestEntry } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Clear all caches - call at start of each build
|
|
4
|
-
*/
|
|
5
|
-
export declare function clearSourceFinderCache(): void;
|
|
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
|
-
export interface SourceLocation {
|
|
12
|
-
file: string;
|
|
13
|
-
line: number;
|
|
14
|
-
snippet?: string;
|
|
15
|
-
type?: 'static' | 'variable' | 'prop' | 'computed' | 'collection';
|
|
16
|
-
variableName?: string;
|
|
17
|
-
definitionLine?: number;
|
|
18
|
-
/** Collection name for collection entries */
|
|
19
|
-
collectionName?: string;
|
|
20
|
-
/** Entry slug for collection entries */
|
|
21
|
-
collectionSlug?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface VariableReference {
|
|
24
|
-
name: string;
|
|
25
|
-
pattern: string;
|
|
26
|
-
definitionLine: number;
|
|
27
|
-
}
|
|
28
|
-
export interface CollectionInfo {
|
|
29
|
-
name: string;
|
|
30
|
-
slug: string;
|
|
31
|
-
file: string;
|
|
32
|
-
}
|
|
33
|
-
export interface MarkdownContent {
|
|
34
|
-
/** Frontmatter fields as key-value pairs with line numbers */
|
|
35
|
-
frontmatter: Record<string, {
|
|
36
|
-
value: string;
|
|
37
|
-
line: number;
|
|
38
|
-
}>;
|
|
39
|
-
/** The full markdown body content */
|
|
40
|
-
body: string;
|
|
41
|
-
/** Line number where body starts */
|
|
42
|
-
bodyStartLine: number;
|
|
43
|
-
/** File path relative to cwd */
|
|
44
|
-
file: string;
|
|
45
|
-
/** Collection name */
|
|
46
|
-
collectionName: string;
|
|
47
|
-
/** Collection slug */
|
|
48
|
-
collectionSlug: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Find source file and line number for text content.
|
|
52
|
-
* Uses pre-built search index for fast lookups.
|
|
53
|
-
*/
|
|
54
|
-
export declare function findSourceLocation(textContent: string, tag: string): Promise<SourceLocation | undefined>;
|
|
55
|
-
/**
|
|
56
|
-
* Find source file and line number for an image by its src attribute.
|
|
57
|
-
* Uses pre-built search index for fast lookups.
|
|
58
|
-
*/
|
|
59
|
-
export declare function findImageSourceLocation(imageSrc: string): Promise<SourceLocation | undefined>;
|
|
60
|
-
/**
|
|
61
|
-
* Extract complete tag snippet including content and indentation.
|
|
62
|
-
* Exported for use in html-processor to populate sourceSnippet.
|
|
63
|
-
*
|
|
64
|
-
* When startLine points to a line inside the element (e.g., the text content line),
|
|
65
|
-
* this function searches backwards to find the opening tag first.
|
|
66
|
-
*/
|
|
67
|
-
export declare function extractCompleteTagSnippet(lines: string[], startLine: number, tag: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* Extract innerHTML from a complete tag snippet.
|
|
70
|
-
* Given `<p class="foo">content here</p>`, returns `content here`.
|
|
71
|
-
*
|
|
72
|
-
* @param snippet - The complete tag snippet from source
|
|
73
|
-
* @param tag - The tag name (e.g., 'p', 'h1')
|
|
74
|
-
* @returns The innerHTML portion, or undefined if can't extract
|
|
75
|
-
*/
|
|
76
|
-
export declare function extractInnerHtmlFromSnippet(snippet: string, tag: string): string | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Read source file and extract the innerHTML at the specified line.
|
|
79
|
-
*
|
|
80
|
-
* @param sourceFile - Path to source file (relative to cwd)
|
|
81
|
-
* @param sourceLine - 1-indexed line number
|
|
82
|
-
* @param tag - The tag name
|
|
83
|
-
* @returns The innerHTML from source, or undefined if can't extract
|
|
84
|
-
*/
|
|
85
|
-
export declare function extractSourceInnerHtml(sourceFile: string, sourceLine: number, tag: string): Promise<string | undefined>;
|
|
86
|
-
/**
|
|
87
|
-
* Find markdown collection file for a given page path
|
|
88
|
-
* @param pagePath - The URL path of the page (e.g., '/services/3d-tisk')
|
|
89
|
-
* @param contentDir - The content directory (default: 'src/content')
|
|
90
|
-
* @returns Collection info if found, undefined otherwise
|
|
91
|
-
*/
|
|
92
|
-
export declare function findCollectionSource(pagePath: string, contentDir?: string): Promise<CollectionInfo | undefined>;
|
|
93
|
-
/**
|
|
94
|
-
* Find text content in a markdown file and return source location
|
|
95
|
-
* Only matches frontmatter fields, not body content (body is handled separately as a whole)
|
|
96
|
-
* @param textContent - The text content to search for
|
|
97
|
-
* @param collectionInfo - Collection information (name, slug, file path)
|
|
98
|
-
* @returns Source location if found in frontmatter
|
|
99
|
-
*/
|
|
100
|
-
export declare function findMarkdownSourceLocation(textContent: string, collectionInfo: CollectionInfo): Promise<SourceLocation | undefined>;
|
|
101
|
-
/**
|
|
102
|
-
* Parse markdown file and extract frontmatter fields and full body content.
|
|
103
|
-
* Uses caching for better performance.
|
|
104
|
-
* @param collectionInfo - Collection information (name, slug, file path)
|
|
105
|
-
* @returns Parsed markdown content with frontmatter and body
|
|
106
|
-
*/
|
|
107
|
-
export declare function parseMarkdownContent(collectionInfo: CollectionInfo): Promise<MarkdownContent | undefined>;
|
|
108
|
-
/**
|
|
109
|
-
* Enhance manifest entries with actual source snippets from source files.
|
|
110
|
-
* This reads the source files and extracts the innerHTML at the specified locations.
|
|
111
|
-
* For images, it finds the correct line containing the src attribute.
|
|
112
|
-
*
|
|
113
|
-
* @param entries - Manifest entries to enhance
|
|
114
|
-
* @returns Enhanced entries with sourceSnippet populated
|
|
115
|
-
*/
|
|
116
|
-
export declare function enhanceManifestWithSourceSnippets(entries: Record<string, ManifestEntry>): Promise<Record<string, ManifestEntry>>;
|
|
117
|
-
//# sourceMappingURL=source-finder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-finder.d.ts","sourceRoot":"","sources":["../../src/source-finder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAgE5C;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAO7C;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwC3D;AAqXD,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,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