@tscircuit/core 0.0.1358 → 0.0.1359

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 +30 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18108,7 +18108,12 @@ var TEXT_BOX_ENABLED_FTYPES = /* @__PURE__ */ new Set([
18108
18108
  "simple_crystal",
18109
18109
  "simple_resonator",
18110
18110
  "simple_potentiometer",
18111
- "simple_fuse"
18111
+ "simple_fuse",
18112
+ "simple_diode",
18113
+ "simple_led",
18114
+ "simple_transistor",
18115
+ "simple_mosfet",
18116
+ "simple_op_amp"
18112
18117
  ]);
18113
18118
  function getTextBounds({
18114
18119
  text,
@@ -19940,35 +19945,33 @@ function extendTraceEndpointsToReachPinsInsideExpandedBoundingBox(params, db) {
19940
19945
  usedCenters.add(i);
19941
19946
  }
19942
19947
  }
19943
- const snap = (endpoint) => {
19944
- const pt = endpoint === "start" ? result[0] : result[result.length - 1];
19945
- let bestIndex = -1;
19946
- let bestDist = Number.POSITIVE_INFINITY;
19948
+ const ALIGN_EPS = 1e-3;
19949
+ const endpoints = ["start", "end"];
19950
+ const candidates = [];
19951
+ for (const endpoint of endpoints) {
19952
+ const endpointPoint = endpoint === "start" ? result[0] : result[result.length - 1];
19947
19953
  for (let i = 0; i < centers.length; i++) {
19948
19954
  if (usedCenters.has(i)) continue;
19949
- const dist = d2(centers[i], pt);
19950
- if (dist < bestDist) {
19951
- bestDist = dist;
19952
- bestIndex = i;
19955
+ const center = centers[i];
19956
+ const dist = d2(center, endpointPoint);
19957
+ if (dist > MAX_PIN_SNAP_GAP ** 2) continue;
19958
+ if (Math.abs(center.x - endpointPoint.x) > ALIGN_EPS && Math.abs(center.y - endpointPoint.y) > ALIGN_EPS) {
19959
+ continue;
19953
19960
  }
19961
+ candidates.push({ endpoint, centerIndex: i, dist });
19954
19962
  }
19955
- if (bestIndex < 0) return;
19956
- if (bestDist <= 1e-12) {
19957
- usedCenters.add(bestIndex);
19958
- return;
19959
- }
19960
- if (bestDist > MAX_PIN_SNAP_GAP ** 2) return;
19961
- const c = centers[bestIndex];
19962
- const ALIGN_EPS = 1e-3;
19963
- if (Math.abs(c.x - pt.x) > ALIGN_EPS && Math.abs(c.y - pt.y) > ALIGN_EPS) {
19964
- return;
19965
- }
19966
- usedCenters.add(bestIndex);
19967
- if (endpoint === "start") result.unshift({ x: c.x, y: c.y });
19968
- else result.push({ x: c.x, y: c.y });
19969
- };
19970
- snap("start");
19971
- snap("end");
19963
+ }
19964
+ candidates.sort((a, b) => a.dist - b.dist);
19965
+ const usedEndpoints = /* @__PURE__ */ new Set();
19966
+ for (const { endpoint, centerIndex, dist } of candidates) {
19967
+ if (usedEndpoints.has(endpoint) || usedCenters.has(centerIndex)) continue;
19968
+ usedCenters.add(centerIndex);
19969
+ usedEndpoints.add(endpoint);
19970
+ if (dist <= 1e-12) continue;
19971
+ const center = centers[centerIndex];
19972
+ if (endpoint === "start") result.unshift({ x: center.x, y: center.y });
19973
+ else result.push({ x: center.x, y: center.y });
19974
+ }
19972
19975
  return result;
19973
19976
  }
19974
19977
  function applyTracesFromSolverOutput(args) {
@@ -24237,7 +24240,7 @@ import { identity as identity5 } from "transformation-matrix";
24237
24240
  var package_default = {
24238
24241
  name: "@tscircuit/core",
24239
24242
  type: "module",
24240
- version: "0.0.1357",
24243
+ version: "0.0.1358",
24241
24244
  types: "dist/index.d.ts",
24242
24245
  main: "dist/index.js",
24243
24246
  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.1358",
4
+ "version": "0.0.1359",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",