@nuasite/cms 0.1.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.
Files changed (269) hide show
  1. package/README.md +237 -0
  2. package/dist/src/build-processor.d.ts +20 -0
  3. package/dist/src/build-processor.d.ts.map +1 -0
  4. package/dist/src/collection-scanner.d.ts +6 -0
  5. package/dist/src/collection-scanner.d.ts.map +1 -0
  6. package/dist/src/component-registry.d.ts +63 -0
  7. package/dist/src/component-registry.d.ts.map +1 -0
  8. package/dist/src/config.d.ts +24 -0
  9. package/dist/src/config.d.ts.map +1 -0
  10. package/dist/src/dev-middleware.d.ts +20 -0
  11. package/dist/src/dev-middleware.d.ts.map +1 -0
  12. package/dist/src/editor/ai.d.ts +60 -0
  13. package/dist/src/editor/ai.d.ts.map +1 -0
  14. package/dist/src/editor/api.d.ts +140 -0
  15. package/dist/src/editor/api.d.ts.map +1 -0
  16. package/dist/src/editor/color-utils.d.ts +106 -0
  17. package/dist/src/editor/color-utils.d.ts.map +1 -0
  18. package/dist/src/editor/components/ai-chat.d.ts +11 -0
  19. package/dist/src/editor/components/ai-chat.d.ts.map +1 -0
  20. package/dist/src/editor/components/ai-tooltip.d.ts +12 -0
  21. package/dist/src/editor/components/ai-tooltip.d.ts.map +1 -0
  22. package/dist/src/editor/components/attribute-editor.d.ts +5 -0
  23. package/dist/src/editor/components/attribute-editor.d.ts.map +1 -0
  24. package/dist/src/editor/components/block-editor.d.ts +12 -0
  25. package/dist/src/editor/components/block-editor.d.ts.map +1 -0
  26. package/dist/src/editor/components/collections-browser.d.ts +2 -0
  27. package/dist/src/editor/components/collections-browser.d.ts.map +1 -0
  28. package/dist/src/editor/components/color-toolbar.d.ts +12 -0
  29. package/dist/src/editor/components/color-toolbar.d.ts.map +1 -0
  30. package/dist/src/editor/components/confirm-dialog.d.ts +2 -0
  31. package/dist/src/editor/components/confirm-dialog.d.ts.map +1 -0
  32. package/dist/src/editor/components/create-page-modal.d.ts +2 -0
  33. package/dist/src/editor/components/create-page-modal.d.ts.map +1 -0
  34. package/dist/src/editor/components/editable-highlights.d.ts +9 -0
  35. package/dist/src/editor/components/editable-highlights.d.ts.map +1 -0
  36. package/dist/src/editor/components/error-boundary.d.ts +32 -0
  37. package/dist/src/editor/components/error-boundary.d.ts.map +1 -0
  38. package/dist/src/editor/components/fields.d.ts +75 -0
  39. package/dist/src/editor/components/fields.d.ts.map +1 -0
  40. package/dist/src/editor/components/frontmatter-fields.d.ts +29 -0
  41. package/dist/src/editor/components/frontmatter-fields.d.ts.map +1 -0
  42. package/dist/src/editor/components/highlight-overlay.d.ts +64 -0
  43. package/dist/src/editor/components/highlight-overlay.d.ts.map +1 -0
  44. package/dist/src/editor/components/image-overlay.d.ts +12 -0
  45. package/dist/src/editor/components/image-overlay.d.ts.map +1 -0
  46. package/dist/src/editor/components/markdown-editor-overlay.d.ts +6 -0
  47. package/dist/src/editor/components/markdown-editor-overlay.d.ts.map +1 -0
  48. package/dist/src/editor/components/markdown-inline-editor.d.ts +10 -0
  49. package/dist/src/editor/components/markdown-inline-editor.d.ts.map +1 -0
  50. package/dist/src/editor/components/media-library.d.ts +2 -0
  51. package/dist/src/editor/components/media-library.d.ts.map +1 -0
  52. package/dist/src/editor/components/outline.d.ts +21 -0
  53. package/dist/src/editor/components/outline.d.ts.map +1 -0
  54. package/dist/src/editor/components/redirect-countdown.d.ts +2 -0
  55. package/dist/src/editor/components/redirect-countdown.d.ts.map +1 -0
  56. package/dist/src/editor/components/seo-editor.d.ts +2 -0
  57. package/dist/src/editor/components/seo-editor.d.ts.map +1 -0
  58. package/dist/src/editor/components/text-style-toolbar.d.ts +8 -0
  59. package/dist/src/editor/components/text-style-toolbar.d.ts.map +1 -0
  60. package/dist/src/editor/components/toast/toast-container.d.ts +7 -0
  61. package/dist/src/editor/components/toast/toast-container.d.ts.map +1 -0
  62. package/dist/src/editor/components/toast/toast.d.ts +7 -0
  63. package/dist/src/editor/components/toast/toast.d.ts.map +1 -0
  64. package/dist/src/editor/components/toast/types.d.ts +7 -0
  65. package/dist/src/editor/components/toast/types.d.ts.map +1 -0
  66. package/dist/src/editor/components/toolbar.d.ts +21 -0
  67. package/dist/src/editor/components/toolbar.d.ts.map +1 -0
  68. package/dist/src/editor/config.d.ts +4 -0
  69. package/dist/src/editor/config.d.ts.map +1 -0
  70. package/dist/src/editor/constants.d.ts +101 -0
  71. package/dist/src/editor/constants.d.ts.map +1 -0
  72. package/dist/src/editor/context.d.ts +14 -0
  73. package/dist/src/editor/context.d.ts.map +1 -0
  74. package/dist/src/editor/dom.d.ts +77 -0
  75. package/dist/src/editor/dom.d.ts.map +1 -0
  76. package/dist/src/editor/editor.d.ts +64 -0
  77. package/dist/src/editor/editor.d.ts.map +1 -0
  78. package/dist/src/editor/history.d.ts +20 -0
  79. package/dist/src/editor/history.d.ts.map +1 -0
  80. package/dist/src/editor/hooks/index.d.ts +14 -0
  81. package/dist/src/editor/hooks/index.d.ts.map +1 -0
  82. package/dist/src/editor/hooks/useAIHandlers.d.ts +22 -0
  83. package/dist/src/editor/hooks/useAIHandlers.d.ts.map +1 -0
  84. package/dist/src/editor/hooks/useBlockEditorHandlers.d.ts +18 -0
  85. package/dist/src/editor/hooks/useBlockEditorHandlers.d.ts.map +1 -0
  86. package/dist/src/editor/hooks/useElementDetection.d.ts +26 -0
  87. package/dist/src/editor/hooks/useElementDetection.d.ts.map +1 -0
  88. package/dist/src/editor/hooks/useImageHoverDetection.d.ts +12 -0
  89. package/dist/src/editor/hooks/useImageHoverDetection.d.ts.map +1 -0
  90. package/dist/src/editor/hooks/useTextSelection.d.ts +23 -0
  91. package/dist/src/editor/hooks/useTextSelection.d.ts.map +1 -0
  92. package/dist/src/editor/hooks/useTooltipState.d.ts +19 -0
  93. package/dist/src/editor/hooks/useTooltipState.d.ts.map +1 -0
  94. package/dist/src/editor/hooks/utils.d.ts +32 -0
  95. package/dist/src/editor/hooks/utils.d.ts.map +1 -0
  96. package/dist/src/editor/index.d.ts +12 -0
  97. package/dist/src/editor/index.d.ts.map +1 -0
  98. package/dist/src/editor/lib/cn.d.ts +3 -0
  99. package/dist/src/editor/lib/cn.d.ts.map +1 -0
  100. package/dist/src/editor/manifest.d.ts +19 -0
  101. package/dist/src/editor/manifest.d.ts.map +1 -0
  102. package/dist/src/editor/markdown-api.d.ts +36 -0
  103. package/dist/src/editor/markdown-api.d.ts.map +1 -0
  104. package/dist/src/editor/signals.d.ts +242 -0
  105. package/dist/src/editor/signals.d.ts.map +1 -0
  106. package/dist/src/editor/storage.d.ts +27 -0
  107. package/dist/src/editor/storage.d.ts.map +1 -0
  108. package/dist/src/editor/text-styling.d.ts +350 -0
  109. package/dist/src/editor/text-styling.d.ts.map +1 -0
  110. package/dist/src/editor/themes.d.ts +38 -0
  111. package/dist/src/editor/themes.d.ts.map +1 -0
  112. package/dist/src/editor/types.d.ts +454 -0
  113. package/dist/src/editor/types.d.ts.map +1 -0
  114. package/dist/src/error-collector.d.ts +56 -0
  115. package/dist/src/error-collector.d.ts.map +1 -0
  116. package/dist/src/handlers/component-ops.d.ts +34 -0
  117. package/dist/src/handlers/component-ops.d.ts.map +1 -0
  118. package/dist/src/handlers/markdown-ops.d.ts +41 -0
  119. package/dist/src/handlers/markdown-ops.d.ts.map +1 -0
  120. package/dist/src/handlers/request-utils.d.ts +20 -0
  121. package/dist/src/handlers/request-utils.d.ts.map +1 -0
  122. package/dist/src/handlers/source-writer.d.ts +51 -0
  123. package/dist/src/handlers/source-writer.d.ts.map +1 -0
  124. package/dist/src/html-processor.d.ts +63 -0
  125. package/dist/src/html-processor.d.ts.map +1 -0
  126. package/dist/src/index.d.ts +41 -0
  127. package/dist/src/index.d.ts.map +1 -0
  128. package/dist/src/manifest-writer.d.ts +111 -0
  129. package/dist/src/manifest-writer.d.ts.map +1 -0
  130. package/dist/src/media/contember.d.ts +15 -0
  131. package/dist/src/media/contember.d.ts.map +1 -0
  132. package/dist/src/media/local.d.ts +9 -0
  133. package/dist/src/media/local.d.ts.map +1 -0
  134. package/dist/src/media/s3.d.ts +12 -0
  135. package/dist/src/media/s3.d.ts.map +1 -0
  136. package/dist/src/media/types.d.ts +40 -0
  137. package/dist/src/media/types.d.ts.map +1 -0
  138. package/dist/src/preview-generator.d.ts +19 -0
  139. package/dist/src/preview-generator.d.ts.map +1 -0
  140. package/dist/src/seo-processor.d.ts +23 -0
  141. package/dist/src/seo-processor.d.ts.map +1 -0
  142. package/dist/src/source-finder/ast-extractors.d.ts +35 -0
  143. package/dist/src/source-finder/ast-extractors.d.ts.map +1 -0
  144. package/dist/src/source-finder/ast-parser.d.ts +16 -0
  145. package/dist/src/source-finder/ast-parser.d.ts.map +1 -0
  146. package/dist/src/source-finder/cache.d.ts +18 -0
  147. package/dist/src/source-finder/cache.d.ts.map +1 -0
  148. package/dist/src/source-finder/collection-finder.d.ts +29 -0
  149. package/dist/src/source-finder/collection-finder.d.ts.map +1 -0
  150. package/dist/src/source-finder/cross-file-tracker.d.ts +39 -0
  151. package/dist/src/source-finder/cross-file-tracker.d.ts.map +1 -0
  152. package/dist/src/source-finder/element-finder.d.ts +42 -0
  153. package/dist/src/source-finder/element-finder.d.ts.map +1 -0
  154. package/dist/src/source-finder/image-finder.d.ts +24 -0
  155. package/dist/src/source-finder/image-finder.d.ts.map +1 -0
  156. package/dist/src/source-finder/index.d.ts +9 -0
  157. package/dist/src/source-finder/index.d.ts.map +1 -0
  158. package/dist/src/source-finder/search-index.d.ts +27 -0
  159. package/dist/src/source-finder/search-index.d.ts.map +1 -0
  160. package/dist/src/source-finder/snippet-utils.d.ts +90 -0
  161. package/dist/src/source-finder/snippet-utils.d.ts.map +1 -0
  162. package/dist/src/source-finder/source-lookup.d.ts +16 -0
  163. package/dist/src/source-finder/source-lookup.d.ts.map +1 -0
  164. package/dist/src/source-finder/types.d.ts +167 -0
  165. package/dist/src/source-finder/types.d.ts.map +1 -0
  166. package/dist/src/source-finder/variable-extraction.d.ts +37 -0
  167. package/dist/src/source-finder/variable-extraction.d.ts.map +1 -0
  168. package/dist/src/tailwind-colors.d.ts +54 -0
  169. package/dist/src/tailwind-colors.d.ts.map +1 -0
  170. package/dist/src/tsconfig.tsbuildinfo +1 -0
  171. package/dist/src/types.d.ts +367 -0
  172. package/dist/src/types.d.ts.map +1 -0
  173. package/dist/src/utils.d.ts +61 -0
  174. package/dist/src/utils.d.ts.map +1 -0
  175. package/dist/src/vite-plugin.d.ts +14 -0
  176. package/dist/src/vite-plugin.d.ts.map +1 -0
  177. package/dist/types/tsconfig.tsbuildinfo +1 -0
  178. package/package.json +80 -0
  179. package/src/build-processor.ts +784 -0
  180. package/src/collection-scanner.ts +304 -0
  181. package/src/component-registry.ts +393 -0
  182. package/src/config.ts +74 -0
  183. package/src/dev-middleware.ts +525 -0
  184. package/src/dist/src/tsconfig.tsbuildinfo +1 -0
  185. package/src/editor/ai.ts +185 -0
  186. package/src/editor/api.ts +513 -0
  187. package/src/editor/color-utils.ts +556 -0
  188. package/src/editor/components/ai-chat.tsx +632 -0
  189. package/src/editor/components/ai-tooltip.tsx +179 -0
  190. package/src/editor/components/attribute-editor.tsx +596 -0
  191. package/src/editor/components/block-editor.tsx +546 -0
  192. package/src/editor/components/collections-browser.tsx +248 -0
  193. package/src/editor/components/color-toolbar.tsx +314 -0
  194. package/src/editor/components/confirm-dialog.tsx +69 -0
  195. package/src/editor/components/create-page-modal.tsx +163 -0
  196. package/src/editor/components/editable-highlights.tsx +260 -0
  197. package/src/editor/components/error-boundary.tsx +87 -0
  198. package/src/editor/components/fields.tsx +387 -0
  199. package/src/editor/components/frontmatter-fields.tsx +469 -0
  200. package/src/editor/components/highlight-overlay.ts +229 -0
  201. package/src/editor/components/image-overlay.tsx +230 -0
  202. package/src/editor/components/markdown-editor-overlay.tsx +505 -0
  203. package/src/editor/components/markdown-inline-editor.tsx +780 -0
  204. package/src/editor/components/media-library.tsx +297 -0
  205. package/src/editor/components/outline.tsx +402 -0
  206. package/src/editor/components/redirect-countdown.tsx +45 -0
  207. package/src/editor/components/seo-editor.tsx +498 -0
  208. package/src/editor/components/text-style-toolbar.tsx +362 -0
  209. package/src/editor/components/toast/toast-container.tsx +15 -0
  210. package/src/editor/components/toast/toast.tsx +49 -0
  211. package/src/editor/components/toast/types.ts +7 -0
  212. package/src/editor/components/toolbar.tsx +366 -0
  213. package/src/editor/config.ts +12 -0
  214. package/src/editor/constants.ts +106 -0
  215. package/src/editor/context.tsx +38 -0
  216. package/src/editor/dom.ts +357 -0
  217. package/src/editor/editor.ts +1510 -0
  218. package/src/editor/env.d.ts +4 -0
  219. package/src/editor/history.ts +355 -0
  220. package/src/editor/hooks/index.ts +19 -0
  221. package/src/editor/hooks/useAIHandlers.ts +345 -0
  222. package/src/editor/hooks/useBlockEditorHandlers.ts +206 -0
  223. package/src/editor/hooks/useElementDetection.ts +284 -0
  224. package/src/editor/hooks/useImageHoverDetection.ts +102 -0
  225. package/src/editor/hooks/useTextSelection.ts +187 -0
  226. package/src/editor/hooks/useTooltipState.ts +126 -0
  227. package/src/editor/hooks/utils.ts +101 -0
  228. package/src/editor/index.tsx +481 -0
  229. package/src/editor/lib/cn.ts +4 -0
  230. package/src/editor/manifest.ts +25 -0
  231. package/src/editor/markdown-api.ts +209 -0
  232. package/src/editor/signals.ts +1351 -0
  233. package/src/editor/storage.ts +266 -0
  234. package/src/editor/styles.css +465 -0
  235. package/src/editor/text-styling.ts +773 -0
  236. package/src/editor/themes.ts +210 -0
  237. package/src/editor/types.ts +591 -0
  238. package/src/error-collector.ts +106 -0
  239. package/src/handlers/component-ops.ts +463 -0
  240. package/src/handlers/markdown-ops.ts +202 -0
  241. package/src/handlers/request-utils.ts +151 -0
  242. package/src/handlers/source-writer.ts +649 -0
  243. package/src/html-processor.ts +1108 -0
  244. package/src/index.ts +284 -0
  245. package/src/manifest-writer.ts +371 -0
  246. package/src/media/contember.ts +84 -0
  247. package/src/media/local.ts +114 -0
  248. package/src/media/s3.ts +133 -0
  249. package/src/media/types.ts +33 -0
  250. package/src/preview-generator.ts +293 -0
  251. package/src/seo-processor.ts +567 -0
  252. package/src/source-finder/ast-extractors.ts +185 -0
  253. package/src/source-finder/ast-parser.ts +150 -0
  254. package/src/source-finder/cache.ts +76 -0
  255. package/src/source-finder/collection-finder.ts +335 -0
  256. package/src/source-finder/cross-file-tracker.ts +741 -0
  257. package/src/source-finder/element-finder.ts +387 -0
  258. package/src/source-finder/image-finder.ts +283 -0
  259. package/src/source-finder/index.ts +37 -0
  260. package/src/source-finder/search-index.ts +525 -0
  261. package/src/source-finder/snippet-utils.ts +668 -0
  262. package/src/source-finder/source-lookup.ts +200 -0
  263. package/src/source-finder/types.ts +210 -0
  264. package/src/source-finder/variable-extraction.ts +406 -0
  265. package/src/tailwind-colors.ts +874 -0
  266. package/src/tsconfig.json +25 -0
  267. package/src/types.ts +406 -0
  268. package/src/utils.ts +186 -0
  269. package/src/vite-plugin.ts +42 -0
