@diagrammo/dgmo 0.50.0 → 0.50.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.
Files changed (136) hide show
  1. package/dist/advanced.js +62 -62
  2. package/dist/auto.js +82 -82
  3. package/dist/auto.mjs +27 -20
  4. package/dist/block.js +29 -29
  5. package/dist/{charts-d3-DKUD7MQE.js → charts-d3-LR6D3D7A.js} +3 -3
  6. package/dist/{chunk-PJUGRJHJ.js → chunk-2KGXHFYK.js} +4 -4
  7. package/dist/{chunk-6X4AKWLF.js → chunk-3LH5CLP4.js} +3 -3
  8. package/dist/{chunk-YA7D2N2O.js → chunk-3NODSS6A.js} +4 -4
  9. package/dist/{chunk-DMJJ3CEQ.js → chunk-3UIKSPFB.js} +8 -3
  10. package/dist/{chunk-RV26LTUU.js → chunk-3XGZF2QJ.js} +4 -4
  11. package/dist/{chunk-I4IFRCUB.js → chunk-3Y2DRD7S.js} +2 -2
  12. package/dist/{chunk-RV6A2B5S.js → chunk-3YPY3OXD.js} +2 -2
  13. package/dist/{chunk-4S723I74.js → chunk-4MJ7M6YL.js} +5 -5
  14. package/dist/{chunk-6ZT4U37Q.js → chunk-4S52SK6G.js} +2 -2
  15. package/dist/{chunk-SGFZZAUO.js → chunk-5GJYGP5Z.js} +4 -4
  16. package/dist/{chunk-TWCLK2GA.js → chunk-5OWVC2A6.js} +3 -3
  17. package/dist/{chunk-F5UDBSJY.js → chunk-66NVRO4K.js} +4 -4
  18. package/dist/{chunk-XCLHOZAM.js → chunk-66RUL3XF.js} +3 -3
  19. package/dist/{chunk-YZLMKW4T.js → chunk-6HJBFVLO.js} +2 -2
  20. package/dist/{chunk-YB3FW24O.js → chunk-7L3R6I3U.js} +2 -2
  21. package/dist/{chunk-PLZI6KPM.js → chunk-7QKLIMRZ.js} +4 -4
  22. package/dist/{chunk-IA3FJYWR.js → chunk-7TV5Y53Y.js} +2 -2
  23. package/dist/{chunk-3TDRHT4J.js → chunk-BBGDM4NQ.js} +3 -3
  24. package/dist/{chunk-T4BRO3Z6.js → chunk-BH3UYK36.js} +2 -2
  25. package/dist/{chunk-UXOSVCLJ.js → chunk-C2CVAM3U.js} +2 -2
  26. package/dist/{chunk-UUS2GIJZ.js → chunk-DFTFPYUD.js} +5 -5
  27. package/dist/{chunk-SU2VBK4L.js → chunk-DSWVNQVS.js} +2 -2
  28. package/dist/{chunk-5JSWBPZZ.js → chunk-DZXYF2F5.js} +12 -2
  29. package/dist/{chunk-6M5PJFQG.js → chunk-EAMEADTV.js} +2 -2
  30. package/dist/{chunk-KJXIHOVL.js → chunk-FA6K3FWM.js} +3 -3
  31. package/dist/{chunk-WCUHAQKB.js → chunk-FJUNPCYI.js} +1 -1
  32. package/dist/{chunk-FB2WHOEQ.js → chunk-GKC3HILQ.js} +2 -2
  33. package/dist/{chunk-QUJGFNFN.js → chunk-HEVYAHLW.js} +2 -2
  34. package/dist/{chunk-3ZPC476N.js → chunk-HLJVEAOF.js} +3 -3
  35. package/dist/{chunk-7G2ER4CY.js → chunk-HTMN2Z6U.js} +2 -2
  36. package/dist/{chunk-OHQEMBLI.js → chunk-I2WKW7C7.js} +2 -2
  37. package/dist/{chunk-R56LASIN.js → chunk-IUMPEA64.js} +2 -2
  38. package/dist/{chunk-QDFNCATJ.js → chunk-J6K7RP6P.js} +4 -4
  39. package/dist/{chunk-PMN3Q7RJ.js → chunk-JJUOHGX2.js} +2 -2
  40. package/dist/{chunk-QFQ35BTO.js → chunk-KFZYNWWO.js} +2 -2
  41. package/dist/{chunk-ER5SCQWQ.js → chunk-KHEYDLMT.js} +2 -2
  42. package/dist/{chunk-X2NMFTG3.js → chunk-LE4MYMLI.js} +2 -2
  43. package/dist/{chunk-NFFIKVNO.js → chunk-MCZ5LBZD.js} +4 -4
  44. package/dist/{chunk-2JJ2KNPI.js → chunk-NU3XLTGP.js} +2 -2
  45. package/dist/{chunk-4BMJQFNK.js → chunk-NWED7CYO.js} +3 -3
  46. package/dist/{chunk-WWN566I7.js → chunk-OMNGQPEZ.js} +2 -2
  47. package/dist/{chunk-O76UD6VJ.js → chunk-OTQKUHRS.js} +2 -2
  48. package/dist/{chunk-5Z736BSU.js → chunk-P7CE7LXL.js} +2 -2
  49. package/dist/{chunk-CVV36CWI.js → chunk-PFHVU7UA.js} +2 -2
  50. package/dist/{chunk-FAL7NOK3.js → chunk-QJP6PG7F.js} +5 -5
  51. package/dist/{chunk-URSQLCTR.js → chunk-QROYX7TT.js} +2 -2
  52. package/dist/{chunk-FL4IOQ37.js → chunk-QXKWYZNR.js} +2 -2
  53. package/dist/{chunk-3G6TMNVF.js → chunk-RZ6YKEUJ.js} +3 -3
  54. package/dist/{chunk-A3WQVFBS.js → chunk-SQLNBA64.js} +2 -2
  55. package/dist/{chunk-S5GRONXL.js → chunk-SXRTRMEE.js} +2 -2
  56. package/dist/{chunk-GPWHQ5FJ.js → chunk-T4VOVZT5.js} +2 -2
  57. package/dist/{chunk-JZNMXEIV.js → chunk-TN35C5KM.js} +2 -2
  58. package/dist/{chunk-O4VUFXIH.js → chunk-VBYSIOOY.js} +2 -2
  59. package/dist/{chunk-2QYTMIRR.js → chunk-VDOOQZUD.js} +2 -2
  60. package/dist/{chunk-XMVQ5F4M.js → chunk-VUJGMJE6.js} +2 -2
  61. package/dist/{chunk-ASS5YYIZ.js → chunk-VVW3F3MD.js} +4 -4
  62. package/dist/{chunk-JFYIP7XU.js → chunk-VVZRV54S.js} +24 -24
  63. package/dist/{chunk-7RB5Q6MB.js → chunk-WW32K72E.js} +5 -5
  64. package/dist/{chunk-EJTKV7CY.js → chunk-X6EZPSW6.js} +4 -4
  65. package/dist/{chunk-OTP5KVLO.js → chunk-XJLKLU4D.js} +2 -2
  66. package/dist/{chunk-GROQGHCT.js → chunk-Y4RNXEAO.js} +9 -17
  67. package/dist/{chunk-L2ZTFHAY.js → chunk-YIA4LEX4.js} +15 -7
  68. package/dist/{chunk-NISQC5KW.js → chunk-ZAD4HV2G.js} +62 -62
  69. package/dist/cli.cjs +96 -96
  70. package/dist/{dgmo-router-QOMFCOOV.js → dgmo-router-YTU3ENAX.js} +25 -25
  71. package/dist/{dimensions-P5FSX2QN.js → dimensions-OTBKC5M6.js} +4 -4
  72. package/dist/element.js +42 -42
  73. package/dist/element.mjs +27 -20
  74. package/dist/index.js +29 -29
  75. package/dist/{layout-T3OZU5QW.js → layout-7MZ5NF2N.js} +3 -3
  76. package/dist/{layout-WZHNDT2O.js → layout-FWODLIMP.js} +3 -3
  77. package/dist/{layout-VYELEAW7.js → layout-J36454XU.js} +3 -3
  78. package/dist/{layout-TJIWF7EM.js → layout-LD6XTLD6.js} +3 -3
  79. package/dist/{parser-ZSOWUBML.js → parser-36HVKU5U.js} +3 -3
  80. package/dist/{parser-QYYM4QVW.js → parser-4NO6VZ6S.js} +3 -3
  81. package/dist/{parser-DOKMZXVZ.js → parser-4WQQQXCG.js} +3 -3
  82. package/dist/{parser-O4QFCUW7.js → parser-5OXGPNBF.js} +3 -3
  83. package/dist/{parser-ZTBATMLX.js → parser-AGVYTQXV.js} +3 -3
  84. package/dist/{parser-D3QT6GWN.js → parser-AXKBDGNO.js} +3 -3
  85. package/dist/{parser-FMPCVFRK.js → parser-CVMEDULU.js} +3 -3
  86. package/dist/{parser-C2HF2C2E.js → parser-D5VILGN2.js} +3 -3
  87. package/dist/{parser-KUQWRPIT.js → parser-H3XEPFPV.js} +3 -3
  88. package/dist/{parser-YLKYBRIT.js → parser-IJBMRXMC.js} +3 -3
  89. package/dist/{parser-UQE5OWZI.js → parser-JJR52VAT.js} +3 -3
  90. package/dist/{parser-4P36TUVD.js → parser-K3XXLMUW.js} +3 -3
  91. package/dist/{parser-45DENHFZ.js → parser-KCR2WS3V.js} +3 -3
  92. package/dist/{parser-5AURY4A6.js → parser-MPCE5JBG.js} +3 -3
  93. package/dist/{parser-Q4QKCIWQ.js → parser-MTOMTWTD.js} +3 -3
  94. package/dist/{parser-RZMQP7MM.js → parser-O4HIUN6G.js} +3 -3
  95. package/dist/{parser-PGMQDD4G.js → parser-PSA4UBSP.js} +3 -3
  96. package/dist/{parser-I2UIJKVQ.js → parser-RV4M6AS2.js} +3 -3
  97. package/dist/{parser-QTOB4KFL.js → parser-TGQZJ5OT.js} +3 -3
  98. package/dist/{parser-SOUJOEYI.js → parser-TXND652E.js} +3 -3
  99. package/dist/{parser-A2BEFMGK.js → parser-VKOJM7KS.js} +3 -3
  100. package/dist/{parser-D5637H5H.js → parser-W4PQUGX3.js} +3 -3
  101. package/dist/pert.d.ts +8 -0
  102. package/dist/{renderer-BSW7SRIZ.js → renderer-2AZ5HJFK.js} +3 -3
  103. package/dist/{renderer-BZSBPTZJ.js → renderer-2QPMJ2DA.js} +5 -5
  104. package/dist/{renderer-KY4KQBTF.js → renderer-45PSOL3E.js} +4 -4
  105. package/dist/{renderer-FZUKFUNZ.js → renderer-5DSEWF74.js} +4 -4
  106. package/dist/{renderer-TQMZGDAX.js → renderer-6OKF44KS.js} +5 -5
  107. package/dist/{renderer-67NPCBIS.js → renderer-7SD6MSBS.js} +5 -5
  108. package/dist/{renderer-ICJN2SA2.js → renderer-A5VE5BCI.js} +4 -4
  109. package/dist/{renderer-Q6ZKPLS6.js → renderer-AUW2BE6G.js} +5 -5
  110. package/dist/{renderer-35HSIDMZ.js → renderer-B5TBNZJE.js} +4 -4
  111. package/dist/{renderer-INEXO7B6.js → renderer-BSR2O2H6.js} +5 -5
  112. package/dist/{renderer-CXUC4KAD.js → renderer-CYB4LK3G.js} +5 -5
  113. package/dist/{renderer-O4JKUGKO.js → renderer-FF24KZCI.js} +4 -4
  114. package/dist/{renderer-BY533UWU.js → renderer-FPE3J5VZ.js} +5 -5
  115. package/dist/{renderer-TKG6LS4U.js → renderer-FYSVXL7M.js} +6 -6
  116. package/dist/{renderer-GO3FE3RA.js → renderer-HDCCZURL.js} +4 -4
  117. package/dist/{renderer-6GHYK7DX.js → renderer-JCCHNECZ.js} +4 -4
  118. package/dist/{renderer-OOGFODWP.js → renderer-KS7YZJE2.js} +6 -6
  119. package/dist/{renderer-KDYCFRBX.js → renderer-NGXZTRK6.js} +4 -4
  120. package/dist/{renderer-LBN65V45.js → renderer-ODUUOPVT.js} +4 -4
  121. package/dist/{renderer-G2NLGNKF.js → renderer-PJM35LJN.js} +2 -2
  122. package/dist/{renderer-SZQ326M5.js → renderer-PPIHO5FI.js} +5 -5
  123. package/dist/{renderer-7SWMIFMM.js → renderer-PSMMZCKH.js} +4 -4
  124. package/dist/{renderer-MGBWOCXG.js → renderer-QAOBLRXV.js} +6 -6
  125. package/dist/{renderer-HPGR6USK.js → renderer-R2WNIC2C.js} +4 -4
  126. package/dist/{renderer-6RNGHC5Z.js → renderer-SBS3YWU5.js} +4 -4
  127. package/dist/{renderer-BBCEFILK.js → renderer-UYMQQCJK.js} +5 -5
  128. package/dist/{renderer-radial-JELMHQ24.js → renderer-radial-F7X5F2VU.js} +5 -5
  129. package/gallery/fixtures/countdown.dgmo +3 -3
  130. package/package.json +1 -1
  131. package/dist/advanced.d.ts +0 -6569
  132. package/dist/auto.d.ts +0 -54
  133. package/dist/block.d.ts +0 -123
  134. package/dist/element.d.ts +0 -62
  135. package/dist/index.d.ts +0 -166
  136. package/dist/themes-1-CuKpeH.d.ts +0 -908
