@duffcloudservices/cms 0.1.1 → 0.1.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/editorBridge.d.ts +37 -0
- package/dist/editor/editorBridge.js +556 -0
- package/dist/editor/editorBridge.js.map +1 -0
- package/dist/index.d.ts +93 -6
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +46 -1
- package/dist/plugins/index.js +38 -1
- package/dist/plugins/index.js.map +1 -1
- package/package.json +72 -69
package/dist/plugins/index.js
CHANGED
|
@@ -164,6 +164,43 @@ function dcsSeoPlugin(options = {}) {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
// src/plugins/dcsEditorPlugin.ts
|
|
168
|
+
function dcsEditorPlugin(options = {}) {
|
|
169
|
+
const { debug = false } = options;
|
|
170
|
+
const VIRTUAL_PATH = "/__dcs-editor-bridge.js";
|
|
171
|
+
return {
|
|
172
|
+
name: "dcs-editor-bridge",
|
|
173
|
+
resolveId(id) {
|
|
174
|
+
if (id === VIRTUAL_PATH) {
|
|
175
|
+
return id;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
load(id) {
|
|
179
|
+
if (id === VIRTUAL_PATH) {
|
|
180
|
+
return `
|
|
181
|
+
import { initEditorBridge } from '@duffcloudservices/cms/editor'
|
|
182
|
+
// The bridge only activates inside an iframe (portal preview)
|
|
183
|
+
if (window.parent !== window) {
|
|
184
|
+
if (document.readyState === 'loading') {
|
|
185
|
+
document.addEventListener('DOMContentLoaded', () => setTimeout(initEditorBridge, 200))
|
|
186
|
+
} else {
|
|
187
|
+
setTimeout(initEditorBridge, 200)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
transformIndexHtml(html) {
|
|
194
|
+
if (debug) {
|
|
195
|
+
console.log("[dcs-editor] Injecting editor bridge script tag");
|
|
196
|
+
}
|
|
197
|
+
const scriptTag = `<script type="module" src="${VIRTUAL_PATH}"></script>`;
|
|
198
|
+
return html.replace("</body>", `${scriptTag}
|
|
199
|
+
</body>`);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export { dcsContentPlugin, dcsEditorPlugin, dcsSeoPlugin };
|
|
168
205
|
//# sourceMappingURL=index.js.map
|
|
169
206
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/dcsContentPlugin.ts","../../src/plugins/dcsSeoPlugin.ts"],"names":["path","fs","yaml"],"mappings":";;;;;AAqDO,SAAS,gBAAA,CAAiB,OAAA,GAAmC,EAAC,EAAW;AAC9E,EAAA,MAAM,EAAE,WAAA,GAAc,mBAAA,EAAqB,KAAA,GAAQ,OAAM,GAAI,OAAA;AAE7D,EAAA,IAAI,cAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,aAAA;AAAA,IAEN,eAAe,MAAA,EAAQ;AACrB,MAAA,cAAA,GAAiB,MAAA;AAAA,IACnB,CAAA;AAAA,IAEA,OAAO,MAAA,EAAQ;AACb,MAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,IAAQ,OAAA,CAAQ,GAAA,EAAI;AAI/C,MAAA,MAAM,aAAA,GAAgB;AAAA,QACpB,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,WAAW,CAAA;AAAA,QACrC,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,IAAA,EAAM,WAAW,CAAA;AAAA,QAC3C,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,GAAA,IAAO,WAAW;AAAA,OACzC;AAEA,MAAA,IAAI,SAAA;AACJ,MAAA,KAAA,MAAW,YAAY,aAAA,EAAe;AACpC,QAAA,IAAI,EAAA,CAAG,UAAA,CAAW,QAAQ,CAAA,EAAG;AAC3B,UAAA,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AAE5B,UAAA,MAAA,CAAO,OAAA,CAAQ,EAAA,CAAG,QAAA,EAAU,CAAC,WAAA,KAAgB;AAC3C,YAAA,IAAI,gBAAgB,SAAA,EAAW;AAC7B,cAAA,IAAI,KAAA,EAAO;AACT,gBAAA,OAAA,CAAQ,IAAI,+CAA+C,CAAA;AAAA,cAC7D;AACA,cAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,YACjB;AAAA,UACF,CAAC,CAAA;AAAA,QACH;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\r\n * DCS Content Plugin for Vite\r\n *\r\n * Reads `.dcs/content.yaml` at build time and injects content\r\n * as `__DCS_CONTENT__` global variable for use by useTextContent.\r\n *\r\n * @example\r\n * ```typescript\r\n * // vite.config.ts\r\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * plugins: [\r\n * dcsContentPlugin({ debug: true })\r\n * ]\r\n * })\r\n * ```\r\n *\r\n * For VitePress:\r\n * ```typescript\r\n * // .vitepress/config.ts\r\n * import { defineConfig } from 'vitepress'\r\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * vite: {\r\n * plugins: [\r\n * dcsContentPlugin()\r\n * ]\r\n * }\r\n * })\r\n * ```\r\n */\r\n\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport yaml from 'js-yaml'\r\nimport type { Plugin, ResolvedConfig } from 'vite'\r\nimport type { DcsContentFile } from '../types/content'\r\n\r\nexport interface DcsContentPluginOptions {\r\n /** Path to content.yaml relative to project root (default: '.dcs/content.yaml') */\r\n contentPath?: string\r\n /** Enable debug logging */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Vite plugin that injects .dcs/content.yaml at build time.\r\n *\r\n * @param options - Plugin configuration\r\n * @returns Vite plugin\r\n */\r\nexport function dcsContentPlugin(options: DcsContentPluginOptions = {}): Plugin {\r\n const { contentPath = '.dcs/content.yaml', debug = false } = options\r\n\r\n let resolvedConfig: ResolvedConfig\r\n\r\n return {\r\n name: 'dcs-content',\r\n\r\n configResolved(config) {\r\n resolvedConfig = config\r\n },\r\n\r\n config(config) {\r\n const projectRoot = config.root || process.cwd()\r\n\r\n // Try to find content.yaml in multiple locations\r\n // VitePress projects have the docs folder as root, so check parent too\r\n const possiblePaths = [\r\n path.resolve(projectRoot, contentPath),\r\n path.resolve(projectRoot, '..', contentPath),\r\n path.resolve(process.cwd(), contentPath),\r\n ]\r\n\r\n let foundPath: string | undefined\r\n for (const testPath of possiblePaths) {\r\n if (fs.existsSync(testPath)) {\r\n foundPath = testPath\r\n break\r\n }\r\n }\r\n\r\n if (!foundPath) {\r\n if (debug) {\r\n console.log('[dcs-content] No content.yaml found at:')\r\n possiblePaths.forEach((p) => console.log(` - ${p}`))\r\n console.log('[dcs-content] Using defaults only')\r\n }\r\n return {\r\n define: {\r\n __DCS_CONTENT__: 'undefined',\r\n },\r\n }\r\n }\r\n\r\n try {\r\n const fileContent = fs.readFileSync(foundPath, 'utf8')\r\n const content = yaml.load(fileContent) as DcsContentFile\r\n\r\n if (debug) {\r\n console.log(`[dcs-content] Loaded ${foundPath}`)\r\n console.log(`[dcs-content] Version: ${content.version}`)\r\n console.log(`[dcs-content] Pages: ${Object.keys(content.pages ?? {}).join(', ') || '(none)'}`)\r\n console.log(`[dcs-content] Global keys: ${Object.keys(content.global ?? {}).length}`)\r\n }\r\n\r\n return {\r\n define: {\r\n __DCS_CONTENT__: JSON.stringify(content),\r\n },\r\n }\r\n } catch (error) {\r\n console.warn('[dcs-content] Failed to parse content.yaml:', error)\r\n return {\r\n define: {\r\n __DCS_CONTENT__: 'undefined',\r\n },\r\n }\r\n }\r\n },\r\n\r\n // Watch for changes in development\r\n configureServer(server) {\r\n const projectRoot = resolvedConfig?.root || process.cwd()\r\n\r\n const watchPaths = [\r\n path.resolve(projectRoot, contentPath),\r\n path.resolve(projectRoot, '..', contentPath),\r\n ]\r\n\r\n watchPaths.forEach((watchPath) => {\r\n if (fs.existsSync(watchPath)) {\r\n server.watcher.add(watchPath)\r\n\r\n server.watcher.on('change', (changedPath) => {\r\n if (changedPath === watchPath) {\r\n if (debug) {\r\n console.log('[dcs-content] content.yaml changed, triggering reload')\r\n }\r\n server.restart()\r\n }\r\n })\r\n }\r\n })\r\n },\r\n }\r\n}\r\n","/**\r\n * DCS SEO Plugin for Vite\r\n *\r\n * Reads `.dcs/seo.yaml` at build time and injects content\r\n * as `__DCS_SEO__` global variable for use by useSEO.\r\n *\r\n * @example\r\n * ```typescript\r\n * // vite.config.ts\r\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * plugins: [\r\n * dcsSeoPlugin({ debug: true })\r\n * ]\r\n * })\r\n * ```\r\n *\r\n * For VitePress:\r\n * ```typescript\r\n * // .vitepress/config.ts\r\n * import { defineConfig } from 'vitepress'\r\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * vite: {\r\n * plugins: [\r\n * dcsSeoPlugin()\r\n * ]\r\n * }\r\n * })\r\n * ```\r\n */\r\n\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport yaml from 'js-yaml'\r\nimport type { Plugin, ResolvedConfig } from 'vite'\r\nimport type { SeoConfiguration } from '../types/seo'\r\n\r\nexport interface DcsSeoPluginOptions {\r\n /** Path to seo.yaml relative to project root (default: '.dcs/seo.yaml') */\r\n seoPath?: string\r\n /** Enable debug logging */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Vite plugin that injects .dcs/seo.yaml at build time.\r\n *\r\n * @param options - Plugin configuration\r\n * @returns Vite plugin\r\n */\r\nexport function dcsSeoPlugin(options: DcsSeoPluginOptions = {}): Plugin {\r\n const { seoPath = '.dcs/seo.yaml', debug = false } = options\r\n\r\n let resolvedConfig: ResolvedConfig\r\n\r\n return {\r\n name: 'dcs-seo',\r\n\r\n configResolved(config) {\r\n resolvedConfig = config\r\n },\r\n\r\n config(config) {\r\n const projectRoot = config.root || process.cwd()\r\n\r\n // Try to find seo.yaml in multiple locations\r\n // VitePress projects have the docs folder as root, so check parent too\r\n const possiblePaths = [\r\n path.resolve(projectRoot, seoPath),\r\n path.resolve(projectRoot, '..', seoPath),\r\n path.resolve(process.cwd(), seoPath),\r\n ]\r\n\r\n let foundPath: string | undefined\r\n for (const testPath of possiblePaths) {\r\n if (fs.existsSync(testPath)) {\r\n foundPath = testPath\r\n break\r\n }\r\n }\r\n\r\n if (!foundPath) {\r\n if (debug) {\r\n console.log('[dcs-seo] No seo.yaml found at:')\r\n possiblePaths.forEach((p) => console.log(` - ${p}`))\r\n console.log('[dcs-seo] Using defaults only')\r\n }\r\n return {\r\n define: {\r\n __DCS_SEO__: 'undefined',\r\n },\r\n }\r\n }\r\n\r\n try {\r\n const fileContent = fs.readFileSync(foundPath, 'utf8')\r\n const seoConfig = yaml.load(fileContent) as SeoConfiguration\r\n\r\n if (debug) {\r\n console.log(`[dcs-seo] Loaded ${foundPath}`)\r\n console.log(`[dcs-seo] Version: ${seoConfig.version}`)\r\n console.log(`[dcs-seo] Site Name: ${seoConfig.global?.siteName || '(not set)'}`)\r\n console.log(`[dcs-seo] Pages: ${Object.keys(seoConfig.pages ?? {}).join(', ') || '(none)'}`)\r\n }\r\n\r\n return {\r\n define: {\r\n __DCS_SEO__: JSON.stringify(seoConfig),\r\n },\r\n }\r\n } catch (error) {\r\n console.warn('[dcs-seo] Failed to parse seo.yaml:', error)\r\n return {\r\n define: {\r\n __DCS_SEO__: 'undefined',\r\n },\r\n }\r\n }\r\n },\r\n\r\n // Watch for changes in development\r\n configureServer(server) {\r\n const projectRoot = resolvedConfig?.root || process.cwd()\r\n\r\n const watchPaths = [\r\n path.resolve(projectRoot, seoPath),\r\n path.resolve(projectRoot, '..', seoPath),\r\n ]\r\n\r\n watchPaths.forEach((watchPath) => {\r\n if (fs.existsSync(watchPath)) {\r\n server.watcher.add(watchPath)\r\n\r\n server.watcher.on('change', (changedPath) => {\r\n if (changedPath === watchPath) {\r\n if (debug) {\r\n console.log('[dcs-seo] seo.yaml changed, triggering reload')\r\n }\r\n server.restart()\r\n }\r\n })\r\n }\r\n })\r\n },\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/dcsContentPlugin.ts","../../src/plugins/dcsSeoPlugin.ts","../../src/plugins/dcsEditorPlugin.ts"],"names":["path","fs","yaml"],"mappings":";;;;;AAqDO,SAAS,gBAAA,CAAiB,OAAA,GAAmC,EAAC,EAAW;AAC9E,EAAA,MAAM,EAAE,WAAA,GAAc,mBAAA,EAAqB,KAAA,GAAQ,OAAM,GAAI,OAAA;AAE7D,EAAA,IAAI,cAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,aAAA;AAAA,IAEN,eAAe,MAAA,EAAQ;AACrB,MAAA,cAAA,GAAiB,MAAA;AAAA,IACnB,CAAA;AAAA,IAEA,OAAO,MAAA,EAAQ;AACb,MAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,IAAQ,OAAA,CAAQ,GAAA,EAAI;AAI/C,MAAA,MAAM,aAAA,GAAgB;AAAA,QACpB,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,WAAW,CAAA;AAAA,QACrC,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,IAAA,EAAM,WAAW,CAAA;AAAA,QAC3C,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,GAAA,IAAO,WAAW;AAAA,OACzC;AAEA,MAAA,IAAI,SAAA;AACJ,MAAA,KAAA,MAAW,YAAY,aAAA,EAAe;AACpC,QAAA,IAAI,EAAA,CAAG,UAAA,CAAW,QAAQ,CAAA,EAAG;AAC3B,UAAA,SAAA,GAAY,QAAA;AACZ,UAAA;AAAA,QACF;AAAA,MACF;AAEA,MAAA,IAAI,CAAC,SAAA,EAAW;AACd,QAAA,IAAI,KAAA,EAAO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EAAW;AAC7B,cAAA,IAAI,KAAA,EAAO;AACT,gBAAA,OAAA,CAAQ,IAAI,+CAA+C,CAAA;AAAA,cAC7D;AACA,cAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,YACjB;AAAA,UACF,CAAC,CAAA;AAAA,QACH;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;ACtGO,SAAS,eAAA,CAAgB,OAAA,GAAkC,EAAC,EAAW;AAC5E,EAAA,MAAM,EAAE,KAAA,GAAQ,KAAA,EAAM,GAAI,OAAA;AAC1B,EAAA,MAAM,YAAA,GAAe,yBAAA;AAErB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,mBAAA;AAAA,IAEN,UAAU,EAAA,EAAI;AACZ,MAAA,IAAI,OAAO,YAAA,EAAc;AACvB,QAAA,OAAO,EAAA;AAAA,MACT;AAAA,IACF,CAAA;AAAA,IAEA,KAAK,EAAA,EAAI;AACP,MAAA,IAAI,OAAO,YAAA,EAAc;AACvB,QAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,MAWT;AAAA,IACF,CAAA;AAAA,IAEA,mBAAmB,IAAA,EAAM;AACvB,MAAA,IAAI,KAAA,EAAO;AACT,QAAA,OAAA,CAAQ,IAAI,iDAAiD,CAAA;AAAA,MAC/D;AAIA,MAAA,MAAM,SAAA,GAAY,8BAA8B,YAAY,CAAA,WAAA,CAAA;AAG5D,MAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,CAAA,EAAG,SAAS;AAAA,OAAA,CAAW,CAAA;AAAA,IACxD;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\r\n * DCS Content Plugin for Vite\r\n *\r\n * Reads `.dcs/content.yaml` at build time and injects content\r\n * as `__DCS_CONTENT__` global variable for use by useTextContent.\r\n *\r\n * @example\r\n * ```typescript\r\n * // vite.config.ts\r\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * plugins: [\r\n * dcsContentPlugin({ debug: true })\r\n * ]\r\n * })\r\n * ```\r\n *\r\n * For VitePress:\r\n * ```typescript\r\n * // .vitepress/config.ts\r\n * import { defineConfig } from 'vitepress'\r\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * vite: {\r\n * plugins: [\r\n * dcsContentPlugin()\r\n * ]\r\n * }\r\n * })\r\n * ```\r\n */\r\n\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport yaml from 'js-yaml'\r\nimport type { Plugin, ResolvedConfig } from 'vite'\r\nimport type { DcsContentFile } from '../types/content'\r\n\r\nexport interface DcsContentPluginOptions {\r\n /** Path to content.yaml relative to project root (default: '.dcs/content.yaml') */\r\n contentPath?: string\r\n /** Enable debug logging */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Vite plugin that injects .dcs/content.yaml at build time.\r\n *\r\n * @param options - Plugin configuration\r\n * @returns Vite plugin\r\n */\r\nexport function dcsContentPlugin(options: DcsContentPluginOptions = {}): Plugin {\r\n const { contentPath = '.dcs/content.yaml', debug = false } = options\r\n\r\n let resolvedConfig: ResolvedConfig\r\n\r\n return {\r\n name: 'dcs-content',\r\n\r\n configResolved(config) {\r\n resolvedConfig = config\r\n },\r\n\r\n config(config) {\r\n const projectRoot = config.root || process.cwd()\r\n\r\n // Try to find content.yaml in multiple locations\r\n // VitePress projects have the docs folder as root, so check parent too\r\n const possiblePaths = [\r\n path.resolve(projectRoot, contentPath),\r\n path.resolve(projectRoot, '..', contentPath),\r\n path.resolve(process.cwd(), contentPath),\r\n ]\r\n\r\n let foundPath: string | undefined\r\n for (const testPath of possiblePaths) {\r\n if (fs.existsSync(testPath)) {\r\n foundPath = testPath\r\n break\r\n }\r\n }\r\n\r\n if (!foundPath) {\r\n if (debug) {\r\n console.log('[dcs-content] No content.yaml found at:')\r\n possiblePaths.forEach((p) => console.log(` - ${p}`))\r\n console.log('[dcs-content] Using defaults only')\r\n }\r\n return {\r\n define: {\r\n __DCS_CONTENT__: 'undefined',\r\n },\r\n }\r\n }\r\n\r\n try {\r\n const fileContent = fs.readFileSync(foundPath, 'utf8')\r\n const content = yaml.load(fileContent) as DcsContentFile\r\n\r\n if (debug) {\r\n console.log(`[dcs-content] Loaded ${foundPath}`)\r\n console.log(`[dcs-content] Version: ${content.version}`)\r\n console.log(`[dcs-content] Pages: ${Object.keys(content.pages ?? {}).join(', ') || '(none)'}`)\r\n console.log(`[dcs-content] Global keys: ${Object.keys(content.global ?? {}).length}`)\r\n }\r\n\r\n return {\r\n define: {\r\n __DCS_CONTENT__: JSON.stringify(content),\r\n },\r\n }\r\n } catch (error) {\r\n console.warn('[dcs-content] Failed to parse content.yaml:', error)\r\n return {\r\n define: {\r\n __DCS_CONTENT__: 'undefined',\r\n },\r\n }\r\n }\r\n },\r\n\r\n // Watch for changes in development\r\n configureServer(server) {\r\n const projectRoot = resolvedConfig?.root || process.cwd()\r\n\r\n const watchPaths = [\r\n path.resolve(projectRoot, contentPath),\r\n path.resolve(projectRoot, '..', contentPath),\r\n ]\r\n\r\n watchPaths.forEach((watchPath) => {\r\n if (fs.existsSync(watchPath)) {\r\n server.watcher.add(watchPath)\r\n\r\n server.watcher.on('change', (changedPath) => {\r\n if (changedPath === watchPath) {\r\n if (debug) {\r\n console.log('[dcs-content] content.yaml changed, triggering reload')\r\n }\r\n server.restart()\r\n }\r\n })\r\n }\r\n })\r\n },\r\n }\r\n}\r\n","/**\r\n * DCS SEO Plugin for Vite\r\n *\r\n * Reads `.dcs/seo.yaml` at build time and injects content\r\n * as `__DCS_SEO__` global variable for use by useSEO.\r\n *\r\n * @example\r\n * ```typescript\r\n * // vite.config.ts\r\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * plugins: [\r\n * dcsSeoPlugin({ debug: true })\r\n * ]\r\n * })\r\n * ```\r\n *\r\n * For VitePress:\r\n * ```typescript\r\n * // .vitepress/config.ts\r\n * import { defineConfig } from 'vitepress'\r\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * vite: {\r\n * plugins: [\r\n * dcsSeoPlugin()\r\n * ]\r\n * }\r\n * })\r\n * ```\r\n */\r\n\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport yaml from 'js-yaml'\r\nimport type { Plugin, ResolvedConfig } from 'vite'\r\nimport type { SeoConfiguration } from '../types/seo'\r\n\r\nexport interface DcsSeoPluginOptions {\r\n /** Path to seo.yaml relative to project root (default: '.dcs/seo.yaml') */\r\n seoPath?: string\r\n /** Enable debug logging */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Vite plugin that injects .dcs/seo.yaml at build time.\r\n *\r\n * @param options - Plugin configuration\r\n * @returns Vite plugin\r\n */\r\nexport function dcsSeoPlugin(options: DcsSeoPluginOptions = {}): Plugin {\r\n const { seoPath = '.dcs/seo.yaml', debug = false } = options\r\n\r\n let resolvedConfig: ResolvedConfig\r\n\r\n return {\r\n name: 'dcs-seo',\r\n\r\n configResolved(config) {\r\n resolvedConfig = config\r\n },\r\n\r\n config(config) {\r\n const projectRoot = config.root || process.cwd()\r\n\r\n // Try to find seo.yaml in multiple locations\r\n // VitePress projects have the docs folder as root, so check parent too\r\n const possiblePaths = [\r\n path.resolve(projectRoot, seoPath),\r\n path.resolve(projectRoot, '..', seoPath),\r\n path.resolve(process.cwd(), seoPath),\r\n ]\r\n\r\n let foundPath: string | undefined\r\n for (const testPath of possiblePaths) {\r\n if (fs.existsSync(testPath)) {\r\n foundPath = testPath\r\n break\r\n }\r\n }\r\n\r\n if (!foundPath) {\r\n if (debug) {\r\n console.log('[dcs-seo] No seo.yaml found at:')\r\n possiblePaths.forEach((p) => console.log(` - ${p}`))\r\n console.log('[dcs-seo] Using defaults only')\r\n }\r\n return {\r\n define: {\r\n __DCS_SEO__: 'undefined',\r\n },\r\n }\r\n }\r\n\r\n try {\r\n const fileContent = fs.readFileSync(foundPath, 'utf8')\r\n const seoConfig = yaml.load(fileContent) as SeoConfiguration\r\n\r\n if (debug) {\r\n console.log(`[dcs-seo] Loaded ${foundPath}`)\r\n console.log(`[dcs-seo] Version: ${seoConfig.version}`)\r\n console.log(`[dcs-seo] Site Name: ${seoConfig.global?.siteName || '(not set)'}`)\r\n console.log(`[dcs-seo] Pages: ${Object.keys(seoConfig.pages ?? {}).join(', ') || '(none)'}`)\r\n }\r\n\r\n return {\r\n define: {\r\n __DCS_SEO__: JSON.stringify(seoConfig),\r\n },\r\n }\r\n } catch (error) {\r\n console.warn('[dcs-seo] Failed to parse seo.yaml:', error)\r\n return {\r\n define: {\r\n __DCS_SEO__: 'undefined',\r\n },\r\n }\r\n }\r\n },\r\n\r\n // Watch for changes in development\r\n configureServer(server) {\r\n const projectRoot = resolvedConfig?.root || process.cwd()\r\n\r\n const watchPaths = [\r\n path.resolve(projectRoot, seoPath),\r\n path.resolve(projectRoot, '..', seoPath),\r\n ]\r\n\r\n watchPaths.forEach((watchPath) => {\r\n if (fs.existsSync(watchPath)) {\r\n server.watcher.add(watchPath)\r\n\r\n server.watcher.on('change', (changedPath) => {\r\n if (changedPath === watchPath) {\r\n if (debug) {\r\n console.log('[dcs-seo] seo.yaml changed, triggering reload')\r\n }\r\n server.restart()\r\n }\r\n })\r\n }\r\n })\r\n },\r\n }\r\n}\r\n","/**\r\n * DCS Editor Plugin for Vite\r\n *\r\n * Injects the editor bridge script into customer sites when running\r\n * in portal preview mode (inside the visual editor iframe).\r\n *\r\n * The bridge enables:\r\n * - Inline text editing via contenteditable\r\n * - Section hover highlights and AI ✨ buttons\r\n * - postMessage communication with the portal\r\n *\r\n * This plugin should only be active in development/preview mode.\r\n * It's safe to include in production builds — it does nothing unless\r\n * the page detects it's inside an iframe.\r\n *\r\n * @example\r\n * ```typescript\r\n * // vite.config.ts\r\n * import { dcsEditorPlugin } from '@duffcloudservices/cms/plugins'\r\n *\r\n * export default defineConfig({\r\n * plugins: [\r\n * dcsEditorPlugin()\r\n * ]\r\n * })\r\n * ```\r\n */\r\n\r\nimport type { Plugin } from 'vite'\r\n\r\nexport interface DcsEditorPluginOptions {\r\n /** Enable debug logging */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Vite plugin that injects the editor bridge script for portal preview integration.\r\n *\r\n * The bridge auto-initializes only when the page detects it's running inside an iframe,\r\n * so it's safe to include in all builds — it's a no-op in standalone browsing.\r\n *\r\n * Uses a virtual module (`/__dcs-editor-bridge.js`) served through Vite's dev server\r\n * so that bare module specifiers (like `@duffcloudservices/cms/editor`) are properly\r\n * resolved through Vite's module graph rather than hitting the browser's native ESM\r\n * resolver, which can't handle bare specifiers.\r\n */\r\nexport function dcsEditorPlugin(options: DcsEditorPluginOptions = {}): Plugin {\r\n const { debug = false } = options\r\n const VIRTUAL_PATH = '/__dcs-editor-bridge.js'\r\n\r\n return {\r\n name: 'dcs-editor-bridge',\r\n\r\n resolveId(id) {\r\n if (id === VIRTUAL_PATH) {\r\n return id\r\n }\r\n },\r\n\r\n load(id) {\r\n if (id === VIRTUAL_PATH) {\r\n return `\r\nimport { initEditorBridge } from '@duffcloudservices/cms/editor'\r\n// The bridge only activates inside an iframe (portal preview)\r\nif (window.parent !== window) {\r\n if (document.readyState === 'loading') {\r\n document.addEventListener('DOMContentLoaded', () => setTimeout(initEditorBridge, 200))\r\n } else {\r\n setTimeout(initEditorBridge, 200)\r\n }\r\n}\r\n`\r\n }\r\n },\r\n\r\n transformIndexHtml(html) {\r\n if (debug) {\r\n console.log('[dcs-editor] Injecting editor bridge script tag')\r\n }\r\n\r\n // Inject a <script> tag referencing our virtual module.\r\n // Vite's dev server will resolve the bare imports in the virtual module code.\r\n const scriptTag = `<script type=\"module\" src=\"${VIRTUAL_PATH}\"></script>`\r\n\r\n // Insert before closing </body> tag\r\n return html.replace('</body>', `${scriptTag}\\n</body>`)\r\n },\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,69 +1,72 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@duffcloudservices/cms",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Vue 3 composables and Vite plugins for DCS CMS integration",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"import": "./dist/index.js"
|
|
10
|
-
},
|
|
11
|
-
"./plugins": {
|
|
12
|
-
"types": "./dist/plugins/index.d.ts",
|
|
13
|
-
"import": "./dist/plugins/index.js"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@duffcloudservices/cms",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Vue 3 composables and Vite plugins for DCS CMS integration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./plugins": {
|
|
12
|
+
"types": "./dist/plugins/index.d.ts",
|
|
13
|
+
"import": "./dist/plugins/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./editor": {
|
|
16
|
+
"types": "./dist/editor/editorBridge.d.ts",
|
|
17
|
+
"import": "./dist/editor/editorBridge.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^3.4.0",
|
|
27
|
+
"@unhead/vue": "^1.9.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"js-yaml": "^4.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/js-yaml": "^4.0.9",
|
|
34
|
+
"@types/node": "^20.11.0",
|
|
35
|
+
"@vue/test-utils": "^2.4.0",
|
|
36
|
+
"tsup": "^8.0.0",
|
|
37
|
+
"typescript": "~5.6.3",
|
|
38
|
+
"vite": "^6.3.5",
|
|
39
|
+
"vitest": "^3.2.3",
|
|
40
|
+
"vue": "^3.5.16",
|
|
41
|
+
"@unhead/vue": "^2.0.5"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"vue",
|
|
45
|
+
"vitepress",
|
|
46
|
+
"cms",
|
|
47
|
+
"dcs",
|
|
48
|
+
"composables",
|
|
49
|
+
"duff-cloud-services"
|
|
50
|
+
],
|
|
51
|
+
"author": "Duff Cloud Services",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/duffn/dcs"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://portal.duffcloudservices.com",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/duffn/dcs/issues"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18.0.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup",
|
|
66
|
+
"dev": "tsup --watch",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest",
|
|
69
|
+
"type-check": "tsc --noEmit",
|
|
70
|
+
"lint": "eslint src --ext .ts"
|
|
71
|
+
}
|
|
72
|
+
}
|