@rotorsoft/act-diagram 1.0.14 → 1.0.16

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/index.cjs CHANGED
@@ -688,6 +688,10 @@ function mock_state(entry, on_build) {
688
688
  // state from the parsed model.
689
689
  autocloses: () => action_builder(_currentAction),
690
690
  archives: () => action_builder(_currentAction),
691
+ // Disclosure predicate for `sensitive()` fields. Same reasoning as
692
+ // the close-policy methods above: the diagram doesn't render it, but
693
+ // the chain must survive or the whole state is dropped (#1394).
694
+ discloses: () => action_builder(_currentAction),
691
695
  build: () => {
692
696
  on_build?.(info);
693
697
  return info;
@@ -761,23 +765,34 @@ function mock_slice(on_build) {
761
765
  if (p) info.projections.push(p);
762
766
  return builder;
763
767
  },
768
+ // Lane declaration — the diagram doesn't render lanes, but the chain
769
+ // must survive or the slice is dropped (#1394).
770
+ withLane() {
771
+ return builder;
772
+ },
764
773
  on(event_name) {
774
+ const reaction_chain = (handler) => {
775
+ const dispatches = capture_dispatches(handler);
776
+ const reaction = {
777
+ event: event_name,
778
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
779
+ dispatches
780
+ };
781
+ info.reactions.push(reaction);
782
+ return {
783
+ ...builder,
784
+ to() {
785
+ return builder;
786
+ }
787
+ };
788
+ };
765
789
  return {
766
- do(handler) {
767
- const dispatches = capture_dispatches(handler);
768
- const reaction = {
769
- event: event_name,
770
- handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
771
- dispatches
772
- };
773
- info.reactions.push(reaction);
774
- return {
775
- ...builder,
776
- to() {
777
- return builder;
778
- }
779
- };
780
- }
790
+ // `.defer(...)` sits between `.on(...)` and `.do(...)`; it only
791
+ // schedules, so the reaction is still recorded by `.do`.
792
+ defer() {
793
+ return { do: reaction_chain };
794
+ },
795
+ do: reaction_chain
781
796
  };
782
797
  },
783
798
  build: () => {
@@ -794,6 +809,26 @@ function mock_projection(target, on_build) {
794
809
  handles: []
795
810
  };
796
811
  const builder = {
812
+ // State-projection (fold) form: `projection(n).of(State, ...).flush(fn)`.
813
+ // The folded state's own events are what the projection handles, so
814
+ // record them from each passed state — that is what makes the
815
+ // projection show up as a consumer of those events (#1394).
816
+ of(...states) {
817
+ for (const st of states) {
818
+ const events = st?.events;
819
+ if (events)
820
+ for (const name of Object.keys(events)) {
821
+ if (!info.handles.includes(name)) info.handles.push(name);
822
+ }
823
+ }
824
+ return builder;
825
+ },
826
+ flush() {
827
+ return builder;
828
+ },
829
+ batch() {
830
+ return builder;
831
+ },
797
832
  on(event_entry) {
798
833
  const event_name = Object.keys(event_entry)[0];
799
834
  info.handles.push(event_name);
@@ -838,6 +873,9 @@ function mock_act(on_build) {
838
873
  return builder;
839
874
  },
840
875
  withActor: () => builder,
876
+ // Lane declaration — not rendered, but the chain must survive or the
877
+ // whole orchestrator is dropped from the model (#1394).
878
+ withLane: () => builder,
841
879
  on(event_name) {
842
880
  return {
843
881
  do(handler) {
@@ -1004,12 +1042,46 @@ function resolve(imp, from_path, by_key) {
1004
1042
 
1005
1043
  // src/client/lib/evaluate.ts
1006
1044
  var strip_non_code = (src, level = "full") => {
1007
- const blank = (m) => m.replace(/[^\n]/g, " ");
1008
- let result = src.replace(/\/\/[^\n]*/g, blank).replace(/\/\*[\s\S]*?\*\//g, blank).replace(/`(?:\\[\s\S]|[^`\\])*`/g, blank);
1009
- if (level === "full") {
1010
- result = result.replace(/"(?:\\[\s\S]|[^"\\])*"/g, blank).replace(/'(?:\\[\s\S]|[^'\\])*'/g, blank);
1045
+ const strip_strings = level === "full";
1046
+ let out = "";
1047
+ let i = 0;
1048
+ const blank = (from, to) => {
1049
+ out += src.slice(from, to).replace(/[^\n]/g, " ");
1050
+ };
1051
+ while (i < src.length) {
1052
+ const c = src[i];
1053
+ const next = src[i + 1];
1054
+ if (c === "/" && next === "/") {
1055
+ const end = src.indexOf("\n", i);
1056
+ const stop = end === -1 ? src.length : end;
1057
+ blank(i, stop);
1058
+ i = stop;
1059
+ } else if (c === "/" && next === "*") {
1060
+ const end = src.indexOf("*/", i + 2);
1061
+ const stop = end === -1 ? src.length : end + 2;
1062
+ blank(i, stop);
1063
+ i = stop;
1064
+ } else if (c === "`" || c === '"' || c === "'") {
1065
+ let j = i + 1;
1066
+ while (j < src.length) {
1067
+ if (src[j] === "\\") {
1068
+ j += 2;
1069
+ continue;
1070
+ }
1071
+ if (src[j] === c) break;
1072
+ if (c !== "`" && src[j] === "\n") break;
1073
+ j++;
1074
+ }
1075
+ const stop = Math.min(j + 1, src.length);
1076
+ if (c === "`" || strip_strings) blank(i, stop);
1077
+ else out += src.slice(i, stop);
1078
+ i = stop;
1079
+ } else {
1080
+ out += c;
1081
+ i++;
1082
+ }
1011
1083
  }
1012
- return result;
1084
+ return out;
1013
1085
  };
1014
1086
  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/");
1015
1087
  function transpile(code) {
@@ -2385,7 +2457,7 @@ function Diagram({
2385
2457
  title: "@rotorsoft/act-diagram version",
2386
2458
  children: [
2387
2459
  "v",
2388
- "1.0.13"
2460
+ "1.0.15"
2389
2461
  ]
2390
2462
  }
2391
2463
  )