@diagrammo/dgmo 0.64.1 → 0.65.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/LICENSE +1 -1
- package/dist/advanced.d.ts +6771 -0
- package/dist/advanced.js +71 -71
- package/dist/block.d.ts +142 -0
- package/dist/block.js +15 -15
- package/dist/chart-meta-D98NbYDp.d.ts +238 -0
- package/dist/chart-meta.d.ts +2 -0
- package/dist/chart-meta.js +3 -3
- package/dist/{charts-d3-ZTXJWEHI.js → charts-d3-I6OE5K3B.js} +9 -9
- package/dist/{chunk-C6DMG2V6.js → chunk-27YPE7NO.js} +28 -12
- package/dist/{chunk-RBAW7VUG.js → chunk-2EPV7CLY.js} +5 -7
- package/dist/{chunk-SCJ7CAJF.js → chunk-3HOCNSPD.js} +2 -2
- package/dist/{chunk-Z2ADWRSW.js → chunk-3PSPUYT5.js} +3 -3
- package/dist/{chunk-RBBJIHNL.js → chunk-4IE42ODL.js} +11 -11
- package/dist/{chunk-SMCUX42K.js → chunk-4TM7MWU4.js} +7 -6
- package/dist/{chunk-H3HFC3SQ.js → chunk-5GM6BZO7.js} +3 -3
- package/dist/{chunk-7T3A2UK3.js → chunk-5T7K6QND.js} +15 -16
- package/dist/{chunk-NKRCPBTJ.js → chunk-6BOPYGJC.js} +6 -6
- package/dist/{chunk-37EHGTQ2.js → chunk-6E5YZR4S.js} +18 -16
- package/dist/{chunk-MHI6W6XS.js → chunk-6IUL6LER.js} +10 -7
- package/dist/{chunk-S5RWWISJ.js → chunk-7L53J53J.js} +4 -4
- package/dist/{chunk-WDJ4HAGO.js → chunk-A6CTYC7O.js} +2 -2
- package/dist/{chunk-CDMF7P5A.js → chunk-BBCKUAUR.js} +2 -2
- package/dist/{chunk-AA4M6F2P.js → chunk-BBY57XAA.js} +3 -3
- package/dist/{chunk-NKRVFQGO.js → chunk-BDI25HWH.js} +18 -6
- package/dist/{chunk-SVR3YFM3.js → chunk-C666LP3O.js} +20 -15
- package/dist/{chunk-KRTO7NRK.js → chunk-D2WHS23S.js} +2 -2
- package/dist/{chunk-LYTEVE2N.js → chunk-DBF4IM4U.js} +20 -15
- package/dist/{chunk-PCWPYOT4.js → chunk-ET4R3AU5.js} +4 -4
- package/dist/{chunk-2KOBOIB2.js → chunk-FBD5ASMB.js} +2 -2
- package/dist/{chunk-ES66QH6J.js → chunk-FG24NXKN.js} +2 -2
- package/dist/{chunk-3CIOJ5YJ.js → chunk-FJ57274M.js} +3 -1
- package/dist/{chunk-6BVIZW5N.js → chunk-FLFBY5GN.js} +14 -12
- package/dist/{chunk-XUN3MIO3.js → chunk-G64OVYUT.js} +2 -2
- package/dist/{chunk-RQL25P3U.js → chunk-G7QZF6T3.js} +9 -9
- package/dist/{chunk-IGIJZHB6.js → chunk-GC7CBX6C.js} +6 -6
- package/dist/{chunk-B6AONGTI.js → chunk-GDQN2TPX.js} +21 -14
- package/dist/{chunk-CZUSH6NI.js → chunk-GMLSYNFP.js} +10 -9
- package/dist/{chunk-R6HCNSP6.js → chunk-GOW5VO6M.js} +2 -2
- package/dist/{chunk-SPHC4RYF.js → chunk-GXOMKWQ5.js} +10 -9
- package/dist/{chunk-MQHOKBJ6.js → chunk-IJ4FUFTR.js} +5 -5
- package/dist/{chunk-V3UQSKWJ.js → chunk-IJSFEU4J.js} +9 -9
- package/dist/{chunk-LSFZDBAP.js → chunk-IKHV5IJB.js} +2 -2
- package/dist/{chunk-LMXAB4YM.js → chunk-IZ6RWMBM.js} +9 -9
- package/dist/{chunk-6VJCURWU.js → chunk-J2EXBAPZ.js} +4 -5
- package/dist/{chunk-IX6N5MCY.js → chunk-JCL4K7AK.js} +12 -11
- package/dist/{chunk-OBKM6GIJ.js → chunk-JTUDM7S4.js} +10 -10
- package/dist/{chunk-CVVICCSB.js → chunk-L65WI4HO.js} +4 -4
- package/dist/{chunk-67D4MN2H.js → chunk-LK6LTSLH.js} +2 -2
- package/dist/{chunk-KOHIF4LD.js → chunk-MBODBL7C.js} +6 -5
- package/dist/chunk-MTGGOCND.js +638 -0
- package/dist/{chunk-VJARCVMH.js → chunk-MU3CJPJF.js} +2 -2
- package/dist/{chunk-RKTIIU7Z.js → chunk-N6XI5VTA.js} +4 -4
- package/dist/{chunk-ODUT5WMC.js → chunk-NVOU7N6C.js} +2 -2
- package/dist/{chunk-T4QXHE34.js → chunk-OWUWLZJT.js} +13 -11
- package/dist/{chunk-LDVUPGWC.js → chunk-OWVDD5EC.js} +2 -2
- package/dist/{chunk-M4HYPDER.js → chunk-P5OCINCI.js} +8 -8
- package/dist/{chunk-JU2VMFYC.js → chunk-PZOFMBF3.js} +2 -2
- package/dist/{chunk-YLK3JNWP.js → chunk-QNCXONBR.js} +2 -2
- package/dist/{chunk-DB2KQ5DN.js → chunk-QRWY5QTA.js} +5 -5
- package/dist/{chunk-I2ATN25N.js → chunk-R4XM44BW.js} +25 -16
- package/dist/{chunk-DJCZWQ2A.js → chunk-RTTZIX34.js} +4 -4
- package/dist/{chunk-OMTBYLKN.js → chunk-TPKNA2U5.js} +9 -7
- package/dist/{chunk-DN5HEDE4.js → chunk-TT5B36WO.js} +16 -20
- package/dist/{chunk-SF3JAWMY.js → chunk-TWILCDUE.js} +3 -3
- package/dist/{chunk-NIZM3LAG.js → chunk-UINRIO77.js} +10 -10
- package/dist/{chunk-5H2LIQIH.js → chunk-UJXCDF4E.js} +4 -4
- package/dist/{chunk-Z5ID35YP.js → chunk-UTCPNJND.js} +2 -4
- package/dist/{chunk-U42ZEK7L.js → chunk-V4BYBIBU.js} +24 -15
- package/dist/{chunk-L4IN4OBB.js → chunk-VLI5SYXW.js} +7 -7
- package/dist/{chunk-43E26CDA.js → chunk-VS2M72PF.js} +4 -4
- package/dist/{chunk-KZ3PCDUJ.js → chunk-VV6HZQ5K.js} +2 -2
- package/dist/{chunk-Z5BTSBWW.js → chunk-WF2HDQPG.js} +4 -4
- package/dist/{chunk-TAJ2XFTT.js → chunk-XKMCL2YJ.js} +19 -16
- package/dist/{chunk-7GUYGQR4.js → chunk-XVEPB2UU.js} +4 -4
- package/dist/{chunk-YHTKDIF2.js → chunk-YGFNITPC.js} +11 -11
- package/dist/{chunk-I24O2RWT.js → chunk-YJOOIOSR.js} +84 -14
- package/dist/{chunk-KPX2OWZR.js → chunk-YKWHUPBP.js} +13 -14
- package/dist/{chunk-FRC4LDTQ.js → chunk-YMYPFX4O.js} +36 -30
- package/dist/{chunk-VOJOARA6.js → chunk-ZZXPYVS4.js} +82 -77
- package/dist/cloud-reference.d.ts +96 -0
- package/dist/completion-registry.d.ts +129 -0
- package/dist/{dgmo-router-QWRF7ZKM.js → dgmo-router-464FE256.js} +4 -4
- package/dist/dgmo-router-Dd5PTjxl.d.ts +540 -0
- package/dist/{dimensions-ES6O2T4H.js → dimensions-ILAVBRQ3.js} +7 -7
- package/dist/{flowchart-renderer-EXMRHFTQ.js → flowchart-renderer-6JKM2FA4.js} +7 -7
- package/dist/index.d.ts +207 -0
- package/dist/index.js +15 -15
- package/dist/{layout-HBWT2G23.js → layout-4LNMXLVK.js} +3 -3
- package/dist/{layout-UU4VJTOP.js → layout-62ERBWCM.js} +3 -3
- package/dist/{layout-N6X46MWG.js → layout-6SKHNQYO.js} +4 -4
- package/dist/{layout-OH4VQ3OI.js → layout-7JULRP4Y.js} +4 -4
- package/dist/{layout-QTZO6CW5.js → layout-FA37VP7V.js} +4 -4
- package/dist/layout-IN53LAE6.js +9 -0
- package/dist/{layout-H4H4OFE4.js → layout-IO6ORC5T.js} +3 -3
- package/dist/{layout-54P3DAXY.js → layout-LVMWK4QY.js} +5 -5
- package/dist/{layout-WCOEZPOI.js → layout-MNOTDWXW.js} +4 -4
- package/dist/{layout-2T2VCCTM.js → layout-RD7GDM4I.js} +5 -5
- package/dist/{layout-SKQMIXTG.js → layout-SBQTN2YM.js} +4 -4
- package/dist/{layout-5E2NQZNM.js → layout-SGYR6HBX.js} +3 -3
- package/dist/{layout-W3ZBJOIK.js → layout-WIMQIHBU.js} +5 -5
- package/dist/{layout-search-AJ6VUVUI.js → layout-search-C44CJQOB.js} +5 -5
- package/dist/{legend-constants-QQU3QYBF.js → legend-constants-RGINV5SF.js} +3 -3
- package/dist/live-link-resolve.d.ts +73 -0
- package/dist/{parser-KSIYWKYF.js → parser-CSKF2KNO.js} +8 -4
- package/dist/{parser-2BGDJJ2L.js → parser-WLL63XH7.js} +2 -2
- package/dist/{renderer-XLEYPLVL.js → renderer-2UIQVKXK.js} +8 -8
- package/dist/{renderer-KOWVTTYR.js → renderer-3GG2DEFQ.js} +7 -7
- package/dist/{renderer-XLPNUOYA.js → renderer-6NDYVZXQ.js} +10 -10
- package/dist/{renderer-2ARNFXSC.js → renderer-6ST44AVP.js} +10 -10
- package/dist/{renderer-YLM4CGBG.js → renderer-ALP46W2X.js} +8 -8
- package/dist/{renderer-NHFRVCDC.js → renderer-AOFIEF2T.js} +9 -9
- package/dist/{renderer-HLWEJQJW.js → renderer-BEVY3UP5.js} +5 -5
- package/dist/{renderer-H6AQ4UIR.js → renderer-BXPWSNTJ.js} +13 -13
- package/dist/{renderer-BYWLJDT4.js → renderer-EWTETTII.js} +8 -8
- package/dist/{renderer-KK2534AF.js → renderer-FHXAWDNI.js} +4 -4
- package/dist/{renderer-OB77AT7V.js → renderer-FI4IKF4I.js} +7 -7
- package/dist/{renderer-DMVUBKP7.js → renderer-GHYH6DLG.js} +4 -4
- package/dist/{renderer-LSBXYOID.js → renderer-GYYJ4APT.js} +10 -10
- package/dist/{renderer-M43ROWET.js → renderer-JFOHE3YB.js} +9 -9
- package/dist/{renderer-OA7FSZ4A.js → renderer-L5QGQTLV.js} +3 -3
- package/dist/{renderer-7OOC2ZO2.js → renderer-L7S6YVM6.js} +4 -4
- package/dist/{renderer-YELZR4QT.js → renderer-LCHVBTV4.js} +12 -12
- package/dist/{renderer-IN3UPTZS.js → renderer-M4DAYNWC.js} +3 -3
- package/dist/{renderer-WN47AMUM.js → renderer-NXIK3LOA.js} +8 -8
- package/dist/{renderer-QR5343AR.js → renderer-OWUXQDHM.js} +3 -3
- package/dist/{renderer-FCO42JLK.js → renderer-PJNJOCLB.js} +8 -8
- package/dist/{renderer-OYTERGAO.js → renderer-QQBUBD66.js} +9 -9
- package/dist/{renderer-PM7JPC3J.js → renderer-REFE3YFH.js} +11 -11
- package/dist/{renderer-C6KOE774.js → renderer-RL2JGVPC.js} +10 -10
- package/dist/{renderer-ZNTLBQ45.js → renderer-RVFPPKWN.js} +9 -9
- package/dist/{renderer-QEHUJHRK.js → renderer-SFQHFPC5.js} +10 -10
- package/dist/{renderer-LO4FXQHP.js → renderer-T4CMBGA5.js} +8 -8
- package/dist/{renderer-M3PQKXK2.js → renderer-TJD6A3AK.js} +13 -13
- package/dist/{renderer-2E7LQC32.js → renderer-URPIVAPI.js} +3 -3
- package/dist/{renderer-T5CUGSXP.js → renderer-WENGQEX6.js} +7 -7
- package/dist/{renderer-WR3FA3FF.js → renderer-WR6J7NKH.js} +8 -8
- package/dist/{renderer-YBEZ5V2H.js → renderer-X3V2G4UL.js} +3 -3
- package/dist/{renderer-KPEQ72FY.js → renderer-YAW4VHAI.js} +11 -11
- package/dist/{renderer-radial-XWAKJACV.js → renderer-radial-HOUGPUPW.js} +7 -7
- package/dist/{state-renderer-LIESKSBO.js → state-renderer-JJSQJZEL.js} +11 -11
- package/dist/themes-DiUAG4Bf.d.ts +631 -0
- package/docs/ai-integration.md +1 -1
- package/docs/language-reference.md +5 -0
- package/gallery/fixtures/er.dgmo +1 -1
- package/package.json +5 -3
- package/dist/chunk-4ASYQ347.js +0 -185
- package/dist/layout-5XGYNYVT.js +0 -9
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { D as DiagnosticSpec, P as PaletteConfig, C as CompactViewState, a as DgmoError } from './dgmo-router-Dd5PTjxl.js';
|
|
2
|
+
export { b as ChartTypeId, c as ChartTypeMeta, d as DgmoSeverity, e as DiagnosticParams, E as EmitOptions, f as PaletteColors, g as chartTypes, h as emit, i as formatDgmoError, j as getPalette, r as resolvePaletteOrFallback, p as validate } from './dgmo-router-Dd5PTjxl.js';
|
|
3
|
+
import { T as Theme, M as MapDataSource } from './themes-DiUAG4Bf.js';
|
|
4
|
+
export { G as Gazetteer, a as GazetteerEntry, b as MapCompletionOptions, c as MapData, d as MapLocationMatch, e as MapPlaceCompletion, f as MapRegionCompletion, R as RegionName, g as RegionNames, h as completeMapPlaces, i as completeMapRegions, p as palettes, s as searchMapLocations, t as themes } from './themes-DiUAG4Bf.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Make an SVG produced by `@diagrammo/dgmo`'s static `render()` suitable for
|
|
8
|
+
* responsive inline embedding in any host (Obsidian, remark/markdown, web
|
|
9
|
+
* pages):
|
|
10
|
+
*
|
|
11
|
+
* - dgmo renders diagrams inside a fixed export canvas (e.g.
|
|
12
|
+
* `viewBox="0 0 1200 800"`), with content often occupying only a fraction
|
|
13
|
+
* of it. We compute a tight content bounding box from element coordinates
|
|
14
|
+
* and set the root `viewBox` to bbox+padding, so the diagram's intrinsic
|
|
15
|
+
* aspect ratio matches its CONTENT — no dead space above/below or beside it.
|
|
16
|
+
* - Ensure the root `<svg>` has a `viewBox` so it scales responsively.
|
|
17
|
+
* - Strip fixed `width="N"` / `height="N"` so CSS (e.g. `width:100%;
|
|
18
|
+
* height:auto`, or an aspect-ratio derived from the tight viewBox) controls
|
|
19
|
+
* sizing.
|
|
20
|
+
* - The root background (the theme's opaque `palette.bg` — both the inline
|
|
21
|
+
* `background:` style and the full-canvas `<rect>` some renderers paint) is
|
|
22
|
+
* STRIPPED by default so the embed inherits the host page surface and blends
|
|
23
|
+
* into Obsidian / doc-site / arbitrary pages instead of showing a mismatched
|
|
24
|
+
* rectangle. Pass `{ background: 'opaque' }` to keep it — the embedder
|
|
25
|
+
* opt-out, and the automatic default for background-meaningful types like
|
|
26
|
+
* `map` (whose bg is the ocean) via `defaultEmbedBackground`. Standalone
|
|
27
|
+
* PNG/SVG export does NOT go through here and stays opaque.
|
|
28
|
+
*
|
|
29
|
+
* This is intentionally a string transform, not a DOM `getBBox()` step: dgmo
|
|
30
|
+
* can dual-render light/dark SVGs where one is hidden by color-mode CSS, and
|
|
31
|
+
* `getBBox()` returns 0 for the hidden copy. Parsing coordinates from the
|
|
32
|
+
* markup measures both copies reliably and works server-side (Node).
|
|
33
|
+
*/
|
|
34
|
+
interface NormalizeSvgForEmbedOptions {
|
|
35
|
+
/**
|
|
36
|
+
* `transparent` (default) strips the theme's opaque root background so the
|
|
37
|
+
* embed inherits the host page surface. `opaque` preserves it — the embedder
|
|
38
|
+
* opt-out for diagrams that need their own solid backdrop. Callers that know
|
|
39
|
+
* the chart type should resolve this via `defaultEmbedBackground`.
|
|
40
|
+
*/
|
|
41
|
+
background?: 'transparent' | 'opaque';
|
|
42
|
+
}
|
|
43
|
+
declare function normalizeSvgForEmbed(input: string, opts?: NormalizeSvgForEmbedOptions): string;
|
|
44
|
+
/**
|
|
45
|
+
* The embed background an embedder gets by default for a given chart type:
|
|
46
|
+
* `transparent` (blend into the host) for everything except
|
|
47
|
+
* background-meaningful types, which stay `opaque`.
|
|
48
|
+
*/
|
|
49
|
+
declare function defaultEmbedBackground(chartType?: string): 'transparent' | 'opaque';
|
|
50
|
+
/**
|
|
51
|
+
* Parse the content bounding box of a normalized embed SVG, if one can be
|
|
52
|
+
* derived. Returns `null` when no usable coordinates are found (e.g. an empty
|
|
53
|
+
* diagram). Useful for hosts that want to set an explicit `aspect-ratio` from
|
|
54
|
+
* the tight viewBox.
|
|
55
|
+
*/
|
|
56
|
+
declare function getEmbedSvgViewBox(svg: string): {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
} | null;
|
|
62
|
+
|
|
63
|
+
interface MountD3Opts {
|
|
64
|
+
theme?: 'light' | 'dark' | 'transparent';
|
|
65
|
+
palette?: string;
|
|
66
|
+
/** Forwarded to the interaction adapter: source-line navigation on click. */
|
|
67
|
+
onNavigate?: (line: number) => void;
|
|
68
|
+
mutedColor?: string;
|
|
69
|
+
surface?: string;
|
|
70
|
+
text?: string;
|
|
71
|
+
}
|
|
72
|
+
interface MountedD3Chart {
|
|
73
|
+
/** Re-render with new content and/or theme/palette; re-attaches interactions. */
|
|
74
|
+
update: (content: string, opts?: Partial<MountD3Opts>) => Promise<void>;
|
|
75
|
+
/** Emphasize the chart element on the given source line (editor cursor sync);
|
|
76
|
+
* pass null to clear. */
|
|
77
|
+
highlight: (line: number | null) => void;
|
|
78
|
+
/** Tear down listeners + overlays and clear the container. */
|
|
79
|
+
destroy: () => void;
|
|
80
|
+
}
|
|
81
|
+
declare function mountD3DataChart(container: HTMLElement, content: string, opts?: MountD3Opts): MountedD3Chart;
|
|
82
|
+
|
|
83
|
+
interface DataChartInteractionOpts {
|
|
84
|
+
onNavigate?: (line: number) => void;
|
|
85
|
+
mutedColor?: string;
|
|
86
|
+
surface?: string;
|
|
87
|
+
text?: string;
|
|
88
|
+
}
|
|
89
|
+
interface DataChartController {
|
|
90
|
+
/** Remove all listeners + overlays. */
|
|
91
|
+
destroy: () => void;
|
|
92
|
+
/** Emphasize the chart element(s) on the given source line (editor cursor
|
|
93
|
+
* sync); pass null to clear. No-op while the pointer is actively hovering. */
|
|
94
|
+
highlight: (line: number | null) => void;
|
|
95
|
+
}
|
|
96
|
+
declare function attachDataChartInteractions(svg: SVGSVGElement, opts?: DataChartInteractionOpts): DataChartController;
|
|
97
|
+
|
|
98
|
+
/** All data-chart types the hand-built renderers currently cover. */
|
|
99
|
+
declare const D3_DATA_CHART_TYPES: Set<string>;
|
|
100
|
+
declare function supportsD3DataChart(type: string): boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The full diagnostic catalog, sorted by code. Every coded diagnostic
|
|
104
|
+
* dgmo can emit — its severity, owning chart type, canonical message,
|
|
105
|
+
* fix hint, and a triggering example. This is the enumerable source of
|
|
106
|
+
* truth for the CLI `diagnostics` subcommand, the console error-review
|
|
107
|
+
* surface, MCP, and the language-spec catalog.
|
|
108
|
+
*/
|
|
109
|
+
declare function listDiagnosticCodes(): DiagnosticSpec[];
|
|
110
|
+
/** Look up a single spec by its code, or `undefined` if not cataloged. */
|
|
111
|
+
declare function getDiagnosticSpec(code: string): DiagnosticSpec | undefined;
|
|
112
|
+
|
|
113
|
+
interface RenderOptions {
|
|
114
|
+
theme?: Theme;
|
|
115
|
+
/**
|
|
116
|
+
* A `PaletteConfig` (e.g. `palettes.catppuccin`) or a palette id string
|
|
117
|
+
* (e.g. `'catppuccin'`). Unknown ids fall back to the default palette.
|
|
118
|
+
*/
|
|
119
|
+
palette?: PaletteConfig | string;
|
|
120
|
+
/**
|
|
121
|
+
* How to handle parse errors:
|
|
122
|
+
* 'svg' — render an inline error SVG (default)
|
|
123
|
+
* 'silent' — return empty svg + diagnostics; caller handles UI
|
|
124
|
+
* 'throw' — throw an Error with the diagnostics
|
|
125
|
+
*/
|
|
126
|
+
onError?: 'svg' | 'silent' | 'throw';
|
|
127
|
+
/**
|
|
128
|
+
* Pre-applied interactive view state — collapsed sections/columns,
|
|
129
|
+
* active swimlane tag-group, etc. Used to render a specific view
|
|
130
|
+
* non-interactively (server-side render, share-link decode).
|
|
131
|
+
*/
|
|
132
|
+
viewState?: CompactViewState;
|
|
133
|
+
/**
|
|
134
|
+
* Canvas to draw onto, in px. Defaults to the 1200x800 export sheet.
|
|
135
|
+
*
|
|
136
|
+
* Omit these and nothing changes. Pass them when the result is going into a
|
|
137
|
+
* box whose shape you already know — fitting the default sheet to a narrow
|
|
138
|
+
* column inherits its aspect, so a one-line meter arrives as tall as a poster.
|
|
139
|
+
*/
|
|
140
|
+
width?: number;
|
|
141
|
+
height?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Basemap assets for `map` charts — the data itself, or a loader returning
|
|
144
|
+
* it. `render()` reads nothing from the filesystem or the network on its own,
|
|
145
|
+
* so this is the only way a map obtains a basemap, and its presence here is
|
|
146
|
+
* what tells a caller whether a render can touch the environment.
|
|
147
|
+
*
|
|
148
|
+
* - Node / CLI / SSR: pass the `loadMapData` loader from
|
|
149
|
+
* `@diagrammo/dgmo/advanced`. It runs only when the content really is a
|
|
150
|
+
* map, so a non-map render never pays to read the assets.
|
|
151
|
+
* - Browser / Worker / Obsidian: pass your bundled `MapData`.
|
|
152
|
+
*
|
|
153
|
+
* Omit it and a map renders empty with an `E_MAP_DATA_NOT_SUPPLIED`
|
|
154
|
+
* diagnostic. Every other chart type ignores this option.
|
|
155
|
+
*/
|
|
156
|
+
mapData?: MapDataSource;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface RenderResult {
|
|
160
|
+
svg: string;
|
|
161
|
+
diagnostics: DgmoError[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Render DGMO source to an SVG string.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { render, palettes, themes } from '@diagrammo/dgmo';
|
|
169
|
+
*
|
|
170
|
+
* const { svg } = await render(text, {
|
|
171
|
+
* palette: palettes.catppuccin,
|
|
172
|
+
* theme: themes.dark,
|
|
173
|
+
* });
|
|
174
|
+
* document.getElementById('chart').innerHTML = svg;
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function render(text: string, options?: RenderOptions): Promise<RenderResult>;
|
|
178
|
+
|
|
179
|
+
interface EncodeDiagramUrlOptions {
|
|
180
|
+
baseUrl?: string;
|
|
181
|
+
palette?: PaletteConfig;
|
|
182
|
+
theme?: Theme;
|
|
183
|
+
filename?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Initial view state to embed in the URL — re-applied when the link is
|
|
186
|
+
* decoded so recipients open the diagram in the same configuration.
|
|
187
|
+
*/
|
|
188
|
+
viewState?: CompactViewState;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Encode DGMO text into a shareable URL. Returns null if the compressed
|
|
192
|
+
* payload exceeds the 8 KB URL limit.
|
|
193
|
+
*/
|
|
194
|
+
declare function encodeDiagramUrl(text: string, options?: EncodeDiagramUrlOptions): string | null;
|
|
195
|
+
interface DecodedDiagramUrl {
|
|
196
|
+
text: string;
|
|
197
|
+
palette?: PaletteConfig;
|
|
198
|
+
theme?: Theme;
|
|
199
|
+
filename?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Decode a share URL back into DGMO text plus optional palette/theme/filename.
|
|
203
|
+
* Returns null if the URL contains no valid DGMO payload.
|
|
204
|
+
*/
|
|
205
|
+
declare function decodeDiagramUrl(url: string): DecodedDiagramUrl | null;
|
|
206
|
+
|
|
207
|
+
export { CompactViewState, D3_DATA_CHART_TYPES, type DataChartInteractionOpts, type DecodedDiagramUrl, DgmoError, DiagnosticSpec, type EncodeDiagramUrlOptions, MapDataSource, type MountD3Opts, type MountedD3Chart, type NormalizeSvgForEmbedOptions, PaletteConfig, type RenderOptions, type RenderResult, Theme, attachDataChartInteractions, decodeDiagramUrl, defaultEmbedBackground, encodeDiagramUrl, getDiagnosticSpec, getEmbedSvgViewBox, listDiagnosticCodes, mountD3DataChart, normalizeSvgForEmbed, render, supportsD3DataChart };
|
package/dist/index.js
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
} from "./chunk-SQAG3UXH.js";
|
|
12
12
|
import {
|
|
13
13
|
render
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZZXPYVS4.js";
|
|
15
15
|
import {
|
|
16
16
|
renderErrorCard
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7L53J53J.js";
|
|
18
18
|
import {
|
|
19
19
|
MAP_DIAGNOSTICS
|
|
20
20
|
} from "./chunk-EOYPX6SF.js";
|
|
@@ -22,27 +22,27 @@ import {
|
|
|
22
22
|
D3_DATA_CHART_TYPES,
|
|
23
23
|
renderDataChartD3,
|
|
24
24
|
supportsD3DataChart
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-5T7K6QND.js";
|
|
26
|
+
import "./chunk-L65WI4HO.js";
|
|
27
|
+
import "./chunk-TPKNA2U5.js";
|
|
28
28
|
import "./chunk-YRYKTYMQ.js";
|
|
29
29
|
import "./chunk-YYVTBZZC.js";
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-LK6LTSLH.js";
|
|
31
|
+
import "./chunk-J2EXBAPZ.js";
|
|
32
32
|
import "./chunk-RU2HHHYA.js";
|
|
33
33
|
import "./chunk-A4GOY3PE.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
36
|
-
import "./chunk-
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
34
|
+
import "./chunk-2EPV7CLY.js";
|
|
35
|
+
import "./chunk-FG24NXKN.js";
|
|
36
|
+
import "./chunk-UTCPNJND.js";
|
|
37
|
+
import "./chunk-3HOCNSPD.js";
|
|
38
|
+
import "./chunk-MTGGOCND.js";
|
|
39
39
|
import {
|
|
40
40
|
decodeDiagramUrl,
|
|
41
41
|
encodeDiagramUrl
|
|
42
42
|
} from "./chunk-U7VO6JAA.js";
|
|
43
43
|
import {
|
|
44
44
|
parseDgmo
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-BBY57XAA.js";
|
|
46
46
|
import "./chunk-2CMM36O7.js";
|
|
47
47
|
import "./chunk-A2RUBBVT.js";
|
|
48
48
|
import "./chunk-JWJBWNQL.js";
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
PERT_DIAGNOSTICS
|
|
85
85
|
} from "./chunk-VXBEG3IB.js";
|
|
86
86
|
import "./chunk-3TYUXC7D.js";
|
|
87
|
-
import "./chunk-
|
|
87
|
+
import "./chunk-FLFBY5GN.js";
|
|
88
88
|
import {
|
|
89
89
|
EVENT_LINE_DIAGNOSTICS
|
|
90
90
|
} from "./chunk-QMYJO4EL.js";
|
|
@@ -107,7 +107,7 @@ import {
|
|
|
107
107
|
import "./chunk-SR7NGZNM.js";
|
|
108
108
|
import "./chunk-NXMESY4J.js";
|
|
109
109
|
import "./chunk-EK4QX7NQ.js";
|
|
110
|
-
import "./chunk-
|
|
110
|
+
import "./chunk-BDI25HWH.js";
|
|
111
111
|
import "./chunk-QE4GTFZS.js";
|
|
112
112
|
import "./chunk-7NK42OIB.js";
|
|
113
113
|
import {
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
fixEdgeWaypoints,
|
|
3
3
|
layoutInfra,
|
|
4
4
|
separateGroups
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-VS2M72PF.js";
|
|
6
|
+
import "./chunk-MTGGOCND.js";
|
|
7
7
|
import "./chunk-5WRI5ZAA.js";
|
|
8
8
|
export {
|
|
9
9
|
fixEdgeWaypoints,
|
|
10
10
|
layoutInfra,
|
|
11
11
|
separateGroups
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=layout-
|
|
13
|
+
//# sourceMappingURL=layout-4LNMXLVK.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutMindmap
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V4BYBIBU.js";
|
|
4
4
|
import "./chunk-YYVTBZZC.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-MTGGOCND.js";
|
|
6
6
|
import "./chunk-IYULMRBE.js";
|
|
7
7
|
import "./chunk-MDI5FMWO.js";
|
|
8
8
|
import "./chunk-P2PUWV3Y.js";
|
|
@@ -12,4 +12,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
12
12
|
export {
|
|
13
13
|
layoutMindmap
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=layout-
|
|
15
|
+
//# sourceMappingURL=layout-62ERBWCM.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
focusFamily,
|
|
3
3
|
layoutFamily
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RTTZIX34.js";
|
|
5
5
|
import "./chunk-IVKC4GID.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-FJ57274M.js";
|
|
7
|
+
import "./chunk-MTGGOCND.js";
|
|
8
8
|
import "./chunk-QQJUTGQH.js";
|
|
9
9
|
import "./chunk-5WRI5ZAA.js";
|
|
10
10
|
export {
|
|
11
11
|
focusFamily,
|
|
12
12
|
layoutFamily
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=layout-
|
|
14
|
+
//# sourceMappingURL=layout-6SKHNQYO.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutOrg
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-N6XI5VTA.js";
|
|
4
|
+
import "./chunk-3HOCNSPD.js";
|
|
5
|
+
import "./chunk-MTGGOCND.js";
|
|
6
6
|
import "./chunk-MDI5FMWO.js";
|
|
7
7
|
import "./chunk-P2PUWV3Y.js";
|
|
8
8
|
import "./chunk-42IT4BG2.js";
|
|
@@ -12,4 +12,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
12
12
|
export {
|
|
13
13
|
layoutOrg
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=layout-
|
|
15
|
+
//# sourceMappingURL=layout-7JULRP4Y.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IKHV5IJB.js";
|
|
4
4
|
import "./chunk-6EK55ART.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-MU3CJPJF.js";
|
|
6
6
|
import "./chunk-5DH3KYFH.js";
|
|
7
7
|
import "./chunk-NCT22MOD.js";
|
|
8
8
|
import "./chunk-WGC42WJU.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-MTGGOCND.js";
|
|
10
10
|
import "./chunk-NXMESY4J.js";
|
|
11
11
|
import "./chunk-QE4GTFZS.js";
|
|
12
12
|
import "./chunk-7NK42OIB.js";
|
|
@@ -18,4 +18,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
18
18
|
export {
|
|
19
19
|
layoutGraph
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=layout-
|
|
21
|
+
//# sourceMappingURL=layout-FA37VP7V.js.map
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
layoutJourneyMap,
|
|
4
4
|
scoreToColor,
|
|
5
5
|
scoreToCurveY
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-D2WHS23S.js";
|
|
7
|
+
import "./chunk-MTGGOCND.js";
|
|
8
8
|
import "./chunk-P2PUWV3Y.js";
|
|
9
9
|
import "./chunk-42IT4BG2.js";
|
|
10
10
|
import "./chunk-EXNKNJ65.js";
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
scoreToColor,
|
|
17
17
|
scoreToCurveY
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=layout-
|
|
19
|
+
//# sourceMappingURL=layout-IO6ORC5T.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutERDiagram
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UJXCDF4E.js";
|
|
4
|
+
import "./chunk-OWVDD5EC.js";
|
|
5
5
|
import "./chunk-6EK55ART.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-MU3CJPJF.js";
|
|
7
7
|
import "./chunk-5DH3KYFH.js";
|
|
8
8
|
import "./chunk-NCT22MOD.js";
|
|
9
9
|
import "./chunk-WGC42WJU.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-MTGGOCND.js";
|
|
11
11
|
import "./chunk-7NK42OIB.js";
|
|
12
12
|
import "./chunk-NOTA6TEI.js";
|
|
13
13
|
import "./chunk-OLMWTJVU.js";
|
|
@@ -15,4 +15,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
15
15
|
export {
|
|
16
16
|
layoutERDiagram
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=layout-
|
|
18
|
+
//# sourceMappingURL=layout-LVMWK4QY.js.map
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
layoutC4Context,
|
|
7
7
|
layoutC4Deployment,
|
|
8
8
|
rollUpContextRelationships
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-TWILCDUE.js";
|
|
10
|
+
import "./chunk-3HOCNSPD.js";
|
|
11
|
+
import "./chunk-MTGGOCND.js";
|
|
12
12
|
import "./chunk-MDI5FMWO.js";
|
|
13
13
|
import "./chunk-P2PUWV3Y.js";
|
|
14
14
|
import "./chunk-42IT4BG2.js";
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
layoutC4Deployment,
|
|
25
25
|
rollUpContextRelationships
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=layout-
|
|
27
|
+
//# sourceMappingURL=layout-MNOTDWXW.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computeNodeSize,
|
|
3
3
|
layoutBoxesAndLines
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WF2HDQPG.js";
|
|
5
5
|
import "./chunk-WTTIODDV.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-OWVDD5EC.js";
|
|
7
7
|
import "./chunk-6EK55ART.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-MU3CJPJF.js";
|
|
9
9
|
import "./chunk-5DH3KYFH.js";
|
|
10
10
|
import "./chunk-NCT22MOD.js";
|
|
11
11
|
import "./chunk-WGC42WJU.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-MTGGOCND.js";
|
|
13
13
|
import "./chunk-7NK42OIB.js";
|
|
14
14
|
import "./chunk-NOTA6TEI.js";
|
|
15
15
|
import "./chunk-OLMWTJVU.js";
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
computeNodeSize,
|
|
19
19
|
layoutBoxesAndLines
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=layout-
|
|
21
|
+
//# sourceMappingURL=layout-RD7GDM4I.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutSitemap
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-MBODBL7C.js";
|
|
4
|
+
import "./chunk-3HOCNSPD.js";
|
|
5
|
+
import "./chunk-MTGGOCND.js";
|
|
6
6
|
import "./chunk-MDI5FMWO.js";
|
|
7
7
|
import "./chunk-P2PUWV3Y.js";
|
|
8
8
|
import "./chunk-42IT4BG2.js";
|
|
@@ -12,4 +12,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
12
12
|
export {
|
|
13
13
|
layoutSitemap
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=layout-
|
|
15
|
+
//# sourceMappingURL=layout-SBQTN2YM.js.map
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
computeNodeSizing,
|
|
3
3
|
layoutPert,
|
|
4
4
|
relayoutPert
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-GOW5VO6M.js";
|
|
6
|
+
import "./chunk-MTGGOCND.js";
|
|
7
7
|
import "./chunk-3TYUXC7D.js";
|
|
8
8
|
import "./chunk-EQW6HOP4.js";
|
|
9
9
|
import "./chunk-5WRI5ZAA.js";
|
|
@@ -12,4 +12,4 @@ export {
|
|
|
12
12
|
layoutPert,
|
|
13
13
|
relayoutPert
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=layout-
|
|
15
|
+
//# sourceMappingURL=layout-SGYR6HBX.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layoutClassDiagram
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ET4R3AU5.js";
|
|
4
|
+
import "./chunk-OWVDD5EC.js";
|
|
5
5
|
import "./chunk-6EK55ART.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-MU3CJPJF.js";
|
|
7
7
|
import "./chunk-5DH3KYFH.js";
|
|
8
8
|
import "./chunk-NCT22MOD.js";
|
|
9
9
|
import "./chunk-WGC42WJU.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-MTGGOCND.js";
|
|
11
11
|
import "./chunk-7NK42OIB.js";
|
|
12
12
|
import "./chunk-NOTA6TEI.js";
|
|
13
13
|
import "./chunk-OLMWTJVU.js";
|
|
@@ -15,4 +15,4 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
15
15
|
export {
|
|
16
16
|
layoutClassDiagram
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=layout-
|
|
18
|
+
//# sourceMappingURL=layout-WIMQIHBU.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
EDGE_LABEL_FONT_SIZE,
|
|
3
3
|
computeNodeSize,
|
|
4
4
|
measureEdgeLabel
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WF2HDQPG.js";
|
|
6
6
|
import {
|
|
7
7
|
groupedTierCandidates
|
|
8
8
|
} from "./chunk-W4EKQ2P6.js";
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
NODE_HEIGHT,
|
|
11
11
|
NODE_WIDTH
|
|
12
12
|
} from "./chunk-WTTIODDV.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-OWVDD5EC.js";
|
|
14
14
|
import "./chunk-6EK55ART.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-MU3CJPJF.js";
|
|
16
16
|
import "./chunk-5DH3KYFH.js";
|
|
17
17
|
import "./chunk-NCT22MOD.js";
|
|
18
18
|
import "./chunk-WGC42WJU.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-MTGGOCND.js";
|
|
20
20
|
import "./chunk-7NK42OIB.js";
|
|
21
21
|
import "./chunk-NOTA6TEI.js";
|
|
22
22
|
import "./chunk-OLMWTJVU.js";
|
|
@@ -1807,4 +1807,4 @@ export {
|
|
|
1807
1807
|
layoutBoxesAndLinesSearch,
|
|
1808
1808
|
separateGroupBands
|
|
1809
1809
|
};
|
|
1810
|
-
//# sourceMappingURL=layout-search-
|
|
1810
|
+
//# sourceMappingURL=layout-search-C44CJQOB.js.map
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
legendChromeColors,
|
|
22
22
|
measureLegendText,
|
|
23
23
|
truncateLegendText
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-3HOCNSPD.js";
|
|
25
|
+
import "./chunk-MTGGOCND.js";
|
|
26
26
|
import "./chunk-42IT4BG2.js";
|
|
27
27
|
import "./chunk-EXNKNJ65.js";
|
|
28
28
|
import "./chunk-OLMWTJVU.js";
|
|
@@ -51,4 +51,4 @@ export {
|
|
|
51
51
|
measureLegendText,
|
|
52
52
|
truncateLegendText
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=legend-constants-
|
|
54
|
+
//# sourceMappingURL=legend-constants-RGINV5SF.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CloudReferenceSource, CloudReference } from './cloud-reference.js';
|
|
2
|
+
|
|
3
|
+
/** Default per-request timeout. A build waits; a reader should not. */
|
|
4
|
+
declare const DEFAULT_LIVE_LINK_TIMEOUT_MS = 10000;
|
|
5
|
+
/**
|
|
6
|
+
* What the source endpoint said, once it has been read.
|
|
7
|
+
*
|
|
8
|
+
* Four outcomes, and the split is the whole point — a host that cannot tell
|
|
9
|
+
* `gone` from `unavailable` will either keep publishing something its author
|
|
10
|
+
* withdrew, or throw away a good copy because one request was dropped.
|
|
11
|
+
*/
|
|
12
|
+
type LiveLinkFetch =
|
|
13
|
+
/** 200, and the body was the shape we expect. */
|
|
14
|
+
{
|
|
15
|
+
kind: 'ok';
|
|
16
|
+
entry: CloudReferenceSource;
|
|
17
|
+
}
|
|
18
|
+
/** 410 — the author withdrew it. Deliberate, and not a failure. */
|
|
19
|
+
| {
|
|
20
|
+
kind: 'gone';
|
|
21
|
+
}
|
|
22
|
+
/** 404 — no such published diagram. A typo, or never published. */
|
|
23
|
+
| {
|
|
24
|
+
kind: 'missing';
|
|
25
|
+
}
|
|
26
|
+
/** Network, timeout, 5xx, 429, or a body we could not read. Try again later. */
|
|
27
|
+
| {
|
|
28
|
+
kind: 'unavailable';
|
|
29
|
+
reason: string;
|
|
30
|
+
};
|
|
31
|
+
interface LiveLinkFetchOptions {
|
|
32
|
+
/** Cloud API origin. Default: the public one. */
|
|
33
|
+
base?: string;
|
|
34
|
+
/** Per-request timeout in milliseconds. */
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The HTTP call. Defaults to `globalThis.fetch` **bound to the global**.
|
|
38
|
+
*
|
|
39
|
+
* 🔴 The binding is not tidiness. `fetch` is a WebIDL operation whose `this`
|
|
40
|
+
* must be the global object, so holding it on an options bag and calling
|
|
41
|
+
* `opts.fetchImpl(url)` passes the bag as `this` and throws
|
|
42
|
+
* `Illegal invocation`. That exact bug shipped in every release of the browser
|
|
43
|
+
* refresh path and was invisible for the feature's whole lifetime, because the
|
|
44
|
+
* throw landed in a catch that reads any failure as "offline or CSP-blocked".
|
|
45
|
+
* Node's fetch happens to tolerate a wrong `this`, which is precisely why the
|
|
46
|
+
* browser half was never caught by a build.
|
|
47
|
+
*
|
|
48
|
+
* A host with its own client adapts it here. Obsidian's `requestUrl` becomes
|
|
49
|
+
* roughly `async (url) => { const r = await requestUrl({ url, throw: false });
|
|
50
|
+
* return new Response(r.text, { status: r.status }); }` — and note
|
|
51
|
+
* `throw: false`, because `requestUrl` throws on 400+ by default, which would
|
|
52
|
+
* turn the 410 above into an exception indistinguishable from being offline.
|
|
53
|
+
*/
|
|
54
|
+
fetchImpl?: typeof fetch;
|
|
55
|
+
/**
|
|
56
|
+
* Extra attempts after an `unavailable` answer. Default 1.
|
|
57
|
+
*
|
|
58
|
+
* A retry belongs here rather than with the host because it is a reading of
|
|
59
|
+
* the response — 429 and 5xx are the server saying "not right now", which is
|
|
60
|
+
* different from "no". Anything beyond one retry is a host's patience budget:
|
|
61
|
+
* set 0 when a person is waiting.
|
|
62
|
+
*/
|
|
63
|
+
retries?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Ask the Cloud for a live link's current source, and say what came back.
|
|
67
|
+
*
|
|
68
|
+
* Never throws: every way this can fail is one of the four outcomes, because a
|
|
69
|
+
* caller that has to tell a rejected promise from a 410 will get it wrong.
|
|
70
|
+
*/
|
|
71
|
+
declare function fetchLiveLink(ref: CloudReference, options?: LiveLinkFetchOptions): Promise<LiveLinkFetch>;
|
|
72
|
+
|
|
73
|
+
export { DEFAULT_LIVE_LINK_TIMEOUT_MS, type LiveLinkFetch, type LiveLinkFetchOptions, fetchLiveLink };
|