astro-mermaid 2.0.3 → 2.0.4
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/astro-mermaid-integration.js +55 -16
- package/package.json +10 -2
|
@@ -255,24 +255,63 @@ export default function astroMermaid(options = {}) {
|
|
|
255
255
|
viteOptimizeDepsInclude.push('@mermaid-js/layout-elk');
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
258
|
+
const remarkEntry = [remarkMermaidPlugin, { logger }];
|
|
259
|
+
const rehypeEntry = [rehypeMermaidPlugin, { logger }];
|
|
260
|
+
const viteConfig = { optimizeDeps: { include: viteOptimizeDepsInclude } };
|
|
261
|
+
|
|
262
|
+
// Astro 6.4+ deprecated `markdown.remarkPlugins` / `markdown.rehypePlugins`
|
|
263
|
+
// in favor of passing plugins to `unified({...})` via `markdown.processor`.
|
|
264
|
+
// On 6.4+ Astro always supplies a default unified processor, so its
|
|
265
|
+
// presence is our signal to use the new API and avoid the deprecation
|
|
266
|
+
// warning. Older Astro versions have no processor — fall back to the
|
|
267
|
+
// (still-supported there) plugin arrays. Fixes #62.
|
|
268
|
+
const existingProcessor = config.markdown?.processor;
|
|
269
|
+
let usedProcessor = false;
|
|
270
|
+
|
|
271
|
+
if (existingProcessor) {
|
|
272
|
+
try {
|
|
273
|
+
const { unified, isUnifiedProcessor } = await import('@astrojs/markdown-remark');
|
|
274
|
+
if (isUnifiedProcessor(existingProcessor)) {
|
|
275
|
+
const existingOptions = existingProcessor.options || {};
|
|
276
|
+
updateConfig({
|
|
277
|
+
markdown: {
|
|
278
|
+
processor: unified({
|
|
279
|
+
...existingOptions,
|
|
280
|
+
remarkPlugins: [...(existingOptions.remarkPlugins || []), remarkEntry],
|
|
281
|
+
rehypePlugins: [...(existingOptions.rehypePlugins || []), rehypeEntry]
|
|
282
|
+
})
|
|
283
|
+
},
|
|
284
|
+
vite: viteConfig
|
|
285
|
+
});
|
|
286
|
+
usedProcessor = true;
|
|
273
287
|
}
|
|
288
|
+
} catch (error) {
|
|
289
|
+
// Dynamic import failed, the unified processor helpers are not
|
|
290
|
+
// exported, or updateConfig rejected the processor — fall through
|
|
291
|
+
// to the legacy plugin arrays below.
|
|
292
|
+
logger.warn(
|
|
293
|
+
`Could not configure the unified markdown processor, falling back ` +
|
|
294
|
+
`to remark/rehype plugin arrays: ${error.message}`
|
|
295
|
+
);
|
|
274
296
|
}
|
|
275
|
-
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (!usedProcessor) {
|
|
300
|
+
// Update markdown config to use both remark and rehype plugins
|
|
301
|
+
updateConfig({
|
|
302
|
+
markdown: {
|
|
303
|
+
remarkPlugins: [
|
|
304
|
+
...(config.markdown?.remarkPlugins || []),
|
|
305
|
+
remarkEntry
|
|
306
|
+
],
|
|
307
|
+
rehypePlugins: [
|
|
308
|
+
...(config.markdown?.rehypePlugins || []),
|
|
309
|
+
rehypeEntry
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
vite: viteConfig
|
|
313
|
+
});
|
|
314
|
+
}
|
|
276
315
|
|
|
277
316
|
// Validate and serialize icon packs for client-side use.
|
|
278
317
|
// Only the pack name and either inline icon data or a JSON URL string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-mermaid",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "An Astro integration for rendering Mermaid diagrams with automatic theme switching and client-side rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./astro-mermaid-integration.js",
|
|
@@ -43,6 +43,14 @@
|
|
|
43
43
|
"mdast-util-to-string": "^4.0.0",
|
|
44
44
|
"unist-util-visit": "^5.0.0"
|
|
45
45
|
},
|
|
46
|
+
"overrides": {
|
|
47
|
+
"vite": "^7.3.5",
|
|
48
|
+
"esbuild": "^0.28.1",
|
|
49
|
+
"ip-address": "^10.1.1",
|
|
50
|
+
"js-yaml": "^4.2.0",
|
|
51
|
+
"picomatch": "^4.0.4",
|
|
52
|
+
"tar": "^7.5.16"
|
|
53
|
+
},
|
|
46
54
|
"scripts": {
|
|
47
55
|
"test": "vitest",
|
|
48
56
|
"test:ui": "vitest --ui",
|
|
@@ -52,7 +60,7 @@
|
|
|
52
60
|
"devDependencies": {
|
|
53
61
|
"@types/hast": "^3.0.4",
|
|
54
62
|
"@vitest/ui": "^4.1.8",
|
|
55
|
-
"astro": "^6.
|
|
63
|
+
"astro": "^6.4.6",
|
|
56
64
|
"hast-util-from-html": "^2.0.3",
|
|
57
65
|
"mermaid": "^11.0.0",
|
|
58
66
|
"rehype-parse": "^9.0.1",
|