sfn-diagram 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025-present Yusuf Afzal
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Yusuf Afzal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -1,4 +1,5 @@
1
- //#region rolldown:runtime
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
9
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
19
16
  }
20
17
  return to;
21
18
  };
@@ -23,15 +20,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
20
  value: mod,
24
21
  enumerable: true
25
22
  }) : target, mod));
26
-
27
23
  //#endregion
28
24
  let _dagrejs_dagre = require("@dagrejs/dagre");
29
25
  _dagrejs_dagre = __toESM(_dagrejs_dagre);
30
- let d3 = require("d3");
26
+ let d3_selection = require("d3-selection");
27
+ let d3_shape = require("d3-shape");
31
28
  let jsdom = require("jsdom");
32
- let node_html_to_image = require("node-html-to-image");
33
- node_html_to_image = __toESM(node_html_to_image);
34
-
35
29
  //#region src/config/themes.ts
36
30
  /**
37
31
  * AWS Light Theme - matches the AWS Step Functions console light mode
@@ -148,7 +142,6 @@ function getTheme(theme, customColors) {
148
142
  };
149
143
  return baseTheme;
150
144
  }
151
-
152
145
  //#endregion
153
146
  //#region src/styles/NodeStyles.ts
154
147
  /**
@@ -197,7 +190,6 @@ function getStrokeWidthForType(stateType) {
197
190
  default: return 2;
198
191
  }
199
192
  }
200
-
201
193
  //#endregion
202
194
  //#region src/constants/labels.ts
203
195
  /**
@@ -227,7 +219,6 @@ function getCatchLabel(params) {
227
219
  if (catchLabelStyle === "catch-number") return `${EDGE_LABELS.CATCH_PREFIX} #${index + 1}`;
228
220
  return getErrorLabel(errorTypes);
229
221
  }
230
-
231
222
  //#endregion
232
223
  //#region src/services/ServiceDetector.ts
233
224
  /**
@@ -419,7 +410,6 @@ function detectService(params) {
419
410
  serviceName
420
411
  };
421
412
  }
422
-
423
413
  //#endregion
424
414
  //#region src/AslParser.ts
425
415
  /**
@@ -777,7 +767,6 @@ function extractNestedEdges(params) {
777
767
  }
778
768
  }
779
769
  }
780
-
781
770
  //#endregion
782
771
  //#region src/layout/DagreLayout.ts
783
772
  /**
@@ -900,16 +889,16 @@ var DagreLayout = class {
900
889
  if (!fromNode || !toNode) return [];
901
890
  if (fromNode.isContainer && fromNode.children?.includes(edge.to)) {
902
891
  const headerHeight = 50;
903
- const fromX$1 = fromNode.x || 0;
904
- const toX$1 = toNode.x || 0;
905
- const fromY$1 = (fromNode.y || 0) - (fromNode.height || 0) / 2 + headerHeight;
906
- const toY$1 = (toNode.y || 0) - (toNode.height || 0) / 2;
892
+ const fromX = fromNode.x || 0;
893
+ const toX = toNode.x || 0;
894
+ const fromY = (fromNode.y || 0) - (fromNode.height || 0) / 2 + headerHeight;
895
+ const toY = (toNode.y || 0) - (toNode.height || 0) / 2;
907
896
  return [{
908
- x: fromX$1,
909
- y: fromY$1
897
+ x: fromX,
898
+ y: fromY
910
899
  }, {
911
- x: toX$1,
912
- y: toY$1
900
+ x: toX,
901
+ y: toY
913
902
  }];
914
903
  }
915
904
  const fromX = fromNode.x || 0;
@@ -953,7 +942,6 @@ var DagreLayout = class {
953
942
  }
954
943
  }
955
944
  };
956
-
957
945
  //#endregion
958
946
  //#region src/renderers/SvgRenderer.ts
959
947
  /**
@@ -973,7 +961,7 @@ var SvgRenderer = class {
973
961
  const document = new jsdom.JSDOM("<!DOCTYPE html><html><body></body></html>").window.document;
974
962
  const bounds = this.calculateBounds(layout);
975
963
  const svgNode = document.createElementNS("http://www.w3.org/2000/svg", "svg");
976
- const svg = (0, d3.select)(svgNode).attr("width", bounds.width).attr("height", bounds.height).attr("xmlns", "http://www.w3.org/2000/svg").attr("viewBox", `${bounds.minX} ${bounds.minY} ${bounds.width} ${bounds.height}`);
964
+ const svg = (0, d3_selection.select)(svgNode).attr("width", bounds.width).attr("height", bounds.height).attr("xmlns", "http://www.w3.org/2000/svg").attr("viewBox", `${bounds.minX} ${bounds.minY} ${bounds.width} ${bounds.height}`);
977
965
  if (this.theme.background && this.theme.background !== "transparent") svg.append("rect").attr("x", bounds.minX).attr("y", bounds.minY).attr("width", bounds.width).attr("height", bounds.height).attr("fill", this.theme.background);
978
966
  const defs = svg.append("defs");
979
967
  defs.append("marker").attr("id", "arrowhead-normal").attr("markerWidth", 10).attr("markerHeight", 10).attr("refX", 9).attr("refY", 3).attr("orient", "auto").append("polygon").attr("points", "0 0, 10 3, 0 6").attr("fill", this.theme.edgeColors.normal);
@@ -1211,8 +1199,8 @@ var SvgRenderer = class {
1211
1199
  if (!edge.points || edge.points.length < 2) return;
1212
1200
  const edgeColor = this.theme.edgeColors[edge.type || "normal"];
1213
1201
  const markerType = edge.type || "normal";
1214
- const pathGenerator = (0, d3.line)().x((d) => d.x).y((d) => d.y);
1215
- if (this.options.edgeStyle === "curved") pathGenerator.curve(d3.curveBasis);
1202
+ const pathGenerator = (0, d3_shape.line)().x((d) => d.x).y((d) => d.y);
1203
+ if (this.options.edgeStyle === "curved") pathGenerator.curve(d3_shape.curveBasis);
1216
1204
  const pathElement = group.append("path").attr("d", pathGenerator(edge.points)).attr("fill", "none").attr("stroke", edgeColor).attr("stroke-width", edge.type === "error" ? 2 : 1.5).attr("marker-end", `url(#arrowhead-${markerType})`);
1217
1205
  if (edge.type === "error") pathElement.attr("stroke-dasharray", "5,5");
1218
1206
  else if (edge.type === "default") pathElement.attr("stroke-dasharray", "8,4");
@@ -1244,7 +1232,6 @@ var SvgRenderer = class {
1244
1232
  };
1245
1233
  }
1246
1234
  };
1247
-
1248
1235
  //#endregion
1249
1236
  //#region src/renderers/MermaidRenderer.ts
1250
1237
  /**
@@ -1343,81 +1330,6 @@ var MermaidRenderer = class {
1343
1330
  return nodes.find((node) => !targetNodes.has(node.id))?.id || nodes[0]?.id || null;
1344
1331
  }
1345
1332
  };
1346
-
1347
- //#endregion
1348
- //#region src/exporters/PngExporter.ts
1349
- /**
1350
- * PngExporter - Converts SVG to PNG using headless rendering
1351
- */
1352
- var PngExporter = class {
1353
- options;
1354
- constructor(options) {
1355
- this.options = options;
1356
- }
1357
- /**
1358
- * Convert SVG string to PNG buffer
1359
- *
1360
- * Note: External images (like AWS service icons from CDN) may not render in PNG export
1361
- * due to limitations with headless browser rendering. Use SVG output for best results
1362
- * when showIcons is enabled.
1363
- */
1364
- async convert(params) {
1365
- const { svg, width, height } = params;
1366
- return {
1367
- buffer: await (0, node_html_to_image.default)({
1368
- html: this.wrapSvgInHtml({
1369
- svg,
1370
- width,
1371
- height
1372
- }),
1373
- puppeteerArgs: { args: ["--no-sandbox", "--disable-setuid-sandbox"] },
1374
- quality: this.options.pngQuality || 90,
1375
- transparent: this.options.backgroundColor === "transparent",
1376
- type: "png"
1377
- }),
1378
- height,
1379
- metadata: { format: "png" },
1380
- width
1381
- };
1382
- }
1383
- /**
1384
- * Wrap SVG in HTML for rendering
1385
- */
1386
- wrapSvgInHtml(params) {
1387
- const { svg, width, height } = params;
1388
- return `
1389
- <!DOCTYPE html>
1390
- <html>
1391
- <head>
1392
- <meta charset="UTF-8">
1393
- <style>
1394
- * {
1395
- margin: 0;
1396
- padding: 0;
1397
- box-sizing: border-box;
1398
- }
1399
- body {
1400
- width: ${width}px;
1401
- height: ${height}px;
1402
- background: ${this.options.backgroundColor || "transparent"};
1403
- display: flex;
1404
- align-items: center;
1405
- justify-content: center;
1406
- }
1407
- svg {
1408
- max-width: 100%;
1409
- max-height: 100%;
1410
- }
1411
- </style>
1412
- </head>
1413
- <body>
1414
- ${svg}
1415
- </body>
1416
- </html>
1417
- `.trim();
1418
- }
1419
- };
1420
-
1421
1333
  //#endregion
