@rotorsoft/act-diagram 1.4.2 → 2.0.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 +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/cli/format.d.ts +2 -0
- package/dist/@types/cli/format.d.ts.map +1 -1
- package/dist/@types/cli/json-schema.d.ts.map +1 -1
- package/dist/@types/cli/markdown.d.ts +0 -9
- package/dist/@types/cli/markdown.d.ts.map +1 -1
- package/dist/@types/client/components/Diagram.d.ts.map +1 -1
- package/dist/@types/client/lib/build-model.d.ts.map +1 -1
- package/dist/@types/client/lib/layout.d.ts +20 -1
- package/dist/@types/client/lib/layout.d.ts.map +1 -1
- package/dist/@types/client/lib/loads.d.ts +17 -0
- package/dist/@types/client/lib/loads.d.ts.map +1 -0
- package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
- package/dist/@types/client/types/domain-model.d.ts +9 -3
- package/dist/@types/client/types/domain-model.d.ts.map +1 -1
- package/dist/@types/client/types/index.d.ts +1 -1
- package/dist/@types/client/types/index.d.ts.map +1 -1
- package/dist/cli/act.js +103 -35
- package/dist/cli/act.js.map +1 -1
- package/dist/index.cjs +209 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +209 -42
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -309,15 +309,12 @@ function build_state(model, st) {
|
|
|
309
309
|
if (action_name.startsWith("__emits_")) continue;
|
|
310
310
|
const emits = raw_actions[`__emits_${action_name}`] ?? [];
|
|
311
311
|
const describe = (rule) => rule.description ?? "";
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
...invariants,
|
|
315
|
-
...(st.requires?.[action_name] ?? []).map(describe)
|
|
316
|
-
];
|
|
312
|
+
const preconditions = (st.requires?.[action_name] ?? []).map(describe);
|
|
313
|
+
const loads = (st.loads?.[action_name] ?? []).filter((l) => l.state);
|
|
317
314
|
action_nodes.push({
|
|
318
315
|
name: action_name,
|
|
319
316
|
emits,
|
|
320
|
-
|
|
317
|
+
...loads.length ? { loads } : {},
|
|
321
318
|
...preconditions.length ? { preconditions } : {},
|
|
322
319
|
zod: raw_actions[action_name]
|
|
323
320
|
});
|
|
@@ -591,7 +588,8 @@ function attach_emit(info, action_name, handler) {
|
|
|
591
588
|
emits.push(handler);
|
|
592
589
|
} else if (typeof handler === "function") {
|
|
593
590
|
const src = String(handler);
|
|
594
|
-
|
|
591
|
+
const routed = (info.loads[action_name] ?? []).flatMap((l) => l.events);
|
|
592
|
+
for (const event_name of [...Object.keys(info.events), ...routed]) {
|
|
595
593
|
if (src.includes(`"${event_name}"`) || src.includes(`'${event_name}'`) || src.includes(`\`${event_name}\``)) {
|
|
596
594
|
emits.push(event_name);
|
|
597
595
|
}
|
|
@@ -618,7 +616,7 @@ function attach_emit(info, action_name, handler) {
|
|
|
618
616
|
}
|
|
619
617
|
}
|
|
620
618
|
);
|
|
621
|
-
const result = handler(dummy_arg, dummy_arg, dummy_arg);
|
|
619
|
+
const result = handler(dummy_arg, dummy_arg, dummy_arg, dummy_arg);
|
|
622
620
|
if (Array.isArray(result) && typeof result[0] === "string") {
|
|
623
621
|
emits.push(result[0]);
|
|
624
622
|
}
|
|
@@ -635,8 +633,10 @@ function mock_state(entry, on_build) {
|
|
|
635
633
|
schema: entry[name],
|
|
636
634
|
events: {},
|
|
637
635
|
actions: {},
|
|
638
|
-
given: {},
|
|
639
636
|
requires: {},
|
|
637
|
+
// Each action's `.loads(...)`: the loaded state's name, the load's
|
|
638
|
+
// name, and the events listed on it.
|
|
639
|
+
loads: {},
|
|
640
640
|
patches: /* @__PURE__ */ new Set(),
|
|
641
641
|
_tag: "State"
|
|
642
642
|
};
|
|
@@ -652,14 +652,16 @@ function mock_state(entry, on_build) {
|
|
|
652
652
|
if (rules) info.requires[action_name] = rules;
|
|
653
653
|
return { emit };
|
|
654
654
|
};
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
655
|
+
const loads = (state, _target, events = [], name2) => {
|
|
656
|
+
const state_name = state?.name ?? "";
|
|
657
|
+
(info.loads[action_name] ??= []).push({
|
|
658
|
+
state: state_name,
|
|
659
|
+
name: name2 ?? state_name,
|
|
660
|
+
events
|
|
661
|
+
});
|
|
662
|
+
return { loads, requires, emit };
|
|
662
663
|
};
|
|
664
|
+
return { loads, requires, emit };
|
|
663
665
|
},
|
|
664
666
|
snap: () => action_builder(_currentAction),
|
|
665
667
|
// Close-the-books policy methods. The diagram doesn't render the
|
|
@@ -894,13 +896,7 @@ function mock_act(on_build) {
|
|
|
894
896
|
};
|
|
895
897
|
return builder;
|
|
896
898
|
}
|
|
897
|
-
var
|
|
898
|
-
constructor(message) {
|
|
899
|
-
super(message);
|
|
900
|
-
this.name = "InvariantError";
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
var PreconditionError = class extends InvariantError {
|
|
899
|
+
var PreconditionError = class extends Error {
|
|
904
900
|
constructor(message) {
|
|
905
901
|
super(message);
|
|
906
902
|
this.name = "PreconditionError";
|
|
@@ -922,7 +918,9 @@ var MODULES = {
|
|
|
922
918
|
}),
|
|
923
919
|
dispose: () => () => Promise.resolve(),
|
|
924
920
|
ZodEmpty: z.record(z.string(), z.never()),
|
|
925
|
-
|
|
921
|
+
// Runs where an event schema is declared, so a file that can't call it
|
|
922
|
+
// stops there and loses every state after it.
|
|
923
|
+
sensitive: (schema) => schema,
|
|
926
924
|
PreconditionError
|
|
927
925
|
},
|
|
928
926
|
zod: { z, ...z },
|
|
@@ -1251,12 +1249,12 @@ function build_patterns(esc, type) {
|
|
|
1251
1249
|
const guard_patterns = [
|
|
1252
1250
|
// Guard definition — prefer jumping to the declaration
|
|
1253
1251
|
new RegExp(
|
|
1254
|
-
`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*
|
|
1252
|
+
`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*Precondition\\b[^=]*)?\\s*=`
|
|
1255
1253
|
),
|
|
1256
1254
|
new RegExp(`rule\\(\\s*["'\`](${esc})["'\`]`),
|
|
1257
1255
|
new RegExp(`description:\\s*["'\`](${esc})["'\`]`),
|
|
1258
|
-
// .
|
|
1259
|
-
new RegExp(`\\.
|
|
1256
|
+
// .requires() usage in the state builder — last resort
|
|
1257
|
+
new RegExp(`\\.requires\\([\\s\\S]*?(${esc})`)
|
|
1260
1258
|
];
|
|
1261
1259
|
const slice_patterns = [
|
|
1262
1260
|
new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*slice\\s*\\(`)
|
|
@@ -1348,7 +1346,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1348
1346
|
const desc_match = desc_re.exec(c);
|
|
1349
1347
|
if (desc_match) {
|
|
1350
1348
|
const before = c.slice(0, desc_match.index);
|
|
1351
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*
|
|
1349
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Precondition[^=]*)?\s*=/g;
|
|
1352
1350
|
let last_decl = null;
|
|
1353
1351
|
let m;
|
|
1354
1352
|
while ((m = decl_re.exec(before)) !== null) {
|
|
@@ -1397,7 +1395,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1397
1395
|
const desc_match = desc_re.exec(c);
|
|
1398
1396
|
if (desc_match) {
|
|
1399
1397
|
const before = c.slice(0, desc_match.index);
|
|
1400
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*
|
|
1398
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Precondition[^=]*)?\s*=/g;
|
|
1401
1399
|
let last_decl = null;
|
|
1402
1400
|
let m;
|
|
1403
1401
|
while ((m = decl_re.exec(before)) !== null) last_decl = m;
|
|
@@ -1536,10 +1534,23 @@ import {
|
|
|
1536
1534
|
} from "lucide-react";
|
|
1537
1535
|
import { useCallback, useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
1538
1536
|
|
|
1537
|
+
// src/client/lib/loads.ts
|
|
1538
|
+
var appending_loads = (action) => (action.loads ?? []).filter((l) => l.events.length > 0);
|
|
1539
|
+
var read_loads = (action) => (action.loads ?? []).filter((l) => l.events.length === 0);
|
|
1540
|
+
var load_of = (action, event) => action.loads?.find((l) => l.events.includes(event));
|
|
1541
|
+
var load_label = (load) => load.name === load.state ? load.state : `${load.state} as "${load.name}"`;
|
|
1542
|
+
var commit_streams = (action, owner) => [
|
|
1543
|
+
owner,
|
|
1544
|
+
...appending_loads(action).map(load_label)
|
|
1545
|
+
];
|
|
1546
|
+
var commit_summary = (action, owner) => {
|
|
1547
|
+
const streams = commit_streams(action, owner);
|
|
1548
|
+
return streams.length > 1 ? `one commit across ${streams.length} streams (${streams.join(", ")})` : void 0;
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1539
1551
|
// src/client/lib/layout.ts
|
|
1540
1552
|
function rules_of(action) {
|
|
1541
|
-
|
|
1542
|
-
return rules.length ? rules : void 0;
|
|
1553
|
+
return action.preconditions?.length ? action.preconditions : void 0;
|
|
1543
1554
|
}
|
|
1544
1555
|
var W = 100;
|
|
1545
1556
|
var H = 36;
|
|
@@ -1551,6 +1562,8 @@ var SLICE_PAD = 24;
|
|
|
1551
1562
|
var SLICE_INNER = 16;
|
|
1552
1563
|
var SLICE_GAP = 20;
|
|
1553
1564
|
var MARGIN = 30;
|
|
1565
|
+
var COMMIT_PAD = 3;
|
|
1566
|
+
var COMMIT_GUTTER = 11;
|
|
1554
1567
|
var COLORS = {
|
|
1555
1568
|
action: { bg: "#1e40af", border: "#3b82f6", text: "#93c5fd" },
|
|
1556
1569
|
event: { bg: "#c2410c", border: "#f97316", text: "#fed7aa" },
|
|
@@ -1686,10 +1699,83 @@ function place_chain(measure, rDef, reactionY, rX, triggered_from_x, triggered_f
|
|
|
1686
1699
|
dispatchY += row.rowH + GAP / 2;
|
|
1687
1700
|
}
|
|
1688
1701
|
}
|
|
1702
|
+
var row_key = (action, event) => `${action}|${event}`;
|
|
1703
|
+
function stream_note(st, action_name, event) {
|
|
1704
|
+
const action = st.actions.find((a) => a.name === action_name);
|
|
1705
|
+
const load = action && load_of(action, event);
|
|
1706
|
+
return load && `\u2192 ${load.name}`;
|
|
1707
|
+
}
|
|
1708
|
+
function load_notes(action, owner) {
|
|
1709
|
+
if (!action.loads?.length) return {};
|
|
1710
|
+
const names = (loads) => loads.map((l) => l.name).join(", ");
|
|
1711
|
+
const appending = appending_loads(action);
|
|
1712
|
+
const reads = read_loads(action);
|
|
1713
|
+
const commit = commit_summary(action, owner);
|
|
1714
|
+
return {
|
|
1715
|
+
note: [
|
|
1716
|
+
...appending.length ? [`loads ${names(appending)}`] : [],
|
|
1717
|
+
...reads.length ? [`reads ${names(reads)}`] : []
|
|
1718
|
+
].join(" \xB7 "),
|
|
1719
|
+
loads: action.loads.map(
|
|
1720
|
+
(l) => l.events.length ? `${load_label(l)} \u2192 ${l.events.join(", ")}` : `${load_label(l)} (read, not guarded)`
|
|
1721
|
+
),
|
|
1722
|
+
...commit ? { commit } : {}
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
function push_commit(commits, action, owner, event_col_x, row_y) {
|
|
1726
|
+
if (!commit_summary(action, owner)) return;
|
|
1727
|
+
const ys = action.emits.map(row_y).filter((y) => y !== void 0);
|
|
1728
|
+
if (ys.length < 2) return;
|
|
1729
|
+
const top = Math.min(...ys);
|
|
1730
|
+
const bottom = Math.max(...ys) + H;
|
|
1731
|
+
commits.push({
|
|
1732
|
+
label: "one commit",
|
|
1733
|
+
x: event_col_x - COMMIT_GUTTER,
|
|
1734
|
+
y: top - COMMIT_PAD,
|
|
1735
|
+
w: W + COMMIT_GUTTER + COMMIT_PAD,
|
|
1736
|
+
h: bottom - top + COMMIT_PAD * 2
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
function connect_loads(view_model, ns, es) {
|
|
1740
|
+
const outside = /* @__PURE__ */ new Map();
|
|
1741
|
+
const loaded_by = /* @__PURE__ */ new Map();
|
|
1742
|
+
for (const s of view_model.states)
|
|
1743
|
+
for (const a of s.actions)
|
|
1744
|
+
for (const l of a.loads ?? []) {
|
|
1745
|
+
const who = `${s.name}.${a.name}`;
|
|
1746
|
+
loaded_by.set(l.state, [...loaded_by.get(l.state) ?? [], who]);
|
|
1747
|
+
for (const e of l.events)
|
|
1748
|
+
outside.set(e, [...outside.get(e) ?? [], who]);
|
|
1749
|
+
}
|
|
1750
|
+
for (const n of ns) {
|
|
1751
|
+
if (n.type === "event" && outside.has(n.label))
|
|
1752
|
+
n.outside = outside.get(n.label);
|
|
1753
|
+
if (n.type === "state" && loaded_by.has(n.label))
|
|
1754
|
+
n.loaded_by = [...new Set(loaded_by.get(n.label))];
|
|
1755
|
+
}
|
|
1756
|
+
for (const s of view_model.states)
|
|
1757
|
+
for (const a of s.actions) {
|
|
1758
|
+
const to = ns.find((n) => n.type === "action" && n.label === a.name);
|
|
1759
|
+
for (const state of new Set((a.loads ?? []).map((l) => l.state))) {
|
|
1760
|
+
const from = ns.find((n) => n.type === "state" && n.label === state);
|
|
1761
|
+
if (!from) continue;
|
|
1762
|
+
const appends = a.loads.some(
|
|
1763
|
+
(l) => l.state === state && l.events.length
|
|
1764
|
+
);
|
|
1765
|
+
es.push({
|
|
1766
|
+
from: { x: from.pos.x, y: from.pos.y + STATE_H / 2 },
|
|
1767
|
+
to: { x: to.pos.x + W, y: to.pos.y + H / 2 },
|
|
1768
|
+
color: appends ? COLORS.state.border : "#a1a1aa",
|
|
1769
|
+
dash: true
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1689
1774
|
function compute_layout(view_model) {
|
|
1690
1775
|
const ns = [];
|
|
1691
1776
|
const es = [];
|
|
1692
1777
|
const boxes = [];
|
|
1778
|
+
const commits = [];
|
|
1693
1779
|
const sv = /* @__PURE__ */ new Map();
|
|
1694
1780
|
for (const s of view_model.states) {
|
|
1695
1781
|
sv.set(s.varName, s);
|
|
@@ -1787,6 +1873,7 @@ function compute_layout(view_model) {
|
|
|
1787
1873
|
let slice_right_x = cx;
|
|
1788
1874
|
const slice_node_start = ns.length;
|
|
1789
1875
|
const slice_edge_start = es.length;
|
|
1876
|
+
const slice_commit_start = commits.length;
|
|
1790
1877
|
const slice_reactions_by_event = /* @__PURE__ */ new Map();
|
|
1791
1878
|
for (const r of slice.reactions) {
|
|
1792
1879
|
const list = slice_reactions_by_event.get(r.event) ?? [];
|
|
@@ -1867,17 +1954,19 @@ function compute_layout(view_model) {
|
|
|
1867
1954
|
const event_y_map = /* @__PURE__ */ new Map();
|
|
1868
1955
|
for (let ei = 0; ei < measured_events.length; ei++) {
|
|
1869
1956
|
const { event_name: en, action_name, chains } = measured_events[ei];
|
|
1957
|
+
const appended_to = stream_note(st, action_name, en);
|
|
1870
1958
|
ns.push({
|
|
1871
1959
|
key: `e:${en}:${slice.name}:${action_name}`,
|
|
1872
1960
|
pos: { x: event_col_x, y: evtY },
|
|
1873
1961
|
type: "event",
|
|
1874
1962
|
label: en,
|
|
1963
|
+
...appended_to ? { note: appended_to } : {},
|
|
1875
1964
|
file: event_file_map.get(en) ?? st.file,
|
|
1876
1965
|
projections: event_projections.get(en),
|
|
1877
1966
|
reactions: event_reactions.get(en),
|
|
1878
1967
|
schema: event_schemas.get(en)
|
|
1879
1968
|
});
|
|
1880
|
-
event_y_map.set(en, evtY);
|
|
1969
|
+
event_y_map.set(row_key(action_name, en), evtY);
|
|
1881
1970
|
for (const { chain, reaction: chain_reaction } of chains) {
|
|
1882
1971
|
const rX = event_col_x + W + GAP * 3;
|
|
1883
1972
|
const min_reaction_y = chain_watermark + chain.dispatch_block_h / 2 - H / 2;
|
|
@@ -1946,10 +2035,11 @@ function compute_layout(view_model) {
|
|
|
1946
2035
|
sub: rules_of(action) ? "guarded" : void 0,
|
|
1947
2036
|
guards: rules_of(action),
|
|
1948
2037
|
file: action_file_map.get(action.name) ?? st.file,
|
|
1949
|
-
emits: action.emits
|
|
2038
|
+
emits: action.emits,
|
|
2039
|
+
...load_notes(action, st.name)
|
|
1950
2040
|
});
|
|
1951
2041
|
for (const en of action.emits) {
|
|
1952
|
-
const ey = event_y_map.get(en);
|
|
2042
|
+
const ey = event_y_map.get(row_key(action.name, en));
|
|
1953
2043
|
es.push({
|
|
1954
2044
|
from: { x: cx + W, y: actY + H / 2 },
|
|
1955
2045
|
to: { x: event_col_x, y: ey + H / 2 },
|
|
@@ -1957,6 +2047,13 @@ function compute_layout(view_model) {
|
|
|
1957
2047
|
dash: false
|
|
1958
2048
|
});
|
|
1959
2049
|
}
|
|
2050
|
+
push_commit(
|
|
2051
|
+
commits,
|
|
2052
|
+
action,
|
|
2053
|
+
st.name,
|
|
2054
|
+
event_col_x,
|
|
2055
|
+
(en) => event_y_map.get(row_key(action.name, en))
|
|
2056
|
+
);
|
|
1960
2057
|
actY += H + GAP / 2;
|
|
1961
2058
|
action_idx++;
|
|
1962
2059
|
}
|
|
@@ -2012,6 +2109,9 @@ function compute_layout(view_model) {
|
|
|
2012
2109
|
es[ei].from.y += dy;
|
|
2013
2110
|
es[ei].to.y += dy;
|
|
2014
2111
|
}
|
|
2112
|
+
for (let ci = slice_commit_start; ci < commits.length; ci++) {
|
|
2113
|
+
commits[ci].y += dy;
|
|
2114
|
+
}
|
|
2015
2115
|
boxes.push({
|
|
2016
2116
|
label: slice.name,
|
|
2017
2117
|
x: sx - GAP / 2,
|
|
@@ -2046,16 +2146,18 @@ function compute_layout(view_model) {
|
|
|
2046
2146
|
const event_y_map = /* @__PURE__ */ new Map();
|
|
2047
2147
|
for (const action of st.actions) {
|
|
2048
2148
|
for (const en of action.emits) {
|
|
2149
|
+
const appended_to = stream_note(st, action.name, en);
|
|
2049
2150
|
ns.push({
|
|
2050
2151
|
key: `e:${en}:standalone`,
|
|
2051
2152
|
pos: { x: event_col_x, y: evtY },
|
|
2052
2153
|
type: "event",
|
|
2053
2154
|
label: en,
|
|
2155
|
+
...appended_to ? { note: appended_to } : {},
|
|
2054
2156
|
projections: event_projections.get(en),
|
|
2055
2157
|
reactions: event_reactions.get(en),
|
|
2056
2158
|
schema: event_schemas.get(en)
|
|
2057
2159
|
});
|
|
2058
|
-
event_y_map.set(en, evtY);
|
|
2160
|
+
event_y_map.set(row_key(action.name, en), evtY);
|
|
2059
2161
|
evtY += H + GAP / 2;
|
|
2060
2162
|
}
|
|
2061
2163
|
}
|
|
@@ -2069,7 +2171,6 @@ function compute_layout(view_model) {
|
|
|
2069
2171
|
reactions: event_reactions.get(en),
|
|
2070
2172
|
schema: event_schemas.get(en)
|
|
2071
2173
|
});
|
|
2072
|
-
event_y_map.set(en, evtY);
|
|
2073
2174
|
evtY += H + GAP / 2;
|
|
2074
2175
|
}
|
|
2075
2176
|
let actY = st_center_y - act_block_h / 2;
|
|
@@ -2091,10 +2192,11 @@ function compute_layout(view_model) {
|
|
|
2091
2192
|
label: action.name,
|
|
2092
2193
|
sub: rules_of(action) ? "guarded" : void 0,
|
|
2093
2194
|
guards: rules_of(action),
|
|
2094
|
-
emits: action.emits
|
|
2195
|
+
emits: action.emits,
|
|
2196
|
+
...load_notes(action, st.name)
|
|
2095
2197
|
});
|
|
2096
2198
|
for (const en of action.emits) {
|
|
2097
|
-
const ey = event_y_map.get(en);
|
|
2199
|
+
const ey = event_y_map.get(row_key(action.name, en));
|
|
2098
2200
|
es.push({
|
|
2099
2201
|
from: { x: cx + W, y: actY + H / 2 },
|
|
2100
2202
|
to: { x: event_col_x, y: ey + H / 2 },
|
|
@@ -2102,6 +2204,13 @@ function compute_layout(view_model) {
|
|
|
2102
2204
|
dash: false
|
|
2103
2205
|
});
|
|
2104
2206
|
}
|
|
2207
|
+
push_commit(
|
|
2208
|
+
commits,
|
|
2209
|
+
action,
|
|
2210
|
+
st.name,
|
|
2211
|
+
event_col_x,
|
|
2212
|
+
(en) => event_y_map.get(row_key(action.name, en))
|
|
2213
|
+
);
|
|
2105
2214
|
actY += H + GAP / 2;
|
|
2106
2215
|
aIdx++;
|
|
2107
2216
|
}
|
|
@@ -2135,6 +2244,7 @@ function compute_layout(view_model) {
|
|
|
2135
2244
|
globalY = Math.max(globalY, rY + H + GAP);
|
|
2136
2245
|
}
|
|
2137
2246
|
}
|
|
2247
|
+
connect_loads(view_model, ns, es);
|
|
2138
2248
|
let minX = 0, minY = 0, maxX = 0, maxY = 0;
|
|
2139
2249
|
for (const n of ns) {
|
|
2140
2250
|
const nw = n.type === "state" ? STATE_W : W;
|
|
@@ -2154,6 +2264,7 @@ function compute_layout(view_model) {
|
|
|
2154
2264
|
ns,
|
|
2155
2265
|
es,
|
|
2156
2266
|
boxes,
|
|
2267
|
+
commits,
|
|
2157
2268
|
// Content bounds (used by viewBox to frame the diagram)
|
|
2158
2269
|
minX: minX - MARGIN,
|
|
2159
2270
|
minY: minY - MARGIN,
|
|
@@ -2205,8 +2316,10 @@ function formatModelTree(model) {
|
|
|
2205
2316
|
if (!st) continue;
|
|
2206
2317
|
lines.push(` State: ${st.name}`);
|
|
2207
2318
|
for (const a of st.actions) {
|
|
2208
|
-
const rules = a.preconditions ??
|
|
2319
|
+
const rules = a.preconditions ?? [];
|
|
2209
2320
|
let line = ` ${a.name} \u2192 [${a.emits.join(", ")}]`;
|
|
2321
|
+
if (a.loads?.length)
|
|
2322
|
+
line += ` loads: [${a.loads.map(load_label).join(", ")}]`;
|
|
2210
2323
|
if (rules.length) line += ` preconditions: [${rules.join(", ")}]`;
|
|
2211
2324
|
lines.push(line);
|
|
2212
2325
|
}
|
|
@@ -2344,7 +2457,7 @@ function Diagram({
|
|
|
2344
2457
|
const onUp = useCallback(() => {
|
|
2345
2458
|
drag.current = false;
|
|
2346
2459
|
}, []);
|
|
2347
|
-
const { ns, es, boxes, minX, minY, width, height, layoutError } = useMemo(() => {
|
|
2460
|
+
const { ns, es, boxes, commits, minX, minY, width, height, layoutError } = useMemo(() => {
|
|
2348
2461
|
try {
|
|
2349
2462
|
return {
|
|
2350
2463
|
...compute_layout(view_model),
|
|
@@ -2356,6 +2469,7 @@ function Diagram({
|
|
|
2356
2469
|
ns: [],
|
|
2357
2470
|
es: [],
|
|
2358
2471
|
boxes: [],
|
|
2472
|
+
commits: [],
|
|
2359
2473
|
minX: 0,
|
|
2360
2474
|
minY: 0,
|
|
2361
2475
|
width: 100,
|
|
@@ -2458,7 +2572,7 @@ function Diagram({
|
|
|
2458
2572
|
title: "@rotorsoft/act-diagram version",
|
|
2459
2573
|
children: [
|
|
2460
2574
|
"v",
|
|
2461
|
-
"1.4.
|
|
2575
|
+
"1.4.2"
|
|
2462
2576
|
]
|
|
2463
2577
|
}
|
|
2464
2578
|
)
|
|
@@ -2669,6 +2783,36 @@ ${prompt}`);
|
|
|
2669
2783
|
i
|
|
2670
2784
|
);
|
|
2671
2785
|
}),
|
|
2786
|
+
commits.map((c) => /* @__PURE__ */ jsxs2("g", { pointerEvents: "none", children: [
|
|
2787
|
+
/* @__PURE__ */ jsx2(
|
|
2788
|
+
"rect",
|
|
2789
|
+
{
|
|
2790
|
+
x: c.x,
|
|
2791
|
+
y: c.y,
|
|
2792
|
+
width: c.w,
|
|
2793
|
+
height: c.h,
|
|
2794
|
+
rx: 6,
|
|
2795
|
+
fill: COLORS2.event.bg,
|
|
2796
|
+
fillOpacity: 0.08,
|
|
2797
|
+
stroke: COLORS2.event.border,
|
|
2798
|
+
strokeWidth: 1,
|
|
2799
|
+
strokeDasharray: "4,3"
|
|
2800
|
+
}
|
|
2801
|
+
),
|
|
2802
|
+
/* @__PURE__ */ jsx2(
|
|
2803
|
+
"text",
|
|
2804
|
+
{
|
|
2805
|
+
x: c.x + 5,
|
|
2806
|
+
y: c.y + c.h / 2,
|
|
2807
|
+
fill: COLORS2.event.text,
|
|
2808
|
+
className: "text-[7px]",
|
|
2809
|
+
textAnchor: "middle",
|
|
2810
|
+
dominantBaseline: "central",
|
|
2811
|
+
transform: `rotate(-90, ${c.x + 5}, ${c.y + c.h / 2})`,
|
|
2812
|
+
children: c.label
|
|
2813
|
+
}
|
|
2814
|
+
)
|
|
2815
|
+
] }, `${c.x}:${c.y}`)),
|
|
2672
2816
|
/* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2(
|
|
2673
2817
|
"marker",
|
|
2674
2818
|
{
|
|
@@ -2706,8 +2850,19 @@ ${prompt}`);
|
|
|
2706
2850
|
onClick: () => onClickElement?.(n.label, n.type, n.file),
|
|
2707
2851
|
onMouseEnter: (ev) => {
|
|
2708
2852
|
const sections = [];
|
|
2853
|
+
if (n.loads?.length)
|
|
2854
|
+
sections.push({ label: "Loads", items: n.loads });
|
|
2855
|
+
if (n.commit)
|
|
2856
|
+
sections.push({ label: "Commit", items: [n.commit] });
|
|
2709
2857
|
if (n.emits?.length)
|
|
2710
2858
|
sections.push({ label: "Emits", items: n.emits });
|
|
2859
|
+
if (n.loaded_by?.length)
|
|
2860
|
+
sections.push({ label: "Loaded by", items: n.loaded_by });
|
|
2861
|
+
if (n.outside?.length)
|
|
2862
|
+
sections.push({
|
|
2863
|
+
label: "Also emitted by",
|
|
2864
|
+
items: n.outside
|
|
2865
|
+
});
|
|
2711
2866
|
if (n.handles?.length)
|
|
2712
2867
|
sections.push({ label: "Handles", items: n.handles });
|
|
2713
2868
|
if (n.guards?.length)
|
|
@@ -2741,7 +2896,8 @@ ${prompt}`);
|
|
|
2741
2896
|
rx: isState ? 6 : 4,
|
|
2742
2897
|
fill: alpha(c.bg, 0.75),
|
|
2743
2898
|
stroke: hasWarn ? "#ef4444" : c.border,
|
|
2744
|
-
strokeWidth: hasWarn ? 2 : 1.5
|
|
2899
|
+
strokeWidth: hasWarn ? 2 : 1.5,
|
|
2900
|
+
strokeDasharray: n.outside?.length ? "4,2" : void 0
|
|
2745
2901
|
}
|
|
2746
2902
|
),
|
|
2747
2903
|
lines.map((line, li) => /* @__PURE__ */ jsx2(
|
|
@@ -2757,6 +2913,17 @@ ${prompt}`);
|
|
|
2757
2913
|
},
|
|
2758
2914
|
li
|
|
2759
2915
|
)),
|
|
2916
|
+
n.note && /* @__PURE__ */ jsx2(
|
|
2917
|
+
"text",
|
|
2918
|
+
{
|
|
2919
|
+
x: n.pos.x + nw / 2,
|
|
2920
|
+
y: n.pos.y + nh - 5,
|
|
2921
|
+
fill: COLORS2.state.text,
|
|
2922
|
+
textAnchor: "middle",
|
|
2923
|
+
className: "text-[7px]",
|
|
2924
|
+
children: n.note
|
|
2925
|
+
}
|
|
2926
|
+
),
|
|
2760
2927
|
(() => {
|
|
2761
2928
|
let ix = n.pos.x + nw - 13;
|
|
2762
2929
|
const icons = [];
|