@nuasite/cms 0.22.1 → 0.23.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.
- package/dist/editor.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -5
- package/src/vite-plugin.ts +49 -17
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.
|
|
384
|
+
const J_ = "0.23.0", 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
|
@@ -58,9 +58,9 @@ export interface NuaCmsOptions extends CmsMarkerOptions {
|
|
|
58
58
|
}>
|
|
59
59
|
/**
|
|
60
60
|
* Enable polling for file watching.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @default
|
|
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 =
|
|
88
|
+
usePolling = false,
|
|
89
89
|
seo = { trackSeo: true, markTitle: true, parseJsonLd: true },
|
|
90
90
|
} = options
|
|
91
91
|
|
|
@@ -180,7 +180,6 @@ export default function nuaCms(options: NuaCmsOptions = {}): AstroIntegration {
|
|
|
180
180
|
config: markerConfig,
|
|
181
181
|
idCounter,
|
|
182
182
|
command,
|
|
183
|
-
contentDir,
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
const vitePlugins: any[] = [...(createVitePlugin(pluginContext) as any)]
|
package/src/vite-plugin.ts
CHANGED
|
@@ -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'
|
|
@@ -11,11 +13,10 @@ export interface VitePluginContext {
|
|
|
11
13
|
config: Required<CmsMarkerOptions>
|
|
12
14
|
idCounter: { value: number }
|
|
13
15
|
command: 'dev' | 'build' | 'preview' | 'sync'
|
|
14
|
-
contentDir: string
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function createVitePlugin(context: VitePluginContext): Plugin[] {
|
|
18
|
-
const { manifestWriter, componentDefinitions, command
|
|
19
|
+
const { manifestWriter, componentDefinitions, command } = context
|
|
19
20
|
|
|
20
21
|
const virtualManifestPlugin: Plugin = {
|
|
21
22
|
name: 'cms-marker-virtual-manifest',
|
|
@@ -79,21 +80,52 @@ export function createVitePlugin(context: VitePluginContext): Plugin[] {
|
|
|
79
80
|
},
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
name: 'cms-defer-content-hmr',
|
|
91
|
-
enforce: 'pre',
|
|
92
|
-
handleHotUpdate({ file }) {
|
|
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) {
|
|
93
91
|
if (command !== 'dev') return
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
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 invalidate = () => {
|
|
98
|
+
// Replicate Astro's invalidateDataStore which never fires because
|
|
99
|
+
// Vite's bundled chokidar 3.6.0 misses atomic-write changes.
|
|
100
|
+
const ssr = server.environments.ssr
|
|
101
|
+
const mod = ssr.moduleGraph.getModuleById('\0astro:data-store')
|
|
102
|
+
if (mod) {
|
|
103
|
+
ssr.moduleGraph.invalidateModule(mod, undefined, Date.now(), true)
|
|
104
|
+
}
|
|
105
|
+
ssr.hot.send('astro:content-changed', {})
|
|
106
|
+
server.environments.client.hot.send({ type: 'full-reload', path: '*' })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const startWatching = () => {
|
|
110
|
+
try {
|
|
111
|
+
fsWatcher = watch(dataStorePath, () => {
|
|
112
|
+
clearTimeout(debounce)
|
|
113
|
+
debounce = setTimeout(invalidate, 80)
|
|
114
|
+
})
|
|
115
|
+
} catch {
|
|
116
|
+
// File doesn't exist yet — retry when it appears
|
|
117
|
+
setTimeout(startWatching, 2000)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Data store is created during content sync, which runs after server start
|
|
122
|
+
setTimeout(startWatching, 3000)
|
|
123
|
+
|
|
124
|
+
const origClose = server.close.bind(server)
|
|
125
|
+
server.close = async () => {
|
|
126
|
+
fsWatcher?.close()
|
|
127
|
+
clearTimeout(debounce)
|
|
128
|
+
return origClose()
|
|
97
129
|
}
|
|
98
130
|
},
|
|
99
131
|
}
|
|
@@ -103,5 +135,5 @@ export function createVitePlugin(context: VitePluginContext): Plugin[] {
|
|
|
103
135
|
// HTML processing is done in build-processor.ts after pages are generated.
|
|
104
136
|
// Source location attributes are provided natively by Astro's compiler
|
|
105
137
|
// (data-astro-source-file, data-astro-source-loc) in dev mode.
|
|
106
|
-
return [virtualManifestPlugin, watcherPlugin,
|
|
138
|
+
return [virtualManifestPlugin, watcherPlugin, dataStoreWatchPlugin, createArrayTransformPlugin()]
|
|
107
139
|
}
|