sysml-diagram 0.26.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
@@ -162703,6 +162703,11 @@ var ACTION_FLOW_STEP_TYPES = /* @__PURE__ */ new Set([
162703
162703
  "ForLoopNode"
162704
162704
  ]);
162705
162705
  var isActionFlowStep = (node) => !!node && ACTION_FLOW_STEP_TYPES.has(node.$type);
162706
+ var NESTED_ACTION_LIMIT = 8;
162707
+ var withoutCompartments = (compartments, ...titles) => {
162708
+ const kept = (compartments ?? []).filter((compartment) => !titles.includes(compartment.title));
162709
+ return kept.length ? kept : void 0;
162710
+ };
162706
162711
  var modifiersOf = (node) => {
162707
162712
  const mods = node.modifiers;
162708
162713
  return Array.isArray(mods) ? mods : [];
@@ -163823,6 +163828,37 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
163823
163828
  /** REQ-196 — is this `perform` a SWIMLANE claim (OMG p.90): a part claiming an
163824
163829
  * action that another action owns? Such a claim is drawn inside that action,
163825
163830
  * so it is never content of the part that wrote it. */
163831
+ /** issue #114 — the path a referencing `perform`/`exhibit` names, as written
163832
+ * (`Mission::prepare`, `flow1.step`). A referencing claim has no local name,
163833
+ * so the written path is the only thing that identifies it in a text row. */
163834
+ behaviorReferenceText(stmt) {
163835
+ return this.behaviorReferenceSegments(stmt).map((segment, at) => at === 0 ? segment.text : `${segment.separator ?? "::"}${segment.text}`).join("");
163836
+ }
163837
+ /** issue #114 — the `perform` claims of the document, grouped by the action
163838
+ * each one names, so an action can list the parts that perform it
163839
+ * (`performed by`, OMG SysML v2 §8.4.13.11 `Parts::Part::performedActions`).
163840
+ * One walk per parse: the reverse listing is otherwise quadratic in the
163841
+ * number of drawn nodes. */
163842
+ performClaimsByTarget(root4, index2) {
163843
+ const cache = this.perParse(root4);
163844
+ if (cache.performClaims)
163845
+ return cache.performClaims;
163846
+ const claims = /* @__PURE__ */ new Map();
163847
+ for (const node of this.rootContents(root4)) {
163848
+ if (node.$type !== "PerformStmt")
163849
+ continue;
163850
+ const target = this.performTargetOf(node, index2);
163851
+ if (!target || target === node)
163852
+ continue;
163853
+ const existing = claims.get(target);
163854
+ if (existing)
163855
+ existing.push(node);
163856
+ else
163857
+ claims.set(target, [node]);
163858
+ }
163859
+ cache.performClaims = claims;
163860
+ return claims;
163861
+ }
163826
163862
  isSwimlaneClaim(member, index2) {
163827
163863
  if (member.$type !== "PerformStmt")
163828
163864
  return false;
@@ -165331,7 +165367,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
165331
165367
  isDef: part.isDef === true,
165332
165368
  type: typeText(part),
165333
165369
  multiplicity: multText(part),
165334
- compartments: this.compartmentsFor(part, uri, index2),
165370
+ // issue #114 — this frame already DRAWS the actions the part
165371
+ // performs, so their textual `perform actions` rows would be a
165372
+ // second depiction of the same members (REQ-181/185).
165373
+ compartments: withoutCompartments(this.compartmentsFor(part, uri, index2), "perform actions"),
165335
165374
  ports: ports.length ? ports : void 0,
165336
165375
  source: sourceOf2(part, uri),
165337
165376
  meta: editMeta
@@ -166693,7 +166732,8 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166693
166732
  else
166694
166733
  emitFlowNode(child, ownerFrameId, holder, occurrence, laneParts);
166695
166734
  };
166696
- const actionFeatureCompartments = (action) => (this.compartmentsFor(action, uri, index2) ?? []).filter((compartment) => compartment.title !== "parameters" && compartment.title !== "actions");
166735
+ const graphicalAfvTitles = ["perform actions", "performed by"];
166736
+ const actionFeatureCompartments = (action) => withoutCompartments(this.compartmentsFor(action, uri, index2), "parameters", "actions", ...graphicalAfvTitles) ?? [];
166697
166737
  const renderContainer = (holder, frameId, parentFrame, depth, seen, isAnchor, inheritedExecutionContext, holderOccurrence = frameId) => {
166698
166738
  if (!occurrenceEdits.has(holderOccurrence)) {
166699
166739
  occurrenceEdits.set(holderOccurrence, {
@@ -166718,7 +166758,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166718
166758
  frameOfNode.set(holder, frameId);
166719
166759
  const framePorts = isPartDecl(holder) ? [...framePins, ...this.portsOf(holder, index2, uri, frameId).ports.filter((port) => !framePins.some((pin) => pin.name === port.name)).map((port) => ({ ...port, meta: { ...port.meta, afvPartPort: true } }))] : framePins;
166720
166760
  registerPins(holder, frameId, framePins, isAnchor);
166721
- const frameCompartments = isActionDecl(holder) ? actionFeatureCompartments(holder) : this.compartmentsFor(holder, uri, index2);
166761
+ const frameCompartments = isActionDecl(holder) ? actionFeatureCompartments(holder) : withoutCompartments(this.compartmentsFor(holder, uri, index2), ...graphicalAfvTitles);
166722
166762
  frames.push({
166723
166763
  id: frameId,
166724
166764
  label: nameOf2(holder) ?? lastSeg(frameId),
@@ -166800,6 +166840,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166800
166840
  return id2;
166801
166841
  };
166802
166842
  const emitLoopFrame = (loop, parentFrameId, executionContext, occurrence, laneParts, wrapper) => {
166843
+ if (nestingExhausted()) {
166844
+ emitFlowNode(wrapper ?? loop, parentFrameId, executionContext, occurrence, laneParts);
166845
+ return;
166846
+ }
166803
166847
  const banner = loopBanner(loop);
166804
166848
  const wrapperName = wrapper ? nameOf2(wrapper) : void 0;
166805
166849
  const loopId = occurrence;
@@ -166852,9 +166896,11 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166852
166896
  const parentEdit = occurrenceEdits.get(occurrence);
166853
166897
  if (parentEdit)
166854
166898
  occurrenceEdits.set(bodyOccurrence, parentEdit);
166899
+ openFrames.add(loop);
166855
166900
  for (const bm of flowMembersOf(body)) {
166856
166901
  emitChild(bm, loopId, executionContext, bodyOccurrence);
166857
166902
  }
166903
+ openFrames.delete(loop);
166858
166904
  }
166859
166905
  idByNode.set(loop, loopId);
166860
166906
  registerStep(occurrence, loopId, [nameOf2(loop)]);
@@ -166881,10 +166927,11 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166881
166927
  return target && isActionDecl(target) && ownsFlow(target) ? target : void 0;
166882
166928
  };
166883
166929
  const isCompositeAction = (node) => contentSourceOf(node) !== void 0;
166884
- const openActionFrames = /* @__PURE__ */ new Set();
166930
+ const openFrames = /* @__PURE__ */ new Set();
166931
+ const nestingExhausted = () => openFrames.size >= NESTED_ACTION_LIMIT;
166885
166932
  const emitCompositeActionFrame = (action, parentFrameId, executionContext, occurrence, laneParts) => {
166886
166933
  const content = contentSourceOf(action) ?? action;
166887
- if (openActionFrames.has(content)) {
166934
+ if (openFrames.has(content) || nestingExhausted()) {
166888
166935
  emitFlowNode(action, parentFrameId, executionContext, occurrence, laneParts);
166889
166936
  return;
166890
166937
  }
@@ -166930,12 +166977,16 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166930
166977
  });
166931
166978
  recordLaneCandidate(id2, true, parentFrameId, laneParts, occurrence);
166932
166979
  actionRecords.push({ m: action, id: id2, performer: executionContext });
166933
- openActionFrames.add(content);
166980
+ openFrames.add(content);
166934
166981
  for (const child of flowMembersOf(content))
166935
166982
  emitChild(child, id2, executionContext, occurrence);
166936
- openActionFrames.delete(content);
166983
+ openFrames.delete(content);
166937
166984
  };
166938
166985
  const emitIfFrame = (node, parentFrameId, executionContext, occurrence, laneParts, wrapper) => {
166986
+ if (nestingExhausted()) {
166987
+ emitFlowNode(wrapper ?? node, parentFrameId, executionContext, occurrence, laneParts);
166988
+ return;
166989
+ }
166939
166990
  const inf = node;
166940
166991
  const declaredNode = wrapper ?? (nameOf2(node) ? node : void 0);
166941
166992
  const wrapperName = declaredNode ? nameOf2(declaredNode) : void 0;
@@ -166988,6 +167039,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
166988
167039
  idByNode.set(wrapper, frameId);
166989
167040
  registerStep(occurrence, frameId, [wrapperName]);
166990
167041
  }
167042
+ openFrames.add(node);
166991
167043
  for (const [branch, block2] of [
166992
167044
  ["then", inf.thenBody],
166993
167045
  ["else", inf.elseIf ?? inf.elseBody]
@@ -167019,6 +167071,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167019
167071
  [branch === "then" ? "structuredThenMemberIds" : "structuredElseMemberIds"]: memberIds
167020
167072
  };
167021
167073
  }
167074
+ openFrames.delete(node);
167022
167075
  };
167023
167076
  const anchorId = qnameOf(anchor) || nameOf2(anchor) || "__anchor__";
167024
167077
  renderContainer(anchor, anchorId, void 0, 0, /* @__PURE__ */ new Set(), true, void 0);
@@ -167147,6 +167200,15 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167147
167200
  branchInsertable: true
167148
167201
  } : void 0;
167149
167202
  };
167203
+ const drawnRowKeys = /* @__PURE__ */ new Set();
167204
+ const rowKey = (source) => source ? `${source.uri} ${source.range.start.line} ${source.range.start.character}` : void 0;
167205
+ const registerDrawn = (member) => {
167206
+ if (!member)
167207
+ return;
167208
+ const key = rowKey(sourceOf2(member, uri));
167209
+ if (key)
167210
+ drawnRowKeys.add(key);
167211
+ };
167150
167212
  const linkedSuccessions = /* @__PURE__ */ new Set();
167151
167213
  const linkIds = (from, to, label, src, meta) => {
167152
167214
  if (!from || !to)
@@ -167172,6 +167234,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167172
167234
  source: src ? sourceOf2(src, uri) : void 0,
167173
167235
  meta
167174
167236
  });
