sfn-diagram-react 0.5.0 → 0.7.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/README.md CHANGED
@@ -15,7 +15,7 @@ npm install sfn-diagram-react sfn-diagram
15
15
  pnpm add sfn-diagram-react sfn-diagram
16
16
  ```
17
17
 
18
- `react` and `sfn-diagram` are peer dependencies. `sfn-diagram >= 1.6.0` is required — earlier versions don't have the options this package forwards (`collapse`, `catchHandling`, `showVariables`, `generateHtml`, and `edgeOverrides`' qualified-id form).
18
+ `react` and `sfn-diagram` are peer dependencies. `sfn-diagram >= 1.7.0` is required — earlier versions don't have the options this package forwards (`collapse`, `catchHandling`, `showVariables`, `generateHtml`, `edgeOverrides`' qualified-id form, and `layout`/`theme` on the Mermaid path).
19
19
 
20
20
  ## Usage
21
21
 
@@ -62,12 +62,12 @@ JSON string of either. In the browser, pass the JSON string.
62
62
  overlaying an execution onto a diff. Combining them calls `onError` and renders `null`,
63
63
  the same way any other invalid input is handled.
64
64
 
65
- **`format="mermaid"` combined with `history` ignores every other diagram option** —
66
- `catchHandling`, `collapse`, `edgeStyle`, `showVariables`, and the rest. Core's
67
- Mermaid execution-overlay function (`generateMermaidExecution`) accepts only the ASL
68
- definition, `history`, `layout`, and `theme`; unlike the plain Mermaid path
69
- (`generateMermaid`), which honours the full option set. The SVG execution overlay is
70
- unaffected — it honours every option.
65
+ **`format="mermaid"` combined with `history` honours the same options as plain
66
+ `format="mermaid"`** — `catchHandling`, `collapse`, `showVariables`, `layout` and
67
+ `theme` — with sfn-diagram 1.10 or later. Earlier versions of core's Mermaid
68
+ execution-overlay function (`generateMermaidExecution`) accept only the ASL definition,
69
+ `history`, `layout`, and `theme`, and ignore the rest. The SVG execution overlay
70
+ honours every option.
71
71
 
72
72
  ### Interactive viewer (`format="html"`)
73
73
 
@@ -83,8 +83,9 @@ Consequences worth knowing:
83
83
  wrapper with a fixed aspect ratio).
84
84
  - `onStateClick` does not fire from inside it — clicks inside a sandboxed iframe never
85
85
  reach the parent document's event handlers.
86
- - `history` cannot be combined with `format="html"` — core's `generateHtml` accepts
87
- neither `history` nor a diff. Combining them calls `onError` and renders `null`.
86
+ - `history` cannot be combined with `format="html"` yet — core's `generateHtml` accepts
87
+ `history` and `diff` overlays since sfn-diagram 1.8, but this hook does not wire them
88
+ up. Combining them calls `onError` and renders `null`.
88
89
 
89
90
  ```tsx
90
91
  <SfnDiagram definition={definition} format="html" style={{ height: 600, width: '100%' }} />
@@ -108,9 +109,9 @@ coloured (green / yellow / red) instead of the machine's normal styling.
108
109
  for either combination. Combining them calls `onError` and renders `null`.
109
110
  - The **SVG diff** (`generateDiff`) honours every diagram option this package forwards
110
111
  (`collapse`, `catchHandling`, `showIcons`, and the rest).
