compasso 0.4.0 → 0.5.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/README.md +115 -5
- package/dist/{chunk-ZBDABVIO.js → chunk-2NDET6O5.js} +3 -3
- package/dist/{chunk-ZBDABVIO.js.map → chunk-2NDET6O5.js.map} +1 -1
- package/dist/{chunk-Q6DVTCXD.js → chunk-3RGYLVTN.js} +18 -6
- package/dist/chunk-3RGYLVTN.js.map +1 -0
- package/dist/chunk-BM7UJBK5.js +680 -0
- package/dist/chunk-BM7UJBK5.js.map +1 -0
- package/dist/chunk-DVLWT565.js +372 -0
- package/dist/chunk-DVLWT565.js.map +1 -0
- package/dist/{chunk-F47C6ZEB.js → chunk-JBDA7E2O.js} +3 -3
- package/dist/{chunk-F47C6ZEB.js.map → chunk-JBDA7E2O.js.map} +1 -1
- package/dist/chunk-MIJTBYX2.js +982 -0
- package/dist/chunk-MIJTBYX2.js.map +1 -0
- package/dist/{chunk-JP4N42AY.js → chunk-PJHLWSGD.js} +3 -3
- package/dist/{chunk-JP4N42AY.js.map → chunk-PJHLWSGD.js.map} +1 -1
- package/dist/{chunk-LRHHUJFZ.js → chunk-RDH4XHA2.js} +3 -3
- package/dist/{chunk-LRHHUJFZ.js.map → chunk-RDH4XHA2.js.map} +1 -1
- package/dist/{chunk-UJVU7B44.js → chunk-WEHUSHVI.js} +31 -51
- package/dist/chunk-WEHUSHVI.js.map +1 -0
- package/dist/{chunk-RWPGGWO5.js → chunk-Z66YUOUM.js} +34 -10
- package/dist/chunk-Z66YUOUM.js.map +1 -0
- package/dist/core/index.cjs +247 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +94 -2
- package/dist/core/index.d.ts +94 -2
- package/dist/core/index.js +1 -1
- package/dist/ecomap/index.cjs +34 -11
- package/dist/ecomap/index.cjs.map +1 -1
- package/dist/ecomap/index.d.cts +12 -0
- package/dist/ecomap/index.d.ts +12 -0
- package/dist/ecomap/index.js +2 -2
- package/dist/fault-tree/index.d.cts +2 -2
- package/dist/fault-tree/index.d.ts +2 -2
- package/dist/fault-tree/index.js +2 -2
- package/dist/fishbone/index.js +2 -2
- package/dist/genogram/index.cjs +57 -7
- package/dist/genogram/index.cjs.map +1 -1
- package/dist/genogram/index.d.cts +22 -6
- package/dist/genogram/index.d.ts +22 -6
- package/dist/genogram/index.js +2 -2
- package/dist/geometry-P-XGqGe7.d.cts +8 -0
- package/dist/geometry-P-XGqGe7.d.ts +8 -0
- package/dist/grid-BMgUSly1.d.cts +79 -0
- package/dist/grid-BMgUSly1.d.ts +79 -0
- package/dist/index.cjs +2360 -395
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.js +10 -8
- package/dist/{kinship-DqEklrDN.d.ts → kinship-BF90HyyS.d.ts} +1 -1
- package/dist/{kinship-Dy_ijjJV.d.cts → kinship-BOUss5cT.d.cts} +1 -1
- package/dist/{labels-RtFw9tX1.d.cts → labels-B0aOMbHy.d.cts} +12 -0
- package/dist/{labels-RtFw9tX1.d.ts → labels-B0aOMbHy.d.ts} +12 -0
- package/dist/labels-Br8yjc3C.d.cts +29 -0
- package/dist/labels-Br8yjc3C.d.ts +29 -0
- package/dist/{labels-DNqRkWuI.d.ts → labels-CuLbFyrz.d.ts} +1 -1
- package/dist/labels-D1v1RWZd.d.cts +97 -0
- package/dist/labels-D1v1RWZd.d.ts +97 -0
- package/dist/{labels-CBQ_3Ec9.d.cts → labels-DhQe7I8m.d.cts} +1 -1
- package/dist/layered-DmZluAqe.d.cts +72 -0
- package/dist/layered-DmZluAqe.d.ts +72 -0
- package/dist/locales/pt-br.cjs +53 -0
- package/dist/locales/pt-br.cjs.map +1 -1
- package/dist/locales/pt-br.d.cts +11 -5
- package/dist/locales/pt-br.d.ts +11 -5
- package/dist/locales/pt-br.js +50 -1
- package/dist/locales/pt-br.js.map +1 -1
- package/dist/org-chart/index.cjs +138 -94
- package/dist/org-chart/index.cjs.map +1 -1
- package/dist/org-chart/index.d.cts +24 -33
- package/dist/org-chart/index.d.ts +24 -33
- package/dist/org-chart/index.js +2 -2
- package/dist/pedigree/index.d.cts +6 -6
- package/dist/pedigree/index.d.ts +6 -6
- package/dist/pedigree/index.js +2 -2
- package/dist/phylo/index.d.cts +2 -2
- package/dist/phylo/index.d.ts +2 -2
- package/dist/phylo/index.js +2 -2
- package/dist/prisma/index.cjs +882 -0
- package/dist/prisma/index.cjs.map +1 -0
- package/dist/prisma/index.d.cts +174 -0
- package/dist/prisma/index.d.ts +174 -0
- package/dist/prisma/index.js +4 -0
- package/dist/prisma/index.js.map +1 -0
- package/dist/{text-DuO_PwYw.d.cts → text-DDVzpwPZ.d.cts} +1 -8
- package/dist/{text-DuO_PwYw.d.ts → text-DDVzpwPZ.d.ts} +1 -8
- package/dist/{types-BnMG7TCd.d.cts → types-jE2fdM1t.d.cts} +8 -0
- package/dist/{types-BnMG7TCd.d.ts → types-jE2fdM1t.d.ts} +8 -0
- package/dist/uml/index.cjs +1214 -0
- package/dist/uml/index.cjs.map +1 -0
- package/dist/uml/index.d.cts +189 -0
- package/dist/uml/index.d.ts +189 -0
- package/dist/uml/index.js +4 -0
- package/dist/uml/index.js.map +1 -0
- package/package.json +28 -2
- package/dist/chunk-O3BT2O42.js +0 -145
- package/dist/chunk-O3BT2O42.js.map +0 -1
- package/dist/chunk-Q6DVTCXD.js.map +0 -1
- package/dist/chunk-RWPGGWO5.js.map +0 -1
- package/dist/chunk-UJVU7B44.js.map +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { g as UmlInput, k as UmlTitleLabels, j as UmlSvgLabels } from '../labels-D1v1RWZd.js';
|
|
2
|
+
export { G as GlyphKind, R as RELATION_GLYPHS, U as UML_RELATIONSHIPS, a as UML_SVG_LABELS_EN, b as UML_TITLE_LABELS_EN, c as UML_VISIBILITIES, d as UML_VIS_GLYPH, e as UmlClass, f as UmlFeature, h as UmlRelationship, i as UmlRelationshipKind, l as UmlVisibility } from '../labels-D1v1RWZd.js';
|
|
3
|
+
import { P as Point } from '../geometry-P-XGqGe7.js';
|
|
4
|
+
import { C as CompartmentMetrics, a as GridResult } from '../grid-BMgUSly1.js';
|
|
5
|
+
|
|
6
|
+
type UmlIssueCode = "duplicate-id" | "unknown-endpoint" | "negative-cell" | "cell-collision" | "self-generalization" | "generalization-cycle" | "too-many-side-edges";
|
|
7
|
+
interface UmlIssue {
|
|
8
|
+
code: UmlIssueCode;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
declare class UmlValidationError extends Error {
|
|
12
|
+
readonly issues: readonly UmlIssue[];
|
|
13
|
+
constructor(issues: readonly UmlIssue[]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Computes ALL validation issues for the input, deduplicated and sorted deterministically.
|
|
17
|
+
* Empty input → []. Empty SVG is always valid.
|
|
18
|
+
*/
|
|
19
|
+
declare function umlIssues(input: UmlInput): readonly UmlIssue[];
|
|
20
|
+
/** Throws UmlValidationError (carrying ALL issues) when the input is invalid. */
|
|
21
|
+
declare function validateUml(input: UmlInput): void;
|
|
22
|
+
/**
|
|
23
|
+
* Build a `too-many-side-edges` issue. A box side can hold only finitely many incident-edge
|
|
24
|
+
* ports: the router spreads N ports along the side as a symmetric zigzag of pitch `pitch`, so the
|
|
25
|
+
* outermost port sits `floor(N/2)·pitch` from the side midpoint (up AND down). Beyond the side's
|
|
26
|
+
* CLEAR vertical band the outermost port's stub/glyph spills past the box and crosses a neighbour —
|
|
27
|
+
* a segment-through-box / glyph-box hit. N arrowhead glyphs simply cannot fit on one short box
|
|
28
|
+
* edge; the honest, house-consistent answer is to REJECT (mirroring org-chart's
|
|
29
|
+
* `too-many-matrix-edges`), never to mis-draw. The message names the class + side + observed
|
|
30
|
+
* count + capacity so the author knows which fan-in to split. `boxH`/`rowGap`/`pitch` are the
|
|
31
|
+
* measured geometry the router uses, so the cap is the TRUE clean capacity for THAT box.
|
|
32
|
+
*
|
|
33
|
+
* The clear band is `boxH/2 + rowGap/2 − glyphHalf`:
|
|
34
|
+
* - `boxH/2` — the box's own half-height (ports start on the box edge).
|
|
35
|
+
* - `rowGap/2` — only HALF the box-free row gutter, NOT the whole gap. The gutter above (and
|
|
36
|
+
* below) the box is SHARED with the neighbouring row's box, which may ALSO fan in on the same
|
|
37
|
+
* side and spill its own ports DOWN (resp. up) into that same gutter. If each box could claim
|
|
38
|
+
* the WHOLE gutter, two adjacent boxes' outermost ports/glyphs would meet in the middle of the
|
|
39
|
+
* shared gutter (a glyph-glyph hit between edges targeting DIFFERENT boxes — the residual #4
|
|
40
|
+
* class). Capping each box at half the gutter guarantees the two spills meet at most at the
|
|
41
|
+
* gutter midline, never overlapping.
|
|
42
|
+
* - `−glyphHalf` — the outermost port carries a glyph whose AABB extends `glyphHalf` PAST the
|
|
43
|
+
* port-y; reserving it keeps the glyph (not just the port stub) inside the half-gutter, so it
|
|
44
|
+
* can never dip across the midline into the neighbour's half (nor into a full-column-wide
|
|
45
|
+
* neighbour box).
|
|
46
|
+
* floor(N/2) ≤ K ⇒ N ≤ 2K+1, with K = floor((boxH/2 + rowGap/2 − glyphHalf) / pitch). K is
|
|
47
|
+
* clamped ≥ 0 so a sub-glyph box still admits the single centre port (offset 0).
|
|
48
|
+
*/
|
|
49
|
+
declare function sideCapacity(boxH: number, rowGap: number, pitch: number, glyphHalf: number): number;
|
|
50
|
+
/** Construct the `too-many-side-edges` issue for an over-capacity box side. */
|
|
51
|
+
declare function sideCapacityIssue(classId: number, side: "left" | "right", count: number, capacity: number): UmlIssue;
|
|
52
|
+
|
|
53
|
+
/** Canvas padding on all sides. */
|
|
54
|
+
declare const UML_PADDING = 32;
|
|
55
|
+
/** Horizontal gutter between adjacent columns. Box-free channel. */
|
|
56
|
+
declare const UML_COL_GAP = 64;
|
|
57
|
+
/** Vertical gutter between adjacent rows. Box-free channel. */
|
|
58
|
+
declare const UML_ROW_GAP = 56;
|
|
59
|
+
/** Horizontal padding inside a box (each side). */
|
|
60
|
+
declare const UML_BOX_PAD_X = 10;
|
|
61
|
+
/** Vertical padding inside a box (each side). */
|
|
62
|
+
declare const UML_BOX_PAD_Y = 8;
|
|
63
|
+
/** Height of a single text line inside a box. */
|
|
64
|
+
declare const UML_LINE_H = 15;
|
|
65
|
+
/** Minimum box width. */
|
|
66
|
+
declare const UML_MIN_BOX_W = 120;
|
|
67
|
+
/** Font size for the name/stereotype compartment. */
|
|
68
|
+
declare const UML_NAME_FONT = 12;
|
|
69
|
+
/** Font size for attributes and operations. */
|
|
70
|
+
declare const UML_FEAT_FONT = 11;
|
|
71
|
+
/** Padding below/above compartment dividers (reserved for future use; geometry uses 0). */
|
|
72
|
+
declare const UML_SEP_PAD = 4;
|
|
73
|
+
/** Pitch between adjacent port offsets on the same box side. */
|
|
74
|
+
declare const UML_PORT_PITCH = 12;
|
|
75
|
+
/** Width of the self-association side-loop lane (right margin). */
|
|
76
|
+
declare const UML_SELF_LOOP_W = 28;
|
|
77
|
+
/** Font size for edge labels (multiplicity, role, mid-edge label). */
|
|
78
|
+
declare const UML_LABEL_FONT = 10;
|
|
79
|
+
/** Routing elements (inter-cell routed edge polylines). */
|
|
80
|
+
declare const UML_ASSOC_ROUTE_BASE = 1000000;
|
|
81
|
+
/** Glyph polygons (decoration, harness-excluded). */
|
|
82
|
+
declare const UML_GLYPH_BASE = 2000000;
|
|
83
|
+
/** Self-association loops. */
|
|
84
|
+
declare const UML_SELF_LOOP_BASE = 3000000;
|
|
85
|
+
/** A positioned UML class box with its measurement metrics. */
|
|
86
|
+
interface UmlBoxNode {
|
|
87
|
+
classId: number;
|
|
88
|
+
/** Box center x (from packGrid). */
|
|
89
|
+
cx: number;
|
|
90
|
+
/** Box center y (from packGrid). */
|
|
91
|
+
cy: number;
|
|
92
|
+
/** Box left edge = cx - boxW/2. */
|
|
93
|
+
boxW: number;
|
|
94
|
+
/** Box height. */
|
|
95
|
+
boxH: number;
|
|
96
|
+
/** Compartment metrics (3 compartments: header / attributes / operations). */
|
|
97
|
+
metrics: CompartmentMetrics;
|
|
98
|
+
/** Display title (from UmlClass.title or computed). */
|
|
99
|
+
title: string;
|
|
100
|
+
/** Grid column index. */
|
|
101
|
+
col: number;
|
|
102
|
+
/** Grid row index. */
|
|
103
|
+
row: number;
|
|
104
|
+
}
|
|
105
|
+
/** A small reserved text AABB (multiplicity / role / mid-edge label). */
|
|
106
|
+
interface UmlTextBox {
|
|
107
|
+
relId: number;
|
|
108
|
+
/** Which text this is (for the emitter to draw the right string at the same anchor). */
|
|
109
|
+
slot: "src-mult" | "src-role" | "tgt-mult" | "tgt-role" | "label";
|
|
110
|
+
/** Verbatim string. */
|
|
111
|
+
text: string;
|
|
112
|
+
/** Top-left x of the reserved AABB. */
|
|
113
|
+
x: number;
|
|
114
|
+
/** Top-left y of the reserved AABB. */
|
|
115
|
+
y: number;
|
|
116
|
+
w: number;
|
|
117
|
+
h: number;
|
|
118
|
+
/** Text anchor: where the emitter places x (left by default). */
|
|
119
|
+
anchor: "start" | "middle";
|
|
120
|
+
}
|
|
121
|
+
/** A routed edge element (inter-cell or self-loop). */
|
|
122
|
+
interface UmlEdgeElement {
|
|
123
|
+
edgeId: number;
|
|
124
|
+
relId: number;
|
|
125
|
+
/** Ordered waypoints forming the polyline. */
|
|
126
|
+
points: Point[];
|
|
127
|
+
kind: "route" | "self-loop";
|
|
128
|
+
/** <title> text — the relationship's `title` override, else the LOCALIZED kind word. */
|
|
129
|
+
title: string;
|
|
130
|
+
}
|
|
131
|
+
/** The complete positioned UML layout. */
|
|
132
|
+
interface UmlLayout {
|
|
133
|
+
nodes: UmlBoxNode[];
|
|
134
|
+
elements: UmlEdgeElement[];
|
|
135
|
+
/** Reserved text AABBs for multiplicity/role/label (drawn at these anchors by svg.ts). */
|
|
136
|
+
textBoxes: UmlTextBox[];
|
|
137
|
+
/** Total canvas width (before legend). */
|
|
138
|
+
canvasW: number;
|
|
139
|
+
/** Total canvas height (before legend). */
|
|
140
|
+
canvasH: number;
|
|
141
|
+
/** The grid result (column/row widths and heights, for harness). */
|
|
142
|
+
grid: GridResult;
|
|
143
|
+
/** colX[c] = left edge of column c (derived from grid + padding). */
|
|
144
|
+
colX: number[];
|
|
145
|
+
/** rowY[r] = top edge of row r (derived from grid + padding). */
|
|
146
|
+
rowY: number[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Computes the full positioned layout for a UML class diagram.
|
|
150
|
+
*
|
|
151
|
+
* @param input The validated UML diagram input.
|
|
152
|
+
* @param labels Display vocabulary (defaults to English) — woven into <title>s by svg.ts
|
|
153
|
+
* via the kind word; threaded through so localized titles are honored.
|
|
154
|
+
*/
|
|
155
|
+
declare function computeUmlLayout(input: UmlInput, labels?: UmlTitleLabels): UmlLayout;
|
|
156
|
+
|
|
157
|
+
interface UmlSvgOptions {
|
|
158
|
+
/** Set false to suppress the legend (default true). */
|
|
159
|
+
legend?: boolean;
|
|
160
|
+
/** Display vocabulary — English default; see locale packs. */
|
|
161
|
+
labels?: UmlSvgLabels;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Emits a self-contained SVG string from a computed UmlLayout + the original input.
|
|
165
|
+
* The input is needed for class attributes/operations/stereotype data that the layout
|
|
166
|
+
* only stores in the metrics.
|
|
167
|
+
*/
|
|
168
|
+
declare function umlLayoutSvg(layout: UmlLayout, input: UmlInput, opts?: UmlSvgOptions): string;
|
|
169
|
+
|
|
170
|
+
interface UmlRenderOptions extends UmlSvgOptions {
|
|
171
|
+
/**
|
|
172
|
+
* Title-bar vocabulary woven into each element's `<title>` by the layout (the
|
|
173
|
+
* localized relationship-kind word). Defaults to English; pass the pt-BR pack for
|
|
174
|
+
* localized titles. The `labels` field (UmlSvgLabels) controls the legend + aria.
|
|
175
|
+
*/
|
|
176
|
+
titleLabels?: UmlTitleLabels;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Renders a UML class diagram to SVG in one call.
|
|
180
|
+
*
|
|
181
|
+
* @returns `{ svg, layout }` — svg is the self-contained SVG string; layout is the
|
|
182
|
+
* positioned model for the overlap harness and decorating callers.
|
|
183
|
+
*/
|
|
184
|
+
declare function umlSvg(input: UmlInput, opts?: UmlRenderOptions): {
|
|
185
|
+
svg: string;
|
|
186
|
+
layout: UmlLayout;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { UML_ASSOC_ROUTE_BASE, UML_BOX_PAD_X, UML_BOX_PAD_Y, UML_COL_GAP, UML_FEAT_FONT, UML_GLYPH_BASE, UML_LABEL_FONT, UML_LINE_H, UML_MIN_BOX_W, UML_NAME_FONT, UML_PADDING, UML_PORT_PITCH, UML_ROW_GAP, UML_SELF_LOOP_BASE, UML_SELF_LOOP_W, UML_SEP_PAD, type UmlBoxNode, type UmlEdgeElement, UmlInput, type UmlIssue, type UmlIssueCode, type UmlLayout, UmlSvgLabels, type UmlSvgOptions, type UmlTextBox, UmlTitleLabels, UmlValidationError, computeUmlLayout, sideCapacity, sideCapacityIssue, umlIssues, umlLayoutSvg, umlSvg, validateUml };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { RELATION_GLYPHS, UML_ASSOC_ROUTE_BASE, UML_BOX_PAD_X, UML_BOX_PAD_Y, UML_COL_GAP, UML_FEAT_FONT, UML_GLYPH_BASE, UML_LABEL_FONT, UML_LINE_H, UML_MIN_BOX_W, UML_NAME_FONT, UML_PADDING, UML_PORT_PITCH, UML_RELATIONSHIPS, UML_ROW_GAP, UML_SELF_LOOP_BASE, UML_SELF_LOOP_W, UML_SEP_PAD, UML_SVG_LABELS_EN, UML_TITLE_LABELS_EN, UML_VISIBILITIES, UML_VIS_GLYPH, UmlValidationError, computeUmlLayout, sideCapacity, sideCapacityIssue, umlIssues, umlLayoutSvg, umlSvg, validateUml } from '../chunk-MIJTBYX2.js';
|
|
2
|
+
import '../chunk-DVLWT565.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compasso",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Standards-faithful relational and analytical diagrams (genogram, ecomap, fault tree, fishbone, pedigree, phylogenetic tree, org chart) as pure SVG strings. Deterministic, zero dependencies, server-safe.",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Standards-faithful relational and analytical diagrams (genogram, ecomap, fault tree, fishbone, pedigree, phylogenetic tree, org chart, PRISMA 2020 flow, UML class diagram) as pure SVG strings. Deterministic, zero dependencies, server-safe.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Victor Canô",
|
|
7
7
|
"repository": {
|
|
@@ -104,6 +104,26 @@
|
|
|
104
104
|
"default": "./dist/org-chart/index.cjs"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
|
+
"./prisma": {
|
|
108
|
+
"import": {
|
|
109
|
+
"types": "./dist/prisma/index.d.ts",
|
|
110
|
+
"default": "./dist/prisma/index.js"
|
|
111
|
+
},
|
|
112
|
+
"require": {
|
|
113
|
+
"types": "./dist/prisma/index.d.cts",
|
|
114
|
+
"default": "./dist/prisma/index.cjs"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"./uml": {
|
|
118
|
+
"import": {
|
|
119
|
+
"types": "./dist/uml/index.d.ts",
|
|
120
|
+
"default": "./dist/uml/index.js"
|
|
121
|
+
},
|
|
122
|
+
"require": {
|
|
123
|
+
"types": "./dist/uml/index.d.cts",
|
|
124
|
+
"default": "./dist/uml/index.cjs"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
107
127
|
"./locales/pt-br": {
|
|
108
128
|
"import": {
|
|
109
129
|
"types": "./dist/locales/pt-br.d.ts",
|
|
@@ -142,6 +162,12 @@
|
|
|
142
162
|
"organogram",
|
|
143
163
|
"organizational-chart",
|
|
144
164
|
"hierarchy",
|
|
165
|
+
"prisma",
|
|
166
|
+
"prisma-2020",
|
|
167
|
+
"systematic-review",
|
|
168
|
+
"uml",
|
|
169
|
+
"uml-class-diagram",
|
|
170
|
+
"class-diagram",
|
|
145
171
|
"svg",
|
|
146
172
|
"diagram",
|
|
147
173
|
"mcgoldrick",
|
package/dist/chunk-O3BT2O42.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// src/core/xml.ts
|
|
2
|
-
function xmlEscape(text) {
|
|
3
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// src/core/roman.ts
|
|
7
|
-
var ROMAN_TABLE = [
|
|
8
|
-
[1e3, "M"],
|
|
9
|
-
[900, "CM"],
|
|
10
|
-
[500, "D"],
|
|
11
|
-
[400, "CD"],
|
|
12
|
-
[100, "C"],
|
|
13
|
-
[90, "XC"],
|
|
14
|
-
[50, "L"],
|
|
15
|
-
[40, "XL"],
|
|
16
|
-
[10, "X"],
|
|
17
|
-
[9, "IX"],
|
|
18
|
-
[5, "V"],
|
|
19
|
-
[4, "IV"],
|
|
20
|
-
[1, "I"]
|
|
21
|
-
];
|
|
22
|
-
function romanNumeral(n) {
|
|
23
|
-
if (!Number.isInteger(n) || n < 1 || n > 3999) return String(n);
|
|
24
|
-
let remaining = n;
|
|
25
|
-
let out = "";
|
|
26
|
-
for (const [value, symbol] of ROMAN_TABLE) {
|
|
27
|
-
while (remaining >= value) {
|
|
28
|
-
out += symbol;
|
|
29
|
-
remaining -= value;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return out;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/core/geometry.ts
|
|
36
|
-
function pathData(points) {
|
|
37
|
-
return points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// src/core/text.ts
|
|
41
|
-
var CHAR_W = 0.6;
|
|
42
|
-
function estimateTextWidth(text, fontPx) {
|
|
43
|
-
return text.length * fontPx * CHAR_W;
|
|
44
|
-
}
|
|
45
|
-
function wrapLabel(label, perLine, maxLines = 2) {
|
|
46
|
-
if (label.length <= perLine) return [label];
|
|
47
|
-
const cap = (s) => s.length > perLine ? s.slice(0, Math.max(1, perLine - 1)) + "\u2026" : s;
|
|
48
|
-
const lines = [""];
|
|
49
|
-
for (const word of label.split(/\s+/)) {
|
|
50
|
-
const last = lines.length - 1;
|
|
51
|
-
const current = lines[last];
|
|
52
|
-
if (current === "" || (current + " " + word).length <= perLine) {
|
|
53
|
-
lines[last] = current === "" ? word : `${current} ${word}`;
|
|
54
|
-
} else if (lines.length < maxLines) {
|
|
55
|
-
lines.push(word);
|
|
56
|
-
} else {
|
|
57
|
-
lines[last] = `${current} ${word}`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
61
|
-
return lines.map(cap);
|
|
62
|
-
}
|
|
63
|
-
function wrapLabelBalanced(label, maxLines) {
|
|
64
|
-
const perLine = Math.min(26, Math.max(14, Math.ceil(label.length / 2) + 2));
|
|
65
|
-
return wrapLabel(label, perLine, maxLines);
|
|
66
|
-
}
|
|
67
|
-
function clampLabel(label, maxChars) {
|
|
68
|
-
if (maxChars === void 0 || label.length <= maxChars) return label;
|
|
69
|
-
return label.slice(0, Math.max(1, maxChars - 1)) + "\u2026";
|
|
70
|
-
}
|
|
71
|
-
var FONT_FAMILY = "Helvetica, Arial, sans-serif";
|
|
72
|
-
|
|
73
|
-
// src/core/legend.ts
|
|
74
|
-
var LEGEND_ROW_H = 18;
|
|
75
|
-
var LEGEND_PAD = 16;
|
|
76
|
-
var LEGEND_SWATCH_W = 22;
|
|
77
|
-
var LEGEND_GAP = 14;
|
|
78
|
-
var LEGEND_FONT = 11;
|
|
79
|
-
var LEGEND_TEXT_FILL = "#52525b";
|
|
80
|
-
function legendBlock(entries, startY) {
|
|
81
|
-
if (entries.length === 0) return { svg: "", width: 0, height: startY };
|
|
82
|
-
const rows = entries.map((entry, i) => {
|
|
83
|
-
const rowCenterY = startY + i * LEGEND_ROW_H + LEGEND_ROW_H / 2;
|
|
84
|
-
const textX = LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP;
|
|
85
|
-
return entry.swatch(LEGEND_PAD, rowCenterY) + `<text x="${textX}" y="${rowCenterY + LEGEND_FONT * 0.32}" font-family="${FONT_FAMILY}" font-size="${LEGEND_FONT}" fill="${LEGEND_TEXT_FILL}">${xmlEscape(entry.label)}</text>`;
|
|
86
|
-
});
|
|
87
|
-
const widestLabel = entries.reduce((m, e) => Math.max(m, estimateTextWidth(e.label, LEGEND_FONT)), 0);
|
|
88
|
-
return {
|
|
89
|
-
svg: `<g data-compasso-legend="true">${rows.join("")}</g>`,
|
|
90
|
-
width: LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP + widestLabel + LEGEND_PAD,
|
|
91
|
-
height: startY + entries.length * LEGEND_ROW_H + LEGEND_PAD / 2
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/core/stroke.ts
|
|
96
|
-
var EDGE_STROKE = {
|
|
97
|
-
plain: { width: 1.5, dash: null, opacity: 0.6 },
|
|
98
|
-
close: { width: 3, dash: null, opacity: 0.85 },
|
|
99
|
-
distant: { width: 1.5, dash: [4, 4], opacity: 0.55 },
|
|
100
|
-
conflict: { width: 2, dash: [2, 2], opacity: 0.75 },
|
|
101
|
-
cutoff: { width: 1.5, dash: [6, 5], opacity: 0.4 }
|
|
102
|
-
};
|
|
103
|
-
var QUALITY_LEXICON_EN = {
|
|
104
|
-
buckets: [
|
|
105
|
-
{
|
|
106
|
-
style: "close",
|
|
107
|
-
needles: ["close", "warm", "support", "lov", "affection", "caring", "tight", "harmon", "healthy"]
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
style: "distant",
|
|
111
|
-
needles: ["distant", "detach", "absent", "cold", "drift"]
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
style: "conflict",
|
|
115
|
-
needles: ["conflict", "fight", "tens", "difficult", "hostil", "violen", "abus", "aggress", "complicat", "toxic", "argu"]
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
style: "cutoff",
|
|
119
|
-
needles: ["estrang", "cut off", "cutoff", "no contact", "broken off", "sever"]
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
negations: ["not", "never", "no longer", "hardly"]
|
|
123
|
-
};
|
|
124
|
-
function normalizeText(text) {
|
|
125
|
-
return text.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
126
|
-
}
|
|
127
|
-
var escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
128
|
-
function qualityLineStyle(quality, lexicon = QUALITY_LEXICON_EN) {
|
|
129
|
-
if (quality === null) return "plain";
|
|
130
|
-
const haystack = normalizeText(quality);
|
|
131
|
-
if (haystack.trim() === "") return "plain";
|
|
132
|
-
if (lexicon.negations.length > 0) {
|
|
133
|
-
const negation = new RegExp(`\\b(${lexicon.negations.map(escapeRegExp).join("|")})\\b`);
|
|
134
|
-
if (negation.test(haystack)) return "plain";
|
|
135
|
-
}
|
|
136
|
-
const matched = [];
|
|
137
|
-
for (const { style, needles } of lexicon.buckets) {
|
|
138
|
-
if (needles.some((n) => haystack.includes(n))) matched.push(style);
|
|
139
|
-
}
|
|
140
|
-
return matched.length === 1 ? matched[0] : "plain";
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export { CHAR_W, EDGE_STROKE, FONT_FAMILY, LEGEND_FONT, LEGEND_GAP, LEGEND_PAD, LEGEND_ROW_H, LEGEND_SWATCH_W, QUALITY_LEXICON_EN, clampLabel, estimateTextWidth, legendBlock, normalizeText, pathData, qualityLineStyle, romanNumeral, wrapLabel, wrapLabelBalanced, xmlEscape };
|
|
144
|
-
//# sourceMappingURL=chunk-O3BT2O42.js.map
|
|
145
|
-
//# sourceMappingURL=chunk-O3BT2O42.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/xml.ts","../src/core/roman.ts","../src/core/geometry.ts","../src/core/text.ts","../src/core/legend.ts","../src/core/stroke.ts"],"names":[],"mappings":";AAMO,SAAS,UAAU,IAAA,EAAsB;AAC9C,EAAA,OAAO,KACJ,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA,CACrB,OAAA,CAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,IAAA,EAAM,MAAM,EACpB,OAAA,CAAQ,IAAA,EAAM,QAAQ,CAAA,CACtB,OAAA,CAAQ,MAAM,QAAQ,CAAA;AAC3B;;;ACPA,IAAM,WAAA,GAAwD;AAAA,EAC5D,CAAC,KAAM,GAAG,CAAA;AAAA,EACV,CAAC,KAAK,IAAI,CAAA;AAAA,EACV,CAAC,KAAK,GAAG,CAAA;AAAA,EACT,CAAC,KAAK,IAAI,CAAA;AAAA,EACV,CAAC,KAAK,GAAG,CAAA;AAAA,EACT,CAAC,IAAI,IAAI,CAAA;AAAA,EACT,CAAC,IAAI,GAAG,CAAA;AAAA,EACR,CAAC,IAAI,IAAI,CAAA;AAAA,EACT,CAAC,IAAI,GAAG,CAAA;AAAA,EACR,CAAC,GAAG,IAAI,CAAA;AAAA,EACR,CAAC,GAAG,GAAG,CAAA;AAAA,EACP,CAAC,GAAG,IAAI,CAAA;AAAA,EACR,CAAC,GAAG,GAAG;AACT,CAAA;AAIO,SAAS,aAAa,CAAA,EAAmB;AAC9C,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,IAAK,CAAA,GAAI,IAAA,EAAM,OAAO,MAAA,CAAO,CAAC,CAAA;AAC9D,EAAA,IAAI,SAAA,GAAY,CAAA;AAChB,EAAA,IAAI,GAAA,GAA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AAA,KAAW,CAAA,GAAI,OAAA,CAAQ,CAAC,CAAA,GAAK,OAAA;AAC9C","file":"chunk-O3BT2O42.js","sourcesContent":["// XML/SVG escaping — every interpolated text in an emitted SVG MUST pass through\n// this. Diagram labels are typically user/author-controlled, and the SVG string may\n// be injected via innerHTML in a browser or embedded as vectors in a PDF — an\n// unescaped label is an XSS / `</svg>`-breakout vector on every surface at once.\n\n/** Escapes a string for use in SVG/XML text content AND attribute values. */\nexport function xmlEscape(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n","// Roman numeral formatting for level/generation labels (pedigree generation rows\n// I, II, III…; any leveled diagram). Standard subtractive notation, valid for\n// integers 1..3999. A renderer must NEVER crash on a weird generation index, so\n// out-of-range / non-integer inputs fall back to the Arabic number as a string\n// rather than throwing or emitting nonsense like \"MMMM…\". Pure + deterministic.\n\nconst ROMAN_TABLE: ReadonlyArray<readonly [number, string]> = [\n [1000, \"M\"],\n [900, \"CM\"],\n [500, \"D\"],\n [400, \"CD\"],\n [100, \"C\"],\n [90, \"XC\"],\n [50, \"L\"],\n [40, \"XL\"],\n [10, \"X\"],\n [9, \"IX\"],\n [5, \"V\"],\n [4, \"IV\"],\n [1, \"I\"],\n];\n\n/** Uppercase Roman numeral for an integer in 1..3999 (1→\"I\", 4→\"IV\", 1990→\"MCMXC\").\n * Out of range or non-integer → the Arabic number as a string (graceful fallback). */\nexport function romanNumeral(n: number): string {\n if (!Number.isInteger(n) || n < 1 || n > 3999) return String(n);\n let remaining = n;\n let out = \"\";\n for (const [value, symbol] of ROMAN_TABLE) {\n while (remaining >= value) {\n out += symbol;\n remaining -= value;\n }\n }\n return out;\n}\n","// Shared geometry primitives.\n\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** \"M x y L x y …\" path data from a polyline. */\nexport function pathData(points: Point[]): string {\n return points.map((p, i) => `${i === 0 ? \"M\" : \"L\"} ${p.x} ${p.y}`).join(\" \");\n}\n","// Pure, deterministic text metrics — no DOM, no canvas, no font files. Every layout\n// in this library reserves space from these estimates and every emitter draws with\n// the same constants, so what is proven collision-free is what is drawn.\n\n/**\n * Conservative per-character advance, as a fraction of the font size. The pure module\n * can't measure real glyphs (no DOM/canvas), so it estimates width = chars * font *\n * CHAR_W. It is deliberately a touch WIDER than Helvetica's ~0.5 average advance: a\n * layout reserves slightly more room than the text needs, so the real render always\n * fits inside its reserved box.\n */\nexport const CHAR_W = 0.6;\n\n/** Pure, deterministic width estimate for a single line of text at `fontPx`. */\nexport function estimateTextWidth(text: string, fontPx: number): number {\n return text.length * fontPx * CHAR_W;\n}\n\n/**\n * Wraps a label onto up to `maxLines` lines (default 2) so long labels don't sprawl.\n * Greedy word fill; each line capped at `perLine` chars (…-truncated only if a line\n * still overflows). The LAST allowed line absorbs every remaining word before the cap\n * applies — words are never dropped mid-label, only visibly elided. Pure + shared so\n * every renderer wraps identically. The full text is always kept elsewhere (the\n * node's `label`, an SVG <title>, or a side list), so nothing is silently lost.\n *\n * INVARIANT: with the default `maxLines` the output is byte-identical to the\n * historical two-line implementation (pinned by test/core/text.test.ts) — both\n * shipped renderers wrap through here.\n */\nexport function wrapLabel(label: string, perLine: number, maxLines = 2): string[] {\n if (label.length <= perLine) return [label];\n const cap = (s: string): string =>\n s.length > perLine ? s.slice(0, Math.max(1, perLine - 1)) + \"…\" : s;\n const lines: string[] = [\"\"];\n for (const word of label.split(/\\s+/)) {\n const last = lines.length - 1;\n const current = lines[last]!;\n if (current === \"\" || (current + \" \" + word).length <= perLine) {\n lines[last] = current === \"\" ? word : `${current} ${word}`;\n } else if (lines.length < maxLines) {\n lines.push(word);\n } else {\n lines[last] = `${current} ${word}`;\n }\n }\n // A trailing-whitespace \"word\" (\"a b \".split(/\\s+/) → [\"a\",\"b\",\"\"]) may open a line\n // it never fills; the historical code dropped that empty line, so this does too.\n if (lines.length > 1 && lines[lines.length - 1] === \"\") lines.pop();\n return lines.map(cap);\n}\n\n/**\n * House \"balanced\" wrap policy (extracted verbatim from the ecomap's tie-label wrap,\n * itself mirroring the genogram's): per-line budget `min(26, max(14, ceil(len/2)+2))`\n * splits a medium label into two roughly even lines instead of one long + one short,\n * then the greedy `wrapLabel` fill (and its `maxLines` semantics) applies. The shipped\n * renderers keep their local copies for now — new modules consume this one; migrating\n * them is a separate provably-zero-change refactor.\n */\nexport function wrapLabelBalanced(label: string, maxLines?: number): string[] {\n const perLine = Math.min(26, Math.max(14, Math.ceil(label.length / 2) + 2));\n return wrapLabel(label, perLine, maxLines);\n}\n\n/** Caps a verbatim label for a COMPACT render (preview); full text kept by the caller. */\nexport function clampLabel(label: string, maxChars: number | undefined): string {\n if (maxChars === undefined || label.length <= maxChars) return label;\n return label.slice(0, Math.max(1, maxChars - 1)) + \"…\";\n}\n\n/** Font stack shared by every emitter; PDF embedders typically map it onto Helvetica. */\nexport const FONT_FAMILY = \"Helvetica, Arial, sans-serif\";\n","// Shared legend machinery — the exact row format the genogram and ecomap emitters\n// currently duplicate character-for-character (`<g data-compasso-legend=\"true\">` with\n// swatch-closure rows). Extracted so new diagram modules don't add a third copy;\n// the two shipped emitters keep their local blocks for now (migrating them is a\n// separate, provably-zero-change refactor — pinned byte-for-byte against the ecomap's\n// emitted legend in test/core/legend.test.ts).\n//\n// The caller stays in charge of the HONESTY RULE half: it decides WHICH entries exist\n// (used-keys-only) and what each swatch draws; this module only owns the row geometry,\n// the text emission (xmlEscape — labels may come from caller-supplied packs), and the\n// width/height bookkeeping both renderers compute identically.\n\nimport { FONT_FAMILY, estimateTextWidth } from \"./text\";\nimport { xmlEscape } from \"./xml\";\n\n// Row metrics shared by every legend in the library. Exported because swatch builders\n// need them (a line swatch spans LEGEND_SWATCH_W; a glyph swatch centers on it).\nexport const LEGEND_ROW_H = 18;\nexport const LEGEND_PAD = 16;\nexport const LEGEND_SWATCH_W = 22;\nexport const LEGEND_GAP = 14;\nexport const LEGEND_FONT = 11;\n\n// Legend text ink — the zinc glyph stroke both shipped emitters use for legend labels.\nconst LEGEND_TEXT_FILL = \"#52525b\";\n\nexport interface LegendEntry {\n /**\n * Swatch markup builder, called with the swatch's left x and the row's center y.\n * The builder owns its own escaping/rounding (it typically reuses the module's\n * glyph/line emitters); it should draw within LEGEND_SWATCH_W of x.\n */\n swatch: (x: number, yCenter: number) => string;\n /** Display label (escaped here; verbatim pack text in, escaped SVG out). */\n label: string;\n}\n\nexport interface LegendBlock {\n /** `<g data-compasso-legend=\"true\">…</g>` — empty string when there are no entries. */\n svg: string;\n /** Minimum canvas width the legend needs; callers take `max(width, block.width)`. */\n width: number;\n /** New total canvas height including the legend; callers assign it directly. */\n height: number;\n}\n\n/**\n * Emits the legend group for the given entries below `startY` (the diagram's current\n * height). Pure + deterministic; coordinates are interpolated exactly as the shipped\n * emitters do. Zero entries (used-keys-only found nothing) → no markup, zero width\n * contribution, height unchanged — safe to call unconditionally.\n */\nexport function legendBlock(entries: readonly LegendEntry[], startY: number): LegendBlock {\n if (entries.length === 0) return { svg: \"\", width: 0, height: startY };\n const rows = entries.map((entry, i) => {\n const rowCenterY = startY + i * LEGEND_ROW_H + LEGEND_ROW_H / 2;\n const textX = LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP;\n return (\n entry.swatch(LEGEND_PAD, rowCenterY) +\n `<text x=\"${textX}\" y=\"${rowCenterY + LEGEND_FONT * 0.32}\" font-family=\"${FONT_FAMILY}\" font-size=\"${LEGEND_FONT}\" fill=\"${LEGEND_TEXT_FILL}\">${xmlEscape(entry.label)}</text>`\n );\n });\n const widestLabel = entries.reduce((m, e) => Math.max(m, estimateTextWidth(e.label, LEGEND_FONT)), 0);\n return {\n svg: `<g data-compasso-legend=\"true\">${rows.join(\"\")}</g>`,\n width: LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP + widestLabel + LEGEND_PAD,\n height: startY + entries.length * LEGEND_ROW_H + LEGEND_PAD / 2,\n };\n}\n","// Edge line styles — a neutral, presentation-only style for a relationship line.\n// NOT a judgment: a deterministic, lexical hint derived from the author's own quality\n// word. The literal word always rides the element's <title>, so a style never replaces\n// what was said. Unknown/ambiguous quality → \"plain\".\n\nexport type EdgeLineStyle = \"plain\" | \"close\" | \"distant\" | \"conflict\" | \"cutoff\";\n\n/** Stroke attributes per style — shared by every renderer so SVG and PDF match. */\nexport interface EdgeStroke {\n width: number;\n /** SVG dash array / PDF dash pattern as [dash, gap]; null = solid. */\n dash: [number, number] | null;\n opacity: number;\n}\n\nexport const EDGE_STROKE: Record<EdgeLineStyle, EdgeStroke> = {\n plain: { width: 1.5, dash: null, opacity: 0.6 },\n close: { width: 3, dash: null, opacity: 0.85 },\n distant: { width: 1.5, dash: [4, 4], opacity: 0.55 },\n conflict: { width: 2, dash: [2, 2], opacity: 0.75 },\n cutoff: { width: 1.5, dash: [6, 5], opacity: 0.4 },\n};\n\n/**\n * A pluggable lexicon mapping free-text quality words onto line styles. Needles are\n * diacritic-free, lowercase substrings of the author's own words; `negations` are\n * whole words that flip the meaning of the very word a needle would match (\"not\n * close\"), so their presence makes the matcher abstain to \"plain\" rather than risk\n * an inverted visual. Locale packs (e.g. `compasso/locales/pt-br`) ship alternates.\n */\nexport interface QualityLexicon {\n buckets: readonly { style: Exclude<EdgeLineStyle, \"plain\">; needles: readonly string[] }[];\n negations: readonly string[];\n}\n\n// English default. Conservative stems: each needle is a substring match on the\n// normalized text, and the SINGLE-BUCKET rule below keeps competing signals honest.\n// \"no\" alone is deliberately NOT a negation: \"no contact\" is a genuine cutoff signal.\nexport const QUALITY_LEXICON_EN: QualityLexicon = {\n buckets: [\n {\n style: \"close\",\n needles: [\"close\", \"warm\", \"support\", \"lov\", \"affection\", \"caring\", \"tight\", \"harmon\", \"healthy\"],\n },\n {\n style: \"distant\",\n needles: [\"distant\", \"detach\", \"absent\", \"cold\", \"drift\"],\n },\n {\n style: \"conflict\",\n needles: [\"conflict\", \"fight\", \"tens\", \"difficult\", \"hostil\", \"violen\", \"abus\", \"aggress\", \"complicat\", \"toxic\", \"argu\"],\n },\n {\n style: \"cutoff\",\n needles: [\"estrang\", \"cut off\", \"cutoff\", \"no contact\", \"broken off\", \"sever\"],\n },\n ],\n negations: [\"not\", \"never\", \"no longer\", \"hardly\"],\n};\n\n/** Lowercase + strip diacritics so matching ignores accents. */\nexport function normalizeText(text: string): string {\n return text.normalize(\"NFD\").replace(/[̀-ͯ]/g, \"\").toLowerCase();\n}\n\nconst escapeRegExp = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/**\n * Maps a free-text relationship quality to a neutral line style. Deterministic and\n * conservative: returns a specific style ONLY when exactly one lexical bucket matches;\n * null/empty/ambiguous/negated/unknown all fall back to \"plain\". The caller still\n * keeps the verbatim quality word, so nothing the author said is ever lost.\n */\nexport function qualityLineStyle(\n quality: string | null,\n lexicon: QualityLexicon = QUALITY_LEXICON_EN,\n): EdgeLineStyle {\n if (quality === null) return \"plain\";\n const haystack = normalizeText(quality);\n if (haystack.trim() === \"\") return \"plain\";\n\n if (lexicon.negations.length > 0) {\n const negation = new RegExp(`\\\\b(${lexicon.negations.map(escapeRegExp).join(\"|\")})\\\\b`);\n if (negation.test(haystack)) return \"plain\";\n }\n\n const matched: EdgeLineStyle[] = [];\n for (const { style, needles } of lexicon.buckets) {\n if (needles.some((n) => haystack.includes(n))) matched.push(style);\n }\n return matched.length === 1 ? matched[0]! : \"plain\";\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ecomap/render.ts"],"names":["w","h"],"mappings":";;;AAuEO,IAAM,gBAAA,GAAiC;AAAA,EAC5C,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,OAAA;AAAA,IACP,OAAA,EAAS,SAAA;AAAA,IACT,QAAA,EAAU,aAAA;AAAA,IACV,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,UAAA,EAAY,cAAA;AAAA,EACZ,SAAA,EAAW,+BAAA;AAAA,EACX,SA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AACzB,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAC1B,EAAA,OACE,wDAAwD,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,SAAA,EAAY,CAAC,CAAA,UAAA,EAAa,CAAC,CAAA,yBAAA,EAA4B,SAAA,CAAU,OAAO,SAAS,CAAC,OAChJ,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,GACb,CAAA,MAAA,CAAA;AAEJ","file":"chunk-Q6DVTCXD.js","sourcesContent":["// Radial ecomap renderer — center node + declared external ties on 1–2 concentric\n// rings, as a SELF-CONTAINED SVG string. Pure (data in, string out), deterministic\n// (same input → same SVG), no DOM, no dependencies.\n//\n// HONESTY RULE: the diagram presents ONLY what the caller declared. A tie's line style\n// is a conservative lexical hint from the author's own quality word (ambiguous/null →\n// neutral solid line, never a synthesized value); an arrowhead appears ONLY when a\n// direction was declared (null = no arrow, never a default). The verbatim text always\n// rides the element's <title>, so a style never replaces what was said.\n//\n// Ring assignment is a deterministic PRESENTATION rule — by input order (sorted by id),\n// alternating rings when the set is large — never by any reading of the tie's content.\n//\n// Every interpolated text passes xmlEscape (labels are author-controlled; the SVG may\n// be inlined via innerHTML or embedded in a PDF). All presentation attributes are\n// literal: a standalone SVG has no stylesheet. Arrowheads are explicit polygons, NOT\n// <marker> defs — marker support is unreliable in SVG-to-PDF embedders, and inline\n// polygons also avoid def-id collisions when several SVGs share one document.\n\nimport {\n EDGE_STROKE,\n FONT_FAMILY,\n LEGEND_SWATCH_W,\n clampLabel,\n estimateTextWidth,\n legendBlock,\n qualityLineStyle,\n wrapLabelBalanced,\n xmlEscape,\n type EdgeLineStyle,\n type LegendEntry,\n type QualityLexicon,\n} from \"../core\";\n\n// ── Input model ───────────────────────────────────────────────────────────────\n\n/** Declared flow of the tie, relative to the CENTER: \"in\" = toward the center. */\nexport type EcomapDirection = \"in\" | \"out\" | \"both\";\n\n/**\n * One declared tie between the center (person/household) and an external system\n * (work, faith, friends, healthcare…). `label` is the author's own naming, kept\n * verbatim. `quality` is the author's verbatim wording about the tie (null = not\n * declared = neutral line). `direction` follows the same doctrine: null = no arrow.\n */\nexport interface EcomapTie {\n id: number;\n label: string;\n quality: string | null;\n direction: EcomapDirection | null;\n /** Optional verbatim <title> override (defaults to \"label · quality\"). */\n title?: string;\n}\n\nexport interface EcomapInput {\n /** Center node label (e.g. the person or household the map is about). */\n centerLabel: string;\n ties: EcomapTie[];\n}\n\n// ── Display vocabulary ────────────────────────────────────────────────────────\n\nexport interface EcomapLabels {\n bondStyles: Record<Exclude<EdgeLineStyle, \"plain\">, string>;\n /** Legend label for the neutral solid line (a declared tie with no styled quality). */\n neutralTie: string;\n /** Legend label for the arrowhead (declared direction of the tie). */\n direction: string;\n ariaLabel: string;\n}\n\nexport const ECOMAP_LABELS_EN: EcomapLabels = {\n bondStyles: {\n close: \"Close\",\n distant: \"Distant\",\n conflict: \"Conflictual\",\n cutoff: \"Cut off (no contact)\",\n },\n neutralTie: \"Declared tie\",\n direction: \"Declared direction of the tie\",\n ariaLabel: \"Ecomap\",\n};\n\nexport interface EcomapSvgOptions {\n /** Display clamp per tie label (verbatim text stays in the <title>). */\n maxLabelChars?: number;\n /** Node label font size (px); default 12. */\n fontSize?: number;\n /** Set false to suppress the legend (compact preview); default true. */\n legend?: boolean;\n /** Quality-word lexicon — English default; see `compasso/locales/pt-br`. */\n qualityLexicon?: QualityLexicon;\n /** Display vocabulary — English default; see locale packs. */\n labels?: EcomapLabels;\n}\n\n// ── Geometry constants ────────────────────────────────────────────────────────\n\nconst PADDING = 32;\nconst LINE_H = 14;\nconst NODE_PAD_X = 14;\nconst NODE_PAD_Y = 9;\nconst CENTER_MIN_R = 36;\nconst RING_MIN_R = 150;\n/** Min gap between two adjacent node boxes on the same ring. */\nconst NODE_GAP = 24;\n/** Radial gap between the center circle and the inner ring's nearest box edge. */\nconst RADIAL_GAP = 40;\n/** Radial gap between the two rings when the set is large enough to split. */\nconst RING_GAP = 26;\n/** Above this many ties the layout alternates between two rings. */\nconst SINGLE_RING_MAX = 8;\n\n// Ink (zinc ramp on white — matches the genogram emitter).\nconst NODE_STROKE = \"#52525b\";\nconst LABEL_FILL = \"#3f3f46\";\nconst EDGE_INK = \"#71717a\";\n// Legend row geometry + the swatch span both live in ../core (LEGEND_SWATCH_W imported\n// above for the swatch closures); the row/text/width/height bookkeeping is legendBlock.\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\n// ── Internal shapes ───────────────────────────────────────────────────────────\n\ninterface SatNode {\n tie: EcomapTie;\n lines: string[];\n rx: number;\n ry: number;\n /** Filled once ring radii are known. */\n x: number;\n y: number;\n angle: number;\n style: EdgeLineStyle;\n}\n\n/** Arrowhead polygon: tip at (tipX,tipY), pointing along the unit vector (ux,uy). */\nfunction arrowHead(tipX: number, tipY: number, ux: number, uy: number, opacity: number): string {\n const LEN = 9;\n const HALF_W = 4.5;\n const bx = tipX - ux * LEN;\n const by = tipY - uy * LEN;\n const px = -uy;\n const py = ux;\n const points = [\n `${round(tipX)},${round(tipY)}`,\n `${round(bx + px * HALF_W)},${round(by + py * HALF_W)}`,\n `${round(bx - px * HALF_W)},${round(by - py * HALF_W)}`,\n ].join(\" \");\n return `<polygon points=\"${points}\" fill=\"${EDGE_INK}\" fill-opacity=\"${opacity}\"/>`;\n}\n\n/**\n * Renders a declared ecomap to a self-contained SVG string. Deterministic: same data →\n * same SVG. Zero ties yield a valid center-only SVG; callers decide their own empty\n * state before calling. The root keeps numeric width/height attributes plus a matching\n * viewBox (PDF-embedder contract).\n */\nexport function ecomapSvg(input: EcomapInput, opts: EcomapSvgOptions = {}): string {\n const fontSize = opts.fontSize ?? 12;\n const labels = opts.labels ?? ECOMAP_LABELS_EN;\n\n // ── Measure every satellite box (deterministic order: by tie id). ───────────\n const sats: SatNode[] = [...input.ties]\n .sort((a, b) => a.id - b.id)\n .map((tie) => {\n const lines = wrapLabelBalanced(clampLabel(tie.label, opts.maxLabelChars));\n const w = Math.max(...lines.map((l) => estimateTextWidth(l, fontSize))) + NODE_PAD_X * 2;\n const h = lines.length * LINE_H + NODE_PAD_Y * 2;\n return {\n tie,\n lines,\n rx: Math.max(40, w / 2),\n ry: Math.max(20, h / 2),\n x: 0,\n y: 0,\n angle: 0,\n style: qualityLineStyle(tie.quality, opts.qualityLexicon),\n };\n });\n\n const centerLines = wrapLabelBalanced(input.centerLabel);\n const centerR = Math.max(\n CENTER_MIN_R,\n Math.max(...centerLines.map((l) => estimateTextWidth(l, fontSize))) / 2 + 12,\n (centerLines.length * LINE_H) / 2 + 12,\n );\n\n // ── Ring radii: wide enough that NO two node boxes can ever touch. The safe\n // center-to-center distance is the diagonal of the worst-case box pair: if the\n // euclidean distance is ≥ hypot(width-sum, height-sum), the axis-aligned boxes\n // cannot overlap in both axes at once. Overlap-proof by construction, not by luck.\n const n = sats.length;\n const maxRx = n > 0 ? Math.max(...sats.map((s) => s.rx)) : 0;\n const maxRy = n > 0 ? Math.max(...sats.map((s) => s.ry)) : 0;\n const twoRings = n > SINGLE_RING_MAX;\n const stepAngle = n > 0 ? (Math.PI * 2) / n : Math.PI;\n const safeDist = Math.hypot(2 * maxRx + NODE_GAP, 2 * maxRy + NODE_GAP);\n /** Min radius so two nodes `steps` angular steps apart on the SAME ring clear safeDist. */\n const sameRingRadius = (steps: number): number => {\n const theta = steps * stepAngle;\n if (n <= 1 || theta >= Math.PI) return 0; // ≤2 nodes on the ring: no chord constraint\n return safeDist / (2 * Math.sin(theta / 2));\n };\n const ringStep = maxRy * 2 + RING_GAP;\n let innerR = Math.max(\n RING_MIN_R,\n centerR + RADIAL_GAP + maxRy,\n sameRingRadius(twoRings ? 2 : 1),\n );\n if (twoRings) {\n // Cross-ring neighbors sit 1 step apart at radii r and r+ringStep. Their distance\n // sqrt(r² + (r+s)² − 2r(r+s)cosΔ) grows monotonically with r — widen the inner ring\n // in fixed increments until it clears safeDist (deterministic, always terminates).\n const crossDist = (r: number): number =>\n Math.sqrt(r * r + (r + ringStep) ** 2 - 2 * r * (r + ringStep) * Math.cos(stepAngle));\n while (crossDist(innerR) < safeDist) innerR += 8;\n }\n const outerR = innerR + ringStep;\n\n for (let i = 0; i < n; i++) {\n const s = sats[i]!;\n s.angle = -Math.PI / 2 + (i * Math.PI * 2) / n;\n const r = twoRings && i % 2 === 1 ? outerR : innerR;\n s.x = r * Math.cos(s.angle);\n s.y = r * Math.sin(s.angle);\n }\n\n // ── Canvas bounds (center at origin until here), then shift positive. ───────\n let minX = -centerR;\n let minY = -centerR;\n let maxX = centerR;\n let maxY = centerR;\n for (const s of sats) {\n minX = Math.min(minX, s.x - s.rx);\n minY = Math.min(minY, s.y - s.ry);\n maxX = Math.max(maxX, s.x + s.rx);\n maxY = Math.max(maxY, s.y + s.ry);\n }\n const dx = PADDING - minX;\n const dy = PADDING - minY;\n const cx = dx;\n const cy = dy;\n for (const s of sats) {\n s.x += dx;\n s.y += dy;\n }\n let width = maxX - minX + PADDING * 2;\n let height = maxY - minY + PADDING * 2;\n\n const parts: string[] = [];\n\n // ── Tie lines first (nodes sit on top), one group per declared tie. ─────────\n for (const s of sats) {\n const ux = (cx - s.x) / Math.hypot(cx - s.x, cy - s.y);\n const uy = (cy - s.y) / Math.hypot(cx - s.x, cy - s.y);\n // Node-edge endpoint: ellipse boundary along the unit vector toward the center.\n const scale = 1 / Math.hypot(ux / s.rx, uy / s.ry);\n const x1 = s.x + ux * scale;\n const y1 = s.y + uy * scale;\n // Center-edge endpoint: circle boundary along the same direction.\n const x2 = cx - ux * centerR;\n const y2 = cy - uy * centerR;\n\n const ink = EDGE_STROKE[s.style];\n const dashAttr = ink.dash === null ? \"\" : ` stroke-dasharray=\"${ink.dash[0]} ${ink.dash[1]}\"`;\n const title = s.tie.title ?? (s.tie.quality !== null ? `${s.tie.label} · ${s.tie.quality}` : s.tie.label);\n const body: string[] = [\n `<line x1=\"${round(x1)}\" y1=\"${round(y1)}\" x2=\"${round(x2)}\" y2=\"${round(y2)}\" stroke=\"${EDGE_INK}\" stroke-width=\"${ink.width}\" stroke-opacity=\"${ink.opacity}\"${dashAttr}/>`,\n ];\n // Arrowheads ONLY for a declared direction. \"in\" points at the center, \"out\" at\n // the external system, \"both\" draws both. Tips back off the boundary so the\n // triangle never pokes into the shape.\n if (s.tie.direction === \"in\" || s.tie.direction === \"both\") {\n body.push(arrowHead(x2, y2, ux, uy, ink.opacity)); // tip at the center edge\n }\n if (s.tie.direction === \"out\" || s.tie.direction === \"both\") {\n body.push(arrowHead(x1, y1, -ux, -uy, ink.opacity)); // tip at the system edge\n }\n parts.push(`<g data-edge-id=\"${s.tie.id}\"><title>${xmlEscape(title)}</title>${body.join(\"\")}</g>`);\n }\n\n // ── Center node. ─────────────────────────────────────────────────────────────\n {\n const tspans = centerLines\n .map(\n (line, i) =>\n `<tspan x=\"${round(cx)}\" y=\"${round(cy - ((centerLines.length - 1) * LINE_H) / 2 + i * LINE_H + fontSize * 0.32)}\">${xmlEscape(line)}</tspan>`,\n )\n .join(\"\");\n parts.push(\n `<g data-individual-id=\"center\"><title>${xmlEscape(input.centerLabel)}</title>` +\n `<circle cx=\"${round(cx)}\" cy=\"${round(cy)}\" r=\"${round(centerR)}\" fill=\"transparent\" stroke=\"${NODE_STROKE}\" stroke-width=\"2\"/>` +\n `<text text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${fontSize}\" fill=\"${LABEL_FILL}\">${tspans}</text></g>`,\n );\n }\n\n // ── Satellite nodes. ─────────────────────────────────────────────────────────\n for (const s of sats) {\n const tspans = s.lines\n .map(\n (line, i) =>\n `<tspan x=\"${round(s.x)}\" y=\"${round(s.y - ((s.lines.length - 1) * LINE_H) / 2 + i * LINE_H + fontSize * 0.32)}\">${xmlEscape(line)}</tspan>`,\n )\n .join(\"\");\n parts.push(\n `<g data-individual-id=\"e${s.tie.id}\"><title>${xmlEscape(s.tie.label)}</title>` +\n `<ellipse cx=\"${round(s.x)}\" cy=\"${round(s.y)}\" rx=\"${round(s.rx)}\" ry=\"${round(s.ry)}\" fill=\"transparent\" stroke=\"${NODE_STROKE}\" stroke-width=\"1.5\"/>` +\n `<text text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${fontSize}\" fill=\"${LABEL_FILL}\">${tspans}</text></g>`,\n );\n }\n\n // ── Minimal legend: only entries actually used. ──────────────────────────────\n if (opts.legend !== false && sats.length > 0) {\n const entries: LegendEntry[] = [];\n\n if (sats.some((s) => s.style === \"plain\")) {\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"${EDGE_STROKE.plain.width}\" stroke-opacity=\"${EDGE_STROKE.plain.opacity}\"/>`,\n label: labels.neutralTie,\n });\n }\n const stylesUsed = new Set(sats.map((s) => s.style));\n for (const style of [\"close\", \"distant\", \"conflict\", \"cutoff\"] as const) {\n if (!stylesUsed.has(style)) continue;\n const ink = EDGE_STROKE[style];\n const dashAttr = ink.dash === null ? \"\" : ` stroke-dasharray=\"${ink.dash[0]} ${ink.dash[1]}\"`;\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"${ink.width}\" stroke-opacity=\"${ink.opacity}\"${dashAttr}/>`,\n label: labels.bondStyles[style],\n });\n }\n if (sats.some((s) => s.tie.direction !== null)) {\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W - 8}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"1.5\" stroke-opacity=\"0.75\"/>` +\n arrowHead(x + LEGEND_SWATCH_W, y, 1, 0, 0.75),\n label: labels.direction,\n });\n }\n\n if (entries.length > 0) {\n const block = legendBlock(entries, height);\n parts.push(block.svg);\n width = Math.max(width, block.width);\n height = block.height;\n }\n }\n\n const w = Math.ceil(width);\n const h = Math.ceil(height);\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${w} ${h}\" width=\"${w}\" height=\"${h}\" role=\"img\" aria-label=\"${xmlEscape(labels.ariaLabel)}\">` +\n parts.join(\"\") +\n `</svg>`\n );\n}\n"]}
|