1422
1334
  //#region src/config/defaults.ts
1423
1335
  /**
@@ -1456,7 +1368,6 @@ function mergeOptions(options = {}) {
1456
1368
  ...options
1457
1369
  };
1458
1370
  }
1459
-
1460
1371
  //#endregion
1461
1372
  //#region src/utils/iconEmbedder.ts
1462
1373
  /** Default timeout for icon fetch operations in milliseconds */
@@ -1527,7 +1438,6 @@ async function embedIcons(params) {
1527
1438
  });
1528
1439
  return embeddedSvg;
1529
1440
  }
1530
-
1531
1441
  //#endregion
1532
1442
  //#region src/index.ts
1533
1443
  /**
@@ -1706,56 +1616,6 @@ function generateDiagram(params) {
1706
1616
  });
1707
1617
  }
1708
1618
  /**
1709
- * Export a diagram as PNG (asynchronous)
1710
- *
1711
- * This function generates an SVG diagram and converts it to PNG format using
1712
- * headless browser rendering. The output is a Buffer that can be written to a file.
1713
- *
1714
- * **Note:** This function is asynchronous and uses Puppeteer for rendering,
1715
- * which may take a moment on first run to download the browser binary.
1716
- *
1717
- * @param params - Configuration object
1718
- * @param params.aslDefinition - ASL definition as an object or JSON string
1719
- * @param params.pngQuality - PNG quality from 1-100 (default: 90)
1720
- * @param params.backgroundColor - Background color as CSS color or 'transparent' (default: 'transparent')
1721
- * @param ...params - Other SVG options (see generateSvg)
1722
- *
1723
- * @returns Promise resolving to PNG output with buffer and dimensions
1724
- *
1725
- * @throws {SyntaxError} If params.asl is a string with invalid JSON
1726
- * @throws {Error} If the ASL definition structure is invalid or PNG conversion fails
1727
- *
1728
- * @example
1729
- * ```typescript
1730
- * import { exportPng } from 'sfn-diagram';
1731
- * import { writeFileSync } from 'fs';
1732
- *
1733
- * const asl = { StartAt: 'Hello', States: { Hello: { Type: 'Pass', End: true } } };
1734
- *
1735
- * const { buffer, width, height } = await exportPng({
1736
- * asl,
1737
- * theme: 'dark',
1738
- * pngQuality: 95,
1739
- * backgroundColor: 'white'
1740
- * });
1741
- *
1742
- * writeFileSync('diagram.png', buffer);
1743
- * console.log(`Saved ${width}x${height} PNG`);
1744
- * ```
1745
- */
1746
- async function exportPng(params) {
1747
- const { aslDefinition, ...options } = params;
1748
- const svgOutput = generateSvg({
1749
- aslDefinition,
1750
- ...options
1751
- });
1752
- return new PngExporter(options).convert({
1753
- svg: svgOutput.svg,
1754
- width: svgOutput.width,
1755
- height: svgOutput.height
1756
- });
1757
- }
1758
- /**
1759
1619
  * Generate a diagram from an AWS SDK DescribeStateMachine response
1760
1620
  *
1761
1621
  * This is a convenience function for integrating with the AWS SDK. It extracts
@@ -1895,24 +1755,6 @@ var SfnDiagramGenerator = class {
1895
1755
  });
1896
1756
  }
1897
1757
  /**
1898
- * Export diagram as PNG
1899
- *
1900
- * @param params - Generation parameters
1901
- * @param params.asl - ASL definition as an object or JSON string
1902
- * @returns Promise resolving to PNG output
1903
- *
1904
- * @example
1905
- * ```typescript
1906
- * const { buffer } = await generator.exportPng({ asl: myStateMachine });
1907
- * ```
1908
- */
1909
- async exportPng(params) {
1910
- return exportPng({
1911
- ...params,
1912
- ...this.options
1913
- });
1914
- }
1915
- /**
1916
1758
  * Update the generator's default options (fluent interface)
1917
1759
  *
1918
1760
  * @param options - Partial options to merge with existing options
@@ -1935,17 +1777,14 @@ var SfnDiagramGenerator = class {
1935
1777
  return this;
1936
1778
  }
1937
1779
  };
1938
-
1939
1780
  //#endregion
1940
1781
  exports.AWS_DARK_THEME = AWS_DARK_THEME;
1941
1782
  exports.AWS_LIGHT_THEME = AWS_LIGHT_THEME;
1942
1783
  exports.AslValidationError = AslValidationError;
1943
- exports.PngExporter = PngExporter;
1944
1784
  exports.SfnDiagramGenerator = SfnDiagramGenerator;
1945
1785
  exports.embedIcons = embedIcons;
1946
- exports.exportPng = exportPng;
1947
1786
  exports.generateDiagram = generateDiagram;
1948
1787
  exports.generateFromAwsResponse = generateFromAwsResponse;
1949
1788
  exports.generateMermaid = generateMermaid;
1950
1789
  exports.generateSvg = generateSvg;
1951
- exports.validateAsl = validateAsl;
1790
+ exports.validateAsl = validateAsl;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- //#region node_modules/.pnpm/@smithy+types@4.9.0/node_modules/@smithy/types/dist-types/response.d.ts
1
+ //#region node_modules/.pnpm/@smithy+types@4.13.1/node_modules/@smithy/types/dist-types/response.d.ts
2
2
  /**
3
3
  * @public
4
4
  */