111
- - The **Mermaid diff** (`generateMermaidDiff`) accepts only the two definitions — every
112
- other prop (`layout`, `theme`, `collapse`, …) is silently ignored in `format="mermaid"`
113
- diff mode.
112
+ - The **Mermaid diff** ignores every prop except the two definitions (`layout`, `theme`,
113
+ `collapse`, …) in `format="mermaid"` diff mode: this package doesn't forward them to
114
+ `generateMermaidDiff` yet (#393), although core accepts them since sfn-diagram 1.10.
114
115
 
115
116
  ### `onStateClick`
116
117
 
@@ -198,8 +199,8 @@ ones (`className`, `onError`, `onStateClick`, `style`, `title`). Errors are retu
198
199
  | `theme` | `'light' \| 'dark' \| CustomTheme` | `'light'` | svg, mermaid | Diagram theme. |
199
200
  | `title` | `string` | `'Step Functions diagram'` | html only | Accessible title for the rendered iframe. |
200
201
 
201
- ¹ Ignored when `format="mermaid"` is combined with `history` — see
202
- [Execution overlay](#execution-overlay). Applies normally to plain `format="mermaid"`
202
+ ¹ Ignored when `format="mermaid"` is combined with `history` on sfn-diagram before 1.10 —
203
+ see [Execution overlay](#execution-overlay). Applies normally to plain `format="mermaid"`
203
204
  (no `history`). `format="mermaid"` diff mode (the `before` prop) is a separate
204
205
  carve-out with its own rule — see [Diff mode](#diff-mode).
205
206
 
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  let react = require("react");
4
4
  let sfn_diagram = require("sfn-diagram");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
- //#region src/useSfnDiagram.ts
6
+ // src/useSfnDiagram.ts
7
7
  function toAslString(params) {
8
8
  const { definition } = params;
9
9
  return typeof definition === "string" ? definition : JSON.stringify(definition);
@@ -153,8 +153,7 @@ function useSfnDiagram(params) {
153
153
  theme
154
154
  ]);
155
155
  }
156
- //#endregion
157
- //#region src/SfnDiagram.tsx
156
+ // src/SfnDiagram.tsx
158
157
  const SfnDiagram = (0, react.forwardRef)(function SfnDiagram({ className, onError, onStateClick, style, title = "Step Functions diagram", ...diagramParams }, ref) {
159
158
  const result = useSfnDiagram(diagramParams);
160
159
  (0, react.useImperativeHandle)(ref, () => ({ getSvg: () => result.type === "svg" ? result.svg : null }), [result]);
@@ -183,7 +182,7 @@ const SfnDiagram = (0, react.forwardRef)(function SfnDiagram({ className, onErro
183
182
  });
184
183
  if (result.type === "html") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
185
184
  className,
186
- sandbox: "allow-scripts",
185
+ sandbox: "allow-downloads allow-scripts",
187
186
  srcDoc: result.html,
188
187
  style,
189
188
  title
@@ -195,6 +194,5 @@ const SfnDiagram = (0, react.forwardRef)(function SfnDiagram({ className, onErro
195
194
  style
196
195
  });
197
196
  });
198
- //#endregion
199
197
  exports.SfnDiagram = SfnDiagram;
200
198
  exports.useSfnDiagram = useSfnDiagram;
package/dist/index.d.cts CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
2
  import { DiagramOptions, DiffOutput, ExecutionHistoryInput, ExecutionOutput, HtmlOutput, MermaidDiffOutput, MermaidExecutionOutput, MermaidOutput, SvgOutput } from "sfn-diagram";
3
- //#region src/useSfnDiagram.d.ts
4
3
  interface UseSfnDiagramParams extends Pick<DiagramOptions, 'catchHandling' | 'collapse' | 'edgeOverrides' | 'edgeStyle' | 'iconPosition' | 'iconSize' | 'layout' | 'nodeOverrides' | 'showIcons' | 'showVariables' | 'theme'> {
5
4
  /**
6
5
  * When set, `definition` is treated as the *after* side of a diff and `before`
7
6
  * as the *original* side: the rendered diagram highlights added, modified, and
8
7
  * removed states rather than the plain machine. Accepts an ASL object or a
9
- * JSON string. Cannot be combined with `history` or `format="html"` - core has
10
- * no diff API for either combination.
8
+ * JSON string. Cannot be combined with `history` (core's SVG and Mermaid diff
9
+ * functions take no history) or with `format="html"` (core's `generateHtml`
10
+ * accepts a diff since sfn-diagram 1.8, but this hook does not wire it up yet).
11
11
  *
12
- * The Mermaid diff (`generateMermaidDiff`) ignores every option in this
13
- * type's `Pick<DiagramOptions, ...>` list - `layout`, `theme`, and the rest -
14
- * since core's diff-specific function accepts only the two definitions. The
15
- * SVG diff honours them.
12
+ * The Mermaid diff ignores every option in this type's `Pick<DiagramOptions, ...>`
13
+ * list - `layout`, `theme`, and the rest: this hook doesn't forward them to
14
+ * `generateMermaidDiff` yet (#393), although core accepts them since sfn-diagram
15
+ * 1.10. The SVG diff honours them.
16
16
  */
17
17
  before?: object | string;
18
18
  definition: object | string;
@@ -80,8 +80,6 @@ type SfnDiagramResult = {
80
80
  * ```
81
81
  */
82
82
  export declare function useSfnDiagram(params: UseSfnDiagramParams): SfnDiagramResult;
83
- //#endregion
84
- //#region src/SfnDiagram.d.ts
85
83
  interface SfnDiagramProps extends UseSfnDiagramParams {
86
84
  className?: string;
87
85
  onError?: (error: Error) => void;
@@ -120,5 +118,4 @@ interface SfnDiagramHandle {
120
118
  getSvg(): string | null;
121
119
  }
122
120
  export declare const SfnDiagram: import("react").ForwardRefExoticComponent<SfnDiagramProps & import("react").RefAttributes<SfnDiagramHandle>>;
123
- //#endregion
124
121
  export type { OnStateClickParams, SfnDiagramHandle, SfnDiagramProps, SfnDiagramResult, UseSfnDiagramParams };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
2
  import { DiagramOptions, DiffOutput, ExecutionHistoryInput, ExecutionOutput, HtmlOutput, MermaidDiffOutput, MermaidExecutionOutput, MermaidOutput, SvgOutput } from "sfn-diagram";
3
- //#region src/useSfnDiagram.d.ts
4
3
  interface UseSfnDiagramParams extends Pick<DiagramOptions, 'catchHandling' | 'collapse' | 'edgeOverrides' | 'edgeStyle' | 'iconPosition' | 'iconSize' | 'layout' | 'nodeOverrides' | 'showIcons' | 'showVariables' | 'theme'> {
5
4
  /**
6
5
  * When set, `definition` is treated as the *after* side of a diff and `before`
7
6
  * as the *original* side: the rendered diagram highlights added, modified, and
8
7
  * removed states rather than the plain machine. Accepts an ASL object or a
9
- * JSON string. Cannot be combined with `history` or `format="html"` - core has
10
- * no diff API for either combination.
8
+ * JSON string. Cannot be combined with `history` (core's SVG and Mermaid diff
9
+ * functions take no history) or with `format="html"` (core's `generateHtml`
10
+ * accepts a diff since sfn-diagram 1.8, but this hook does not wire it up yet).
11
11
  *
12
- * The Mermaid diff (`generateMermaidDiff`) ignores every option in this
13
- * type's `Pick<DiagramOptions, ...>` list - `layout`, `theme`, and the rest -
14
- * since core's diff-specific function accepts only the two definitions. The
15
- * SVG diff honours them.
12
+ * The Mermaid diff ignores every option in this type's `Pick<DiagramOptions, ...>`
13
+ * list - `layout`, `theme`, and the rest: this hook doesn't forward them to
14
+ * `generateMermaidDiff` yet (#393), although core accepts them since sfn-diagram
15
+ * 1.10. The SVG diff honours them.
16
16
  */
17
17
  before?: object | string;
18
18
  definition: object | string;
@@ -80,8 +80,6 @@ type SfnDiagramResult = {
80
80
  * ```
81
81
  */
82
82
  export declare function useSfnDiagram(params: UseSfnDiagramParams): SfnDiagramResult;
83
- //#endregion
84
- //#region src/SfnDiagram.d.ts
85
83
  interface SfnDiagramProps extends UseSfnDiagramParams {
86
84
  className?: string;
87
85
  onError?: (error: Error) => void;
@@ -120,5 +118,4 @@ interface SfnDiagramHandle {
120
118
  getSvg(): string | null;
121
119
  }
122
120
  export declare const SfnDiagram: import("react").ForwardRefExoticComponent<SfnDiagramProps & import("react").RefAttributes<SfnDiagramHandle>>;
123
- //#endregion
124
121
  export type { OnStateClickParams, SfnDiagramHandle, SfnDiagramProps, SfnDiagramResult, UseSfnDiagramParams };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
3
3
  import { generateDiff, generateExecution, generateHtml, generateMermaid, generateMermaidDiff, generateMermaidExecution, generateSvg } from "sfn-diagram";
4
4
  import { jsx } from "react/jsx-runtime";
5
- //#region src/useSfnDiagram.ts
5
+ // src/useSfnDiagram.ts
6
6
  function toAslString(params) {
7
7
  const { definition } = params;
8
8
  return typeof definition === "string" ? definition : JSON.stringify(definition);
@@ -152,8 +152,7 @@ function useSfnDiagram(params) {
152
152
  theme
153
153
  ]);
154
154
  }
155
- //#endregion
156
- //#region src/SfnDiagram.tsx
155
+ // src/SfnDiagram.tsx
157
156
  const SfnDiagram = forwardRef(function SfnDiagram({ className, onError, onStateClick, style, title = "Step Functions diagram", ...diagramParams }, ref) {
158
157
  const result = useSfnDiagram(diagramParams);
159
158
  useImperativeHandle(ref, () => ({ getSvg: () => result.type === "svg" ? result.svg : null }), [result]);
@@ -182,7 +181,7 @@ const SfnDiagram = forwardRef(function SfnDiagram({ className, onError, onStateC
182
181
  });
183
182
  if (result.type === "html") return /* @__PURE__ */ jsx("iframe", {
184
183
  className,
185
- sandbox: "allow-scripts",
184
+ sandbox: "allow-downloads allow-scripts",
186
185
  srcDoc: result.html,
187
186
  style,
188
187
  title
@@ -194,5 +193,4 @@ const SfnDiagram = forwardRef(function SfnDiagram({ className, onError, onStateC
194
193
  style
195
194
  });
196
195
  });
197
- //#endregion
198
196
  export { SfnDiagram, useSfnDiagram };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfn-diagram-react",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "React component for AWS Step Functions ASL diagrams",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -64,22 +64,22 @@
64
64
  "homepage": "https://sfn.yusufaf.dev/ecosystem/react/",
65
65
  "peerDependencies": {
66
66
  "react": "^18.0.0 || ^19.0.0",
67
- "sfn-diagram": "^1.6.0"
67
+ "sfn-diagram": "^1.7.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@arethetypeswrong/cli": "^0.18.5",
71
71
  "@testing-library/jest-dom": "^7.0.1",
72
72
  "@testing-library/react": "^16.0.0",
73
- "@types/react": "^18.3.0",
74
- "@types/react-dom": "^18.3.0",
73
+ "@types/react": "^19.3.0",
74
+ "@types/react-dom": "^19.3.0",
75
75
  "jsdom": "^26.0.0",
76
- "publint": "^0.3.16",
77
- "react": "^18.3.0",
78
- "react-dom": "^18.3.0",
76
+ "publint": "^0.3.25",
77
+ "react": "^19.3.1",
78
+ "react-dom": "^19.3.1",
79
79
  "sfn-diagram": "workspace:*",
80
- "tsdown": "^0.23.0",
81
- "typescript": "^5.9.2",
82
- "vite": "^8.3.0",
83
- "vitest": "^4.1.11"
80
+ "tsdown": "^0.23.1",
81
+ "typescript": "^6.0.3",
82
+ "vite": "^8.3.5",
83
+ "vitest": "^4.1.12"
84
84
  }
85
85
  }