schematex 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 (181) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +379 -0
  3. package/dist/chunk-2MQWZ2XY.cjs +453 -0
  4. package/dist/chunk-2MQWZ2XY.cjs.map +1 -0
  5. package/dist/chunk-2UKC6ZCY.cjs +1803 -0
  6. package/dist/chunk-2UKC6ZCY.cjs.map +1 -0
  7. package/dist/chunk-34X3ZJ6E.cjs +783 -0
  8. package/dist/chunk-34X3ZJ6E.cjs.map +1 -0
  9. package/dist/chunk-3FTUWAXK.cjs +1220 -0
  10. package/dist/chunk-3FTUWAXK.cjs.map +1 -0
  11. package/dist/chunk-3J7TFUOC.js +745 -0
  12. package/dist/chunk-3J7TFUOC.js.map +1 -0
  13. package/dist/chunk-47ZC6EMJ.js +1009 -0
  14. package/dist/chunk-47ZC6EMJ.js.map +1 -0
  15. package/dist/chunk-4DBRNOPA.cjs +750 -0
  16. package/dist/chunk-4DBRNOPA.cjs.map +1 -0
  17. package/dist/chunk-4G7ZIBHN.js +778 -0
  18. package/dist/chunk-4G7ZIBHN.js.map +1 -0
  19. package/dist/chunk-5C7DPDHQ.js +1321 -0
  20. package/dist/chunk-5C7DPDHQ.js.map +1 -0
  21. package/dist/chunk-ADOXGKAK.js +1251 -0
  22. package/dist/chunk-ADOXGKAK.js.map +1 -0
  23. package/dist/chunk-BE5HNDA5.cjs +874 -0
  24. package/dist/chunk-BE5HNDA5.cjs.map +1 -0
  25. package/dist/chunk-CZRM7LT7.js +889 -0
  26. package/dist/chunk-CZRM7LT7.js.map +1 -0
  27. package/dist/chunk-D4JTSPOL.js +1795 -0
  28. package/dist/chunk-D4JTSPOL.js.map +1 -0
  29. package/dist/chunk-DS47NTWZ.cjs +1034 -0
  30. package/dist/chunk-DS47NTWZ.cjs.map +1 -0
  31. package/dist/chunk-FDLZEKEB.js +449 -0
  32. package/dist/chunk-FDLZEKEB.js.map +1 -0
  33. package/dist/chunk-FGPTCDUT.cjs +1851 -0
  34. package/dist/chunk-FGPTCDUT.cjs.map +1 -0
  35. package/dist/chunk-HDKDQAEQ.cjs +86 -0
  36. package/dist/chunk-HDKDQAEQ.cjs.map +1 -0
  37. package/dist/chunk-IX554O5K.js +346 -0
  38. package/dist/chunk-IX554O5K.js.map +1 -0
  39. package/dist/chunk-KLJEK547.js +71 -0
  40. package/dist/chunk-KLJEK547.js.map +1 -0
  41. package/dist/chunk-LMFSHK45.js +1028 -0
  42. package/dist/chunk-LMFSHK45.js.map +1 -0
  43. package/dist/chunk-MDICUK6F.cjs +1258 -0
  44. package/dist/chunk-MDICUK6F.cjs.map +1 -0
  45. package/dist/chunk-N7KOXOMX.cjs +363 -0
  46. package/dist/chunk-N7KOXOMX.cjs.map +1 -0
  47. package/dist/chunk-NYCIK4SU.cjs +775 -0
  48. package/dist/chunk-NYCIK4SU.cjs.map +1 -0
  49. package/dist/chunk-PDPHRZZT.js +770 -0
  50. package/dist/chunk-PDPHRZZT.js.map +1 -0
  51. package/dist/chunk-ROFLJ74T.js +1212 -0
  52. package/dist/chunk-ROFLJ74T.js.map +1 -0
  53. package/dist/chunk-S6BK5DB6.cjs +845 -0
  54. package/dist/chunk-S6BK5DB6.cjs.map +1 -0
  55. package/dist/chunk-U4I37IBN.js +874 -0
  56. package/dist/chunk-U4I37IBN.js.map +1 -0
  57. package/dist/chunk-U5GGE6PJ.js +839 -0
  58. package/dist/chunk-U5GGE6PJ.js.map +1 -0
  59. package/dist/chunk-UHLYS3W5.cjs +1015 -0
  60. package/dist/chunk-UHLYS3W5.cjs.map +1 -0
  61. package/dist/chunk-URSKIHSY.cjs +881 -0
  62. package/dist/chunk-URSKIHSY.cjs.map +1 -0
  63. package/dist/chunk-V6WO7RK7.cjs +1056 -0
  64. package/dist/chunk-V6WO7RK7.cjs.map +1 -0
  65. package/dist/chunk-VFQCTXOX.js +869 -0
  66. package/dist/chunk-VFQCTXOX.js.map +1 -0
  67. package/dist/chunk-XQ52ICHU.cjs +895 -0
  68. package/dist/chunk-XQ52ICHU.cjs.map +1 -0
  69. package/dist/chunk-XX4BKS7Y.js +1051 -0
  70. package/dist/chunk-XX4BKS7Y.js.map +1 -0
  71. package/dist/chunk-XXU36667.js +1844 -0
  72. package/dist/chunk-XXU36667.js.map +1 -0
  73. package/dist/chunk-ZX7QKZK2.cjs +1326 -0
  74. package/dist/chunk-ZX7QKZK2.cjs.map +1 -0
  75. package/dist/diagrams/blockdiagram/index.cjs +25 -0
  76. package/dist/diagrams/blockdiagram/index.cjs.map +1 -0
  77. package/dist/diagrams/blockdiagram/index.d.cts +67 -0
  78. package/dist/diagrams/blockdiagram/index.d.ts +67 -0
  79. package/dist/diagrams/blockdiagram/index.js +4 -0
  80. package/dist/diagrams/blockdiagram/index.js.map +1 -0
  81. package/dist/diagrams/circuit/index.cjs +34 -0
  82. package/dist/diagrams/circuit/index.cjs.map +1 -0
  83. package/dist/diagrams/circuit/index.d.cts +138 -0
  84. package/dist/diagrams/circuit/index.d.ts +138 -0
  85. package/dist/diagrams/circuit/index.js +5 -0
  86. package/dist/diagrams/circuit/index.js.map +1 -0
  87. package/dist/diagrams/ecomap/index.cjs +30 -0
  88. package/dist/diagrams/ecomap/index.cjs.map +1 -0
  89. package/dist/diagrams/ecomap/index.d.cts +15 -0
  90. package/dist/diagrams/ecomap/index.d.ts +15 -0
  91. package/dist/diagrams/ecomap/index.js +5 -0
  92. package/dist/diagrams/ecomap/index.js.map +1 -0
  93. package/dist/diagrams/entity/index.cjs +26 -0
  94. package/dist/diagrams/entity/index.cjs.map +1 -0
  95. package/dist/diagrams/entity/index.d.cts +54 -0
  96. package/dist/diagrams/entity/index.d.ts +54 -0
  97. package/dist/diagrams/entity/index.js +5 -0
  98. package/dist/diagrams/entity/index.js.map +1 -0
  99. package/dist/diagrams/fishbone/index.cjs +34 -0
  100. package/dist/diagrams/fishbone/index.cjs.map +1 -0
  101. package/dist/diagrams/fishbone/index.d.cts +185 -0
  102. package/dist/diagrams/fishbone/index.d.ts +185 -0
  103. package/dist/diagrams/fishbone/index.js +5 -0
  104. package/dist/diagrams/fishbone/index.js.map +1 -0
  105. package/dist/diagrams/flowchart/index.cjs +34 -0
  106. package/dist/diagrams/flowchart/index.cjs.map +1 -0
  107. package/dist/diagrams/flowchart/index.d.cts +2 -0
  108. package/dist/diagrams/flowchart/index.d.ts +2 -0
  109. package/dist/diagrams/flowchart/index.js +5 -0
  110. package/dist/diagrams/flowchart/index.js.map +1 -0
  111. package/dist/diagrams/genogram/index.cjs +38 -0
  112. package/dist/diagrams/genogram/index.cjs.map +1 -0
  113. package/dist/diagrams/genogram/index.d.cts +20 -0
  114. package/dist/diagrams/genogram/index.d.ts +20 -0
  115. package/dist/diagrams/genogram/index.js +5 -0
  116. package/dist/diagrams/genogram/index.js.map +1 -0
  117. package/dist/diagrams/ladder/index.cjs +26 -0
  118. package/dist/diagrams/ladder/index.cjs.map +1 -0
  119. package/dist/diagrams/ladder/index.d.cts +49 -0
  120. package/dist/diagrams/ladder/index.d.ts +49 -0
  121. package/dist/diagrams/ladder/index.js +5 -0
  122. package/dist/diagrams/ladder/index.js.map +1 -0
  123. package/dist/diagrams/logic/index.cjs +26 -0
  124. package/dist/diagrams/logic/index.cjs.map +1 -0
  125. package/dist/diagrams/logic/index.d.cts +73 -0
  126. package/dist/diagrams/logic/index.d.ts +73 -0
  127. package/dist/diagrams/logic/index.js +5 -0
  128. package/dist/diagrams/logic/index.js.map +1 -0
  129. package/dist/diagrams/orgchart/index.cjs +30 -0
  130. package/dist/diagrams/orgchart/index.cjs.map +1 -0
  131. package/dist/diagrams/orgchart/index.d.cts +100 -0
  132. package/dist/diagrams/orgchart/index.d.ts +100 -0
  133. package/dist/diagrams/orgchart/index.js +5 -0
  134. package/dist/diagrams/orgchart/index.js.map +1 -0
  135. package/dist/diagrams/pedigree/index.cjs +30 -0
  136. package/dist/diagrams/pedigree/index.cjs.map +1 -0
  137. package/dist/diagrams/pedigree/index.d.cts +15 -0
  138. package/dist/diagrams/pedigree/index.d.ts +15 -0
  139. package/dist/diagrams/pedigree/index.js +5 -0
  140. package/dist/diagrams/pedigree/index.js.map +1 -0
  141. package/dist/diagrams/phylo/index.cjs +30 -0
  142. package/dist/diagrams/phylo/index.cjs.map +1 -0
  143. package/dist/diagrams/phylo/index.d.cts +32 -0
  144. package/dist/diagrams/phylo/index.d.ts +32 -0
  145. package/dist/diagrams/phylo/index.js +5 -0
  146. package/dist/diagrams/phylo/index.js.map +1 -0
  147. package/dist/diagrams/sld/index.cjs +26 -0
  148. package/dist/diagrams/sld/index.cjs.map +1 -0
  149. package/dist/diagrams/sld/index.d.cts +58 -0
  150. package/dist/diagrams/sld/index.d.ts +58 -0
  151. package/dist/diagrams/sld/index.js +5 -0
  152. package/dist/diagrams/sld/index.js.map +1 -0
  153. package/dist/diagrams/sociogram/index.cjs +26 -0
  154. package/dist/diagrams/sociogram/index.cjs.map +1 -0
  155. package/dist/diagrams/sociogram/index.d.cts +76 -0
  156. package/dist/diagrams/sociogram/index.d.ts +76 -0
  157. package/dist/diagrams/sociogram/index.js +5 -0
  158. package/dist/diagrams/sociogram/index.js.map +1 -0
  159. package/dist/diagrams/timing/index.cjs +21 -0
  160. package/dist/diagrams/timing/index.cjs.map +1 -0
  161. package/dist/diagrams/timing/index.d.cts +9 -0
  162. package/dist/diagrams/timing/index.d.ts +9 -0
  163. package/dist/diagrams/timing/index.js +4 -0
  164. package/dist/diagrams/timing/index.js.map +1 -0
  165. package/dist/diagrams/venn/index.cjs +38 -0
  166. package/dist/diagrams/venn/index.cjs.map +1 -0
  167. package/dist/diagrams/venn/index.d.cts +69 -0
  168. package/dist/diagrams/venn/index.d.ts +69 -0
  169. package/dist/diagrams/venn/index.js +5 -0
  170. package/dist/diagrams/venn/index.js.map +1 -0
  171. package/dist/index-BSlza1YY.d.ts +150 -0
  172. package/dist/index-BXefHVce.d.cts +150 -0
  173. package/dist/index.cjs +2033 -0
  174. package/dist/index.cjs.map +1 -0
  175. package/dist/index.d.cts +29 -0
  176. package/dist/index.d.ts +29 -0
  177. package/dist/index.js +1944 -0
  178. package/dist/index.js.map +1 -0
  179. package/dist/types-DqfcYkcY.d.cts +741 -0
  180. package/dist/types-DqfcYkcY.d.ts +741 -0
  181. package/package.json +163 -0