@@ -40,8 +40,7 @@ interface MetadataBearer {
40
40
  $metadata: ResponseMetadata;
41
41
  }
42
42
  //#endregion
43
- //#region node_modules/.pnpm/@smithy+types@4.9.0/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts
44
-
43
+ //#region node_modules/.pnpm/@smithy+types@4.13.1/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts
45
44
  declare global {
46
45
  /**
47
46
  * interface merging stub.
@@ -49,7 +48,7 @@ declare global {
49
48
  interface RequestInit {}
50
49
  }
51
50
  //#endregion
52
- //#region node_modules/.pnpm/@aws-sdk+types@3.936.0/node_modules/@aws-sdk/types/dist-types/serde.d.ts
51
+ //#region node_modules/.pnpm/@aws-sdk+types@3.973.6/node_modules/@aws-sdk/types/dist-types/serde.d.ts
53
52
  /**
54
53
  * @public
55
54
  *
@@ -72,7 +71,7 @@ declare global {
72
71
  export interface Blob {}
73
72
  }
74
73
  //#endregion
75
- //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/models/enums.d.ts
74
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.1024.0/node_modules/@aws-sdk/client-sfn/dist-types/models/enums.d.ts
76
75
  /**
77
76
  * @public
78
77
  * @enum
@@ -111,11 +110,6 @@ declare const StateMachineType: {
111
110
  * @public
112
111
  */
113
112
  type StateMachineType = (typeof StateMachineType)[keyof typeof StateMachineType];
114
- /**
115
- * @public
116
- * @enum
117
- */
118
-
119
113
  /**
120
114
  * @public
121
115
  * @enum
@@ -128,14 +122,8 @@ declare const StateMachineStatus: {
128
122
  * @public
129
123
  */
130
124
  type StateMachineStatus = (typeof StateMachineStatus)[keyof typeof StateMachineStatus];
131
- /**
132
- * @public
133
- * @enum
134
- */
135
-
136
125
  //#endregion
137
- //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/models/models_0.d.ts
138
-
126
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.1024.0/node_modules/@aws-sdk/client-sfn/dist-types/models/models_0.d.ts
139
127
  /**
140
128
  * <p>Settings to configure server-side encryption. </p>
141
129
  * <p>
@@ -165,17 +153,6 @@ interface EncryptionConfiguration {
165
153
  */
166
154
  type: EncryptionType | undefined;
167
155
  }
