@nuasite/cms 0.22.0 → 0.22.2

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.2", 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.2",
18
18
  "module": "src/index.ts",
19
19
  "types": "src/index.ts",
20
20
  "type": "module",
package/src/index.ts CHANGED
@@ -58,9 +58,9 @@ export interface NuaCmsOptions extends CmsMarkerOptions {
58
58
  }>
59
59
  /**
60
60
  * Enable polling for file watching.
61
- * Ensures reliable change detection after CMS edits.
62
- * Set to `false` to use native fs events instead.
63
- * @default true
61
+ * Set to `true` on filesystems that don't support native events (e.g. network mounts).
62
+ * E2B sandboxes use ext4 with full inotify support, so polling is unnecessary.
63
+ * @default false
64
64
  */
65
65
  usePolling?: boolean
66
66
  }
@@ -85,7 +85,7 @@ export default function nuaCms(options: NuaCmsOptions = {}): AstroIntegration {
85
85
  componentDirs = ['src/components'],
86
86
  contentDir = 'src/content',
87
87
  mdxComponentDirs,
88
- usePolling = true,
88
+ usePolling = false,
89
89
  seo = { trackSeo: true, markTitle: true, parseJsonLd: true },
90
90
  } = options
91
91
 
@@ -1,3 +1,5 @@
1
+ import { watch } from 'node:fs'
2
+ import { join } from 'node:path'
1
3
  import type { Plugin } from 'vite'
2
4
  import { expectedDeletions } from './dev-middleware'
3
5
  import type { ManifestWriter } from './manifest-writer'
@@ -78,10 +80,50 @@ export function createVitePlugin(context: VitePluginContext): Plugin[] {
78
80
  },
79
81
  }
80
82
 
83
+ // Vite's bundled chokidar 3.6.0 fails to detect changes to .astro/data-store.json
84
+ // (added via watcher.add() in Astro's vite-plugin-content-virtual-mod).
85
+ // Without this, content collection edits update the data store on disk but the
86
+ // browser never receives a full-reload because Vite's watcher never fires "change"
87
+ // for that file. We use native fs.watch as a reliable fallback.
88
+ const dataStoreWatchPlugin: Plugin = {
89
+ name: 'cms-data-store-watch',
90
+ configureServer(server) {
91
+ if (command !== 'dev') return
92
+ const root = server.config.root
93
+ const dataStorePath = join(root, '.astro', 'data-store.json')
94
+ let fsWatcher: ReturnType<typeof watch> | undefined
95
+ let debounce: ReturnType<typeof setTimeout> | undefined
96
+
97
+ const startWatching = () => {
98
+ try {
99
+ fsWatcher = watch(dataStorePath, () => {
100
+ clearTimeout(debounce)
101
+ debounce = setTimeout(() => {
102
+ server.environments.client.hot.send({ type: 'full-reload', path: '*' })
103
+ }, 80)
104
+ })
105
+ } catch {
106
+ // File doesn't exist yet — retry when it appears
107
+ setTimeout(startWatching, 2000)
108
+ }
109
+ }
110
+
111
+ // Data store is created during content sync, which runs after server start
112
+ setTimeout(startWatching, 3000)
113
+
114
+ const origClose = server.close.bind(server)
115
+ server.close = async () => {
116
+ fsWatcher?.close()
117
+ clearTimeout(debounce)
118
+ return origClose()
119
+ }
120
+ },
121
+ }
122
+
81
123
  // Note: We cannot use transformIndexHtml for static Astro builds because
82
124
  // Astro generates HTML files directly without going through Vite's HTML pipeline.
83
125
  // HTML processing is done in build-processor.ts after pages are generated.
84
126
  // Source location attributes are provided natively by Astro's compiler
85
127
  // (data-astro-source-file, data-astro-source-loc) in dev mode.
86
- return [virtualManifestPlugin, watcherPlugin, createArrayTransformPlugin()]
128
+ return [virtualManifestPlugin, watcherPlugin, dataStoreWatchPlugin, createArrayTransformPlugin()]
87
129
  }