@rotorsoft/act-diagram 0.2.0 → 0.2.2
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/@types/client/lib/layout.d.ts.map +1 -1
- package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
- package/dist/index.cjs +49 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -25
- 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";
|
|
@@ -372,13 +372,14 @@ function captureDispatches(handler) {
|
|
|
372
372
|
const dispatches = [];
|
|
373
373
|
if (typeof handler !== "function") return dispatches;
|
|
374
374
|
try {
|
|
375
|
+
const safeProxy = () => new Proxy({}, { get: () => "" });
|
|
375
376
|
const mockApp = {
|
|
376
377
|
do: (actionName) => {
|
|
377
378
|
if (typeof actionName === "string" && !dispatches.includes(actionName))
|
|
378
379
|
dispatches.push(actionName);
|
|
379
380
|
return Promise.resolve([]);
|
|
380
381
|
},
|
|
381
|
-
load: () => Promise.resolve({}),
|
|
382
|
+
load: () => Promise.resolve({ state: safeProxy(), version: 0 }),
|
|
382
383
|
query: () => Promise.resolve({ count: 0 }),
|
|
383
384
|
query_array: () => Promise.resolve([])
|
|
384
385
|
};
|
|
@@ -1400,7 +1401,6 @@ function computeLayout(viewModel) {
|
|
|
1400
1401
|
const actionEmitted = /* @__PURE__ */ new Set();
|
|
1401
1402
|
for (const action of st.actions) {
|
|
1402
1403
|
for (const en of action.emits) {
|
|
1403
|
-
eventRows.push({ eventName: en, actionName: action.name });
|
|
1404
1404
|
actionEmitted.add(en);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
@@ -1409,6 +1409,11 @@ function computeLayout(viewModel) {
|
|
|
1409
1409
|
eventRows.push({ eventName: ev.name, actionName: "" });
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
|
+
for (const action of st.actions) {
|
|
1413
|
+
for (const en of action.emits) {
|
|
1414
|
+
eventRows.push({ eventName: en, actionName: action.name });
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1412
1417
|
const measuredEvents = [];
|
|
1413
1418
|
let evtBlockH = 0;
|
|
1414
1419
|
for (const { eventName: en, actionName } of eventRows) {
|
|
@@ -1544,7 +1549,12 @@ function computeLayout(viewModel) {
|
|
|
1544
1549
|
actY += H + GAP / 2;
|
|
1545
1550
|
actionIdx++;
|
|
1546
1551
|
}
|
|
1547
|
-
|
|
1552
|
+
const contentBottomY = Math.max(
|
|
1553
|
+
y + primaryBlockH,
|
|
1554
|
+
evtY,
|
|
1555
|
+
chainWatermark > -Infinity ? chainWatermark : 0
|
|
1556
|
+
);
|
|
1557
|
+
y = contentBottomY + GAP / 2;
|
|
1548
1558
|
partIdx++;
|
|
1549
1559
|
}
|
|
1550
1560
|
for (const r of slice.reactions) {
|
|
@@ -2521,6 +2531,39 @@ ${prompt}`);
|
|
|
2521
2531
|
|
|
2522
2532
|
// src/client/components/ActDiagram.tsx
|
|
2523
2533
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2534
|
+
var emptyModel = {
|
|
2535
|
+
entries: [],
|
|
2536
|
+
states: [],
|
|
2537
|
+
slices: [],
|
|
2538
|
+
projections: [],
|
|
2539
|
+
reactions: []
|
|
2540
|
+
};
|
|
2541
|
+
function useExtractModel(files) {
|
|
2542
|
+
const [result, setResult] = useState3({ model: emptyModel, warnings: [] });
|
|
2543
|
+
const lastGoodRef = useRef2(null);
|
|
2544
|
+
useEffect2(() => {
|
|
2545
|
+
if (files.length === 0) {
|
|
2546
|
+
lastGoodRef.current = null;
|
|
2547
|
+
setResult({ model: emptyModel, warnings: [] });
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
const timer = setTimeout(() => {
|
|
2551
|
+
const { model, error } = extractModel(files);
|
|
2552
|
+
const warnings = validate(model);
|
|
2553
|
+
const hasErrors = !!error || model.slices.some((s) => !!s.error);
|
|
2554
|
+
if (!hasErrors) {
|
|
2555
|
+
const next = { model, warnings };
|
|
2556
|
+
lastGoodRef.current = next;
|
|
2557
|
+
setResult(next);
|
|
2558
|
+
} else if (lastGoodRef.current) {
|
|
2559
|
+
} else {
|
|
2560
|
+
setResult({ model, warnings });
|
|
2561
|
+
}
|
|
2562
|
+
}, 500);
|
|
2563
|
+
return () => clearTimeout(timer);
|
|
2564
|
+
}, [files]);
|
|
2565
|
+
return result;
|
|
2566
|
+
}
|
|
2524
2567
|
function ActDiagram({
|
|
2525
2568
|
files: propFiles,
|
|
2526
2569
|
onNavigate,
|
|
@@ -2562,22 +2605,7 @@ function ActDiagram({
|
|
|
2562
2605
|
window.addEventListener("message", handler);
|
|
2563
2606
|
return () => window.removeEventListener("message", handler);
|
|
2564
2607
|
}, [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]);
|
|
2608
|
+
const { model, warnings } = useExtractModel(files);
|
|
2581
2609
|
const handleClick = useCallback2(
|
|
2582
2610
|
(name, type, file) => {
|
|
2583
2611
|
if (!onNavigate) return;
|
|
@@ -2697,7 +2725,7 @@ function Logo({ size = 24 }) {
|
|
|
2697
2725
|
}
|
|
2698
2726
|
|
|
2699
2727
|
// src/client/components/Tooltip.tsx
|
|
2700
|
-
import { useCallback as useCallback3, useRef as
|
|
2728
|
+
import { useCallback as useCallback3, useRef as useRef3, useState as useState4 } from "react";
|
|
2701
2729
|
import { createPortal } from "react-dom";
|
|
2702
2730
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2703
2731
|
function Tooltip({
|
|
@@ -2710,8 +2738,8 @@ function Tooltip({
|
|
|
2710
2738
|
}) {
|
|
2711
2739
|
const [show, setShow] = useState4(false);
|
|
2712
2740
|
const [coords, setCoords] = useState4({ x: 0, y: 0, w: 0 });
|
|
2713
|
-
const timeout =
|
|
2714
|
-
const ref =
|
|
2741
|
+
const timeout = useRef3(void 0);
|
|
2742
|
+
const ref = useRef3(null);
|
|
2715
2743
|
const onEnter = useCallback3(() => {
|
|
2716
2744
|
timeout.current = setTimeout(() => {
|
|
2717
2745
|
if (ref.current) {
|
|
@@ -2820,7 +2848,7 @@ function deriveProjectName(prompt, code) {
|
|
|
2820
2848
|
}
|
|
2821
2849
|
|
|
2822
2850
|
// src/client/types/domain-model.ts
|
|
2823
|
-
function
|
|
2851
|
+
function emptyModel2() {
|
|
2824
2852
|
return {
|
|
2825
2853
|
entries: [],
|
|
2826
2854
|
states: [],
|
|
@@ -2839,7 +2867,7 @@ export {
|
|
|
2839
2867
|
buildModel,
|
|
2840
2868
|
computeLayout,
|
|
2841
2869
|
deriveProjectName,
|
|
2842
|
-
emptyModel,
|
|
2870
|
+
emptyModel2 as emptyModel,
|
|
2843
2871
|
extractModel,
|
|
2844
2872
|
navigateToCode,
|
|
2845
2873
|
parseMultiFileResponse,
|