167237
+ registerDrawn(src);
167175
167238
  return true;
167176
167239
  };
167177
167240
  const linkInlineTerminate = (action, actionId) => {
@@ -167300,6 +167363,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167300
167363
  label: this.flowPayloadText(fm) ?? typeText(m) ?? transferredFeature ?? nameOf2(m),
167301
167364
  source: sourceOf2(m, uri)
167302
167365
  });
167366
+ registerDrawn(m);
167303
167367
  }
167304
167368
  } else if (m.$type === "BindStmt" || m.$type === "BindingConnectorStmt" || m.$type === "BindingDecl") {
167305
167369
  const binding = m;
@@ -167309,6 +167373,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167309
167373
  const to = resolvePin(right, occurrenceContext);
167310
167374
  if (from && to) {
167311
167375
  edges.push({ id: `e${e++}`, from, to, kind: "binding", label: "=", source: sourceOf2(m, uri) });
167376
+ registerDrawn(m);
167312
167377
  }
167313
167378
  } else {
167314
167379
  const memberName = localFlowName(m);
@@ -167598,6 +167663,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167598
167663
  const toId = match ? nodeIdOf(match.m) : void 0;
167599
167664
  if (fromId && toId) {
167600
167665
  edges.push({ id: `e${e++}`, from: fromId, to: toId, kind: "message", label: payload, source: sourceOf2(s.m, uri) });
167666
+ registerDrawn(s.m);
167601
167667
  }
167602
167668
  }
