@diagrammo/dgmo 0.50.1 → 0.50.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/advanced.d.ts +6578 -0
- package/dist/advanced.js +6 -6
- package/dist/auto.d.ts +54 -0
- package/dist/auto.js +103 -103
- package/dist/auto.mjs +99 -8
- package/dist/block.d.ts +130 -0
- package/dist/block.js +13 -7
- package/dist/{charts-d3-LR6D3D7A.js → charts-d3-MUW3LTML.js} +3 -3
- package/dist/{chunk-7PQYTZMA.js → chunk-5WFIYXQ6.js} +5 -5
- package/dist/{chunk-YIA4LEX4.js → chunk-DN66GPY5.js} +74 -3
- package/dist/{chunk-VVZRV54S.js → chunk-KQ57MHRO.js} +2 -2
- package/dist/{chunk-4S52SK6G.js → chunk-QJJZSROI.js} +10 -3
- package/dist/{chunk-ZAD4HV2G.js → chunk-SVTI362O.js} +9 -9
- package/dist/{chunk-Y4RNXEAO.js → chunk-T5SHNNGP.js} +81 -1
- package/dist/{chunk-XDXNDSKO.js → chunk-XEGTMVYY.js} +4 -1
- package/dist/cli.cjs +124 -124
- package/dist/{dgmo-router-YTU3ENAX.js → dgmo-router-CE2G67FV.js} +3 -3
- package/dist/element.d.ts +62 -0
- package/dist/element.js +100 -100
- package/dist/element.mjs +99 -8
- package/dist/index.d.ts +185 -0
- package/dist/index.js +7 -5
- package/dist/{renderer-72LGR2YF.js → renderer-5KVCNMOJ.js} +2 -2
- package/dist/{renderer-PJM35LJN.js → renderer-P5ROYQGU.js} +2 -2
- package/dist/themes-PdPR1-hC.d.ts +916 -0
- package/docs/language-reference.md +5 -0
- package/gallery/fixtures/countdown-far.dgmo +2 -0
- package/package.json +1 -1
package/dist/element.mjs
CHANGED
|
@@ -13545,6 +13545,8 @@ function parseChart(content, palette) {
|
|
|
13545
13545
|
result.solidFill = true;
|
|
13546
13546
|
} else if (firstToken === "no-title") {
|
|
13547
13547
|
result.noTitle = true;
|
|
13548
|
+
} else if (firstToken === "no-auto-y") {
|
|
13549
|
+
result.noAutoY = true;
|
|
13548
13550
|
} else if (firstToken === "fill") {
|
|
13549
13551
|
result.fill = true;
|
|
13550
13552
|
} else if (firstToken === "hole") {
|
|
@@ -13839,6 +13841,7 @@ var init_chart = __esm({
|
|
|
13839
13841
|
"orientation-horizontal",
|
|
13840
13842
|
"solid-fill",
|
|
13841
13843
|
"no-title",
|
|
13844
|
+
"no-auto-y",
|
|
13842
13845
|
"fill",
|
|
13843
13846
|
"hole"
|
|
13844
13847
|
]);
|
|
@@ -31924,7 +31927,14 @@ function renderLine(svg, chart, width, height, colors, palette, isDark, textColo
|
|
|
31924
31927
|
hi = Math.max(hi, v);
|
|
31925
31928
|
}
|
|
31926
31929
|
if (!isFinite(lo)) return [0, 1];
|
|
31927
|
-
if (
|
|
31930
|
+
if (chart.noAutoY) {
|
|
31931
|
+
if (lo > 0) lo = 0;
|
|
31932
|
+
} else {
|
|
31933
|
+
const pad3 = (hi - lo) * 0.05 || Math.abs(hi) * 0.05 || 1;
|
|
31934
|
+
const nlo = lo - pad3;
|
|
31935
|
+
lo = lo >= 0 && nlo < 0 ? 0 : nlo;
|
|
31936
|
+
hi = hi + pad3;
|
|
31937
|
+
}
|
|
31928
31938
|
if (lo === hi) hi = lo + 1;
|
|
31929
31939
|
return [lo, hi];
|
|
31930
31940
|
};
|
|
@@ -72501,6 +72511,7 @@ function haloRect(svg, x, y, w, h, rx, C) {
|
|
|
72501
72511
|
function pickBand(nowMs, resolvedMs, hasTime) {
|
|
72502
72512
|
const days = dayDelta(nowMs, resolvedMs);
|
|
72503
72513
|
if (hasTime && days <= 0) return "clock";
|
|
72514
|
+
if (days > 3 * 365) return "years";
|
|
72504
72515
|
if (days > 365) return "year";
|
|
72505
72516
|
if (days > 92) return "months";
|
|
72506
72517
|
if (days > 18) return "monthgrid";
|
|
@@ -72531,9 +72542,31 @@ function monthGridLayout(nowMs, resolvedMs, contentW) {
|
|
|
72531
72542
|
}
|
|
72532
72543
|
return { months, dim };
|
|
72533
72544
|
}
|
|
72545
|
+
function yearsLayout(nowMs, resolvedMs) {
|
|
72546
|
+
const y0 = new Date(nowMs).getFullYear();
|
|
72547
|
+
const y1 = new Date(resolvedMs).getFullYear();
|
|
72548
|
+
const d0 = Math.floor(y0 / 10) * 10;
|
|
72549
|
+
const d1 = Math.floor(y1 / 10) * 10;
|
|
72550
|
+
return { d0, d1, rows: (d1 - d0) / 10 + 1 };
|
|
72551
|
+
}
|
|
72534
72552
|
function bandHeightFor(kind, nowMs, resolvedMs, contentW) {
|
|
72535
72553
|
const clamp5 = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
72536
72554
|
switch (kind) {
|
|
72555
|
+
case "years": {
|
|
72556
|
+
const { rows } = yearsLayout(nowMs, resolvedMs);
|
|
72557
|
+
const rowGap = 11;
|
|
72558
|
+
const labW = 54;
|
|
72559
|
+
const gap = 7;
|
|
72560
|
+
const cellW = (contentW - labW - 10 * gap) / 10;
|
|
72561
|
+
let cellH = clamp5(cellW * 0.5, 26, 40);
|
|
72562
|
+
const MAX = 380;
|
|
72563
|
+
let total = rows * cellH + (rows - 1) * rowGap;
|
|
72564
|
+
if (total > MAX) {
|
|
72565
|
+
cellH = Math.max(9, (MAX - (rows - 1) * rowGap) / rows);
|
|
72566
|
+
total = rows * cellH + (rows - 1) * rowGap;
|
|
72567
|
+
}
|
|
72568
|
+
return total;
|
|
72569
|
+
}
|
|
72537
72570
|
case "year": {
|
|
72538
72571
|
const R = new Date(resolvedMs).getFullYear() - new Date(nowMs).getFullYear() + 1;
|
|
72539
72572
|
const yearW = 66;
|
|
@@ -72572,6 +72605,61 @@ function bandHeightFor(kind, nowMs, resolvedMs, contentW) {
|
|
|
72572
72605
|
return clamp5(contentW * 0.22, 125, 170);
|
|
72573
72606
|
}
|
|
72574
72607
|
}
|
|
72608
|
+
function vizYears(svg, g, nowMs, resolvedMs, C) {
|
|
72609
|
+
const now = new Date(nowMs);
|
|
72610
|
+
const ev = new Date(resolvedMs);
|
|
72611
|
+
const nowY = now.getFullYear();
|
|
72612
|
+
const evY = ev.getFullYear();
|
|
72613
|
+
const { d0, rows } = yearsLayout(nowMs, resolvedMs);
|
|
72614
|
+
const labW = 54;
|
|
72615
|
+
const gap = 7;
|
|
72616
|
+
const rowGap = 11;
|
|
72617
|
+
const rowH = (g.height - rowGap * (rows - 1)) / rows;
|
|
72618
|
+
const cellH = rowH;
|
|
72619
|
+
const cellW = (g.contentW - labW - 10 * gap) / 10;
|
|
72620
|
+
const rx = Math.min(6, Math.min(cellW, cellH) * 0.22);
|
|
72621
|
+
const showLabel = cellH >= 18 && cellW >= 22;
|
|
72622
|
+
const yrFont = Math.min(12, cellW * 0.34, cellH * 0.5);
|
|
72623
|
+
for (let r = 0; r < rows; r++) {
|
|
72624
|
+
const dec = d0 + r * 10;
|
|
72625
|
+
const ry = g.top + r * (rowH + rowGap);
|
|
72626
|
+
aText(
|
|
72627
|
+
svg,
|
|
72628
|
+
g.left + labW - 12,
|
|
72629
|
+
ry + rowH / 2,
|
|
72630
|
+
Math.min(14, rowH * 0.5),
|
|
72631
|
+
C.muted,
|
|
72632
|
+
800,
|
|
72633
|
+
"end",
|
|
72634
|
+
`${dec}s`,
|
|
72635
|
+
{ "dominant-baseline": "central" }
|
|
72636
|
+
);
|
|
72637
|
+
for (let i = 0; i < 10; i++) {
|
|
72638
|
+
const yr = dec + i;
|
|
72639
|
+
const before = yr < nowY;
|
|
72640
|
+
const isNow = yr === nowY;
|
|
72641
|
+
const isEv = yr === evY;
|
|
72642
|
+
const between = yr > nowY && yr < evY;
|
|
72643
|
+
const st = isEv ? roleStyle(C, "event") : isNow ? roleStyle(C, "today") : between ? gradStyle(C, (yr - nowY) / (evY - nowY)) : roleStyle(C, before ? "past" : "future");
|
|
72644
|
+
const x = g.left + labW + i * (cellW + gap);
|
|
72645
|
+
aRect(svg, x, ry, cellW, cellH, rx, st.fill, st.stroke, 1);
|
|
72646
|
+
if (isEv) haloRect(svg, x, ry, cellW, cellH, rx, C);
|
|
72647
|
+
if (showLabel) {
|
|
72648
|
+
aText(
|
|
72649
|
+
svg,
|
|
72650
|
+
x + cellW / 2,
|
|
72651
|
+
ry + cellH / 2,
|
|
72652
|
+
yrFont,
|
|
72653
|
+
st.text,
|
|
72654
|
+
isNow || isEv ? 800 : 650,
|
|
72655
|
+
"middle",
|
|
72656
|
+
String(yr),
|
|
72657
|
+
{ "dominant-baseline": "central" }
|
|
72658
|
+
);
|
|
72659
|
+
}
|
|
72660
|
+
}
|
|
72661
|
+
}
|
|
72662
|
+
}
|
|
72575
72663
|
function vizYear(svg, g, nowMs, resolvedMs, C) {
|
|
72576
72664
|
const now = new Date(nowMs);
|
|
72577
72665
|
const ev = new Date(resolvedMs);
|
|
@@ -73083,6 +73171,8 @@ function pad22(n) {
|
|
|
73083
73171
|
}
|
|
73084
73172
|
function drawBand2(svg, kind, g, nowMs, resolvedMs, C) {
|
|
73085
73173
|
switch (kind) {
|
|
73174
|
+
case "years":
|
|
73175
|
+
return vizYears(svg, g, nowMs, resolvedMs, C);
|
|
73086
73176
|
case "year":
|
|
73087
73177
|
return vizYear(svg, g, nowMs, resolvedMs, C);
|
|
73088
73178
|
case "months":
|
|
@@ -73762,13 +73852,13 @@ function drawRow(svg, entry, index, parsed, now, rowTop, rowH, geom, col) {
|
|
|
73762
73852
|
const mainFont = 48;
|
|
73763
73853
|
const baseY = center + 16;
|
|
73764
73854
|
const capTop = baseY - mainFont * 0.7;
|
|
73765
|
-
g.append("text").attr("data-dgmo-clock-digital", "").attr("data-dgmo-clock-digital-part", "main").attr("x", contentLeft).attr("y", baseY).attr("fill", timeColor).attr("font-family", FONT_FAMILY).attr("font-size", mainFont).attr("font-weight", 600).style("font-variant-numeric", "tabular-nums").text(ts.main);
|
|
73766
73855
|
const sf = 20;
|
|
73767
73856
|
const mainW = [...ts.main].reduce(
|
|
73768
|
-
(w, c) => w + mainFont * (c === ":" ? 0.
|
|
73857
|
+
(w, c) => w + mainFont * (c === ":" ? 0.334 : 0.6),
|
|
73769
73858
|
0
|
|
73770
73859
|
);
|
|
73771
73860
|
const stackX = contentLeft + mainW + 5;
|
|
73861
|
+
g.append("text").attr("data-dgmo-clock-digital", "").attr("data-dgmo-clock-digital-part", "main").attr("x", contentLeft).attr("y", baseY).attr("fill", timeColor).attr("font-family", FONT_FAMILY).attr("font-size", mainFont).attr("font-weight", 600).attr("textLength", mainW).attr("lengthAdjust", "spacing").style("font-variant-numeric", "tabular-nums").text(ts.main);
|
|
73772
73862
|
g.append("text").attr("data-dgmo-clock-digital-part", "sec").attr("x", stackX).attr("y", capTop + sf * 0.72).attr("fill", muted).attr("font-family", FONT_FAMILY).attr("font-size", sf).attr("font-weight", 600).style("font-variant-numeric", "tabular-nums").text(`:${ts.sec}`);
|
|
73773
73863
|
if (ts.ap)
|
|
73774
73864
|
g.append("text").attr("data-dgmo-clock-digital-part", "ap").attr("x", stackX).attr("y", baseY).attr("fill", muted).attr("font-family", FONT_FAMILY).attr("font-size", sf).attr("font-weight", 600).text(ts.ap);
|
|
@@ -73907,13 +73997,13 @@ function drawColumns(body, parsed, now, top, geom, col) {
|
|
|
73907
73997
|
const sf = 13;
|
|
73908
73998
|
const tf = fitFont(ts.main, 44, innerW - 30, 20);
|
|
73909
73999
|
const mainW = [...ts.main].reduce(
|
|
73910
|
-
(w, c) => w + tf * (c === ":" ? 0.
|
|
74000
|
+
(w, c) => w + tf * (c === ":" ? 0.334 : 0.6),
|
|
73911
74001
|
0
|
|
73912
74002
|
);
|
|
73913
74003
|
const stackW = Math.max(estWidth(`:${ts.sec}`, sf), estWidth(ts.ap, sf));
|
|
73914
74004
|
const gLeft = cx - (mainW + 7 + stackW) / 2;
|
|
73915
74005
|
const baseY = cy + tf * 0.34;
|
|
73916
|
-
g.append("text").attr("data-dgmo-clock-digital", "").attr("data-dgmo-clock-digital-part", "main").attr("x", gLeft).attr("y", baseY).attr("fill", timeColor).attr("font-family", FONT_FAMILY).attr("font-size", tf).attr("font-weight", 600).style("font-variant-numeric", "tabular-nums").text(ts.main);
|
|
74006
|
+
g.append("text").attr("data-dgmo-clock-digital", "").attr("data-dgmo-clock-digital-part", "main").attr("x", gLeft).attr("y", baseY).attr("fill", timeColor).attr("font-family", FONT_FAMILY).attr("font-size", tf).attr("font-weight", 600).attr("textLength", mainW).attr("lengthAdjust", "spacing").style("font-variant-numeric", "tabular-nums").text(ts.main);
|
|
73917
74007
|
const stackX = gLeft + mainW + 7;
|
|
73918
74008
|
g.append("text").attr("data-dgmo-clock-digital-part", "sec").attr("x", stackX).attr("y", baseY - tf * 0.32).attr("fill", muted).attr("font-family", FONT_FAMILY).attr("font-size", sf).attr("font-weight", 500).text(`:${ts.sec}`);
|
|
73919
74009
|
if (ts.ap)
|
|
@@ -81465,7 +81555,7 @@ async function render(content, options) {
|
|
|
81465
81555
|
try {
|
|
81466
81556
|
const raw = await renderDataChartD3(renderContent, theme, paletteColors);
|
|
81467
81557
|
const svg2 = injectHoverStyles(raw, chartType, { bakeHover });
|
|
81468
|
-
return { svg: svg2, diagnostics };
|
|
81558
|
+
return { svg: svg2, diagnostics, chartType: chartType ?? void 0 };
|
|
81469
81559
|
} finally {
|
|
81470
81560
|
releaseDom();
|
|
81471
81561
|
}
|
|
@@ -81506,7 +81596,7 @@ async function render(content, options) {
|
|
|
81506
81596
|
} catch {
|
|
81507
81597
|
}
|
|
81508
81598
|
}
|
|
81509
|
-
return { svg, diagnostics };
|
|
81599
|
+
return { svg, diagnostics, chartType: chartType ?? void 0 };
|
|
81510
81600
|
}
|
|
81511
81601
|
|
|
81512
81602
|
// src/countdown/ticker.ts
|
|
@@ -82714,6 +82804,7 @@ function resolveBlockOptions(opts) {
|
|
|
82714
82804
|
mode,
|
|
82715
82805
|
palette: opts.palette ?? "slate",
|
|
82716
82806
|
colorMode: opts.colorMode ?? "auto",
|
|
82807
|
+
background: opts.background ?? "auto",
|
|
82717
82808
|
showSource: opts.showSource ?? showcase,
|
|
82718
82809
|
showCopy: opts.showCopy ?? showcase,
|
|
82719
82810
|
showExpand: opts.showExpand ?? showcase,
|
|
@@ -82816,7 +82907,7 @@ var CSS = AUTO_BASE_CSS + "\n" + BLOCK_CSS + "\n" + darkScopedBlockCss(BLOCK_CSS
|
|
|
82816
82907
|
|
|
82817
82908
|
// src/auto/shared.ts
|
|
82818
82909
|
init_safe_href();
|
|
82819
|
-
var VERSION = "0.50.
|
|
82910
|
+
var VERSION = "0.50.2";
|
|
82820
82911
|
var ARIA_LABEL_MAX = 200;
|
|
82821
82912
|
var COPIED_INTERACTION_MS = 1500;
|
|
82822
82913
|
var LOG_PREFIX = "[dgmo]";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ab as DiagnosticSpec, a as PaletteConfig, J as Theme, C as CompactViewState, D as DgmoError } from './themes-PdPR1-hC.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-PdPR1-hC.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 background (the theme's opaque `palette.bg` — both the inline
|
|
24
|
+
* `background:` style and the full-canvas `<rect>` some renderers paint) is
|
|
25
|
+
* STRIPPED by default so the embed inherits the host page surface and blends
|
|
26
|
+
* into Obsidian / doc-site / arbitrary pages instead of showing a mismatched
|
|
27
|
+
* rectangle. Pass `{ background: 'opaque' }` to keep it — the embedder
|
|
28
|
+
* opt-out, and the automatic default for background-meaningful types like
|
|
29
|
+
* `map` (whose bg is the ocean) via `defaultEmbedBackground`. Standalone
|
|
30
|
+
* PNG/SVG export does NOT go through here and stays opaque.
|
|
31
|
+
*
|
|
32
|
+
* This is intentionally a string transform, not a DOM `getBBox()` step: dgmo
|
|
33
|
+
* can dual-render light/dark SVGs where one is hidden by color-mode CSS, and
|
|
34
|
+
* `getBBox()` returns 0 for the hidden copy. Parsing coordinates from the
|
|
35
|
+
* markup measures both copies reliably and works server-side (Node).
|
|
36
|
+
*/
|
|
37
|
+
interface NormalizeSvgForEmbedOptions {
|
|
38
|
+
/**
|
|
39
|
+
* `transparent` (default) strips the theme's opaque root background so the
|
|
40
|
+
* embed inherits the host page surface. `opaque` preserves it — the embedder
|
|
41
|
+
* opt-out for diagrams that need their own solid backdrop. Callers that know
|
|
42
|
+
* the chart type should resolve this via `defaultEmbedBackground`.
|
|
43
|
+
*/
|
|
44
|
+
background?: 'transparent' | 'opaque';
|
|
45
|
+
}
|
|
46
|
+
declare function normalizeSvgForEmbed(input: string, opts?: NormalizeSvgForEmbedOptions): string;
|
|
47
|
+
/**
|
|
48
|
+
* The embed background an embedder gets by default for a given chart type:
|
|
49
|
+
* `transparent` (blend into the host) for everything except
|
|
50
|
+
* background-meaningful types, which stay `opaque`.
|
|
51
|
+
*/
|
|
52
|
+
declare function defaultEmbedBackground(chartType?: string): 'transparent' | 'opaque';
|
|
53
|
+
/**
|
|
54
|
+
* Parse the content bounding box of a normalized embed SVG, if one can be
|
|
55
|
+
* derived. Returns `null` when no usable coordinates are found (e.g. an empty
|
|
56
|
+
* diagram). Useful for hosts that want to set an explicit `aspect-ratio` from
|
|
57
|
+
* the tight viewBox.
|
|
58
|
+
*/
|
|
59
|
+
declare function getEmbedSvgViewBox(svg: string): {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
} | null;
|
|
65
|
+
|
|
66
|
+
interface MountD3Opts {
|
|
67
|
+
theme?: 'light' | 'dark' | 'transparent';
|
|
68
|
+
palette?: string;
|
|
69
|
+
/** Forwarded to the interaction adapter: source-line navigation on click. */
|
|
70
|
+
onNavigate?: (line: number) => void;
|
|
71
|
+
mutedColor?: string;
|
|
72
|
+
surface?: string;
|
|
73
|
+
text?: string;
|
|
74
|
+
}
|
|
75
|
+
interface MountedD3Chart {
|
|
76
|
+
/** Re-render with new content and/or theme/palette; re-attaches interactions. */
|
|
77
|
+
update: (content: string, opts?: Partial<MountD3Opts>) => Promise<void>;
|
|
78
|
+
/** Emphasize the chart element on the given source line (editor cursor sync);
|
|
79
|
+
* pass null to clear. */
|
|
80
|
+
highlight: (line: number | null) => void;
|
|
81
|
+
/** Tear down listeners + overlays and clear the container. */
|
|
82
|
+
destroy: () => void;
|
|
83
|
+
}
|
|
84
|
+
declare function mountD3DataChart(container: HTMLElement, content: string, opts?: MountD3Opts): MountedD3Chart;
|
|
85
|
+
|
|
86
|
+
interface DataChartInteractionOpts {
|
|
87
|
+
onNavigate?: (line: number) => void;
|
|
88
|
+
mutedColor?: string;
|
|
89
|
+
surface?: string;
|
|
90
|
+
text?: string;
|
|
91
|
+
}
|
|
92
|
+
interface DataChartController {
|
|
93
|
+
/** Remove all listeners + overlays. */
|
|
94
|
+
destroy: () => void;
|
|
95
|
+
/** Emphasize the chart element(s) on the given source line (editor cursor
|
|
96
|
+
* sync); pass null to clear. No-op while the pointer is actively hovering. */
|
|
97
|
+
highlight: (line: number | null) => void;
|
|
98
|
+
}
|
|
99
|
+
declare function attachDataChartInteractions(svg: SVGSVGElement, opts?: DataChartInteractionOpts): DataChartController;
|
|
100
|
+
|
|
101
|
+
/** All data-chart types the hand-built renderers currently cover. */
|
|
102
|
+
declare const D3_DATA_CHART_TYPES: Set<string>;
|
|
103
|
+
declare function supportsD3DataChart(type: string): boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The full diagnostic catalog, sorted by code. Every coded diagnostic
|
|
107
|
+
* dgmo can emit — its severity, owning chart type, canonical message,
|
|
108
|
+
* fix hint, and a triggering example. This is the enumerable source of
|
|
109
|
+
* truth for the CLI `diagnostics` subcommand, the console error-review
|
|
110
|
+
* surface, MCP, and the language-spec catalog.
|
|
111
|
+
*/
|
|
112
|
+
declare function listDiagnosticCodes(): DiagnosticSpec[];
|
|
113
|
+
/** Look up a single spec by its code, or `undefined` if not cataloged. */
|
|
114
|
+
declare function getDiagnosticSpec(code: string): DiagnosticSpec | undefined;
|
|
115
|
+
|
|
116
|
+
interface RenderOptions {
|
|
117
|
+
theme?: Theme;
|
|
118
|
+
/**
|
|
119
|
+
* A `PaletteConfig` (e.g. `palettes.catppuccin`) or a palette id string
|
|
120
|
+
* (e.g. `'catppuccin'`). Unknown ids fall back to the default palette.
|
|
121
|
+
*/
|
|
122
|
+
palette?: PaletteConfig | string;
|
|
123
|
+
/**
|
|
124
|
+
* How to handle parse errors:
|
|
125
|
+
* 'svg' — render an inline error SVG (default)
|
|
126
|
+
* 'silent' — return empty svg + diagnostics; caller handles UI
|
|
127
|
+
* 'throw' — throw an Error with the diagnostics
|
|
128
|
+
*/
|
|
129
|
+
onError?: 'svg' | 'silent' | 'throw';
|
|
130
|
+
/**
|
|
131
|
+
* Pre-applied interactive view state — collapsed sections/columns,
|
|
132
|
+
* active swimlane tag-group, etc. Used to render a specific view
|
|
133
|
+
* non-interactively (server-side render, share-link decode).
|
|
134
|
+
*/
|
|
135
|
+
viewState?: CompactViewState;
|
|
136
|
+
}
|
|
137
|
+
interface RenderResult {
|
|
138
|
+
svg: string;
|
|
139
|
+
diagnostics: DgmoError[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Render DGMO source to an SVG string.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { render, palettes, themes } from '@diagrammo/dgmo';
|
|
147
|
+
*
|
|
148
|
+
* const { svg } = await render(text, {
|
|
149
|
+
* palette: palettes.catppuccin,
|
|
150
|
+
* theme: themes.dark,
|
|
151
|
+
* });
|
|
152
|
+
* document.getElementById('chart').innerHTML = svg;
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function render(text: string, options?: RenderOptions): Promise<RenderResult>;
|
|
156
|
+
|
|
157
|
+
interface EncodeDiagramUrlOptions {
|
|
158
|
+
baseUrl?: string;
|
|
159
|
+
palette?: PaletteConfig;
|
|
160
|
+
theme?: Theme;
|
|
161
|
+
filename?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Initial view state to embed in the URL — re-applied when the link is
|
|
164
|
+
* decoded so recipients open the diagram in the same configuration.
|
|
165
|
+
*/
|
|
166
|
+
viewState?: CompactViewState;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Encode DGMO text into a shareable URL. Returns null if the compressed
|
|
170
|
+
* payload exceeds the 8 KB URL limit.
|
|
171
|
+
*/
|
|
172
|
+
declare function encodeDiagramUrl(text: string, options?: EncodeDiagramUrlOptions): string | null;
|
|
173
|
+
interface DecodedDiagramUrl {
|
|
174
|
+
text: string;
|
|
175
|
+
palette?: PaletteConfig;
|
|
176
|
+
theme?: Theme;
|
|
177
|
+
filename?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Decode a share URL back into DGMO text plus optional palette/theme/filename.
|
|
181
|
+
* Returns null if the URL contains no valid DGMO payload.
|
|
182
|
+
*/
|
|
183
|
+
declare function decodeDiagramUrl(url: string): DecodedDiagramUrl | null;
|
|
184
|
+
|
|
185
|
+
export { CompactViewState, D3_DATA_CHART_TYPES, type DataChartInteractionOpts, type DecodedDiagramUrl, DgmoError, DiagnosticSpec, type EncodeDiagramUrlOptions, type MountD3Opts, type MountedD3Chart, type NormalizeSvgForEmbedOptions, PaletteConfig, type RenderOptions, type RenderResult, Theme, attachDataChartInteractions, decodeDiagramUrl, defaultEmbedBackground, encodeDiagramUrl, getDiagnosticSpec, getEmbedSvgViewBox, getMinDimensions, listDiagnosticCodes, mountD3DataChart, normalizeSvgForEmbed, render, supportsD3DataChart };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
defaultEmbedBackground,
|
|
2
3
|
getEmbedSvgViewBox,
|
|
3
4
|
normalizeSvgForEmbed,
|
|
4
5
|
renderErrorCard
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DN66GPY5.js";
|
|
6
7
|
import {
|
|
7
8
|
completeMapPlaces,
|
|
8
9
|
completeMapRegions,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
decodeDiagramUrl,
|
|
17
18
|
encodeDiagramUrl,
|
|
18
19
|
render
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-SVTI362O.js";
|
|
20
21
|
import "./chunk-66RUL3XF.js";
|
|
21
22
|
import "./chunk-YRYKTYMQ.js";
|
|
22
23
|
import "./chunk-YYVTBZZC.js";
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
REGISTRY_BY_ID,
|
|
26
27
|
chartTypes,
|
|
27
28
|
parseDgmo
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-KQ57MHRO.js";
|
|
29
30
|
import "./chunk-Q4V4XQWV.js";
|
|
30
31
|
import "./chunk-BTUTZMPT.js";
|
|
31
32
|
import "./chunk-YNRDWYZP.js";
|
|
@@ -42,7 +43,7 @@ import {
|
|
|
42
43
|
D3_DATA_CHART_TYPES,
|
|
43
44
|
renderDataChartD3,
|
|
44
45
|
supportsD3DataChart
|
|
45
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-QJJZSROI.js";
|
|
46
47
|
import "./chunk-HGN652MU.js";
|
|
47
48
|
import "./chunk-U6EQI3U6.js";
|
|
48
49
|
import "./chunk-7UEMZREK.js";
|
|
@@ -50,7 +51,7 @@ import "./chunk-A4GOY3PE.js";
|
|
|
50
51
|
import "./chunk-6KFWC4CO.js";
|
|
51
52
|
import "./chunk-HQCHYB5F.js";
|
|
52
53
|
import "./chunk-5LWQH6QV.js";
|
|
53
|
-
import "./chunk-
|
|
54
|
+
import "./chunk-XEGTMVYY.js";
|
|
54
55
|
import "./chunk-I2WKW7C7.js";
|
|
55
56
|
import "./chunk-TSA237IM.js";
|
|
56
57
|
import "./chunk-6IAA2QQ2.js";
|
|
@@ -866,6 +867,7 @@ export {
|
|
|
866
867
|
completeMapPlaces,
|
|
867
868
|
completeMapRegions,
|
|
868
869
|
decodeDiagramUrl2 as decodeDiagramUrl,
|
|
870
|
+
defaultEmbedBackground,
|
|
869
871
|
emit,
|
|
870
872
|
encodeDiagramUrl2 as encodeDiagramUrl,
|
|
871
873
|
formatDgmoError,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderClock,
|
|
3
3
|
renderClockForExport
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5WFIYXQ6.js";
|
|
5
5
|
import "./chunk-6KFWC4CO.js";
|
|
6
6
|
import "./chunk-P6T66CCZ.js";
|
|
7
7
|
import "./chunk-TLVIHFRO.js";
|
|
@@ -11,4 +11,4 @@ export {
|
|
|
11
11
|
renderClock,
|
|
12
12
|
renderClockForExport
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=renderer-
|
|
14
|
+
//# sourceMappingURL=renderer-5KVCNMOJ.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderCountdown,
|
|
3
3
|
renderCountdownForExport
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-T5SHNNGP.js";
|
|
5
5
|
import "./chunk-3HDBAXF5.js";
|
|
6
6
|
import "./chunk-BMR4CIEO.js";
|
|
7
7
|
import "./chunk-YNRDWYZP.js";
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
renderCountdown,
|
|
15
15
|
renderCountdownForExport
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=renderer-
|
|
17
|
+
//# sourceMappingURL=renderer-P5ROYQGU.js.map
|