@diagrammo/dgmo 0.24.0 → 0.25.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.cjs +14 -18
- package/dist/advanced.js +14 -18
- package/dist/auto.cjs +15 -19
- package/dist/auto.js +99 -99
- package/dist/auto.mjs +15 -19
- package/dist/cli.cjs +132 -132
- package/dist/index.cjs +14 -18
- package/dist/index.js +14 -18
- package/dist/internal.cjs +14 -18
- package/dist/internal.js +14 -18
- package/package.json +1 -1
- package/src/diagnostics.ts +0 -19
- package/src/map/geo.ts +0 -5
- package/src/sequence/parser.ts +0 -4
- package/src/utils/brand.ts +0 -17
- package/src/utils/legend-d3.ts +18 -8
- package/src/utils/parsing.ts +0 -16
- package/src/utils/reserved-key-registry.ts +0 -12
package/src/utils/brand.ts
CHANGED
|
@@ -27,23 +27,6 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export type Brand<T, B extends string> = T & { readonly __brand: B };
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* Cast a raw value to a branded type. The only legal "mint" point —
|
|
32
|
-
* call this at the boundary where unbranded data (parser input,
|
|
33
|
-
* external API) enters branded territory.
|
|
34
|
-
*
|
|
35
|
-
* const id = asBrand<NodeId>(rawString);
|
|
36
|
-
*
|
|
37
|
-
* Inverts trivially: a `Brand<T, B>` is assignable to `T` without a
|
|
38
|
-
* cast, so consumers that want the underlying primitive lose the
|
|
39
|
-
* brand naturally.
|
|
40
|
-
*/
|
|
41
|
-
export function asBrand<B>(
|
|
42
|
-
value: B extends Brand<infer T, string> ? T : never
|
|
43
|
-
): B {
|
|
44
|
-
return value as B;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
30
|
// ============================================================
|
|
48
31
|
// Writable<T> — escape hatch for parsers that need a mutable
|
|
49
32
|
// construction phase before returning a `readonly`-typed value.
|
package/src/utils/legend-d3.ts
CHANGED
|
@@ -31,6 +31,16 @@ import type {
|
|
|
31
31
|
D3Sel,
|
|
32
32
|
} from './legend-types';
|
|
33
33
|
|
|
34
|
+
// Vertically center an SVG <text> across engines. WebKit drops
|
|
35
|
+
// `dominant-baseline` on <text>, and resvg has limited support too
|
|
36
|
+
// (see legend-svg.ts), so we use the alphabetic baseline (the shared
|
|
37
|
+
// default) plus an em-relative dy. 0.32em matches legend-svg.ts's
|
|
38
|
+
// proven pill offset (fontSize/2 - 2 = 0.318em at 11px).
|
|
39
|
+
const LEGEND_TEXT_DY = '0.32em';
|
|
40
|
+
function centerText(sel: D3Sel): D3Sel {
|
|
41
|
+
return sel.attr('dy', LEGEND_TEXT_DY);
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
// ── Main renderer ───────────────────────────────────────────
|
|
35
45
|
|
|
36
46
|
export function renderLegendD3(
|
|
@@ -190,7 +200,7 @@ function renderCapsule(
|
|
|
190
200
|
.attr('x', pill.x + pill.width / 2)
|
|
191
201
|
.attr('y', LEGEND_HEIGHT / 2)
|
|
192
202
|
.attr('text-anchor', 'middle')
|
|
193
|
-
.
|
|
203
|
+
.call(centerText)
|
|
194
204
|
.attr('font-size', LEGEND_PILL_FONT_SIZE)
|
|
195
205
|
.attr('font-weight', 500)
|
|
196
206
|
.attr('fill', palette.text)
|
|
@@ -211,7 +221,7 @@ function renderCapsule(
|
|
|
211
221
|
g.append('text')
|
|
212
222
|
.attr('x', gr.minX)
|
|
213
223
|
.attr('y', gr.textY)
|
|
214
|
-
.
|
|
224
|
+
.call(centerText)
|
|
215
225
|
.attr('font-size', LEGEND_ENTRY_FONT_SIZE)
|
|
216
226
|
.attr('fill', palette.textMuted)
|
|
217
227
|
.attr('pointer-events', 'none')
|
|
@@ -232,7 +242,7 @@ function renderCapsule(
|
|
|
232
242
|
g.append('text')
|
|
233
243
|
.attr('x', gr.maxX)
|
|
234
244
|
.attr('y', gr.textY)
|
|
235
|
-
.
|
|
245
|
+
.call(centerText)
|
|
236
246
|
.attr('font-size', LEGEND_ENTRY_FONT_SIZE)
|
|
237
247
|
.attr('fill', palette.textMuted)
|
|
238
248
|
.attr('pointer-events', 'none')
|
|
@@ -259,7 +269,7 @@ function renderCapsule(
|
|
|
259
269
|
.append('text')
|
|
260
270
|
.attr('x', entry.textX)
|
|
261
271
|
.attr('y', entry.textY)
|
|
262
|
-
.
|
|
272
|
+
.call(centerText)
|
|
263
273
|
.attr('font-size', LEGEND_ENTRY_FONT_SIZE)
|
|
264
274
|
.attr('fill', palette.textMuted)
|
|
265
275
|
.attr('font-family', FONT_FAMILY)
|
|
@@ -318,7 +328,7 @@ function renderPill(
|
|
|
318
328
|
.attr('x', pill.width / 2)
|
|
319
329
|
.attr('y', pill.height / 2)
|
|
320
330
|
.attr('text-anchor', 'middle')
|
|
321
|
-
.
|
|
331
|
+
.call(centerText)
|
|
322
332
|
.attr('font-size', LEGEND_PILL_FONT_SIZE)
|
|
323
333
|
.attr('font-weight', 500)
|
|
324
334
|
.attr('fill', palette.textMuted)
|
|
@@ -387,7 +397,7 @@ function renderControl(
|
|
|
387
397
|
.attr('x', textX)
|
|
388
398
|
.attr('y', ctrl.height / 2)
|
|
389
399
|
.attr('text-anchor', 'middle')
|
|
390
|
-
.
|
|
400
|
+
.call(centerText)
|
|
391
401
|
.attr('font-size', LEGEND_PILL_FONT_SIZE)
|
|
392
402
|
.attr('font-weight', 500)
|
|
393
403
|
.attr('fill', palette.textMuted)
|
|
@@ -422,7 +432,7 @@ function renderControl(
|
|
|
422
432
|
.attr('x', child.width / 2)
|
|
423
433
|
.attr('y', ctrl.height / 2)
|
|
424
434
|
.attr('text-anchor', 'middle')
|
|
425
|
-
.
|
|
435
|
+
.call(centerText)
|
|
426
436
|
.attr('font-size', LEGEND_ENTRY_FONT_SIZE)
|
|
427
437
|
.attr('fill', child.isActive ? palette.bg : palette.textMuted)
|
|
428
438
|
.attr('font-family', FONT_FAMILY)
|
|
@@ -585,7 +595,7 @@ function renderControlsGroup(
|
|
|
585
595
|
.append('text')
|
|
586
596
|
.attr('x', tl.textX)
|
|
587
597
|
.attr('y', tl.textY)
|
|
588
|
-
.
|
|
598
|
+
.call(centerText)
|
|
589
599
|
.attr('font-size', LEGEND_ENTRY_FONT_SIZE)
|
|
590
600
|
.attr('fill', palette.textMuted)
|
|
591
601
|
.attr('opacity', tl.active ? 1 : LEGEND_TOGGLE_OFF_OPACITY)
|
package/src/utils/parsing.ts
CHANGED
|
@@ -79,22 +79,6 @@ export const ALL_CHART_TYPES = new Set([
|
|
|
79
79
|
'map',
|
|
80
80
|
]);
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Heuristic: pipe-metadata content is structured `key: value, …` form when
|
|
84
|
-
* the first token is a bare identifier followed by `:`. Used by parsers that
|
|
85
|
-
* accept both shorthand-description-after-pipe and structured key-value
|
|
86
|
-
* (pyramid, ring) to disambiguate the two.
|
|
87
|
-
*/
|
|
88
|
-
export const PIPE_KEY_VALUE_PREFIX_RE = /^\s*[A-Za-z][A-Za-z0-9_-]*\s*:/;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Heuristic to detect a likely-structured tail inside an otherwise-shorthand
|
|
92
|
-
* pipe: `, key:` somewhere in the string. Used to flag user errors like
|
|
93
|
-
* `Inner | bare desc, color: blue` where `color: blue` is silently swallowed
|
|
94
|
-
* into the description.
|
|
95
|
-
*/
|
|
96
|
-
export const PIPE_LIKELY_STRUCTURED_TAIL_RE = /,\s*[A-Za-z][A-Za-z0-9_-]*\s*:/;
|
|
97
|
-
|
|
98
82
|
/** Measure leading whitespace of a line, normalizing tabs to 4 spaces. */
|
|
99
83
|
export function measureIndent(line: string): number {
|
|
100
84
|
let indent = 0;
|
|
@@ -113,11 +113,6 @@ export const ER_REGISTRY: ReservedKeyRegistry = staticRegistry([
|
|
|
113
113
|
'domain',
|
|
114
114
|
]);
|
|
115
115
|
|
|
116
|
-
export const CLASS_REGISTRY: ReservedKeyRegistry = staticRegistry([
|
|
117
|
-
'color',
|
|
118
|
-
'description',
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
116
|
export const KANBAN_REGISTRY: ReservedKeyRegistry = staticRegistry([
|
|
122
117
|
'color',
|
|
123
118
|
'description',
|
|
@@ -221,10 +216,3 @@ export const RACI_REGISTRY: ReservedKeyRegistry = staticRegistry([
|
|
|
221
216
|
'color',
|
|
222
217
|
'description',
|
|
223
218
|
]);
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Wireframe uses a trailing-keyword flag list (§19.5), not key-value
|
|
227
|
-
* metadata. This empty registry exists so callers can still pass a
|
|
228
|
-
* registry to shared helpers without a special-case.
|
|
229
|
-
*/
|
|
230
|
-
export const WIREFRAME_REGISTRY: ReservedKeyRegistry = staticRegistry([]);
|