@diagrammo/dgmo 0.20.3 → 0.21.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 +329 -109
- package/dist/advanced.d.cts +66 -25
- package/dist/advanced.d.ts +66 -25
- package/dist/advanced.js +329 -109
- package/dist/auto.cjs +332 -107
- package/dist/auto.js +109 -109
- package/dist/auto.mjs +332 -107
- package/dist/cli.cjs +151 -151
- package/dist/editor.cjs +5 -2
- package/dist/editor.js +5 -2
- package/dist/highlight.cjs +5 -2
- package/dist/highlight.js +5 -2
- package/dist/index.cjs +326 -104
- package/dist/index.js +326 -104
- package/dist/internal.cjs +329 -109
- package/dist/internal.d.cts +66 -25
- package/dist/internal.d.ts +66 -25
- package/dist/internal.js +329 -109
- package/gallery/fixtures/map-choropleth.dgmo +7 -7
- package/gallery/fixtures/map-pois.dgmo +4 -4
- package/gallery/fixtures/map-region-scope.dgmo +8 -8
- package/gallery/fixtures/map-route.dgmo +5 -6
- package/package.json +1 -1
- package/src/completion.ts +9 -4
- package/src/editor/keywords.ts +5 -2
- package/src/map/layout.ts +141 -67
- package/src/map/parser.ts +122 -33
- package/src/map/renderer.ts +13 -6
- package/src/map/resolved-types.ts +13 -2
- package/src/map/resolver.ts +179 -34
- package/src/map/types.ts +39 -14
- package/src/utils/reserved-key-registry.ts +7 -7
package/dist/internal.d.cts
CHANGED
|
@@ -4268,8 +4268,12 @@ interface MapScale {
|
|
|
4268
4268
|
interface MapDirectives {
|
|
4269
4269
|
region?: string;
|
|
4270
4270
|
projection?: string;
|
|
4271
|
-
metric
|
|
4272
|
-
|
|
4271
|
+
/** Legend label for the region value ramp (`region-metric <label>`). */
|
|
4272
|
+
regionMetric?: string;
|
|
4273
|
+
/** Legend label for the POI value (marker size) channel (`poi-metric`). */
|
|
4274
|
+
poiMetric?: string;
|
|
4275
|
+
/** Legend label for the edge/leg value (thickness) channel (`flow-metric`). */
|
|
4276
|
+
flowMetric?: string;
|
|
4273
4277
|
scale?: MapScale;
|
|
4274
4278
|
regionLabels?: string;
|
|
4275
4279
|
poiLabels?: string;
|
|
@@ -4279,6 +4283,12 @@ interface MapDirectives {
|
|
|
4279
4283
|
noLegend?: boolean;
|
|
4280
4284
|
subtitle?: string;
|
|
4281
4285
|
caption?: string;
|
|
4286
|
+
/** Basemap dress override (bare flags `muted` / `natural`). Forces the
|
|
4287
|
+
* land/water styling regardless of whether a colouring dimension is active —
|
|
4288
|
+
* `muted` recedes to neutral grays, `natural` keeps the green/blue reference
|
|
4289
|
+
* dress. Absent → auto (muted iff a score/tag dimension is active). Lets two
|
|
4290
|
+
* maps in one deck share a look. */
|
|
4291
|
+
basemapStyle?: 'muted' | 'natural';
|
|
4282
4292
|
}
|
|
4283
4293
|
/** A region-fill: a subdivision name with an optional score and/or tag values
|
|
4284
4294
|
* (§24B.3/.4 — BOTH may be present; bivariate seam). */
|
|
@@ -4288,15 +4298,16 @@ interface MapRegion {
|
|
|
4288
4298
|
* (`Georgia US` → US context) or 3166-2 subdivision (`Georgia US-GA`).
|
|
4289
4299
|
* Forces the country-vs-state interpretation and silences the ambiguity warning. */
|
|
4290
4300
|
readonly scope?: string;
|
|
4291
|
-
|
|
4301
|
+
/** Numeric value → choropleth shade (§24B.3). Lifted out of `meta`. */
|
|
4302
|
+
readonly value?: number;
|
|
4292
4303
|
/** Tag values keyed by lowercased tag GROUP name (alias is resolved away). */
|
|
4293
4304
|
readonly tags: Readonly<Record<string, string>>;
|
|
4294
|
-
/**
|
|
4305
|
+
/** Any remaining reserved keys captured verbatim (`label`/`style`/…). */
|
|
4295
4306
|
readonly meta: Readonly<Record<string, string>>;
|
|
4296
4307
|
readonly lineNumber: number;
|
|
4297
4308
|
}
|
|
4298
|
-
/** A point of interest (§24B.5). `meta` holds
|
|
4299
|
-
*
|
|
4309
|
+
/** A point of interest (§24B.5). `meta` holds the numeric `value` (→ marker
|
|
4310
|
+
* size) and `style` verbatim; `label` is lifted out. */
|
|
4300
4311
|
interface MapPoi {
|
|
4301
4312
|
readonly pos: PoiPos;
|
|
4302
4313
|
readonly alias?: string;
|
|
@@ -4305,17 +4316,31 @@ interface MapPoi {
|
|
|
4305
4316
|
readonly meta: Readonly<Record<string, string>>;
|
|
4306
4317
|
readonly lineNumber: number;
|
|
4307
4318
|
}
|
|
4308
|
-
/**
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4319
|
+
/** One leg of a route (§24B.6): an edge from the previous stop to `dest`. Reuses
|
|
4320
|
+
* the edge arrow idiom — in-arrow text = leg label, `value:` = leg thickness,
|
|
4321
|
+
* `->`/`~>` (or the header `style: arc`) = shape. Stop-targeted keys on the leg
|
|
4322
|
+
* line (`tag`, `label:`) decorate the DESTINATION point. */
|
|
4323
|
+
interface MapRouteLeg {
|
|
4324
|
+
readonly label?: string;
|
|
4325
|
+
readonly style: 'straight' | 'arc';
|
|
4326
|
+
readonly value?: string;
|
|
4327
|
+
readonly dest: PoiPos;
|
|
4328
|
+
readonly destAlias?: string;
|
|
4329
|
+
readonly destLabel?: string;
|
|
4330
|
+
readonly destTags: Readonly<Record<string, string>>;
|
|
4313
4331
|
readonly lineNumber: number;
|
|
4314
4332
|
}
|
|
4315
|
-
/** An ordered, auto-numbered route (§24B.6)
|
|
4333
|
+
/** An ordered, auto-numbered route (§24B.6): `route <origin> [style: arc]` + a
|
|
4334
|
+
* sequence of indented arrow legs, each continuing from the previous stop.
|
|
4335
|
+
* Repeat the origin as a leg's destination to close a loop. */
|
|
4316
4336
|
interface MapRoute {
|
|
4317
|
-
readonly
|
|
4318
|
-
readonly
|
|
4337
|
+
readonly origin: PoiPos;
|
|
4338
|
+
readonly originAlias?: string;
|
|
4339
|
+
readonly originLabel?: string;
|
|
4340
|
+
readonly originValue?: string;
|
|
4341
|
+
readonly originTags: Readonly<Record<string, string>>;
|
|
4342
|
+
readonly style: 'straight' | 'arc';
|
|
4343
|
+
readonly legs: readonly MapRouteLeg[];
|
|
4319
4344
|
readonly lineNumber: number;
|
|
4320
4345
|
}
|
|
4321
4346
|
/** A connector (§24B.6). Endpoints are RAW identifier strings (name or alias);
|
|
@@ -4447,7 +4472,7 @@ interface ResolvedRegion {
|
|
|
4447
4472
|
readonly iso: string;
|
|
4448
4473
|
readonly name: string;
|
|
4449
4474
|
readonly layer: 'country' | 'us-state';
|
|
4450
|
-
readonly
|
|
4475
|
+
readonly value?: number;
|
|
4451
4476
|
readonly tags: Readonly<Record<string, string>>;
|
|
4452
4477
|
readonly meta: Readonly<Record<string, string>>;
|
|
4453
4478
|
readonly lineNumber: number;
|
|
@@ -4477,9 +4502,19 @@ interface ResolvedEdge {
|
|
|
4477
4502
|
readonly meta: Readonly<Record<string, string>>;
|
|
4478
4503
|
readonly lineNumber: number;
|
|
4479
4504
|
}
|
|
4505
|
+
interface ResolvedRouteLeg {
|
|
4506
|
+
readonly fromId: string;
|
|
4507
|
+
readonly toId: string;
|
|
4508
|
+
readonly label?: string;
|
|
4509
|
+
readonly style: 'straight' | 'arc';
|
|
4510
|
+
readonly value?: string;
|
|
4511
|
+
readonly lineNumber: number;
|
|
4512
|
+
}
|
|
4480
4513
|
interface ResolvedRoute {
|
|
4514
|
+
/** Ordered UNIQUE stop ids (for numbering + the origin marker). A loop-closing
|
|
4515
|
+
* leg whose destination is an earlier stop adds a leg but no duplicate stop. */
|
|
4481
4516
|
readonly stopIds: readonly string[];
|
|
4482
|
-
readonly
|
|
4517
|
+
readonly legs: readonly ResolvedRouteLeg[];
|
|
4483
4518
|
readonly lineNumber: number;
|
|
4484
4519
|
}
|
|
4485
4520
|
/** Geographic bounding box `[[west, south], [east, north]]` in degrees.
|
|
@@ -4524,9 +4559,9 @@ interface MapLayoutRegion {
|
|
|
4524
4559
|
readonly label?: string;
|
|
4525
4560
|
readonly lineNumber: number;
|
|
4526
4561
|
readonly layer: 'base' | 'country' | 'us-state';
|
|
4527
|
-
/** The region's
|
|
4562
|
+
/** The region's value (if any) — emitted as `data-value` so the app can
|
|
4528
4563
|
* highlight by gradient-scrub proximity. */
|
|
4529
|
-
readonly
|
|
4564
|
+
readonly value?: number;
|
|
4530
4565
|
/** The region's tag values keyed by group (lowercased) — emitted as
|
|
4531
4566
|
* `data-tag-<group>` so the app can highlight on legend-entry hover. */
|
|
4532
4567
|
readonly tags?: Readonly<Record<string, string>>;
|
|
@@ -4555,6 +4590,9 @@ interface MapLayoutPoi {
|
|
|
4555
4590
|
readonly implicit: boolean;
|
|
4556
4591
|
readonly isOrigin: boolean;
|
|
4557
4592
|
readonly routeNumber?: number;
|
|
4593
|
+
/** Tag values keyed by lowercased group name — emitted as `data-tag-<group>`
|
|
4594
|
+
* so the app can spotlight markers on legend-entry hover (mirrors regions). */
|
|
4595
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
4558
4596
|
}
|
|
4559
4597
|
/** A drawn connector -- an edge or a route leg (same geometry contract). */
|
|
4560
4598
|
interface MapLayoutLeg {
|
|
@@ -4651,13 +4689,16 @@ interface Size {
|
|
|
4651
4689
|
}
|
|
4652
4690
|
/** The map's water / backdrop colour for a palette — the single source of truth
|
|
4653
4691
|
* shared by the renderer's `<rect>` fill and any host wrapper that needs to
|
|
4654
|
-
* match it (so letterbox gaps around the SVG don't show a stray band).
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
*
|
|
4660
|
-
|
|
4692
|
+
* match it (so letterbox gaps around the SVG don't show a stray band). When
|
|
4693
|
+
* `dataActive` (a score ramp or tag group is colouring regions) the sea recedes
|
|
4694
|
+
* to a pale neutral so blue/green data hues don't blend into it. */
|
|
4695
|
+
declare function mapBackgroundColor(palette: PaletteColors, isDark?: boolean, dataActive?: boolean): string;
|
|
4696
|
+
/** The map's neutral (unscored/untagged) LAND colour — the base every region
|
|
4697
|
+
* blends from. Exported so a host can DIM a region to plain land (rather than
|
|
4698
|
+
* lowering opacity, which would let the water show through and make the shape
|
|
4699
|
+
* read as ocean). Matches the layout's `neutralFill`. Green reference dress by
|
|
4700
|
+
* default; neutral (page bg on light, lifted gray on dark) when `dataActive`. */
|
|
4701
|
+
declare function mapNeutralLandColor(palette: PaletteColors, isDark: boolean, dataActive?: boolean): string;
|
|
4661
4702
|
declare function layoutMap(resolved: ResolvedMap, data: MapData, size: Size, opts: LayoutOptions): MapLayout;
|
|
4662
4703
|
|
|
4663
4704
|
/** Render a resolved map into `container` (d3-selection appends an `<svg>`). */
|
package/dist/internal.d.ts
CHANGED
|
@@ -4268,8 +4268,12 @@ interface MapScale {
|
|
|
4268
4268
|
interface MapDirectives {
|
|
4269
4269
|
region?: string;
|
|
4270
4270
|
projection?: string;
|
|
4271
|
-
metric
|
|
4272
|
-
|
|
4271
|
+
/** Legend label for the region value ramp (`region-metric <label>`). */
|
|
4272
|
+
regionMetric?: string;
|
|
4273
|
+
/** Legend label for the POI value (marker size) channel (`poi-metric`). */
|
|
4274
|
+
poiMetric?: string;
|
|
4275
|
+
/** Legend label for the edge/leg value (thickness) channel (`flow-metric`). */
|
|
4276
|
+
flowMetric?: string;
|
|
4273
4277
|
scale?: MapScale;
|
|
4274
4278
|
regionLabels?: string;
|
|
4275
4279
|
poiLabels?: string;
|
|
@@ -4279,6 +4283,12 @@ interface MapDirectives {
|
|
|
4279
4283
|
noLegend?: boolean;
|
|
4280
4284
|
subtitle?: string;
|
|
4281
4285
|
caption?: string;
|
|
4286
|
+
/** Basemap dress override (bare flags `muted` / `natural`). Forces the
|
|
4287
|
+
* land/water styling regardless of whether a colouring dimension is active —
|
|
4288
|
+
* `muted` recedes to neutral grays, `natural` keeps the green/blue reference
|
|
4289
|
+
* dress. Absent → auto (muted iff a score/tag dimension is active). Lets two
|
|
4290
|
+
* maps in one deck share a look. */
|
|
4291
|
+
basemapStyle?: 'muted' | 'natural';
|
|
4282
4292
|
}
|
|
4283
4293
|
/** A region-fill: a subdivision name with an optional score and/or tag values
|
|
4284
4294
|
* (§24B.3/.4 — BOTH may be present; bivariate seam). */
|
|
@@ -4288,15 +4298,16 @@ interface MapRegion {
|
|
|
4288
4298
|
* (`Georgia US` → US context) or 3166-2 subdivision (`Georgia US-GA`).
|
|
4289
4299
|
* Forces the country-vs-state interpretation and silences the ambiguity warning. */
|
|
4290
4300
|
readonly scope?: string;
|
|
4291
|
-
|
|
4301
|
+
/** Numeric value → choropleth shade (§24B.3). Lifted out of `meta`. */
|
|
4302
|
+
readonly value?: number;
|
|
4292
4303
|
/** Tag values keyed by lowercased tag GROUP name (alias is resolved away). */
|
|
4293
4304
|
readonly tags: Readonly<Record<string, string>>;
|
|
4294
|
-
/**
|
|
4305
|
+
/** Any remaining reserved keys captured verbatim (`label`/`style`/…). */
|
|
4295
4306
|
readonly meta: Readonly<Record<string, string>>;
|
|
4296
4307
|
readonly lineNumber: number;
|
|
4297
4308
|
}
|
|
4298
|
-
/** A point of interest (§24B.5). `meta` holds
|
|
4299
|
-
*
|
|
4309
|
+
/** A point of interest (§24B.5). `meta` holds the numeric `value` (→ marker
|
|
4310
|
+
* size) and `style` verbatim; `label` is lifted out. */
|
|
4300
4311
|
interface MapPoi {
|
|
4301
4312
|
readonly pos: PoiPos;
|
|
4302
4313
|
readonly alias?: string;
|
|
@@ -4305,17 +4316,31 @@ interface MapPoi {
|
|
|
4305
4316
|
readonly meta: Readonly<Record<string, string>>;
|
|
4306
4317
|
readonly lineNumber: number;
|
|
4307
4318
|
}
|
|
4308
|
-
/**
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4319
|
+
/** One leg of a route (§24B.6): an edge from the previous stop to `dest`. Reuses
|
|
4320
|
+
* the edge arrow idiom — in-arrow text = leg label, `value:` = leg thickness,
|
|
4321
|
+
* `->`/`~>` (or the header `style: arc`) = shape. Stop-targeted keys on the leg
|
|
4322
|
+
* line (`tag`, `label:`) decorate the DESTINATION point. */
|
|
4323
|
+
interface MapRouteLeg {
|
|
4324
|
+
readonly label?: string;
|
|
4325
|
+
readonly style: 'straight' | 'arc';
|
|
4326
|
+
readonly value?: string;
|
|
4327
|
+
readonly dest: PoiPos;
|
|
4328
|
+
readonly destAlias?: string;
|
|
4329
|
+
readonly destLabel?: string;
|
|
4330
|
+
readonly destTags: Readonly<Record<string, string>>;
|
|
4313
4331
|
readonly lineNumber: number;
|
|
4314
4332
|
}
|
|
4315
|
-
/** An ordered, auto-numbered route (§24B.6)
|
|
4333
|
+
/** An ordered, auto-numbered route (§24B.6): `route <origin> [style: arc]` + a
|
|
4334
|
+
* sequence of indented arrow legs, each continuing from the previous stop.
|
|
4335
|
+
* Repeat the origin as a leg's destination to close a loop. */
|
|
4316
4336
|
interface MapRoute {
|
|
4317
|
-
readonly
|
|
4318
|
-
readonly
|
|
4337
|
+
readonly origin: PoiPos;
|
|
4338
|
+
readonly originAlias?: string;
|
|
4339
|
+
readonly originLabel?: string;
|
|
4340
|
+
readonly originValue?: string;
|
|
4341
|
+
readonly originTags: Readonly<Record<string, string>>;
|
|
4342
|
+
readonly style: 'straight' | 'arc';
|
|
4343
|
+
readonly legs: readonly MapRouteLeg[];
|
|
4319
4344
|
readonly lineNumber: number;
|
|
4320
4345
|
}
|
|
4321
4346
|
/** A connector (§24B.6). Endpoints are RAW identifier strings (name or alias);
|
|
@@ -4447,7 +4472,7 @@ interface ResolvedRegion {
|
|
|
4447
4472
|
readonly iso: string;
|
|
4448
4473
|
readonly name: string;
|
|
4449
4474
|
readonly layer: 'country' | 'us-state';
|
|
4450
|
-
readonly
|
|
4475
|
+
readonly value?: number;
|
|
4451
4476
|
readonly tags: Readonly<Record<string, string>>;
|
|
4452
4477
|
readonly meta: Readonly<Record<string, string>>;
|
|
4453
4478
|
readonly lineNumber: number;
|
|
@@ -4477,9 +4502,19 @@ interface ResolvedEdge {
|
|
|
4477
4502
|
readonly meta: Readonly<Record<string, string>>;
|
|
4478
4503
|
readonly lineNumber: number;
|
|
4479
4504
|
}
|
|
4505
|
+
interface ResolvedRouteLeg {
|
|
4506
|
+
readonly fromId: string;
|
|
4507
|
+
readonly toId: string;
|
|
4508
|
+
readonly label?: string;
|
|
4509
|
+
readonly style: 'straight' | 'arc';
|
|
4510
|
+
readonly value?: string;
|
|
4511
|
+
readonly lineNumber: number;
|
|
4512
|
+
}
|
|
4480
4513
|
interface ResolvedRoute {
|
|
4514
|
+
/** Ordered UNIQUE stop ids (for numbering + the origin marker). A loop-closing
|
|
4515
|
+
* leg whose destination is an earlier stop adds a leg but no duplicate stop. */
|
|
4481
4516
|
readonly stopIds: readonly string[];
|
|
4482
|
-
readonly
|
|
4517
|
+
readonly legs: readonly ResolvedRouteLeg[];
|
|
4483
4518
|
readonly lineNumber: number;
|
|
4484
4519
|
}
|
|
4485
4520
|
/** Geographic bounding box `[[west, south], [east, north]]` in degrees.
|
|
@@ -4524,9 +4559,9 @@ interface MapLayoutRegion {
|
|
|
4524
4559
|
readonly label?: string;
|
|
4525
4560
|
readonly lineNumber: number;
|
|
4526
4561
|
readonly layer: 'base' | 'country' | 'us-state';
|
|
4527
|
-
/** The region's
|
|
4562
|
+
/** The region's value (if any) — emitted as `data-value` so the app can
|
|
4528
4563
|
* highlight by gradient-scrub proximity. */
|
|
4529
|
-
readonly
|
|
4564
|
+
readonly value?: number;
|
|
4530
4565
|
/** The region's tag values keyed by group (lowercased) — emitted as
|
|
4531
4566
|
* `data-tag-<group>` so the app can highlight on legend-entry hover. */
|
|
4532
4567
|
readonly tags?: Readonly<Record<string, string>>;
|
|
@@ -4555,6 +4590,9 @@ interface MapLayoutPoi {
|
|
|
4555
4590
|
readonly implicit: boolean;
|
|
4556
4591
|
readonly isOrigin: boolean;
|
|
4557
4592
|
readonly routeNumber?: number;
|
|
4593
|
+
/** Tag values keyed by lowercased group name — emitted as `data-tag-<group>`
|
|
4594
|
+
* so the app can spotlight markers on legend-entry hover (mirrors regions). */
|
|
4595
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
4558
4596
|
}
|
|
4559
4597
|
/** A drawn connector -- an edge or a route leg (same geometry contract). */
|
|
4560
4598
|
interface MapLayoutLeg {
|
|
@@ -4651,13 +4689,16 @@ interface Size {
|
|
|
4651
4689
|
}
|
|
4652
4690
|
/** The map's water / backdrop colour for a palette — the single source of truth
|
|
4653
4691
|
* shared by the renderer's `<rect>` fill and any host wrapper that needs to
|
|
4654
|
-
* match it (so letterbox gaps around the SVG don't show a stray band).
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
*
|
|
4660
|
-
|
|
4692
|
+
* match it (so letterbox gaps around the SVG don't show a stray band). When
|
|
4693
|
+
* `dataActive` (a score ramp or tag group is colouring regions) the sea recedes
|
|
4694
|
+
* to a pale neutral so blue/green data hues don't blend into it. */
|
|
4695
|
+
declare function mapBackgroundColor(palette: PaletteColors, isDark?: boolean, dataActive?: boolean): string;
|
|
4696
|
+
/** The map's neutral (unscored/untagged) LAND colour — the base every region
|
|
4697
|
+
* blends from. Exported so a host can DIM a region to plain land (rather than
|
|
4698
|
+
* lowering opacity, which would let the water show through and make the shape
|
|
4699
|
+
* read as ocean). Matches the layout's `neutralFill`. Green reference dress by
|
|
4700
|
+
* default; neutral (page bg on light, lifted gray on dark) when `dataActive`. */
|
|
4701
|
+
declare function mapNeutralLandColor(palette: PaletteColors, isDark: boolean, dataActive?: boolean): string;
|
|
4661
4702
|
declare function layoutMap(resolved: ResolvedMap, data: MapData, size: Size, opts: LayoutOptions): MapLayout;
|
|
4662
4703
|
|
|
4663
4704
|
/** Render a resolved map into `container` (d3-selection appends an `<svg>`). */
|