sysml-diagram 0.27.0 → 0.27.1

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/out/main.js CHANGED
@@ -167715,11 +167715,12 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167715
167715
  };
167716
167716
  const ownStates = (holder) => membersOf(holder).map((member) => this.thenActionMemberNode(member) ?? member).filter((member) => isStateDecl(member) && nameOf2(member) !== void 0);
167717
167717
  const nestedStates = (holder) => {
167718
- const out = ownStates(holder);
167718
+ const out = ownStates(holder).map((node) => ({ node, borrowed: false }));
167719
167719
  const def = definitionOf(holder);
167720
167720
  for (const inherited of def ? ownStates(def) : []) {
167721
- if (!out.some((m) => nameOf2(m) === nameOf2(inherited)))
167722
- out.push(inherited);
167721
+ if (!out.some((m) => nameOf2(m.node) === nameOf2(inherited))) {
167722
+ out.push({ node: inherited, borrowed: true });
167723
+ }
167723
167724
  }
167724
167725
  return out;
167725
167726
  };
@@ -167769,8 +167770,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167769
167770
  namesByFrame.set(key, created);
167770
167771
  return created;
167771
167772
  };
167772
- const renderState = (s, parentFrame, depth, seen) => {
167773
- const id2 = qnameOf(s) || nameOf2(s);
167773
+ const scopedId = (scope2, name) => `${scope2}::${name}`;
167774
+ const machineScopeId = anchorFrameId ?? qnameOf(anchor) ?? nameOf2(anchor) ?? "__stv__";
167775
+ const renderState = (s, parentFrame, depth, seen, scope2, borrowed) => {
167776
+ const id2 = borrowed ? scopedId(scope2, nameOf2(s)) : qnameOf(s) || nameOf2(s);
167774
167777
  byName.set(nameOf2(s), id2);
167775
167778
  namesIn(parentFrame).set(nameOf2(s), id2);
167776
167779
  registerDrawn(s);
@@ -167791,10 +167794,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167791
167794
  meta: { composite: true, ...isParallel ? { parallel: true } : {} },
167792
167795
  source: sourceOf2(s, uri)
167793
167796
  });
167794
- compositeFrames.push({ state: s, frameId: id2 });
167797
+ compositeFrames.push({ state: s, frameId: id2, borrowed });
167795
167798
  const next = typeQ ? /* @__PURE__ */ new Set([...seen, typeQ]) : seen;
167796
167799
  for (const ss of subStates)
167797
- renderState(ss, id2, depth + 1, next);
167800
+ renderState(ss.node, id2, depth + 1, next, id2, borrowed || ss.borrowed);
167798
167801
  } else {
167799
167802
  nodes.push({
167800
167803
  id: id2,
@@ -167809,8 +167812,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167809
167812
  });
167810
167813
  }
167811
167814
  };
167812
- for (const s of topStates)
167813
- renderState(s, anchorFrameId, 0, /* @__PURE__ */ new Set());
167815
+ for (const s of topStates) {
167816
+ renderState(s.node, anchorFrameId, 0, /* @__PURE__ */ new Set(), machineScopeId, s.borrowed);
167817
+ }
167814
167818
  const endpointName = (path10) => typeof path10 === "string" ? path10.split(/::|\./).pop() || void 0 : void 0;
