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 +15 -14
- package/dist/index.cjs +3 -5
- package/dist/index.d.cts +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +3 -5
- package/package.json +11 -11
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.
|
|
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`
|
|
66
|
-
`catchHandling`, `collapse`, `
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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**
|
|
112
|
-
|
|
113
|
-
|
|
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` —
|
|
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
|
-
|
|
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
|
-
|
|
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`
|
|
10
|
-
* no
|
|
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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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`
|
|
10
|
-
* no
|
|
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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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": "^
|
|
74
|
-
"@types/react-dom": "^
|
|
73
|
+
"@types/react": "^19.3.0",
|
|
74
|
+
"@types/react-dom": "^19.3.0",
|
|
75
75
|
"jsdom": "^26.0.0",
|
|
76
|
-
"publint": "^0.3.
|
|
77
|
-
"react": "^
|
|
78
|
-
"react-dom": "^
|
|
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.
|
|
81
|
-
"typescript": "^
|
|
82
|
-
"vite": "^8.3.
|
|
83
|
-
"vitest": "^4.1.
|
|
80
|
+
"tsdown": "^0.23.1",
|
|
81
|
+
"typescript": "^6.0.3",
|
|
82
|
+
"vite": "^8.3.5",
|
|
83
|
+
"vitest": "^4.1.12"
|
|
84
84
|
}
|
|
85
85
|
}
|