167603
167669
  this.emitBehaviorDefinitions([
@@ -167612,6 +167678,23 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167612
167678
  bare.notes = ["No actions found to flow."];
167613
167679
  return bare;
167614
167680
  }
167681
+ if (drawnRowKeys.size) {
167682
+ for (const element of [...frames, ...nodes]) {
167683
+ const full = element.compartments;
167684
+ if (!full?.length)
167685
+ continue;
167686
+ const kept = full.map((compartment) => ({
167687
+ title: compartment.title,
167688
+ items: compartment.items.filter((row) => {
167689
+ const key = rowKey(row.source);
167690
+ return !key || !drawnRowKeys.has(key);
167691
+ })
167692
+ })).filter((compartment) => compartment.items.length > 0);
167693
+ if (kept.length === full.length && kept.every((c, at) => c.items.length === full[at].items.length))
167694
+ continue;
167695
+ element.compartments = kept.length ? kept : void 0;
167696
+ }
167697
+ }
167615
167698
  const model = this.model("afv", anchor, nodes, edges);
167616
167699
  model.frames = frames;
167617
167700
  model.meta = { ...model.meta, unified: true, groupMode: "nested" };
@@ -167632,11 +167715,12 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167632
167715
  };
167633
167716
  const ownStates = (holder) => membersOf(holder).map((member) => this.thenActionMemberNode(member) ?? member).filter((member) => isStateDecl(member) && nameOf2(member) !== void 0);
167634
167717
  const nestedStates = (holder) => {
167635
- const out = ownStates(holder);
167718
+ const out = ownStates(holder).map((node) => ({ node, borrowed: false }));
167636
167719
  const def = definitionOf(holder);
167637
167720
  for (const inherited of def ? ownStates(def) : []) {
167638
- if (!out.some((m) => nameOf2(m) === nameOf2(inherited)))
167639
- out.push(inherited);
167721
+ if (!out.some((m) => nameOf2(m.node) === nameOf2(inherited))) {
167722
+ out.push({ node: inherited, borrowed: true });
167723
+ }
167640
167724
  }
167641
167725
  return out;
167642
167726
  };
@@ -167686,8 +167770,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167686
167770
  namesByFrame.set(key, created);
167687
167771
  return created;
167688
167772
  };
167689
- const renderState = (s, parentFrame, depth, seen) => {
167690
- 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);
167691
167777
  byName.set(nameOf2(s), id2);
167692
167778
  namesIn(parentFrame).set(nameOf2(s), id2);
167693
167779
  registerDrawn(s);
@@ -167708,10 +167794,10 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167708
167794
  meta: { composite: true, ...isParallel ? { parallel: true } : {} },
167709
167795
  source: sourceOf2(s, uri)
167710
167796
  });
167711
- compositeFrames.push({ state: s, frameId: id2 });
167797
+ compositeFrames.push({ state: s, frameId: id2, borrowed });
167712
167798
  const next = typeQ ? /* @__PURE__ */ new Set([...seen, typeQ]) : seen;
167713
167799
  for (const ss of subStates)
167714
- renderState(ss, id2, depth + 1, next);
167800
+ renderState(ss.node, id2, depth + 1, next, id2, borrowed || ss.borrowed);
167715
167801
  } else {
167716
167802
  nodes.push({
167717
167803
  id: id2,
@@ -167726,8 +167812,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167726
167812
  });
167727
167813
  }
167728
167814
  };
167729
- for (const s of topStates)
167730
- 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
+ }
167731
167818
  const endpointName = (path10) => typeof path10 === "string" ? path10.split(/::|\./).pop() || void 0 : void 0;
