@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.js CHANGED
@@ -656,6 +656,10 @@ function mock_state(entry, on_build) {
656
656
  // state from the parsed model.
657
657
  autocloses: () => action_builder(_currentAction),
658
658
  archives: () => action_builder(_currentAction),
659
+ // Disclosure predicate for `sensitive()` fields. Same reasoning as
660
+ // the close-policy methods above: the diagram doesn't render it, but
661
+ // the chain must survive or the whole state is dropped (#1394).
662
+ discloses: () => action_builder(_currentAction),
659
663
  build: () => {
660
664
  on_build?.(info);
661
665
  return info;
@@ -729,23 +733,34 @@ function mock_slice(on_build) {
729
733
  if (p) info.projections.push(p);
730
734
  return builder;
731
735
  },
736
+ // Lane declaration — the diagram doesn't render lanes, but the chain
737
+ // must survive or the slice is dropped (#1394).
738
+ withLane() {
739
+ return builder;
740
+ },
732
741
  on(event_name) {
742
+ const reaction_chain = (handler) => {
743
+ const dispatches = capture_dispatches(handler);
744
+ const reaction = {
745
+ event: event_name,
746
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
747
+ dispatches
748
+ };
749
+ info.reactions.push(reaction);
750
+ return {
751
+ ...builder,
752
+ to() {
753
+ return builder;
754
+ }
755
+ };
756
+ };
733
757
  return {
734
- do(handler) {
735
- const dispatches = capture_dispatches(handler);
736
- const reaction = {
737
- event: event_name,
738
- handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
739
- dispatches
740
- };
741
- info.reactions.push(reaction);
742
- return {
743
- ...builder,
744
- to() {
745
- return builder;
746
- }
747
- };
748
- }
758
+ // `.defer(...)` sits between `.on(...)` and `.do(...)`; it only
759
+ // schedules, so the reaction is still recorded by `.do`.
760
+ defer() {
761
+ return { do: reaction_chain };
762
+ },
763
+ do: reaction_chain
749
764
  };
750
765
  },
751
766
  build: () => {
@@ -762,6 +777,26 @@ function mock_projection(target, on_build) {
762
777
  handles: []
763
778
  };
764
779
  const builder = {
780
+ // State-projection (fold) form: `projection(n).of(State, ...).flush(fn)`.
781
+ // The folded state's own events are what the projection handles, so
782
+ // record them from each passed state — that is what makes the
783
+ // projection show up as a consumer of those events (#1394).
784
+ of(...states) {
785
+ for (const st of states) {
786
+ const events = st?.events;
787
+ if (events)
788
+ for (const name of Object.keys(events)) {
789
+ if (!info.handles.includes(name)) info.handles.push(name);
790
+ }
791
+ }
792
+ return builder;
793
+ },
794
+ flush() {
795
+ return builder;
796
+ },
797
+ batch() {
798
+ return builder;
799
+ },
765
800
  on(event_entry) {
766
801
  const event_name = Object.keys(event_entry)[0];
767
802
  info.handles.push(event_name);
@@ -806,6 +841,9 @@ function mock_act(on_build) {
806
841
  return builder;
807
842
  },
808
843
  withActor: () => builder,
844
+ // Lane declaration — not rendered, but the chain must survive or the
845
+ // whole orchestrator is dropped from the model (#1394).
846
+ withLane: () => builder,
809
847
  on(event_name) {
810
848
  return {
811
849
  do(handler) {
@@ -972,12 +1010,46 @@ function resolve(imp, from_path, by_key) {
972
1010
 
973
1011
  // src/client/lib/evaluate.ts
974
1012
  var strip_non_code = (src, level = "full") => {
975
- const blank = (m) => m.replace(/[^\n]/g, " ");
976
- let result = src.replace(/\/\/[^\n]*/g, blank).replace(/\/\*[\s\S]*?\*\//g, blank).replace(/`(?:\\[\s\S]|[^`\\])*`/g, blank);
977
- if (level === "full") {
978
- result = result.replace(/"(?:\\[\s\S]|[^"\\])*"/g, blank).replace(/'(?:\\[\s\S]|[^'\\])*'/g, blank);
1013
+ const strip_strings = level === "full";
1014
+ let out = "";
1015
+ let i = 0;
1016
+ const blank = (from, to) => {
1017
+ out += src.slice(from, to).replace(/[^\n]/g, " ");
1018
+ };
1019
+ while (i < src.length) {
1020
+ const c = src[i];
1021
+ const next = src[i + 1];
1022
+ if (c === "/" && next === "/") {
1023
+ const end = src.indexOf("\n", i);
1024
+ const stop = end === -1 ? src.length : end;
1025
+ blank(i, stop);
1026
+ i = stop;
1027
+ } else if (c === "/" && next === "*") {
1028
+ const end = src.indexOf("*/", i + 2);
1029
+ const stop = end === -1 ? src.length : end + 2;
1030
+ blank(i, stop);
1031
+ i = stop;
1032
+ } else if (c === "`" || c === '"' || c === "'") {
1033
+ let j = i + 1;
1034
+ while (j < src.length) {
1035
+ if (src[j] === "\\") {
1036
+ j += 2;
1037
+ continue;
1038
+ }
1039
+ if (src[j] === c) break;
1040
+ if (c !== "`" && src[j] === "\n") break;
1041
+ j++;
1042
+ }
1043
+ const stop = Math.min(j + 1, src.length);
1044
+ if (c === "`" || strip_strings) blank(i, stop);
1045
+ else out += src.slice(i, stop);
1046
+ i = stop;
1047
+ } else {
1048
+ out += c;
1049
+ i++;
1050
+ }
979
1051
  }
980
- return result;
1052
+ return out;
981
1053
  };
982
1054
  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/");
983
1055
  function transpile(code) {
@@ -2361,7 +2433,7 @@ function Diagram({
2361
2433
  title: "@rotorsoft/act-diagram version",
2362
2434
  children: [
2363
2435
  "v",
2364
- "1.0.13"
2436
+ "1.0.15"
2365
2437
  ]
2366
2438
  }
2367
2439
  )