@tscircuit/schematic-trace-solver 0.0.186 → 0.0.187

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/dist/index.js CHANGED
@@ -13915,17 +13915,16 @@ var pathsIntersect = (firstPath, secondPath) => {
13915
13915
  }
13916
13916
  return false;
13917
13917
  };
13918
- var preserveAttachedLabelConnectorJunctions = ({
13918
+ var preserveAttachedTraceJunctions = ({
13919
13919
  originalTrace,
13920
13920
  candidateTrace,
13921
- traces,
13922
- netLabelConnectorTraceIds
13921
+ traces
13923
13922
  }) => {
13924
13923
  let outputTraces = traces.map(
13925
13924
  (trace) => trace.mspPairId === originalTrace.mspPairId ? candidateTrace : trace
13926
13925
  );
13927
13926
  for (const connector of traces) {
13928
- if (connector.mspPairId === originalTrace.mspPairId || !netLabelConnectorTraceIds.has(connector.mspPairId) || connector.globalConnNetId !== originalTrace.globalConnNetId || !pathsIntersect(originalTrace.tracePath, connector.tracePath) || pathsIntersect(candidateTrace.tracePath, connector.tracePath)) {
13927
+ if (connector.mspPairId === originalTrace.mspPairId || connector.globalConnNetId !== originalTrace.globalConnNetId || !pathsIntersect(originalTrace.tracePath, connector.tracePath) || pathsIntersect(candidateTrace.tracePath, connector.tracePath)) {
13929
13928
  continue;
13930
13929
  }
13931
13930
  const endpointIndex = [0, connector.tracePath.length - 1].find(
@@ -13936,6 +13935,11 @@ var preserveAttachedLabelConnectorJunctions = ({
13936
13935
  );
13937
13936
  if (endpointIndex === void 0) return null;
13938
13937
  const originalJunction = connector.tracePath[endpointIndex];
13938
+ if (connector.pins.some(
13939
+ (pin) => nearlyEqual(pin.x, originalJunction.x) && nearlyEqual(pin.y, originalJunction.y)
13940
+ )) {
13941
+ return null;
13942
+ }
13939
13943
  const movedJunction = getMovedAnchorPointForReroute(
13940
13944
  originalJunction,
13941
13945
  originalTrace.tracePath,
@@ -14314,11 +14318,10 @@ var alignSameNetJunctions = ({
14314
14318
  netLabelPlacements: outputNetLabelPlacements,
14315
14319
  attachedLabelIndexes
14316
14320
  });
14317
- const candidateTraces = preserveAttachedLabelConnectorJunctions({
14321
+ const candidateTraces = preserveAttachedTraceJunctions({
14318
14322
  originalTrace: branchTrace,
14319
14323
  candidateTrace,
14320
- traces: outputTraces,
14321
- netLabelConnectorTraceIds
14324
+ traces: outputTraces
14322
14325
  });
14323
14326
  if (!candidateTraces) continue;
14324
14327
  if (!candidateIsClear({
@@ -14333,7 +14336,7 @@ var alignSameNetJunctions = ({
14333
14336
  continue;
14334
14337
  }
14335
14338
  const movedConnectorsAreClear = candidateTraces.every((trace) => {
14336
- if (trace.mspPairId === branchTrace.mspPairId || !netLabelConnectorTraceIds.has(trace.mspPairId)) {
14339
+ if (trace.mspPairId === branchTrace.mspPairId) {
14337
14340
  return true;
14338
14341
  }
14339
14342
  const originalConnector = outputTraces.find(
@@ -648,20 +648,18 @@ const pathsIntersect = (firstPath: Point[], secondPath: Point[]) => {
648
648
  }
649
649
 
650
650
  /**
651
- * Keep generated label connectors joined when their host trace moves. Only a
651
+ * Keep same-net branches joined when their host trace moves. Only a
652
652
  * connector endpoint is projected, and only along its existing first/last
653
653
  * segment, so the label and the rest of its route stay fixed.
654
654
  */
655
- const preserveAttachedLabelConnectorJunctions = ({
655
+ const preserveAttachedTraceJunctions = ({
656
656
  originalTrace,
657
657
  candidateTrace,
658
658
  traces,
659
- netLabelConnectorTraceIds,
660
659
  }: {
661
660
  originalTrace: SolvedTracePath
662
661
  candidateTrace: SolvedTracePath
663
662
  traces: SolvedTracePath[]
664
- netLabelConnectorTraceIds: ReadonlySet<MspConnectionPairId>
665
663
  }): SolvedTracePath[] | null => {
666
664
  let outputTraces = traces.map((trace) =>
667
665
  trace.mspPairId === originalTrace.mspPairId ? candidateTrace : trace,
@@ -670,7 +668,6 @@ const preserveAttachedLabelConnectorJunctions = ({
670
668
  for (const connector of traces) {
671
669
  if (
672
670
  connector.mspPairId === originalTrace.mspPairId ||
673
- !netLabelConnectorTraceIds.has(connector.mspPairId) ||
674
671
  connector.globalConnNetId !== originalTrace.globalConnNetId ||
675
672
  !pathsIntersect(originalTrace.tracePath, connector.tracePath) ||
676
673
  pathsIntersect(candidateTrace.tracePath, connector.tracePath)
@@ -686,6 +683,16 @@ const preserveAttachedLabelConnectorJunctions = ({
686
683
  )
687
684
  if (endpointIndex === undefined) return null
688
685
  const originalJunction = connector.tracePath[endpointIndex]!
686
+ // Component pins are fixed; reject a rail move that would detach one.
687
+ if (
688
+ connector.pins.some(
689
+ (pin) =>
690
+ nearlyEqual(pin.x, originalJunction.x) &&
691
+ nearlyEqual(pin.y, originalJunction.y),
692
+ )
693
+ ) {
694
+ return null
695
+ }
689
696
  const movedJunction = getMovedAnchorPointForReroute(
690
697
  originalJunction,
691
698
  originalTrace.tracePath,
@@ -1250,11 +1257,10 @@ export const alignSameNetJunctions = ({
1250
1257
  netLabelPlacements: outputNetLabelPlacements,
1251
1258
  attachedLabelIndexes,
1252
1259
  })
1253
- const candidateTraces = preserveAttachedLabelConnectorJunctions({
1260
+ const candidateTraces = preserveAttachedTraceJunctions({
1254
1261
  originalTrace: branchTrace,
1255
1262
  candidateTrace,
1256
1263
  traces: outputTraces,
1257
- netLabelConnectorTraceIds,
1258
1264
  })
1259
1265
  if (!candidateTraces) continue
1260
1266
  if (
@@ -1272,10 +1278,7 @@ export const alignSameNetJunctions = ({
1272
1278
  }
1273
1279
 
1274
1280
  const movedConnectorsAreClear = candidateTraces.every((trace) => {
1275
- if (
1276
- trace.mspPairId === branchTrace.mspPairId ||
1277
- !netLabelConnectorTraceIds.has(trace.mspPairId)
1278
- ) {
1281
+ if (trace.mspPairId === branchTrace.mspPairId) {
1279
1282
  return true
1280
1283
  }
1281
1284
  const originalConnector = outputTraces.find(
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/tscircuit/schematic-trace-solver.git"
6
6
  },
7
7
  "main": "dist/index.js",
8
- "version": "0.0.186",
8
+ "version": "0.0.187",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "start": "cosmos",
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260907T083336Z/bug-report-20260907T083336Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />