@nuasite/cms 0.22.0 → 0.22.1
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/editor.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/vite-plugin.ts +22 -2
package/dist/editor.js
CHANGED
|
@@ -381,7 +381,7 @@ function CS(t, e) {
|
|
|
381
381
|
function ES(t, e) {
|
|
382
382
|
return typeof e == "function" ? e(t) : e;
|
|
383
383
|
}
|
|
384
|
-
const J_ = "0.22.
|
|
384
|
+
const J_ = "0.22.1", j_ = J_, ct = {
|
|
385
385
|
/** Highlight overlay for hovered elements */
|
|
386
386
|
HIGHLIGHT: 2147483644,
|
|
387
387
|
/** Hover outline for elements/components */
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/vite-plugin.ts
CHANGED
|
@@ -11,10 +11,11 @@ export interface VitePluginContext {
|
|
|
11
11
|
config: Required<CmsMarkerOptions>
|
|
12
12
|
idCounter: { value: number }
|
|
13
13
|
command: 'dev' | 'build' | 'preview' | 'sync'
|
|
14
|
+
contentDir: string
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function createVitePlugin(context: VitePluginContext): Plugin[] {
|
|
17
|
-
const { manifestWriter, componentDefinitions, command } = context
|
|
18
|
+
const { manifestWriter, componentDefinitions, command, contentDir } = context
|
|
18
19
|
|
|
19
20
|
const virtualManifestPlugin: Plugin = {
|
|
20
21
|
name: 'cms-marker-virtual-manifest',
|
|
@@ -78,10 +79,29 @@ export function createVitePlugin(context: VitePluginContext): Plugin[] {
|
|
|
78
79
|
},
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
// Suppress immediate HMR page reload for content collection files.
|
|
83
|
+
// Without this, Astro's vite-plugin-content-imports invalidates the module and
|
|
84
|
+
// triggers a browser reload BEFORE the content layer has flushed the updated
|
|
85
|
+
// data store to disk — causing a brief render of stale frontmatter data.
|
|
86
|
+
// By returning [] the module graph still marks the module stale (so the MDX body
|
|
87
|
+
// gets re-compiled on next request), but the browser reload is deferred until
|
|
88
|
+
// the content layer writes data-store.json and fires `astro:content-changed`.
|
|
89
|
+
const contentHmrPlugin: Plugin = {
|
|
90
|
+
name: 'cms-defer-content-hmr',
|
|
91
|
+
enforce: 'pre',
|
|
92
|
+
handleHotUpdate({ file }) {
|
|
93
|
+
if (command !== 'dev') return
|
|
94
|
+
const contentSuffix = `/${contentDir}/`
|
|
95
|
+
if (file.includes(contentSuffix)) {
|
|
96
|
+
return []
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
|
|
81
101
|
// Note: We cannot use transformIndexHtml for static Astro builds because
|
|
82
102
|
// Astro generates HTML files directly without going through Vite's HTML pipeline.
|
|
83
103
|
// HTML processing is done in build-processor.ts after pages are generated.
|
|
84
104
|
// Source location attributes are provided natively by Astro's compiler
|
|
85
105
|
// (data-astro-source-file, data-astro-source-loc) in dev mode.
|
|
86
|
-
return [virtualManifestPlugin, watcherPlugin, createArrayTransformPlugin()]
|
|
106
|
+
return [virtualManifestPlugin, watcherPlugin, contentHmrPlugin, createArrayTransformPlugin()]
|
|
87
107
|
}
|