@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 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.0", j_ = J_, ct = {
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
@@ -14,7 +14,7 @@
14
14
  "directory": "packages/astro-cms"
15
15
  },
16
16
  "license": "Apache-2.0",
17
- "version": "0.22.0",
17
+ "version": "0.22.1",
18
18
  "module": "src/index.ts",
19
19
  "types": "src/index.ts",
20
20
  "type": "module",
package/src/index.ts CHANGED
@@ -180,6 +180,7 @@ export default function nuaCms(options: NuaCmsOptions = {}): AstroIntegration {
180
180
  config: markerConfig,
181
181
  idCounter,
182
182
  command,
183
+ contentDir,
183
184
  }
184
185
 
185
186
  const vitePlugins: any[] = [...(createVitePlugin(pluginContext) as any)]
@@ -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
  }