sysml-diagram 0.27.0 → 0.28.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/out/main.js CHANGED
@@ -164070,7 +164070,6 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
164070
164070
  ...packageOverview && hasOwnedMemberNode && isPackage(scope) && nameOf2(scope) ? [scope] : [],
164071
164071
  ...all.filter((p) => isPackage(p) && nameOf2(p))
164072
164072
  ];
164073
- const packagesInScope = [scope, ...all.filter(isPackage)];
164074
164073
  const packageNodeSet = new Set(packageNodes);
164075
164074
  const containingDrawnPackage = (node) => {
164076
164075
  let owner = node.$container;
@@ -167715,11 +167714,12 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167715
167714
  };
167716
167715
  const ownStates = (holder) => membersOf(holder).map((member) => this.thenActionMemberNode(member) ?? member).filter((member) => isStateDecl(member) && nameOf2(member) !== void 0);
167717
167716
  const nestedStates = (holder) => {
167718
- const out = ownStates(holder);
167717
+ const out = ownStates(holder).map((node) => ({ node, borrowed: false }));
167719
167718
  const def = definitionOf(holder);
167720
167719
  for (const inherited of def ? ownStates(def) : []) {
167721
- if (!out.some((m) => nameOf2(m) === nameOf2(inherited)))
167722
- out.push(inherited);
167720
+ if (!out.some((m) => nameOf2(m.node) === nameOf2(inherited))) {
167721
+ out.push({ node: inherited, borrowed: true });
167722
+ }
167723
167723
  }
167724
167724
  return out;
167725
167725
  };
@@ -167769,8 +167769,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167769
167769
  namesByFrame.set(key, created);
167770
167770
  return created;
167771
167771
  };
167772
- const renderState = (s, parentFrame, depth, seen) => {
167773
- const id2 = qnameOf(s) || nameOf2(s);
167772
+ const scopedId = (scope2, name) => `${scope2}::${name}`;
167773
+ const machineScopeId = anchorFrameId ?? qnameOf(anchor) ?? nameOf2(anchor) ?? "__stv__";
167774
+ const renderState = (s, parentFrame, depth, seen, scope2, borrowed) => {
167775
+ const id2 = borrowed ? scopedId(scope2, nameOf2(s)) : qnameOf(s) || nameOf2(s);
167774
167776
  byName.set(nameOf2(s), id2);
167775
167777
  namesIn(parentFrame).set(nameOf2(s), id2);
167776
167778
  registerDrawn(s);
@@ -167791,10 +167793,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167791
167793
  meta: { composite: true, ...isParallel ? { parallel: true } : {} },
167792
167794
  source: sourceOf2(s, uri)
167793
167795
  });
167794
- compositeFrames.push({ state: s, frameId: id2 });
167796
+ compositeFrames.push({ state: s, frameId: id2, borrowed });
167795
167797
  const next = typeQ ? /* @__PURE__ */ new Set([...seen, typeQ]) : seen;
167796
167798
  for (const ss of subStates)
167797
- renderState(ss, id2, depth + 1, next);
167799
+ renderState(ss.node, id2, depth + 1, next, id2, borrowed || ss.borrowed);
167798
167800
  } else {
167799
167801
  nodes.push({
167800
167802
  id: id2,
@@ -167809,8 +167811,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167809
167811
  });
167810
167812
  }
167811
167813
  };
167812
- for (const s of topStates)
167813
- renderState(s, anchorFrameId, 0, /* @__PURE__ */ new Set());
167814
+ for (const s of topStates) {
167815
+ renderState(s.node, anchorFrameId, 0, /* @__PURE__ */ new Set(), machineScopeId, s.borrowed);
167816
+ }
167814
167817
  const endpointName = (path10) => typeof path10 === "string" ? path10.split(/::|\./).pop() || void 0 : void 0;