167732
167819
  const controlNodeInfo = (m) => {
167733
167820
  switch (m.$type) {
@@ -167761,10 +167848,11 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167761
167848
  const entry = member;
167762
167849
  return !!entry && entry.$type === "EntryAction" && !entry.name && !entry.actionKw && !entry.send && !entry.accept && !entry.assign;
167763
167850
  };
167764
- const machineNodeIds = /* @__PURE__ */ new Map();
167851
+ const machineNodesByFrame = /* @__PURE__ */ new Map();
167852
+ const machineNodeIdIn = (frameId, member) => machineNodesByFrame.get(frameId ?? "")?.get(member);
167765
167853
  const machineNodeMembers = [];
167766
167854
  let anonymousNodes = 0;
167767
- const emitMachineNodes = (holder, frameId) => {
167855
+ const emitMachineNodes = (holder, frameId, borrowed) => {
167768
167856
  const members = membersOf(holder);
167769
167857
  const drawnHere = namesIn(frameId);
167770
167858
  for (const raw of members) {
@@ -167775,7 +167863,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167775
167863
  const name = nameOf2(member);
167776
167864
  if (name && drawnHere.has(name))
167777
167865
  continue;
167778
- 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++}__`;
167779
167867
  if (nodes.some((n2) => n2.id === id2) || frames.some((f) => f.id === id2))
167780
167868
  continue;
167781
167869
  if (name) {
@@ -167783,7 +167871,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167783
167871
  if (!byName.has(name))
167784
167872
  byName.set(name, id2);
167785
167873
  }
167786
- machineNodeIds.set(member, id2);
167874
+ const frameNodes = machineNodesByFrame.get(frameId) ?? /* @__PURE__ */ new Map();
167875
+ frameNodes.set(member, id2);
167876
+ machineNodesByFrame.set(frameId, frameNodes);
167787
167877
  machineNodeMembers.push({ member, id: id2 });
167788
167878
  nodes.push({
167789
167879
  id: id2,
@@ -167799,17 +167889,28 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167799
167889
  };
167800
167890
  const edges = [];
167801
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
+ };
167802
167907
  const resolveState = (nm) => {
167803
167908
  if (!nm)
167804
167909
  return void 0;
167805
167910
  if (byName.has(nm))
167806
167911
  return byName.get(nm);
167807
- if (nm === "done") {
167808
- if (!nodes.some((n2) => n2.shape === "final")) {
167809
- nodes.push({ id: "__final__", name: "", keyword: "final", isDef: false, shape: "final", frame: anchorFrameId });
167810
- }
167811
- return "__final__";
167812
- }
167912
+ if (nm === "done")
167913
+ return finalIn(anchorFrameId);
167813
167914
  return void 0;
167814
167915
  };
167815
167916
  const drawnEdges = /* @__PURE__ */ new Set();
@@ -167846,15 +167947,14 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167846
167947
  return void 0;
167847
167948
  const short = endpointName(path10);
167848
167949
  const local = namesByFrame.get(frameId ?? "");
167849
- 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);
167850
167956
  };
167851
167957
  const transitionScope = [anchor, ...definitionOf(anchor) ? [definitionOf(anchor)] : []];
167852
- for (const t of transitionScope.flatMap((holder) => [...ast_utils_exports.streamAllContents(holder)])) {
167853
- if (t.$type !== "TransitionDecl")
167854
- continue;
167855
- const tn = t;
167856
- link(resolveState(tn.from), resolveState(tn.to), this.transitionLabel(t), t);
167857
- }
167858
167958
  const designatedInitial = (owner, frameId) => {
167859
167959
  const members = owner.members;
167860
167960
  if (!Array.isArray(members))
@@ -167877,7 +167977,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167877
167977
  const then = members[i + 1];
167878
167978
  if (then?.$type !== "ThenActionMember" || typeof then.target !== "string")
167879
167979
  continue;
167880
- const target = resolveState(lastSeg(then.target));
167980
+ const target = resolveEndpoint(then.target, void 0, frameId);
167881
167981
  if (target) {
167882
167982
  registerDrawn(then);
167883
167983
  return target;
@@ -167885,35 +167985,66 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167885
167985
  }
167886
167986
  return void 0;
167887
167987
  };
167888
- const machineScope = (holder) => {
167988
+ const machineScope = (holder, borrowed) => {
167889
167989
  const def = definitionOf(holder);
167890
- return def ? [holder, def] : [holder];
167990
+ return def ? [{ holder, borrowed }, { holder: def, borrowed: true }] : [{ holder, borrowed }];
167891
167991
  };
167892
167992
  if (anchorFrameId) {
167893
- for (const holder of machineScope(anchor))
167894
- emitMachineNodes(holder, anchorFrameId);
167993
+ for (const scope2 of machineScope(anchor, false)) {
167994
+ emitMachineNodes(scope2.holder, anchorFrameId, scope2.borrowed);
167995
+ }
167895
167996
  }
167896
- for (const { state, frameId } of compositeFrames) {
167897
- for (const holder of machineScope(state))
167898
- 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
+ }
167899
168001
  }
167900
168002
  const anchorDefinition = definitionOf(anchor);
167901
- 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);
167902
168004
  if (firstStateId)
167903
168005
  link("__initial__", firstStateId, void 0, void 0);
167904
168006
  const compositeInitial = /* @__PURE__ */ new Map();
167905
- for (const { state, frameId } of compositeFrames) {
167906
- 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
+ }
167907
168014
  if (!target)
167908
168015
  continue;
167909
168016
  const id2 = `__initial__${frameId}`;
167910
168017
  nodes.push({ id: id2, name: "", keyword: "initial", isDef: false, shape: "initial", frame: frameId });
167911
- compositeInitial.set(state, id2);
168018
+ compositeInitial.set(frameId, id2);
167912
168019
  link(id2, target, void 0, void 0);
167913
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
+ }
167914
168045
  const sequentialTransitions = (holder, initialId, frameId) => {
167915
168046
  let cursor;
167916
- 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);
167917
168048
  const endpoint = (path10) => resolveEndpoint(path10, initialId, frameId);
167918
168049
  for (const member of membersOf(holder)) {
167919
168050
  switch (member.$type) {
@@ -167928,7 +168059,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167928
168059
  cursor = initialId;
167929
168060
  break;
167930
168061
  }
167931
- cursor = machineNodeIds.get(member) ?? cursor;
168062
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
167932
168063
  break;
167933
168064
  }
167934
168065
  // OMG 8.2.3.18 names this edge `st-succession`, so the
@@ -167994,18 +168125,18 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
167994
168125
  break;
167995
168126
  }
167996
168127
  default: {
167997
- cursor = machineNodeIds.get(member) ?? cursor;
168128
+ cursor = machineNodeIdIn(frameId, member) ?? cursor;
167998
168129
  break;
167999
168130
  }
168000
168131
  }
168001
168132
  }
168002
168133
  };
168003
- for (const holder of machineScope(anchor)) {
168004
- sequentialTransitions(holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168134
+ for (const scope2 of machineScope(anchor, false)) {
168135
+ sequentialTransitions(scope2.holder, hostsStateMachine ? "__initial__" : void 0, anchorFrameId);
168005
168136
  }
168006
- for (const { state, frameId } of compositeFrames) {
168007
- for (const holder of machineScope(state)) {
168008
- 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);
168009
168140
  }
168010
168141
  }
168011
168142
  const exhibitorsByState = /* @__PURE__ */ new Map();
@@ -170331,6 +170462,31 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
170331
170462
  return item(m, `${head2} { ${expr} }`.replace(/\s+/g, " ").trim());
170332
170463
  }));
170333
170464
  add("actions", usages(isActionDecl).map((m) => item(m)));
170465
+ const performRowText = (m) => {
170466
+ const referenced = this.behaviorReferenceText(m);
170467
+ if (this.isAnonymousBehaviorReference(m))
170468
+ return referenced || this.featureText(m);
170469
+ const declared = this.featureText(m);
170470
+ return referenced && referenced !== nameOf2(m) ? `${declared} references ${referenced}` : declared;
170471
+ };
170472
+ add("perform actions", members.filter((m) => m.$type === "PerformStmt").filter(isNonVariantMember).map((m) => item(m, performRowText(m))));
170473
+ if (isActionFlowStep(node)) {
170474
+ const scope = qnameOf(this.packageScopeOf(node));
170475
+ const performerName = (part) => {
170476
+ const qualified = qnameOf(part);
170477
+ if (!qualified)
170478
+ return nameOf2(part) ?? "?";
170479
+ return scope && qualified.startsWith(`${scope}::`) ? qualified.slice(scope.length + 2) : qualified;
170480
+ };
170481
+ const claims = this.performClaimsByTarget(this.documentRootOf(node), index2).get(node) ?? [];
170482
+ const seenPerformers = /* @__PURE__ */ new Set();
170483
+ add("performed by", claims.map((claim) => ({ claim, part: this.declaringOwnerOf(claim) })).filter((entry) => !!entry.part && isPartDecl(entry.part)).map(({ claim, part }) => ({ text: performerName(part), source: sourceOf2(claim, uri) })).filter((row) => {
170484
+ if (seenPerformers.has(row.text))
170485
+ return false;
170486
+ seenPerformers.add(row.text);
170487
+ return true;
170488
+ }));
170489
+ }
170334
170490
  add("concerns", usages(isConcernDecl).map((m) => item(m)));
170335
170491
  add("viewpoints", usages(isViewpointDecl).map((m) => item(m)));
170336
170492
  add("exposes", members.filter((m) => m.$type === "ExposeMember").flatMap((m) => (m.paths ?? []).map((path10) => item(path10, this.featurePath(path10) ?? (path10.$cstNode?.text ?? "").replace(/\s+/g, " ").trim()))));
@@ -205018,7 +205174,7 @@ async function runExport(command) {
205018
205174
  }
205019
205175
 
205020
205176
  // src/main.ts
205021
- var VERSION2 = true ? "0.26.0" : "dev";
205177
+ var VERSION2 = true ? "0.27.1" : "dev";
205022
205178
  function display(file) {
205023
205179
  const rel2 = path9.relative(process.cwd(), file);
205024
205180
  return rel2 && !rel2.startsWith("..") ? rel2.split(path9.sep).join("/") : file;