167815
167819
  const controlNodeInfo = (m) => {
167816
167820
  switch (m.$type) {
@@ -167844,10 +167848,11 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167844
167848
  const entry = member;
167845
167849
  return !!entry && entry.$type === "EntryAction" && !entry.name && !entry.actionKw && !entry.send && !entry.accept && !entry.assign;
167846
167850
  };
167847
- const machineNodeIds = /* @__PURE__ */ new Map();
167851
+ const machineNodesByFrame = /* @__PURE__ */ new Map();
167852
+ const machineNodeIdIn = (frameId, member) => machineNodesByFrame.get(frameId ?? "")?.get(member);
167848
167853
  const machineNodeMembers = [];
167849
167854
  let anonymousNodes = 0;
167850
- const emitMachineNodes = (holder, frameId) => {
167855
+ const emitMachineNodes = (holder, frameId, borrowed) => {
167851
167856
  const members = membersOf(holder);
167852
167857
  const drawnHere = namesIn(frameId);
167853
167858
  for (const raw of members) {
@@ -167858,7 +167863,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167858
167863
  const name = nameOf2(member);
167859
167864
  if (name && drawnHere.has(name))
167860
167865
  continue;
167861
- const id2 = name ? qnameOf(member) || `${frameId}::${name}` : `${frameId}::__stv_${member.$type}_${anonymousNodes++}__`;
167866
+ const id2 = name ? borrowed ? scopedId(frameId, name) : qnameOf(member) || scopedId(frameId, name) : `${frameId}::__stv_${member.$type}_${anonymousNodes++}__`;
167862
167867
  if (nodes.some((n2) => n2.id === id2) || frames.some((f) => f.id === id2))
167863
167868
  continue;
167864
167869
  if (name) {
@@ -167866,7 +167871,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167866
167871
  if (!byName.has(name))
167867
167872
  byName.set(name, id2);
167868
167873
  }
167869
- machineNodeIds.set(member, id2);
167874
+ const frameNodes = machineNodesByFrame.get(frameId) ?? /* @__PURE__ */ new Map();
167875
+ frameNodes.set(member, id2);
167876
+ machineNodesByFrame.set(frameId, frameNodes);
167870
167877
  machineNodeMembers.push({ member, id: id2 });
167871
167878
  nodes.push({
167872
167879
  id: id2,
@@ -167882,17 +167889,28 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167882
167889
  };
167883
167890
  const edges = [];
167884
167891
  let e = 0;
167892
+ const finalIn = (frameId) => {
167893
+ const own = frameId && frameId !== anchorFrameId;
167894
+ const id2 = own ? `__final__${frameId}` : "__final__";
167895
+ if (!nodes.some((n2) => n2.id === id2)) {
167896
+ nodes.push({
167897
+ id: id2,
167898
+ name: "",
167899
+ keyword: "final",
167900
+ isDef: false,
167901
+ shape: "final",
167902
+ frame: own ? frameId : anchorFrameId
167903
+ });
167904
+ }
167905
+ return id2;
167906
+ };
167885
167907
  const resolveState = (nm) => {
167886
167908
  if (!nm)
167887
167909
  return void 0;
167888
167910
  if (byName.has(nm))
167889
167911
  return byName.get(nm);
167890
- if (nm === "done") {
167891
- if (!nodes.some((n2) => n2.shape === "final")) {
167892
- nodes.push({ id: "__final__", name: "", keyword: "final", isDef: false, shape: "final", frame: anchorFrameId });
167893
- }
167894
- return "__final__";
167895
- }
167912
+ if (nm === "done")
167913
+ return finalIn(anchorFrameId);
167896
167914
  return void 0;
167897
167915
  };
167898
167916
  const drawnEdges = /* @__PURE__ */ new Set();
@@ -167929,15 +167947,14 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167929
167947
  return void 0;
167930
167948
  const short = endpointName(path10);
167931
167949
  const local = namesByFrame.get(frameId ?? "");
167932
- return (short ? local?.get(short) : void 0) ?? resolveState(path10) ?? resolveState(short) ?? (short === "start" ? initialId : void 0);
167950
+ const known2 = short ? local?.get(short) : void 0;
167951
+ if (known2)
167952
+ return known2;
167953
+ if (short === "done")
167954
+ return finalIn(frameId);
167955
+ return resolveState(path10) ?? resolveState(short) ?? (short === "start" ? initialId : void 0);
167933
167956
  };
167934
167957
  const transitionScope = [anchor, ...definitionOf(anchor) ? [definitionOf(anchor)] : []];
167935
- for (const t of transitionScope.flatMap((holder) => [...ast_utils_exports.streamAllContents(holder)])) {
167936
- if (t.$type !== "TransitionDecl")
167937
- continue;
167938
- const tn = t;
167939
- link(resolveState(tn.from), resolveState(tn.to), this.transitionLabel(t), t);
167940
- }
167941
167958
  const designatedInitial = (owner, frameId) => {
167942
167959
  const members = owner.members;
167943
167960
  if (!Array.isArray(members))
@@ -167960,7 +167977,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167960
167977
  const then = members[i + 1];
167961
167978
  if (then?.$type !== "ThenActionMember" || typeof then.target !== "string")
167962
167979
  continue;
167963
- const target = resolveState(lastSeg(then.target));
167980
+ const target = resolveEndpoint(then.target, void 0, frameId);
167964
167981
  if (target) {
167965
167982
  registerDrawn(then);
167966
167983
  return target;
@@ -167968,35 +167985,66 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167968
167985
  }
167969
167986
  return void 0;
167970
167987
  };
167971
- const machineScope = (holder) => {
167988
+ const machineScope = (holder, borrowed) => {
167972
167989
  const def = definitionOf(holder);
167973
- return def ? [holder, def] : [holder];
167990
+ return def ? [{ holder, borrowed }, { holder: def, borrowed: true }] : [{ holder, borrowed }];
167974
167991
  };
167975
167992
  if (anchorFrameId) {
167976
- for (const holder of machineScope(anchor))
167977
- emitMachineNodes(holder, anchorFrameId);
167993
+ for (const scope2 of machineScope(anchor, false)) {
167994
+ emitMachineNodes(scope2.holder, anchorFrameId, scope2.borrowed);
167995
+ }
167978
167996
  }
167979
- for (const { state, frameId } of compositeFrames) {
167980
- for (const holder of machineScope(state))
167981
- emitMachineNodes(holder, frameId);
167997
+ for (const { state, frameId, borrowed } of compositeFrames) {
167998
+ for (const scope2 of machineScope(state, borrowed)) {
167999
+ emitMachineNodes(scope2.holder, frameId, scope2.borrowed);
168000
+ }
167982
168001
  }
167983
168002
  const anchorDefinition = definitionOf(anchor);
167984
- const firstStateId = designatedInitial(anchor, anchorFrameId) ?? (anchorDefinition ? designatedInitial(anchorDefinition, anchorFrameId) : void 0) ?? (topStates.length ? byName.get(nameOf2(topStates[0])) : void 0);
168003
+ const firstStateId = designatedInitial(anchor, anchorFrameId) ?? (anchorDefinition ? designatedInitial(anchorDefinition, anchorFrameId) : void 0) ?? (topStates.length ? namesIn(anchorFrameId).get(nameOf2(topStates[0].node)) ?? byName.get(nameOf2(topStates[0].node)) : void 0);
167985
168004
  if (firstStateId)
167986
168005
  link("__initial__", firstStateId, void 0, void 0);
167987
168006
  const compositeInitial = /* @__PURE__ */ new Map();
167988
- for (const { state, frameId } of compositeFrames) {
167989
- const target = designatedInitial(state, frameId);
168007
+ for (const { state, frameId, borrowed } of compositeFrames) {
168008
+ let target;
168009
+ for (const scope2 of machineScope(state, borrowed)) {
168010
+ target = designatedInitial(scope2.holder, frameId);
168011
+ if (target)
168012
+ break;
168013
+ }
167990
168014
  if (!target)
167991
168015
  continue;
167992
168016
  const id2 = `__initial__${frameId}`;
167993
168017
  nodes.push({ id: id2, name: "", keyword: "initial", isDef: false, shape: "initial", frame: frameId });
167994
- compositeInitial.set(state, id2);
168018
+ compositeInitial.set(frameId, id2);
167995
168019
  link(id2, target, void 0, void 0);
167996
168020
  }
168021
+ const framedTransitions = /* @__PURE__ */ new Set();
168022
+ const declaredTransitions = (holder, frameId) => {
168023
+ for (const member of membersOf(holder)) {
168024
+ if (member.$type !== "TransitionDecl")
168025
+ continue;
168026
+ framedTransitions.add(member);
168027
+ const tn = member;
168028
+ link(resolveEndpoint(tn.from, void 0, frameId), resolveEndpoint(tn.to, void 0, frameId), this.transitionLabel(member), member);
168029
+ }
168030
+ };
168031
+ for (const scope2 of machineScope(anchor, false)) {
168032
+ declaredTransitions(scope2.holder, anchorFrameId);
168033
+ }
168034
+ for (const { state, frameId, borrowed } of compositeFrames) {
168035
+ for (const scope2 of machineScope(state, borrowed)) {
168036
+ declaredTransitions(scope2.holder, frameId);
168037
+ }
168038
+ }
168039
+ for (const t of transitionScope.flatMap((holder) => [...ast_utils_exports.streamAllContents(holder)])) {
168040
+ if (t.$type !== "TransitionDecl" || framedTransitions.has(t))
168041
+ continue;
168042
+ const tn = t;
168043
+ link(resolveState(tn.from), resolveState(tn.to), this.transitionLabel(t), t);
168044
+ }
167997
168045
  const sequentialTransitions = (holder, initialId, frameId) => {
167998
168046
  let cursor;
167999
- const idOf = (member) => machineNodeIds.get(member) ?? idByState.get(member) ?? (nameOf2(member) ? resolveEndpoint(nameOf2(member), void 0, frameId) : void 0);
168047
+ const idOf = (member) => machineNodeIdIn(frameId, member) ?? (nameOf2(member) ? resolveEndpoint(nameOf2(member), void 0, frameId) : void 0) ?? idByState.get(member);
168000
168048
  const endpoint = (path10) => resolveEndpoint(path10, initialId, frameId);
168001
168049
  for (const member of membersOf(holder)) {
168002
168050
  switch (member.$type) {
@@ -168011,7 +168059,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
168011
168059
  cursor = initialId;
168012
168060
  break;
168013
168061
  }
168014
- cursor = machineNodeIds.get(member) ?? cursor;
168062
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
168015
168063
  break;
168016
168064
  }
168017
168065
  // OMG 8.2.3.18 names this edge `st-succession`, so the
@@ -168077,18 +168125,18 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
168077
168125
  break;
168078
168126
  }
168079
168127
  default: {
168080
- cursor = machineNodeIds.get(member) ?? cursor;
168128
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
168081
168129
  break;
168082
168130
  }
168083
168131
  }
168084
168132
  }
168085
168133
  };
168086
- for (const holder of machineScope(anchor)) {
168087
- sequentialTransitions(holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168134
+ for (const scope2 of machineScope(anchor, false)) {
168135
+ sequentialTransitions(scope2.holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168088
168136
  }
168089
- for (const { state, frameId } of compositeFrames) {
168090
- for (const holder of machineScope(state)) {
168091
- sequentialTransitions(holder, compositeInitial.get(state), frameId);
168137
+ for (const { state, frameId, borrowed } of compositeFrames) {
168138
+ for (const scope2 of machineScope(state, borrowed)) {
168139
+ sequentialTransitions(scope2.holder, compositeInitial.get(frameId), frameId);
168092
168140
  }
168093
168141
  }
168094
168142
  const exhibitorsByState = /* @__PURE__ */ new Map();
@@ -205126,7 +205174,7 @@ async function runExport(command) {
205126
205174
  }
205127
205175
 
205128
205176
  // src/main.ts
205129
- var VERSION2 = true ? "0.27.0" : "dev";
205177
+ var VERSION2 = true ? "0.27.1" : "dev";
205130
205178
  function display(file) {
205131
205179
  const rel2 = path9.relative(process.cwd(), file);
205132
205180
  return rel2 && !rel2.startsWith("..") ? rel2.split(path9.sep).join("/") : file;