168
- /**
169
- * <p>Tags are key-value pairs that can be associated with Step Functions state machines and
170
- * activities.</p>
171
- * <p>An array of key-value pairs. For more information, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html">Using
172
- * Cost Allocation Tags</a> in the <i>Amazon Web Services Billing and Cost Management User
173
- * Guide</i>, and <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html">Controlling Access Using IAM
174
- * Tags</a>.</p>
175
- * <p>Tags may only contain Unicode letters, digits, white space, or these symbols: <code>_ . : / = + - @</code>.</p>
176
- * @public
177
- */
178
-
179
156
  /**
180
157
  * <p></p>
181
158
  * @public
@@ -237,10 +214,6 @@ interface TracingConfiguration {
237
214
  */
238
215
  enabled?: boolean | undefined;
239
216
  }
240
- /**
241
- * @public
242
- */
243
-
244
217
  /**
245
218
  * @public
246
219
  */
@@ -353,11 +326,8 @@ interface DescribeStateMachineOutput {
353
326
  */
354
327
  variableReferences?: Record<string, string[]> | undefined;
355
328
  }
356
- /**
357
- * @public
358
- */
359
329
  //#endregion
360
- //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/commands/DescribeStateMachineCommand.d.ts
330
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.1024.0/node_modules/@aws-sdk/client-sfn/dist-types/commands/DescribeStateMachineCommand.d.ts
361
331
  /**
362
332
  * @public
363
333
  *
@@ -581,9 +551,7 @@ interface SvgOutput {
581
551
  height: number;
582
552
  /** Metadata about the generated diagram */
