@swiftlysingh/excalidraw-cli 1.0.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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -0
  3. package/dist/cli.d.ts +8 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +152 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/factory/connection-factory.d.ts +16 -0
  8. package/dist/factory/connection-factory.d.ts.map +1 -0
  9. package/dist/factory/connection-factory.js +91 -0
  10. package/dist/factory/connection-factory.js.map +1 -0
  11. package/dist/factory/element-factory.d.ts +16 -0
  12. package/dist/factory/element-factory.d.ts.map +1 -0
  13. package/dist/factory/element-factory.js +78 -0
  14. package/dist/factory/element-factory.js.map +1 -0
  15. package/dist/factory/index.d.ts +8 -0
  16. package/dist/factory/index.d.ts.map +1 -0
  17. package/dist/factory/index.js +8 -0
  18. package/dist/factory/index.js.map +1 -0
  19. package/dist/factory/node-factory.d.ts +24 -0
  20. package/dist/factory/node-factory.d.ts.map +1 -0
  21. package/dist/factory/node-factory.js +85 -0
  22. package/dist/factory/node-factory.js.map +1 -0
  23. package/dist/factory/text-factory.d.ts +42 -0
  24. package/dist/factory/text-factory.d.ts.map +1 -0
  25. package/dist/factory/text-factory.js +148 -0
  26. package/dist/factory/text-factory.js.map +1 -0
  27. package/dist/generator/excalidraw-generator.d.ts +17 -0
  28. package/dist/generator/excalidraw-generator.d.ts.map +1 -0
  29. package/dist/generator/excalidraw-generator.js +91 -0
  30. package/dist/generator/excalidraw-generator.js.map +1 -0
  31. package/dist/generator/index.d.ts +5 -0
  32. package/dist/generator/index.d.ts.map +1 -0
  33. package/dist/generator/index.js +5 -0
  34. package/dist/generator/index.js.map +1 -0
  35. package/dist/index.d.ts +23 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +36 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/layout/arrow-router.d.ts +48 -0
  40. package/dist/layout/arrow-router.d.ts.map +1 -0
  41. package/dist/layout/arrow-router.js +103 -0
  42. package/dist/layout/arrow-router.js.map +1 -0
  43. package/dist/layout/elk-layout.d.ts +11 -0
  44. package/dist/layout/elk-layout.d.ts.map +1 -0
  45. package/dist/layout/elk-layout.js +179 -0
  46. package/dist/layout/elk-layout.js.map +1 -0
  47. package/dist/layout/index.d.ts +6 -0
  48. package/dist/layout/index.d.ts.map +1 -0
  49. package/dist/layout/index.js +6 -0
  50. package/dist/layout/index.js.map +1 -0
  51. package/dist/parser/dsl-parser.d.ts +21 -0
  52. package/dist/parser/dsl-parser.d.ts.map +1 -0
  53. package/dist/parser/dsl-parser.js +249 -0
  54. package/dist/parser/dsl-parser.js.map +1 -0
  55. package/dist/parser/index.d.ts +6 -0
  56. package/dist/parser/index.d.ts.map +1 -0
  57. package/dist/parser/index.js +6 -0
  58. package/dist/parser/index.js.map +1 -0
  59. package/dist/parser/json-parser.d.ts +16 -0
  60. package/dist/parser/json-parser.d.ts.map +1 -0
  61. package/dist/parser/json-parser.js +76 -0
  62. package/dist/parser/json-parser.js.map +1 -0
  63. package/dist/types/dsl.d.ts +127 -0
  64. package/dist/types/dsl.d.ts.map +1 -0
  65. package/dist/types/dsl.js +14 -0
  66. package/dist/types/dsl.js.map +1 -0
  67. package/dist/types/excalidraw.d.ts +171 -0
  68. package/dist/types/excalidraw.d.ts.map +1 -0
  69. package/dist/types/excalidraw.js +36 -0
  70. package/dist/types/excalidraw.js.map +1 -0
  71. package/dist/types/index.d.ts +6 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/index.js +6 -0
  74. package/dist/types/index.js.map +1 -0
  75. package/package.json +53 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * JSON Parser for Flowchart Input