package/dist/auto.d.ts DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * Shared browser-embed helpers for the `@diagrammo/dgmo` client-side
3
- * drop-ins (`./auto` script-tag renderer and `./element` custom element).
4
- *
5
- * These are the SVG sanitizer, theme resolver, the standard-block DOM
6
- * assembler (canonical chrome from `src/embed` — BL-114), the error card,
7
- * aria-label derivation, style injection, and share-URL builder — factored
8
- * out of `auto/index.ts` so the two entries share one implementation rather
9
- * than diverging copies. The `auto` entry's public `window.dgmo` surface is
10
- * unaffected; it imports from here.
11
- */
12
- declare const VERSION: string;
13
-
14
- type ThemePreference = 'auto' | 'light' | 'dark' | 'transparent';
15
- declare function resolveTheme(theme: ThemePreference | undefined): 'light' | 'dark' | 'transparent';
16
-
17
- /**
18
- * `@diagrammo/dgmo/auto` — IIFE-distributed auto-renderer for static HTML.
19
- *
20
- * Drop a `<script src="…/auto.js">` on any page; on `DOMContentLoaded`
21
- * this module scans for `.dgmo, .language-dgmo`, runs `render()`, and
22
- * replaces each match with the standard DGMO embed block (BL-114,
23
- * `figure.dgmo.dgmo-rendered`) — the diagram plus a hover-reveal icon
24
- * toolbar with view-source, Copy, and "Open in editor" actions.
25
- *
26
- * Public API: frozen `window.dgmo` and alias `window.diagrammo` with
27
- * `{ initialize, run, version }`. Configuration is read from the
28
- * bundle's own `<script data-config='{…}'>` (JSON with strict
29
- * allowlist) or via `dgmo.initialize(opts)` for `data-auto="false"`
30
- * embedders.
31
- */
32
-
33
- interface AutoConfig {
34
- theme?: 'auto' | 'light' | 'dark' | 'transparent';
35
- palette?: string;
36
- showSource?: boolean;
37
- showEditorLink?: boolean;
38
- }
39
- interface RunOptions {
40
- nodes?: Element[] | NodeListOf<Element>;
41
- }
42
-
43
- declare function findScriptTag(): HTMLScriptElement | null;
44
- declare function parseConfig(raw: string | null | undefined): Partial<AutoConfig>;
45
- declare function selectTargets(root?: ParentNode): Element[];
46
- declare function initialize(opts?: AutoConfig): void;
47
- declare function run(opts?: RunOptions): Promise<void>;
48
- declare const api: Readonly<{
49
- initialize: typeof initialize;
50
- run: typeof run;
51
- version: string;
52
- }>;
53
-
54
- export { type AutoConfig, type RunOptions, VERSION, api as default, findScriptTag, initialize, parseConfig, resolveTheme, run, selectTargets };
package/dist/block.d.ts DELETED
@@ -1,123 +0,0 @@
1
- /**
2
- * Canonical stylesheet for the standard DGMO embed block (BL-114).
3
- *
4
- * Shipped two ways: `dist/block.css` (extracted at build time by
5
- * tsup.config.ts, same regex mechanism as auto.css) for `<link>`/import
6
- * consumers, and the `BLOCK_CSS` string export for embedders that inject a
7
- * `<style>` tag.
8
- *
9
- * Dark mode keys off `[data-theme="dark"]`. Hosts with a different signal
10
- * (`html.dark`, `body.theme-dark`) rewrite the selector at their build step —
11
- * fumadocs-dgmo/nextra-dgmo's build-css.mjs is the reference adapter.
12
- *
13
- * The `.dgmo-tok-*` role colors mirror LIGHT_ROLE_STYLES (light) and
14
- * NORD_ROLE_STYLES (dark) from editor/highlight-api.ts. A parity test
15
- * (tests/block.test.ts) guards against drift — update both when either
16
- * changes.
17
- *
18
- * IMPORTANT: keep this a single pure template literal — the build extracts it
19
- * with a regex, so no interpolation or computed values.
20
- */
21
- declare const BLOCK_CSS: string;
22
-
23
- /**
24
- * Standard DGMO embed block (BL-114) — the ONE canonical
25
- * "diagram + source chrome" HTML builder shared by every embed surface:
26
- * remark-dgmo (and through it the astro/docusaurus/fumadocs/nextra/vitepress
27
- * wrappers), the `/auto` script-tag drop-in, `<dgmo-diagram>`, dgmo-mcp HTML
28
- * reports, the marketing site, and the Obsidian plugin.
29
- *
30
- * Chrome contract (user-approved 2026-07-05): the diagram is the star. A slim
31
- * icon toolbar sits in a reserved row below the SVG, invisible until the
32
- * block is hovered/focused or the source is open. Four wordless icon
33
- * buttons — `</>` toggles the hidden source panel, expand (full-screen),
34
- * copy, open-in-editor. No disclosure triangle, no text labels. The toolbar
35
- * IS the <summary> of a native <details>, so show/hide works with zero
36
- * JavaScript; copy and expand need a small delegated click handler
37
- * (remark-dgmo's `bindDgmo` is the reference — expand's lightbox helper is
38
- * mirrored across every client surface, same as copy).
39
- *
40
- * Markup vocabulary: `figure.dgmo` (`--diagram`/`--showcase`/`--error`),
41
- * `.dgmo-light`/`.dgmo-dark` (dual color-mode) or `.dgmo-svg` (single),
42
- * `details.dgmo-source-wrap > summary.dgmo-toolbar`, `.dgmo-source-inner`,
43
- * `pre.dgmo-pre > span.dgmo-code` with `.dgmo-tok-<role>` token spans. While
44
- * the source is open the wrapper gets one shared frame (`:has()` rule) so
45
- * diagram + code read as a single unit. No visible caption — `title` becomes
46
- * the wrapper's aria-label. Styles ship as `BLOCK_CSS` / `dist/block.css`.
47
- */
48
-
49
- /** Default hosted editor used by "Open in editor" links. */
50
- declare const EDITOR_BASE_URL = "https://online.diagrammo.app";
51
- type BlockMode = 'diagram' | 'showcase';
52
- /**
53
- * Color-mode strategy for the emitted SVG(s).
54
- * - `auto` — render twice (light + dark) and let CSS flip visibility.
55
- * - `light` / `dark` / `transparent` — single render with that theme.
56
- */
57
- type BlockColorMode = 'auto' | 'light' | 'dark' | 'transparent';
58
- interface DgmoBlockOptions {
59
- /** `diagram` (default): SVG only. `showcase`: SVG + source chrome. */
60
- mode?: BlockMode;
61
- /** Palette name. Default `slate`; unknown names warn + fall back. */
62
- palette?: string;
63
- /** Default `auto` (dual light/dark render). */
64
- colorMode?: BlockColorMode;
65
- /** Default: true in showcase mode, false in diagram mode. */
66
- showSource?: boolean;
67
- /** Default: true in showcase mode, false in diagram mode. */
68
- showCopy?: boolean;
69
- /**
70
- * Show the expand (full-screen) toolbar button. Default: true in showcase
71
- * mode, false in diagram mode. Needs the client lightbox handler to do
72
- * anything (mirrored across surfaces); markup-only surfaces can omit it.
73
- */
74
- showExpand?: boolean;
75
- /** Default: true in showcase mode, false in diagram mode. */
76
- showOpenInEditor?: boolean;
77
- /** Base URL for the open-in-editor link. Default: online.diagrammo.app. */
78
- editorBaseUrl?: string;
79
- /** Outer wrapper element. Default `figure`. */
80
- wrapper?: 'figure' | 'div';
81
- /** Base class for the wrapper (styling hook). Default `dgmo`. */
82
- className?: string;
83
- /** Extra classes appended to every emitted wrapper (compat shims). */
84
- legacyClassNames?: string[];
85
- /**
86
- * Accessible name for the block (`aria-label` on the wrapper). NOT rendered
87
- * visually — the chart's visible title belongs in the DGMO source itself.
88
- */
89
- title?: string;
90
- /** Receives palette-fallback warnings. Default: console.warn. */
91
- onWarn?: (message: string) => void;
92
- }
93
- interface DgmoBlockResult {
94
- html: string;
95
- diagnostics: Array<{
96
- message: string;
97
- line?: number;
98
- severity?: string;
99
- }>;
100
- }
101
- /**
102
- * Render one ```dgmo source block to the standard embed HTML. Async because
103
- * it runs the full dgmo render pipeline (once per color mode).
104
- *
105
- * Render errors are NOT caught here — callers decide between throwing,
106
- * `errorBlockHtml()`, or their own fallback.
107
- */
108
- declare function renderDgmoBlock(source: string, options?: DgmoBlockOptions): Promise<DgmoBlockResult>;
109
- /**
110
- * Assemble the standard block around already-rendered SVG markup. Exposed for
111
- * surfaces that render through their own pipeline (e.g. dgmo-mcp's
112
- * renderPipeline) but must emit the canonical chrome. `svgsHtml` must be the
113
- * `.dgmo-light`+`.dgmo-dark` (or `.dgmo-svg`) wrapper divs.
114
- */
115
- declare function buildDgmoBlockHtml(source: string, svgsHtml: string, options?: DgmoBlockOptions): string;
116
- /**
117
- * Standard error card for a block that failed to parse/render. Same shape on
118
- * every surface: `.dgmo--error` with `role="alert"`, message + offending
119
- * source.
120
- */
121
- declare function errorBlockHtml(err: unknown, source: string, options?: Pick<DgmoBlockOptions, 'className' | 'legacyClassNames'>): string;
122
-
123
- export { BLOCK_CSS, type BlockColorMode, type BlockMode, type DgmoBlockOptions, type DgmoBlockResult, EDITOR_BASE_URL, buildDgmoBlockHtml, errorBlockHtml, renderDgmoBlock };
package/dist/element.d.ts DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * `@diagrammo/dgmo/element` — the universal `<dgmo-diagram>` custom element.
3
- *
4
- * A mermaid-style, framework-agnostic client-side web component. Drop the
5
- * IIFE script (`dist/element.js`) on ANY page — Hugo, Jekyll, MkDocs,
6
- * VitePress, plain HTML — and author diagrams as:
7
- *
8
- * ```html
9
- * <script src="https://unpkg.com/@diagrammo/dgmo/dist/element.js"></script>
10
- * <dgmo-diagram palette="nord">
11
- * flowchart
12
- * [Start] -> [Done]
13
- * </dgmo-diagram>
14
- * ```
15
- *
16
- * The element reads its DGMO source (a nested `<script type="text/dgmo">`,
17
- * a `<pre>`, or its own text content — de-indented), calls the isomorphic
18
- * `render()`, sanitizes the SVG, and injects it. Attributes: `palette`,
19
- * `theme`/`color-mode`, `mode` (diagram|showcase), `editor-base`,
20
- * `map-data-base`.
21
- *
22
- * DOM strategy — **light DOM** (not shadow DOM). Rationale: the rendered
23
- * SVG, source panel, and syntax-highlight token classes are all styled by
24
- * the shared `auto.css` (injected once via `ensureStyles()`). Cloning that
25
- * whole stylesheet into every shadow root would be heavy and would break
26
- * the `.dgmo-tok-*` highlight hooks; the CSS is already namespaced under
27
- * `.dgmo-*` so collision risk is low. See the CLAUDE.md embed notes.
28
- *
29
- * Map-data seam — the base bundle never statically imports the ~380 KB geo
30
- * JSON. Only when a diagram's first token is `map` does the element
31
- * lazy-`fetch()` the map assets from `map-data-base` (default: the pinned
32
- * unpkg `dist/map-data/` path) and inject them as `render({ mapData })`.
33
- * Fetched data is cached across every element on the page. Non-map diagrams
34
- * trigger ZERO extra network requests.
35
- */
36
-
37
- declare class DgmoDiagram extends HTMLElement {
38
- static get observedAttributes(): readonly string[];
39
- /** DGMO source, captured from the original children ONCE before the first
40
- * render replaces them. */
41
- private source;
42
- /** Monotonic render token — a late-resolving render/fetch whose token is
43
- * stale (superseded by a newer attribute-driven render) is discarded. */
44
- private renderToken;
45
- private container;
46
- connectedCallback(): void;
47
- attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
48
- private readSource;
49
- private themePreference;
50
- private palette;
51
- private editorBase;
52
- private mapDataBase;
53
- private isShowcase;
54
- private mount;
55
- private showError;
56
- private rerender;
57
- }
58
- /** Idempotently define `<dgmo-diagram>`. Safe to call multiple times and in
59
- * SSR/no-DOM contexts (no-ops when `customElements` is unavailable). */
60
- declare function defineDgmoDiagram(): void;
61
-
62
- export { DgmoDiagram, DgmoDiagram as default, defineDgmoDiagram };
package/dist/index.d.ts DELETED
@@ -1,166 +0,0 @@
1
- import { ab as DiagnosticSpec, a as PaletteConfig, J as Theme, C as CompactViewState, D as DgmoError } from './themes-1-CuKpeH.js';
2
- export { f as ChartTypeMeta, h as DgmoSeverity, ac as DiagnosticParams, ad as EmitOptions, j as Gazetteer, k as GazetteerEntry, l as MapCompletionOptions, M as MapData, o as MapLocationMatch, p as MapPlaceCompletion, s as MapRegionCompletion, P as PaletteColors, w as RegionName, x as RegionNames, N as chartTypes, O as completeMapPlaces, Q as completeMapRegions, ae as emit, X as formatDgmoError, _ as getPalette, a4 as palettes, af as resolvePaletteOrFallback, a8 as searchMapLocations, aa as themes, a5 as validate } from './themes-1-CuKpeH.js';
3
-
4
- declare function getMinDimensions(content: string): {
5
- width: number;
6
- height: number;
7
- };
8
-
9
- /**
10
- * Make an SVG produced by `@diagrammo/dgmo`'s static `render()` suitable for
11
- * responsive inline embedding in any host (Obsidian, remark/markdown, web
12
- * pages):
13
- *
14
- * - dgmo renders diagrams inside a fixed export canvas (e.g.
15
- * `viewBox="0 0 1200 800"`), with content often occupying only a fraction
16
- * of it. We compute a tight content bounding box from element coordinates
17
- * and set the root `viewBox` to bbox+padding, so the diagram's intrinsic
18
- * aspect ratio matches its CONTENT — no dead space above/below or beside it.
19
- * - Ensure the root `<svg>` has a `viewBox` so it scales responsively.
20
- * - Strip fixed `width="N"` / `height="N"` so CSS (e.g. `width:100%;
21
- * height:auto`, or an aspect-ratio derived from the tight viewBox) controls
22
- * sizing.
23
- * - The root inline `background:` (the theme's opaque `palette.bg`) is
24
- * PRESERVED: every chart type now carries its own opaque background so
25
- * diagrams render consistently across hosts and color modes rather than
26
- * inheriting an arbitrary host page background.
27
- *
28
- * This is intentionally a string transform, not a DOM `getBBox()` step: dgmo
29
- * can dual-render light/dark SVGs where one is hidden by color-mode CSS, and
30
- * `getBBox()` returns 0 for the hidden copy. Parsing coordinates from the
31
- * markup measures both copies reliably and works server-side (Node).
32
- */
33
- declare function normalizeSvgForEmbed(input: string): string;
34
- /**
35
- * Parse the content bounding box of a normalized embed SVG, if one can be
36
- * derived. Returns `null` when no usable coordinates are found (e.g. an empty
37
- * diagram). Useful for hosts that want to set an explicit `aspect-ratio` from
38
- * the tight viewBox.
39
- */
40
- declare function getEmbedSvgViewBox(svg: string): {
41
- x: number;
42
- y: number;
43
- width: number;
44
- height: number;
45
- } | null;
46
-
47
- interface MountD3Opts {
48
- theme?: 'light' | 'dark' | 'transparent';
49
- palette?: string;
50
- /** Forwarded to the interaction adapter: source-line navigation on click. */
51
- onNavigate?: (line: number) => void;
52
- mutedColor?: string;
53
- surface?: string;
54
- text?: string;
55
- }
56
- interface MountedD3Chart {
57
- /** Re-render with new content and/or theme/palette; re-attaches interactions. */
58
- update: (content: string, opts?: Partial<MountD3Opts>) => Promise<void>;
59
- /** Emphasize the chart element on the given source line (editor cursor sync);
60
- * pass null to clear. */
61
- highlight: (line: number | null) => void;
62
- /** Tear down listeners + overlays and clear the container. */
63
- destroy: () => void;
64
- }
65
- declare function mountD3DataChart(container: HTMLElement, content: string, opts?: MountD3Opts): MountedD3Chart;
66
-
67
- interface DataChartInteractionOpts {
68
- onNavigate?: (line: number) => void;
69
- mutedColor?: string;
70
- surface?: string;
71
- text?: string;
72
- }
73
- interface DataChartController {
74
- /** Remove all listeners + overlays. */
75
- destroy: () => void;
76
- /** Emphasize the chart element(s) on the given source line (editor cursor
77
- * sync); pass null to clear. No-op while the pointer is actively hovering. */
78
- highlight: (line: number | null) => void;
79
- }
80
- declare function attachDataChartInteractions(svg: SVGSVGElement, opts?: DataChartInteractionOpts): DataChartController;
81
-
82
- /** All data-chart types the hand-built renderers currently cover. */
83
- declare const D3_DATA_CHART_TYPES: Set<string>;
84
- declare function supportsD3DataChart(type: string): boolean;
85
-
86
- /**
87
- * The full diagnostic catalog, sorted by code. Every coded diagnostic
88
- * dgmo can emit — its severity, owning chart type, canonical message,
89
- * fix hint, and a triggering example. This is the enumerable source of
90
- * truth for the CLI `diagnostics` subcommand, the console error-review
91
- * surface, MCP, and the language-spec catalog.
92
- */
93
- declare function listDiagnosticCodes(): DiagnosticSpec[];
94
- /** Look up a single spec by its code, or `undefined` if not cataloged. */
95
- declare function getDiagnosticSpec(code: string): DiagnosticSpec | undefined;
96
-
97
- interface RenderOptions {
98
- theme?: Theme;
99
- /**
100
- * A `PaletteConfig` (e.g. `palettes.catppuccin`) or a palette id string
101
- * (e.g. `'catppuccin'`). Unknown ids fall back to the default palette.
102
- */
103
- palette?: PaletteConfig | string;
104
- /**
105
- * How to handle parse errors:
106
- * 'svg' — render an inline error SVG (default)
107
- * 'silent' — return empty svg + diagnostics; caller handles UI
108
- * 'throw' — throw an Error with the diagnostics
109
- */
110
- onError?: 'svg' | 'silent' | 'throw';
111
- /**
112
- * Pre-applied interactive view state — collapsed sections/columns,
113
- * active swimlane tag-group, etc. Used to render a specific view
114
- * non-interactively (server-side render, share-link decode).
115
- */
116
- viewState?: CompactViewState;
117
- }
118
- interface RenderResult {
119
- svg: string;
120
- diagnostics: DgmoError[];
121
- }
122
- /**
123
- * Render DGMO source to an SVG string.
124
- *
125
- * @example
126
- * ```ts
127
- * import { render, palettes, themes } from '@diagrammo/dgmo';
128
- *
129
- * const { svg } = await render(text, {
130
- * palette: palettes.catppuccin,
131
- * theme: themes.dark,
132
- * });
133
- * document.getElementById('chart').innerHTML = svg;
134
- * ```
135
- */
136
- declare function render(text: string, options?: RenderOptions): Promise<RenderResult>;
137
-
138
- interface EncodeDiagramUrlOptions {
139
- baseUrl?: string;
140
- palette?: PaletteConfig;
141
- theme?: Theme;
142
- filename?: string;
143
- /**
144
- * Initial view state to embed in the URL — re-applied when the link is
145
- * decoded so recipients open the diagram in the same configuration.
146
- */
147
- viewState?: CompactViewState;
148
- }
149
- /**
150
- * Encode DGMO text into a shareable URL. Returns null if the compressed
151
- * payload exceeds the 8 KB URL limit.
152
- */
153
- declare function encodeDiagramUrl(text: string, options?: EncodeDiagramUrlOptions): string | null;
154
- interface DecodedDiagramUrl {
155
- text: string;
156
- palette?: PaletteConfig;
157
- theme?: Theme;
158
- filename?: string;
159
- }
160
- /**
161
- * Decode a share URL back into DGMO text plus optional palette/theme/filename.
162
- * Returns null if the URL contains no valid DGMO payload.
163
- */
164
- declare function decodeDiagramUrl(url: string): DecodedDiagramUrl | null;
165
-
166
- export { CompactViewState, D3_DATA_CHART_TYPES, type DataChartInteractionOpts, type DecodedDiagramUrl, DgmoError, DiagnosticSpec, type EncodeDiagramUrlOptions, type MountD3Opts, type MountedD3Chart, PaletteConfig, type RenderOptions, type RenderResult, Theme, attachDataChartInteractions, decodeDiagramUrl, encodeDiagramUrl, getDiagnosticSpec, getEmbedSvgViewBox, getMinDimensions, listDiagnosticCodes, mountD3DataChart, normalizeSvgForEmbed, render, supportsD3DataChart };