583
553
  metadata: {
584
- /** Number of edges (transitions) in the diagram */
585
- edgeCount: number;
586
- /** Number of state nodes in the diagram */
554
+ /** Number of edges (transitions) in the diagram */edgeCount: number; /** Number of state nodes in the diagram */
587
555
  nodeCount: number;
588
556
  };
589
557
  /** Complete SVG markup as a string */
@@ -597,26 +565,10 @@ interface MermaidOutput {
597
565
  code: string;
598
566
  /** Metadata about the generated diagram */
599
567
  metadata: {
600
- /** Number of transitions in the diagram */
601
- edgeCount: number;
602
- /** Number of states in the diagram */
568
+ /** Number of transitions in the diagram */edgeCount: number; /** Number of states in the diagram */
603
569
  stateCount: number;
604
570
  };
605
571
  }
606
- /** PNG image output */
607
- interface PngOutput {
608
- /** PNG image data as a Buffer */
609
- buffer: Buffer;
610
- /** Height of the image in pixels */
611
- height: number;
612
- /** Metadata about the generated image */
613
- metadata: {
614
- /** Image format (always 'png') */
615
- format: 'png';
616
- };
617
- /** Width of the image in pixels */
618
- width: number;
619
- }
620
572
  interface GenerateSvgParams extends DiagramOptions {
621
573
  /** ASL definition as object or JSON string */
622
574
  aslDefinition: AslDefinition | string;
@@ -629,10 +581,6 @@ interface GenerateDiagramParams extends DiagramOptions {
629
581
  /** ASL definition as object or JSON string */
630
582
  aslDefinition: AslDefinition | string;
631
583
  }
632
- interface ExportPngParams extends DiagramOptions {
633
- /** ASL definition as object or JSON string */
634
- aslDefinition: AslDefinition | string;
635
- }
636
584
  interface GenerateFromAwsParams extends DiagramOptions {
637
585
  /** AWS SDK DescribeStateMachine command output */
638
586
  response: DescribeStateMachineCommandOutput;
@@ -647,9 +595,6 @@ declare const AWS_LIGHT_THEME: CustomTheme;
647
595
  * AWS Dark Theme - matches the AWS Step Functions console dark mode
648
596
  */
649
597
  declare const AWS_DARK_THEME: CustomTheme;
650
- /**
651
- * Get theme object from theme name or custom theme
652
- */
653
598
  //#endregion
654
599
  //#region src/utils/iconEmbedder.d.ts
655
600
  interface EmbedIconsParams {
@@ -682,36 +627,6 @@ interface EmbedIconsParams {
682
627
  */
683
628
  declare function embedIcons(params: EmbedIconsParams): Promise<string>;
684
629
  //#endregion
685
- //#region src/exporters/PngExporter.d.ts
686
- /** Parameters for converting SVG to PNG */
687
- interface ConvertParams {
688
- /** Height of the SVG in pixels */
689
- height: number;
690
- /** SVG markup string */
691
- svg: string;
692
- /** Width of the SVG in pixels */
693
- width: number;
694
- }
695
- /**
696
- * PngExporter - Converts SVG to PNG using headless rendering
697
- */
698
- declare class PngExporter {
699
- private options;
700
- constructor(options: DiagramOptions);
701
- /**
702
- * Convert SVG string to PNG buffer
703
- *
704
- * Note: External images (like AWS service icons from CDN) may not render in PNG export
705
- * due to limitations with headless browser rendering. Use SVG output for best results
706
- * when showIcons is enabled.
707
- */
708
- convert(params: ConvertParams): Promise<PngOutput>;
709
- /**
710
- * Wrap SVG in HTML for rendering
711
- */
712
- private wrapSvgInHtml;
713
- }
714
- //#endregion
715
630
  //#region src/AslParser.d.ts
716
631
  /**
717
632
  * Error thrown when ASL validation fails
@@ -719,10 +634,6 @@ declare class PngExporter {
719
634
  declare class AslValidationError extends Error {
720
635
  constructor(message: string);
721
636
  }
722
- /**
723
- * Result of parsing an ASL definition into a graph structure
724
- */
725
-
726
637
  interface ValidateAslParams {
727
638
  /** The ASL definition to validate */
728
639
  definition: unknown;
@@ -734,10 +645,6 @@ interface ValidateAslParams {
734
645
  * @throws {AslValidationError} When the ASL definition is invalid
735
646
  */
736
647
  declare function validateAsl(params: ValidateAslParams): void;
737
- /**
738
- * Parameters for parsing an ASL definition into a graph
739
- */
740
-
741
648
  //#endregion
742
649
  //#region src/index.d.ts
743
650
  /**
@@ -880,45 +787,6 @@ declare function generateMermaid(params: GenerateMermaidParams): MermaidOutput;
880
787
  * ```
881
788
  */
882
789
  declare function generateDiagram(params: GenerateDiagramParams): SvgOutput | MermaidOutput;
883
- /**
884
- * Export a diagram as PNG (asynchronous)
885
- *
886
- * This function generates an SVG diagram and converts it to PNG format using
887
- * headless browser rendering. The output is a Buffer that can be written to a file.
888
- *
889
- * **Note:** This function is asynchronous and uses Puppeteer for rendering,
890
- * which may take a moment on first run to download the browser binary.
891
- *
892
- * @param params - Configuration object
893
- * @param params.aslDefinition - ASL definition as an object or JSON string
894
- * @param params.pngQuality - PNG quality from 1-100 (default: 90)
895
- * @param params.backgroundColor - Background color as CSS color or 'transparent' (default: 'transparent')
896
- * @param ...params - Other SVG options (see generateSvg)
897
- *
898
- * @returns Promise resolving to PNG output with buffer and dimensions
899
- *
900
- * @throws {SyntaxError} If params.asl is a string with invalid JSON
901
- * @throws {Error} If the ASL definition structure is invalid or PNG conversion fails
902
- *
903
- * @example
904
- * ```typescript
905
- * import { exportPng } from 'sfn-diagram';
906
- * import { writeFileSync } from 'fs';
907
- *
908
- * const asl = { StartAt: 'Hello', States: { Hello: { Type: 'Pass', End: true } } };
909
- *
910
- * const { buffer, width, height } = await exportPng({
911
- * asl,
912
- * theme: 'dark',
913
- * pngQuality: 95,
914
- * backgroundColor: 'white'
915
- * });
916
- *
917
- * writeFileSync('diagram.png', buffer);
918
- * console.log(`Saved ${width}x${height} PNG`);
919
- * ```
920
- */
921
- declare function exportPng(params: ExportPngParams): Promise<PngOutput>;
922
790
  /**
923
791
  * Generate a diagram from an AWS SDK DescribeStateMachine response
924
792
  *
@@ -1040,21 +908,6 @@ declare class SfnDiagramGenerator {
1040
908
  generateMermaid(params: {
1041
909
  aslDefinition: AslDefinition | string;
1042
910
  }): MermaidOutput;
1043
- /**
1044
- * Export diagram as PNG
1045
- *
1046
- * @param params - Generation parameters
1047
- * @param params.asl - ASL definition as an object or JSON string
1048
- * @returns Promise resolving to PNG output
1049
- *
1050
- * @example
1051
- * ```typescript
1052
- * const { buffer } = await generator.exportPng({ asl: myStateMachine });
1053
- * ```
1054
- */
1055
- exportPng(params: {
1056
- aslDefinition: AslDefinition | string;
1057
- }): Promise<PngOutput>;
1058
911
  /**
1059
912
  * Update the generator's default options (fluent interface)
1060
913
  *
@@ -1073,4 +926,4 @@ declare class SfnDiagramGenerator {
1073
926
  setOptions(options: Partial<DiagramOptions>): this;
1074
927
  }
1075
928
  //#endregion
1076
- export { AWS_DARK_THEME, AWS_LIGHT_THEME, type AslDefinition, type AslState, AslValidationError, type CustomTheme, type DiagramFormat, type DiagramOptions, type EdgePathStyle, type EdgeType, type ExportPngParams, type GenerateDiagramParams, type GenerateFromAwsParams, type GenerateMermaidParams, type GenerateSvgParams, type GraphEdge, type LayoutDirection, type MermaidOutput, type NodeShape, type NodeStyle, PngExporter, type PngOutput, SfnDiagramGenerator, type StateNode, type StateType, type SvgOutput, type ThemeOption, embedIcons, exportPng, generateDiagram, generateFromAwsResponse, generateMermaid, generateSvg, validateAsl };
929
+ export { AWS_DARK_THEME, AWS_LIGHT_THEME, type AslDefinition, type AslState, AslValidationError, type CustomTheme, type DiagramFormat, type DiagramOptions, type EdgePathStyle, type EdgeType, type GenerateDiagramParams, type GenerateFromAwsParams, type GenerateMermaidParams, type GenerateSvgParams, type GraphEdge, type LayoutDirection, type MermaidOutput, type NodeShape, type NodeStyle, SfnDiagramGenerator, type StateNode, type StateType, type SvgOutput, type ThemeOption, embedIcons, generateDiagram, generateFromAwsResponse, generateMermaid, generateSvg, validateAsl };