3
+ *
4
+ * Accepts structured JSON input for programmatic flowchart creation.
5
+ */
6
+ import type { FlowchartGraph, FlowchartInput } from '../types/dsl.js';
7
+ /**
8
+ * Parse JSON input into FlowchartGraph
9
+ */
10
+ export declare function parseJSON(input: FlowchartInput): FlowchartGraph;
11
+ /**
12
+ * Parse JSON string into FlowchartGraph
13
+ */
14
+ export declare function parseJSONString(jsonString: string): FlowchartGraph;
15
+ export { DEFAULT_LAYOUT_OPTIONS } from '../types/dsl.js';
16
+ //# sourceMappingURL=json-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-parser.d.ts","sourceRoot":"","sources":["../../src/parser/json-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAiD/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,CAUlE;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * JSON Parser for Flowchart Input
3
+ *
4
+ * Accepts structured JSON input for programmatic flowchart creation.
5
+ */
6
+ import { nanoid } from 'nanoid';
7
+ import { DEFAULT_LAYOUT_OPTIONS } from '../types/dsl.js';
8
+ /**
9
+ * Validate node type
10
+ */
11
+ function isValidNodeType(type) {
12
+ return ['rectangle', 'diamond', 'ellipse', 'database'].includes(type);
13
+ }
14
+ /**
15
+ * Parse JSON input into FlowchartGraph
16
+ */
17
+ export function parseJSON(input) {
18
+ const nodeMap = new Map();
19
+ // Process nodes
20
+ for (const nodeInput of input.nodes) {
21
+ const type = isValidNodeType(nodeInput.type) ? nodeInput.type : 'rectangle';
22
+ const node = {
23
+ id: nodeInput.id || nanoid(10),
24
+ type,
25
+ label: nodeInput.label,
26
+ style: nodeInput.style,
27
+ };
28
+ nodeMap.set(nodeInput.id, node);
29
+ }
30
+ // Process edges
31
+ const edges = input.edges.map((edgeInput) => {
32
+ const sourceNode = nodeMap.get(edgeInput.from);
33
+ const targetNode = nodeMap.get(edgeInput.to);
34
+ if (!sourceNode) {
35
+ throw new Error(`Edge references unknown source node: ${edgeInput.from}`);
36
+ }
37
+ if (!targetNode) {
38
+ throw new Error(`Edge references unknown target node: ${edgeInput.to}`);
39
+ }
40
+ return {
41
+ id: nanoid(10),
42
+ source: sourceNode.id,
43
+ target: targetNode.id,
44
+ label: edgeInput.label,
45
+ style: edgeInput.style,
46
+ };
47
+ });
48
+ // Merge options with defaults
49
+ const options = {
50
+ ...DEFAULT_LAYOUT_OPTIONS,
51
+ ...input.options,
52
+ };
53
+ return {
54
+ nodes: Array.from(nodeMap.values()),
55
+ edges,
56
+ options,
57
+ };
58
+ }
59
+ /**
60
+ * Parse JSON string into FlowchartGraph
61
+ */
62
+ export function parseJSONString(jsonString) {
63
+ try {
64
+ const input = JSON.parse(jsonString);
65
+ return parseJSON(input);
66
+ }
67
+ catch (error) {
68
+ if (error instanceof SyntaxError) {
69
+ throw new Error(`Invalid JSON: ${error.message}`);
70
+ }
71
+ throw error;
72
+ }
73
+ }
74
+ // Re-export
75
+ export { DEFAULT_LAYOUT_OPTIONS } from '../types/dsl.js';
76
+ //# sourceMappingURL=json-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-parser.js","sourceRoot":"","sources":["../../src/parser/json-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;GAEG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE7C,gBAAgB;IAChB,KA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AAG,sBAAsB;QACzB,GAAG,KAAK,CAAC,OAAO;KACjB,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAmB,CAAC;QACvD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,YAAY;AACZ,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Flowchart DSL Type Definitions
3
+ */
4
+ export type NodeType = 'rectangle' | 'diamond' | 'ellipse' | 'database';
5
+ export type FlowDirection = 'TB' | 'BT' | 'LR' | 'RL';
6
+ export type LayoutAlgorithm = 'layered' | 'tree' | 'force';
7
+ export type ArrowheadType = 'arrow' | 'bar' | 'dot' | 'triangle' | null;
8
+ export type StrokeStyle = 'solid' | 'dashed' | 'dotted';
9
+ export type FillStyle = 'solid' | 'hachure' | 'cross-hatch';
10
+ /**
11
+ * Node style configuration
12
+ */
13
+ export interface NodeStyle {
14
+ backgroundColor?: string;
15
+ strokeColor?: string;
16
+ strokeWidth?: number;
17
+ strokeStyle?: StrokeStyle;
18
+ fillStyle?: FillStyle;
19
+ opacity?: number;
20
+ fontSize?: number;
21
+ fontFamily?: number;
22
+ roughness?: number;
23
+ }
24
+ /**
25
+ * Edge style configuration
26
+ */
27
+ export interface EdgeStyle {
28
+ strokeColor?: string;
29
+ strokeWidth?: number;
30
+ strokeStyle?: StrokeStyle;
31
+ startArrowhead?: ArrowheadType;
32
+ endArrowhead?: ArrowheadType;
33
+ roughness?: number;
34
+ }
35
+ /**
36
+ * A node in the flowchart graph
37
+ */
38
+ export interface GraphNode {
39
+ id: string;
40
+ type: NodeType;
41
+ label: string;
42
+ style?: NodeStyle;
43
+ }
44
+ /**
45
+ * An edge (connection) between nodes
46
+ */
47
+ export interface GraphEdge {
48
+ id: string;
49
+ source: string;
50
+ target: string;
51
+ label?: string;
52
+ style?: EdgeStyle;
53
+ }
54
+ /**
55
+ * Layout configuration options
56
+ */
57
+ export interface LayoutOptions {
58
+ algorithm: LayoutAlgorithm;
59
+ direction: FlowDirection;
60
+ nodeSpacing: number;
61
+ rankSpacing: number;
62
+ padding: number;
63
+ }
64
+ /**
65
+ * Complete flowchart graph representation
66
+ */
67
+ export interface FlowchartGraph {
68
+ nodes: GraphNode[];
69
+ edges: GraphEdge[];
70
+ options: LayoutOptions;
71
+ }
72
+ /**
73
+ * Default layout options
74
+ */
75
+ export declare const DEFAULT_LAYOUT_OPTIONS: LayoutOptions;
76
+ /**
77
+ * JSON input format for programmatic API
78
+ */
79
+ export interface FlowchartInput {
80
+ nodes: Array<{
81
+ id: string;
82
+ type: string;
83
+ label: string;
84
+ style?: NodeStyle;
85
+ }>;
86
+ edges: Array<{
87
+ from: string;
88
+ to: string;
89
+ label?: string;
90
+ style?: EdgeStyle;
91
+ }>;
92
+ options?: Partial<LayoutOptions>;
93
+ }
94
+ /**
95
+ * Node with computed layout position
96
+ */
97
+ export interface LayoutedNode extends GraphNode {
98
+ x: number;
99
+ y: number;
100
+ width: number;
101
+ height: number;
102
+ }
103
+ /**
104
+ * Edge with computed layout points
105
+ */
106
+ export interface LayoutedEdge extends GraphEdge {
107
+ points: Array<[number, number]>;
108
+ sourcePoint: {
109
+ x: number;
110
+ y: number;
111
+ };
112
+ targetPoint: {
113
+ x: number;
114
+ y: number;
115
+ };
116
+ }
117
+ /**
118
+ * Layouted flowchart graph
119
+ */
120
+ export interface LayoutedGraph {
121
+ nodes: LayoutedNode[];
122
+ edges: LayoutedEdge[];
123
+ options: LayoutOptions;
124
+ width: number;
125
+ height: number;
126
+ }
127
+ //# sourceMappingURL=dsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dsl.d.ts","sourceRoot":"","sources":["../../src/types/dsl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAExE,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,IAAI,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAA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ACf,KAAK,CAAC,EAAE,SAAS,CAAC;KACnB,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChC,WAAW,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,WAAW,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Flowchart DSL Type Definitions
3
+ */
4
+ /**
5
+ * Default layout options
6
+ */
7
+ export const DEFAULT_LAYOUT_OPTIONS = {
8
+ algorithm: 'layered',
9
+ direction: 'TB',
10
+ nodeSpacing: 50,
11
+ rankSpacing: 80,
12
+ padding: 50,
13
+ };
14
+ //# sourceMappingURL=dsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dsl.js","sourceRoot":"","sources":["../../src/types/dsl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkFH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,EAAE;CACZ,CAAC"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Excalidraw Element Type Definitions
3
+ * Based on Excalidraw JSON schema
4
+ */
5
+ export type ExcalidrawElementType = 'rectangle' | 'diamond' | 'ellipse' | 'text' | 'arrow' | 'line' | 'freedraw';
6
+ export type ExcalidrawFillStyle = 'solid' | 'hachure' | 'cross-hatch';
7
+ export type ExcalidrawStrokeStyle = 'solid' | 'dashed' | 'dotted';
8
+ export type ExcalidrawArrowhead = 'arrow' | 'bar' | 'dot' | 'triangle' | null;
9
+ export type ExcalidrawTextAlign = 'left' | 'center' | 'right';
10
+ export type ExcalidrawVerticalAlign = 'top' | 'middle' | 'bottom';
11
+ /**
12
+ * Roundness configuration for elements
13
+ */
14
+ export interface ExcalidrawRoundness {
15
+ type: 1 | 2 | 3;
16
+ }
17
+ /**
18
+ * Binding reference for arrows
19
+ */
20
+ export interface ExcalidrawBoundElement {
21
+ id: string;
22
+ type: 'arrow' | 'text';
23
+ }
24
+ /**
25
+ * Arrow binding to shapes
26
+ */
27
+ export interface ExcalidrawArrowBinding {
28
+ elementId: string;
29
+ mode: 'orbit' | 'point';
30
+ fixedPoint: [number, number];
31
+ }
32
+ /**
33
+ * Base properties shared by all Excalidraw elements
34
+ */
35
+ export interface ExcalidrawElementBase {
36
+ id: string;
37
+ type: ExcalidrawElementType;
38
+ x: number;
39
+ y: number;
40
+ width: number;
41
+ height: number;
42
+ angle: number;
43
+ strokeColor: string;
44
+ backgroundColor: string;
45
+ fillStyle: ExcalidrawFillStyle;
46
+ strokeWidth: number;
47
+ strokeStyle: ExcalidrawStrokeStyle;
48
+ roughness: number;
49
+ opacity: number;
50
+ groupIds: string[];
51
+ frameId: string | null;
52
+ index: string;
53
+ roundness: ExcalidrawRoundness | null;
54
+ seed: number;
55
+ version: number;
56
+ versionNonce: number;
57
+ isDeleted: boolean;
58
+ boundElements: ExcalidrawBoundElement[] | null;
59
+ updated: number;
60
+ link: string | null;
61
+ locked: boolean;
62
+ }
63
+ /**
64
+ * Rectangle element
65
+ */
66
+ export interface ExcalidrawRectangle extends ExcalidrawElementBase {
67
+ type: 'rectangle';
68
+ }
69
+ /**
70
+ * Diamond element
71
+ */
72
+ export interface ExcalidrawDiamond extends ExcalidrawElementBase {
73
+ type: 'diamond';
74
+ }
75
+ /**
76
+ * Ellipse element
77
+ */
78
+ export interface ExcalidrawEllipse extends ExcalidrawElementBase {
79
+ type: 'ellipse';
80
+ }
81
+ /**
82
+ * Text element
83
+ */
84
+ export interface ExcalidrawText extends ExcalidrawElementBase {
85
+ type: 'text';
86
+ text: string;
87
+ fontSize: number;
88
+ fontFamily: number;
89
+ textAlign: ExcalidrawTextAlign;
90
+ verticalAlign: ExcalidrawVerticalAlign;
91
+ containerId: string | null;
92
+ originalText: string;
93
+ autoResize: boolean;
94
+ lineHeight: number;
95
+ }
96
+ /**
97
+ * Arrow element
98
+ */
99
+ export interface ExcalidrawArrow extends ExcalidrawElementBase {
100
+ type: 'arrow';
101
+ points: Array<[number, number]>;
102
+ lastCommittedPoint: [number, number] | null;
103
+ startBinding: ExcalidrawArrowBinding | null;
104
+ endBinding: ExcalidrawArrowBinding | null;
105
+ startArrowhead: ExcalidrawArrowhead;
106
+ endArrowhead: ExcalidrawArrowhead;
107
+ elbowed: boolean;
108
+ }
109
+ /**
110
+ * Line element
111
+ */
112
+ export interface ExcalidrawLine extends ExcalidrawElementBase {
113
+ type: 'line';
114
+ points: Array<[number, number]>;
115
+ lastCommittedPoint: [number, number] | null;
116
+ startBinding: ExcalidrawArrowBinding | null;
117
+ endBinding: ExcalidrawArrowBinding | null;
118
+ startArrowhead: ExcalidrawArrowhead;
119
+ endArrowhead: ExcalidrawArrowhead;
120
+ }
121
+ /**
122
+ * Union type for all Excalidraw elements
123
+ */
124
+ export type ExcalidrawElement = ExcalidrawRectangle | ExcalidrawDiamond | ExcalidrawEllipse | ExcalidrawText | ExcalidrawArrow | ExcalidrawLine;
125
+ /**
126
+ * Application state for the canvas
127
+ */
128
+ export interface ExcalidrawAppState {
129
+ gridSize: number;
130
+ gridStep: number;
131
+ gridModeEnabled: boolean;
132
+ viewBackgroundColor: string;
133
+ lockedMultiSelections: Record<string, unknown>;
134
+ }
135
+ /**
136
+ * Complete Excalidraw file structure
137
+ */
138
+ export interface ExcalidrawFile {
139
+ type: 'excalidraw';
140
+ version: 2;
141
+ source: string;
142
+ elements: ExcalidrawElement[];
143
+ appState: ExcalidrawAppState;
144
+ files: Record<string, unknown>;
145
+ }
146
+ /**
147
+ * Default app state
148
+ */
149
+ export declare const DEFAULT_APP_STATE: ExcalidrawAppState;
150
+ /**
151
+ * Default element style values
152
+ */
153
+ export declare const DEFAULT_ELEMENT_STYLE: {
154
+ strokeColor: string;
155
+ backgroundColor: string;
156
+ fillStyle: ExcalidrawFillStyle;
157
+ strokeWidth: number;
158
+ strokeStyle: ExcalidrawStrokeStyle;
159
+ roughness: number;
160
+ opacity: number;
161
+ };
162
+ /**
163
+ * Font family mapping
164
+ */
165
+ export declare const FONT_FAMILIES: {
166
+ readonly Virgil: 1;
167
+ readonly Helvetica: 2;
168
+ readonly Cascadia: 3;
169
+ readonly Excalifont: 5;
170
+ };
171
+ //# sourceMappingURL=excalidraw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excalidraw.d.ts","sourceRoot":"","sources":["../../src/types/excalidraw.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,MAAM,GACN,OAAO,GACP,MAAM,GACN,UAAU,CAAC;AAEf,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAEtE,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG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;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Excalidraw Element Type Definitions
3
+ * Based on Excalidraw JSON schema
4
+ */
5
+ /**
6
+ * Default app state
7
+ */
8
+ export const DEFAULT_APP_STATE = {
9
+ gridSize: 20,
10
+ gridStep: 5,
11
+ gridModeEnabled: false,
12
+ viewBackgroundColor: '#ffffff',
13
+ lockedMultiSelections: {},
14
+ };
15
+ /**
16
+ * Default element style values
17
+ */
18
+ export const DEFAULT_ELEMENT_STYLE = {
19
+ strokeColor: '#1e1e1e',
20
+ backgroundColor: 'transparent',
21
+ fillStyle: 'solid',
22
+ strokeWidth: 2,
23
+ strokeStyle: 'solid',
24
+ roughness: 1,
25
+ opacity: 100,
26
+ };
27
+ /**
28
+ * Font family mapping
29
+ */
30
+ export const FONT_FAMILIES = {
31
+ Virgil: 1,
32
+ Helvetica: 2,
33
+ Cascadia: 3,
34
+ Excalifont: 5,
35
+ };
36
+ //# sourceMappingURL=excalidraw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excalidraw.js","sourceRoot":"","sources":["../../src/types/excalidraw.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+KH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAuB;IACnD,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,CAAC;IACX,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,SAAS;IAC9B,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,aAAa;IAC9B,SAAS,EAAE,OAA8B;IACzC,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,OAAgC;IAC7C,SAAS,EAAE,CAAC;IACZ,OAAO,EAAE,GAAG;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;CACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Type definitions exports
3
+ */
4
+ export * from './dsl.js';
5
+ export * from './excalidraw.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Type definitions exports
3
+ */
4
+ export * from './dsl.js';
5
+ export * from './excalidraw.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@swiftlysingh/excalidraw-cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI for creating Excalidraw flowcharts programmatically",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "excalidraw-cli": "dist/cli.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "tsc --watch",
14
+ "test": "vitest",
15
+ "test:run": "vitest run",
16
+ "lint": "eslint src --ext .ts",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "excalidraw",
22
+ "flowchart",
23
+ "diagram",
24
+ "cli",
25
+ "visualization"
26
+ ],
27
+ "author": "",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/swiftlysingh/excalidraw-cli.git"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "engines": {
37
+ "node": ">=18.0.0"
38
+ },
39
+ "dependencies": {
40
+ "commander": "^12.1.0",
41
+ "elkjs": "^0.9.3",
42
+ "nanoid": "^5.0.9"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^22.10.5",
46
+ "@typescript-eslint/eslint-plugin": "^8.19.1",
47
+ "@typescript-eslint/parser": "^8.19.1",
48
+ "eslint": "^9.17.0",
49
+ "prettier": "^3.4.2",
50
+ "typescript": "^5.7.2",
51
+ "vitest": "^2.1.8"
52
+ }
53
+ }