167815
167818
  const controlNodeInfo = (m) => {
167816
167819
  switch (m.$type) {
@@ -167844,10 +167847,11 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167844
167847
  const entry = member;
167845
167848
  return !!entry && entry.$type === "EntryAction" && !entry.name && !entry.actionKw && !entry.send && !entry.accept && !entry.assign;
167846
167849
  };
167847
- const machineNodeIds = /* @__PURE__ */ new Map();
167850
+ const machineNodesByFrame = /* @__PURE__ */ new Map();
167851
+ const machineNodeIdIn = (frameId, member) => machineNodesByFrame.get(frameId ?? "")?.get(member);
167848
167852
  const machineNodeMembers = [];
167849
167853
  let anonymousNodes = 0;
167850
- const emitMachineNodes = (holder, frameId) => {
167854
+ const emitMachineNodes = (holder, frameId, borrowed) => {
167851
167855
  const members = membersOf(holder);
167852
167856
  const drawnHere = namesIn(frameId);
167853
167857
  for (const raw of members) {
@@ -167858,7 +167862,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167858
167862
  const name = nameOf2(member);
167859
167863
  if (name && drawnHere.has(name))
167860
167864
  continue;
167861
- const id2 = name ? qnameOf(member) || `${frameId}::${name}` : `${frameId}::__stv_${member.$type}_${anonymousNodes++}__`;
167865
+ const id2 = name ? borrowed ? scopedId(frameId, name) : qnameOf(member) || scopedId(frameId, name) : `${frameId}::__stv_${member.$type}_${anonymousNodes++}__`;
167862
167866
  if (nodes.some((n2) => n2.id === id2) || frames.some((f) => f.id === id2))
167863
167867
  continue;
167864
167868
  if (name) {
@@ -167866,7 +167870,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167866
167870
  if (!byName.has(name))
167867
167871
  byName.set(name, id2);
167868
167872
  }
167869
- machineNodeIds.set(member, id2);
167873
+ const frameNodes = machineNodesByFrame.get(frameId) ?? /* @__PURE__ */ new Map();
167874
+ frameNodes.set(member, id2);
167875
+ machineNodesByFrame.set(frameId, frameNodes);
167870
167876
  machineNodeMembers.push({ member, id: id2 });
167871
167877
  nodes.push({
167872
167878
  id: id2,
@@ -167882,17 +167888,28 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167882
167888
  };
167883
167889
  const edges = [];
167884
167890
  let e = 0;
167891
+ const finalIn = (frameId) => {
167892
+ const own = frameId && frameId !== anchorFrameId;
167893
+ const id2 = own ? `__final__${frameId}` : "__final__";
167894
+ if (!nodes.some((n2) => n2.id === id2)) {
167895
+ nodes.push({
167896
+ id: id2,
167897
+ name: "",
167898
+ keyword: "final",
167899
+ isDef: false,
167900
+ shape: "final",
167901
+ frame: own ? frameId : anchorFrameId
167902
+ });
167903
+ }
167904
+ return id2;
167905
+ };
167885
167906
  const resolveState = (nm) => {
167886
167907
  if (!nm)
167887
167908
  return void 0;
167888
167909
  if (byName.has(nm))
167889
167910
  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
- }
167911
+ if (nm === "done")
167912
+ return finalIn(anchorFrameId);
167896
167913
  return void 0;
167897
167914
  };
167898
167915
  const drawnEdges = /* @__PURE__ */ new Set();
@@ -167929,15 +167946,14 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167929
167946
  return void 0;
167930
167947
  const short = endpointName(path10);
167931
167948
  const local = namesByFrame.get(frameId ?? "");
167932
- return (short ? local?.get(short) : void 0) ?? resolveState(path10) ?? resolveState(short) ?? (short === "start" ? initialId : void 0);
167949
+ const known2 = short ? local?.get(short) : void 0;
167950
+ if (known2)
167951
+ return known2;
167952
+ if (short === "done")
167953
+ return finalIn(frameId);
167954
+ return resolveState(path10) ?? resolveState(short) ?? (short === "start" ? initialId : void 0);
167933
167955
  };
167934
167956
  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
167957
  const designatedInitial = (owner, frameId) => {
167942
167958
  const members = owner.members;
167943
167959
  if (!Array.isArray(members))
@@ -167960,7 +167976,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167960
167976
  const then = members[i + 1];
167961
167977
  if (then?.$type !== "ThenActionMember" || typeof then.target !== "string")
167962
167978
  continue;
167963
- const target = resolveState(lastSeg(then.target));
167979
+ const target = resolveEndpoint(then.target, void 0, frameId);
167964
167980
  if (target) {
167965
167981
  registerDrawn(then);
167966
167982
  return target;
@@ -167968,35 +167984,66 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167968
167984
  }
167969
167985
  return void 0;
167970
167986
  };
167971
- const machineScope = (holder) => {
167987
+ const machineScope = (holder, borrowed) => {
167972
167988
  const def = definitionOf(holder);
167973
- return def ? [holder, def] : [holder];
167989
+ return def ? [{ holder, borrowed }, { holder: def, borrowed: true }] : [{ holder, borrowed }];
167974
167990
  };
167975
167991
  if (anchorFrameId) {
167976
- for (const holder of machineScope(anchor))
167977
- emitMachineNodes(holder, anchorFrameId);
167992
+ for (const scope2 of machineScope(anchor, false)) {
167993
+ emitMachineNodes(scope2.holder, anchorFrameId, scope2.borrowed);
167994
+ }
167978
167995
  }
167979
- for (const { state, frameId } of compositeFrames) {
167980
- for (const holder of machineScope(state))
167981
- emitMachineNodes(holder, frameId);
167996
+ for (const { state, frameId, borrowed } of compositeFrames) {
167997
+ for (const scope2 of machineScope(state, borrowed)) {
167998
+ emitMachineNodes(scope2.holder, frameId, scope2.borrowed);
167999
+ }
167982
168000
  }
167983
168001
  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);
168002
+ 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
168003
  if (firstStateId)
167986
168004
  link("__initial__", firstStateId, void 0, void 0);
167987
168005
  const compositeInitial = /* @__PURE__ */ new Map();
167988
- for (const { state, frameId } of compositeFrames) {
167989
- const target = designatedInitial(state, frameId);
168006
+ for (const { state, frameId, borrowed } of compositeFrames) {
168007
+ let target;
168008
+ for (const scope2 of machineScope(state, borrowed)) {
168009
+ target = designatedInitial(scope2.holder, frameId);
168010
+ if (target)
168011
+ break;
168012
+ }
167990
168013
  if (!target)
167991
168014
  continue;
167992
168015
  const id2 = `__initial__${frameId}`;
167993
168016
  nodes.push({ id: id2, name: "", keyword: "initial", isDef: false, shape: "initial", frame: frameId });
167994
- compositeInitial.set(state, id2);
168017
+ compositeInitial.set(frameId, id2);
167995
168018
  link(id2, target, void 0, void 0);
167996
168019
  }
168020
+ const framedTransitions = /* @__PURE__ */ new Set();
168021
+ const declaredTransitions = (holder, frameId) => {
168022
+ for (const member of membersOf(holder)) {
168023
+ if (member.$type !== "TransitionDecl")
168024
+ continue;
168025
+ framedTransitions.add(member);
168026
+ const tn = member;
168027
+ link(resolveEndpoint(tn.from, void 0, frameId), resolveEndpoint(tn.to, void 0, frameId), this.transitionLabel(member), member);
168028
+ }
168029
+ };
168030
+ for (const scope2 of machineScope(anchor, false)) {
168031
+ declaredTransitions(scope2.holder, anchorFrameId);
168032
+ }
168033
+ for (const { state, frameId, borrowed } of compositeFrames) {
168034
+ for (const scope2 of machineScope(state, borrowed)) {
168035
+ declaredTransitions(scope2.holder, frameId);
168036
+ }
168037
+ }
168038
+ for (const t of transitionScope.flatMap((holder) => [...ast_utils_exports.streamAllContents(holder)])) {
168039
+ if (t.$type !== "TransitionDecl" || framedTransitions.has(t))
168040
+ continue;
168041
+ const tn = t;
168042
+ link(resolveState(tn.from), resolveState(tn.to), this.transitionLabel(t), t);
168043
+ }
167997
168044
  const sequentialTransitions = (holder, initialId, frameId) => {
167998
168045
  let cursor;
167999
- const idOf = (member) => machineNodeIds.get(member) ?? idByState.get(member) ?? (nameOf2(member) ? resolveEndpoint(nameOf2(member), void 0, frameId) : void 0);
168046
+ const idOf = (member) => machineNodeIdIn(frameId, member) ?? (nameOf2(member) ? resolveEndpoint(nameOf2(member), void 0, frameId) : void 0) ?? idByState.get(member);
168000
168047
  const endpoint = (path10) => resolveEndpoint(path10, initialId, frameId);
168001
168048
  for (const member of membersOf(holder)) {
168002
168049
  switch (member.$type) {
@@ -168011,7 +168058,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
168011
168058
  cursor = initialId;
168012
168059
  break;
168013
168060
  }
168014
- cursor = machineNodeIds.get(member) ?? cursor;
168061
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
168015
168062
  break;
168016
168063
  }
168017
168064
  // OMG 8.2.3.18 names this edge `st-succession`, so the
@@ -168077,18 +168124,18 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
168077
168124
  break;
168078
168125
  }
168079
168126
  default: {
168080
- cursor = machineNodeIds.get(member) ?? cursor;
168127
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
168081
168128
  break;
168082
168129
  }
168083
168130
  }
168084
168131
  }
168085
168132
  };
168086
- for (const holder of machineScope(anchor)) {
168087
- sequentialTransitions(holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168133
+ for (const scope2 of machineScope(anchor, false)) {
168134
+ sequentialTransitions(scope2.holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168088
168135
  }
168089
- for (const { state, frameId } of compositeFrames) {
168090
- for (const holder of machineScope(state)) {
168091
- sequentialTransitions(holder, compositeInitial.get(state), frameId);
168136
+ for (const { state, frameId, borrowed } of compositeFrames) {
168137
+ for (const scope2 of machineScope(state, borrowed)) {
168138
+ sequentialTransitions(scope2.holder, compositeInitial.get(frameId), frameId);
168092
168139
  }
168093
168140
  }
168094
168141
  const exhibitorsByState = /* @__PURE__ */ new Map();
@@ -168845,9 +168892,13 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
168845
168892
  return { id: qname, name, keyword: keywordFor(req), cells, status, source: sourceOf2(req, uri), depth, parentId };
168846
168893
  });
168847
168894
  const model = this.model("grv", ctx.anchor, [], []);
168895
+ const columns = ["Id", "Requirement", "Doc", "Subject", ...attrColumns, "Constraint", "Satisfy", "Verify", "Status"];
168896
+ const firstAttr = 4;
168897
+ const columnEdits = columns.map((_2, i) => i >= firstAttr && i < firstAttr + attrColumns.length ? { kind: "attribute", name: attrColumns[i - firstAttr] } : null);
168848
168898
  model.table = {
168849
- columns: ["Id", "Requirement", "Doc", "Subject", ...attrColumns, "Constraint", "Satisfy", "Verify", "Status"],
168850
- rows
168899
+ columns,
168900
+ rows,
168901
+ ...attrColumns.length ? { columnEdits } : {}
168851
168902
  };
168852
168903
  if (rows.length === 0)
168853
168904
  model.notes = ["No requirements found in this package."];
@@ -201255,6 +201306,11 @@ body {
201255
201306
  }
201256
201307
  /* issue 144 \u2014 the Doc column's multi-line editor (Shift+Enter for a newline). */
201257
201308
  .grv-edit-doc { resize: vertical; min-height: 48px; line-height: 1.45; }
201309
+ /* issue 139 \u2014 a column TITLE that is a model name renames it from the header;
201310
+ * same dashed hover affordance as an editable cell, and the inline editor keeps
201311
+ * the header's own casing rather than the uppercase title style. */
201312
+ .grv-table th.editable:hover { outline: 1px dashed var(--line); outline-offset: -3px; }
201313
+ .grv-table th.editable .grv-edit { text-transform: none; letter-spacing: normal; font-weight: 400; }
201258
201314
 
201259
201315
  /* \u2500\u2500 React Flow canvas (REQ-224) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
201260
201316
  .dcanvas-host, .rp-body-host { flex: 1; min-width: 0; min-height: 0; position: relative; overflow: hidden; }
@@ -205126,7 +205182,7 @@ async function runExport(command) {
205126
205182
  }
205127
205183
 
205128
205184
  // src/main.ts
205129
- var VERSION2 = true ? "0.27.0" : "dev";
205185
+ var VERSION2 = true ? "0.28.0" : "dev";
205130
205186
  function display(file) {
205131
205187
  const rel2 = path9.relative(process.cwd(), file);
205132
205188
  return rel2 && !rel2.startsWith("..") ? rel2.split(path9.sep).join("/") : file;