sysml-diagram 0.18.0 → 0.19.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 +95 -33
- package/out/main.js.map +2 -2
- package/package.json +1 -1
- package/resources/sysml.dimension-table.json +1 -1
package/out/main.js
CHANGED
|
@@ -162237,6 +162237,7 @@ var redefinedNameOf = (node) => {
|
|
|
162237
162237
|
}
|
|
162238
162238
|
return void 0;
|
|
162239
162239
|
};
|
|
162240
|
+
var effectiveNameOf = (node) => nameOf2(node) ?? redefinedNameOf(node);
|
|
162240
162241
|
var portionLabelOf = (node) => nameOf2(node) ?? (isOccurrenceModified(node) ? redefinedNameOf(node) : void 0);
|
|
162241
162242
|
function diagramNodeId(node) {
|
|
162242
162243
|
const name = nameOf2(node);
|
|
@@ -162457,6 +162458,60 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
162457
162458
|
return void 0;
|
|
162458
162459
|
return index2.get(t) ?? index2.get(lastSeg(t));
|
|
162459
162460
|
}
|
|
162461
|
+
// REQ-192/REQ-193, issue #233 — the types a node inherits members FROM, nearest
|
|
162462
|
+
// first. A USAGE inherits from its typing definition (`part p : Base`) and from
|
|
162463
|
+
// everything that definition specializes; a DEFINITION inherits from the
|
|
162464
|
+
// definitions IT specializes (`part def Custom :> Base`). resolveType only ever
|
|
162465
|
+
// walked the usage's `typing` relationship, so a part def that specialized
|
|
162466
|
+
// another part def rendered only the members it redeclared — the inherited ones
|
|
162467
|
+
// were never folded in, because the specialization chain was not walked for
|
|
162468
|
+
// definitions at all. Breadth-first, so a nearer supertype shadows a farther one, and the
|
|
162469
|
+
// `seen` set terminates it: every node is visited at most once and a document
|
|
162470
|
+
// holds finitely many, so a cyclic hierarchy stops without a depth cap — and a
|
|
162471
|
+
// cap is what silently dropped the far end of a legitimately deep chain
|
|
162472
|
+
// (PR #239 review), against REQ-192's own "to any depth" wording.
|
|
162473
|
+
inheritedTypesOf(node, index2) {
|
|
162474
|
+
const root4 = node.isDef === true ? node : this.resolveType(node, index2);
|
|
162475
|
+
if (!root4)
|
|
162476
|
+
return [];
|
|
162477
|
+
const chain = root4 === node ? [] : [root4];
|
|
162478
|
+
const seen = /* @__PURE__ */ new Set([node, root4]);
|
|
162479
|
+
let frontier = [root4];
|
|
162480
|
+
while (frontier.length > 0) {
|
|
162481
|
+
const next = [];
|
|
162482
|
+
for (const cur of frontier) {
|
|
162483
|
+
for (const target of specializationTargets(cur)) {
|
|
162484
|
+
const superType = this.resolveSpecializationTarget(cur, target, index2);
|
|
162485
|
+
if (!superType || seen.has(superType))
|
|
162486
|
+
continue;
|
|
162487
|
+
seen.add(superType);
|
|
162488
|
+
chain.push(superType);
|
|
162489
|
+
next.push(superType);
|
|
162490
|
+
}
|
|
162491
|
+
}
|
|
162492
|
+
frontier = next;
|
|
162493
|
+
}
|
|
162494
|
+
return chain;
|
|
162495
|
+
}
|
|
162496
|
+
// issue #233 (PR #239 review) — one supertype path, resolved. A specialization
|
|
162497
|
+
// target is path TEXT in this grammar, not a cross-reference, so there is no
|
|
162498
|
+
// linked node to prefer the way `resolveType` prefers `typing.type.ref`; the
|
|
162499
|
+
// name has to be looked up. The active document's index answers the ordinary
|
|
162500
|
+
// case, but `resolveType` legitimately returns a definition from ANOTHER
|
|
162501
|
+
// document (an imported or library `part def Custom :> Base`), and that
|
|
162502
|
+
// document's supertypes are not in the active map at all — so the chain used to
|
|
162503
|
+
// stop dead at the first foreign definition, dropping everything `Base`
|
|
162504
|
+
// contributes. The declaring document's own index is consulted second: it is
|
|
162505
|
+
// the namespace the path was written in, and `perParse` caches it per document
|
|
162506
|
+
// exactly as it caches the active one, so this stays one lookup, not a
|
|
162507
|
+
// workspace scan.
|
|
162508
|
+
resolveSpecializationTarget(owner, target, index2) {
|
|
162509
|
+
const local = index2.get(target) ?? index2.get(lastSeg(target));
|
|
162510
|
+
if (local)
|
|
162511
|
+
return local;
|
|
162512
|
+
const declaring = this.localIndex(this.documentRootOf(owner));
|
|
162513
|
+
return declaring === index2 ? void 0 : declaring.get(target) ?? declaring.get(lastSeg(target));
|
|
162514
|
+
}
|
|
162460
162515
|
findAnchor(root4, rootSymbol, kind, index2) {
|
|
162461
162516
|
const all = this.rootContents(root4);
|
|
162462
162517
|
if (kind === "bv" && !rootSymbol) {
|
|
@@ -162813,7 +162868,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
162813
162868
|
}
|
|
162814
162869
|
case "iv":
|
|
162815
162870
|
if (isPartDecl(node)) {
|
|
162816
|
-
return this.
|
|
162871
|
+
return this.hasNestedPartUsages(node, index2) || this.hasRenderablePorts(node, index2);
|
|
162817
162872
|
}
|
|
162818
162873
|
return (isPackage(node) || isDocument(node)) && this.nestedUsages(node, isPartDecl).some((n2) => nameOf2(n2) !== void 0);
|
|
162819
162874
|
case "afv": {
|
|
@@ -162867,11 +162922,15 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
162867
162922
|
return this.collectGeometry(node, index2).length > 0;
|
|
162868
162923
|
}
|
|
162869
162924
|
hasRenderablePorts(node, index2) {
|
|
162870
|
-
|
|
162871
|
-
|
|
162872
|
-
|
|
162873
|
-
|
|
162874
|
-
|
|
162925
|
+
return [node, ...this.inheritedTypesOf(node, index2)].some((source) => membersOf(source).some((m) => isPortDecl(m) && m.isDef !== true));
|
|
162926
|
+
}
|
|
162927
|
+
// REQ-192, issue #233 — the named part usages a part shows when expanded: its
|
|
162928
|
+
// own and the ones it inherits, through its typing definition or a `:>`
|
|
162929
|
+
// specialization.
|
|
162930
|
+
// The predicate form of `childUsagesOf`, so an anchor that only INHERITS
|
|
162931
|
+
// internals is recognised as having them.
|
|
162932
|
+
hasNestedPartUsages(node, index2) {
|
|
162933
|
+
return [node, ...this.inheritedTypesOf(node, index2)].some((source) => this.nestedUsages(source, isPartDecl).some((n2) => nameOf2(n2) !== void 0));
|
|
162875
162934
|
}
|
|
162876
162935
|
nestedUsages(node, guard) {
|
|
162877
162936
|
return membersOf(node).filter((m) => guard(m) && m.isDef !== true);
|
|
@@ -163524,23 +163583,27 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
163524
163583
|
return id2;
|
|
163525
163584
|
};
|
|
163526
163585
|
const childUsagesOf = (part) => {
|
|
163527
|
-
const
|
|
163528
|
-
const
|
|
163529
|
-
|
|
163530
|
-
|
|
163531
|
-
|
|
163532
|
-
|
|
163533
|
-
|
|
163534
|
-
|
|
163535
|
-
|
|
163536
|
-
|
|
163537
|
-
|
|
163586
|
+
const out = this.nestedUsages(part, isPartDecl);
|
|
163587
|
+
const have = new Set(out.map(effectiveNameOf).filter((x) => !!x));
|
|
163588
|
+
for (const source of this.inheritedTypesOf(part, index2)) {
|
|
163589
|
+
for (const usage of this.nestedUsages(source, isPartDecl)) {
|
|
163590
|
+
const nm = effectiveNameOf(usage);
|
|
163591
|
+
if (nm !== void 0) {
|
|
163592
|
+
if (have.has(nm))
|
|
163593
|
+
continue;
|
|
163594
|
+
have.add(nm);
|
|
163595
|
+
}
|
|
163596
|
+
out.push(usage);
|
|
163597
|
+
}
|
|
163598
|
+
}
|
|
163599
|
+
return out;
|
|
163538
163600
|
};
|
|
163601
|
+
const effectiveMembersOf = (part) => [part, ...this.inheritedTypesOf(part, index2)].flatMap((source) => membersOf(source));
|
|
163539
163602
|
const childResolver = (childInfos, self2) => {
|
|
163540
163603
|
const localPort = /* @__PURE__ */ new Map();
|
|
163541
163604
|
const localNode = /* @__PURE__ */ new Map();
|
|
163542
163605
|
const addPorts = (usage, id2, bare) => {
|
|
163543
|
-
const nm =
|
|
163606
|
+
const nm = effectiveNameOf(usage);
|
|
163544
163607
|
if (!nm)
|
|
163545
163608
|
return;
|
|
163546
163609
|
localNode.set(nm, id2);
|
|
@@ -163592,7 +163655,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
163592
163655
|
const editMeta = ivEditMeta(part, instanceId, typeDef, localUsage, localPath, uri);
|
|
163593
163656
|
const children2 = depth < 8 && !(typeQ !== void 0 && seenTypes.has(typeQ)) ? childUsagesOf(part) : [];
|
|
163594
163657
|
const performLabelOf = (m) => [nameOf2(m), ...m.chainSegs ?? []].filter((segment) => !!segment).at(-1) ?? "perform";
|
|
163595
|
-
const performedActions = depth < 8 && !(typeQ !== void 0 && seenTypes.has(typeQ)) ?
|
|
163658
|
+
const performedActions = depth < 8 && !(typeQ !== void 0 && seenTypes.has(typeQ)) ? effectiveMembersOf(part).filter((m) => m.$type === "PerformStmt" && !!nameOf2(m)).filter((m, i, list) => list.findIndex((o) => performLabelOf(o) === performLabelOf(m)) === i) : [];
|
|
163596
163659
|
const emitOwnedActions = (frameOf) => {
|
|
163597
163660
|
for (const act of performedActions) {
|
|
163598
163661
|
const actId = `${frameOf}::${performLabelOf(act)}`;
|
|
@@ -163614,7 +163677,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
163614
163677
|
if (children2.length > 0 || performedActions.length > 0) {
|
|
163615
163678
|
frames.push({
|
|
163616
163679
|
id: instanceId,
|
|
163617
|
-
label:
|
|
163680
|
+
label: effectiveNameOf(part) ?? lastSeg(instanceId),
|
|
163618
163681
|
keyword: keywordFor(part),
|
|
163619
163682
|
parent: parentFrame,
|
|
163620
163683
|
// REQ-363 — same presentation data container parts that leaf part
|
|
@@ -163628,16 +163691,16 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
163628
163691
|
meta: editMeta
|
|
163629
163692
|
});
|
|
163630
163693
|
const nextSeen = typeQ ? /* @__PURE__ */ new Set([...seenTypes, typeQ]) : seenTypes;
|
|
163631
|
-
const childInfos = children2.map((cu) => ({ usage: cu, id: `${instanceId}::${
|
|
163694
|
+
const childInfos = children2.map((cu) => ({ usage: cu, id: `${instanceId}::${effectiveNameOf(cu) ?? lastSeg(qnameOf(cu) || "")}` }));
|
|
163632
163695
|
for (const { usage, id: id2 } of childInfos) {
|
|
163633
|
-
renderInstance(usage, id2, instanceId, nextSeen, depth + 1, localUsage, [...localPath,
|
|
163696
|
+
renderInstance(usage, id2, instanceId, nextSeen, depth + 1, localUsage, [...localPath, effectiveNameOf(usage) ?? lastSeg(id2)]);
|
|
163634
163697
|
}
|
|
163635
163698
|
emitOwnedActions(instanceId);
|
|
163636
|
-
this.emitInterconnectEdges(
|
|
163699
|
+
this.emitInterconnectEdges(effectiveMembersOf(part), childResolver(childInfos, { usage: part, id: instanceId }), children2, index2, uri, nodes, edges, eRef, instanceId);
|
|
163637
163700
|
} else {
|
|
163638
163701
|
nodes.push({
|
|
163639
163702
|
id: instanceId,
|
|
163640
|
-
name:
|
|
163703
|
+
name: effectiveNameOf(part) ?? lastSeg(instanceId),
|
|
163641
163704
|
keyword: keywordFor(part),
|
|
163642
163705
|
isDef: part.isDef === true,
|
|
163643
163706
|
shape: "box",
|
|
@@ -163927,7 +163990,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
163927
163990
|
const all = [...ast_utils_exports.streamAllContents(scope)];
|
|
163928
163991
|
const isUsagePart = (n2) => isPartDecl(n2) && n2.isDef !== true && nameOf2(n2) !== void 0;
|
|
163929
163992
|
const isDefPart = (n2) => isPartDecl(n2) && n2.isDef === true && nameOf2(n2) !== void 0;
|
|
163930
|
-
const hasInternalParts = (d) => this.
|
|
163993
|
+
const hasInternalParts = (d) => [d, ...this.inheritedTypesOf(d, index2)].some((source) => this.nestedUsages(source, isPartDecl).length > 0);
|
|
163931
163994
|
const insideAPart = (n2) => {
|
|
163932
163995
|
let c = n2.$container;
|
|
163933
163996
|
while (c && c !== scope) {
|
|
@@ -166916,9 +166979,9 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
166916
166979
|
const ports = [];
|
|
166917
166980
|
const map3 = /* @__PURE__ */ new Map();
|
|
166918
166981
|
const visibleNames = /* @__PURE__ */ new Set();
|
|
166919
|
-
const usageName =
|
|
166982
|
+
const usageName = effectiveNameOf(node);
|
|
166920
166983
|
const makePort = (portNode, inheritedFromType, parentPortId, parentPath) => {
|
|
166921
|
-
const pn =
|
|
166984
|
+
const pn = effectiveNameOf(portNode);
|
|
166922
166985
|
if (!pn)
|
|
166923
166986
|
return void 0;
|
|
166924
166987
|
const portId = parentPortId ? `${parentPortId}.${pn}` : `${ownerId}.${pn}`;
|
|
@@ -166984,7 +167047,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
166984
167047
|
for (const { member, inherited } of nestedSources) {
|
|
166985
167048
|
if (!isPortDecl(member) || member.isDef === true)
|
|
166986
167049
|
continue;
|
|
166987
|
-
const nn =
|
|
167050
|
+
const nn = effectiveNameOf(member);
|
|
166988
167051
|
if (!nn || nestedSeen.has(nn))
|
|
166989
167052
|
continue;
|
|
166990
167053
|
nestedSeen.add(nn);
|
|
@@ -166996,7 +167059,7 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
166996
167059
|
}
|
|
166997
167060
|
};
|
|
166998
167061
|
const addPort = (portNode, inheritedFromType) => {
|
|
166999
|
-
const pn =
|
|
167062
|
+
const pn = effectiveNameOf(portNode);
|
|
167000
167063
|
if (!pn || visibleNames.has(pn))
|
|
167001
167064
|
return;
|
|
167002
167065
|
visibleNames.add(pn);
|
|
@@ -167009,9 +167072,8 @@ var SysmlDiagramModelProvider = class _SysmlDiagramModelProvider {
|
|
|
167009
167072
|
for (const m of membersOf(node))
|
|
167010
167073
|
if (isPortDecl(m) && m.isDef !== true)
|
|
167011
167074
|
addPort(m, false);
|
|
167012
|
-
const
|
|
167013
|
-
|
|
167014
|
-
for (const m of membersOf(typeDef))
|
|
167075
|
+
for (const inherited of this.inheritedTypesOf(node, index2)) {
|
|
167076
|
+
for (const m of membersOf(inherited))
|
|
167015
167077
|
if (isPortDecl(m) && m.isDef !== true)
|
|
167016
167078
|
addPort(m, true);
|
|
167017
167079
|
}
|
|
@@ -198291,7 +198353,7 @@ async function runExport(command) {
|
|
|
198291
198353
|
}
|
|
198292
198354
|
|
|
198293
198355
|
// src/main.ts
|
|
198294
|
-
var VERSION2 = true ? "0.
|
|
198356
|
+
var VERSION2 = true ? "0.19.0" : "dev";
|
|
198295
198357
|
function display(file) {
|
|
198296
198358
|
const rel2 = path9.relative(process.cwd(), file);
|
|
198297
198359
|
return rel2 && !rel2.startsWith("..") ? rel2.split(path9.sep).join("/") : file;
|