@tscircuit/core 0.0.554 → 0.0.556

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 (3) hide show
  1. package/dist/index.d.ts +202 -206
  2. package/dist/index.js +125 -55
  3. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -811,13 +811,12 @@ var PrimitiveComponent2 = class extends Renderable {
811
811
  */
812
812
  _getPcbManualPlacementForComponent(component) {
813
813
  if (!this.isSubcircuit) return null;
814
- const layout = this.props.layout;
815
814
  const manualEdits = this.props.manualEdits;
816
- if (!layout && !manualEdits) return null;
817
- const placementConfigPositions = layout?.manual_pcb_placement_config?.positions || manualEdits?.pcb_placements;
815
+ if (!manualEdits) return null;
816
+ const placementConfigPositions = manualEdits?.pcb_placements;
818
817
  if (!placementConfigPositions) return null;
819
818
  for (const position of placementConfigPositions) {
820
- if (layout && isMatchingSelector(component, position.selector) || component.props.name === position.selector) {
819
+ if (isMatchingSelector(component, position.selector) || component.props.name === position.selector) {
821
820
  const center = applyToPoint(
822
821
  this._computePcbGlobalTransformBeforeLayout(),
823
822
  position.center
@@ -4373,6 +4372,8 @@ var computeSchematicNetLabelCenter = ({
4373
4372
  // lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
4374
4373
  import { MultilayerIjump } from "@tscircuit/infgrid-ijump-astar";
4375
4374
  import "circuit-json";
4375
+ import { calculateElbow } from "calculate-elbow";
4376
+ import { doesLineIntersectLine as doesLineIntersectLine3 } from "@tscircuit/math-utils";
4376
4377
 
4377
4378
  // lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-crossing-segments.ts
4378
4379
  import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
@@ -4856,6 +4857,71 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
4856
4857
  if (portsWithPosition.length < 2) {
4857
4858
  return;
4858
4859
  }
4860
+ const attemptElbowEdges = () => {
4861
+ const elbowEdges = [];
4862
+ for (let i = 0; i < portsWithPosition.length - 1; i++) {
4863
+ const start = portsWithPosition[i];
4864
+ const end = portsWithPosition[i + 1];
4865
+ const path = calculateElbow(
4866
+ {
4867
+ x: start.position.x,
4868
+ y: start.position.y,
4869
+ facingDirection: start.facingDirection
4870
+ },
4871
+ {
4872
+ x: end.position.x,
4873
+ y: end.position.y,
4874
+ facingDirection: end.facingDirection
4875
+ }
4876
+ );
4877
+ for (let j = 0; j < path.length - 1; j++) {
4878
+ elbowEdges.push({ from: path[j], to: path[j + 1] });
4879
+ }
4880
+ }
4881
+ const doesSegmentIntersectRect = (edge, rect) => {
4882
+ const halfW = rect.width / 2;
4883
+ const halfH = rect.height / 2;
4884
+ const left = rect.center.x - halfW;
4885
+ const right = rect.center.x + halfW;
4886
+ const top = rect.center.y - halfH;
4887
+ const bottom = rect.center.y + halfH;
4888
+ const inRect = (p) => p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
4889
+ if (inRect(edge.from) || inRect(edge.to)) return true;
4890
+ const rectEdges = [
4891
+ [
4892
+ { x: left, y: top },
4893
+ { x: right, y: top }
4894
+ ],
4895
+ [
4896
+ { x: right, y: top },
4897
+ { x: right, y: bottom }
4898
+ ],
4899
+ [
4900
+ { x: right, y: bottom },
4901
+ { x: left, y: bottom }
4902
+ ],
4903
+ [
4904
+ { x: left, y: bottom },
4905
+ { x: left, y: top }
4906
+ ]
4907
+ ];
4908
+ return rectEdges.some(
4909
+ (r) => doesLineIntersectLine3([edge.from, edge.to], r, { lineThickness: 0 })
4910
+ );
4911
+ };
4912
+ for (const edge of elbowEdges) {
4913
+ for (const obstacle of obstacles) {
4914
+ if (doesSegmentIntersectRect(edge, obstacle)) {
4915
+ return null;
4916
+ }
4917
+ }
4918
+ }
4919
+ return elbowEdges;
4920
+ };
4921
+ let edges = attemptElbowEdges();
4922
+ if (edges && edges.length === 0) {
4923
+ edges = null;
4924
+ }
4859
4925
  connection.pointsToConnect = portsWithPosition.map(({ position }) => ({
4860
4926
  ...position,
4861
4927
  layer: "top"
@@ -4880,54 +4946,56 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
4880
4946
  Autorouter = DirectLineRouter;
4881
4947
  skipOtherTraceInteraction = true;
4882
4948
  }
4883
- const autorouter = new Autorouter({
4884
- input: simpleRouteJsonInput,
4885
- MAX_ITERATIONS: 100,
4886
- OBSTACLE_MARGIN: 0.1,
4887
- isRemovePathLoopsEnabled: true,
4888
- isShortenPathWithShortcutsEnabled: true,
4889
- marginsWithCosts: [
4890
- {
4891
- margin: 1,
4892
- enterCost: 0,
4893
- travelCostFactor: 1
4894
- },
4895
- {
4896
- margin: 0.3,
4897
- enterCost: 0,
4898
- travelCostFactor: 1
4899
- },
4900
- {
4901
- margin: 0.2,
4902
- enterCost: 0,
4903
- travelCostFactor: 2
4904
- },
4905
- {
4906
- margin: 0.1,
4907
- enterCost: 0,
4908
- travelCostFactor: 3
4949
+ if (!edges) {
4950
+ const autorouter = new Autorouter({
4951
+ input: simpleRouteJsonInput,
4952
+ MAX_ITERATIONS: 100,
4953
+ OBSTACLE_MARGIN: 0.1,
4954
+ isRemovePathLoopsEnabled: true,
4955
+ isShortenPathWithShortcutsEnabled: true,
4956
+ marginsWithCosts: [
4957
+ {
4958
+ margin: 1,
4959
+ enterCost: 0,
4960
+ travelCostFactor: 1
4961
+ },
4962
+ {
4963
+ margin: 0.3,
4964
+ enterCost: 0,
4965
+ travelCostFactor: 1
4966
+ },
4967
+ {
4968
+ margin: 0.2,
4969
+ enterCost: 0,
4970
+ travelCostFactor: 2
4971
+ },
4972
+ {
4973
+ margin: 0.1,
4974
+ enterCost: 0,
4975
+ travelCostFactor: 3
4976
+ }
4977
+ ]
4978
+ });
4979
+ let results = autorouter.solveAndMapToTraces();
4980
+ if (results.length === 0) {
4981
+ if (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection()) {
4982
+ trace._doInitialSchematicTraceRenderWithDisplayLabel();
4983
+ return;
4909
4984
  }
4910
- ]
4911
- });
4912
- let results = autorouter.solveAndMapToTraces();
4913
- if (results.length === 0) {
4914
- if (trace._isSymbolToChipConnection() || trace._isSymbolToSymbolConnection() || trace._isChipToChipConnection()) {
4915
- trace._doInitialSchematicTraceRenderWithDisplayLabel();
4916
- return;
4985
+ const directLineRouter = new DirectLineRouter({
4986
+ input: simpleRouteJsonInput
4987
+ });
4988
+ results = directLineRouter.solveAndMapToTraces();
4989
+ skipOtherTraceInteraction = true;
4990
+ }
4991
+ const [{ route }] = results;
4992
+ edges = [];
4993
+ for (let i = 0; i < route.length - 1; i++) {
4994
+ edges.push({
4995
+ from: route[i],
4996
+ to: route[i + 1]
4997
+ });
4917
4998
  }
4918
- const directLineRouter = new DirectLineRouter({
4919
- input: simpleRouteJsonInput
4920
- });
4921
- results = directLineRouter.solveAndMapToTraces();
4922
- skipOtherTraceInteraction = true;
4923
- }
4924
- const [{ route }] = results;
4925
- let edges = [];
4926
- for (let i = 0; i < route.length - 1; i++) {
4927
- edges.push({
4928
- from: route[i],
4929
- to: route[i + 1]
4930
- });
4931
4999
  }
4932
5000
  const source_trace_id = trace.source_trace_id;
4933
5001
  let junctions = [];
@@ -4945,6 +5013,9 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
4945
5013
  source_trace_id: trace.source_trace_id
4946
5014
  });
4947
5015
  }
5016
+ if (!edges || edges.length === 0) {
5017
+ return;
5018
+ }
4948
5019
  const lastEdge = edges[edges.length - 1];
4949
5020
  const lastEdgePort = portsWithPosition[portsWithPosition.length - 1];
4950
5021
  const lastDominantDirection = getDominantDirection(lastEdge);
@@ -7882,7 +7953,7 @@ var Group = class extends NormalComponent {
7882
7953
  const { db } = this.root;
7883
7954
  const groupProps2 = props;
7884
7955
  if (!this.isSubcircuit) return;
7885
- const manualTraceHints = groupProps2.layout?.manual_trace_hints;
7956
+ const manualTraceHints = groupProps2.manualEdits?.manual_trace_hints;
7886
7957
  if (!manualTraceHints) return;
7887
7958
  for (const manualTraceHint of manualTraceHints) {
7888
7959
  this.add(
@@ -10716,7 +10787,7 @@ import { identity as identity5 } from "transformation-matrix";
10716
10787
  var package_default = {
10717
10788
  name: "@tscircuit/core",
10718
10789
  type: "module",
10719
- version: "0.0.553",
10790
+ version: "0.0.555",
10720
10791
  types: "dist/index.d.ts",
10721
10792
  main: "dist/index.js",
10722
10793
  module: "dist/index.js",
@@ -10740,15 +10811,14 @@ var package_default = {
10740
10811
  devDependencies: {
10741
10812
  "@biomejs/biome": "^1.8.3",
10742
10813
  "@tscircuit/capacity-autorouter": "^0.0.93",
10743
- "@tscircuit/checks": "^0.0.52",
10814
+ "@tscircuit/checks": "^0.0.56",
10744
10815
  "@tscircuit/circuit-json-util": "^0.0.51",
10745
10816
  "@tscircuit/footprinter": "^0.0.189",
10746
10817
  "@tscircuit/import-snippet": "^0.0.4",
10747
10818
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
10748
- "@tscircuit/layout": "^0.0.28",
10749
10819
  "@tscircuit/log-soup": "^1.0.2",
10750
10820
  "@tscircuit/math-utils": "^0.0.18",
10751
- "@tscircuit/props": "^0.0.251",
10821
+ "@tscircuit/props": "^0.0.255",
10752
10822
  "@tscircuit/schematic-autolayout": "^0.0.6",
10753
10823
  "@tscircuit/schematic-corpus": "^0.0.52",
10754
10824
  "@tscircuit/schematic-match-adapt": "^0.0.16",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.554",
4
+ "version": "0.0.556",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -25,15 +25,14 @@
25
25
  "devDependencies": {
26
26
  "@biomejs/biome": "^1.8.3",
27
27
  "@tscircuit/capacity-autorouter": "^0.0.93",
28
- "@tscircuit/checks": "^0.0.52",
28
+ "@tscircuit/checks": "^0.0.56",
29
29
  "@tscircuit/circuit-json-util": "^0.0.51",
30
30
  "@tscircuit/footprinter": "^0.0.189",
31
31
  "@tscircuit/import-snippet": "^0.0.4",
32
32
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
33
- "@tscircuit/layout": "^0.0.28",
34
33
  "@tscircuit/log-soup": "^1.0.2",
35
34
  "@tscircuit/math-utils": "^0.0.18",
36
- "@tscircuit/props": "^0.0.251",
35
+ "@tscircuit/props": "^0.0.255",
37
36
  "@tscircuit/schematic-autolayout": "^0.0.6",
38
37
  "@tscircuit/schematic-corpus": "^0.0.52",
39
38
  "@tscircuit/schematic-match-adapt": "^0.0.16",