schematex 0.6.8 → 0.6.10

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.
@@ -5169,6 +5169,22 @@ function layoutPid(ast) {
5169
5169
  equipById.set(equip.id, layoutEq);
5170
5170
  cursorX += geo.width + EQUIP_GAP_X;
5171
5171
  }
5172
+ const lineMidById = /* @__PURE__ */ new Map();
5173
+ for (const ln of ast.lines) {
5174
+ const from = equipById.get(ln.from.id);
5175
+ const to = equipById.get(ln.to.id);
5176
+ if (!from || !to) continue;
5177
+ const fa = getAnchor(from, ln.from.port, "out");
5178
+ const ta = getAnchor(to, ln.to.port, "in");
5179
+ lineMidById.set(ln.id, { x: (fa.x + ta.x) / 2, y: (fa.y + ta.y) / 2 });
5180
+ }
5181
+ const targetX = (tgt, fallback) => {
5182
+ const eq = equipById.get(tgt);
5183
+ if (eq) return eq.cx;
5184
+ const lm = lineMidById.get(tgt);
5185
+ if (lm) return lm.x;
5186
+ return fallback;
5187
+ };
5172
5188
  const instruments = [];
5173
5189
  const instById = /* @__PURE__ */ new Map();
5174
5190
  const crBandY = PADDING + TITLE_AREA + 40;
