@diagrammo/dgmo 0.24.0 → 0.25.1
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 +203 -351
- package/dist/advanced.d.cts +17 -80
- package/dist/advanced.d.ts +17 -80
- package/dist/advanced.js +203 -343
- package/dist/auto.cjs +201 -336
- package/dist/auto.js +118 -118
- package/dist/auto.mjs +201 -336
- package/dist/cli.cjs +156 -156
- package/dist/editor.cjs +1 -0
- package/dist/editor.js +1 -0
- package/dist/highlight.cjs +1 -0
- package/dist/highlight.js +1 -0
- package/dist/index.cjs +218 -337
- package/dist/index.js +218 -337
- package/dist/internal.cjs +203 -351
- package/dist/internal.d.cts +17 -80
- package/dist/internal.d.ts +17 -80
- package/dist/internal.js +203 -343
- package/package.json +1 -1
- package/src/advanced.ts +0 -8
- package/src/completion.ts +5 -0
- package/src/d3.ts +12 -2
- package/src/diagnostics.ts +0 -19
- package/src/editor/keywords.ts +1 -0
- package/src/map/geo.ts +0 -5
- package/src/map/layout.ts +18 -11
- package/src/map/parser.ts +12 -2
- package/src/map/renderer.ts +25 -2
- package/src/map/types.ts +9 -0
- package/src/pert/renderer.ts +21 -358
- package/src/sequence/parser.ts +0 -4
- package/src/sequence/renderer.ts +36 -1
- 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/svg-embed.ts +36 -2
|
@@ -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([]);
|
package/src/utils/svg-embed.ts
CHANGED
|
@@ -34,8 +34,30 @@ export function normalizeSvgForEmbed(input: string): string {
|
|
|
34
34
|
const tight = computeBBox(svg);
|
|
35
35
|
if (tight && tight.width > 0 && tight.height > 0) {
|
|
36
36
|
const pad = 16;
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const x = tight.x - pad;
|
|
38
|
+
const y = tight.y - pad;
|
|
39
|
+
const w = tight.width + pad * 2;
|
|
40
|
+
const h = tight.height + pad * 2;
|
|
41
|
+
// Genuine content-tightening is ALWAYS a sub-rectangle of the renderer's
|
|
42
|
+
// export canvas. computeBBox is a best-effort string parser: it misreads
|
|
43
|
+
// path arc commands (`A rx ry rot … x y`) and ignores `<g transform>`, so
|
|
44
|
+
// it can return a box that strays OUTSIDE the canvas (negative origin or
|
|
45
|
+
// over-wide). That's a parse error, not real content — applying it shifts the
|
|
46
|
+
// viewBox and CLIPS the diagram (the right/bottom fall off in embeds). Only
|
|
47
|
+
// tighten when the computed box sits within the renderer's viewBox;
|
|
48
|
+
// otherwise keep the already-correct canvas bounds.
|
|
49
|
+
const canvas = readViewBox(svg);
|
|
50
|
+
const TOL = 2;
|
|
51
|
+
const withinCanvas =
|
|
52
|
+
!canvas ||
|
|
53
|
+
(x >= canvas.x - TOL &&
|
|
54
|
+
y >= canvas.y - TOL &&
|
|
55
|
+
x + w <= canvas.x + canvas.width + TOL &&
|
|
56
|
+
y + h <= canvas.y + canvas.height + TOL);
|
|
57
|
+
if (withinCanvas) {
|
|
58
|
+
const vb = `${x} ${y} ${w} ${h}`;
|
|
59
|
+
svg = svg.replace(/(<svg[^>]*?)viewBox="[^"]*"/, `$1viewBox="${vb}"`);
|
|
60
|
+
}
|
|
39
61
|
}
|
|
40
62
|
|
|
41
63
|
svg = svg.replace(/(<svg[^>]*?) width="[^"]*"/g, '$1');
|
|
@@ -73,6 +95,18 @@ export function getEmbedSvgViewBox(
|
|
|
73
95
|
* absolute coordinates within their viewBox, so the approximation is close
|
|
74
96
|
* enough that the rendered output reliably fills the visible area.
|
|
75
97
|
*/
|
|
98
|
+
/** Read the root `<svg>` viewBox as numbers, if present and well-formed. */
|
|
99
|
+
function readViewBox(
|
|
100
|
+
svg: string
|
|
101
|
+
): { x: number; y: number; width: number; height: number } | null {
|
|
102
|
+
const m = svg.match(/<svg[^>]*?\bviewBox="([^"]+)"/);
|
|
103
|
+
if (!m) return null;
|
|
104
|
+
const n = m[1]!.trim().split(/[\s,]+/).map(Number);
|
|
105
|
+
if (n.length !== 4 || n.some((v) => !Number.isFinite(v)) || n[2]! <= 0 || n[3]! <= 0)
|
|
106
|
+
return null;
|
|
107
|
+
return { x: n[0]!, y: n[1]!, width: n[2]!, height: n[3]! };
|
|
108
|
+
}
|
|
109
|
+
|
|
76
110
|
function computeBBox(
|
|
77
111
|
svg: string
|
|
78
112
|
): { x: number; y: number; width: number; height: number } | null {
|