@draftably/editor 0.0.0-stage → 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 (185) hide show
  1. package/README.md +26 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
  4. package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
  5. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
  6. package/dist/chunks/arc-rJj0TtXf.js +83 -0
  7. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
  8. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
  9. package/dist/chunks/browser-iNhbPsGc.js +40 -0
  10. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
  11. package/dist/chunks/channel-qMvPU6eH.js +5 -0
  12. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
  13. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
  14. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
  15. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
  16. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
  17. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
  18. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
  19. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
  20. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
  21. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
  22. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
  23. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
  24. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
  25. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
  26. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
  27. package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
  28. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
  29. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
  30. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
  31. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
  32. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
  33. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
  34. package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
  35. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
  36. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
  37. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
  38. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
  39. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
  40. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
  41. package/dist/chunks/graph-CKJmgLki.js +1541 -0
  42. package/dist/chunks/import-core-C-I1wGfw.js +145 -0
  43. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
  44. package/dist/chunks/init-DjUOC4st.js +16 -0
  45. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
  46. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
  47. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
  48. package/dist/chunks/katex-BsrBVQKd.js +11314 -0
  49. package/dist/chunks/linear-4t7D_ros.js +259 -0
  50. package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
  51. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
  52. package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
  53. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
  54. package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
  55. package/dist/chunks/ordinal-DfAQgscy.js +61 -0
  56. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
  57. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
  58. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
  59. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
  60. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
  61. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
  62. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
  63. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
  64. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
  65. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
  66. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
  67. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
  68. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
  69. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
  70. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
  71. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
  72. package/dist/element.js +36 -0
  73. package/dist/index.js +4 -0
  74. package/dist/types/src/cli/links.d.ts +4 -0
  75. package/dist/types/src/cli/pdf.d.ts +29 -0
  76. package/dist/types/src/cli/png.d.ts +23 -0
  77. package/dist/types/src/cli/svg.d.ts +4 -0
  78. package/dist/types/src/components/Icon.d.ts +14 -0
  79. package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
  80. package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
  81. package/dist/types/src/components/canvas/Frame.d.ts +22 -0
  82. package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
  83. package/dist/types/src/components/canvas/Notes.d.ts +5 -0
  84. package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
  85. package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
  86. package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
  87. package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
  88. package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
  89. package/dist/types/src/components/controls.d.ts +88 -0
  90. package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
  91. package/dist/types/src/components/scene/GroupView.d.ts +22 -0
  92. package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
  93. package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
  94. package/dist/types/src/components/scene/NodeView.d.ts +18 -0
  95. package/dist/types/src/components/scene/parts.d.ts +50 -0
  96. package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
  97. package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
  98. package/dist/types/src/components/session-context.d.ts +486 -0
  99. package/dist/types/src/dsl/cells.d.ts +91 -0
  100. package/dist/types/src/dsl/channels.d.ts +53 -0
  101. package/dist/types/src/dsl/compile.d.ts +162 -0
  102. package/dist/types/src/dsl/frame.d.ts +38 -0
  103. package/dist/types/src/dsl/lanes.d.ts +23 -0
  104. package/dist/types/src/dsl/layout-edits.d.ts +58 -0
  105. package/dist/types/src/dsl/legend-notes.d.ts +3 -0
  106. package/dist/types/src/dsl/project.d.ts +39 -0
  107. package/dist/types/src/dsl/source-edits.d.ts +37 -0
  108. package/dist/types/src/dsl/syntax.d.ts +317 -0
  109. package/dist/types/src/dsl/translate.d.ts +69 -0
  110. package/dist/types/src/editor/Editor.d.ts +6 -0
  111. package/dist/types/src/editor/element.d.ts +15 -0
  112. package/dist/types/src/editor/mount.d.ts +23 -0
  113. package/dist/types/src/import/browser.d.ts +3 -0
  114. package/dist/types/src/import/detect.d.ts +31 -0
  115. package/dist/types/src/import/dot-importer.d.ts +3 -0
  116. package/dist/types/src/import/import-core.d.ts +105 -0
  117. package/dist/types/src/import/mermaid-facade.d.ts +120 -0
  118. package/dist/types/src/import/mermaid-importer.d.ts +4 -0
  119. package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
  120. package/dist/types/src/import/scratch.d.ts +3 -0
  121. package/dist/types/src/lib/engine-tasks.d.ts +88 -0
  122. package/dist/types/src/lib/font-data.d.ts +9 -0
  123. package/dist/types/src/lib/saved-diagram.d.ts +4 -0
  124. package/dist/types/src/lib/scene-cache.d.ts +4 -0
  125. package/dist/types/src/lib/source-hash.d.ts +7 -0
  126. package/dist/types/src/lib/svg-export.d.ts +15 -0
  127. package/dist/types/src/model/appearance.d.ts +209 -0
  128. package/dist/types/src/model/bounds.d.ts +19 -0
  129. package/dist/types/src/model/camera.d.ts +21 -0
  130. package/dist/types/src/model/candidates.d.ts +53 -0
  131. package/dist/types/src/model/colors.d.ts +22 -0
  132. package/dist/types/src/model/document.d.ts +24 -0
  133. package/dist/types/src/model/edits.d.ts +133 -0
  134. package/dist/types/src/model/embed.d.ts +17 -0
  135. package/dist/types/src/model/examples.d.ts +15 -0
  136. package/dist/types/src/model/font-faces.d.ts +24 -0
  137. package/dist/types/src/model/fonts.d.ts +47 -0
  138. package/dist/types/src/model/footnote.d.ts +34 -0
  139. package/dist/types/src/model/frame.d.ts +71 -0
  140. package/dist/types/src/model/geometry.d.ts +29 -0
  141. package/dist/types/src/model/graph.d.ts +53 -0
  142. package/dist/types/src/model/heading.d.ts +38 -0
  143. package/dist/types/src/model/icons.d.ts +2 -0
  144. package/dist/types/src/model/label-hits.d.ts +27 -0
  145. package/dist/types/src/model/labels.d.ts +88 -0
  146. package/dist/types/src/model/legend.d.ts +25 -0
  147. package/dist/types/src/model/link.d.ts +63 -0
  148. package/dist/types/src/model/markers.d.ts +47 -0
  149. package/dist/types/src/model/note.d.ts +75 -0
  150. package/dist/types/src/model/panels.d.ts +11 -0
  151. package/dist/types/src/model/rich-text.d.ts +24 -0
  152. package/dist/types/src/model/routes.d.ts +170 -0
  153. package/dist/types/src/model/samples.d.ts +11 -0
  154. package/dist/types/src/model/stack.d.ts +8 -0
  155. package/dist/types/src/model/static-scene.d.ts +15 -0
  156. package/dist/types/src/model/status.d.ts +84 -0
  157. package/dist/types/src/model/styles.d.ts +13 -0
  158. package/dist/types/src/model/surface.d.ts +31 -0
  159. package/dist/types/src/model/types.d.ts +277 -0
  160. package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
  161. package/dist/types/src/server/file-session.d.ts +19 -0
  162. package/dist/types/src/server/workspace.d.ts +21 -0
  163. package/dist/types/src/state/active-session.d.ts +479 -0
  164. package/dist/types/src/state/commands.d.ts +529 -0
  165. package/dist/types/src/state/comparison.d.ts +151 -0
  166. package/dist/types/src/state/files.d.ts +61 -0
  167. package/dist/types/src/state/keyboard.d.ts +6 -0
  168. package/dist/types/src/state/keys.d.ts +5 -0
  169. package/dist/types/src/state/launch.d.ts +61 -0
  170. package/dist/types/src/state/links.d.ts +11 -0
  171. package/dist/types/src/state/session/actions.d.ts +77 -0
  172. package/dist/types/src/state/session/canvas-text.d.ts +24 -0
  173. package/dist/types/src/state/session/document.d.ts +84 -0
  174. package/dist/types/src/state/session/editor.d.ts +81 -0
  175. package/dist/types/src/state/session/emphasis.d.ts +11 -0
  176. package/dist/types/src/state/session/file-session.d.ts +98 -0
  177. package/dist/types/src/state/session/index.d.ts +496 -0
  178. package/dist/types/src/state/session/layout.d.ts +79 -0
  179. package/dist/types/src/state/session/pointer.d.ts +19 -0
  180. package/dist/types/src/state/session/routing.d.ts +20 -0
  181. package/dist/types/src/state/session/scene.d.ts +144 -0
  182. package/dist/types/src/state/session/sculpt.d.ts +70 -0
  183. package/dist/types/src/state/toast.d.ts +14 -0
  184. package/dist/types/src/state/ui.d.ts +39 -0
  185. package/package.json +41 -3
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Tested against mermaid 12.2.0. Uses its internal DB behind a narrow, checked boundary.
3
+ * This file parses only; it neither renders Mermaid nor attaches interaction callbacks.
4
+ * Call in an isolated Node worker with a DOM, or in a dedicated browser Mermaid instance.
5
+ */
6
+ export declare const MERMAID_VERSION: "12.2.0";
7
+ export type ParserDiagnostic = {
8
+ code: string;
9
+ severity: 'warning' | 'error';
10
+ message: string;
11
+ line?: number;
12
+ column?: number;
13
+ locationKind?: 'source' | 'parser-relative';
14
+ };
15
+ export type FlowVertex = {
16
+ id: string;
17
+ text: string;
18
+ type?: string;
19
+ labelType: string;
20
+ classes: string[];
21
+ styles: string[];
22
+ link?: string;
23
+ icon?: string;
24
+ img?: string;
25
+ props?: Record<string, unknown>;
26
+ };
27
+ export type FlowEdge = {
28
+ start: string;
29
+ end: string;
30
+ text: string;
31
+ type?: string;
32
+ stroke?: string;
33
+ id?: string;
34
+ isUserDefinedId: boolean;
35
+ labelType: string;
36
+ classes: string[];
37
+ style: string[];
38
+ length?: number;
39
+ interpolate?: string;
40
+ animate?: boolean;
41
+ animation?: string;
42
+ };
43
+ export type FlowGroup = {
44
+ id: string;
45
+ title: string;
46
+ nodes: string[];
47
+ dir?: string;
48
+ labelType: string;
49
+ classes: string[];
50
+ metadata?: Record<string, unknown>;
51
+ };
52
+ export type FlowClass = {
53
+ id: string;
54
+ styles: string[];
55
+ textStyles: string[];
56
+ };
57
+ export type FlowSnapshot = {
58
+ format: 'mermaid';
59
+ family: 'flowchart';
60
+ parserVersion: typeof MERMAID_VERSION;
61
+ direction: string;
62
+ vertices: FlowVertex[];
63
+ edges: FlowEdge[];
64
+ groups: FlowGroup[];
65
+ classes: FlowClass[];
66
+ defaultEdgeStyle: string[];
67
+ defaultEdgeInterpolate?: string;
68
+ };
69
+ /** One entry of Mermaid's ordered sequence log; `kind` is its LINETYPE name. */
70
+ export type SequenceEvent = {
71
+ kind: string;
72
+ from?: string;
73
+ to?: string;
74
+ text: string;
75
+ placement?: 'left' | 'right' | 'over';
76
+ central: boolean;
77
+ };
78
+ export type SequenceActor = {
79
+ id: string;
80
+ name: string;
81
+ type: string;
82
+ box?: number;
83
+ links: string[];
84
+ };
85
+ export type SequenceBox = {
86
+ name?: string;
87
+ fill?: string;
88
+ };
89
+ export type SequenceSnapshot = {
90
+ format: 'mermaid';
91
+ family: 'sequence';
92
+ parserVersion: typeof MERMAID_VERSION;
93
+ title?: string;
94
+ actors: SequenceActor[];
95
+ boxes: SequenceBox[];
96
+ events: SequenceEvent[];
97
+ created: string[];
98
+ destroyed: string[];
99
+ };
100
+ export type ParseFlowResult = {
101
+ ok: true;
102
+ snapshot: FlowSnapshot | SequenceSnapshot;
103
+ diagnostics: ParserDiagnostic[];
104
+ } | {
105
+ ok: false;
106
+ diagnostics: ParserDiagnostic[];
107
+ };
108
+ type MermaidApi = Pick<(typeof import('mermaid'))['default'], 'initialize' | 'mermaidAPI'>;
109
+ /** DB strings contain Mermaid entity sentinels; preserve entity spelling for text decoding. */
110
+ export declare function restoreEntitySpelling(value: string): string;
111
+ /**
112
+ * Use an unattached HTML template only. Its content is inert and is never adopted into the page.
113
+ * Caller supplies the browser document or the dedicated worker's JSDOM document.
114
+ * Markdown markers deliberately remain visible; native Markdown rendering is not assumed.
115
+ */
116
+ export declare function makePlainLabel(document: Document): (value: string) => string;
117
+ export declare function preflightMermaidFlow(source: string): ParserDiagnostic[];
118
+ /** Each factory owns a serialized queue because Mermaid maintains parser/configuration state. */
119
+ export declare function createMermaidFlowParser(load: () => Promise<MermaidApi>): (source: string) => Promise<ParseFlowResult>;
120
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ImportResult } from './import-core';
2
+ import { type ParseFlowResult } from './mermaid-facade';
3
+ /** Convert a checked Mermaid snapshot into valid native source. */
4
+ export declare function importMermaidFlow(parsed: ParseFlowResult, plainText: (value: string) => string, title?: string): ImportResult;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Mermaid `sequenceDiagram` -> native source. Participants become nodes and messages become edges
3
+ * in file order. Native sequences have no fragments, so each top-level branch of a block becomes
4
+ * a phase band, and the warning says that the branch logic is gone.
5
+ */
6
+ import { type Diagnostic, type ImportResult } from './import-core';
7
+ import type { SequenceSnapshot } from './mermaid-facade';
8
+ export declare function mapMermaidSequence(snapshot: SequenceSnapshot, plainText: (value: string) => string, title: string, diagnostics: Diagnostic[]): ImportResult;
@@ -0,0 +1,3 @@
1
+ /** Keep the imported native source before navigating away from the current diagram. */
2
+ export declare function keepImportedSource(source: string): string;
3
+ export declare function readImportedSource(id: string): string | null;
@@ -0,0 +1,88 @@
1
+ import { type CandidateResult, type CandidateSpec, type ComparisonConfig } from '../engines/explorer-engine.js';
2
+ import { type LayoutOptions, type LayoutResult } from '../engines/layout-engine.js';
3
+ import { type Timeline } from '../engines/sculpt-engine.js';
4
+ import { type RouteInput, type RoutingOptions, type RoutingResult } from '../engines/routing-engine.js';
5
+ import { type Scene } from '../dsl/compile';
6
+ import { type ViewState } from '../dsl/project';
7
+ import type { Diagram } from '../model/types';
8
+ export type EngineTask = {
9
+ kind: 'layout';
10
+ doc: Diagram;
11
+ options: LayoutOptions;
12
+ } | {
13
+ kind: 'candidate';
14
+ baseline: Diagram;
15
+ spec: CandidateSpec;
16
+ config: ComparisonConfig;
17
+ } | {
18
+ kind: 'timeline';
19
+ doc: Diagram;
20
+ options: LayoutOptions;
21
+ }
22
+ /** A diagram file variant, compiled exactly as the file would be. */
23
+ | {
24
+ kind: 'source';
25
+ source: string;
26
+ spec: CandidateSpec;
27
+ }
28
+ /** Full-quality routes for a drawing shown meanwhile with quick routes. */
29
+ | {
30
+ kind: 'route';
31
+ input: RouteInput;
32
+ options: RoutingOptions;
33
+ }
34
+ /** A diagram file compiled: laid out, not routed. */
35
+ | {
36
+ kind: 'compile';
37
+ source: string;
38
+ }
39
+ /** A diagram file compiled, projected with the editor's view and routed, as the viewer shows it. */
40
+ | {
41
+ kind: 'scene';
42
+ source: string;
43
+ view: ViewState;
44
+ };
45
+ /** A compiled file and its routes, keyed by the projected document they were drawn for. */
46
+ export interface SceneResult {
47
+ scene: Scene;
48
+ fingerprint: string;
49
+ routing: RoutingResult;
50
+ }
51
+ export type EngineResult<T extends EngineTask> = T extends {
52
+ kind: 'layout';
53
+ } ? LayoutResult : T extends {
54
+ kind: 'candidate' | 'source';
55
+ } ? CandidateResult : T extends {
56
+ kind: 'route';
57
+ } ? RoutingResult : T extends {
58
+ kind: 'scene';
59
+ } ? SceneResult : T extends {
60
+ kind: 'compile';
61
+ } ? Scene : Timeline;
62
+ export declare function runEngineTask(task: EngineTask): Promise<LayoutResult | CandidateResult | Timeline | RoutingResult | SceneResult | Scene>;
63
+ /**
64
+ * Run a short task in one worker that stays up, so frequent work such as recompiling a file after
65
+ * each edit pays no start-up cost. Without workers the task runs on the main thread.
66
+ */
67
+ export declare function runShared<T extends EngineTask>(input: T): Promise<EngineResult<T>>;
68
+ export declare class CancelledError extends Error {
69
+ constructor();
70
+ }
71
+ export interface RunningTask<T> {
72
+ promise: Promise<T>;
73
+ /** Stop the computation. The promise rejects with `CancelledError`. */
74
+ cancel(): void;
75
+ /** `worker`, or `main thread` when workers are unavailable. */
76
+ thread: () => string;
77
+ }
78
+ /** Computations to run at once: one core stays with the page. */
79
+ export declare const poolSize: () => number;
80
+ /** Call `work` for each index up to `count`, with at most `poolSize()` calls going at once. */
81
+ export declare function inPool(count: number, work: (index: number) => Promise<void>): Promise<void>;
82
+ /**
83
+ * Run an engine computation in a worker. If the browser blocks workers, the same computation
84
+ * runs on the main thread instead.
85
+ */
86
+ export declare function startEngineTask<T extends EngineTask>(input: T, { timeout }?: {
87
+ timeout?: number;
88
+ }): RunningTask<EngineResult<T>>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The bundled diagram fonts as data URLs, for SVG exports that must render without the app.
3
+ * The browser loads this module only when exporting; the CLI bundles it.
4
+ */
5
+ import type { ResolvedAppearance } from '../model/appearance';
6
+ /** `@font-face` rules for the faces an appearance draws with. */
7
+ export declare function fontFaceCss(look: ResolvedAppearance): string;
8
+ /** Make the bundled faces available to the page, so the canvas draws with measured fonts. */
9
+ export declare function registerFonts(): void;
@@ -0,0 +1,4 @@
1
+ /** Where the editor keeps the browser's diagram. The site reads it too: same origin. */
2
+ export declare const STORAGE_KEY = "diagram-studio-v5";
3
+ /** The title of the diagram kept in this browser, if there is one. */
4
+ export declare function savedTitle(): string;
@@ -0,0 +1,4 @@
1
+ /** The compiled file stored for `source` by this build, if any. */
2
+ export declare function cachedScene<T>(source: string): Promise<T | undefined>;
3
+ /** Store the compiled file for `source`, keeping the most recently stored few. */
4
+ export declare function cacheScene(source: string, value: unknown): Promise<void>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Source in a URL hash, deflated and base64url-encoded: `#s=<data>`. The hash never reaches a
3
+ * server, so a shared link carries the diagram and nothing else.
4
+ */
5
+ export declare function encodeSource(source: string): Promise<string>;
6
+ /** The source in a `#s=` hash, or null when there is none or it does not decode. */
7
+ export declare function decodeSource(hash: string): Promise<string | null>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Deep-copy an SVG subtree with computed styles inlined and editor-only parts removed. An object
3
+ * with a link (`data-href`) is wrapped in `<a>`, its target written by `href`. The source element
4
+ * must be attached to the document.
5
+ */
6
+ export declare function materializeSvg<T extends SVGElement>(original: T, href?: (href: string) => string): T;
7
+ export declare const serializeSvg: (node: Node) => string;
8
+ export declare function createSvgElement<K extends keyof SVGElementTagNameMap>(tag: K, attrs?: Record<string, string | number>): SVGElementTagNameMap[K];
9
+ export declare const escapeXml: (value: unknown) => string;
10
+ export declare function downloadBlob(blob: Blob, name: string): void;
11
+ /** A download name from the diagram's title: `My plan` → `my-plan.svg`. */
12
+ export declare function fileName(title: string, extension: string): string;
13
+ export declare const downloadText: (text: string, name: string, type: string) => void;
14
+ /** Rasterize an SVG string at `scale` (2× unless given), within browser canvas limits. */
15
+ export declare function svgToPng(svg: string, scale?: number): Promise<Blob>;
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Diagram appearance: five preset themes, color families with numeric shades, and the overrides a
3
+ * file can set. `resolveAppearance` turns a saved appearance into the concrete colors, spacing and
4
+ * type that sizing, the canvas and both SVG exports read, so all of them agree.
5
+ *
6
+ * Diagram appearance is separate from the editor's light or dark mode.
7
+ */
8
+ import type { Footnote } from './footnote';
9
+ import type { Note } from './note';
10
+ import { type FontRole, type TypeProfile } from './fonts';
11
+ import type { FileConfig } from './link';
12
+ export type ThemeId = 'drafting' | 'fieldnotes' | 'signal' | 'ink' | 'blueprint';
13
+ export declare const THEME_IDS: ThemeId[];
14
+ export declare const DEFAULT_THEME: ThemeId;
15
+ /** Shade stops. Lower numbers are lighter and higher numbers darker, in every theme. */
16
+ export declare const SHADES: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
17
+ export type Shade = (typeof SHADES)[number];
18
+ export declare const isShade: (n: unknown) => n is Shade;
19
+ /** Shade of a node that names a color without a shade. */
20
+ export declare const NODE_SHADE: Shade;
21
+ /**
22
+ * Shade of a group that names a color without a shade. Groups are quiet surfaces behind nodes, so
23
+ * this is a pale shade in light themes and a deep one in dark themes; the scale itself never flips.
24
+ */
25
+ export declare const groupShadeFor: (theme: ThemeId) => Shade;
26
+ /** Built-in color families, available in every theme. `primary` and `secondary` follow the theme. */
27
+ export declare const BUILT_IN_FAMILIES: readonly ["primary", "secondary", "slate", "stone", "blue", "sky", "teal", "mint", "green", "amber", "orange", "red", "rose", "violet"];
28
+ export declare const isBuiltInFamily: (name: string) => boolean;
29
+ export interface Swatch {
30
+ fill: string;
31
+ stroke: string;
32
+ ink: string;
33
+ }
34
+ /** A file's color declaration: one shade of a family. Built-in shades may set some fields only. */
35
+ export interface ColorDefinition {
36
+ family: string;
37
+ shade: Shade;
38
+ fill?: string;
39
+ stroke?: string;
40
+ ink?: string;
41
+ }
42
+ export interface AppearanceOverrides {
43
+ paddingX?: number;
44
+ paddingY?: number;
45
+ radius?: number;
46
+ titleFont?: FontRole;
47
+ annotationFont?: FontRole;
48
+ canvas?: string;
49
+ text?: string;
50
+ connection?: string;
51
+ }
52
+ export interface DiagramAppearance {
53
+ theme: ThemeId;
54
+ overrides: AppearanceOverrides;
55
+ colors: ColorDefinition[];
56
+ /** What the colors mean, from `legend` statements, drawn as a key beside the diagram. */
57
+ legend?: LegendEntry[];
58
+ /** Title and subtitle drawn above exported images, from `diagram` and `subtitle` statements. */
59
+ heading?: Heading;
60
+ /** Sentences drawn on the diagram without moving it, from `note` statements. */
61
+ notes?: Note[];
62
+ /** Entries of the block between the drawing and the key, from `footnote` statements. */
63
+ footnotes?: Footnote[];
64
+ /** Panel labels from a `compare` statement: draw the old and new versions side by side. */
65
+ compare?: {
66
+ /** Set by `draftably compare`: the changes the older panel draws in their new version. */
67
+ undrawn?: string;
68
+ before: string;
69
+ after: string;
70
+ /** `right` sets the panels side by side, `down` stacks them; chosen by `aspect` when unset. */
71
+ direction?: 'right' | 'down';
72
+ /** Width over height the whole image should come closest to; 1.6 when unset. */
73
+ aspect?: number;
74
+ };
75
+ /** File settings from `config` statements. */
76
+ config?: FileConfig;
77
+ /** Named emphasis states from `state` statements, in file order. */
78
+ states?: EmphasisState[];
79
+ }
80
+ /** One way to draw the diagram: these objects and connections in focus, the rest faded or plain. */
81
+ export interface EmphasisState {
82
+ id: string;
83
+ label: string;
84
+ /** Objects (a group brings its members) and connections in focus. */
85
+ ids: string[];
86
+ /** How everything else draws: faded like a context line, or as usual. */
87
+ rest: 'dim' | 'plain';
88
+ }
89
+ export interface Heading {
90
+ title?: string;
91
+ subtitle?: string;
92
+ /** Width of the frame round the drawing, from `diagram width=`; never narrower than its content. */
93
+ width?: number;
94
+ }
95
+ /** The connection styles a `legend line` row can explain. */
96
+ export declare const LEGEND_LINES: readonly ["dashed", "solid"];
97
+ export type LegendLine = (typeof LEGEND_LINES)[number];
98
+ /** One row of the key: a color swatch (`family`), or a short connection (`line`). */
99
+ export interface LegendEntry {
100
+ family?: string;
101
+ line?: LegendLine;
102
+ /** Shade of the swatch; nodes' default when omitted. */
103
+ shade?: Shade;
104
+ label: string;
105
+ }
106
+ export declare const defaultAppearance: () => DiagramAppearance;
107
+ /** Limits for numeric overrides, shared by the file parser and JSON validation. */
108
+ export declare const OVERRIDE_LIMITS: {
109
+ readonly paddingX: {
110
+ readonly min: 4;
111
+ readonly max: 48;
112
+ };
113
+ readonly paddingY: {
114
+ readonly min: 4;
115
+ readonly max: 48;
116
+ };
117
+ readonly radius: {
118
+ readonly min: 0;
119
+ readonly max: 24;
120
+ };
121
+ };
122
+ export declare const HEX_COLOR: RegExp;
123
+ interface Preset {
124
+ label: string;
125
+ description: string;
126
+ dark: boolean;
127
+ canvas: string;
128
+ text: string;
129
+ muted: string;
130
+ connection: string;
131
+ node: Swatch;
132
+ group: Swatch;
133
+ paddingX: number;
134
+ paddingY: number;
135
+ radius: number;
136
+ shadow: boolean;
137
+ titleFont: FontRole;
138
+ annotationFont: FontRole;
139
+ titleSize: number;
140
+ titleLine: number;
141
+ annotationSize: number;
142
+ /** Chroma multiplier for the built-in families: how saturated this theme's colors are. */
143
+ chroma: number;
144
+ /** Anchor colors for `primary` and `secondary`, at the shade they appear as. */
145
+ primary: [string, Shade];
146
+ secondary: [string, Shade];
147
+ /** Hue and chroma for built-in families this theme draws in its own way. */
148
+ hues?: Partial<Record<string, [number, number]>>;
149
+ }
150
+ export declare const PRESETS: Record<ThemeId, Preset>;
151
+ export declare function contrast(a: string, b: string): number;
152
+ /** Contrast targets (WCAG ratios) every generated color meets. */
153
+ export declare const CONTRAST: {
154
+ /** Dark title text on a pale fill. */
155
+ readonly paleInk: 7;
156
+ /** White title text on a dark fill. */
157
+ readonly darkInk: 4.5;
158
+ /** A shape's outline against the canvas when its fill alone does not separate it. */
159
+ readonly outline: 3;
160
+ /** Connection lines and connection label text against the canvas. */
161
+ readonly connection: 4.5;
162
+ /** A group's frame against the canvas. */
163
+ readonly frame: 2;
164
+ };
165
+ /**
166
+ * Move a color's lightness away from `against` until it reaches `min` contrast with it. Colors
167
+ * that already meet the target are returned unchanged.
168
+ */
169
+ export declare function ensureContrast(color: string, against: string, min: number): string;
170
+ /** The built-in families of a preset on a canvas color, generated once. */
171
+ export declare function builtInFamilies(theme: ThemeId, canvas?: string): Map<string, Map<Shade, Swatch>>;
172
+ export interface ResolvedAppearance {
173
+ theme: ThemeId;
174
+ dark: boolean;
175
+ canvas: string;
176
+ text: string;
177
+ muted: string;
178
+ connection: string;
179
+ /** Default node and group colors when nothing names a family. */
180
+ node: Swatch;
181
+ group: Swatch;
182
+ paddingX: number;
183
+ paddingY: number;
184
+ radius: number;
185
+ shadow: boolean;
186
+ title: TypeProfile;
187
+ groupTitle: TypeProfile;
188
+ annotation: TypeProfile;
189
+ /** Space above a group's content; the group title sits in it. */
190
+ groupHeader: number;
191
+ /** Every family and the shades it defines: built-in ones plus the file's own. */
192
+ families: Map<string, Map<Shade, Swatch>>;
193
+ custom: Set<string>;
194
+ /** Strike a removed object's title through (`config strike-removed=on`). */
195
+ strikeRemoved: boolean;
196
+ }
197
+ /** Height of a group's title band, derived from the title's line height. */
198
+ export declare const groupHeaderFor: (lineHeight: number) => number;
199
+ /** Preset values, then file overrides. Omitted fields inherit from the preset. */
200
+ export declare function resolveAppearance(appearance?: DiagramAppearance): ResolvedAppearance;
201
+ /**
202
+ * Colors for an object. `family` is a family name, or `auto` for the theme's default surface; an
203
+ * omitted shade is 500 for nodes and 100 for groups. Unknown families or shades fall back to the
204
+ * default surface; the file parser reports them before they get here.
205
+ */
206
+ export declare function swatchFor(r: ResolvedAppearance, family: string | undefined, shade: Shade | undefined, kind?: 'node' | 'group'): Swatch;
207
+ /** Shades a family defines, in numeric order. */
208
+ export declare const shadesOf: (r: ResolvedAppearance, family: string) => Shade[];
209
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { VisibleGraph } from './graph';
2
+ import type { Diagram, Point, Rect } from './types';
3
+ /** How far a connection's ink reaches past its points: half the stroke plus the arrowhead's wings. */
4
+ export declare const ROUTE_INK = 4;
5
+ export interface BoundedRoute {
6
+ id?: string;
7
+ points: readonly Point[];
8
+ label: {
9
+ x: number;
10
+ y: number;
11
+ w: number;
12
+ h: number;
13
+ } | null;
14
+ }
15
+ /**
16
+ * Bounds of everything drawn: shapes with their labels, containers, every route point with its
17
+ * stroke and arrowhead, and every connection label box. `pad` adds a margin on each side.
18
+ */
19
+ export declare function drawingBounds(doc: Diagram, vg: VisibleGraph, rects: ReadonlyMap<string, Rect>, routes: readonly BoundedRoute[], pad?: number): Rect;
@@ -0,0 +1,21 @@
1
+ import type { Rect } from './types';
2
+ /** A camera described by the world point at the viewport center and a zoom factor. */
3
+ export interface ViewCamera {
4
+ cx: number;
5
+ cy: number;
6
+ k: number;
7
+ }
8
+ /** Camera that fits `bounds` inside `viewport` with padding, or null for a hidden viewport. */
9
+ export declare function fitCamera(bounds: Rect, viewport: {
10
+ width: number;
11
+ height: number;
12
+ } | undefined, padding?: number): ViewCamera | null;
13
+ /**
14
+ * The zoom factor for one wheel event. A mouse notch (about 100px) zooms by about 18%; a pinch,
15
+ * which arrives as small Ctrl + wheel deltas, keeps its faster rate. `unit` converts line and
16
+ * page deltas to pixels.
17
+ */
18
+ export declare function wheelZoomFactor(e: {
19
+ deltaY: number;
20
+ ctrlKey: boolean;
21
+ }, unit?: number): number;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Compare's reading of its candidates: what each one measures, which ones are the same drawing,
3
+ * which few are worth showing, and how each differs from the current drawing.
4
+ */
5
+ import type { RoutingResult } from '../engines/routing-engine.js';
6
+ import type { StaticScene } from './static-scene';
7
+ export interface Measure {
8
+ crossings: number;
9
+ blocked: number;
10
+ overlaps: number;
11
+ labels: number;
12
+ bends: number;
13
+ length: number;
14
+ area: number;
15
+ aspect: number;
16
+ }
17
+ export declare function measure(scene: StaticScene, routing: RoutingResult): Measure;
18
+ /** Two drawings match when every box and line agrees within a couple of pixels. */
19
+ export declare function sameDrawing(a: StaticScene, b: StaticScene): boolean;
20
+ export interface Reading {
21
+ /** Hard defects this candidate has that the current drawing does not. */
22
+ defects: string[];
23
+ gains: string[];
24
+ costs: string[];
25
+ }
26
+ export declare const count: (n: number, noun: string) => string;
27
+ /** How a candidate differs from the current drawing, from its measures alone. */
28
+ export declare function readDifference(m: Measure, base: Measure): Reading;
29
+ /** The measures of the drawing the others are read against. */
30
+ export declare const describeMeasure: (m: Measure) => string;
31
+ export interface Candidate {
32
+ index: number;
33
+ measure: Measure;
34
+ scene: StaticScene;
35
+ }
36
+ /**
37
+ * The sheet's slots after a change: each card in `keep` stays where it was, so a card never moves
38
+ * under the pointer, and `fill` takes the free slots in order.
39
+ */
40
+ export declare function holdSlots(before: number[], keep: number[], fill: number[], limit: number): number[];
41
+ /**
42
+ * The candidates worth showing beside the current drawing, best first. Repeats of the current
43
+ * drawing or of each other are dropped. A candidate with more hard defects than the current
44
+ * drawing comes last, whatever its other measures, and the fewer it has the sooner it comes. A
45
+ * candidate that beats the current drawing on something comes before one that does not: first the
46
+ * best for hard defects, crossings, area and line length, then the ones with the fewest hard
47
+ * defects and least like those already chosen.
48
+ */
49
+ export declare function pickCandidates(current: Candidate, candidates: Candidate[], limit: number): {
50
+ shown: number[];
51
+ others: number[];
52
+ alike: number;
53
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The colors an object is drawn in. A file names a family and maybe a shade; drawing adds one
3
+ * rule on top, so nesting stays readable without the author doing shade arithmetic:
4
+ *
5
+ * - A container inside a container of the same family steps one shade toward emphasis per level
6
+ * (lighter frames underneath, smaller and stronger ones on top), instead of repeating the fill.
7
+ * - A shape whose shade is within two steps of its container's, in the same family, moves three
8
+ * steps past the container, so a member never melts into its frame.
9
+ *
10
+ * The canvas, the CLI's SVG and exports all draw through `drawnSwatch`.
11
+ */
12
+ import { type ResolvedAppearance, type Shade, type Swatch } from './appearance';
13
+ import type { Diagram } from './types';
14
+ /** The shade an object is drawn at, or undefined for the theme's neutral surface. */
15
+ export declare function drawnShade(doc: Diagram, look: ResolvedAppearance, id: string): Shade | undefined;
16
+ /** The swatch an object is drawn with. */
17
+ export declare function drawnSwatch(doc: Diagram, look: ResolvedAppearance, id: string, kind: 'node' | 'group'): Swatch;
18
+ /**
19
+ * A sequence participant's accent: the fill its color would have, drawn as a thin stripe along
20
+ * its top. Undefined for anything else, and for a participant with no color of its own.
21
+ */
22
+ export declare function participantAccent(doc: Diagram, look: ResolvedAppearance, id: string): string | undefined;
@@ -0,0 +1,24 @@
1
+ import { type DiagramAppearance } from './appearance';
2
+ import type { Diagram, DiagramSettings } from './types';
3
+ export declare const MAX_NODES = 500;
4
+ export declare const MAX_EDGES = 1200;
5
+ export declare function uid(prefix?: string): string;
6
+ export declare const DEFAULT_SETTINGS: DiagramSettings;
7
+ export declare function emptyDiagram(title?: string): Diagram;
8
+ type Raw = any;
9
+ export declare const isLegacyDiagram: (input: Raw) => boolean;
10
+ /**
11
+ * Validate a diagram from any source and return a complete, canonical copy.
12
+ * Throws a readable error for anything that cannot be repaired.
13
+ */
14
+ export declare function normalize(input: unknown): Diagram;
15
+ /** Validate a saved appearance. A missing appearance is the default theme. */
16
+ export declare function normalizeAppearance(input: Raw): DiagramAppearance;
17
+ /** The meaning of a document, ignoring where the camera happens to be. */
18
+ export declare function documentIdentity(doc: Diagram): string;
19
+ /**
20
+ * Inputs that affect connection routing. The editor store keeps the key order of the document it
21
+ * replaced, so the worker's freshly projected copy of the same document lists its keys differently.
22
+ */
23
+ export declare function routingFingerprint(doc: Diagram): string;
24
+ export {};