@@ -0,0 +1,591 @@
1
+ import type { Attribute, CmsManifest, CollectionDefinition, ComponentInstance } from '../types'
2
+
3
+ // Re-export shared types from @nuasite/cms-marker (source of truth)
4
+ export type {
5
+ Attribute,
6
+ AvailableColors,
7
+ AvailableTextStyles,
8
+ CanonicalUrl,
9
+ CmsManifest,
10
+ CollectionDefinition,
11
+ CollectionEntry,
12
+ CollectionEntryInfo,
13
+ ComponentDefinition,
14
+ ComponentInstance,
15
+ FieldDefinition,
16
+ FieldType,
17
+ JsonLdEntry,
18
+ ManifestEntry,
19
+ OpenGraphData,
20
+ PageSeoData,
21
+ SeoFavicon,
22
+ SeoKeywords,
23
+ SeoMetaTag,
24
+ SeoOptions,
25
+ SeoSourceInfo,
26
+ SeoTitle,
27
+ TailwindColor,
28
+ TextStyleValue,
29
+ TwitterCardData,
30
+ } from '../types'
31
+
32
+ export interface CmsThemeConfig {
33
+ // Colors
34
+ primary?: string
35
+ secondary?: string
36
+ background?: string
37
+ card?: string
38
+
39
+ // Style presets
40
+ borderRadius?: 'sharp' | 'soft' | 'rounded'
41
+ shadowStyle?: 'none' | 'soft' | 'brutalist'
42
+ }
43
+
44
+ export type CmsThemePreset = 'soft' | 'brutalist' | 'minimal'
45
+
46
+ export interface CmsConfig {
47
+ apiBase: string
48
+ highlightColor: string
49
+ debug: boolean
50
+ theme?: CmsThemeConfig
51
+ themePreset?: CmsThemePreset
52
+ }
53
+
54
+ export interface ComponentProp {
55
+ name: string
56
+ type: string
57
+ required: boolean
58
+ defaultValue?: string
59
+ description?: string
60
+ }
61
+
62
+ export interface ChildCmsElement {
63
+ id: string
64
+ placeholder: string
65
+ currentHTML?: string
66
+ }
67
+
68
+ export interface PendingChange {
69
+ element: HTMLElement
70
+ originalHTML: string
71
+ originalText: string
72
+ newText: string
73
+ currentHTML: string
74
+ isDirty: boolean
75
+ childCmsElements?: ChildCmsElement[]
76
+ hasStyledContent?: boolean
77
+ }
78
+
79
+ export interface PendingImageChange {
80
+ element: HTMLImageElement
81
+ originalSrc: string
82
+ newSrc: string
83
+ originalAlt: string
84
+ newAlt: string
85
+ originalSrcSet: string
86
+ isDirty: boolean
87
+ }
88
+
89
+ export interface PendingColorChange {
90
+ element: HTMLElement
91
+ cmsId: string
92
+ originalClasses: Record<string, Attribute>
93
+ newClasses: Record<string, Attribute>
94
+ isDirty: boolean
95
+ }
96
+
97
+ export interface ColorEditorState {
98
+ isOpen: boolean
99
+ targetElementId: string | null
100
+ targetRect: DOMRect | null
101
+ }
102
+
103
+ export interface SavedEdit {
104
+ originalText: string
105
+ newText: string
106
+ currentHTML: string
107
+ hasStyledContent?: boolean
108
+ }
109
+
110
+ export interface SavedEdits {
111
+ [cmsId: string]: SavedEdit
112
+ }
113
+
114
+ export interface SavedImageEdit {
115
+ originalSrc: string
116
+ newSrc: string
117
+ originalAlt: string
118
+ newAlt: string
119
+ originalSrcSet: string
120
+ }
121
+
122
+ export interface SavedImageEdits {
123
+ [cmsId: string]: SavedImageEdit
124
+ }
125
+
126
+ export interface SavedColorEdit {
127
+ originalClasses: Record<string, Attribute>
128
+ newClasses: Record<string, Attribute>
129
+ }
130
+
131
+ export interface SavedColorEdits {
132
+ [cmsId: string]: SavedColorEdit
133
+ }
134
+
135
+ /** Color change details for updating element color classes */
136
+ export interface ColorChangePayload {
137
+ /** The color class to replace (e.g., 'bg-blue-500') */
138
+ oldClass: string
139
+ /** The new color class (e.g., 'bg-red-500') */
140
+ newClass: string
141
+ /** Type of color change: 'bg' | 'text' | 'border' | 'hoverBg' | 'hoverText' */
142
+ type: 'bg' | 'text' | 'border' | 'hoverBg' | 'hoverText'
143
+ /** Path to the source file where the color class is defined */
144
+ sourcePath?: string
145
+ /** Line number where the color class is defined */
146
+ sourceLine?: number
147
+ /** The source code snippet containing the color class */
148
+ sourceSnippet?: string
149
+ }
150
+
151
+ export interface ChangePayload {
152
+ cmsId: string
153
+ newValue: string
154
+ /** Original value to find and replace within the source snippet */
155
+ originalValue: string
156
+ /** Path to the source file */
157
+ sourcePath: string
158
+ /** Line number in the source file (for disambiguation) */
159
+ sourceLine: number
160
+ /** The source code snippet containing the text to replace */
161
+ sourceSnippet: string
162
+ /** HTML content when the element contains styled text (spans with Tailwind classes) */
163
+ htmlValue?: string
164
+ childCmsIds?: string[]
165
+ /** Whether this change contains styled inline text */
166
+ hasStyledContent?: boolean
167
+ /** Image change details when replacing an image */
168
+ imageChange?: {
169
+ newSrc: string
170
+ newAlt?: string
171
+ }
172
+ /** Color class change (for buttons, etc.) */
173
+ colorChange?: ColorChangePayload
174
+ /** Attribute changes (for links, forms, etc.) */
175
+ attributeChanges?: AttributeChangePayload[]
176
+ }
177
+
178
+ export interface SaveBatchRequest {
179
+ changes: ChangePayload[]
180
+ meta: {
181
+ source: string
182
+ url: string
183
+ }
184
+ }
185
+
186
+ export interface SaveBatchResponse {
187
+ updated: number
188
+ errors?: Array<{ cmsId: string; error: string }>
189
+ }
190
+
191
+ export interface ChatMessage {
192
+ id: string
193
+ role: 'user' | 'assistant'
194
+ content: string
195
+ elementId?: string
196
+ timestamp: number
197
+ }
198
+
199
+ export type AIStatusType =
200
+ | 'thinking'
201
+ | 'coding'
202
+ | 'building'
203
+ | 'deploying'
204
+ | 'complete'
205
+ | null
206
+
207
+ export interface AIState {
208
+ isPromptVisible: boolean
209
+ isProcessing: boolean
210
+ targetElementId: string | null
211
+ streamingContent: string | null
212
+ error: string | null
213
+ isChatOpen: boolean
214
+ chatMessages: ChatMessage[]
215
+ chatContextElementId: string | null
216
+ currentStatus: AIStatusType
217
+ statusMessage: string | null
218
+ }
219
+
220
+ export interface BlockEditorState {
221
+ isOpen: boolean
222
+ currentComponentId: string | null
223
+ mode: 'edit' | 'add' | 'picker'
224
+ }
225
+
226
+ // Component insertion types
227
+ export type InsertPosition = 'before' | 'after'
228
+
229
+ export interface PendingComponentInsert {
230
+ id: string // Temporary ID for preview
231
+ position: InsertPosition
232
+ referenceComponentId: string // The component we're inserting relative to
233
+ componentName: string
234
+ props: Record<string, any>
235
+ previewElement?: HTMLElement // The DOM element created for preview
236
+ }
237
+
238
+ export interface ComponentInsertRequest {
239
+ position: InsertPosition
240
+ referenceComponentId: string
241
+ componentName: string
242
+ props: Record<string, any>
243
+ }
244
+
245
+ export interface ComponentInsertResponse {
246
+ success: boolean
247
+ insertedId?: string
248
+ error?: string
249
+ diff?: {
250
+ file: string
251
+ before: string
252
+ after: string
253
+ }
254
+ }
255
+
256
+ export interface ComponentInsertOperation {
257
+ position: InsertPosition
258
+ referenceComponentId: string
259
+ componentName: string
260
+ props: Record<string, any>
261
+ }
262
+
263
+ export interface EditorState {
264
+ isEnabled: boolean
265
+ isEditing: boolean
266
+ showingOriginal: boolean
267
+ currentEditingId: string | null
268
+ currentComponentId: string | null
269
+ pendingChanges: Map<string, PendingChange>
270
+ pendingComponentChanges: Map<string, ComponentInstance>
271
+ pendingInserts: Map<string, PendingComponentInsert>
272
+ manifest: CmsManifest
273
+ ai: AIState
274
+ blockEditor: BlockEditorState
275
+ }
276
+
277
+ // Text styling types for inline Tailwind class application
278
+ export interface TextStyleDefinition {
279
+ class: string
280
+ label: string
281
+ }
282
+
283
+ export interface TextStyleCategory {
284
+ [key: string]: TextStyleDefinition
285
+ }
286
+
287
+ // ============================================================================
288
+ // Markdown CMS Types
289
+ // ============================================================================
290
+
291
+ export interface BlogFrontmatter {
292
+ title: string
293
+ date: string
294
+ author?: string
295
+ categories?: string[]
296
+ excerpt?: string
297
+ featuredImage?: string
298
+ draft?: boolean
299
+ [key: string]: unknown
300
+ }
301
+
302
+ export interface MarkdownPageEntry {
303
+ filePath: string
304
+ slug: string
305
+ frontmatter: Record<string, unknown>
306
+ content: string
307
+ isDirty: boolean
308
+ }
309
+
310
+ export interface MarkdownEditorState {
311
+ isOpen: boolean
312
+ currentPage: MarkdownPageEntry | null
313
+ activeElementId: string | null
314
+ mode: 'edit' | 'create'
315
+ collectionDefinition?: CollectionDefinition
316
+ createOptions?: {
317
+ collectionName: string
318
+ collectionDefinition: CollectionDefinition
319
+ }
320
+ }
321
+
322
+ export interface MediaItem {
323
+ id: string
324
+ url: string
325
+ filename: string
326
+ annotation?: string
327
+ contentType: string
328
+ width?: number
329
+ height?: number
330
+ uploadedAt?: string
331
+ }
332
+
333
+ export interface MediaLibraryState {
334
+ isOpen: boolean
335
+ items: MediaItem[]
336
+ isLoading: boolean
337
+ selectedItem: MediaItem | null
338
+ insertCallback: ((url: string, alt: string) => void) | null
339
+ }
340
+
341
+ export interface CreatePageState {
342
+ isOpen: boolean
343
+ isCreating: boolean
344
+ selectedCollection: string | null
345
+ }
346
+
347
+ export interface CollectionsBrowserState {
348
+ isOpen: boolean
349
+ selectedCollection: string | null
350
+ }
351
+
352
+ // API Request/Response types for markdown operations
353
+ export interface CreateMarkdownPageRequest {
354
+ /** Collection name (e.g., 'blog', 'services') */
355
+ collection: string
356
+ /** URL-friendly slug for the page */
357
+ slug: string
358
+ /** Page title */
359
+ title: string
360
+ /** Optional frontmatter fields */
361
+ frontmatter?: Partial<BlogFrontmatter>
362
+ /** Optional markdown content */
363
+ content?: string
364
+ }
365
+
366
+ export interface CreateMarkdownPageResponse {
367
+ success: boolean
368
+ filePath?: string
369
+ slug?: string
370
+ url?: string
371
+ error?: string
372
+ }
373
+
374
+ export interface UpdateMarkdownPageRequest {
375
+ filePath: string
376
+ frontmatter?: Partial<BlogFrontmatter>
377
+ content?: string
378
+ }
379
+
380
+ export interface UpdateMarkdownPageResponse {
381
+ success: boolean
382
+ commit?: string
383
+ commitMessage?: string
384
+ error?: string
385
+ }
386
+
387
+ export interface MediaUploadResponse {
388
+ success: boolean
389
+ url?: string
390
+ filename?: string
391
+ annotation?: string
392
+ id?: string
393
+ error?: string
394
+ }
395
+
396
+ // ============================================================================
397
+ // Deployment Status Types
398
+ // ============================================================================
399
+
400
+ export type DeploymentStatusType =
401
+ | 'pending'
402
+ | 'queued'
403
+ | 'running'
404
+ | 'completed'
405
+ | 'failed'
406
+ | 'cancelled'
407
+
408
+ export interface DeploymentStatusResponse {
409
+ currentDeployment: {
410
+ id: string
411
+ status: DeploymentStatusType
412
+ createdAt: string
413
+ startedAt: string | null
414
+ commitMessage: string | null
415
+ } | null
416
+ lastSuccessfulDeployment: {
417
+ completedAt: string
418
+ publishedUrl: string
419
+ } | null
420
+ pendingCount: number
421
+ }
422
+
423
+ export interface DeploymentState {
424
+ status: DeploymentStatusType | null
425
+ lastDeployedAt: string | null
426
+ isPolling: boolean
427
+ error: string | null
428
+ }
429
+
430
+ // ============================================================================
431
+ // Confirm Dialog Types
432
+ // ============================================================================
433
+
434
+ export interface ConfirmDialogState {
435
+ isOpen: boolean
436
+ title: string
437
+ message: string
438
+ confirmLabel: string
439
+ cancelLabel: string
440
+ variant: 'danger' | 'warning' | 'info'
441
+ onConfirm: (() => void) | null
442
+ onCancel: (() => void) | null
443
+ }
444
+
445
+ // ============================================================================
446
+ // CMS Settings Types
447
+ // ============================================================================
448
+
449
+ export interface CmsSettings {
450
+ showEditableHighlights: boolean
451
+ }
452
+
453
+ // ============================================================================
454
+ // SEO Editor Types
455
+ // ============================================================================
456
+
457
+ export interface SeoEditorState {
458
+ isOpen: boolean
459
+ }
460
+
461
+ /** Represents a pending SEO field change */
462
+ export interface PendingSeoChange {
463
+ /** The SEO element's id */
464
+ id: string
465
+ /** Original value */
466
+ originalValue: string
467
+ /** New value */
468
+ newValue: string
469
+ /** Whether this change is dirty (modified) */
470
+ isDirty: boolean
471
+ }
472
+
473
+ // ============================================================================
474
+ // Attribute Editor Types
475
+ // ============================================================================
476
+
477
+ /** Represents a pending attribute change */
478
+ export interface PendingAttributeChange {
479
+ element: HTMLElement
480
+ cmsId: string
481
+ /** Original attribute values from manifest */
482
+ originalAttributes: Record<string, Attribute>
483
+ /** Current (possibly modified) attribute values */
484
+ newAttributes: Record<string, Attribute>
485
+ /** Whether this change is dirty */
486
+ isDirty: boolean
487
+ }
488
+
489
+ /** Attribute change payload for API */
490
+ export interface AttributeChangePayload {
491
+ /** The attribute name being changed */
492
+ attributeName: string
493
+ /** Old value */
494
+ oldValue: string | undefined
495
+ /** New value */
496
+ newValue: string | undefined
497
+ /** Path to the source file where the attribute is defined */
498
+ sourcePath?: string
499
+ /** Line number where the attribute is defined */
500
+ sourceLine?: number
501
+ /** The source code snippet containing the attribute */
502
+ sourceSnippet?: string
503
+ }
504
+
505
+ /** Editor state for attribute editor */
506
+ export interface AttributeEditorState {
507
+ isOpen: boolean
508
+ targetElementId: string | null
509
+ targetRect: DOMRect | null
510
+ }
511
+
512
+ /** Saved attribute edit for storage persistence */
513
+ export interface SavedAttributeEdit {
514
+ originalAttributes: Record<string, Attribute>
515
+ newAttributes: Record<string, Attribute>
516
+ }
517
+
518
+ /** Saved attribute edits indexed by CMS ID */
519
+ export interface SavedAttributeEdits {
520
+ [cmsId: string]: SavedAttributeEdit
521
+ }
522
+
523
+ // ============================================================================
524
+ // Undo/Redo Types
525
+ // ============================================================================
526
+
527
+ export interface UndoTextAction {
528
+ type: 'text'
529
+ cmsId: string
530
+ element: HTMLElement
531
+ previousHTML: string
532
+ previousText: string
533
+ currentHTML: string
534
+ currentText: string
535
+ wasDirty: boolean
536
+ }
537
+
538
+ export interface UndoImageAction {
539
+ type: 'image'
540
+ cmsId: string
541
+ element: HTMLImageElement
542
+ previousSrc: string
543
+ previousAlt: string
544
+ currentSrc: string
545
+ currentAlt: string
546
+ wasDirty: boolean
547
+ }
548
+
549
+ export interface UndoColorAction {
550
+ type: 'color'
551
+ cmsId: string
552
+ element: HTMLElement
553
+ previousClassName: string
554
+ currentClassName: string
555
+ previousStyleCssText: string
556
+ currentStyleCssText: string
557
+ previousClasses: Record<string, Attribute>
558
+ currentClasses: Record<string, Attribute>
559
+ wasDirty: boolean
560
+ }
561
+
562
+ export interface UndoAttributeAction {
563
+ type: 'attribute'
564
+ cmsId: string
565
+ element: HTMLElement
566
+ previousAttributes: Record<string, Attribute>
567
+ currentAttributes: Record<string, Attribute>
568
+ wasDirty: boolean
569
+ }
570
+
571
+ export interface UndoSeoAction {
572
+ type: 'seo'
573
+ cmsId: string
574
+ previousValue: string
575
+ currentValue: string
576
+ originalValue: string
577
+ wasDirty: boolean
578
+ }
579
+
580
+ export type UndoAction =
581
+ | UndoTextAction
582
+ | UndoImageAction
583
+ | UndoColorAction
584
+ | UndoAttributeAction
585
+ | UndoSeoAction
586
+
587
+ declare global {
588
+ interface Window {
589
+ NuaCmsConfig?: Partial<CmsConfig>
590
+ }
591
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Collects errors during processing for aggregated reporting.
3
+ * This allows the build to continue while tracking what failed.
4
+ */
5
+ export class ErrorCollector {
6
+ private errors: Array<{ context: string; error: Error }> = []
7
+ private warnings: Array<{ context: string; message: string }> = []
8
+
9
+ /**
10
+ * Record an error with context about where it occurred.
11
+ */
12
+ addError(context: string, error: Error): void {
13
+ this.errors.push({ context, error })
14
+ }
15
+
16
+ /**
17
+ * Record a warning (non-fatal issue).
18
+ */
19
+ addWarning(context: string, message: string): void {
20
+ this.warnings.push({ context, message })
21
+ }
22
+
23
+ /**
24
+ * Check if any errors were recorded.
25
+ */
26
+ hasErrors(): boolean {
27
+ return this.errors.length > 0
28
+ }
29
+
30
+ /**
31
+ * Check if any warnings were recorded.
32
+ */
33
+ hasWarnings(): boolean {
34
+ return this.warnings.length > 0
35
+ }
36
+
37
+ /**
38
+ * Get all recorded errors.
39
+ */
40
+ getErrors(): ReadonlyArray<{ context: string; error: Error }> {
41
+ return this.errors
42
+ }
43
+
44
+ /**
45
+ * Get all recorded warnings.
46
+ */
47
+ getWarnings(): ReadonlyArray<{ context: string; message: string }> {
48
+ return this.warnings
49
+ }
50
+
51
+ /**
52
+ * Get a summary of all errors and warnings.
53
+ */
54
+ getSummary(): string {
55
+ const lines: string[] = []
56
+
57
+ if (this.errors.length > 0) {
58
+ lines.push(`${this.errors.length} error(s):`)
59
+ for (const { context, error } of this.errors) {
60
+ lines.push(` - ${context}: ${error.message}`)
61
+ }
62
+ }
63
+
64
+ if (this.warnings.length > 0) {
65
+ lines.push(`${this.warnings.length} warning(s):`)
66
+ for (const { context, message } of this.warnings) {
67
+ lines.push(` - ${context}: ${message}`)
68
+ }
69
+ }
70
+
71
+ return lines.join('\n')
72
+ }
73
+
74
+ /**
75
+ * Clear all recorded errors and warnings.
76
+ */
77
+ clear(): void {
78
+ this.errors = []
79
+ this.warnings = []
80
+ }
81
+ }
82
+
83
+ /** Singleton error collector for the build process */
84
+ let globalErrorCollector: ErrorCollector | null = null
85
+
86
+ /**
87
+ * Get the global error collector instance.
88
+ * Creates one if it doesn't exist.
89
+ */
90
+ export function getErrorCollector(): ErrorCollector {
91
+ if (!globalErrorCollector) {
92
+ globalErrorCollector = new ErrorCollector()
93
+ }
94
+ return globalErrorCollector
95
+ }
96
+
97
+ /**
98
+ * Reset the global error collector (call at start of each build).
99
+ */
100
+ export function resetErrorCollector(): void {
101
+ if (globalErrorCollector) {
102
+ globalErrorCollector.clear()
103
+ } else {
104
+ globalErrorCollector = new ErrorCollector()
105
+ }
106
+ }