@diagrammo/dgmo 0.48.1 → 0.49.0
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/.cursorrules +8 -3
- package/.github/copilot-instructions.md +8 -3
- package/.windsurfrules +8 -3
- package/SKILL.md +8 -3
- package/dist/advanced.d.ts +444 -1
- package/dist/advanced.js +208 -146
- package/dist/auto.css +74 -5
- package/dist/auto.js +213 -107
- package/dist/auto.mjs +6906 -831
- package/dist/block.css +74 -5
- package/dist/block.d.ts +13 -5
- package/dist/block.js +148 -62
- package/dist/{charts-d3-QOZHKTCT.js → charts-d3-EW3YQTEA.js} +9 -8
- package/dist/chunk-26RVGM44.js +331 -0
- package/dist/{chunk-44CM72SQ.js → chunk-2WMBWZY2.js} +3 -3
- package/dist/{chunk-L66GEFB6.js → chunk-35BBZDFE.js} +4 -4
- package/dist/{chunk-4GRI7MEB.js → chunk-3BIAFYD2.js} +6 -6
- package/dist/chunk-3NFJWFNP.js +1474 -0
- package/dist/{chunk-76OWZ3BA.js → chunk-4BD7EVPK.js} +2 -2
- package/dist/{chunk-MITI6NOL.js → chunk-4FIV4K4Z.js} +9 -9
- package/dist/chunk-4HVNZ7WF.js +574 -0
- package/dist/{chunk-X5LCYCL5.js → chunk-4NQ3IKUM.js} +2 -2
- package/dist/{chunk-PWIHZ6NJ.js → chunk-4UDKKGHH.js} +4 -4
- package/dist/{chunk-6NYWYNBI.js → chunk-4XK3FLFB.js} +3 -3
- package/dist/chunk-4YNP6O47.js +607 -0
- package/dist/{chunk-3MQQNXPD.js → chunk-5FGDJIJX.js} +3 -3
- package/dist/{chunk-WCT3NYCV.js → chunk-5LWQH6QV.js} +1 -1
- package/dist/chunk-5XCM7UUW.js +261 -0
- package/dist/{chunk-RYEGFMUO.js → chunk-5ZZLLBFK.js} +2 -2
- package/dist/{chunk-EB6FPQUP.js → chunk-65RTDUZH.js} +3 -3
- package/dist/chunk-6CLKNXVP.js +664 -0
- package/dist/{chunk-H6PI3KJT.js → chunk-6IUAK7RZ.js} +2 -2
- package/dist/{chunk-ZGR7ULFJ.js → chunk-6SA7FJE4.js} +31 -19
- package/dist/{chunk-LIOHW36Z.js → chunk-6VE3VLWM.js} +3 -3
- package/dist/{chunk-AN2MOO5T.js → chunk-7OVSJI2V.js} +3 -3
- package/dist/{chunk-YAA6IID3.js → chunk-7UEMZREK.js} +2 -2
- package/dist/{chunk-FCIIHT24.js → chunk-7VLUGEMJ.js} +7 -7
- package/dist/{chunk-VOKGH627.js → chunk-AHGF2YYA.js} +13 -3
- package/dist/{chunk-3R5POCTZ.js → chunk-AJ2PEY7J.js} +6 -6
- package/dist/{chunk-PBHE5UG6.js → chunk-ALRHIR6I.js} +46 -12
- package/dist/{chunk-7JEGTRLD.js → chunk-B57V3DWN.js} +3 -3
- package/dist/{chunk-ILKORZ3H.js → chunk-BCT5G2VN.js} +7 -7
- package/dist/{chunk-TYS6CSS5.js → chunk-BCYVE3N5.js} +2 -2
- package/dist/{chunk-ZBWMSD5N.js → chunk-BGJV5ATD.js} +4 -4
- package/dist/{chunk-G2H74XJZ.js → chunk-BPIJLRYE.js} +8 -8
- package/dist/{chunk-YGJTDXVR.js → chunk-C4GQDB5L.js} +2 -2
- package/dist/{chunk-Y2ZE3MSG.js → chunk-C63UWAKM.js} +2 -2
- package/dist/{chunk-QEBUY5NY.js → chunk-CEHZOPGM.js} +4 -4
- package/dist/{chunk-725LDASD.js → chunk-CLD2OKV7.js} +2 -2
- package/dist/{chunk-5QXL4NYS.js → chunk-CLR4A2N2.js} +10 -5
- package/dist/{chunk-WBRZJOEC.js → chunk-CMCR5WBW.js} +3 -3
- package/dist/{chunk-SML67VPV.js → chunk-D5AVQCDN.js} +3 -3
- package/dist/{chunk-2LACINWN.js → chunk-DDTJ5N7Q.js} +9 -9
- package/dist/{chunk-FITOLXSX.js → chunk-EOFPYPAU.js} +26 -2
- package/dist/{chunk-B65G5DNL.js → chunk-EYN7VFKL.js} +3 -3
- package/dist/{chunk-4OHACBGX.js → chunk-F2L5GCQ4.js} +2 -2
- package/dist/{chunk-RVMRZAPB.js → chunk-F743CM2N.js} +3 -3
- package/dist/{chunk-3JLKYGBQ.js → chunk-F7BFXWNQ.js} +2 -2
- package/dist/{chunk-WCSOJFU3.js → chunk-FMKTYMP4.js} +3 -3
- package/dist/{chunk-RTLBSQ3G.js → chunk-FUCAB3KQ.js} +3 -3
- package/dist/{chunk-SGZYXELT.js → chunk-GB3YZTAM.js} +9 -6
- package/dist/{chunk-QLCCJEJI.js → chunk-HBVD67XG.js} +2 -2
- package/dist/{chunk-PBAHEPLQ.js → chunk-HGN652MU.js} +7 -6
- package/dist/{chunk-3SMGIJDD.js → chunk-HHXOONLX.js} +13 -1
- package/dist/{chunk-QOOUC2J5.js → chunk-HQCHYB5F.js} +2 -2
- package/dist/chunk-IAEC4KLA.js +492 -0
- package/dist/{chunk-J5FIXQRT.js → chunk-IBC35BTK.js} +4 -4
- package/dist/{chunk-NURGB5Z4.js → chunk-IFK3GIUW.js} +2 -2
- package/dist/{chunk-FANX6UJR.js → chunk-IHLSHCPZ.js} +11 -11
- package/dist/{chunk-GMR5MFHJ.js → chunk-IUK7AGD4.js} +2 -2
- package/dist/chunk-IVKC4GID.js +32 -0
- package/dist/{chunk-OJR3MQYV.js → chunk-JFPY3UJ7.js} +296 -57
- package/dist/{chunk-5MLYVTYM.js → chunk-K6HNAY5V.js} +2 -2
- package/dist/{chunk-P235SVAH.js → chunk-KQAEKMIX.js} +2 -2
- package/dist/{chunk-7DTWEFUE.js → chunk-KUBBJ2CD.js} +10 -10
- package/dist/{chunk-BUVJFRPY.js → chunk-KV6Y2HE6.js} +4 -4
- package/dist/{chunk-OURHMODR.js → chunk-LG4TWW4U.js} +13 -13
- package/dist/{chunk-XAKEUMEJ.js → chunk-LVHPTBO3.js} +3 -3
- package/dist/{chunk-ERLBPDGU.js → chunk-MJCG5K2O.js} +2 -2
- package/dist/{chunk-THXCFRTU.js → chunk-N4J5KGWG.js} +12 -12
- package/dist/{chunk-MZSBFAPJ.js → chunk-NVT6C2VE.js} +9 -9
- package/dist/{chunk-AELOBFW5.js → chunk-O5MQPK7E.js} +3 -3
- package/dist/{chunk-JM4LEPY3.js → chunk-O7NUCTFU.js} +2 -2
- package/dist/{chunk-JED6ZDEE.js → chunk-O7WP4ZD4.js} +2 -2
- package/dist/{chunk-ZO27FGJS.js → chunk-PH5X4GIP.js} +2 -2
- package/dist/{chunk-B7JUCQUA.js → chunk-PU3AUQPA.js} +4 -4
- package/dist/{chunk-A4VFQH5G.js → chunk-PZFVK3IH.js} +52 -7
- package/dist/chunk-QQJUTGQH.js +135 -0
- package/dist/{chunk-HSH73DP6.js → chunk-RI4NIMFP.js} +99 -39
- package/dist/{chunk-33LCUH4H.js → chunk-RTERS6S5.js} +3 -3
- package/dist/{chunk-T3UBLACL.js → chunk-SCQ5VPUF.js} +19 -5
- package/dist/chunk-SGHSY3LU.js +377 -0
- package/dist/{chunk-SRTU6HMQ.js → chunk-SJEGO2QL.js} +8 -8
- package/dist/chunk-SQDFK5ZQ.js +273 -0
- package/dist/{chunk-UC7TFHUM.js → chunk-SVDWQGX2.js} +296 -121
- package/dist/{chunk-Z5CGSFJB.js → chunk-T7IKPCMI.js} +4 -4
- package/dist/chunk-TC3YWBFO.js +233 -0
- package/dist/{chunk-EVCVDTXE.js → chunk-TLKMTQYL.js} +3 -3
- package/dist/{chunk-IJZFN3HM.js → chunk-TWQUYVP3.js} +4 -4
- package/dist/{chunk-IZMRON6C.js → chunk-UVCXZEGU.js} +2 -2
- package/dist/{chunk-CKNVO24D.js → chunk-UWDO3O52.js} +2 -2
- package/dist/{chunk-RJE5JTVK.js → chunk-VC3TR4NL.js} +7 -7
- package/dist/{chunk-CI2G3OEB.js → chunk-X2CH42BN.js} +9 -9
- package/dist/{chunk-6HO5ZTXK.js → chunk-XCC2RENT.js} +2 -2
- package/dist/chunk-XHVV4NVW.js +51 -0
- package/dist/{chunk-ZJEL4H2R.js → chunk-XJ7J6WOO.js} +9 -9
- package/dist/{chunk-ULOEATBZ.js → chunk-XKTN7CZF.js} +106 -29
- package/dist/{chunk-IPWPWM6R.js → chunk-YM2BSPYW.js} +111 -10
- package/dist/{chunk-BUPDIHML.js → chunk-YRVLP7UU.js} +3 -3
- package/dist/{chunk-T2OE3YQB.js → chunk-YTN572Q2.js} +3 -3
- package/dist/{chunk-WVAJFAIA.js → chunk-YYX3SU6H.js} +3 -3
- package/dist/{chunk-MO5YHHMQ.js → chunk-ZDUQGL3N.js} +2 -2
- package/dist/{chunk-Y3J7VR52.js → chunk-ZNQX6QWH.js} +30 -2
- package/dist/{chunk-UWN33VNX.js → chunk-ZREZOIGS.js} +8 -8
- package/dist/{chunk-6SM5NJQH.js → chunk-ZTLWVRNS.js} +4 -4
- package/dist/{chunk-RUNNI6VE.js → chunk-ZXL6MB4R.js} +3 -3
- package/dist/cli.cjs +159 -122
- package/dist/dgmo-router-ODKPEJ3P.js +79 -0
- package/dist/dimensions-WSIJXT5Q.js +22 -0
- package/dist/editor.js +4 -1
- package/dist/element.js +214 -108
- package/dist/element.mjs +6906 -831
- package/dist/{flowchart-parser-ZNSKIBVR.js → flowchart-parser-IVZN7CQN.js} +4 -4
- package/dist/{flowchart-renderer-SNDSII4D.js → flowchart-renderer-GMI2U3DD.js} +9 -9
- package/dist/highlight.js +7 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +193 -232
- package/dist/{layout-HRBZPFCN.js → layout-34CLNICW.js} +5 -5
- package/dist/{layout-5RA6QWR6.js → layout-4Z5JM7PT.js} +6 -6
- package/dist/layout-6RDJHS6E.js +9 -0
- package/dist/{layout-7QXCNOVS.js → layout-7H4H46CS.js} +3 -3
- package/dist/{layout-46N4JJYK.js → layout-7SKMFYHL.js} +5 -5
- package/dist/{layout-HWDSRX5E.js → layout-D42XE4RE.js} +6 -6
- package/dist/{layout-EE6GE46Y.js → layout-DC4TVXER.js} +5 -5
- package/dist/layout-FGQWRYYW.js +14 -0
- package/dist/layout-GZ2CWONU.js +14 -0
- package/dist/layout-HQMBPJVS.js +10 -0
- package/dist/{layout-UM5F4DJB.js → layout-K2ZN3Q42.js} +5 -5
- package/dist/{layout-S2QBYSK2.js → layout-NXG63LWH.js} +3 -3
- package/dist/{layout-N76NR4ZO.js → layout-PUQCB6AN.js} +7 -7
- package/dist/{layout-HYZPWAK5.js → layout-QNUQLEHU.js} +3 -3
- package/dist/layout-S3EK4IYO.js +14 -0
- package/dist/{layout-search-OYV77HHS.js → layout-search-QS44PI5R.js} +6 -6
- package/dist/{parser-KNSQSKQO.js → parser-4BKIFG2C.js} +5 -5
- package/dist/{parser-OV7NOBW6.js → parser-4ROBKVUR.js} +4 -4
- package/dist/parser-667RGSUW.js +13 -0
- package/dist/{parser-IXSZZQHY.js → parser-BL7Z72EY.js} +4 -4
- package/dist/{parser-AQETEVRW.js → parser-CLMFZWCC.js} +4 -4
- package/dist/{parser-XKRP7QKP.js → parser-D6ONJQFR.js} +3 -3
- package/dist/{parser-2EWECDSA.js → parser-DERPY5KC.js} +4 -4
- package/dist/{parser-4OGOBJJ4.js → parser-GFSOPDB7.js} +4 -4
- package/dist/{parser-2MFP2H2E.js → parser-HVJFTOXL.js} +3 -3
- package/dist/{parser-VQP2UJ6W.js → parser-IKZFTLOJ.js} +3 -3
- package/dist/parser-J3P2D6IP.js +13 -0
- package/dist/{parser-PQ3POX45.js → parser-JD7OQ2E6.js} +4 -4
- package/dist/{parser-O5J4VBII.js → parser-K647FRI4.js} +3 -3
- package/dist/{parser-NGU3ETO6.js → parser-KPMN5KKE.js} +4 -4
- package/dist/{parser-4FL2CMDG.js → parser-MBJSBTL5.js} +4 -4
- package/dist/{parser-TFZFBVWN.js → parser-MCJWF5G3.js} +3 -3
- package/dist/{parser-NRAI6O25.js → parser-MRBPXXIV.js} +4 -4
- package/dist/{parser-6BTRLKRZ.js → parser-OBQG655V.js} +4 -4
- package/dist/{parser-3STE62GB.js → parser-QJYS7KQQ.js} +4 -4
- package/dist/{parser-XDVELHRK.js → parser-SMBJO3XN.js} +4 -4
- package/dist/{parser-TRTHDFPP.js → parser-TITK4YW6.js} +5 -5
- package/dist/{parser-I6KXEYFK.js → parser-TNYX5S7E.js} +4 -4
- package/dist/{parser-Y6WTBU76.js → parser-UBGPTIZD.js} +3 -3
- package/dist/parser-UGA23PYK.js +14 -0
- package/dist/{parser-N5O4IHUN.js → parser-WISPH7LW.js} +4 -4
- package/dist/{parser-CFZD5IBL.js → parser-XWUDFJ7P.js} +4 -4
- package/dist/parser-ZKF5K2H2.js +15 -0
- package/dist/{parser-ZSDPZYQP.js → parser-ZYC3XGNS.js} +4 -4
- package/dist/{renderer-AWWAF6XD.js → renderer-4IUPINAE.js} +10 -10
- package/dist/renderer-6L3NBEY5.js +24 -0
- package/dist/{renderer-ZRNG54CW.js → renderer-6T3KK4S3.js} +11 -11
- package/dist/{renderer-KQB7UGDS.js → renderer-7RH2SI3B.js} +3 -3
- package/dist/{renderer-6EEZHMH4.js → renderer-A5VFZQQK.js} +9 -9
- package/dist/{renderer-5MYBMBYO.js → renderer-BB5PREMY.js} +5 -5
- package/dist/{renderer-BYCNMBF7.js → renderer-CGW7QPNA.js} +10 -10
- package/dist/{renderer-QIWVHWZO.js → renderer-DAXMXIKD.js} +3 -3
- package/dist/{renderer-7MVLWWQD.js → renderer-DKESNMU5.js} +9 -9
- package/dist/{renderer-ZTR3DER3.js → renderer-HVCU2C3Z.js} +3 -3
- package/dist/{renderer-VACVQYML.js → renderer-LWGJFT3D.js} +8 -8
- package/dist/{renderer-PGX2TKVS.js → renderer-MFJ7HY2H.js} +8 -8
- package/dist/{renderer-B2OMQIQG.js → renderer-MJDDU27W.js} +15 -15
- package/dist/{renderer-4JHRUBE6.js → renderer-QL5KO6SK.js} +10 -10
- package/dist/{renderer-W4M6QLIJ.js → renderer-QNHUXCRL.js} +14 -14
- package/dist/{renderer-ZGNTUWC4.js → renderer-ROV756WT.js} +8 -8
- package/dist/{renderer-YY2OSF6E.js → renderer-SQ3JUAI7.js} +9 -9
- package/dist/renderer-THD6V5TL.js +22 -0
- package/dist/{renderer-5NDVNDAZ.js → renderer-TPIBXNOS.js} +9 -9
- package/dist/{renderer-RPOA5YPZ.js → renderer-TYXRHMRI.js} +13 -13
- package/dist/{renderer-N43WR5GV.js → renderer-UZF3JROD.js} +11 -11
- package/dist/{renderer-6W5462RB.js → renderer-V3JEMWMM.js} +9 -9
- package/dist/{renderer-JGBKUCZD.js → renderer-VFUVRNLK.js} +4 -4
- package/dist/{renderer-Z7I3W2PP.js → renderer-VICQ4WNY.js} +8 -8
- package/dist/renderer-W5RMOURB.js +21 -0
- package/dist/renderer-XEKIRPI6.js +23 -0
- package/dist/{renderer-CLJHQPBJ.js → renderer-YHXPN3GF.js} +12 -12
- package/dist/renderer-radial-MHO2VDXN.js +21 -0
- package/dist/{resolver-NOAA7ID7.js → resolver-FHBCO3PL.js} +3 -3
- package/dist/{state-parser-Z2V23ATR.js → state-parser-RX3GXOIB.js} +4 -4
- package/dist/{state-renderer-B4DQBM6M.js → state-renderer-AJUKGNWU.js} +9 -9
- package/docs/ai-integration.md +8 -3
- package/docs/language-reference.md +179 -5
- package/gallery/fixtures/family.dgmo +23 -0
- package/gallery/fixtures/sketch.dgmo +22 -0
- package/package.json +1 -1
- package/dist/chunk-ODZVHU3R.js +0 -153
- package/dist/dgmo-router-X35VLZLM.js +0 -73
- package/dist/dimensions-J3FHIMJ6.js +0 -22
- package/dist/layout-5T6RH5M6.js +0 -14
- package/dist/layout-G23F7LDH.js +0 -9
- package/dist/layout-OB3RI63S.js +0 -14
- package/dist/parser-JAL2HD4I.js +0 -13
- package/dist/renderer-SMIBCRVB.js +0 -24
- package/dist/renderer-radial-C32GPJQ7.js +0 -21
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import {
|
|
2
|
+
encodeDiagramUrl
|
|
3
|
+
} from "./chunk-SVDWQGX2.js";
|
|
4
|
+
import {
|
|
5
|
+
FONT_FAMILY
|
|
6
|
+
} from "./chunk-6KFWC4CO.js";
|
|
7
|
+
import {
|
|
8
|
+
measureText,
|
|
9
|
+
truncateText
|
|
10
|
+
} from "./chunk-5LWQH6QV.js";
|
|
11
|
+
|
|
12
|
+
// src/error-card.ts
|
|
13
|
+
var MONO_FAMILY = "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace";
|
|
14
|
+
var W = 660;
|
|
15
|
+
var PAD = 24;
|
|
16
|
+
var CONTENT_W = W - PAD * 2;
|
|
17
|
+
var MAX_ERRORS = 4;
|
|
18
|
+
var MONO_CH = 0.6;
|
|
19
|
+
var CODE_FS = 12.5;
|
|
20
|
+
function renderErrorCard(errors, source, palette, theme) {
|
|
21
|
+
const c = palette[theme === "dark" ? "dark" : "light"];
|
|
22
|
+
const isTransparent = theme === "transparent";
|
|
23
|
+
const card = c.surface;
|
|
24
|
+
const codeBg = c.bg;
|
|
25
|
+
const border = c.border;
|
|
26
|
+
const danger = c.destructive ?? c.colors.red;
|
|
27
|
+
const text = c.text;
|
|
28
|
+
const muted = c.textMuted;
|
|
29
|
+
const srcLines = source.split("\n");
|
|
30
|
+
const shown = errors.slice(0, MAX_ERRORS);
|
|
31
|
+
const overflow = errors.length - shown.length;
|
|
32
|
+
const parts = [];
|
|
33
|
+
let y = PAD + 8;
|
|
34
|
+
parts.push(frownMark(PAD + 14, y + 12, danger));
|
|
35
|
+
parts.push(
|
|
36
|
+
`<text x="${PAD + 38}" y="${y + 11}" fill="${text}" font-family="${FONT_FAMILY}" font-size="16" font-weight="700">Couldn't render this diagram</text>`,
|
|
37
|
+
`<text x="${W - PAD}" y="${y + 10}" text-anchor="end" fill="${muted}" font-family="${FONT_FAMILY}" font-size="12" font-weight="600" letter-spacing="0.5">dgmo</text>`
|
|
38
|
+
);
|
|
39
|
+
y += 24;
|
|
40
|
+
const errLabel = errors.length === 1 ? "1 error" : `${errors.length} errors`;
|
|
41
|
+
parts.push(
|
|
42
|
+
`<text x="${PAD + 38}" y="${y + 4}" fill="${muted}" font-family="${FONT_FAMILY}" font-size="12.5">${errLabel} \u2014 fix the lines below and re-render</text>`
|
|
43
|
+
);
|
|
44
|
+
y += 22;
|
|
45
|
+
parts.push(
|
|
46
|
+
`<line x1="${PAD}" y1="${y}" x2="${W - PAD}" y2="${y}" stroke="${border}" stroke-width="1"/>`
|
|
47
|
+
);
|
|
48
|
+
y += 24;
|
|
49
|
+
for (const e of shown) {
|
|
50
|
+
const hasLine = e.line > 0;
|
|
51
|
+
let msgX = PAD;
|
|
52
|
+
if (hasLine) {
|
|
53
|
+
const label = e.column ? `Line ${e.line}:${e.column}` : `Line ${e.line}`;
|
|
54
|
+
const badgeW = 14 + label.length * 7;
|
|
55
|
+
parts.push(
|
|
56
|
+
`<rect x="${PAD}" y="${y - 13}" width="${badgeW}" height="19" rx="4" fill="${danger}"/>`,
|
|
57
|
+
`<text x="${PAD + badgeW / 2}" y="${y + 1}" text-anchor="middle" fill="${c.bg}" font-family="${FONT_FAMILY}" font-size="11.5" font-weight="700">${escapeXml(label)}</text>`
|
|
58
|
+
);
|
|
59
|
+
msgX = PAD + badgeW + 12;
|
|
60
|
+
}
|
|
61
|
+
const lines = wrapMessage(e.message, CONTENT_W - (msgX - PAD), CONTENT_W);
|
|
62
|
+
lines.forEach((line, i) => {
|
|
63
|
+
parts.push(
|
|
64
|
+
`<text x="${i === 0 ? msgX : PAD}" y="${y + 1}" fill="${text}" font-family="${FONT_FAMILY}" font-size="13">${escapeXml(line)}</text>`
|
|
65
|
+
);
|
|
66
|
+
if (i < lines.length - 1) y += 18;
|
|
67
|
+
});
|
|
68
|
+
y += 24;
|
|
69
|
+
if (hasLine) {
|
|
70
|
+
const CTX = 2;
|
|
71
|
+
const first = Math.max(1, e.line - CTX);
|
|
72
|
+
const last = Math.min(srcLines.length, e.line + CTX);
|
|
73
|
+
const rowH = 18;
|
|
74
|
+
const hasCaret = e.column !== void 0 && e.column > 0;
|
|
75
|
+
const gutterW = `${last}`.length * CODE_FS * MONO_CH + 16;
|
|
76
|
+
const codeX = PAD + gutterW;
|
|
77
|
+
const codeMaxW = CONTENT_W - gutterW - 12;
|
|
78
|
+
const topY = y - 14;
|
|
79
|
+
const rowCount = last - first + 1;
|
|
80
|
+
const blockH = rowCount * rowH + (hasCaret ? 14 : 0) + 10;
|
|
81
|
+
const rowParts = [];
|
|
82
|
+
let ry = y + 3;
|
|
83
|
+
for (let n = first; n <= last; n++) {
|
|
84
|
+
const raw = (srcLines[n - 1] ?? "").replace(/\t/g, " ");
|
|
85
|
+
const codeText = truncateText(raw, CODE_FS, codeMaxW);
|
|
86
|
+
const isBad = n === e.line;
|
|
87
|
+
if (isBad) {
|
|
88
|
+
rowParts.push(
|
|
89
|
+
`<rect x="${PAD + 1}" y="${ry - 13}" width="${CONTENT_W - 2}" height="${rowH}" fill="${danger}" fill-opacity="0.16"/>`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
rowParts.push(
|
|
93
|
+
`<text x="${PAD + 8}" y="${ry + 1}" fill="${isBad ? danger : muted}" font-family="${MONO_FAMILY}" font-size="${CODE_FS}" font-weight="${isBad ? 700 : 400}">${escapeXml(`${n}`)}</text>`,
|
|
94
|
+
`<text x="${codeX}" y="${ry + 1}" fill="${text}" font-family="${MONO_FAMILY}" font-size="${CODE_FS}" xml:space="preserve">${escapeXml(codeText)}</text>`
|
|
95
|
+
);
|
|
96
|
+
if (isBad && hasCaret) {
|
|
97
|
+
const caretX = codeX + (e.column - 1) * CODE_FS * MONO_CH;
|
|
98
|
+
rowParts.push(
|
|
99
|
+
`<text x="${caretX}" y="${ry + 15}" fill="${danger}" font-family="${MONO_FAMILY}" font-size="${CODE_FS}" font-weight="700">^</text>`
|
|
100
|
+
);
|
|
101
|
+
ry += 14;
|
|
102
|
+
}
|
|
103
|
+
ry += rowH;
|
|
104
|
+
}
|
|
105
|
+
parts.push(
|
|
106
|
+
`<rect x="${PAD}" y="${topY}" width="${CONTENT_W}" height="${blockH}" rx="5" fill="${codeBg}" stroke="${border}" stroke-width="1"/>`,
|
|
107
|
+
`<line x1="${codeX - 8}" y1="${topY}" x2="${codeX - 8}" y2="${topY + blockH}" stroke="${border}" stroke-width="1"/>`,
|
|
108
|
+
rowParts.join("")
|
|
109
|
+
);
|
|
110
|
+
y = topY + blockH + 10;
|
|
111
|
+
}
|
|
112
|
+
y += 14;
|
|
113
|
+
}
|
|
114
|
+
if (overflow > 0) {
|
|
115
|
+
parts.push(
|
|
116
|
+
`<text x="${PAD}" y="${y}" fill="${muted}" font-family="${FONT_FAMILY}" font-size="12.5" font-style="italic">+ ${overflow} more error${overflow === 1 ? "" : "s"}</text>`
|
|
117
|
+
);
|
|
118
|
+
y += 22;
|
|
119
|
+
}
|
|
120
|
+
y += 2;
|
|
121
|
+
parts.push(
|
|
122
|
+
`<line x1="${PAD}" y1="${y}" x2="${W - PAD}" y2="${y}" stroke="${border}" stroke-width="1"/>`
|
|
123
|
+
);
|
|
124
|
+
y += 24;
|
|
125
|
+
const encoded = encodeDiagramUrl(source);
|
|
126
|
+
const editUrl = "url" in encoded && encoded.url ? encoded.url : "https://online.diagrammo.app";
|
|
127
|
+
const iconSize = 18;
|
|
128
|
+
const linkColor = c.colors.blue ?? c.text;
|
|
129
|
+
parts.push(
|
|
130
|
+
`<a href="${escapeXml(editUrl)}" target="_blank" rel="noopener noreferrer">` + diagrammoIcon(PAD, y - 14, iconSize) + `<text x="${PAD + iconSize + 8}" y="${y}" fill="${linkColor}" font-family="${FONT_FAMILY}" font-size="12.5" font-weight="600" text-decoration="underline">Edit & fix this diagram at online.diagrammo.app \u2197</text></a>`
|
|
131
|
+
);
|
|
132
|
+
y += 8;
|
|
133
|
+
const height = Math.round(y + PAD - 14);
|
|
134
|
+
const pageBg = isTransparent ? "" : `<rect width="100%" height="100%" fill="${c.bg}"/>`;
|
|
135
|
+
return [
|
|
136
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${height}" viewBox="0 0 ${W} ${height}" font-family="${FONT_FAMILY}">`,
|
|
137
|
+
pageBg,
|
|
138
|
+
`<rect x="0.5" y="0.5" width="${W - 1}" height="${height - 1}" rx="10" fill="${card}" stroke="${border}" stroke-width="1"/>`,
|
|
139
|
+
parts.join(""),
|
|
140
|
+
`</svg>`
|
|
141
|
+
].join("");
|
|
142
|
+
}
|
|
143
|
+
function wrapMessage(message, firstWidth, fullWidth) {
|
|
144
|
+
const words = message.split(/\s+/).filter(Boolean);
|
|
145
|
+
if (words.length === 0) return [""];
|
|
146
|
+
const lines = [];
|
|
147
|
+
let cur = "";
|
|
148
|
+
for (const word of words) {
|
|
149
|
+
const limit = lines.length === 0 ? firstWidth : fullWidth;
|
|
150
|
+
const test = cur ? `${cur} ${word}` : word;
|
|
151
|
+
if (measureText(test, 13) <= limit || !cur) {
|
|
152
|
+
cur = test;
|
|
153
|
+
} else {
|
|
154
|
+
lines.push(cur);
|
|
155
|
+
cur = word;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (cur) lines.push(cur);
|
|
159
|
+
return lines;
|
|
160
|
+
}
|
|
161
|
+
function frownMark(cx, cy, color) {
|
|
162
|
+
const r = 12;
|
|
163
|
+
return [
|
|
164
|
+
`<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="${color}" stroke-width="2"/>`,
|
|
165
|
+
`<circle cx="${cx - 4.5}" cy="${cy - 3}" r="1.6" fill="${color}"/>`,
|
|
166
|
+
`<circle cx="${cx + 4.5}" cy="${cy - 3}" r="1.6" fill="${color}"/>`,
|
|
167
|
+
`<path d="M ${cx - 5} ${cy + 6} Q ${cx} ${cy + 1} ${cx + 5} ${cy + 6}" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round"/>`
|
|
168
|
+
].join("");
|
|
169
|
+
}
|
|
170
|
+
function diagrammoIcon(x, y, size) {
|
|
171
|
+
const s = size / 100;
|
|
172
|
+
return `<g transform="translate(${x} ${y}) scale(${s})"><rect width="100" height="100" rx="18" fill="#1f2933"/><path d="M41 71 L41 63.51 A28 28 0 1 1 59 63.51 L59 71" fill="none" stroke="#c9a227" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"/><rect x="36" y="43" width="7" height="9" rx="1.9" fill="#c0504d"/><rect x="45" y="37" width="7" height="15" rx="1.9" fill="#5b9357"/><rect x="54" y="30" width="7" height="22" rx="1.9" fill="#3b6ea5"/><rect x="36" y="75" width="28" height="4.6" rx="2.3" fill="#7d5ba6"/><rect x="36" y="82" width="28" height="4.6" rx="2.3" fill="#7d5ba6"/><rect x="36" y="89" width="28" height="4.6" rx="2.3" fill="#7d5ba6"/></g>`;
|
|
173
|
+
}
|
|
174
|
+
function escapeXml(s) {
|
|
175
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/utils/svg-embed.ts
|
|
179
|
+
function normalizeSvgForEmbed(input) {
|
|
180
|
+
let svg = input;
|
|
181
|
+
const rootMatch = svg.match(/<svg[^>]*>/);
|
|
182
|
+
const rootTag = rootMatch?.[0] ?? "";
|
|
183
|
+
if (rootTag && !rootTag.includes("viewBox")) {
|
|
184
|
+
const wh = rootTag.match(/width="(\d+)"[^>]*height="(\d+)"/);
|
|
185
|
+
if (wh) {
|
|
186
|
+
svg = svg.replace(/<svg/, `<svg viewBox="0 0 ${wh[1]} ${wh[2]}"`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const tight = computeBBox(svg);
|
|
190
|
+
if (tight && tight.width > 0 && tight.height > 0) {
|
|
191
|
+
const pad = 16;
|
|
192
|
+
const x = tight.x - pad;
|
|
193
|
+
const y = tight.y - pad;
|
|
194
|
+
const w = tight.width + pad * 2;
|
|
195
|
+
const h = tight.height + pad * 2;
|
|
196
|
+
const canvas = readViewBox(svg);
|
|
197
|
+
const TOL = 2;
|
|
198
|
+
const MIN_COVERAGE = 0.5;
|
|
199
|
+
const trustworthy = !canvas || x >= canvas.x - TOL && y >= canvas.y - TOL && x + w <= canvas.x + canvas.width + TOL && y + h <= canvas.y + canvas.height + TOL && w >= canvas.width * MIN_COVERAGE && h >= canvas.height * MIN_COVERAGE;
|
|
200
|
+
if (trustworthy) {
|
|
201
|
+
const vb = `${x} ${y} ${w} ${h}`;
|
|
202
|
+
svg = svg.replace(/(<svg[^>]*?)viewBox="[^"]*"/, `$1viewBox="${vb}"`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
svg = svg.replace(/(<svg[^>]*?) width="[^"]*"/g, "$1");
|
|
206
|
+
svg = svg.replace(/(<svg[^>]*?) height="[^"]*"/g, "$1");
|
|
207
|
+
svg = svg.replace(/<svg\s{2,}/g, "<svg ");
|
|
208
|
+
return svg;
|
|
209
|
+
}
|
|
210
|
+
function getEmbedSvgViewBox(svg) {
|
|
211
|
+
const tight = computeBBox(svg);
|
|
212
|
+
if (!tight || tight.width <= 0 || tight.height <= 0) return null;
|
|
213
|
+
const pad = 16;
|
|
214
|
+
return {
|
|
215
|
+
x: tight.x - pad,
|
|
216
|
+
y: tight.y - pad,
|
|
217
|
+
width: tight.width + pad * 2,
|
|
218
|
+
height: tight.height + pad * 2
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function readViewBox(svg) {
|
|
222
|
+
const m = svg.match(/<svg[^>]*?\bviewBox="([^"]+)"/);
|
|
223
|
+
if (!m) return null;
|
|
224
|
+
const n = m[1].trim().split(/[\s,]+/).map(Number);
|
|
225
|
+
if (n.length !== 4 || n.some((v) => !Number.isFinite(v)) || n[2] <= 0 || n[3] <= 0)
|
|
226
|
+
return null;
|
|
227
|
+
return { x: n[0], y: n[1], width: n[2], height: n[3] };
|
|
228
|
+
}
|
|
229
|
+
function computeBBox(svg) {
|
|
230
|
+
const xs = [];
|
|
231
|
+
const ys = [];
|
|
232
|
+
function push(x, y) {
|
|
233
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
234
|
+
xs.push(x);
|
|
235
|
+
ys.push(y);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function attr(tag, name) {
|
|
239
|
+
const m = tag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
240
|
+
if (!m) return null;
|
|
241
|
+
const n = parseFloat(m[1]);
|
|
242
|
+
return Number.isFinite(n) ? n : null;
|
|
243
|
+
}
|
|
244
|
+
for (const m of svg.matchAll(/<rect\b[^>]*?\/?>/g)) {
|
|
245
|
+
const tag = m[0];
|
|
246
|
+
const x = attr(tag, "x");
|
|
247
|
+
const y = attr(tag, "y");
|
|
248
|
+
const w = attr(tag, "width");
|
|
249
|
+
const h = attr(tag, "height");
|
|
250
|
+
if (x !== null && y !== null && w !== null && h !== null) {
|
|
251
|
+
push(x, y);
|
|
252
|
+
push(x + w, y + h);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for (const m of svg.matchAll(/<line\b[^>]*?\/?>/g)) {
|
|
256
|
+
const tag = m[0];
|
|
257
|
+
const x1 = attr(tag, "x1");
|
|
258
|
+
const y1 = attr(tag, "y1");
|
|
259
|
+
const x2 = attr(tag, "x2");
|
|
260
|
+
const y2 = attr(tag, "y2");
|
|
261
|
+
if (x1 !== null && y1 !== null && x2 !== null && y2 !== null) {
|
|
262
|
+
push(x1, y1);
|
|
263
|
+
push(x2, y2);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const m of svg.matchAll(/<circle\b[^>]*?\/?>/g)) {
|
|
267
|
+
const tag = m[0];
|
|
268
|
+
const cx = attr(tag, "cx");
|
|
269
|
+
const cy = attr(tag, "cy");
|
|
270
|
+
const r = attr(tag, "r");
|
|
271
|
+
if (cx !== null && cy !== null && r !== null) {
|
|
272
|
+
push(cx - r, cy - r);
|
|
273
|
+
push(cx + r, cy + r);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
for (const m of svg.matchAll(/<ellipse\b[^>]*?\/?>/g)) {
|
|
277
|
+
const tag = m[0];
|
|
278
|
+
const cx = attr(tag, "cx");
|
|
279
|
+
const cy = attr(tag, "cy");
|
|
280
|
+
const rx = attr(tag, "rx");
|
|
281
|
+
const ry = attr(tag, "ry");
|
|
282
|
+
if (cx !== null && cy !== null && rx !== null && ry !== null) {
|
|
283
|
+
push(cx - rx, cy - ry);
|
|
284
|
+
push(cx + rx, cy + ry);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
for (const m of svg.matchAll(/<text\b([^>]*?)>([\s\S]*?)<\/text>/g)) {
|
|
288
|
+
const tag = `<text${m[1]}>`;
|
|
289
|
+
const text = m[2].replace(/<[^>]+>/g, "");
|
|
290
|
+
const x = attr(tag, "x");
|
|
291
|
+
const y = attr(tag, "y");
|
|
292
|
+
if (x !== null && y !== null) {
|
|
293
|
+
const w = text.length * 7;
|
|
294
|
+
const anchor = tag.match(/\btext-anchor="([^"]*)"/)?.[1] ?? "start";
|
|
295
|
+
const left = anchor === "middle" ? x - w / 2 : anchor === "end" ? x - w : x;
|
|
296
|
+
const right = anchor === "middle" ? x + w / 2 : anchor === "end" ? x : x + w;
|
|
297
|
+
push(left, y - 14);
|
|
298
|
+
push(right, y + 4);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
for (const m of svg.matchAll(/<path\b[^>]*?\bd="([^"]+)"/g)) {
|
|
302
|
+
const d = m[1];
|
|
303
|
+
const nums = d.match(/-?\d+(?:\.\d+)?/g);
|
|
304
|
+
if (!nums) continue;
|
|
305
|
+
for (let i = 0; i + 1 < nums.length; i += 2) {
|
|
306
|
+
push(parseFloat(nums[i]), parseFloat(nums[i + 1]));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for (const m of svg.matchAll(
|
|
310
|
+
/<(?:polygon|polyline)\b[^>]*?\bpoints="([^"]+)"/g
|
|
311
|
+
)) {
|
|
312
|
+
const nums = m[1].match(/-?\d+(?:\.\d+)?/g);
|
|
313
|
+
if (!nums) continue;
|
|
314
|
+
for (let i = 0; i + 1 < nums.length; i += 2) {
|
|
315
|
+
push(parseFloat(nums[i]), parseFloat(nums[i + 1]));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (xs.length === 0 || ys.length === 0) return null;
|
|
319
|
+
const minX = Math.min(...xs);
|
|
320
|
+
const maxX = Math.max(...xs);
|
|
321
|
+
const minY = Math.min(...ys);
|
|
322
|
+
const maxY = Math.max(...ys);
|
|
323
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export {
|
|
327
|
+
renderErrorCard,
|
|
328
|
+
normalizeSvgForEmbed,
|
|
329
|
+
getEmbedSvgViewBox
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=chunk-26RVGM44.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
stripDefaultModifier,
|
|
9
9
|
tagAttrKey,
|
|
10
10
|
validateTagGroupNames
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HBVD67XG.js";
|
|
12
12
|
import {
|
|
13
13
|
JOURNEY_MAP_REGISTRY,
|
|
14
14
|
OPTION_NOCOLON_RE,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
splitNameAndMeta,
|
|
20
20
|
warnUnknownMetaKeys,
|
|
21
21
|
withTagAliases
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZNQX6QWH.js";
|
|
23
23
|
import {
|
|
24
24
|
resolveColorWithDiagnostic
|
|
25
25
|
} from "./chunk-TLVIHFRO.js";
|
|
@@ -406,4 +406,4 @@ function parseStepLine(trimmed, lineNumber, counter, aliasMap, warn, diagnostics
|
|
|
406
406
|
export {
|
|
407
407
|
parseJourneyMap
|
|
408
408
|
};
|
|
409
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-2WMBWZY2.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
tagAttrKey,
|
|
7
7
|
validateTagGroupNames,
|
|
8
8
|
validateTagValues
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HBVD67XG.js";
|
|
10
10
|
import {
|
|
11
11
|
tryCollectNote
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-K6HNAY5V.js";
|
|
13
13
|
import {
|
|
14
14
|
resolveNotes
|
|
15
15
|
} from "./chunk-FMDSF3OV.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
tryParseSharedOption,
|
|
33
33
|
warnUnknownMetaKeys,
|
|
34
34
|
withTagAliases
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-ZNQX6QWH.js";
|
|
36
36
|
import {
|
|
37
37
|
resolveColorWithDiagnostic
|
|
38
38
|
} from "./chunk-TLVIHFRO.js";
|
|
@@ -521,4 +521,4 @@ export {
|
|
|
521
521
|
looksLikeERDiagram,
|
|
522
522
|
extractSymbols
|
|
523
523
|
};
|
|
524
|
-
//# sourceMappingURL=chunk-
|
|
524
|
+
//# sourceMappingURL=chunk-35BBZDFE.js.map
|
|
@@ -2,15 +2,15 @@ import {
|
|
|
2
2
|
parseInlineMarkdown,
|
|
3
3
|
safeHref
|
|
4
4
|
} from "./chunk-3HDBAXF5.js";
|
|
5
|
-
import {
|
|
6
|
-
renderIntegratedLegend
|
|
7
|
-
} from "./chunk-PWIHZ6NJ.js";
|
|
8
5
|
import {
|
|
9
6
|
ScaleContext
|
|
10
7
|
} from "./chunk-YYVTBZZC.js";
|
|
8
|
+
import {
|
|
9
|
+
renderIntegratedLegend
|
|
10
|
+
} from "./chunk-4UDKKGHH.js";
|
|
11
11
|
import {
|
|
12
12
|
getMaxLegendReservedHeight
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7UEMZREK.js";
|
|
14
14
|
import {
|
|
15
15
|
FONT_FAMILY
|
|
16
16
|
} from "./chunk-6KFWC4CO.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
measureText,
|
|
19
19
|
truncateText,
|
|
20
20
|
wrapTextToWidth
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-5LWQH6QV.js";
|
|
22
22
|
import {
|
|
23
23
|
contrastText,
|
|
24
24
|
mix,
|
|
@@ -1601,4 +1601,4 @@ export {
|
|
|
1601
1601
|
renderTechRadar,
|
|
1602
1602
|
renderTechRadarForExport
|
|
1603
1603
|
};
|
|
1604
|
-
//# sourceMappingURL=chunk-
|
|
1604
|
+
//# sourceMappingURL=chunk-3BIAFYD2.js.map
|