@nuasite/cms-marker 0.0.65 → 0.0.66
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 +2 -1
- package/dist/types/build-processor.d.ts.map +1 -1
- package/dist/types/component-registry.d.ts.map +1 -1
- package/dist/types/config.d.ts +19 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/dev-middleware.d.ts +10 -2
- package/dist/types/dev-middleware.d.ts.map +1 -1
- package/dist/types/error-collector.d.ts +56 -0
- package/dist/types/error-collector.d.ts.map +1 -0
- package/dist/types/html-processor.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/manifest-writer.d.ts.map +1 -1
- package/dist/types/source-finder.d.ts +18 -3
- package/dist/types/source-finder.d.ts.map +1 -1
- package/dist/types/tailwind-colors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +0 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/vite-plugin.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/build-processor.ts +73 -19
- package/src/component-registry.ts +2 -0
- package/src/config.ts +29 -0
- package/src/dev-middleware.ts +12 -4
- package/src/error-collector.ts +106 -0
- package/src/html-processor.ts +55 -37
- package/src/index.ts +20 -4
- package/src/manifest-writer.ts +12 -2
- package/src/source-finder.ts +1003 -295
- package/src/tailwind-colors.ts +248 -48
- package/src/types.ts +0 -4
- package/src/vite-plugin.ts +4 -12
- package/dist/types/astro-transform.d.ts +0 -21
- package/dist/types/astro-transform.d.ts.map +0 -1
- package/src/astro-transform.ts +0 -205
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro'
|
|
2
2
|
import { processBuildOutput } from './build-processor'
|
|
3
3
|
import { ComponentRegistry } from './component-registry'
|
|
4
|
+
import { resetProjectRoot } from './config'
|
|
4
5
|
import { createDevMiddleware } from './dev-middleware'
|
|
6
|
+
import { getErrorCollector, resetErrorCollector } from './error-collector'
|
|
5
7
|
import { ManifestWriter } from './manifest-writer'
|
|
6
8
|
import type { CmsMarkerOptions, ComponentDefinition } from './types'
|
|
7
9
|
import { createVitePlugin } from './vite-plugin'
|
|
@@ -46,6 +48,8 @@ export default function cmsMarker(options: CmsMarkerOptions = {}): AstroIntegrat
|
|
|
46
48
|
// Reset state for new build/dev session
|
|
47
49
|
idCounter.value = 0
|
|
48
50
|
manifestWriter.reset()
|
|
51
|
+
resetErrorCollector()
|
|
52
|
+
resetProjectRoot()
|
|
49
53
|
|
|
50
54
|
// Load available colors from Tailwind config
|
|
51
55
|
await manifestWriter.loadAvailableColors()
|
|
@@ -72,15 +76,16 @@ export default function cmsMarker(options: CmsMarkerOptions = {}): AstroIntegrat
|
|
|
72
76
|
command,
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
// VitePluginLike is compatible with both Astro's bundled Vite and root Vite
|
|
75
80
|
updateConfig({
|
|
76
81
|
vite: {
|
|
77
|
-
plugins:
|
|
82
|
+
plugins: createVitePlugin(pluginContext) as any,
|
|
78
83
|
},
|
|
79
84
|
})
|
|
80
85
|
},
|
|
81
86
|
|
|
82
87
|
'astro:server:setup': ({ server, logger }) => {
|
|
83
|
-
createDevMiddleware(server
|
|
88
|
+
createDevMiddleware(server, config, manifestWriter, componentDefinitions, idCounter)
|
|
84
89
|
logger.info('Dev middleware initialized')
|
|
85
90
|
},
|
|
86
91
|
|
|
@@ -88,13 +93,24 @@ export default function cmsMarker(options: CmsMarkerOptions = {}): AstroIntegrat
|
|
|
88
93
|
if (generateManifest) {
|
|
89
94
|
await processBuildOutput(dir, config, manifestWriter, idCounter, logger)
|
|
90
95
|
}
|
|
96
|
+
|
|
97
|
+
// Report any warnings collected during processing
|
|
98
|
+
const errorCollector = getErrorCollector()
|
|
99
|
+
if (errorCollector.hasWarnings()) {
|
|
100
|
+
const warnings = errorCollector.getWarnings()
|
|
101
|
+
logger.warn(`${warnings.length} warning(s) during processing:`)
|
|
102
|
+
for (const { context, message } of warnings) {
|
|
103
|
+
logger.warn(` - ${context}: ${message}`)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
91
106
|
},
|
|
92
107
|
},
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
|
|
96
|
-
export
|
|
97
|
-
|
|
111
|
+
// Re-export config functions for testing
|
|
112
|
+
export { getProjectRoot, resetProjectRoot, setProjectRoot } from './config'
|
|
98
113
|
// Re-export types for consumers
|
|
99
114
|
export type { CollectionInfo, MarkdownContent, SourceLocation, VariableReference } from './source-finder'
|
|
115
|
+
export { findCollectionSource, parseMarkdownContent } from './source-finder'
|
|
100
116
|
export type * from './types'
|
package/src/manifest-writer.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
+
import { getProjectRoot } from './config'
|
|
3
4
|
import { parseTailwindConfig, parseTextStyles } from './tailwind-colors'
|
|
4
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
AvailableColors,
|
|
7
|
+
AvailableTextStyles,
|
|
8
|
+
CmsManifest,
|
|
9
|
+
CollectionEntry,
|
|
10
|
+
ComponentDefinition,
|
|
11
|
+
ComponentInstance,
|
|
12
|
+
ManifestEntry,
|
|
13
|
+
ManifestMetadata,
|
|
14
|
+
} from './types'
|
|
5
15
|
import { generateManifestContentHash, generateSourceFileHashes } from './utils'
|
|
6
16
|
|
|
7
17
|
/** Current manifest schema version */
|
|
@@ -54,7 +64,7 @@ export class ManifestWriter {
|
|
|
54
64
|
/**
|
|
55
65
|
* Load available Tailwind colors and text styles from the project's CSS config
|
|
56
66
|
*/
|
|
57
|
-
async loadAvailableColors(projectRoot: string =
|
|
67
|
+
async loadAvailableColors(projectRoot: string = getProjectRoot()): Promise<void> {
|
|
58
68
|
this.availableColors = await parseTailwindConfig(projectRoot)
|
|
59
69
|
this.availableTextStyles = await parseTextStyles(projectRoot)
|
|
60
70
|
this.globalManifest.availableColors = this.availableColors
|