@diagrammo/dgmo 0.22.0 → 0.24.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/dist/advanced.cjs +372 -103
- package/dist/advanced.d.cts +52 -19
- package/dist/advanced.d.ts +52 -19
- package/dist/advanced.js +372 -103
- package/dist/auto.cjs +370 -97
- package/dist/auto.js +117 -117
- package/dist/auto.mjs +370 -97
- package/dist/cli.cjs +151 -151
- package/dist/editor.cjs +3 -0
- package/dist/editor.js +3 -0
- package/dist/highlight.cjs +3 -0
- package/dist/highlight.js +3 -0
- package/dist/index.cjs +498 -96
- package/dist/index.d.cts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +496 -96
- package/dist/internal.cjs +372 -103
- package/dist/internal.d.cts +52 -19
- package/dist/internal.d.ts +52 -19
- package/dist/internal.js +372 -103
- package/dist/map-data/PROVENANCE.json +1 -1
- package/dist/map-data/gazetteer.json +1 -1
- package/dist/map-data/mountain-ranges.json +1 -1
- package/dist/map-data/water-bodies.json +1 -1
- package/dist/map-data/world-coarse.json +1 -1
- package/dist/map-data/world-detail.json +1 -1
- package/docs/language-reference.md +38 -2
- package/gallery/fixtures/boxes-and-lines.dgmo +6 -4
- package/package.json +1 -1
- package/src/boxes-and-lines/parser.ts +39 -0
- package/src/boxes-and-lines/renderer.ts +219 -14
- package/src/boxes-and-lines/types.ts +9 -0
- package/src/completion.ts +4 -5
- package/src/d3.ts +26 -6
- package/src/editor/keywords.ts +3 -0
- package/src/index.ts +8 -0
- package/src/map/data/PROVENANCE.json +1 -1
- package/src/map/data/README.md +6 -0
- package/src/map/data/gazetteer.json +1 -1
- package/src/map/data/mountain-ranges.json +1 -1
- package/src/map/data/water-bodies.json +1 -1
- package/src/map/data/world-coarse.json +1 -1
- package/src/map/data/world-detail.json +1 -1
- package/src/map/dimensions.ts +21 -5
- package/src/map/layout.ts +167 -63
- package/src/map/legend-band.ts +99 -0
- package/src/map/renderer.ts +105 -32
- package/src/map/resolver.ts +43 -1
- package/src/map/types.ts +20 -0
- package/src/utils/reserved-key-registry.ts +5 -3
- package/src/utils/svg-embed.ts +193 -0
package/dist/index.d.cts
CHANGED
|
@@ -182,6 +182,42 @@ declare function getMinDimensions(content: string): {
|
|
|
182
182
|
height: number;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Make an SVG produced by `@diagrammo/dgmo`'s static `render()` suitable for
|
|
187
|
+
* responsive inline embedding in any host (Obsidian, remark/markdown, web
|
|
188
|
+
* pages):
|
|
189
|
+
*
|
|
190
|
+
* - dgmo renders diagrams inside a fixed export canvas (e.g.
|
|
191
|
+
* `viewBox="0 0 1200 800"`), with content often occupying only a fraction
|
|
192
|
+
* of it. We compute a tight content bounding box from element coordinates
|
|
193
|
+
* and set the root `viewBox` to bbox+padding, so the diagram's intrinsic
|
|
194
|
+
* aspect ratio matches its CONTENT — no dead space above/below or beside it.
|
|
195
|
+
* - Ensure the root `<svg>` has a `viewBox` so it scales responsively.
|
|
196
|
+
* - Strip fixed `width="N"` / `height="N"` so CSS (e.g. `width:100%;
|
|
197
|
+
* height:auto`, or an aspect-ratio derived from the tight viewBox) controls
|
|
198
|
+
* sizing.
|
|
199
|
+
* - Remove any inline `background:` from the root style so the page
|
|
200
|
+
* background shows through.
|
|
201
|
+
*
|
|
202
|
+
* This is intentionally a string transform, not a DOM `getBBox()` step: dgmo
|
|
203
|
+
* can dual-render light/dark SVGs where one is hidden by color-mode CSS, and
|
|
204
|
+
* `getBBox()` returns 0 for the hidden copy. Parsing coordinates from the
|
|
205
|
+
* markup measures both copies reliably and works server-side (Node).
|
|
206
|
+
*/
|
|
207
|
+
declare function normalizeSvgForEmbed(input: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Parse the content bounding box of a normalized embed SVG, if one can be
|
|
210
|
+
* derived. Returns `null` when no usable coordinates are found (e.g. an empty
|
|
211
|
+
* diagram). Useful for hosts that want to set an explicit `aspect-ratio` from
|
|
212
|
+
* the tight viewBox.
|
|
213
|
+
*/
|
|
214
|
+
declare function getEmbedSvgViewBox(svg: string): {
|
|
215
|
+
x: number;
|
|
216
|
+
y: number;
|
|
217
|
+
width: number;
|
|
218
|
+
height: number;
|
|
219
|
+
} | null;
|
|
220
|
+
|
|
185
221
|
/**
|
|
186
222
|
* A gazetteer city entry: `[lat, lon, iso, pop, name, sub?]`.
|
|
187
223
|
* - `lat`/`lon` — rounded to 3 decimals.
|
|
@@ -336,4 +372,4 @@ interface DecodedDiagramUrl {
|
|
|
336
372
|
*/
|
|
337
373
|
declare function decodeDiagramUrl(url: string): DecodedDiagramUrl | null;
|
|
338
374
|
|
|
339
|
-
export { type CompactViewState, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type EncodeDiagramUrlOptions, type Gazetteer, type GazetteerEntry, type MapCompletionOptions, type MapPlaceCompletion, type MapRegionCompletion, type PaletteColors, type PaletteConfig, type RegionName, type RegionNames, type RenderOptions, type RenderResult, type Theme, completeMapPlaces, completeMapRegions, decodeDiagramUrl, encodeDiagramUrl, formatDgmoError, getMinDimensions, getPalette, palettes, render, themes, parseDgmo as validate };
|
|
375
|
+
export { type CompactViewState, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type EncodeDiagramUrlOptions, type Gazetteer, type GazetteerEntry, type MapCompletionOptions, type MapPlaceCompletion, type MapRegionCompletion, type PaletteColors, type PaletteConfig, type RegionName, type RegionNames, type RenderOptions, type RenderResult, type Theme, completeMapPlaces, completeMapRegions, decodeDiagramUrl, encodeDiagramUrl, formatDgmoError, getEmbedSvgViewBox, getMinDimensions, getPalette, normalizeSvgForEmbed, palettes, render, themes, parseDgmo as validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -182,6 +182,42 @@ declare function getMinDimensions(content: string): {
|
|
|
182
182
|
height: number;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Make an SVG produced by `@diagrammo/dgmo`'s static `render()` suitable for
|
|
187
|
+
* responsive inline embedding in any host (Obsidian, remark/markdown, web
|
|
188
|
+
* pages):
|
|
189
|
+
*
|
|
190
|
+
* - dgmo renders diagrams inside a fixed export canvas (e.g.
|
|
191
|
+
* `viewBox="0 0 1200 800"`), with content often occupying only a fraction
|
|
192
|
+
* of it. We compute a tight content bounding box from element coordinates
|
|
193
|
+
* and set the root `viewBox` to bbox+padding, so the diagram's intrinsic
|
|
194
|
+
* aspect ratio matches its CONTENT — no dead space above/below or beside it.
|
|
195
|
+
* - Ensure the root `<svg>` has a `viewBox` so it scales responsively.
|
|
196
|
+
* - Strip fixed `width="N"` / `height="N"` so CSS (e.g. `width:100%;
|
|
197
|
+
* height:auto`, or an aspect-ratio derived from the tight viewBox) controls
|
|
198
|
+
* sizing.
|
|
199
|
+
* - Remove any inline `background:` from the root style so the page
|
|
200
|
+
* background shows through.
|
|
201
|
+
*
|
|
202
|
+
* This is intentionally a string transform, not a DOM `getBBox()` step: dgmo
|
|
203
|
+
* can dual-render light/dark SVGs where one is hidden by color-mode CSS, and
|
|
204
|
+
* `getBBox()` returns 0 for the hidden copy. Parsing coordinates from the
|
|
205
|
+
* markup measures both copies reliably and works server-side (Node).
|
|
206
|
+
*/
|
|
207
|
+
declare function normalizeSvgForEmbed(input: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Parse the content bounding box of a normalized embed SVG, if one can be
|
|
210
|
+
* derived. Returns `null` when no usable coordinates are found (e.g. an empty
|
|
211
|
+
* diagram). Useful for hosts that want to set an explicit `aspect-ratio` from
|
|
212
|
+
* the tight viewBox.
|
|
213
|
+
*/
|
|
214
|
+
declare function getEmbedSvgViewBox(svg: string): {
|
|
215
|
+
x: number;
|
|
216
|
+
y: number;
|
|
217
|
+
width: number;
|
|
218
|
+
height: number;
|
|
219
|
+
} | null;
|
|
220
|
+
|
|
185
221
|
/**
|
|
186
222
|
* A gazetteer city entry: `[lat, lon, iso, pop, name, sub?]`.
|
|
187
223
|
* - `lat`/`lon` — rounded to 3 decimals.
|
|
@@ -336,4 +372,4 @@ interface DecodedDiagramUrl {
|
|
|
336
372
|
*/
|
|
337
373
|
declare function decodeDiagramUrl(url: string): DecodedDiagramUrl | null;
|
|
338
374
|
|
|
339
|
-
export { type CompactViewState, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type EncodeDiagramUrlOptions, type Gazetteer, type GazetteerEntry, type MapCompletionOptions, type MapPlaceCompletion, type MapRegionCompletion, type PaletteColors, type PaletteConfig, type RegionName, type RegionNames, type RenderOptions, type RenderResult, type Theme, completeMapPlaces, completeMapRegions, decodeDiagramUrl, encodeDiagramUrl, formatDgmoError, getMinDimensions, getPalette, palettes, render, themes, parseDgmo as validate };
|
|
375
|
+
export { type CompactViewState, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type EncodeDiagramUrlOptions, type Gazetteer, type GazetteerEntry, type MapCompletionOptions, type MapPlaceCompletion, type MapRegionCompletion, type PaletteColors, type PaletteConfig, type RegionName, type RegionNames, type RenderOptions, type RenderResult, type Theme, completeMapPlaces, completeMapRegions, decodeDiagramUrl, encodeDiagramUrl, formatDgmoError, getEmbedSvgViewBox, getMinDimensions, getPalette, normalizeSvgForEmbed, palettes, render, themes, parseDgmo as validate };
|