@rotorsoft/act-diagram 0.2.0 → 0.2.1
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/dist/.tsbuildinfo +1 -1
- package/dist/@types/client/components/ActDiagram.d.ts.map +1 -1
- package/dist/index.cjs +36 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/client/components/ActDiagram.tsx
|
|
2
|
-
import { useCallback as useCallback2, useEffect as useEffect2,
|
|
2
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/client/lib/evaluate.ts
|
|
5
5
|
import { transform } from "sucrase";
|
|
@@ -2521,6 +2521,39 @@ ${prompt}`);
|
|
|
2521
2521
|
|
|
2522
2522
|
// src/client/components/ActDiagram.tsx
|
|
2523
2523
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2524
|
+
var emptyModel = {
|
|
2525
|
+
entries: [],
|
|
2526
|
+
states: [],
|
|
2527
|
+
slices: [],
|
|
2528
|
+
projections: [],
|
|
2529
|
+
reactions: []
|
|
2530
|
+
};
|
|
2531
|
+
function useExtractModel(files) {
|
|
2532
|
+
const [result, setResult] = useState3({ model: emptyModel, warnings: [] });
|
|
2533
|
+
const lastGoodRef = useRef2(null);
|
|
2534
|
+
useEffect2(() => {
|
|
2535
|
+
if (files.length === 0) {
|
|
2536
|
+
lastGoodRef.current = null;
|
|
2537
|
+
setResult({ model: emptyModel, warnings: [] });
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
const timer = setTimeout(() => {
|
|
2541
|
+
const { model, error } = extractModel(files);
|
|
2542
|
+
const warnings = validate(model);
|
|
2543
|
+
const hasErrors = !!error || model.slices.some((s) => !!s.error);
|
|
2544
|
+
if (!hasErrors) {
|
|
2545
|
+
const next = { model, warnings };
|
|
2546
|
+
lastGoodRef.current = next;
|
|
2547
|
+
setResult(next);
|
|
2548
|
+
} else if (lastGoodRef.current) {
|
|
2549
|
+
} else {
|
|
2550
|
+
setResult({ model, warnings });
|
|
2551
|
+
}
|
|
2552
|
+
}, 500);
|
|
2553
|
+
return () => clearTimeout(timer);
|
|
2554
|
+
}, [files]);
|
|
2555
|
+
return result;
|
|
2556
|
+
}
|
|
2524
2557
|
function ActDiagram({
|
|
2525
2558
|
files: propFiles,
|
|
2526
2559
|
onNavigate,
|
|
@@ -2562,22 +2595,7 @@ function ActDiagram({
|
|
|
2562
2595
|
window.addEventListener("message", handler);
|
|
2563
2596
|
return () => window.removeEventListener("message", handler);
|
|
2564
2597
|
}, [usePostMessage]);
|
|
2565
|
-
const { model, warnings } =
|
|
2566
|
-
if (files.length === 0)
|
|
2567
|
-
return {
|
|
2568
|
-
model: {
|
|
2569
|
-
entries: [],
|
|
2570
|
-
states: [],
|
|
2571
|
-
slices: [],
|
|
2572
|
-
projections: [],
|
|
2573
|
-
reactions: []
|
|
2574
|
-
},
|
|
2575
|
-
warnings: []
|
|
2576
|
-
};
|
|
2577
|
-
const { model: model2 } = extractModel(files);
|
|
2578
|
-
const warnings2 = validate(model2);
|
|
2579
|
-
return { model: model2, warnings: warnings2 };
|
|
2580
|
-
}, [files]);
|
|
2598
|
+
const { model, warnings } = useExtractModel(files);
|
|
2581
2599
|
const handleClick = useCallback2(
|
|
2582
2600
|
(name, type, file) => {
|
|
2583
2601
|
if (!onNavigate) return;
|
|
@@ -2697,7 +2715,7 @@ function Logo({ size = 24 }) {
|
|
|
2697
2715
|
}
|
|
2698
2716
|
|
|
2699
2717
|
// src/client/components/Tooltip.tsx
|
|
2700
|
-
import { useCallback as useCallback3, useRef as
|
|
2718
|
+
import { useCallback as useCallback3, useRef as useRef3, useState as useState4 } from "react";
|
|
2701
2719
|
import { createPortal } from "react-dom";
|
|
2702
2720
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2703
2721
|
function Tooltip({
|
|
@@ -2710,8 +2728,8 @@ function Tooltip({
|
|
|
2710
2728
|
}) {
|
|
2711
2729
|
const [show, setShow] = useState4(false);
|
|
2712
2730
|
const [coords, setCoords] = useState4({ x: 0, y: 0, w: 0 });
|
|
2713
|
-
const timeout =
|
|
2714
|
-
const ref =
|
|
2731
|
+
const timeout = useRef3(void 0);
|
|
2732
|
+
const ref = useRef3(null);
|
|
2715
2733
|
const onEnter = useCallback3(() => {
|
|
2716
2734
|
timeout.current = setTimeout(() => {
|
|
2717
2735
|
if (ref.current) {
|
|
@@ -2820,7 +2838,7 @@ function deriveProjectName(prompt, code) {
|
|
|
2820
2838
|
}
|
|
2821
2839
|
|
|
2822
2840
|
// src/client/types/domain-model.ts
|
|
2823
|
-
function
|
|
2841
|
+
function emptyModel2() {
|
|
2824
2842
|
return {
|
|
2825
2843
|
entries: [],
|
|
2826
2844
|
states: [],
|
|
@@ -2839,7 +2857,7 @@ export {
|
|
|
2839
2857
|
buildModel,
|
|
2840
2858
|
computeLayout,
|
|
2841
2859
|
deriveProjectName,
|
|
2842
|
-
emptyModel,
|
|
2860
|
+
emptyModel2 as emptyModel,
|
|
2843
2861
|
extractModel,
|
|
2844
2862
|
navigateToCode,
|
|
2845
2863
|
parseMultiFileResponse,
|