@rotorsoft/act-diagram 1.2.3 → 1.3.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/dist/.tsbuildinfo +1 -1
- package/dist/@types/cli/format.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
- package/dist/@types/client/types/domain-model.d.ts +2 -1
- package/dist/@types/client/types/domain-model.d.ts.map +1 -1
- package/dist/cli/act.js +22 -18
- package/dist/cli/act.js.map +1 -1
- package/dist/index.cjs +18 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -349,7 +349,10 @@ function build_state(model, st) {
|
|
|
349
349
|
const emits = raw_actions[`__emits_${action_name}`] ?? [];
|
|
350
350
|
const describe = (rule) => rule.description ?? "";
|
|
351
351
|
const invariants = (st.given?.[action_name] ?? []).map(describe);
|
|
352
|
-
const preconditions =
|
|
352
|
+
const preconditions = [
|
|
353
|
+
...invariants,
|
|
354
|
+
...(st.requires?.[action_name] ?? []).map(describe)
|
|
355
|
+
];
|
|
353
356
|
action_nodes.push({
|
|
354
357
|
name: action_name,
|
|
355
358
|
emits,
|
|
@@ -933,6 +936,12 @@ var InvariantError = class extends Error {
|
|
|
933
936
|
this.name = "InvariantError";
|
|
934
937
|
}
|
|
935
938
|
};
|
|
939
|
+
var PreconditionError = class extends InvariantError {
|
|
940
|
+
constructor(message) {
|
|
941
|
+
super(message);
|
|
942
|
+
this.name = "PreconditionError";
|
|
943
|
+
}
|
|
944
|
+
};
|
|
936
945
|
var crypto_mock = { randomUUID: () => "mock-uuid" };
|
|
937
946
|
var MODULES = {
|
|
938
947
|
"@rotorsoft/act": {
|
|
@@ -949,7 +958,8 @@ var MODULES = {
|
|
|
949
958
|
}),
|
|
950
959
|
dispose: () => () => Promise.resolve(),
|
|
951
960
|
ZodEmpty: import_zod.z.record(import_zod.z.string(), import_zod.z.never()),
|
|
952
|
-
InvariantError
|
|
961
|
+
InvariantError,
|
|
962
|
+
PreconditionError
|
|
953
963
|
},
|
|
954
964
|
zod: { z: import_zod.z, ...import_zod.z },
|
|
955
965
|
crypto: crypto_mock,
|
|
@@ -1374,7 +1384,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1374
1384
|
const desc_match = desc_re.exec(c);
|
|
1375
1385
|
if (desc_match) {
|
|
1376
1386
|
const before = c.slice(0, desc_match.index);
|
|
1377
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
|
|
1387
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*(?:Invariant|Precondition)[^=]*)?\s*=/g;
|
|
1378
1388
|
let last_decl = null;
|
|
1379
1389
|
let m;
|
|
1380
1390
|
while ((m = decl_re.exec(before)) !== null) {
|
|
@@ -1423,7 +1433,7 @@ function navigate_to_code(files, name, type, target_file) {
|
|
|
1423
1433
|
const desc_match = desc_re.exec(c);
|
|
1424
1434
|
if (desc_match) {
|
|
1425
1435
|
const before = c.slice(0, desc_match.index);
|
|
1426
|
-
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
|
|
1436
|
+
const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*(?:Invariant|Precondition)[^=]*)?\s*=/g;
|
|
1427
1437
|
let last_decl = null;
|
|
1428
1438
|
let m;
|
|
1429
1439
|
while ((m = decl_re.exec(before)) !== null) last_decl = m;
|
|
@@ -1556,7 +1566,7 @@ var import_react2 = require("react");
|
|
|
1556
1566
|
|
|
1557
1567
|
// src/client/lib/layout.ts
|
|
1558
1568
|
function rules_of(action) {
|
|
1559
|
-
const rules =
|
|
1569
|
+
const rules = action.preconditions ?? action.invariants;
|
|
1560
1570
|
return rules.length ? rules : void 0;
|
|
1561
1571
|
}
|
|
1562
1572
|
var W = 100;
|
|
@@ -2223,11 +2233,9 @@ function formatModelTree(model) {
|
|
|
2223
2233
|
if (!st) continue;
|
|
2224
2234
|
lines.push(` State: ${st.name}`);
|
|
2225
2235
|
for (const a of st.actions) {
|
|
2236
|
+
const rules = a.preconditions ?? a.invariants;
|
|
2226
2237
|
let line = ` ${a.name} \u2192 [${a.emits.join(", ")}]`;
|
|
2227
|
-
if (
|
|
2228
|
-
line += ` guards: [${a.invariants.join(", ")}]`;
|
|
2229
|
-
if (a.preconditions?.length)
|
|
2230
|
-
line += ` requires: [${a.preconditions.join(", ")}]`;
|
|
2238
|
+
if (rules.length) line += ` preconditions: [${rules.join(", ")}]`;
|
|
2231
2239
|
lines.push(line);
|
|
2232
2240
|
}
|
|
2233
2241
|
}
|
|
@@ -2478,7 +2486,7 @@ function Diagram({
|
|
|
2478
2486
|
title: "@rotorsoft/act-diagram version",
|
|
2479
2487
|
children: [
|
|
2480
2488
|
"v",
|
|
2481
|
-
"1.2.
|
|
2489
|
+
"1.2.4"
|
|
2482
2490
|
]
|
|
2483
2491
|
}
|
|
2484
2492
|
)
|