@nuasite/cms-marker 0.0.47 → 0.0.48

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "directory": "packages/cms-marker"
15
15
  },
16
16
  "license": "Apache-2.0",
17
- "version": "0.0.47",
17
+ "version": "0.0.48",
18
18
  "module": "src/index.ts",
19
19
  "types": "src/index.ts",
20
20
  "type": "module",
@@ -4,6 +4,7 @@ import path from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
5
  import { processHtml } from './html-processor'
6
6
  import type { ManifestWriter } from './manifest-writer'
7
+ import { findSourceLocation } from './source-finder'
7
8
  import type { CmsMarkerOptions } from './types'
8
9
 
9
10
  // Concurrency limit for parallel processing
@@ -66,8 +67,23 @@ async function processFile(
66
67
  idGenerator,
67
68
  )
68
69
 
69
- // Note: Source locations are now extracted from Astro's compiler attributes
70
- // in html-processor.ts, so we don't need the expensive findSourceLocation calls
70
+ // During build, source location attributes are not injected by astro-transform.ts
71
+ // (disabled to avoid Vite parse errors). Use findSourceLocation to look up source files.
72
+ for (const entry of Object.values(result.entries)) {
73
+ // Skip entries that already have source info from component detection
74
+ if (entry.sourcePath && !entry.sourcePath.endsWith('.html')) {
75
+ continue
76
+ }
77
+
78
+ const sourceLocation = await findSourceLocation(entry.text, entry.tag)
79
+ if (sourceLocation) {
80
+ entry.sourcePath = sourceLocation.file
81
+ entry.sourceLine = sourceLocation.line
82
+ entry.sourceSnippet = sourceLocation.snippet
83
+ entry.sourceType = sourceLocation.type
84
+ entry.variableName = sourceLocation.variableName
85
+ }
86
+ }
71
87
 
72
88
  // Add to manifest writer (handles per-page manifest writes)
73
89
  manifestWriter.addPage(pagePath, result.entries, result.components)
@@ -94,7 +94,7 @@ export class ComponentRegistry {
94
94
 
95
95
  while (i < content.length) {
96
96
  // Skip whitespace and newlines
97
- while (i < content.length && /\s/.test(content[i])) i++
97
+ while (i < content.length && /\s/.test(content[i] ?? '')) i++
98
98
  if (i >= content.length) break
99
99
 
100
100
  // Skip comments
@@ -113,27 +113,27 @@ export class ComponentRegistry {
113
113
 
114
114
  // Extract property name
115
115
  const nameStart = i
116
- while (i < content.length && /\w/.test(content[i])) i++
116
+ while (i < content.length && /\w/.test(content[i] ?? '')) i++
117
117
  const name = content.substring(nameStart, i)
118
118
 
119
119
  if (!name) break
120
120
 
121
121
  // Skip whitespace
122
- while (i < content.length && /\s/.test(content[i])) i++
122
+ while (i < content.length && /\s/.test(content[i] ?? '')) i++
123
123
 
124
124
  // Check for optional marker
125
125
  const optional = content[i] === '?'
126
126
  if (optional) i++
127
127
 
128
128
  // Skip whitespace
129
- while (i < content.length && /\s/.test(content[i])) i++
129
+ while (i < content.length && /\s/.test(content[i] ?? '')) i++
130
130
 
131
131
  // Expect colon
132
132
  if (content[i] !== ':') break
133
133
  i++
134
134
 
135
135
  // Skip whitespace
136
- while (i < content.length && /\s/.test(content[i])) i++
136
+ while (i < content.length && /\s/.test(content[i] ?? '')) i++
137
137
 
138
138
  // Extract type (up to semicolon, handling nested braces)
139
139
  const typeStart = i
@@ -154,7 +154,7 @@ export class ComponentRegistry {
154
154
  if (content[i] === ';') i++
155
155
 
156
156
  // Skip whitespace
157
- while (i < content.length && /[ \t]/.test(content[i])) i++
157
+ while (i < content.length && /[ \t]/.test(content[i] ?? '')) i++
158
158
 
159
159
  // Check for inline comment
160
160
  let description: string | undefined
@@ -215,7 +215,7 @@ export class ComponentRegistry {
215
215
 
216
216
  // Find the frontmatter section
217
217
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/)
218
- if (!frontmatterMatch) return props
218
+ if (!frontmatterMatch?.[1]) return props
219
219
 
220
220
  const frontmatter = frontmatterMatch[1]
221
221