sysml-diagram 0.26.0 → 0.27.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
@@ -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" };
@@ -170331,6 +170414,31 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
170331
170414
  return item(m, `${head2} { ${expr} }`.replace(/\s+/g, " ").trim());
170332
170415
  }));
170333
170416
  add("actions", usages(isActionDecl).map((m) => item(m)));
170417
+ const performRowText = (m) => {
170418
+ const referenced = this.behaviorReferenceText(m);
170419
+ if (this.isAnonymousBehaviorReference(m))
170420
+ return referenced || this.featureText(m);
170421
+ const declared = this.featureText(m);
170422
+ return referenced && referenced !== nameOf2(m) ? `${declared} references ${referenced}` : declared;
170423
+ };
170424
+ add("perform actions", members.filter((m) => m.$type === "PerformStmt").filter(isNonVariantMember).map((m) => item(m, performRowText(m))));
170425
+ if (isActionFlowStep(node)) {
170426
+ const scope = qnameOf(this.packageScopeOf(node));
170427
+ const performerName = (part) => {
170428
+ const qualified = qnameOf(part);
170429
+ if (!qualified)
170430
+ return nameOf2(part) ?? "?";
170431
+ return scope && qualified.startsWith(`${scope}::`) ? qualified.slice(scope.length + 2) : qualified;
170432
+ };
170433
+ const claims = this.performClaimsByTarget(this.documentRootOf(node), index2).get(node) ?? [];
170434
+ const seenPerformers = /* @__PURE__ */ new Set();
170435
+ 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) => {
170436
+ if (seenPerformers.has(row.text))
170437
+ return false;
170438
+ seenPerformers.add(row.text);
170439
+ return true;
170440
+ }));
170441
+ }
170334
170442
  add("concerns", usages(isConcernDecl).map((m) => item(m)));
170335
170443
  add("viewpoints", usages(isViewpointDecl).map((m) => item(m)));
170336
170444
  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 +205126,7 @@ async function runExport(command) {
205018
205126
  }
205019
205127
 
205020
205128
  // src/main.ts
205021
- var VERSION2 = true ? "0.26.0" : "dev";
205129
+ var VERSION2 = true ? "0.27.0" : "dev";
205022
205130
  function display(file) {
205023
205131
  const rel2 = path9.relative(process.cwd(), file);
205024
205132
  return rel2 && !rel2.startsWith("..") ? rel2.split(path9.sep).join("/") : file;