@@ -0,0 +1,741 @@
1
+ /**
2
+ * Core type definitions for Schematex.
3
+ *
4
+ * The pipeline is: Text → Parser → AST → Layout → LayoutResult → Renderer → SVG
5
+ *
6
+ * Each diagram type (genogram, ecomap, pedigree) implements its own:
7
+ * - Parser: text → DiagramAST
8
+ * - Layout: DiagramAST → LayoutResult
9
+ * - Renderer: LayoutResult → SVG string
10
+ */
11
+ type DiagramType = "genogram" | "ecomap" | "pedigree" | "phylo" | "sociogram" | "timing" | "logic" | "circuit" | "blockdiagram" | "ladder" | "sld" | "entity" | "fishbone" | "venn" | "flowchart" | "mindmap" | "matrix" | "orgchart";
12
+ type GenogramMode = "medical" | "heritage";
13
+ type LegendPosition = "bottom-right" | "right" | "bottom-center" | "none";
14
+ interface DiagramAST {
15
+ type: DiagramType;
16
+ individuals: Individual[];
17
+ relationships: Relationship[];
18
+ metadata?: Record<string, string>;
19
+ /** Legend definitions (pedigree traits, heritage colors, etc.) */
20
+ legend?: LegendEntry[];
21
+ /** Genogram display mode: medical conditions or cultural heritage */
22
+ mode?: GenogramMode;
23
+ /** Legend box position */
24
+ legendPosition?: LegendPosition;
25
+ }
26
+ interface LegendEntry {
27
+ id: string;
28
+ label: string;
29
+ /** Fill position (for pedigree trait legend) */
30
+ fill?: ConditionFill;
31
+ /** Color (for heritage legend or pedigree trait legend) */
32
+ color?: string;
33
+ }
34
+ interface Individual {
35
+ id: string;
36
+ label: string;
37
+ sex: Sex;
38
+ status: IndividualStatus;
39
+ birthYear?: number;
40
+ deathYear?: number;
41
+ /** Medical/psychological conditions (genogram) or affected traits (pedigree) */
42
+ conditions?: Condition[];
43
+ /** Genetic status for pedigree charts */
44
+ geneticStatus?: GeneticStatus;
45
+ /** Child relationship modifier */
46
+ childType?: ChildType;
47
+ /** Special markers */
48
+ markers?: IndividualMarker[];
49
+ /** Gender identity annotation (Bennett 2022: when gender ≠ assigned sex) */
50
+ genderIdentity?: string;
51
+ /** Cultural/ethnic heritage identifiers (heritage genogram mode) */
52
+ heritage?: string[];
53
+ /** Age to display inside shape (auto-calculated from birthYear if omitted) */
54
+ age?: number;
55
+ /** Rich annotations: occupation, traits, notes, etc. */
56
+ annotations?: Record<string, string>;
57
+ /** Whether this individual is external/non-family (dashed border) */
58
+ external?: boolean;
59
+ /** Custom properties for extensibility */
60
+ properties?: Record<string, string>;
61
+ }
62
+ type Sex = "male" | "female" | "unknown" | "other" | "nonbinary" | "intersex";
63
+ type IndividualStatus = "alive" | "deceased" | "stillborn" | "miscarriage" | "abortion" | "pregnancy" | "sab" | "tab" | "ectopic";
64
+ type GeneticStatus = "unaffected" | "affected" | "carrier" | "carrier-x" | "obligate-carrier" | "presymptomatic";
65
+ type ChildType = "biological" | "adopted" | "adopted-in" | "adopted-out" | "foster" | "step" | "surrogate" | "donor" | "donor-egg" | "donor-sperm" | "donor-embryo";
66
+ type IndividualMarker = "proband" | "consultand" | "evaluated" | "index-person" | "transgender" | "no-children" | "infertile";
67
+ interface Condition {
68
+ label: string;
69
+ /** Fill pattern for condition display */
70
+ fill: ConditionFill;
71
+ /** Color for the fill (hex or named). Falls back to category default. */
72
+ color?: string;
73
+ /** Medical category for automatic color assignment */
74
+ category?: MedicalCategory;
75
+ }
76
+ type ConditionFill = "full" | "half-left" | "half-right" | "half-top" | "half-bottom" | "quad-tl" | "quad-tr" | "quad-bl" | "quad-br" | "striped" | "dotted" | "carrier";
77
+ /** Standard 22-category medical condition system (genogram) */
78
+ type MedicalCategory = "cardiovascular" | "cancer" | "diabetes" | "mental-health" | "depression" | "anxiety" | "bipolar" | "ptsd" | "substance-alcohol" | "substance-drugs" | "substance-tobacco" | "neurological" | "respiratory" | "autoimmune" | "genetic" | "reproductive" | "eating-disorder" | "learning-developmental" | "kidney" | "liver-gi" | "obesity" | "other";
79
+ type FishboneOrientation = "ltr" | "rtl";
80
+ /** Which halves of the spine host ribs. */
81
+ type FishboneSides = "both" | "top" | "bottom";
82
+ /** Density preset — controls spine length, slot spacing, header size. */
83
+ type FishboneDensity = "compact" | "normal" | "spacious";
84
+ /** Where cause branches stick out of a rib. */
85
+ type FishboneCauseSide = "head" | "tail" | "both";
86
+ interface FishboneNode {
87
+ /** Display text on the bone. */
88
+ label: string;
89
+ /** Optional explicit hex color (conventionally set only on majors). */
90
+ color?: string;
91
+ /** Nested sub-causes (unbounded depth, recommended ≤ 3). */
92
+ children: FishboneNode[];
93
+ /** Per-rib placement override (only honored on majors). */
94
+ side?: "top" | "bottom";
95
+ /** Per-rib explicit ordering within its half (lower = closer to tail). */
96
+ order?: number;
97
+ }
98
+ interface FishboneLegendEntry {
99
+ label: string;
100
+ color: string;
101
+ }
102
+ interface FishboneAST {
103
+ type: "fishbone";
104
+ title?: string;
105
+ /** Problem / outcome displayed in the head box. */
106
+ effect: string;
107
+ /** Top-level cause categories (major bones). */
108
+ majors: FishboneNode[];
109
+ /** Effect position: `ltr` → head on right, `rtl` → head on left. */
110
+ orientation: FishboneOrientation;
111
+ /** Optional explicit canvas dimensions (otherwise auto-computed). */
112
+ width?: number;
113
+ height?: number;
114
+ /** Optional legend entries rendered in a corner box. */
115
+ legend?: FishboneLegendEntry[];
116
+ metadata?: Record<string, string>;
117
+ /** Which sides of the spine host ribs. Default: "both". */
118
+ sides?: FishboneSides;
119
+ /** Rib slope dx/dy. Default: 0.6. Accepts number or preset name. */
120
+ ribSlope?: number;
121
+ /** Density preset. Default: "normal". */
122
+ density?: FishboneDensity;
123
+ /** Which side of the rib cause branches stick out on. Default: "head". */
124
+ causeSide?: FishboneCauseSide;
125
+ }
126
+ /** Layout algorithm for phylogenetic tree */
127
+ type PhyloLayout = "rectangular" | "slanted" | "circular" | "unrooted";
128
+ /** Tree representation mode — determines how branch lengths are interpreted */
129
+ type PhyloMode = "phylogram" | "cladogram" | "chronogram";
130
+ /** Clade highlight display mode */
131
+ type CladeHighlightMode = "branch" | "background" | "both";
132
+ /** A phylogenetic tree node (distinct from family-tree Individual) */
133
+ interface PhyloNode {
134
+ /** Unique id (auto-generated for unnamed internal nodes) */
135
+ id: string;
136
+ /** Display label (species name, gene id, etc.) */
137
+ label?: string;
138
+ /** Branch length to parent (substitutions/site or time units) */
139
+ branchLength?: number;
140
+ /** Bootstrap support or Bayesian posterior probability (0-100 or 0-1) */
141
+ support?: number;
142
+ /** Children nodes (empty = leaf/tip) */
143
+ children: PhyloNode[];
144
+ /** Is this a leaf/tip node? */
145
+ isLeaf: boolean;
146
+ /** NHX metadata key-value pairs */
147
+ nhx?: Record<string, string>;
148
+ }
149
+ /** Clade definition for visual highlighting */
150
+ interface CladeDef {
151
+ id: string;
152
+ /** Label to display next to clade bracket/background */
153
+ label?: string;
154
+ /** Leaf ids that define this clade (MRCA computed automatically) */
155
+ members: string[];
156
+ /** Branch/background color */
157
+ color?: string;
158
+ /** Highlight mode */
159
+ highlight?: CladeHighlightMode;
160
+ }
161
+ /** Phylogenetic tree AST — separate from DiagramAST because structure is fundamentally different */
162
+ interface PhyloTreeAST {
163
+ type: "phylo";
164
+ /** Tree title */
165
+ title?: string;
166
+ /** Root node of the tree */
167
+ root: PhyloNode;
168
+ /** Is this explicitly unrooted? */
169
+ unrooted: boolean;
170
+ /** Layout algorithm */
171
+ layout: PhyloLayout;
172
+ /** Branch length interpretation */
173
+ mode: PhyloMode;
174
+ /** Clade definitions for visual highlighting */
175
+ clades: CladeDef[];
176
+ /** Scale bar label (e.g. "substitutions/site", "Million years ago") */
177
+ scaleLabel?: string;
178
+ /** Most recent sampling date (for chronogram mode) */
179
+ mrsd?: string;
180
+ /** Outgroup taxon id (for rooting) */
181
+ outgroup?: string;
182
+ /** Custom metadata */
183
+ metadata?: Record<string, string>;
184
+ }
185
+ /** Layout result for phylogenetic tree */
186
+ interface PhyloLayoutNode {
187
+ node: PhyloNode;
188
+ x: number;
189
+ y: number;
190
+ /** Angle in radians (for circular/unrooted layouts) */
191
+ angle?: number;
192
+ /** Radius from center (for circular/unrooted layouts) */
193
+ radius?: number;
194
+ }
195
+ type RelationshipType = "married" | "divorced" | "separated" | "engaged" | "cohabiting" | "domestic-partnership" | "consanguineous" | "parent-child" | "adopted" | "foster" | "twin-identical" | "twin-fraternal" | "harmony" | "close" | "bestfriends" | "love" | "inlove" | "friendship" | "hostile" | "conflict" | "enmity" | "distant-hostile" | "cutoff" | "close-hostile" | "fused" | "fused-hostile" | "distant" | "normal" | "nevermet" | "abuse" | "physical-abuse" | "emotional-abuse" | "sexual-abuse" | "neglect" | "manipulative" | "controlling" | "jealous" | "focused" | "focused-neg" | "distrust" | "admirer" | "limerence" | "strong" | "moderate" | "weak" | "stressful" | "stressful-strong" | "conflictual" | "broken" | "reciprocal";
196
+ interface Relationship {
197
+ type: RelationshipType;
198
+ from: string;
199
+ to: string;
200
+ label?: string;
201
+ /** Is this relationship directional? (abuse, control, focused, ecomap energy flow) */
202
+ directional?: boolean;
203
+ /** For ecomap: line weight 1-5 */
204
+ weight?: number;
205
+ /** For ecomap: energy flow direction */
206
+ energyFlow?: "from" | "to" | "mutual" | "none";
207
+ }
208
+ interface LayoutResult {
209
+ width: number;
210
+ height: number;
211
+ nodes: LayoutNode[];
212
+ edges: LayoutEdge[];
213
+ }
214
+ interface LayoutNode {
215
+ id: string;
216
+ x: number;
217
+ y: number;
218
+ width: number;
219
+ height: number;
220
+ /** Generation/layer index (0 = oldest generation) */
221
+ generation: number;
222
+ individual: Individual;
223
+ }
224
+ interface LayoutEdge {
225
+ from: string;
226
+ to: string;
227
+ relationship: Relationship;
228
+ /** SVG path data (d attribute) */
229
+ path: string;
230
+ }
231
+ interface DiagramPlugin {
232
+ type: DiagramType;
233
+ detect: (text: string) => boolean;
234
+ render: (text: string, config?: RenderConfig) => string;
235
+ }
236
+ interface LayoutConfig {
237
+ /** Horizontal spacing between nodes */
238
+ nodeSpacingX: number;
239
+ /** Vertical spacing between generations */
240
+ nodeSpacingY: number;
241
+ /** Node dimensions */
242
+ nodeWidth: number;
243
+ nodeHeight: number;
244
+ }
245
+ interface RenderConfig {
246
+ fontFamily: string;
247
+ fontSize: number;
248
+ theme: string;
249
+ padding: number;
250
+ /** Show age number inside shapes */
251
+ showAge?: boolean;
252
+ /** Show rich annotations below names */
253
+ showAnnotations?: boolean;
254
+ /** Show relationship labels on lines */
255
+ showEdgeLabels?: boolean;
256
+ /** Show in-law relationship labels */
257
+ showInLawLabels?: boolean;
258
+ /** Legend position override */
259
+ legendPosition?: LegendPosition;
260
+ }
261
+ interface TimingSignal {
262
+ /** Signal name (display label) */
263
+ name: string;
264
+ /** WaveDrom wave string: sequence of state chars */
265
+ wave: string;
266
+ /** Data labels for bus states (= or 2-9) */
267
+ data?: string[];
268
+ /** Phase offset in half-periods */
269
+ phase?: number;
270
+ /** Period multiplier */
271
+ period?: number;
272
+ /** Node markers for annotation arrows */
273
+ node?: string;
274
+ }
275
+ interface TimingGroup {
276
+ label: string;
277
+ signals: Array<TimingSignal | TimingGroup>;
278
+ }
279
+ interface TimingAnnotation {
280
+ /** Source node marker id */
281
+ from: string;
282
+ /** Target node marker id */
283
+ to: string;
284
+ label?: string;
285
+ }
286
+ interface TimingAST {
287
+ type: "timing";
288
+ title?: string;
289
+ /** Time scale multiplier (1–4) */
290
+ hscale?: number;
291
+ signals: Array<TimingSignal | TimingGroup>;
292
+ annotations?: TimingAnnotation[];
293
+ metadata?: Record<string, string>;
294
+ }
295
+ type LogicGateType = "AND" | "OR" | "NOT" | "NAND" | "NOR" | "XOR" | "XNOR" | "BUF" | "TRISTATE_BUF" | "TRISTATE_INV" | "OPEN_DRAIN" | "SCHMITT" | "DFF" | "JKFF" | "SRFF" | "TFF" | "LATCH_SR" | "LATCH_D" | "MUX" | "DEMUX" | "DECODER" | "ENCODER" | "COUNTER" | "SHIFT_REG";
296
+ type LogicGateStyle = "ansi" | "iec";
297
+ interface LogicGateNode {
298
+ id: string;
299
+ gateType: LogicGateType;
300
+ inputs: string[];
301
+ label?: string;
302
+ style?: LogicGateStyle;
303
+ /** Optional module/sub-circuit this gate belongs to */
304
+ moduleId?: string;
305
+ }
306
+ interface LogicGateModule {
307
+ id: string;
308
+ label: string;
309
+ }
310
+ interface LogicGateInput {
311
+ id: string;
312
+ label: string;
313
+ isActiveLow?: boolean;
314
+ }
315
+ interface LogicGateOutput {
316
+ id: string;
317
+ /** Signal source id (gate output or input port) */
318
+ from: string;
319
+ label: string;
320
+ isActiveLow?: boolean;
321
+ }
322
+ interface LogicGateAST {
323
+ type: "logic";
324
+ title?: string;
325
+ style?: LogicGateStyle;
326
+ inputs: LogicGateInput[];
327
+ outputs: LogicGateOutput[];
328
+ gates: LogicGateNode[];
329
+ modules?: LogicGateModule[];
330
+ metadata?: Record<string, string>;
331
+ }
332
+ type CircuitComponentType = "resistor" | "potentiometer" | "rheostat" | "thermistor_ntc" | "thermistor_ptc" | "ldr" | "varistor" | "fuse" | "fuse_slow" | "capacitor" | "electrolytic_cap" | "variable_cap" | "inductor" | "inductor_iron" | "inductor_ferrite" | "variable_inductor" | "ferrite_bead" | "crystal" | "transformer" | "diode" | "zener" | "schottky" | "led" | "photodiode" | "varactor" | "tvs_diode" | "bridge_rectifier" | "npn" | "pnp" | "darlington_npn" | "darlington_pnp" | "nmos" | "pmos" | "nmos_depletion" | "jfet_n" | "jfet_p" | "igbt" | "scr" | "triac" | "diac" | "phototransistor" | "optocoupler" | "opamp" | "comparator" | "schmitt_buffer" | "tri_state_buffer" | "instrumentation_amp" | "generic_ic" | "voltage_regulator" | "dc_dc_converter" | "555_timer" | "voltage_source" | "current_source" | "ac_source" | "battery" | "vcc" | "ground" | "gnd_signal" | "gnd_chassis" | "gnd_digital" | "switch_spst" | "switch_spdt" | "switch_dpdt" | "push_no" | "push_nc" | "relay_coil" | "relay_no" | "relay_nc" | "motor" | "speaker" | "microphone" | "buzzer" | "ammeter" | "voltmeter" | "wattmeter" | "oscilloscope" | "wire" | "dot" | "label" | "port" | "test_point" | "no_connect" | "antenna";
333
+ type CircuitDirection = "right" | "left" | "up" | "down";
334
+ interface CircuitComponent {
335
+ id: string;
336
+ componentType: CircuitComponentType;
337
+ direction: CircuitDirection;
338
+ /** Reference to anchor point of previous/named element: e.g. "R1.end", "origin" */
339
+ at?: string;
340
+ /** Display label (R1, C2, etc.) */
341
+ label?: string;
342
+ /** Value annotation (1kΩ, 100nF, etc.) */
343
+ value?: string;
344
+ /** Extra attributes (length for wires, gain for opamp, etc.) */
345
+ attrs?: Record<string, string>;
346
+ }
347
+ /** Multi-terminal electrical node — connects multiple anchor refs to the same node */
348
+ interface CircuitNet {
349
+ /** Net name (e.g. "VOUT") */
350
+ id: string;
351
+ /** Anchor refs sharing the same node (e.g. ["R2.end", "U1.out", "OUT.start"]) */
352
+ anchors: string[];
353
+ }
354
+ interface CircuitAST {
355
+ type: "circuit";
356
+ title?: string;
357
+ components: CircuitComponent[];
358
+ /** Explicit net declarations for multi-terminal connections */
359
+ nets: CircuitNet[];
360
+ metadata?: Record<string, string>;
361
+ /** Layout mode: "positional" (Schemdraw-style direction chain) or "netlist" (SPICE-style, auto-layout). */
362
+ mode?: "positional" | "netlist";
363
+ /**
364
+ * Netlist-only. Maps componentId → { pinName → netId }.
365
+ * Populated by the netlist parser; consumed by the auto-layout engine.
366
+ */
367
+ pinMap?: Record<string, Record<string, string>>;
368
+ }
369
+ type BlockRole = "plant" | "controller" | "sensor" | "actuator" | "reference" | "disturbance" | "generic";
370
+ interface BlockNode {
371
+ id: string;
372
+ /** Display label / transfer function e.g. "G(s)" */
373
+ label: string;
374
+ role?: BlockRole;
375
+ /** Routing hint for feedback/feedforward blocks: "above" = route over forward path */
376
+ route?: "above" | "below";
377
+ }
378
+ interface SummingJunction {
379
+ id: string;
380
+ /** Signed inputs: "+r" means add signal r, "-ym" means subtract signal ym */
381
+ inputs: string[];
382
+ /** Output signal id */
383
+ output?: string;
384
+ }
385
+ interface BlockEdge {
386
+ from: string;
387
+ to: string;
388
+ /** Signal label e.g. "E(s)", "U(s)" */
389
+ label?: string;
390
+ /** Dashed line for discrete-time signals */
391
+ discrete?: boolean;
392
+ }
393
+ interface BlockAST {
394
+ type: "blockdiagram";
395
+ title?: string;
396
+ blocks: BlockNode[];
397
+ sums: SummingJunction[];
398
+ connections: BlockEdge[];
399
+ metadata?: Record<string, string>;
400
+ }
401
+ type LadderContactType = "XIC" | "XIO" | "ONS" | "OSF";
402
+ type LadderCoilType = "OTE" | "OTL" | "OTU" | "OTN";
403
+ type LadderFBType = "TON" | "TOFF" | "TP" | "CTU" | "CTD" | "CTUD" | "ADD" | "SUB" | "MUL" | "DIV" | "MOV" | "EQU" | "NEQ" | "GRT" | "LES" | "GEQ" | "LEQ";
404
+ interface LadderContact {
405
+ elementType: "contact";
406
+ contactType: LadderContactType;
407
+ tag: string;
408
+ address?: string;
409
+ /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */
410
+ name?: string;
411
+ }
412
+ interface LadderCoil {
413
+ elementType: "coil";
414
+ coilType: LadderCoilType;
415
+ tag: string;
416
+ address?: string;
417
+ /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */
418
+ name?: string;
419
+ }
420
+ interface LadderFunctionBlock {
421
+ elementType: "function_block";
422
+ fbType: LadderFBType;
423
+ tag: string;
424
+ params: Record<string, string | number>;
425
+ }
426
+ type LadderElement = LadderContact | LadderCoil | LadderFunctionBlock;
427
+ interface LadderBranch {
428
+ elements: LadderElement[];
429
+ }
430
+ interface LadderRung {
431
+ number: number;
432
+ comment?: string;
433
+ /** Sequential elements and parallel groups */
434
+ elements: Array<LadderElement | {
435
+ parallel: LadderBranch[];
436
+ }>;
437
+ }
438
+ interface LadderAST {
439
+ type: "ladder";
440
+ title?: string;
441
+ rungs: LadderRung[];
442
+ metadata?: Record<string, string>;
443
+ }
444
+ type SLDNodeType = "utility" | "generator" | "solar" | "wind" | "ups" | "transformer" | "transformer_dy" | "transformer_yd" | "transformer_yy" | "transformer_dd" | "autotransformer" | "transformer_3winding" | "bus" | "bus_tie" | "hub" | "breaker" | "breaker_vacuum" | "switch" | "switch_load" | "ground_switch" | "ats" | "recloser" | "sectionalizer" | "fuse" | "fuse_cl" | "ct" | "pt" | "relay" | "surge_arrester" | "ground_fault" | "motor" | "load" | "capacitor_bank" | "harmonic_filter" | "vfd" | "watthour_meter" | "demand_meter";
445
+ interface SLDNode {
446
+ id: string;
447
+ nodeType: SLDNodeType;
448
+ label?: string;
449
+ /** Voltage level e.g. "13.8kV", "480V" */
450
+ voltage?: string;
451
+ /** Equipment rating e.g. "1000A", "500kVA" */
452
+ rating?: string;
453
+ /** ANSI device number (relays: 51, 87, 27, etc.) */
454
+ deviceNumber?: string;
455
+ /** Additional nameplate data (transformer: kVA, ratio, %Z) */
456
+ nameplate?: Record<string, string>;
457
+ }
458
+ interface SLDConnection {
459
+ from: string;
460
+ to: string;
461
+ /** Cable specification e.g. "3#2/0 AWG" */
462
+ cable?: string;
463
+ label?: string;
464
+ }
465
+ interface SLDAST {
466
+ type: "sld";
467
+ title?: string;
468
+ nodes: SLDNode[];
469
+ connections: SLDConnection[];
470
+ metadata?: Record<string, string>;
471
+ }
472
+ type EntityType = "corp" | "llc" | "lp" | "trust" | "individual" | "foundation" | "disregarded" | "pool" | "placeholder";
473
+ type EntityStatus = "normal" | "new" | "eliminated" | "modified";
474
+ interface EntityNode {
475
+ id: string;
476
+ name: string;
477
+ entityType: EntityType;
478
+ /** ISO 3166-1 alpha-2 or 2-3 letter state code (DE, IE, KY, BVI, ...) */
479
+ jurisdiction?: string;
480
+ status?: EntityStatus;
481
+ taxClass?: string;
482
+ role?: string;
483
+ note?: string;
484
+ formationDate?: string;
485
+ properties?: Record<string, string>;
486
+ }
487
+ type EntityEdgeOp = "ownership" | "voting" | "pool" | "license" | "distribution";
488
+ interface EntityEdge {
489
+ from: string;
490
+ to: string;
491
+ op: EntityEdgeOp;
492
+ /** Raw percentage text, e.g. "100%" or "V 75% / E 50%" or "was 40% → 100%" */
493
+ percentage?: string;
494
+ /** Share class label (Series A Pref, Common, Option Pool) */
495
+ shareClass?: string;
496
+ label?: string;
497
+ }
498
+ interface JurisdictionDef {
499
+ code: string;
500
+ name: string;
501
+ color?: string;
502
+ }
503
+ interface ClusterDef {
504
+ id: string;
505
+ label: string;
506
+ /** Entity ids (explicit members) */
507
+ members: string[];
508
+ color?: string;
509
+ }
510
+ interface EntityAST {
511
+ type: "entity";
512
+ title?: string;
513
+ entities: EntityNode[];
514
+ edges: EntityEdge[];
515
+ jurisdictions: JurisdictionDef[];
516
+ clusters: ClusterDef[];
517
+ metadata?: Record<string, string>;
518
+ }
519
+ type VennDiagramMode = "auto" | "venn" | "euler";
520
+ type VennPalette = "default" | "brand" | "monochrome";
521
+ type VennBlendMode = "multiply" | "screen" | "none";
522
+ type VennEulerRelationType = "subset" | "disjoint" | "overlap";
523
+ /** Raw value attached to a region. */
524
+ type VennRegionValue = {
525
+ kind: "integer";
526
+ value: number;
527
+ } | {
528
+ kind: "percent";
529
+ value: number;
530
+ } | {
531
+ kind: "text";
532
+ value: string;
533
+ } | {
534
+ kind: "list";
535
+ value: string[];
536
+ } | {
537
+ kind: "none";
538
+ };
539
+ /** One set (a circle or ellipse in the diagram). */
540
+ interface VennSet {
541
+ id: string;
542
+ label: string;
543
+ /** Optional explicit elements (enumeration DSL). */
544
+ elements?: string[];
545
+ /** Override color (hex). */
546
+ color?: string;
547
+ }
548
+ /** A named region. `sets` is the subset of set ids that define it (at least one). */
549
+ interface VennRegion {
550
+ /** Sorted list of set ids that belong to the intersection (e.g. ["A","B"]). */
551
+ sets: string[];
552
+ /** Does this region mean "only" these sets (exclude any other set)? */
553
+ only: boolean;
554
+ /** Value payload attached to the region. */
555
+ value: VennRegionValue;
556
+ }
557
+ interface VennEulerRelation {
558
+ from: string;
559
+ to: string;
560
+ type: VennEulerRelationType;
561
+ }
562
+ interface VennConfig {
563
+ mode: VennDiagramMode;
564
+ proportional: boolean;
565
+ palette: VennPalette;
566
+ blendMode: VennBlendMode;
567
+ showCounts: boolean | "auto";
568
+ showPercent: boolean;
569
+ }
570
+ interface VennAST {
571
+ type: "venn";
572
+ title?: string;
573
+ sets: VennSet[];
574
+ regions: VennRegion[];
575
+ relations: VennEulerRelation[];
576
+ config: VennConfig;
577
+ metadata?: Record<string, string>;
578
+ }
579
+ /** Circle geometry (n=2, n=3 and Euler). */
580
+ interface VennCircle {
581
+ id: string;
582
+ cx: number;
583
+ cy: number;
584
+ r: number;
585
+ }
586
+ /** Ellipse geometry (n=4). */
587
+ interface VennEllipse {
588
+ id: string;
589
+ cx: number;
590
+ cy: number;
591
+ rx: number;
592
+ ry: number;
593
+ /** Rotation in degrees around (cx,cy). */
594
+ rotation: number;
595
+ }
596
+ type VennShape = ({
597
+ kind: "circle";
598
+ } & VennCircle) | ({
599
+ kind: "ellipse";
600
+ } & VennEllipse);
601
+ interface VennLabelPosition {
602
+ /** Region this label describes (sorted set ids). */
603
+ sets: string[];
604
+ /** Canonical label text (e.g. "A ∩ B", "42", "[a,b,c]"). */
605
+ label: string;
606
+ /** Centroid x / y (inside or external). */
607
+ x: number;
608
+ y: number;
609
+ /** If true, label is placed outside the region and `leader` is populated. */
610
+ external: boolean;
611
+ /** Optional leader line endpoints (from region-interior → label). */
612
+ leader?: {
613
+ x1: number;
614
+ y1: number;
615
+ x2: number;
616
+ y2: number;
617
+ };
618
+ /** Text anchor for external labels. */
619
+ anchor?: "start" | "middle" | "end";
620
+ }
621
+ interface VennLayoutResult {
622
+ width: number;
623
+ height: number;
624
+ /** Rendering mode chosen (venn or euler; upset deferred). */
625
+ mode: "venn" | "euler";
626
+ /** Shape per set id (circles for n=2/3/euler, ellipses for n=4). */
627
+ shapes: VennShape[];
628
+ /** Region labels + placements. */
629
+ labels: VennLabelPosition[];
630
+ /** Set-title positions (one per set). */
631
+ setLabels: Array<{
632
+ id: string;
633
+ label: string;
634
+ x: number;
635
+ y: number;
636
+ anchor: "start" | "middle" | "end";
637
+ }>;
638
+ /** Title placement (optional). */
639
+ title?: {
640
+ text: string;
641
+ x: number;
642
+ y: number;
643
+ };
644
+ /** Proportional-solve residual (0 if not proportional). */
645
+ proportionalResidual?: number;
646
+ }
647
+ type FlowchartDirection = "TB" | "BT" | "LR" | "RL";
648
+ /**
649
+ * Shape keyword catalog. M1 implements only the first 5; the rest are reserved
650
+ * for M2 so AST/types don't have to be rewritten later.
651
+ */
652
+ type FlowchartShape = "rect" | "round" | "stadium" | "diamond" | "parallelogram" | "parallelogram-alt" | "trapezoid" | "trapezoid-alt" | "subroutine" | "cylinder" | "circle" | "double-circle" | "hexagon" | "asymmetric";
653
+ type FlowchartEdgeKind = "solid" | "none" | "dotted" | "thick" | "bidirectional" | "crossed" | "round-end";
654
+ type FlowchartArrowEnd = "none" | "arrow" | "circle" | "cross";
655
+ interface FlowchartNode {
656
+ id: string;
657
+ label: string;
658
+ shape: FlowchartShape;
659
+ icon?: string;
660
+ classes?: string[];
661
+ /** Containing subgraph id (undefined = root) */
662
+ parent?: string;
663
+ }
664
+ interface FlowchartEdge {
665
+ id?: string;
666
+ from: string;
667
+ to: string;
668
+ kind: FlowchartEdgeKind;
669
+ label?: string;
670
+ arrowStart?: FlowchartArrowEnd;
671
+ arrowEnd?: FlowchartArrowEnd;
672
+ classes?: string[];
673
+ /** Reversed during cycle-removal (renderer must flip visual arrow) */
674
+ isReversed?: boolean;
675
+ }
676
+ interface FlowchartSubgraph {
677
+ id: string;
678
+ label: string;
679
+ direction?: FlowchartDirection;
680
+ children: string[];
681
+ subgraphs: string[];
682
+ classes?: string[];
683
+ }
684
+ interface FlowchartClassDef {
685
+ id: string;
686
+ props: Record<string, string>;
687
+ }
688
+ interface FlowchartAST {
689
+ type: "flowchart";
690
+ title?: string;
691
+ direction: FlowchartDirection;
692
+ nodes: FlowchartNode[];
693
+ edges: FlowchartEdge[];
694
+ subgraphs: FlowchartSubgraph[];
695
+ classDefs: FlowchartClassDef[];
696
+ /** linkStyle index → css-ish props. Parsed in M1, applied in M2. */
697
+ linkStyles: Map<number, Record<string, string>>;
698
+ metadata?: Record<string, string>;
699
+ }
700
+ interface FlowchartLayoutNode {
701
+ node: FlowchartNode;
702
+ x: number;
703
+ y: number;
704
+ width: number;
705
+ height: number;
706
+ /** 0-based layer index (top for TB, left for LR) */
707
+ layer: number;
708
+ /** Position within the layer (0-based) */
709
+ order: number;
710
+ /** Dummy routing node inserted for long edges */
711
+ isDummy?: boolean;
712
+ }
713
+ interface FlowchartLayoutEdge {
714
+ edge: FlowchartEdge;
715
+ /** SVG path d attribute */
716
+ path: string;
717
+ /** Label anchor with optional text-anchor hint for proper line clearance */
718
+ labelAnchor?: {
719
+ x: number;
720
+ y: number;
721
+ textAnchor?: "start" | "middle" | "end";
722
+ };
723
+ }
724
+ interface FlowchartLayoutCluster {
725
+ subgraph: FlowchartSubgraph;
726
+ x: number;
727
+ y: number;
728
+ width: number;
729
+ height: number;
730
+ depth: number;
731
+ }
732
+ interface FlowchartLayoutResult {
733
+ width: number;
734
+ height: number;
735
+ direction: FlowchartDirection;
736
+ nodes: FlowchartLayoutNode[];
737
+ edges: FlowchartLayoutEdge[];
738
+ clusters: FlowchartLayoutCluster[];
739
+ }
740
+
741
+ export type { BlockAST as B, CircuitAST as C, DiagramAST as D, EntityAST as E, FishboneAST as F, Individual as I, LayoutConfig as L, PhyloTreeAST as P, RenderConfig as R, SLDAST as S, TimingAST as T, VennAST as V, LayoutResult as a, DiagramPlugin as b, PhyloLayoutNode as c, LogicGateAST as d, CircuitComponent as e, LadderAST as f, LadderRung as g, LadderElement as h, SLDNode as i, SLDNodeType as j, EntityNode as k, EntityEdge as l, VennLayoutResult as m, FlowchartAST as n, FlowchartLayoutResult as o };