@rotorsoft/act-diagram 1.0.14 → 1.0.15
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/contract-index.d.ts +23 -1
- package/dist/@types/cli/contract-index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/@types/client/lib/evaluate.d.ts +10 -1
- package/dist/@types/client/lib/evaluate.d.ts.map +1 -1
- package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
- package/dist/cli/act.js +140 -36
- package/dist/cli/act.js.map +1 -1
- package/dist/index.cjs +93 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -21
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -24,8 +24,30 @@ export type ContractIndex = {
|
|
|
24
24
|
model: DomainModel;
|
|
25
25
|
/** All event names that appear anywhere in the model. */
|
|
26
26
|
all_event_names: Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Event names declared by each state, keyed by state name. Deprecation
|
|
29
|
+
* is a per-state property — event names are per-state-namespaced, so two
|
|
30
|
+
* unrelated states may legally share a base name — and classifying over
|
|
31
|
+
* the global set reported one state's event as superseded by another's
|
|
32
|
+
* (#1393, the CLI twin of #1310).
|
|
33
|
+
*/
|
|
34
|
+
events_by_state: Map<string, Set<string>>;
|
|
27
35
|
};
|
|
28
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The event-name set deprecation should be classified within: the owning
|
|
38
|
+
* state's own events when known, the global set otherwise (an event
|
|
39
|
+
* reached only through a reaction or projection has no owning state here).
|
|
40
|
+
*/
|
|
41
|
+
export declare function event_names_for(idx: ContractIndex, state?: string): Set<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Strip `_v<digits>` suffix and return logical (base, version).
|
|
44
|
+
*
|
|
45
|
+
* Only `v >= 2` counts as a version, mirroring the framework
|
|
46
|
+
* (`event-versions.ts`): `Foo_v1` is a literal event name, since the base
|
|
47
|
+
* `Foo` is implicitly v1. Treating it as a version made the CLI report a
|
|
48
|
+
* current, emittable event as deprecated and tell operators to migrate
|
|
49
|
+
* off it (#1395).
|
|
50
|
+
*/
|
|
29
51
|
export declare function decompose_event_name(name: string): {
|
|
30
52
|
base: string;
|
|
31
53
|
version: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-index.d.ts","sourceRoot":"","sources":["../../../src/cli/contract-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,IAAI,GACZ,OAAO,GACP,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,OAAO,GACP,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,KAAK,EAAE,WAAW,CAAC;IACnB,yDAAyD;IACzD,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"contract-index.d.ts","sourceRoot":"","sources":["../../../src/cli/contract-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,IAAI,GACZ,OAAO,GACP,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,OAAO,GACP,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,KAAK,EAAE,WAAW,CAAC;IACnB,yDAAyD;IACzD,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B;;;;;;OAMG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,KAAK,CAAC,EAAE,MAAM,GACb,GAAG,CAAC,MAAM,CAAC,CAIb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAOA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,QAAQ,GAAG,YAAY,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC1B,WAAW,CAeb;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CA8EtE;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAalD,CAAC;AAEF,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,CAIzE;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,SAAK,GACT,UAAU,EAAE,CAoBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/cli/format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,OAAO,EACL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/cli/format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,OAAO,EACL,KAAK,aAAa,EAGlB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAiB7B,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAY3E;AAmFD,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAoE1E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAoC3E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CA8C1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAkC1E;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,GAChB,MAAM,CAWR;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAwC7E;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,CAQlD,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAG3E;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAazD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../../src/cli/json-schema.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../../src/cli/json-schema.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAkG7B;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,GACX;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAc5D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAqC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/cli/markdown.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/cli/markdown.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,qBAAqB,CAAC;AAoG7B,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAuN1D"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { DomainModel, FileTab } from "../types/index.js";
|
|
2
2
|
/** Replace non-executable content with same-length whitespace (preserving offsets).
|
|
3
3
|
* `level: "full"` strips comments + strings + template literals (for scanning).
|
|
4
|
-
* `level: "nav"` strips comments + template literals only (for navigation).
|
|
4
|
+
* `level: "nav"` strips comments + template literals only (for navigation).
|
|
5
|
+
*
|
|
6
|
+
* Single left-to-right pass rather than sequential regex replaces. The
|
|
7
|
+
* passes used to run comments-first, so a `//` inside a string literal
|
|
8
|
+
* ("https://host/path") was treated as a comment start: blanking to
|
|
9
|
+
* end-of-line truncated the literal, and the dangling quote then paired
|
|
10
|
+
* with the next quote in the file, blanking every line between. One URL
|
|
11
|
+
* could erase a whole slice declaration (#1391). Scanning once with the
|
|
12
|
+
* cursor's context tracked makes that structurally impossible, and it
|
|
13
|
+
* handles the mirror case (a quote inside a comment) for free. */
|
|
5
14
|
export declare const strip_non_code: (src: string, level?: "full" | "nav") => string;
|
|
6
15
|
export declare function extract_model(files: FileTab[]): {
|
|
7
16
|
model: DomainModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../../src/client/lib/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK9D
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../../src/client/lib/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK9D;;;;;;;;;;;mEAWmE;AACnE,eAAO,MAAM,cAAc,QAAS,MAAM,UAAS,MAAM,GAAG,KAAK,WA+ChE,CAAC;AAgOF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG;IAC/C,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAGA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-builders.d.ts","sourceRoot":"","sources":["../../../../src/client/lib/mock-builders.ts"],"names":[],"mappings":"AAQA,4FAA4F;AAC5F,wBAAgB,YAAY,SAAK;AA2DjC,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"mock-builders.d.ts","sourceRoot":"","sources":["../../../../src/client/lib/mock-builders.ts"],"names":[],"mappings":"AAQA,4FAA4F;AAC5F,wBAAgB,YAAY,SAAK;AA2DjC,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI;IAoD5B,IAAI,aAAa,GAAG;QAClB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;EAatC;AA4DD,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,OAuDxD;AAED,wBAAgB,eAAe,CAC7B,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,OAkD/B;AAED,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,OAmEtD;AAWD,+CAA+C;AAC/C,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoB3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmB9D"}
|
package/dist/cli/act.js
CHANGED
|
@@ -817,6 +817,10 @@ function mock_state(entry, on_build) {
|
|
|
817
817
|
// state from the parsed model.
|
|
818
818
|
autocloses: () => action_builder(_currentAction),
|
|
819
819
|
archives: () => action_builder(_currentAction),
|
|
820
|
+
// Disclosure predicate for `sensitive()` fields. Same reasoning as
|
|
821
|
+
// the close-policy methods above: the diagram doesn't render it, but
|
|
822
|
+
// the chain must survive or the whole state is dropped (#1394).
|
|
823
|
+
discloses: () => action_builder(_currentAction),
|
|
820
824
|
build: () => {
|
|
821
825
|
on_build?.(info);
|
|
822
826
|
return info;
|
|
@@ -890,23 +894,34 @@ function mock_slice(on_build) {
|
|
|
890
894
|
if (p) info.projections.push(p);
|
|
891
895
|
return builder;
|
|
892
896
|
},
|
|
897
|
+
// Lane declaration — the diagram doesn't render lanes, but the chain
|
|
898
|
+
// must survive or the slice is dropped (#1394).
|
|
899
|
+
withLane() {
|
|
900
|
+
return builder;
|
|
901
|
+
},
|
|
893
902
|
on(event_name) {
|
|
903
|
+
const reaction_chain = (handler) => {
|
|
904
|
+
const dispatches = capture_dispatches(handler);
|
|
905
|
+
const reaction = {
|
|
906
|
+
event: event_name,
|
|
907
|
+
handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
|
|
908
|
+
dispatches
|
|
909
|
+
};
|
|
910
|
+
info.reactions.push(reaction);
|
|
911
|
+
return {
|
|
912
|
+
...builder,
|
|
913
|
+
to() {
|
|
914
|
+
return builder;
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
};
|
|
894
918
|
return {
|
|
895
|
-
do(
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
};
|
|
902
|
-
info.reactions.push(reaction);
|
|
903
|
-
return {
|
|
904
|
-
...builder,
|
|
905
|
-
to() {
|
|
906
|
-
return builder;
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
}
|
|
919
|
+
// `.defer(...)` sits between `.on(...)` and `.do(...)`; it only
|
|
920
|
+
// schedules, so the reaction is still recorded by `.do`.
|
|
921
|
+
defer() {
|
|
922
|
+
return { do: reaction_chain };
|
|
923
|
+
},
|
|
924
|
+
do: reaction_chain
|
|
910
925
|
};
|
|
911
926
|
},
|
|
912
927
|
build: () => {
|
|
@@ -923,6 +938,26 @@ function mock_projection(target, on_build) {
|
|
|
923
938
|
handles: []
|
|
924
939
|
};
|
|
925
940
|
const builder = {
|
|
941
|
+
// State-projection (fold) form: `projection(n).of(State, ...).flush(fn)`.
|
|
942
|
+
// The folded state's own events are what the projection handles, so
|
|
943
|
+
// record them from each passed state — that is what makes the
|
|
944
|
+
// projection show up as a consumer of those events (#1394).
|
|
945
|
+
of(...states) {
|
|
946
|
+
for (const st of states) {
|
|
947
|
+
const events = st?.events;
|
|
948
|
+
if (events)
|
|
949
|
+
for (const name of Object.keys(events)) {
|
|
950
|
+
if (!info.handles.includes(name)) info.handles.push(name);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
return builder;
|
|
954
|
+
},
|
|
955
|
+
flush() {
|
|
956
|
+
return builder;
|
|
957
|
+
},
|
|
958
|
+
batch() {
|
|
959
|
+
return builder;
|
|
960
|
+
},
|
|
926
961
|
on(event_entry) {
|
|
927
962
|
const event_name = Object.keys(event_entry)[0];
|
|
928
963
|
info.handles.push(event_name);
|
|
@@ -967,6 +1002,9 @@ function mock_act(on_build) {
|
|
|
967
1002
|
return builder;
|
|
968
1003
|
},
|
|
969
1004
|
withActor: () => builder,
|
|
1005
|
+
// Lane declaration — not rendered, but the chain must survive or the
|
|
1006
|
+
// whole orchestrator is dropped from the model (#1394).
|
|
1007
|
+
withLane: () => builder,
|
|
970
1008
|
on(event_name) {
|
|
971
1009
|
return {
|
|
972
1010
|
do(handler) {
|
|
@@ -1133,12 +1171,46 @@ function resolve(imp, from_path, by_key) {
|
|
|
1133
1171
|
|
|
1134
1172
|
// src/client/lib/evaluate.ts
|
|
1135
1173
|
var strip_non_code = (src, level = "full") => {
|
|
1136
|
-
const
|
|
1137
|
-
let
|
|
1138
|
-
|
|
1139
|
-
|
|
1174
|
+
const strip_strings = level === "full";
|
|
1175
|
+
let out = "";
|
|
1176
|
+
let i2 = 0;
|
|
1177
|
+
const blank = (from, to) => {
|
|
1178
|
+
out += src.slice(from, to).replace(/[^\n]/g, " ");
|
|
1179
|
+
};
|
|
1180
|
+
while (i2 < src.length) {
|
|
1181
|
+
const c2 = src[i2];
|
|
1182
|
+
const next = src[i2 + 1];
|
|
1183
|
+
if (c2 === "/" && next === "/") {
|
|
1184
|
+
const end = src.indexOf("\n", i2);
|
|
1185
|
+
const stop = end === -1 ? src.length : end;
|
|
1186
|
+
blank(i2, stop);
|
|
1187
|
+
i2 = stop;
|
|
1188
|
+
} else if (c2 === "/" && next === "*") {
|
|
1189
|
+
const end = src.indexOf("*/", i2 + 2);
|
|
1190
|
+
const stop = end === -1 ? src.length : end + 2;
|
|
1191
|
+
blank(i2, stop);
|
|
1192
|
+
i2 = stop;
|
|
1193
|
+
} else if (c2 === "`" || c2 === '"' || c2 === "'") {
|
|
1194
|
+
let j = i2 + 1;
|
|
1195
|
+
while (j < src.length) {
|
|
1196
|
+
if (src[j] === "\\") {
|
|
1197
|
+
j += 2;
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
if (src[j] === c2) break;
|
|
1201
|
+
if (c2 !== "`" && src[j] === "\n") break;
|
|
1202
|
+
j++;
|
|
1203
|
+
}
|
|
1204
|
+
const stop = Math.min(j + 1, src.length);
|
|
1205
|
+
if (c2 === "`" || strip_strings) blank(i2, stop);
|
|
1206
|
+
else out += src.slice(i2, stop);
|
|
1207
|
+
i2 = stop;
|
|
1208
|
+
} else {
|
|
1209
|
+
out += c2;
|
|
1210
|
+
i2++;
|
|
1211
|
+
}
|
|
1140
1212
|
}
|
|
1141
|
-
return
|
|
1213
|
+
return out;
|
|
1142
1214
|
};
|
|
1143
1215
|
var is_source_file = (f) => f.path.endsWith(".ts") && !f.path.endsWith(".d.ts") && !f.path.endsWith(".tsx") && !f.path.endsWith(".spec.ts") && !f.path.endsWith(".test.ts") && !f.path.includes("node_modules/") && !f.path.includes("__tests__/") && !f.path.includes("/test/") && !f.path.startsWith("test/");
|
|
1144
1216
|
function transpile(code) {
|
|
@@ -1288,9 +1360,15 @@ function extract_model(files) {
|
|
|
1288
1360
|
}
|
|
1289
1361
|
|
|
1290
1362
|
// src/cli/contract-index.ts
|
|
1363
|
+
function event_names_for(idx, state) {
|
|
1364
|
+
return (state ? idx.events_by_state.get(state) : void 0) ?? idx.all_event_names;
|
|
1365
|
+
}
|
|
1291
1366
|
function decompose_event_name(name) {
|
|
1292
1367
|
const m = name.match(/^(.+)_v(\d+)$/);
|
|
1293
|
-
if (m)
|
|
1368
|
+
if (m) {
|
|
1369
|
+
const version = Number.parseInt(m[2], 10);
|
|
1370
|
+
if (version >= 2) return { base: m[1], version };
|
|
1371
|
+
}
|
|
1294
1372
|
return { base: name, version: 1 };
|
|
1295
1373
|
}
|
|
1296
1374
|
function event_status(name, all_names) {
|
|
@@ -1310,6 +1388,7 @@ function event_status(name, all_names) {
|
|
|
1310
1388
|
function build_contract_index(model) {
|
|
1311
1389
|
const entries = [];
|
|
1312
1390
|
const all_event_names = /* @__PURE__ */ new Set();
|
|
1391
|
+
const events_by_state = /* @__PURE__ */ new Map();
|
|
1313
1392
|
for (const st of model.states) {
|
|
1314
1393
|
entries.push({
|
|
1315
1394
|
kind: "state",
|
|
@@ -1317,8 +1396,14 @@ function build_contract_index(model) {
|
|
|
1317
1396
|
file: st.file,
|
|
1318
1397
|
line: st.line
|
|
1319
1398
|
});
|
|
1399
|
+
let own = events_by_state.get(st.name);
|
|
1400
|
+
if (!own) {
|
|
1401
|
+
own = /* @__PURE__ */ new Set();
|
|
1402
|
+
events_by_state.set(st.name, own);
|
|
1403
|
+
}
|
|
1320
1404
|
for (const ev of st.events) {
|
|
1321
1405
|
all_event_names.add(ev.name);
|
|
1406
|
+
own.add(ev.name);
|
|
1322
1407
|
entries.push({
|
|
1323
1408
|
kind: "event",
|
|
1324
1409
|
name: ev.name,
|
|
@@ -1374,7 +1459,7 @@ function build_contract_index(model) {
|
|
|
1374
1459
|
line: r2.line
|
|
1375
1460
|
});
|
|
1376
1461
|
}
|
|
1377
|
-
return { entries, model, all_event_names };
|
|
1462
|
+
return { entries, model, all_event_names, events_by_state };
|
|
1378
1463
|
}
|
|
1379
1464
|
var CATEGORY_KEYWORDS = {
|
|
1380
1465
|
event: "event",
|
|
@@ -1525,7 +1610,10 @@ function format_event(idx, entry) {
|
|
|
1525
1610
|
}
|
|
1526
1611
|
}
|
|
1527
1612
|
const file = entry.file ?? owning_state?.file;
|
|
1528
|
-
const status = event_status(
|
|
1613
|
+
const status = event_status(
|
|
1614
|
+
entry.name,
|
|
1615
|
+
event_names_for(idx, entry.qualifier)
|
|
1616
|
+
);
|
|
1529
1617
|
const status_line = status.status === "active" ? green("active") : (
|
|
1530
1618
|
// `superseded_by` is always set on deprecated entries — see event_status.
|
|
1531
1619
|
`${red("deprecated")} (superseded by ${orange(status.superseded_by)})`
|
|
@@ -1603,23 +1691,39 @@ function format_action(idx, entry) {
|
|
|
1603
1691
|
return lines.join("\n");
|
|
1604
1692
|
}
|
|
1605
1693
|
function format_state(idx, entry) {
|
|
1606
|
-
const
|
|
1694
|
+
const partials = idx.model.states.filter((s) => s.name === entry.name);
|
|
1607
1695
|
const lines = [];
|
|
1608
1696
|
lines.push(bold(amber(entry.name)));
|
|
1609
|
-
|
|
1610
|
-
if (
|
|
1611
|
-
|
|
1697
|
+
const files = [...new Set(partials.map((s) => s.file).filter(Boolean))];
|
|
1698
|
+
if (files.length > 1) {
|
|
1699
|
+
lines.push(" in:");
|
|
1700
|
+
for (const f of files) lines.push(` - ${dim(loc(f))}`);
|
|
1701
|
+
} else {
|
|
1702
|
+
const file = files[0] ?? entry.file;
|
|
1703
|
+
if (file) lines.push(` in: ${dim(loc(file, entry.line))}`);
|
|
1704
|
+
}
|
|
1705
|
+
if (!partials.length) return lines.join("\n");
|
|
1706
|
+
const show_file = files.length > 1;
|
|
1707
|
+
const actions = partials.flatMap(
|
|
1708
|
+
(s) => s.actions.map((a2) => ({ node: a2, file: s.file }))
|
|
1709
|
+
);
|
|
1710
|
+
if (actions.length > 0) {
|
|
1612
1711
|
lines.push(" actions:");
|
|
1613
|
-
for (const
|
|
1614
|
-
const emits =
|
|
1615
|
-
|
|
1712
|
+
for (const { node, file } of actions) {
|
|
1713
|
+
const emits = node.emits.length > 0 ? ` \u2192 ${node.emits.join(", ")}` : "";
|
|
1714
|
+
const where = show_file && file ? ` ${dim(loc(file, node.line))}` : "";
|
|
1715
|
+
lines.push(` - ${pink(node.name)}${emits}${where}`);
|
|
1616
1716
|
}
|
|
1617
1717
|
}
|
|
1618
|
-
|
|
1718
|
+
const events = partials.flatMap(
|
|
1719
|
+
(s) => s.events.map((e) => ({ node: e, file: s.file }))
|
|
1720
|
+
);
|
|
1721
|
+
if (events.length > 0) {
|
|
1619
1722
|
lines.push(" events:");
|
|
1620
|
-
for (const
|
|
1621
|
-
const schema =
|
|
1622
|
-
|
|
1723
|
+
for (const { node, file } of events) {
|
|
1724
|
+
const schema = node.schema ? ` ${dim(node.schema)}` : "";
|
|
1725
|
+
const where = show_file && file ? ` ${dim(loc(file, node.line))}` : "";
|
|
1726
|
+
lines.push(` - ${orange(node.name)}${schema}${where}`);
|
|
1623
1727
|
}
|
|
1624
1728
|
}
|
|
1625
1729
|
return lines.join("\n");
|
|
@@ -1787,7 +1891,7 @@ function format_json_schema(idx) {
|
|
|
1787
1891
|
const events = {};
|
|
1788
1892
|
for (const st of m.states) {
|
|
1789
1893
|
for (const ev of st.events) {
|
|
1790
|
-
const status = event_status(ev.name, idx.
|
|
1894
|
+
const status = event_status(ev.name, event_names_for(idx, st.name));
|
|
1791
1895
|
const conv = toJsonSchemaSafe(ev.zod);
|
|
1792
1896
|
const report = {
|
|
1793
1897
|
name: ev.name,
|
|
@@ -1976,7 +2080,7 @@ function format_markdown(idx) {
|
|
|
1976
2080
|
break;
|
|
1977
2081
|
}
|
|
1978
2082
|
}
|
|
1979
|
-
const status = event_status(e.name, idx
|
|
2083
|
+
const status = event_status(e.name, event_names_for(idx, owning_state));
|
|
1980
2084
|
const status_label = status.status === "active" ? "active" : `deprecated \u2014 superseded by **${status.superseded_by}**`;
|
|
1981
2085
|
lines.push(`### \`${e.name}\``);
|
|
1982
2086
|
if (e.file) lines.push(`- **defined in:** \`${loc2(e.file, e.line)}\``);
|