@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.cjs
CHANGED
|
@@ -348,15 +348,12 @@ function build_state(model, st) {
|
|
|
348
348
|
if (action_name.startsWith("__emits_")) continue;
|
|
349
349
|
const emits = raw_actions[`__emits_${action_name}`] ?? [];
|
|
350
350
|
const describe = (rule) => rule.description ?? "";
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
...invariants,
|
|
354
|
-
...(st.requires?.[action_name] ?? []).map(describe)
|
|
355
|
-
];
|
|
351
|
+
const preconditions = (st.requires?.[action_name] ?? []).map(describe);
|
|
352
|
+
const loads = (st.loads?.[action_name] ?? []).filter((l) => l.state);
|
|
356
353
|
action_nodes.push({
|
|
357
354
|
name: action_name,
|
|
358
355
|
emits,
|
|
359
|
-
|
|
356
|
+
...loads.length ? { loads } : {},
|
|
360
357
|
...preconditions.length ? { preconditions } : {},
|
|
361
358
|
zod: raw_actions[action_name]
|
|
362
359
|
});
|
|
@@ -630,7 +627,8 @@ function attach_emit(info, action_name, handler) {
|
|
|
630
627
|
emits.push(handler);
|
|
631
628
|
} else if (typeof handler === "function") {
|
|
632
629
|
const src = String(handler);
|
|
633
|
-
|
|
630
|
+
const routed = (info.loads[action_name] ?? []).flatMap((l) => l.events);
|
|
631
|
+
for (const event_name of [...Object.keys(info.events), ...routed]) {
|
|
634
632
|
if (src.includes(`"${event_name}"`) || src.includes(`'${event_name}'`) || src.includes(`\`${event_name}\``)) {
|
|
635
633
|
emits.push(event_name);
|
|
636
634
|
}
|
|
@@ -657,7 +655,7 @@ function attach_emit(info, action_name, handler) {
|
|
|
657
655
|
}
|
|
658
656
|
}
|
|
659
657
|
);
|
|
660
|
-
const result = handler(dummy_arg, dummy_arg, dummy_arg);
|
|
658
|
+
const result = handler(dummy_arg, dummy_arg, dummy_arg, dummy_arg);
|
|
661
659
|
if (Array.isArray(result) && typeof result[0] === "string") {
|
|
662
660
|
emits.push(result[0]);
|
|
663
661
|
}
|
|
@@ -674,8 +672,10 @@ function mock_state(entry, on_build) {
|
|
|
674
672
|
schema: entry[name],
|
|
675
673
|
events: {},
|
|
676
674
|
actions: {},
|
|
677
|
-
given: {},
|
|
678
675
|
requires: {},
|
|
676
|
+
// Each action's `.loads(...)`: the loaded state's name, the load's
|
|
677
|
+
// name, and the events listed on it.
|
|
678
|
+
loads: {},
|
|
679
679
|
patches: /* @__PURE__ */ new Set(),
|
|
680
680
|
_tag: "State"
|
|
681
681
|
};
|
|
@@ -691,14 +691,16 @@ function mock_state(entry, on_build) {
|
|
|
691
691
|
if (rules) info.requires[action_name] = rules;
|
|
692
692
|
return { emit };
|
|
693
693
|
};
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
694
|
+
const loads = (state, _target, events = [], name2) => {
|
|
695
|
+
const state_name = state?.name ?? "";
|
|
696
|
+
(info.loads[action_name] ??= []).push({
|
|
697
|
+
state: state_name,
|
|
698
|
+
name: name2 ?? state_name,
|
|
699
|
+
events
|
|
700
|
+
});
|
|
701
|
+
return { loads, requires, emit };
|
|
701
702
|
};
|
|
703
|
+
return { loads, requires, emit };
|
|
702
704
|
},
|
|
703
705
|
snap: () => action_builder(_currentAction),
|
|
704
706
|
// Close-the-books policy methods. The diagram doesn't render the
|
|
@@ -933,13 +935,7 @@ function mock_act(on_build) {
|
|
|
933
935
|
};
|
|
934
936
|
return builder;
|
|
935
937
|
}
|
|
936
|
-
var
|
|
937
|
-
constructor(message) {
|
|
938
|
-
super(message);
|
|
939
|
-
this.name = "InvariantError";
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
var PreconditionError = class extends InvariantError {
|
|
938
|
+
var PreconditionError = class extends Error {
|
|
943
939
|
constructor(message) {
|
|
944
940
|
super(message);
|
|
945
941
|
this.name = "PreconditionError";
|
|
@@ -961,7 +957,9 @@ var MODULES = {
|
|
|
961
957
|
}),
|
|
962
958
|
dispose: () => () => Promise.resolve(),
|
|
963
959
|
ZodEmpty: import_zod.z.record(import_zod.z.string(), import_zod.z.never()),
|
|
964
|
-
|
|
960
|
+
// Runs where an event schema is declared, so a file that can't call it
|
|
961
|
+
// stops there and loses every state after it.
|
|
962
|
+
sensitive: (schema) => schema,
|
|
965
963
|
PreconditionError
|
|
966
964
|
},
|
|
967
965
|
zod: { z: import_zod.z, ...import_zod.z },
|
|
@@ -1290,12 +1288,12 @@ function build_patterns(esc, type) {
|
|
|
1290
1288
|
const guard_patterns = [
|
|
1291
1289
|
// Guard definition — prefer jumping to the declaration
|
|
1292
1290
|
new RegExp(
|
|
1293
|
-
`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*
|
|
1291
|
+
`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*Precondition\\b[^=]*)?\\s*=`
|
|
1294
1292
|
),
|
|
1295
1293
|
new RegExp(`rule\\(\\s*["'\`](${esc})["'\`]`),
|
|
1296
1294
|
new RegExp(`description:\\s*["'\`](${esc})["'\`]`),
|
|
1297
|
-
// .
|
|
1298
|
-
new RegExp(`\\.
|
|
1295
|
+
// .requires() usage in the state builder — last resort
|
|
1296
|
+
new RegExp(`\\.requires\\([\\s\\S]*?(${esc})`)
|
|
1299
1297
|
];
|
|
1300
1298
|
const slice_patterns = [
|
|
1301
1299
|
new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*slice\\s*\\(`)
|
|
@@ -1387,7 +1385,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1387
1385
|
const desc_match = desc_re.exec(c);
|
|
1388
1386
|
if (desc_match) {
|
|
1389
1387
|
const before = c.slice(0, desc_match.index);
|
|
1390
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*
|
|
1388
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Precondition[^=]*)?\s*=/g;
|
|
1391
1389
|
let last_decl = null;
|
|
1392
1390
|
let m;
|
|
1393
1391
|
while ((m = decl_re.exec(before)) !== null) {
|
|
@@ -1436,7 +1434,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1436
1434
|
const desc_match = desc_re.exec(c);
|
|
1437
1435
|
if (desc_match) {
|
|
1438
1436
|
const before = c.slice(0, desc_match.index);
|
|
1439
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*
|
|
1437
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Precondition[^=]*)?\s*=/g;
|
|
1440
1438
|
let last_decl = null;
|
|
1441
1439
|
let m;
|
|
1442
1440
|
while ((m = decl_re.exec(before)) !== null) last_decl = m;
|
|
@@ -1567,10 +1565,23 @@ function AiBar({ onSubmit, generating }) {
|
|
|
1567
1565
|
var import_lucide_react2 = require("lucide-react");
|
|
1568
1566
|
var import_react2 = require("react");
|
|
1569
1567
|
|
|
1568
|
+
// src/client/lib/loads.ts
|
|
1569
|
+
var appending_loads = (action) => (action.loads ?? []).filter((l) => l.events.length > 0);
|
|
1570
|
+
var read_loads = (action) => (action.loads ?? []).filter((l) => l.events.length === 0);
|
|
1571
|
+
var load_of = (action, event) => action.loads?.find((l) => l.events.includes(event));
|
|
1572
|
+
var load_label = (load) => load.name === load.state ? load.state : `${load.state} as "${load.name}"`;
|
|
1573
|
+
var commit_streams = (action, owner) => [
|
|
1574
|
+
owner,
|
|
1575
|
+
...appending_loads(action).map(load_label)
|
|
1576
|
+
];
|
|
1577
|
+
var commit_summary = (action, owner) => {
|
|
1578
|
+
const streams = commit_streams(action, owner);
|
|
1579
|
+
return streams.length > 1 ? `one commit across ${streams.length} streams (${streams.join(", ")})` : void 0;
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1570
1582
|
// src/client/lib/layout.ts
|
|
1571
1583
|
function rules_of(action) {
|
|
1572
|
-
|
|
1573
|
-
return rules.length ? rules : void 0;
|
|
1584
|
+
return action.preconditions?.length ? action.preconditions : void 0;
|
|
1574
1585
|
}
|
|
1575
1586
|
var W = 100;
|
|
1576
1587
|
var H = 36;
|
|
@@ -1582,6 +1593,8 @@ var SLICE_PAD = 24;
|
|
|
1582
1593
|
var SLICE_INNER = 16;
|
|
1583
1594
|
var SLICE_GAP = 20;
|
|
1584
1595
|
var MARGIN = 30;
|
|
1596
|
+
var COMMIT_PAD = 3;
|
|
1597
|
+
var COMMIT_GUTTER = 11;
|
|
1585
1598
|
var COLORS = {
|
|
1586
1599
|
action: { bg: "#1e40af", border: "#3b82f6", text: "#93c5fd" },
|
|
1587
1600
|
event: { bg: "#c2410c", border: "#f97316", text: "#fed7aa" },
|
|
@@ -1717,10 +1730,83 @@ function place_chain(measure, rDef, reactionY, rX, triggered_from_x, triggered_f
|
|
|
1717
1730
|
dispatchY += row.rowH + GAP / 2;
|
|
1718
1731
|
}
|
|
1719
1732
|
}
|
|
1733
|
+
var row_key = (action, event) => `${action}|${event}`;
|
|
1734
|
+
function stream_note(st, action_name, event) {
|
|
1735
|
+
const action = st.actions.find((a) => a.name === action_name);
|
|
1736
|
+
const load = action && load_of(action, event);
|
|
1737
|
+
return load && `\u2192 ${load.name}`;
|
|
1738
|
+
}
|
|
1739
|
+
function load_notes(action, owner) {
|
|
1740
|
+
if (!action.loads?.length) return {};
|
|
1741
|
+
const names = (loads) => loads.map((l) => l.name).join(", ");
|
|
1742
|
+
const appending = appending_loads(action);
|
|
1743
|
+
const reads = read_loads(action);
|
|
1744
|
+
const commit = commit_summary(action, owner);
|
|
1745
|
+
return {
|
|
1746
|
+
note: [
|
|
1747
|
+
...appending.length ? [`loads ${names(appending)}`] : [],
|
|
1748
|
+
...reads.length ? [`reads ${names(reads)}`] : []
|
|
1749
|
+
].join(" \xB7 "),
|
|
1750
|
+
loads: action.loads.map(
|
|
1751
|
+
(l) => l.events.length ? `${load_label(l)} \u2192 ${l.events.join(", ")}` : `${load_label(l)} (read, not guarded)`
|
|
1752
|
+
),
|
|
1753
|
+
...commit ? { commit } : {}
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
function push_commit(commits, action, owner, event_col_x, row_y) {
|
|
1757
|
+
if (!commit_summary(action, owner)) return;
|
|
1758
|
+
const ys = action.emits.map(row_y).filter((y) => y !== void 0);
|
|
1759
|
+
if (ys.length < 2) return;
|
|
1760
|
+
const top = Math.min(...ys);
|
|
1761
|
+
const bottom = Math.max(...ys) + H;
|
|
1762
|
+
commits.push({
|
|
1763
|
+
label: "one commit",
|
|
1764
|
+
x: event_col_x - COMMIT_GUTTER,
|
|
1765
|
+
y: top - COMMIT_PAD,
|
|
1766
|
+
w: W + COMMIT_GUTTER + COMMIT_PAD,
|
|
1767
|
+
h: bottom - top + COMMIT_PAD * 2
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
function connect_loads(view_model, ns, es) {
|
|
1771
|
+
const outside = /* @__PURE__ */ new Map();
|
|
1772
|
+
const loaded_by = /* @__PURE__ */ new Map();
|
|
1773
|
+
for (const s of view_model.states)
|
|
1774
|
+
for (const a of s.actions)
|
|
1775
|
+
for (const l of a.loads ?? []) {
|
|
1776
|
+
const who = `${s.name}.${a.name}`;
|
|
1777
|
+
loaded_by.set(l.state, [...loaded_by.get(l.state) ?? [], who]);
|
|
1778
|
+
for (const e of l.events)
|
|
1779
|
+
outside.set(e, [...outside.get(e) ?? [], who]);
|
|
1780
|
+
}
|
|
1781
|
+
for (const n of ns) {
|
|
1782
|
+
if (n.type === "event" && outside.has(n.label))
|
|
1783
|
+
n.outside = outside.get(n.label);
|
|
1784
|
+
if (n.type === "state" && loaded_by.has(n.label))
|
|
1785
|
+
n.loaded_by = [...new Set(loaded_by.get(n.label))];
|
|
1786
|
+
}
|
|
1787
|
+
for (const s of view_model.states)
|
|
1788
|
+
for (const a of s.actions) {
|
|
1789
|
+
const to = ns.find((n) => n.type === "action" && n.label === a.name);
|
|
1790
|
+
for (const state of new Set((a.loads ?? []).map((l) => l.state))) {
|
|
1791
|
+
const from = ns.find((n) => n.type === "state" && n.label === state);
|
|
1792
|
+
if (!from) continue;
|
|
1793
|
+
const appends = a.loads.some(
|
|
1794
|
+
(l) => l.state === state && l.events.length
|
|
1795
|
+
);
|
|
1796
|
+
es.push({
|
|
1797
|
+
from: { x: from.pos.x, y: from.pos.y + STATE_H / 2 },
|
|
1798
|
+
to: { x: to.pos.x + W, y: to.pos.y + H / 2 },
|
|
1799
|
+
color: appends ? COLORS.state.border : "#a1a1aa",
|
|
1800
|
+
dash: true
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1720
1805
|
function compute_layout(view_model) {
|
|
1721
1806
|
const ns = [];
|
|
1722
1807
|
const es = [];
|
|
1723
1808
|
const boxes = [];
|
|
1809
|
+
const commits = [];
|
|
1724
1810
|
const sv = /* @__PURE__ */ new Map();
|
|
1725
1811
|
for (const s of view_model.states) {
|
|
1726
1812
|
sv.set(s.varName, s);
|
|
@@ -1818,6 +1904,7 @@ function compute_layout(view_model) {
|
|
|
1818
1904
|
let slice_right_x = cx;
|
|
1819
1905
|
const slice_node_start = ns.length;
|
|
1820
1906
|
const slice_edge_start = es.length;
|
|
1907
|
+
const slice_commit_start = commits.length;
|
|
1821
1908
|
const slice_reactions_by_event = /* @__PURE__ */ new Map();
|
|
1822
1909
|
for (const r of slice.reactions) {
|
|
1823
1910
|
const list = slice_reactions_by_event.get(r.event) ?? [];
|
|
@@ -1898,17 +1985,19 @@ function compute_layout(view_model) {
|
|
|
1898
1985
|
const event_y_map = /* @__PURE__ */ new Map();
|
|
1899
1986
|
for (let ei = 0; ei < measured_events.length; ei++) {
|
|
1900
1987
|
const { event_name: en, action_name, chains } = measured_events[ei];
|
|
1988
|
+
const appended_to = stream_note(st, action_name, en);
|
|
1901
1989
|
ns.push({
|
|
1902
1990
|
key: `e:${en}:${slice.name}:${action_name}`,
|
|
1903
1991
|
pos: { x: event_col_x, y: evtY },
|
|
1904
1992
|
type: "event",
|
|
1905
1993
|
label: en,
|
|
1994
|
+
...appended_to ? { note: appended_to } : {},
|
|
1906
1995
|
file: event_file_map.get(en) ?? st.file,
|
|
1907
1996
|
projections: event_projections.get(en),
|
|
1908
1997
|
reactions: event_reactions.get(en),
|
|
1909
1998
|
schema: event_schemas.get(en)
|
|
1910
1999
|
});
|
|
1911
|
-
event_y_map.set(en, evtY);
|
|
2000
|
+
event_y_map.set(row_key(action_name, en), evtY);
|
|
1912
2001
|
for (const { chain, reaction: chain_reaction } of chains) {
|
|
1913
2002
|
const rX = event_col_x + W + GAP * 3;
|
|
1914
2003
|
const min_reaction_y = chain_watermark + chain.dispatch_block_h / 2 - H / 2;
|
|
@@ -1977,10 +2066,11 @@ function compute_layout(view_model) {
|
|
|
1977
2066
|
sub: rules_of(action) ? "guarded" : void 0,
|
|
1978
2067
|
guards: rules_of(action),
|
|
1979
2068
|
file: action_file_map.get(action.name) ?? st.file,
|
|
1980
|
-
emits: action.emits
|
|
2069
|
+
emits: action.emits,
|
|
2070
|
+
...load_notes(action, st.name)
|
|
1981
2071
|
});
|
|
1982
2072
|
for (const en of action.emits) {
|
|
1983
|
-
const ey = event_y_map.get(en);
|
|
2073
|
+
const ey = event_y_map.get(row_key(action.name, en));
|
|
1984
2074
|
es.push({
|
|
1985
2075
|
from: { x: cx + W, y: actY + H / 2 },
|
|
1986
2076
|
to: { x: event_col_x, y: ey + H / 2 },
|
|
@@ -1988,6 +2078,13 @@ function compute_layout(view_model) {
|
|
|
1988
2078
|
dash: false
|
|
1989
2079
|
});
|
|
1990
2080
|
}
|
|
2081
|
+
push_commit(
|
|
2082
|
+
commits,
|
|
2083
|
+
action,
|
|
2084
|
+
st.name,
|
|
2085
|
+
event_col_x,
|
|
2086
|
+
(en) => event_y_map.get(row_key(action.name, en))
|
|
2087
|
+
);
|
|
1991
2088
|
actY += H + GAP / 2;
|
|
1992
2089
|
action_idx++;
|
|
1993
2090
|
}
|
|
@@ -2043,6 +2140,9 @@ function compute_layout(view_model) {
|
|
|
2043
2140
|
es[ei].from.y += dy;
|
|
2044
2141
|
es[ei].to.y += dy;
|
|
2045
2142
|
}
|
|
2143
|
+
for (let ci = slice_commit_start; ci < commits.length; ci++) {
|
|
2144
|
+
commits[ci].y += dy;
|
|
2145
|
+
}
|
|
2046
2146
|
boxes.push({
|
|
2047
2147
|
label: slice.name,
|
|
2048
2148
|
x: sx - GAP / 2,
|
|
@@ -2077,16 +2177,18 @@ function compute_layout(view_model) {
|
|
|
2077
2177
|
const event_y_map = /* @__PURE__ */ new Map();
|
|
2078
2178
|
for (const action of st.actions) {
|
|
2079
2179
|
for (const en of action.emits) {
|
|
2180
|
+
const appended_to = stream_note(st, action.name, en);
|
|
2080
2181
|
ns.push({
|
|
2081
2182
|
key: `e:${en}:standalone`,
|
|
2082
2183
|
pos: { x: event_col_x, y: evtY },
|
|
2083
2184
|
type: "event",
|
|
2084
2185
|
label: en,
|
|
2186
|
+
...appended_to ? { note: appended_to } : {},
|
|
2085
2187
|
projections: event_projections.get(en),
|
|
2086
2188
|
reactions: event_reactions.get(en),
|
|
2087
2189
|
schema: event_schemas.get(en)
|
|
2088
2190
|
});
|
|
2089
|
-
event_y_map.set(en, evtY);
|
|
2191
|
+
event_y_map.set(row_key(action.name, en), evtY);
|
|
2090
2192
|
evtY += H + GAP / 2;
|
|
2091
2193
|
}
|
|
2092
2194
|
}
|
|
@@ -2100,7 +2202,6 @@ function compute_layout(view_model) {
|
|
|
2100
2202
|
reactions: event_reactions.get(en),
|
|
2101
2203
|
schema: event_schemas.get(en)
|
|
2102
2204
|
});
|
|
2103
|
-
event_y_map.set(en, evtY);
|
|
2104
2205
|
evtY += H + GAP / 2;
|
|
2105
2206
|
}
|
|
2106
2207
|
let actY = st_center_y - act_block_h / 2;
|
|
@@ -2122,10 +2223,11 @@ function compute_layout(view_model) {
|
|
|
2122
2223
|
label: action.name,
|
|
2123
2224
|
sub: rules_of(action) ? "guarded" : void 0,
|
|
2124
2225
|
guards: rules_of(action),
|
|
2125
|
-
emits: action.emits
|
|
2226
|
+
emits: action.emits,
|
|
2227
|
+
...load_notes(action, st.name)
|
|
2126
2228
|
});
|
|
2127
2229
|
for (const en of action.emits) {
|
|
2128
|
-
const ey = event_y_map.get(en);
|
|
2230
|
+
const ey = event_y_map.get(row_key(action.name, en));
|
|
2129
2231
|
es.push({
|
|
2130
2232
|
from: { x: cx + W, y: actY + H / 2 },
|
|
2131
2233
|
to: { x: event_col_x, y: ey + H / 2 },
|
|
@@ -2133,6 +2235,13 @@ function compute_layout(view_model) {
|
|
|
2133
2235
|
dash: false
|
|
2134
2236
|
});
|
|
2135
2237
|
}
|
|
2238
|
+
push_commit(
|
|
2239
|
+
commits,
|
|
2240
|
+
action,
|
|
2241
|
+
st.name,
|
|
2242
|
+
event_col_x,
|
|
2243
|
+
(en) => event_y_map.get(row_key(action.name, en))
|
|
2244
|
+
);
|
|
2136
2245
|
actY += H + GAP / 2;
|
|
2137
2246
|
aIdx++;
|
|
2138
2247
|
}
|
|
@@ -2166,6 +2275,7 @@ function compute_layout(view_model) {
|
|
|
2166
2275
|
globalY = Math.max(globalY, rY + H + GAP);
|
|
2167
2276
|
}
|
|
2168
2277
|
}
|
|
2278
|
+
connect_loads(view_model, ns, es);
|
|
2169
2279
|
let minX = 0, minY = 0, maxX = 0, maxY = 0;
|
|
2170
2280
|
for (const n of ns) {
|
|
2171
2281
|
const nw = n.type === "state" ? STATE_W : W;
|
|
@@ -2185,6 +2295,7 @@ function compute_layout(view_model) {
|
|
|
2185
2295
|
ns,
|
|
2186
2296
|
es,
|
|
2187
2297
|
boxes,
|
|
2298
|
+
commits,
|
|
2188
2299
|
// Content bounds (used by viewBox to frame the diagram)
|
|
2189
2300
|
minX: minX - MARGIN,
|
|
2190
2301
|
minY: minY - MARGIN,
|
|
@@ -2236,8 +2347,10 @@ function formatModelTree(model) {
|
|
|
2236
2347
|
if (!st) continue;
|
|
2237
2348
|
lines.push(` State: ${st.name}`);
|
|
2238
2349
|
for (const a of st.actions) {
|
|
2239
|
-
const rules = a.preconditions ??
|
|
2350
|
+
const rules = a.preconditions ?? [];
|
|
2240
2351
|
let line = ` ${a.name} \u2192 [${a.emits.join(", ")}]`;
|
|
2352
|
+
if (a.loads?.length)
|
|
2353
|
+
line += ` loads: [${a.loads.map(load_label).join(", ")}]`;
|
|
2241
2354
|
if (rules.length) line += ` preconditions: [${rules.join(", ")}]`;
|
|
2242
2355
|
lines.push(line);
|
|
2243
2356
|
}
|
|
@@ -2375,7 +2488,7 @@ function Diagram({
|
|
|
2375
2488
|
const onUp = (0, import_react2.useCallback)(() => {
|
|
2376
2489
|
drag.current = false;
|
|
2377
2490
|
}, []);
|
|
2378
|
-
const { ns, es, boxes, minX, minY, width, height, layoutError } = (0, import_react2.useMemo)(() => {
|
|
2491
|
+
const { ns, es, boxes, commits, minX, minY, width, height, layoutError } = (0, import_react2.useMemo)(() => {
|
|
2379
2492
|
try {
|
|
2380
2493
|
return {
|
|
2381
2494
|
...compute_layout(view_model),
|
|
@@ -2387,6 +2500,7 @@ function Diagram({
|
|
|
2387
2500
|
ns: [],
|
|
2388
2501
|
es: [],
|
|
2389
2502
|
boxes: [],
|
|
2503
|
+
commits: [],
|
|
2390
2504
|
minX: 0,
|
|
2391
2505
|
minY: 0,
|
|
2392
2506
|
width: 100,
|
|
@@ -2489,7 +2603,7 @@ function Diagram({
|
|
|
2489
2603
|
title: "@rotorsoft/act-diagram version",
|
|
2490
2604
|
children: [
|
|
2491
2605
|
"v",
|
|
2492
|
-
"1.4.
|
|
2606
|
+
"1.4.2"
|
|
2493
2607
|
]
|
|
2494
2608
|
}
|
|
2495
2609
|
)
|
|
@@ -2700,6 +2814,36 @@ ${prompt}`);
|
|
|
2700
2814
|
i
|
|
2701
2815
|
);
|
|
2702
2816
|
}),
|
|
2817
|
+
commits.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { pointerEvents: "none", children: [
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2819
|
+
"rect",
|
|
2820
|
+
{
|
|
2821
|
+
x: c.x,
|
|
2822
|
+
y: c.y,
|
|
2823
|
+
width: c.w,
|
|
2824
|
+
height: c.h,
|
|
2825
|
+
rx: 6,
|
|
2826
|
+
fill: COLORS2.event.bg,
|
|
2827
|
+
fillOpacity: 0.08,
|
|
2828
|
+
stroke: COLORS2.event.border,
|
|
2829
|
+
strokeWidth: 1,
|
|
2830
|
+
strokeDasharray: "4,3"
|
|
2831
|
+
}
|
|
2832
|
+
),
|
|
2833
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2834
|
+
"text",
|
|
2835
|
+
{
|
|
2836
|
+
x: c.x + 5,
|
|
2837
|
+
y: c.y + c.h / 2,
|
|
2838
|
+
fill: COLORS2.event.text,
|
|
2839
|
+
className: "text-[7px]",
|
|
2840
|
+
textAnchor: "middle",
|
|
2841
|
+
dominantBaseline: "central",
|
|
2842
|
+
transform: `rotate(-90, ${c.x + 5}, ${c.y + c.h / 2})`,
|
|
2843
|
+
children: c.label
|
|
2844
|
+
}
|
|
2845
|
+
)
|
|
2846
|
+
] }, `${c.x}:${c.y}`)),
|
|
2703
2847
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2704
2848
|
"marker",
|
|
2705
2849
|
{
|
|
@@ -2737,8 +2881,19 @@ ${prompt}`);
|
|
|
2737
2881
|
onClick: () => onClickElement?.(n.label, n.type, n.file),
|
|
2738
2882
|
onMouseEnter: (ev) => {
|
|
2739
2883
|
const sections = [];
|
|
2884
|
+
if (n.loads?.length)
|
|
2885
|
+
sections.push({ label: "Loads", items: n.loads });
|
|
2886
|
+
if (n.commit)
|
|
2887
|
+
sections.push({ label: "Commit", items: [n.commit] });
|
|
2740
2888
|
if (n.emits?.length)
|
|
2741
2889
|
sections.push({ label: "Emits", items: n.emits });
|
|
2890
|
+
if (n.loaded_by?.length)
|
|
2891
|
+
sections.push({ label: "Loaded by", items: n.loaded_by });
|
|
2892
|
+
if (n.outside?.length)
|
|
2893
|
+
sections.push({
|
|
2894
|
+
label: "Also emitted by",
|
|
2895
|
+
items: n.outside
|
|
2896
|
+
});
|
|
2742
2897
|
if (n.handles?.length)
|
|
2743
2898
|
sections.push({ label: "Handles", items: n.handles });
|
|
2744
2899
|
if (n.guards?.length)
|
|
@@ -2772,7 +2927,8 @@ ${prompt}`);
|
|
|
2772
2927
|
rx: isState ? 6 : 4,
|
|
2773
2928
|
fill: alpha(c.bg, 0.75),
|
|
2774
2929
|
stroke: hasWarn ? "#ef4444" : c.border,
|
|
2775
|
-
strokeWidth: hasWarn ? 2 : 1.5
|
|
2930
|
+
strokeWidth: hasWarn ? 2 : 1.5,
|
|
2931
|
+
strokeDasharray: n.outside?.length ? "4,2" : void 0
|
|
2776
2932
|
}
|
|
2777
2933
|
),
|
|
2778
2934
|
lines.map((line, li) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -2788,6 +2944,17 @@ ${prompt}`);
|
|
|
2788
2944
|
},
|
|
2789
2945
|
li
|
|
2790
2946
|
)),
|
|
2947
|
+
n.note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2948
|
+
"text",
|
|
2949
|
+
{
|
|
2950
|
+
x: n.pos.x + nw / 2,
|
|
2951
|
+
y: n.pos.y + nh - 5,
|
|
2952
|
+
fill: COLORS2.state.text,
|
|
2953
|
+
textAnchor: "middle",
|
|
2954
|
+
className: "text-[7px]",
|
|
2955
|
+
children: n.note
|
|
2956
|
+
}
|
|
2957
|
+
),
|
|
2791
2958
|
(() => {
|
|
2792
2959
|
let ix = n.pos.x + nw - 13;
|
|
2793
2960
|
const icons = [];
|