astro-dgmo 0.11.1 → 0.11.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/README.md +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ integrations: [dgmo({ liveLink: { enabled: false } })];
|
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
Switched off, the fence renders a small card naming the diagram and linking
|
|
146
|
-
through to it, plus a hover-revealed
|
|
146
|
+
through to it, plus a hover-revealed _"Show this diagram here"_ link to the
|
|
147
147
|
guide, and the build warns. See the
|
|
148
148
|
[live links guide](https://diagrammo.app/docs/live-links/).
|
|
149
149
|
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,12 @@ function dgmoIntegration(options = {}) {
|
|
|
15
15
|
return {
|
|
16
16
|
name: "astro-dgmo",
|
|
17
17
|
hooks: {
|
|
18
|
-
async "astro:config:setup"({
|
|
18
|
+
async "astro:config:setup"({
|
|
19
|
+
config,
|
|
20
|
+
updateConfig,
|
|
21
|
+
injectScript,
|
|
22
|
+
logger
|
|
23
|
+
}) {
|
|
19
24
|
const plugin = [
|
|
20
25
|
remarkDgmo,
|
|
21
26
|
optionsWithLegacy
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type { AstroIntegration } from 'astro';\nimport remarkDgmo from 'remark-dgmo';\nimport type { DgmoIntegrationOptions } from './options.js';\n\nexport type { DgmoIntegrationOptions, Mode, Theme } from './options.js';\nexport { default as remarkDgmo } from 'remark-dgmo';\n\n/**\n * Astro integration that renders DGMO fenced code blocks at build time.\n *\n * @example\n * ```js\n * // astro.config.mjs\n * import dgmo from 'astro-dgmo';\n *\n * export default defineConfig({\n * integrations: [dgmo()],\n * });\n * ```\n *\n * v0.3.0 changes the rendered HTML class-name prefix from `astro-dgmo-*` to\n * `dgmo-*`. Both are emitted for one minor cycle via the shared `remark-dgmo`\n * `legacyClassNames` option, so existing user CSS keeps working until v0.4.\n *\n * v0.3.0 also defaults to `colorMode: 'auto'` (dual-render, light+dark SVGs)\n * to fix the silent dark/light-mismatch bug on Starlight and any toggle-\n * enabled Astro site. Users on single-mode sites can opt back to single-render\n * by setting `colorMode: 'light'` or `colorMode: 'dark'` in the integration\n * options.\n *\n * **CSS is automatic since v0.11.0.** The integration adds\n * `remark-dgmo/client.css` to every page itself, so a fresh install renders\n * one diagram rather than two. Opt out with `injectClientCss: false` if you\n * ship your own copy of the color-mode rules.\n */\nexport default function dgmoIntegration(\n options: DgmoIntegrationOptions = {}\n): AstroIntegration {\n // Emit BOTH new (`dgmo-*`) and legacy (`astro-dgmo-*`) class names so user\n // CSS targeting the v0.2 classes keeps working. Removed in v0.4.\n const optionsWithLegacy: DgmoIntegrationOptions = {\n ...options,\n legacyClassNames: [\n ...(options.legacyClassNames ?? []),\n 'astro-dgmo',\n 'astro-dgmo-card',\n ],\n };\n\n return {\n name: 'astro-dgmo',\n hooks: {\n async 'astro:config:setup'({ config, updateConfig, injectScript, logger }) {\n const plugin: [typeof remarkDgmo, DgmoIntegrationOptions] = [\n remarkDgmo,\n optionsWithLegacy,\n ];\n\n // 🔴 Astro 7 stopped running remark plugins, and does it QUIETLY.\n //\n // Sätteri replaced unified as the default Markdown processor, and\n // `markdown.remarkPlugins` is simply not consulted by it. The build\n // stays green, exits 0, and every diagram is gone — measured on this\n // repo's own fixture 2026-08-10: 423,794 bytes and 14 SVGs became\n // 6,625 bytes and 1. Astro prints one warning and carries on.\n //\n // So this hook asks what processor it has rather than assuming, and\n // says out loud what it did. Feature detection, not a version check:\n // `processor` does not exist in Astro 4-6's config at all, and\n // `unified`/`isUnifiedProcessor` are only exported by the Astro 7 line\n // of `@astrojs/markdown-remark`, so the two together identify the new\n // world without anyone parsing a version string.\n const markdownRemark = await import('@astrojs/markdown-remark').catch(\n () => undefined\n );\n const unified = markdownRemark?.unified;\n const isUnifiedProcessor = markdownRemark?.isUnifiedProcessor;\n const processor = (\n config?.markdown as { processor?: { name?: string } } | undefined\n )?.processor;\n\n if (!unified || !isUnifiedProcessor || processor === undefined) {\n // Astro 4-6: remark IS the Markdown pipeline, so this is all it takes.\n updateConfig({ markdown: { remarkPlugins: [plugin] } });\n } else if (isUnifiedProcessor(processor as { name: string })) {\n // The site already runs unified. Push into it rather than replacing\n // it — replacing would silently drop every other plugin they set.\n (\n processor as { options: { remarkPlugins: unknown[] } }\n ).options.remarkPlugins.push(plugin);\n } else {\n // 🔴 Something else is configured — Sätteri, or a third processor.\n //\n // We take it over, because the alternative is rendering nothing, and\n // unified is the engine this integration has always run on: a site\n // arriving from Astro 6 gets the Markdown semantics it already had.\n //\n // 🔴 Carry the whole pipeline, not just our plugin. Integrations\n // that ran before us — Starlight, most importantly — have already\n // pushed their remark and rehype plugins into `config.markdown`,\n // where the processor being replaced never looked. Neither did the\n // first version of this takeover, which rebuilt the pipeline as\n // `[plugin]` alone: Starlight's `:::note` asides are remark\n // plugins, so every aside on a Starlight site rendered as literal\n // `:::` text while the diagrams worked (issue 191, 2026-08-11).\n // The site's own gfm / smartypants / remarkRehype settings ride\n // along for the same reason — the takeover's contract is \"your\n // Markdown, plus diagrams\", never \"our Markdown instead\".\n //\n // It is announced rather than done quietly, and that is not\n // squeamishness — Astro materialises its DEFAULT processor before\n // integrations run (verified 2026-08-10: `config.markdown.processor`\n // is already `satteri` inside this hook on a config that never\n // mentioned it). So \"the site asked for Sätteri\" and \"the site asked\n // for nothing\" are indistinguishable here, and a silent swap would\n // sometimes be overruling a real choice with no way to notice.\n const md = (config?.markdown ?? {}) as {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n remarkRehype?: Record<string, unknown>;\n gfm?: boolean;\n smartypants?: boolean;\n };\n // 🔴 An integration that ran BEFORE us may have registered plugins\n // into the processor being replaced — Starlight, when it sees\n // Sätteri, pushes its aside/anchor plugins into the processor's own\n // `mdastPlugins`/`hastPlugins` rather than into `config.markdown`,\n // and those cannot be carried onto unified(). We cannot fix that\n // from here; we CAN name it and name the fix, because the silent\n // version of this was a Starlight site whose every `:::` aside\n // rendered as plain text (issue 191). Listing dgmo() before those\n // integrations makes them find the unified processor already in\n // place and join it through their own unified support.\n const opts = (\n processor as {\n options?: { mdastPlugins?: unknown[]; hastPlugins?: unknown[] };\n }\n ).options;\n const strandedCount =\n (opts?.mdastPlugins?.length ?? 0) + (opts?.hastPlugins?.length ?? 0);\n if (strandedCount > 0) {\n logger.warn(\n `The \\`${(processor as { name?: string })?.name ?? 'configured'}\\` processor being replaced already ` +\n `carries ${strandedCount} plugin(s) registered by integrations that ran before astro-dgmo ` +\n `(Starlight registers its \\`:::\\` asides this way). Those plugins CANNOT be carried over and ` +\n `their output will be missing. Fix: list dgmo() BEFORE those integrations in \\`integrations: []\\`, ` +\n `so they find the unified() processor already in place and join it instead.`\n );\n }\n const carried = {\n remarkPlugins: [...(md.remarkPlugins ?? []), plugin],\n rehypePlugins: [...(md.rehypePlugins ?? [])],\n ...(md.remarkRehype !== undefined && {\n remarkRehype: md.remarkRehype,\n }),\n ...(md.gfm !== undefined && { gfm: md.gfm }),\n ...(md.smartypants !== undefined && {\n smartypants: md.smartypants,\n }),\n };\n logger.warn(\n `astro-dgmo renders diagrams through a remark plugin, which your ` +\n `\\`${(processor as { name?: string })?.name ?? 'configured'}\\` Markdown processor does not run. ` +\n `Switching \\`markdown.processor\\` to \\`unified()\\` so diagrams render, ` +\n `carrying the ${md.remarkPlugins?.length ?? 0} remark and ` +\n `${md.rehypePlugins?.length ?? 0} rehype plugins already registered. ` +\n `To keep your own processor and control this yourself, set ` +\n `\\`markdown: { processor: unified({ remarkPlugins: [[remarkDgmo, options]] }) }\\` ` +\n `— astro-dgmo will then add itself to that processor instead of replacing it.`\n );\n updateConfig({\n markdown: {\n processor: unified(carried as Parameters<typeof unified>[0]),\n },\n });\n }\n // Inline the shared remark-dgmo client script so showcase-mode copy\n // buttons + viewBox tightening light up without users wiring scripts\n // manually. Read at config-setup time so the absolute path resolves\n // through node_modules.\n const clientJsPath = fileURLToPath(\n import.meta.resolve('remark-dgmo/client.js')\n );\n injectScript('page', readFileSync(clientJsPath, 'utf8'));\n\n // 🔴 The color-mode stylesheet, which used to be a manual `import` in\n // the consumer's own layout — and therefore was routinely missing.\n //\n // Under `colorMode: 'auto'` (the default) every fence renders TWO\n // SVGs; the rule that hides the one you are not in lives only in\n // `client.css`. A site that never imported it printed the SAME\n // diagram twice, stacked, with a green build and no warning anywhere\n // (issue 507, reported from a real Astro site 2026-08-26).\n //\n // Both this file and the README said the manual step was\n // \"unavoidable\" because `IntegrationHook` has no stylesheet API. The\n // premise is right and the conclusion was wrong: `page-ssr` imports a\n // module into every page's frontmatter, and Vite turns a CSS import\n // there into a real stylesheet. It is the route Astro's own\n // integration reference documents for exactly this. Measured on this\n // repo's fixture under Astro 7.2.0 (2026-08-26): a probe page that\n // imports nothing carried zero stylesheets before and\n // `.dgmo-dark,[data-theme=dark] .dgmo-light{display:none}` after.\n //\n // Importing it again by hand costs nothing — Vite resolves both to\n // one module.\n if (options.injectClientCss !== false) {\n injectScript('page-ssr', `import 'remark-dgmo/client.css';`);\n }\n\n // Live links, `refresh: 'render'` only (story 10.4). The base\n // client NOTICES that a referenced diagram moved; this second module is\n // what re-renders it, and it is separate because its dynamic import is\n // static-analyzable — injecting it unconditionally took this repo's own\n // fixture from 1 chunk / 7,990 gzipped bytes to 90 chunks / 634,199.\n // Lazy for the reader, not free for the site, so it is opt-in.\n if (options.liveLink?.refresh === 'render') {\n const renderJsPath = fileURLToPath(\n import.meta.resolve('remark-dgmo/client-render.js')\n );\n injectScript('page', readFileSync(renderJsPath, 'utf8'));\n }\n },\n },\n };\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAE9B,OAAO,gBAAgB;AAIvB,SAAoB,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,EAAE,KAAK,GAAG,IAAI;AAAA,YAC1C,GAAI,GAAG,gBAAgB,UAAa;AAAA,cAClC,aAAa,GAAG;AAAA,YAClB;AAAA,UACF;AACA,iBAAO;AAAA,YACL,qEACQ,WAAiC,QAAQ,YAAY,0HAE3C,GAAG,eAAe,UAAU,CAAC,eAC1C,GAAG,eAAe,UAAU,CAAC;AAAA,UAIpC;AACA,uBAAa;AAAA,YACX,UAAU;AAAA,cACR,WAAW,QAAQ,OAAwC;AAAA,YAC7D;AAAA,UACF,CAAC;AAAA,QACH;AAKA,cAAM,eAAe;AAAA,UACnB,YAAY,QAAQ,uBAAuB;AAAA,QAC7C;AACA,qBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAuBvD,YAAI,QAAQ,oBAAoB,OAAO;AACrC,uBAAa,YAAY,kCAAkC;AAAA,QAC7D;AAQA,YAAI,QAAQ,UAAU,YAAY,UAAU;AAC1C,gBAAM,eAAe;AAAA,YACnB,YAAY,QAAQ,8BAA8B;AAAA,UACpD;AACA,uBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["default"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type { AstroIntegration } from 'astro';\nimport remarkDgmo from 'remark-dgmo';\nimport type { DgmoIntegrationOptions } from './options.js';\n\nexport type { DgmoIntegrationOptions, Mode, Theme } from './options.js';\nexport { default as remarkDgmo } from 'remark-dgmo';\n\n/**\n * Astro integration that renders DGMO fenced code blocks at build time.\n *\n * @example\n * ```js\n * // astro.config.mjs\n * import dgmo from 'astro-dgmo';\n *\n * export default defineConfig({\n * integrations: [dgmo()],\n * });\n * ```\n *\n * v0.3.0 changes the rendered HTML class-name prefix from `astro-dgmo-*` to\n * `dgmo-*`. Both are emitted for one minor cycle via the shared `remark-dgmo`\n * `legacyClassNames` option, so existing user CSS keeps working until v0.4.\n *\n * v0.3.0 also defaults to `colorMode: 'auto'` (dual-render, light+dark SVGs)\n * to fix the silent dark/light-mismatch bug on Starlight and any toggle-\n * enabled Astro site. Users on single-mode sites can opt back to single-render\n * by setting `colorMode: 'light'` or `colorMode: 'dark'` in the integration\n * options.\n *\n * **CSS is automatic since v0.11.0.** The integration adds\n * `remark-dgmo/client.css` to every page itself, so a fresh install renders\n * one diagram rather than two. Opt out with `injectClientCss: false` if you\n * ship your own copy of the color-mode rules.\n */\nexport default function dgmoIntegration(\n options: DgmoIntegrationOptions = {}\n): AstroIntegration {\n // Emit BOTH new (`dgmo-*`) and legacy (`astro-dgmo-*`) class names so user\n // CSS targeting the v0.2 classes keeps working. Removed in v0.4.\n const optionsWithLegacy: DgmoIntegrationOptions = {\n ...options,\n legacyClassNames: [\n ...(options.legacyClassNames ?? []),\n 'astro-dgmo',\n 'astro-dgmo-card',\n ],\n };\n\n return {\n name: 'astro-dgmo',\n hooks: {\n async 'astro:config:setup'({\n config,\n updateConfig,\n injectScript,\n logger,\n }) {\n const plugin: [typeof remarkDgmo, DgmoIntegrationOptions] = [\n remarkDgmo,\n optionsWithLegacy,\n ];\n\n // 🔴 Astro 7 stopped running remark plugins, and does it QUIETLY.\n //\n // Sätteri replaced unified as the default Markdown processor, and\n // `markdown.remarkPlugins` is simply not consulted by it. The build\n // stays green, exits 0, and every diagram is gone — measured on this\n // repo's own fixture 2026-08-10: 423,794 bytes and 14 SVGs became\n // 6,625 bytes and 1. Astro prints one warning and carries on.\n //\n // So this hook asks what processor it has rather than assuming, and\n // says out loud what it did. Feature detection, not a version check:\n // `processor` does not exist in Astro 4-6's config at all, and\n // `unified`/`isUnifiedProcessor` are only exported by the Astro 7 line\n // of `@astrojs/markdown-remark`, so the two together identify the new\n // world without anyone parsing a version string.\n const markdownRemark = await import('@astrojs/markdown-remark').catch(\n () => undefined\n );\n const unified = markdownRemark?.unified;\n const isUnifiedProcessor = markdownRemark?.isUnifiedProcessor;\n const processor = (\n config?.markdown as { processor?: { name?: string } } | undefined\n )?.processor;\n\n if (!unified || !isUnifiedProcessor || processor === undefined) {\n // Astro 4-6: remark IS the Markdown pipeline, so this is all it takes.\n updateConfig({ markdown: { remarkPlugins: [plugin] } });\n } else if (isUnifiedProcessor(processor as { name: string })) {\n // The site already runs unified. Push into it rather than replacing\n // it — replacing would silently drop every other plugin they set.\n (\n processor as { options: { remarkPlugins: unknown[] } }\n ).options.remarkPlugins.push(plugin);\n } else {\n // 🔴 Something else is configured — Sätteri, or a third processor.\n //\n // We take it over, because the alternative is rendering nothing, and\n // unified is the engine this integration has always run on: a site\n // arriving from Astro 6 gets the Markdown semantics it already had.\n //\n // 🔴 Carry the whole pipeline, not just our plugin. Integrations\n // that ran before us — Starlight, most importantly — have already\n // pushed their remark and rehype plugins into `config.markdown`,\n // where the processor being replaced never looked. Neither did the\n // first version of this takeover, which rebuilt the pipeline as\n // `[plugin]` alone: Starlight's `:::note` asides are remark\n // plugins, so every aside on a Starlight site rendered as literal\n // `:::` text while the diagrams worked (issue 191, 2026-08-11).\n // The site's own gfm / smartypants / remarkRehype settings ride\n // along for the same reason — the takeover's contract is \"your\n // Markdown, plus diagrams\", never \"our Markdown instead\".\n //\n // It is announced rather than done quietly, and that is not\n // squeamishness — Astro materialises its DEFAULT processor before\n // integrations run (verified 2026-08-10: `config.markdown.processor`\n // is already `satteri` inside this hook on a config that never\n // mentioned it). So \"the site asked for Sätteri\" and \"the site asked\n // for nothing\" are indistinguishable here, and a silent swap would\n // sometimes be overruling a real choice with no way to notice.\n const md = (config?.markdown ?? {}) as {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n remarkRehype?: Record<string, unknown>;\n gfm?: boolean;\n smartypants?: boolean;\n };\n // 🔴 An integration that ran BEFORE us may have registered plugins\n // into the processor being replaced — Starlight, when it sees\n // Sätteri, pushes its aside/anchor plugins into the processor's own\n // `mdastPlugins`/`hastPlugins` rather than into `config.markdown`,\n // and those cannot be carried onto unified(). We cannot fix that\n // from here; we CAN name it and name the fix, because the silent\n // version of this was a Starlight site whose every `:::` aside\n // rendered as plain text (issue 191). Listing dgmo() before those\n // integrations makes them find the unified processor already in\n // place and join it through their own unified support.\n const opts = (\n processor as {\n options?: { mdastPlugins?: unknown[]; hastPlugins?: unknown[] };\n }\n ).options;\n const strandedCount =\n (opts?.mdastPlugins?.length ?? 0) +\n (opts?.hastPlugins?.length ?? 0);\n if (strandedCount > 0) {\n logger.warn(\n `The \\`${(processor as { name?: string })?.name ?? 'configured'}\\` processor being replaced already ` +\n `carries ${strandedCount} plugin(s) registered by integrations that ran before astro-dgmo ` +\n `(Starlight registers its \\`:::\\` asides this way). Those plugins CANNOT be carried over and ` +\n `their output will be missing. Fix: list dgmo() BEFORE those integrations in \\`integrations: []\\`, ` +\n `so they find the unified() processor already in place and join it instead.`\n );\n }\n const carried = {\n remarkPlugins: [...(md.remarkPlugins ?? []), plugin],\n rehypePlugins: [...(md.rehypePlugins ?? [])],\n ...(md.remarkRehype !== undefined && {\n remarkRehype: md.remarkRehype,\n }),\n ...(md.gfm !== undefined && { gfm: md.gfm }),\n ...(md.smartypants !== undefined && {\n smartypants: md.smartypants,\n }),\n };\n logger.warn(\n `astro-dgmo renders diagrams through a remark plugin, which your ` +\n `\\`${(processor as { name?: string })?.name ?? 'configured'}\\` Markdown processor does not run. ` +\n `Switching \\`markdown.processor\\` to \\`unified()\\` so diagrams render, ` +\n `carrying the ${md.remarkPlugins?.length ?? 0} remark and ` +\n `${md.rehypePlugins?.length ?? 0} rehype plugins already registered. ` +\n `To keep your own processor and control this yourself, set ` +\n `\\`markdown: { processor: unified({ remarkPlugins: [[remarkDgmo, options]] }) }\\` ` +\n `— astro-dgmo will then add itself to that processor instead of replacing it.`\n );\n updateConfig({\n markdown: {\n processor: unified(carried as Parameters<typeof unified>[0]),\n },\n });\n }\n // Inline the shared remark-dgmo client script so showcase-mode copy\n // buttons + viewBox tightening light up without users wiring scripts\n // manually. Read at config-setup time so the absolute path resolves\n // through node_modules.\n const clientJsPath = fileURLToPath(\n import.meta.resolve('remark-dgmo/client.js')\n );\n injectScript('page', readFileSync(clientJsPath, 'utf8'));\n\n // 🔴 The color-mode stylesheet, which used to be a manual `import` in\n // the consumer's own layout — and therefore was routinely missing.\n //\n // Under `colorMode: 'auto'` (the default) every fence renders TWO\n // SVGs; the rule that hides the one you are not in lives only in\n // `client.css`. A site that never imported it printed the SAME\n // diagram twice, stacked, with a green build and no warning anywhere\n // (issue 507, reported from a real Astro site 2026-08-26).\n //\n // Both this file and the README said the manual step was\n // \"unavoidable\" because `IntegrationHook` has no stylesheet API. The\n // premise is right and the conclusion was wrong: `page-ssr` imports a\n // module into every page's frontmatter, and Vite turns a CSS import\n // there into a real stylesheet. It is the route Astro's own\n // integration reference documents for exactly this. Measured on this\n // repo's fixture under Astro 7.2.0 (2026-08-26): a probe page that\n // imports nothing carried zero stylesheets before and\n // `.dgmo-dark,[data-theme=dark] .dgmo-light{display:none}` after.\n //\n // Importing it again by hand costs nothing — Vite resolves both to\n // one module.\n if (options.injectClientCss !== false) {\n injectScript('page-ssr', `import 'remark-dgmo/client.css';`);\n }\n\n // Live links, `refresh: 'render'` only (story 10.4). The base\n // client NOTICES that a referenced diagram moved; this second module is\n // what re-renders it, and it is separate because its dynamic import is\n // static-analyzable — injecting it unconditionally took this repo's own\n // fixture from 1 chunk / 7,990 gzipped bytes to 90 chunks / 634,199.\n // Lazy for the reader, not free for the site, so it is opt-in.\n if (options.liveLink?.refresh === 'render') {\n const renderJsPath = fileURLToPath(\n import.meta.resolve('remark-dgmo/client-render.js')\n );\n injectScript('page', readFileSync(renderJsPath, 'utf8'));\n }\n },\n },\n };\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAE9B,OAAO,gBAAgB;AAIvB,SAAoB,WAAXA,gBAA6B;AA8BvB,SAAR,gBACL,UAAkC,CAAC,GACjB;AAGlB,QAAM,oBAA4C;AAAA,IAChD,GAAG;AAA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C,aAAa,GAAG;AAAA,YAClB;AAAA,UACF;AACA,iBAAO;AAAA,YACL,qEACQ,WAAiC,QAAQ,YAAY,0HAE3C,GAAG,eAAe,UAAU,CAAC,eAC1C,GAAG,eAAe,UAAU,CAAC;AAAA,UAIpC;AACA,uBAAa;AAAA,YACX,UAAU;AAAA,cACR,WAAW,QAAQ,OAAwC;AAAA,YAC7D;AAAA,UACF,CAAC;AAAA,QACH;AAKA,cAAM,eAAe;AAAA,UACnB,YAAY,QAAQ,uBAAuB;AAAA,QAC7C;AACA,qBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAuBvD,YAAI,QAAQ,oBAAoB,OAAO;AACrC,uBAAa,YAAY,kCAAkC;AAAA,QAC7D;AAQA,YAAI,QAAQ,UAAU,YAAY,UAAU;AAC1C,gBAAM,eAAe;AAAA,YACnB,YAAY,QAAQ,8BAA8B;AAAA,UACpD;AACA,uBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["default"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-dgmo",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Astro integration to render DGMO diagrams from fenced code blocks at build time. Powered by @diagrammo/dgmo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Diagrammo LLC",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"check:deadcode": "knip",
|
|
63
63
|
"check:duplication": "jscpd ./src",
|
|
64
64
|
"check:deps": "depcheck --ignores=''",
|
|
65
|
-
"check:all": "pnpm check:deadcode && pnpm check:duplication && pnpm check:deps",
|
|
65
|
+
"check:all": "pnpm format:check && pnpm check:deadcode && pnpm check:duplication && pnpm check:deps",
|
|
66
66
|
"prepublishOnly": "pnpm build && pnpm test"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"remark-dgmo": ">=0.15.
|
|
80
|
+
"remark-dgmo": ">=0.15.2 <1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@astrojs/markdown-remark": "^7.2.2",
|
|
84
|
-
"@diagrammo/dgmo": ">=0.
|
|
84
|
+
"@diagrammo/dgmo": ">=0.79.0 <1",
|
|
85
85
|
"@eslint/js": "^10.0.1",
|
|
86
86
|
"@types/node": "^22.20.1",
|
|
87
87
|
"astro": "^7.2.0",
|