@@ -5178,20 +5194,17 @@ function layoutPid(ast) {
5178
5194
  let cy = 0;
5179
5195
  if (inst.category.startsWith("cr_")) {
5180
5196
  const tgt = inst.controls ?? inst.measures ?? "";
5181
- const tgtEq = equipById.get(tgt);
5182
- cx = tgtEq ? tgtEq.cx : PADDING + 80 + crSlot * (INST_RADIUS * 2 + 28);
5197
+ cx = targetX(tgt, PADDING + 80 + crSlot * (INST_RADIUS * 2 + 28));
5183
5198
  cy = crBandY;
5184
5199
  crSlot += 1;
5185
5200
  } else if (inst.category.startsWith("local_")) {
5186
5201
  cy = rowY + maxH / 2 + INST_OFFSET + INST_RADIUS;
5187
5202
  const tgt = inst.measures ?? inst.controls ?? "";
5188
- const tgtEq = equipById.get(tgt);
5189
- cx = tgtEq ? tgtEq.cx : PADDING + 80;
5203
+ cx = targetX(tgt, PADDING + 80);
5190
5204
  } else {
5191
5205
  cy = rowY + maxH / 2 + INST_OFFSET;
5192
5206
  const tgt = inst.measures ?? inst.controls ?? "";
5193
- const tgtEq = equipById.get(tgt);
5194
- cx = tgtEq ? tgtEq.cx : PADDING + 80;
5207
+ cx = targetX(tgt, PADDING + 80);
5195
5208
  }
5196
5209
  const lay = {
5197
5210
  inst,
@@ -5202,13 +5215,14 @@ function layoutPid(ast) {
5202
5215
  instruments.push(lay);
5203
5216
  instById.set(inst.tag, lay);
5204
5217
  }
5205
- const sameRow = (a, b) => Math.abs(a.cy - b.cy) < INST_RADIUS && Math.abs(a.cx - b.cx) < INST_RADIUS * 2 + 8;
5218
+ const INST_FANOUT = INST_RADIUS * 2 + 12;
5219
+ const sameYRow = (a, b) => Math.abs(a.cy - b.cy) < INST_RADIUS;
5206
5220
  const sortedByX = [...instruments].sort((a, b) => a.cx - b.cx);
5207
5221
  for (let i = 1; i < sortedByX.length; i++) {
5208
5222
  const prev = sortedByX[i - 1];
5209
5223
  const cur = sortedByX[i];
5210
- if (sameRow(prev, cur)) {
5211
- cur.cx = prev.cx + INST_RADIUS * 2 + 14;
5224
+ if (sameYRow(prev, cur) && cur.cx < prev.cx + INST_FANOUT) {
5225
+ cur.cx = prev.cx + INST_FANOUT;
5212
5226
  }
5213
5227
  }
5214
5228
  const lines = [];
@@ -5298,6 +5312,7 @@ var STYLE2 = `
5298
5312
  .lt-inst-local-line { stroke: #1d1d1d; stroke-width: 1; stroke-dasharray: 2 2; }
5299
5313
  .lt-pid-valve-body { fill: #ffffff; stroke: #1d1d1d; stroke-width: 1.4; }
5300
5314
 
5315
+ .lt-pid-line-path { fill: none; }
5301
5316
  .lt-pid-line-tag-bg { fill: #ffffff; stroke: #1d1d1d; stroke-width: 0.6; }
5302
5317
  .lt-pid-line-tag-text { font: 9px ui-monospace, monospace; fill: #1d1d1d; }
5303
5318
 
@@ -5308,15 +5323,37 @@ var STYLE2 = `
5308
5323
  .lt-pid-unknown-type { font: 9px ui-monospace, monospace; fill: #6a6a6a; }
5309
5324
  `;
5310
5325
  var ARROW_ID = "lt-pid-arrow";
5326
+ var LINE_CLASS = {
5327
+ process: "lt-pid-process",
5328
+ process_minor: "lt-pid-process-min",
5329
+ pneumatic: "lt-pid-pneumatic",
5330
+ electric: "lt-pid-electric",
5331
+ hydraulic: "lt-pid-hydraulic",
5332
+ capillary: "lt-pid-capillary",
5333
+ software: "lt-pid-software",
5334
+ mechanical: "lt-pid-mechanical"
5335
+ };
5336
+ var SIGNAL_LINE_TYPES = /* @__PURE__ */ new Set([
5337
+ "pneumatic",
5338
+ "electric",
5339
+ "hydraulic",
5340
+ "capillary",
5341
+ "software",
5342
+ "mechanical"
5343
+ ]);
5311
5344
  function lineClass(t) {
5312
- return `lt-pid-${t.replace("_", "-")}`;
5345
+ return LINE_CLASS[t] ?? `lt-pid-${String(t).replace(/_/g, "-")}`;
5346
+ }
5347
+ function isSignalLine(l) {
5348
+ return SIGNAL_LINE_TYPES.has(l.line.lineType);
5313
5349
  }
5314
5350
  function renderLine(l) {
5315
5351
  const cls = lineClass(l.line.lineType);
5316
5352
  const parts = [
5317
5353
  path({
5318
5354
  d: l.path,
5319
- class: cls,
5355
+ // Type class + a shared no-fill guard class on every line path.
5356
+ class: `${cls} lt-pid-line-path`,
5320
5357
  "data-line-id": l.line.id,
5321
5358
  "data-service": l.line.service ?? ""
5322
5359
  })
@@ -5483,9 +5520,16 @@ function renderLayout2(layout) {
5483
5520
  el("style", {}, STYLE2)
5484
5521
  ]),
5485
5522
  titleNode,
5523
+ // Z-order: process pipes behind equipment; signal lines + instruments above.
5524
+ group(
5525
+ { class: "lt-pid-lines lt-pid-process-lines" },
5526
+ layout.lines.filter((l) => !isSignalLine(l)).map(renderLine)
5527
+ ),
5486
5528
  group({ class: "lt-pid-equipment" }, equipNodes),
5487
- group({ class: "lt-pid-lines" }, layout.lines.map(renderLine)),
5488
- group({ class: "lt-pid-signals" }, autoSignals),
5529
+ group(
5530
+ { class: "lt-pid-lines lt-pid-signal-lines" },
5531
+ [...layout.lines.filter(isSignalLine).map(renderLine), ...autoSignals]
5532
+ ),
5489
5533
  group({ class: "lt-pid-instruments" }, instNodes)
5490
5534
  ]
5491
5535
  );
@@ -14905,7 +14949,6 @@ function layoutUmlClass(ast) {
14905
14949
  n.box.layer = n.rank;
14906
14950
  }
14907
14951
  }
14908
- applyDirectionTransform(direction, nodes, boxes);
14909
14952
  normaliseCoords(nodes, boxes);
14910
14953
  const packages = layoutPackages(ast, boxByID);
14911
14954
  shiftForPackages(nodes, boxes, packages);
@@ -14913,29 +14956,6 @@ function layoutUmlClass(ast) {
14913
14956
  const { edges, trees } = routeEdges(chains, nodes, boxByID, vertical);
14914
14957
  return { ast, boxes, packages, edges, trees, width, height };
14915
14958
  }
14916
- function applyDirectionTransform(direction, nodes, boxes) {
14917
- if (direction === "tb") return;
14918
- const transform = (p) => {
14919
- switch (direction) {
14920
- case "bt":
14921
- return { x: p.x, y: -p.y };
14922
- case "lr":
14923
- return { x: p.y, y: p.x };
14924
- case "rl":
14925
- return { x: -p.y, y: p.x };
14926
- }
14927
- };
14928
- for (const n of nodes) {
14929
- const p = transform({ x: n.cx, y: n.cy });
14930
- n.cx = p.x;
14931
- n.cy = p.y;
14932
- }
14933
- for (const b of boxes) {
14934
- const c = transform({ x: b.x + b.width / 2, y: b.y + b.height / 2 });
14935
- b.x = c.x - b.width / 2;
14936
- b.y = c.y - b.height / 2;
14937
- }
14938
- }
14939
14959
  function topLevelPackageMap(ast) {
14940
14960
  const parentOf = /* @__PURE__ */ new Map();
14941
14961
  for (const p of ast.packages) parentOf.set(p.id, p.parentId);
@@ -16211,14 +16231,12 @@ function parseFaultTree(text2) {
16211
16231
  }
16212
16232
  if (/^layout\s*:/i.test(t)) {
16213
16233
  const v = afterColon2(t).toLowerCase();
16214
- if (v === "tb") ast.direction = v;
16215
- else if (v === "bt") ast.warnings.push(`Line ${lineNo}: layout: bt is reserved but not implemented yet; using layout: tb.`);
16234
+ if (v === "tb" || v === "bt") ast.direction = v;
16216
16235
  continue;
16217
16236
  }
16218
16237
  if (/^style\s*:/i.test(t)) {
16219
16238
  const v = afterColon2(t).toLowerCase();
16220
- if (v === "ansi") ast.gateStyle = v;
16221
- else if (v === "iec") ast.warnings.push(`Line ${lineNo}: style: iec is reserved but not implemented yet; using style: ansi.`);
16239
+ if (v === "ansi" || v === "iec") ast.gateStyle = v;
16222
16240
  continue;
16223
16241
  }
16224
16242
  if (/^transfer\b/i.test(t)) {
@@ -17252,7 +17270,6 @@ function summarise(layout) {
17252
17270
  if (analysis.topProb !== void 0) parts.push(`P(top) = ${fmtProb(analysis.topProb)} (${analysis.method}).`);
17253
17271
  else if (analysis.missingProb.length > 0) parts.push(`P(top) = n/a \u2014 missing p on ${analysis.missingProb.join(", ")}.`);
17254
17272
  }
17255
- for (const w of ast.warnings) parts.push(w);
17256
17273
  for (const n of analysis.notes) parts.push(n);
17257
17274
  for (const w of analysis.warnings) parts.push(w);
17258
17275
  return parts.join(" ");
@@ -17349,8 +17366,7 @@ function parseBowtie(text2) {
17349
17366
  const lineNo = i + 1;
17350
17367
  if (/^layout\s*:/i.test(t)) {
17351
17368
  const v = afterColon3(t).toLowerCase();
17352
- if (v === "symmetric") ast.layout = v;
17353
- else if (v === "compact") ast.warnings.push(`Line ${lineNo}: layout: compact is reserved but not implemented yet; using layout: symmetric.`);
17369
+ if (v === "symmetric" || v === "compact") ast.layout = v;
17354
17370
  continue;
17355
17371
  }
17356
17372
  if (/^legend\s*:/i.test(t)) {
@@ -26740,5 +26756,5 @@ function renderWithPlugin(prepared, plugin, config) {
26740
26756
  }
26741
26757
 
26742
26758
  export { GEOMETRY, bowtie2 as bowtie, decisiontree, drawDeviceIcon, faulttree, iconSize, network, parse, parseResult, pert, petri, pid, prisma, render, renderEquip, renderPreview, renderResult, sequence, state, timeline, umlclass, usecase };
26743
- //# sourceMappingURL=chunk-J2TT7PGI.js.map
26744
- //# sourceMappingURL=chunk-J2TT7PGI.js.map
26759
+ //# sourceMappingURL=chunk-6AWASOFO.js.map
26760
+ //# sourceMappingURL=chunk-6AWASOFO.js.map