astro-dgmo 0.8.0 → 0.9.1

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 CHANGED
@@ -104,7 +104,7 @@ A -> B
104
104
 
105
105
  See the [`remark-dgmo` README](https://github.com/diagrammo/remark-dgmo) for the full option matrix.
106
106
 
107
- ## Cloud references (opt-in)
107
+ ## Live links (on by default)
108
108
 
109
109
  A fence can name a published [Diagrammo Cloud](https://diagrammo.app) diagram
110
110
  instead of carrying its own source, so the page stops going stale the day it is
@@ -112,15 +112,23 @@ written:
112
112
 
113
113
  ````md
114
114
  ```dgmo
115
- cloud dgm_01HQ3RSTUV
115
+ live-link dgm_01HQ3RSTUV
116
116
  ```
117
117
  ````
118
118
 
119
+ No configuration needed — this resolves out of the box. To stop your build
120
+ fetching anything:
121
+
119
122
  ```js
120
123
  // astro.config.mjs
121
- integrations: [dgmo({ references: { enabled: true } })];
124
+ integrations: [dgmo({ liveLink: { enabled: false } })];
122
125
  ```
123
126
 
127
+ Switched off, the fence renders a small card naming the diagram and linking
128
+ through to it, plus a hover-revealed *"Show this diagram here"* link to the
129
+ guide, and the build warns. See the
130
+ [live links guide](https://diagrammo.app/docs/live-links/).
131
+
124
132
  The build resolves it, renders it exactly like any other block, and writes what
125
133
  it fetched to `.dgmo/references/<id>.json` — **commit that directory.** It is
126
134
  what makes your build reproducible, offline-capable, and independent of our
@@ -142,11 +150,11 @@ gzipped and 88 chunks / 634 KB**. Lazy for your readers; not free for your
142
150
  Opt in if your diagrams change far more often than your site rebuilds:
143
151
 
144
152
  ```js
145
- integrations: [dgmo({ references: { enabled: true, refresh: 'render' } })];
153
+ integrations: [dgmo({ liveLink: { refresh: 'render' } })];
146
154
  ```
147
155
 
148
156
  The full behaviour, including what each kind of failure does to your build, is in
149
- the [`remark-dgmo` README](https://github.com/diagrammo/remark-dgmo#cloud-references-opt-in).
157
+ the [`remark-dgmo` README](https://github.com/diagrammo/remark-dgmo#live-links-on-by-default).
150
158
 
151
159
  ## Working reference site
152
160
 
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ function dgmoIntegration(options = {}) {
25
25
  import.meta.resolve("remark-dgmo/client.js")
26
26
  );
27
27
  injectScript("page", readFileSync(clientJsPath, "utf8"));
28
- if (options.references?.refresh === "render") {
28
+ if (options.liveLink?.refresh === "render") {
29
29
  const renderJsPath = fileURLToPath(
30
30
  import.meta.resolve("remark-dgmo/client-render.js")
31
31
  );
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:** Astro 6's IntegrationHook has no programmatic stylesheet\n * injection — only `injectScript`. You must import the color-mode stylesheet\n * yourself in a global layout (e.g. `src/layouts/Base.astro`):\n *\n * import 'remark-dgmo/client.css';\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 'astro:config:setup'({ updateConfig, injectScript }) {\n updateConfig({\n markdown: {\n remarkPlugins: [[remarkDgmo, optionsWithLegacy]],\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 // Cloud references, `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.references?.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;AA+BvB,SAAR,gBACL,UAAkC,CAAC,GACjB;AAGlB,QAAM,oBAA4C;AAAA,IAChD,GAAG;AAAA,IACH,kBAAkB;AAAA,MAChB,GAAI,QAAQ,oBAAoB,CAAC;AAAA,MACjC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,qBAAqB,EAAE,cAAc,aAAa,GAAG;AACnD,qBAAa;AAAA,UACX,UAAU;AAAA,YACR,eAAe,CAAC,CAAC,YAAY,iBAAiB,CAAC;AAAA,UACjD;AAAA,QACF,CAAC;AAKD,cAAM,eAAe;AAAA,UACnB,YAAY,QAAQ,uBAAuB;AAAA,QAC7C;AACA,qBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAQvD,YAAI,QAAQ,YAAY,YAAY,UAAU;AAC5C,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:** Astro 6's IntegrationHook has no programmatic stylesheet\n * injection — only `injectScript`. You must import the color-mode stylesheet\n * yourself in a global layout (e.g. `src/layouts/Base.astro`):\n *\n * import 'remark-dgmo/client.css';\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 'astro:config:setup'({ updateConfig, injectScript }) {\n updateConfig({\n markdown: {\n remarkPlugins: [[remarkDgmo, optionsWithLegacy]],\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 // 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;AA+BvB,SAAR,gBACL,UAAkC,CAAC,GACjB;AAGlB,QAAM,oBAA4C;AAAA,IAChD,GAAG;AAAA,IACH,kBAAkB;AAAA,MAChB,GAAI,QAAQ,oBAAoB,CAAC;AAAA,MACjC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,qBAAqB,EAAE,cAAc,aAAa,GAAG;AACnD,qBAAa;AAAA,UACX,UAAU;AAAA,YACR,eAAe,CAAC,CAAC,YAAY,iBAAiB,CAAC;AAAA,UACjD;AAAA,QACF,CAAC;AAKD,cAAM,eAAe;AAAA,UACnB,YAAY,QAAQ,uBAAuB;AAAA,QAC7C;AACA,qBAAa,QAAQ,aAAa,cAAc,MAAM,CAAC;AAQvD,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.8.0",
3
+ "version": "0.9.1",
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
  "repository": {
@@ -65,14 +65,14 @@
65
65
  "prepublishOnly": "pnpm build && pnpm test"
66
66
  },
67
67
  "peerDependencies": {
68
- "@diagrammo/dgmo": ">=0.57.0 <1",
68
+ "@diagrammo/dgmo": ">=0.60.0 <1",
69
69
  "astro": "^4.0.0 || ^5.0.0 || ^6.0.0"
70
70
  },
71
71
  "dependencies": {
72
- "remark-dgmo": "^0.11.0"
72
+ "remark-dgmo": "^0.14.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@diagrammo/dgmo": "^0.57.0",
75
+ "@diagrammo/dgmo": "^0.60.0",
76
76
  "@eslint/js": "^10.0.1",
77
77
  "@types/node": "^22.10.0",
78
78
  "astro": "^6.1.10",