compasso 0.1.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-5RRRE2GF.js +1125 -0
  4. package/dist/chunk-5RRRE2GF.js.map +1 -0
  5. package/dist/chunk-E456YKAJ.js +86 -0
  6. package/dist/chunk-E456YKAJ.js.map +1 -0
  7. package/dist/chunk-L5CYESBI.js +208 -0
  8. package/dist/chunk-L5CYESBI.js.map +1 -0
  9. package/dist/core/index.cjs +98 -0
  10. package/dist/core/index.cjs.map +1 -0
  11. package/dist/core/index.d.cts +36 -0
  12. package/dist/core/index.d.ts +36 -0
  13. package/dist/core/index.js +3 -0
  14. package/dist/core/index.js.map +1 -0
  15. package/dist/ecomap/index.cjs +287 -0
  16. package/dist/ecomap/index.cjs.map +1 -0
  17. package/dist/ecomap/index.d.cts +53 -0
  18. package/dist/ecomap/index.d.ts +53 -0
  19. package/dist/ecomap/index.js +4 -0
  20. package/dist/ecomap/index.js.map +1 -0
  21. package/dist/genogram/index.cjs +1222 -0
  22. package/dist/genogram/index.cjs.map +1 -0
  23. package/dist/genogram/index.d.cts +149 -0
  24. package/dist/genogram/index.d.ts +149 -0
  25. package/dist/genogram/index.js +4 -0
  26. package/dist/genogram/index.js.map +1 -0
  27. package/dist/index.cjs +1441 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +5 -0
  30. package/dist/index.d.ts +5 -0
  31. package/dist/index.js +5 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/kinship-BARO5-qz.d.cts +115 -0
  34. package/dist/kinship-Bkf87Jhu.d.ts +115 -0
  35. package/dist/locales/pt-br.cjs +123 -0
  36. package/dist/locales/pt-br.cjs.map +1 -0
  37. package/dist/locales/pt-br.d.cts +11 -0
  38. package/dist/locales/pt-br.d.ts +11 -0
  39. package/dist/locales/pt-br.js +117 -0
  40. package/dist/locales/pt-br.js.map +1 -0
  41. package/dist/stroke-MQ427drt.d.cts +35 -0
  42. package/dist/stroke-MQ427drt.d.ts +35 -0
  43. package/package.json +72 -0
