@tscircuit/core 0.0.2305 → 0.0.2306

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22770,7 +22770,8 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
22770
22770
  const labels = /* @__PURE__ */ new Map();
22771
22771
  const labelCenters = /* @__PURE__ */ new Map();
22772
22772
  const labelAttachments = /* @__PURE__ */ new Map();
22773
- const portObstacles = [...portsByConnection.values()].flat().map(({ escape }) => ({
22773
+ const portObstacles = [...portsByConnection.values()].flat().map(({ escape, connection }) => ({
22774
+ connection,
22774
22775
  left: escape.x - 1,
22775
22776
  right: escape.x + 1,
22776
22777
  bottom: escape.y - 1,
@@ -22781,13 +22782,16 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
22781
22782
  const center = initialRoutes.get(connection).label_anchor_center;
22782
22783
  if (label !== void 0 && center) {
22783
22784
  const halfWidth = getSystemConnectionLabelWidth(label) / 2;
22784
- const occupied = [...obstacles, ...labels.values(), ...portObstacles];
22785
- const fits = (rectangle) => !occupied.some(
22786
- (r2) => rectangle.left < r2.right + 1 && rectangle.right > r2.left - 1 && rectangle.bottom < r2.top + 1 && rectangle.top > r2.bottom - 1
22787
- );
22788
22785
  const [start, end] = portsByConnection.get(connection);
22789
22786
  const endpoints = tree.endpoints.get(connection);
22790
22787
  const selfLoop = endpoints.from === endpoints.to;
22788
+ const occupied = [...obstacles, ...labels.values(), ...portObstacles];
22789
+ const fits = (rectangle, besideOwnLoop = false) => !occupied.some((r2) => {
22790
+ if (besideOwnLoop && "connection" in r2 && r2.connection === connection)
22791
+ return false;
22792
+ const margin = besideOwnLoop && "connection" in r2 ? 0 : 1;
22793
+ return rectangle.left < r2.right + margin && rectangle.right > r2.left - margin && rectangle.bottom < r2.top + margin && rectangle.top > r2.bottom - margin;
22794
+ });
22791
22795
  const vertical = start.escape.x === end.escape.x;
22792
22796
  const horizontal = start.escape.y === end.escape.y;
22793
22797
  const oppositeFaces = (start.side + 2) % 4 === end.side;
@@ -22804,14 +22808,20 @@ function routeSystemBlocks(tree, bounds, initialRoutes) {
22804
22808
  };
22805
22809
  const signs = selfLoop ? [start.side < 2 ? 1 : -1] : [1, -1];
22806
22810
  for (const sign of signs) {
22807
- const candidate = vertical ? { x: attachment.x + sign * (halfWidth + 2), y: attachment.y } : { x: attachment.x, y: attachment.y + sign * 4.5 };
22811
+ const candidate = vertical ? {
22812
+ x: attachment.x + sign * (halfWidth + (selfLoop ? 0 : 2)),
22813
+ y: attachment.y
22814
+ } : {
22815
+ x: attachment.x,
22816
+ y: attachment.y + sign * (selfLoop ? 3.5 : 4.5)
22817
+ };
22808
22818
  const rectangle = {
22809
22819
  left: candidate.x - halfWidth,
22810
22820
  right: candidate.x + halfWidth,
22811
22821
  bottom: candidate.y - 2.5,
22812
22822
  top: candidate.y + 2.5
22813
22823
  };
22814
- if (!fits(rectangle)) continue;
22824
+ if (!fits(rectangle, sameFaceReturn)) continue;
22815
22825
  labels.set(connection, rectangle);
22816
22826
  labelCenters.set(connection, candidate);
22817
22827
  labelAttachments.set(connection, attachment);
@@ -159360,7 +159370,7 @@ var RoutingPhasePreparationError = class extends Error {
159360
159370
  var package_default = {
159361
159371
  name: "@tscircuit/core",
159362
159372
  type: "module",
159363
- version: "0.0.2304",
159373
+ version: "0.0.2305",
159364
159374
  types: "dist/index.d.ts",
159365
159375
  main: "dist/index.js",
159366
159376
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.2305",
4
+ "version": "0.0.2306",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",