@nuasite/cms-marker 0.0.82 → 0.0.84

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.
Files changed (37) hide show
  1. package/dist/types/build-processor.d.ts.map +1 -1
  2. package/dist/types/html-processor.d.ts.map +1 -1
  3. package/dist/types/index.d.ts +1 -1
  4. package/dist/types/index.d.ts.map +1 -1
  5. package/dist/types/source-finder/ast-extractors.d.ts.map +1 -1
  6. package/dist/types/source-finder/cross-file-tracker.d.ts +10 -0
  7. package/dist/types/source-finder/cross-file-tracker.d.ts.map +1 -1
  8. package/dist/types/source-finder/index.d.ts +2 -1
  9. package/dist/types/source-finder/index.d.ts.map +1 -1
  10. package/dist/types/source-finder/search-index.d.ts.map +1 -1
  11. package/dist/types/source-finder/snippet-utils.d.ts +43 -2
  12. package/dist/types/source-finder/snippet-utils.d.ts.map +1 -1
  13. package/dist/types/source-finder/source-lookup.d.ts.map +1 -1
  14. package/dist/types/source-finder/types.d.ts +4 -0
  15. package/dist/types/source-finder/types.d.ts.map +1 -1
  16. package/dist/types/tailwind-colors.d.ts +5 -3
  17. package/dist/types/tailwind-colors.d.ts.map +1 -1
  18. package/dist/types/tsconfig.tsbuildinfo +1 -1
  19. package/dist/types/types.d.ts +16 -271
  20. package/dist/types/types.d.ts.map +1 -1
  21. package/dist/types/utils.d.ts +2 -4
  22. package/dist/types/utils.d.ts.map +1 -1
  23. package/package.json +1 -1
  24. package/src/build-processor.ts +54 -5
  25. package/src/dev-middleware.ts +2 -2
  26. package/src/html-processor.ts +153 -714
  27. package/src/index.ts +1 -14
  28. package/src/source-finder/ast-extractors.ts +17 -7
  29. package/src/source-finder/cross-file-tracker.ts +405 -2
  30. package/src/source-finder/index.ts +12 -1
  31. package/src/source-finder/search-index.ts +52 -0
  32. package/src/source-finder/snippet-utils.ts +308 -16
  33. package/src/source-finder/source-lookup.ts +5 -1
  34. package/src/source-finder/types.ts +4 -0
  35. package/src/tailwind-colors.ts +49 -48
  36. package/src/types.ts +16 -284
  37. package/src/utils.ts +1 -6
package/src/types.ts CHANGED
@@ -39,20 +39,6 @@ export interface ComponentDefinition {
39
39
  slots?: string[]
40
40
  }
41
41
 
42
- /** Context around an element for resilient matching when exact match fails */
43
- export interface SourceContext {
44
- /** Text content of the preceding sibling element */
45
- precedingText?: string
46
- /** Text content of the following sibling element */
47
- followingText?: string
48
- /** Parent element's tag name */
49
- parentTag?: string
50
- /** Position among siblings (0-indexed) */
51
- siblingIndex?: number
52
- /** Parent element's class attribute */
53
- parentClasses?: string
54
- }
55
-
56
42
  /** Image metadata for better tracking and integrity */
57
43
  export interface ImageMetadata {
58
44
  /** Image source URL */
@@ -91,252 +77,18 @@ export interface TailwindColor {
91
77
  isCustom?: boolean
92
78
  }
93
79
 
94
- /** Opacity classes currently applied to an element */
95
- export interface OpacityClasses {
96
- /** Background opacity class (e.g., 'bg-opacity-90') */
97
- bgOpacity?: string
98
- /** Text opacity class (e.g., 'text-opacity-50') */
99
- textOpacity?: string
100
- /** Border opacity class (e.g., 'border-opacity-75') */
101
- borderOpacity?: string
102
- }
103
-
104
- /** Gradient color classes currently applied to an element */
105
- export interface GradientClasses {
106
- /** Gradient start color (e.g., 'from-blue-500') */
107
- from?: string
108
- /** Gradient middle color (e.g., 'via-purple-500') */
109
- via?: string
110
- /** Gradient end color (e.g., 'to-pink-500') */
111
- to?: string
112
- /** Hover gradient start color (e.g., 'hover:from-blue-600') */
113
- hoverFrom?: string
114
- /** Hover gradient middle color (e.g., 'hover:via-purple-600') */
115
- hoverVia?: string
116
- /** Hover gradient end color (e.g., 'hover:to-pink-600') */
117
- hoverTo?: string
118
- }
119
-
120
- /** Color classes currently applied to an element */
121
- export interface ColorClasses {
122
- /** Background color class (e.g., 'bg-blue-500') */
123
- bg?: string
124
- /** Text color class (e.g., 'text-white') */
125
- text?: string
126
- /** Border color class (e.g., 'border-blue-600') */
127
- border?: string
128
- /** Hover background color class (e.g., 'hover:bg-blue-600') */
129
- hoverBg?: string
130
- /** Hover text color class (e.g., 'hover:text-gray-100') */
131
- hoverText?: string
132
- /** Hover border color class (e.g., 'hover:border-blue-700') */
133
- hoverBorder?: string
134
- /** Gradient color classes */
135
- gradient?: GradientClasses
136
- /** Opacity classes */
137
- opacity?: OpacityClasses
138
- /** All color-related classes as found in the element */
139
- allColorClasses?: string[]
140
- }
141
-
142
- /** Link attributes for anchor elements (for git diff tracking) */
143
- export interface LinkAttributes {
144
- /** The href attribute value */
145
- href: string
146
- /** Target attribute (e.g., '_blank', '_self') */
147
- target?: string
148
- /** Rel attribute (e.g., 'noopener noreferrer') */
149
- rel?: string
150
- /** Title attribute */
151
- title?: string
152
- /** Download attribute (triggers file download) */
153
- download?: string | boolean
154
- }
155
-
156
- /** Button attributes for button elements (for git diff tracking) */
157
- export interface ButtonAttributes {
158
- /** Button type (submit, reset, button) */
159
- type?: string
160
- /** Whether the button is disabled */
161
- disabled?: boolean
162
- /** Form ID the button belongs to */
163
- form?: string
164
- /** Form action URL override */
165
- formAction?: string
166
- /** Form method override */
167
- formMethod?: string
168
- }
169
-
170
- /** Input attributes for form input elements (for git diff tracking) */
171
- export interface InputAttributes {
172
- /** Input type (text, email, password, checkbox, etc.) */
173
- type?: string
174
- /** Input name for form submission */
175
- name?: string
176
- /** Placeholder text */
177
- placeholder?: string
178
- /** Whether the input is required */
179
- required?: boolean
180
- /** Validation pattern (regex) */
181
- pattern?: string
182
- /** Mobile keyboard type (numeric, email, tel, etc.) */
183
- inputMode?: string
184
- /** Autocomplete hint (email, username, current-password, etc.) */
185
- autoComplete?: string
186
- /** Whether the input is disabled */
187
- disabled?: boolean
188
- /** Whether the input is readonly */
189
- readOnly?: boolean
190
- /** Minimum value (for number/date inputs) */
191
- min?: string
192
- /** Maximum value (for number/date inputs) */
193
- max?: string
194
- /** Step value (for number inputs) */
195
- step?: string
196
- /** Minimum length */
197
- minLength?: number
198
- /** Maximum length */
199
- maxLength?: number
200
- }
201
-
202
- /** Form attributes for form elements (for git diff tracking) */
203
- export interface FormAttributes {
204
- /** Form submission endpoint */
205
- action?: string
206
- /** HTTP method (GET, POST, etc.) */
207
- method?: string
208
- /** Encoding type (multipart/form-data, etc.) */
209
- encType?: string
210
- /** Whether to disable HTML5 validation */
211
- noValidate?: boolean
212
- /** Target for form submission (_blank, _self, etc.) */
213
- target?: string
214
- /** Form name */
215
- name?: string
216
- }
217
-
218
- /** Media attributes for video/audio elements (for git diff tracking) */
219
- export interface MediaAttributes {
220
- /** Media source URL */
221
- src?: string
222
- /** Poster image URL (video only) */
223
- poster?: string
224
- /** Whether to show controls */
225
- controls?: boolean
226
- /** Whether to autoplay */
227
- autoplay?: boolean
228
- /** Whether to mute audio */
229
- muted?: boolean
230
- /** Whether to loop playback */
231
- loop?: boolean
232
- /** Whether to play inline on mobile */
233
- playsInline?: boolean
234
- /** Preload strategy (none, metadata, auto) */
235
- preload?: string
236
- }
237
-
238
- /** Iframe attributes for embedded content (for git diff tracking) */
239
- export interface IframeAttributes {
240
- /** Iframe source URL */
241
- src?: string
242
- /** Accessibility title */
243
- title?: string
244
- /** Permissions policy (camera, microphone, etc.) */
245
- allow?: string
246
- /** Sandbox restrictions */
247
- sandbox?: string
248
- /** Loading strategy (lazy, eager) */
249
- loading?: string
250
- /** Width */
251
- width?: string
252
- /** Height */
253
- height?: string
254
- /** Name attribute */
255
- name?: string
256
- }
257
-
258
- /** Select attributes for dropdown elements (for git diff tracking) */
259
- export interface SelectAttributes {
260
- /** Select name for form submission */
261
- name?: string
262
- /** Whether multiple selection is allowed */
263
- multiple?: boolean
264
- /** Whether the select is required */
265
- required?: boolean
266
- /** Whether the select is disabled */
267
- disabled?: boolean
268
- /** Number of visible options */
269
- size?: number
270
- }
271
-
272
- /** Textarea attributes for multiline input (for git diff tracking) */
273
- export interface TextareaAttributes {
274
- /** Textarea name for form submission */
275
- name?: string
276
- /** Placeholder text */
277
- placeholder?: string
278
- /** Whether the textarea is required */
279
- required?: boolean
280
- /** Whether the textarea is disabled */
281
- disabled?: boolean
282
- /** Whether the textarea is readonly */
283
- readOnly?: boolean
284
- /** Number of visible rows */
285
- rows?: number
286
- /** Number of visible columns */
287
- cols?: number
288
- /** Minimum length */
289
- minLength?: number
290
- /** Maximum length */
291
- maxLength?: number
292
- /** Wrap behavior (soft, hard, off) */
293
- wrap?: string
294
- }
295
-
296
- /** ARIA accessibility attributes (for git diff tracking) */
297
- export interface AriaAttributes {
298
- /** ARIA role (button, tab, navigation, dialog, etc.) */
299
- role?: string
300
- /** Screen reader label */
301
- ariaLabel?: string
302
- /** ID of element that labels this one */
303
- ariaLabelledBy?: string
304
- /** ID of element that describes this one */
305
- ariaDescribedBy?: string
306
- /** Whether hidden from assistive technology */
307
- ariaHidden?: boolean
308
- /** Expanded state for collapsibles */
309
- ariaExpanded?: boolean
310
- /** Pressed state for toggle buttons */
311
- ariaPressed?: boolean | 'mixed'
312
- /** Selected state for tabs/options */
313
- ariaSelected?: boolean
314
- /** Disabled state */
315
- ariaDisabled?: boolean
316
- /** Required state */
317
- ariaRequired?: boolean
318
- /** Invalid state */
319
- ariaInvalid?: boolean | 'grammar' | 'spelling'
320
- /** Live region announcement type */
321
- ariaLive?: 'polite' | 'assertive' | 'off'
322
- /** Atomic update for live regions */
323
- ariaAtomic?: boolean
324
- /** Busy state */
325
- ariaBusy?: boolean
326
- /** Current state (page, step, location, date, time, true, false) */
327
- ariaCurrent?: string
328
- /** Controls relationship */
329
- ariaControls?: string
330
- /** Owns relationship */
331
- ariaOwns?: string
332
- /** Haspopup type */
333
- ariaHasPopup?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'
334
- }
335
-
336
- /** Custom data-* attributes (for git diff tracking) */
337
- export interface DataAttributes {
338
- /** All data-* attributes as key-value pairs (without 'data-' prefix) */
339
- [key: string]: string | undefined
80
+ /** Attribute with source information for git diff tracking */
81
+ export interface Attribute {
82
+ /** The resolved attribute value (from rendered HTML) */
83
+ value: string
84
+ /** The expression text if dynamic (e.g., "component.githubUrl") */
85
+ sourceExpression?: string
86
+ /** Path to the source file where the value is defined */
87
+ sourcePath?: string
88
+ /** Line number where the value is defined in source (1-indexed) */
89
+ sourceLine?: number
90
+ /** The exact source snippet that can be replaced for git diff */
91
+ sourceSnippet?: string
340
92
  }
341
93
 
342
94
  /** Available colors palette from Tailwind config */
@@ -380,8 +132,8 @@ export interface ManifestEntry {
380
132
  html?: string
381
133
  sourcePath?: string
382
134
  sourceLine?: number
135
+ /** Full element snippet from opening to closing tag (for text content updates) */
383
136
  sourceSnippet?: string
384
- sourceType?: 'static' | 'variable' | 'prop' | 'computed' | 'collection' | 'image'
385
137
  variableName?: string
386
138
  childCmsIds?: string[]
387
139
  parentComponentId?: string
@@ -398,34 +150,14 @@ export interface ManifestEntry {
398
150
  stableId?: string
399
151
  /** SHA256 hash of sourceSnippet at generation time for conflict detection */
400
152
  sourceHash?: string
401
- /** Context around the element for resilient matching */
402
- sourceContext?: SourceContext
403
153
  /** Image metadata for img elements (replaces imageSrc/imageAlt) */
404
154
  imageMetadata?: ImageMetadata
405
155
  /** Content validation constraints */
406
156
  constraints?: ContentConstraints
407
157
  /** Color classes applied to this element (for buttons, etc.) */
408
- colorClasses?: ColorClasses
409
- /** Link attributes for anchor elements (href, target, rel, title) */
410
- linkAttributes?: LinkAttributes
411
- /** Button attributes (type, disabled, form, etc.) */
412
- buttonAttributes?: ButtonAttributes
413
- /** Input attributes (type, name, placeholder, required, etc.) */
414
- inputAttributes?: InputAttributes
415
- /** Form attributes (action, method, enctype, etc.) */
416
- formAttributes?: FormAttributes
417
- /** Media attributes for video/audio (src, controls, autoplay, etc.) */
418
- mediaAttributes?: MediaAttributes
419
- /** Iframe attributes (src, title, allow, sandbox, etc.) */
420
- iframeAttributes?: IframeAttributes
421
- /** Select attributes (name, multiple, required, etc.) */
422
- selectAttributes?: SelectAttributes
423
- /** Textarea attributes (name, placeholder, rows, cols, etc.) */
424
- textareaAttributes?: TextareaAttributes
425
- /** ARIA accessibility attributes (role, aria-label, etc.) */
426
- ariaAttributes?: AriaAttributes
427
- /** Custom data-* attributes */
428
- dataAttributes?: DataAttributes
158
+ colorClasses?: Record<string, Attribute>
159
+ /** All HTML attributes with source information */
160
+ attributes?: Record<string, Attribute>
429
161
  }
430
162
 
431
163
  export interface ComponentInstance {
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHash } from 'node:crypto'
2
- import type { ManifestEntry, SourceContext } from './types'
2
+ import type { ManifestEntry } from './types'
3
3
 
4
4
  /**
5
5
  * Generate a SHA256 hash of the given content
@@ -24,21 +24,16 @@ export function shortHash(content: string): string {
24
24
  * - tag name
25
25
  * - first 50 chars of text content
26
26
  * - source path (if available)
27
- * - parent tag
28
- * - sibling index
29
27
  */
30
28
  export function generateStableId(
31
29
  tag: string,
32
30
  text: string,
33
31
  sourcePath?: string,
34
- context?: SourceContext,
35
32
  ): string {
36
33
  const components = [
37
34
  tag,
38
35
  text.substring(0, 50).trim(),
39
36
  sourcePath || '',
40
- context?.parentTag || '',
41
- context?.siblingIndex?.toString() || '',
42
37
  ]
43
38
 
44
39
  return shortHash(components.join('|'))