@@ -0,0 +1,149 @@
1
+ import { N as NodeShape, e as KinshipLexicon, d as GenogramTitleLabels, f as Person, i as Union, P as ParentLink, R as Relationship, c as GenogramSvgLabels, j as UnionStatus, b as GenogramInput } from '../kinship-Bkf87Jhu.js';
2
+ export { G as GENOGRAM_SVG_LABELS_EN, a as GENOGRAM_TITLE_LABELS_EN, K as KINSHIP_EN, g as PersonSex, h as RelationshipMapClass, U as UNION_STATUSES, k as classifyRelationshipType, r as relationshipTypeTokens } from '../kinship-Bkf87Jhu.js';
3
+ import { Point } from '../core/index.js';
4
+ export { CHAR_W, estimateTextWidth, wrapLabel, xmlEscape } from '../core/index.js';
5
+ import { a as EdgeLineStyle, c as QualityLexicon } from '../stroke-MQ427drt.js';
6
+ export { E as EDGE_STROKE, b as EdgeStroke, q as qualityLineStyle } from '../stroke-MQ427drt.js';
7
+
8
+ declare const NODE_SIZE = 56;
9
+ /** Node label font size (px). The live SVG renders at this size; the PDF scales it. */
10
+ declare const LABEL_FONT = 12;
11
+ /** Line height for stacked node-label lines (px). */
12
+ declare const LABEL_LINE_H = 14;
13
+ /** Edge label font size (px) — kept for the shared metrics contract (invariant #9). */
14
+ declare const EDGE_FONT = 11;
15
+ declare const UNION_REL_ID_BASE = 1000000;
16
+ declare const PARENT_REL_ID_BASE = 2000000;
17
+ declare const PROMOTED_REL_ID_BASE = 3000000;
18
+ /**
19
+ * Per-edge VISUAL union style applied at emission (§7.2 / FIX 3) — the McGoldrick
20
+ * notation for a declared union TYPE, WITHOUT touching the layout or the patient's
21
+ * words. `coparental` never gets one (it draws no edge). Defined here (not in
22
+ * fallback-svg) so a routed element can carry it and the emitter stays free of layout
23
+ * cycles; fallback-svg re-exports it for the existing call sites.
24
+ */
25
+ interface UnionEdgeStyle {
26
+ /** Inline stroke-dasharray [dash, gap] on the bar; absent = solid (e.g. casado). */
27
+ dash?: readonly [number, number];
28
+ /** Diagonal status slashes at the midpoint: 1 = separação, 2 = divórcio. */
29
+ slashes?: 0 | 1 | 2;
30
+ }
31
+ interface GenogramNode {
32
+ personId: number;
33
+ /** Full, verbatim label (used for tooltips/aria — never truncated). */
34
+ label: string;
35
+ shape: NodeShape;
36
+ deceased: boolean;
37
+ /** Center of the node. */
38
+ cx: number;
39
+ cy: number;
40
+ /** Side length (square) / diameter (circle) / width (diamond). */
41
+ size: number;
42
+ /** Pre-wrapped display lines (already capped for the requested density). */
43
+ labelLines: string[];
44
+ /** Y of the TOP of the first label line's box (each next line is +LABEL_LINE_H). */
45
+ labelTop: number;
46
+ }
47
+ /** A routed map element — the orthogonal replacement for the old straight `GenogramEdge`. */
48
+ type GenogramElementKind = "union-bar" | "union-elbow" | "descent" | "sibling-bar" | "bond";
49
+ interface GenogramElement {
50
+ kind: GenogramElementKind;
51
+ /** Source row ids for traceability; merged bonds carry every merged rel id. */
52
+ relIds: number[];
53
+ /** data-edge-id value: highest relId (matches latestUnionPerPair's highest-wins). */
54
+ edgeId: number;
55
+ fromPersonId: number | null;
56
+ toPersonId: number | null;
57
+ /** Polyline; EVERY consecutive pair is axis-aligned (H or V). */
58
+ points: Point[];
59
+ /** Verbatim titles (one per source row), joined for the <title>. */
60
+ titles: string[];
61
+ lineStyle: EdgeLineStyle;
62
+ unionStyle?: UnionEdgeStyle;
63
+ dotted?: boolean;
64
+ }
65
+ interface GenogramLayout {
66
+ width: number;
67
+ height: number;
68
+ nodes: GenogramNode[];
69
+ elements: GenogramElement[];
70
+ /** People with NO drawn structural/bond connection — grouped to the side and labeled
71
+ * "Sem ascendência registrada" so a loose glyph is never left unexplained. */
72
+ isolatedPersonIds: number[];
73
+ }
74
+ /**
75
+ * Deterministic, overlap-proof ORTHOGONAL layout (pure function of the inputs — same
76
+ * data always yields the same geometry). People are grouped by `generation` (null trails
77
+ * as a bottom row), rows ordered oldest-on-top. Declared structure is drawn as McGoldrick
78
+ * elements: same-row adjacent unions as straight bars, couples-with-children as a shared
79
+ * sibling bar, lone/co-parental genitors as dotted descents, and free-text relationships
80
+ * as orthogonally-routed bonds — NEVER promoting a bond into structure.
81
+ *
82
+ * @param unions caller-deduped (one per pair) declared couple bonds.
83
+ * @param parentLinks declared parent→child links (one row per declared genitor).
84
+ * @param relationships non-structural ties (drawn as bonds).
85
+ * @param opts.maxLabelChars cap each node's DISPLAY label to this many chars (compact
86
+ * preview); the full verbatim text is still exposed on `node.label`.
87
+ * @param opts.kinship / opts.qualityLexicon / opts.titleLabels — locale packs (English
88
+ * defaults; see `compasso/locales/pt-br`).
89
+ */
90
+ interface GenogramLayoutOptions {
91
+ maxLabelChars?: number;
92
+ kinship?: KinshipLexicon;
93
+ qualityLexicon?: QualityLexicon;
94
+ titleLabels?: GenogramTitleLabels;
95
+ }
96
+ declare function computeGenogramLayout(people: Person[], unions: Union[], parentLinks: ParentLink[], relationships: Relationship[], opts?: GenogramLayoutOptions): GenogramLayout;
97
+
98
+ interface GenogramSvgOptions {
99
+ /**
100
+ * Per-edge VISUAL union style (edgeId → {dash?, slashes?}), applied at emission.
101
+ * Gives each declared union TYPE its own McGoldrick notation. Overrides any
102
+ * `unionStyle` already on the element.
103
+ */
104
+ unionStyleByRelId?: ReadonlyMap<number, UnionEdgeStyle>;
105
+ /** Set false to suppress the legend (compact preview); default true. */
106
+ legend?: boolean;
107
+ /** Display vocabulary (legend/accessibility) — English default; see locale packs. */
108
+ labels?: GenogramSvgLabels;
109
+ }
110
+ /**
111
+ * Emits a self-contained SVG for a computed genogram layout. Pure + deterministic.
112
+ * Coordinates come straight from the layout; all interpolated text is XML-escaped; all
113
+ * presentation attributes are literal; there is NO text on map edges.
114
+ */
115
+ declare function genogramLayoutSvg(layout: GenogramLayout, opts?: GenogramSvgOptions): string;
116
+
117
+ /**
118
+ * McGoldrick notation per declared union TYPE — a per-edge VISUAL override applied at
119
+ * emission, never a synthesized quality. `coparental` is ABSENT on purpose: it draws
120
+ * NO couple element at all; the co-parenthood shows only on the descents converging
121
+ * on the child(ren).
122
+ */
123
+ declare const UNION_NOTATION: Record<Exclude<UnionStatus, "coparental">, UnionEdgeStyle>;
124
+ /**
125
+ * Duplicate unions for the same unordered pair should not exist (callers are expected
126
+ * to normalize), but if they do, the HIGHEST id wins — the most recent statement.
127
+ * NEVER a status-rank heuristic: recency is a fact, ranking would be an interpretation.
128
+ */
129
+ declare function latestUnionPerPair(unions: Union[]): Union[];
130
+ interface GenogramRenderOptions extends GenogramLayoutOptions {
131
+ /** Set false to suppress the legend (compact preview); default true. */
132
+ legend?: boolean;
133
+ /** Display vocabulary for the emitter (legend/accessibility) — English default. */
134
+ svgLabels?: GenogramSvgLabels;
135
+ }
136
+ interface GenogramRenderResult {
137
+ /** Self-contained SVG (numeric width/height + matching viewBox — PDF-embedder safe). */
138
+ svg: string;
139
+ /** The computed layout, for callers that decorate or hit-test the diagram. */
140
+ layout: GenogramLayout;
141
+ }
142
+ /**
143
+ * Renders a genogram input to a self-contained SVG string. Deterministic: same data →
144
+ * same SVG. Empty `people` yields an empty-but-valid SVG; callers decide their own
145
+ * empty state before calling.
146
+ */
147
+ declare function genogramSvg(input: GenogramInput, opts?: GenogramRenderOptions): GenogramRenderResult;
148
+
149
+ export { EDGE_FONT, EdgeLineStyle, type GenogramElement, type GenogramElementKind, GenogramInput, type GenogramLayout, type GenogramLayoutOptions, type GenogramNode, type GenogramRenderOptions, type GenogramRenderResult, GenogramSvgLabels, type GenogramSvgOptions, GenogramTitleLabels, KinshipLexicon, LABEL_FONT, LABEL_LINE_H, NODE_SIZE, NodeShape, PARENT_REL_ID_BASE, PROMOTED_REL_ID_BASE, ParentLink, Person, Point, QualityLexicon, Relationship, UNION_NOTATION, UNION_REL_ID_BASE, Union, type UnionEdgeStyle, UnionStatus, computeGenogramLayout, genogramLayoutSvg, genogramSvg, latestUnionPerPair };
@@ -0,0 +1,4 @@
1
+ export { EDGE_FONT, GENOGRAM_SVG_LABELS_EN, GENOGRAM_TITLE_LABELS_EN, KINSHIP_EN, LABEL_FONT, LABEL_LINE_H, NODE_SIZE, PARENT_REL_ID_BASE, PROMOTED_REL_ID_BASE, UNION_NOTATION, UNION_REL_ID_BASE, UNION_STATUSES, classifyRelationshipType, computeGenogramLayout, genogramLayoutSvg, genogramSvg, latestUnionPerPair, relationshipTypeTokens } from '../chunk-5RRRE2GF.js';
2
+ export { CHAR_W, EDGE_STROKE, estimateTextWidth, qualityLineStyle, wrapLabel, xmlEscape } from '../chunk-E456YKAJ.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}