@tscircuit/core 0.0.1394 → 0.0.1396

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 +55 -12
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -19810,8 +19810,18 @@ import { SchematicTracePipelineSolver as SchematicTracePipelineSolver4 } from "@
19810
19810
  import Debug12 from "debug";
19811
19811
 
19812
19812
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
19813
+ import {
19814
+ getBoundFromCenteredRect as getBoundFromCenteredRect4,
19815
+ getBoundsCenter as getBoundsCenter2
19816
+ } from "@tscircuit/math-utils";
19813
19817
  import "@tscircuit/schematic-trace-solver";
19814
19818
 
19819
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/schematicTextToTextBounds.ts
19820
+ import {
19821
+ getBoundFromCenteredRect as getBoundFromCenteredRect3,
19822
+ getBoundsCenter
19823
+ } from "@tscircuit/math-utils";
19824
+
19815
19825
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicTextBounds.ts
19816
19826
  import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
19817
19827
  var DEFAULT_SCHEMATIC_TEXT_FONT_SIZE = 0.18;
@@ -19863,10 +19873,29 @@ function getSchematicTextBounds(text) {
19863
19873
  }
19864
19874
 
19865
19875
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/schematicTextToTextBounds.ts
19866
- import { getBoundsCenter } from "@tscircuit/math-utils";
19867
- function schematicTextToTextBox(text) {
19876
+ var REFDES_TEXT_BOX_CHIP_OVERLAP = 0.01;
19877
+ var REFDES_TEXT_BOX_CLEARANCE = 0.06;
19878
+ function isReferenceDesignatorText(text, sourceComponent) {
19879
+ if (!sourceComponent) return false;
19880
+ return text.text === sourceComponent.display_name || text.text === sourceComponent.name;
19881
+ }
19882
+ function schematicTextToTextBox(text, options = {}) {
19868
19883
  if (!text.text) return null;
19869
19884
  const bounds = getSchematicTextBounds(text);
19885
+ if (isReferenceDesignatorText(text, options.sourceComponent) && options.schematicComponent?.center && options.schematicComponent?.size) {
19886
+ const componentBounds = getBoundFromCenteredRect3({
19887
+ center: options.schematicComponent.center,
19888
+ width: options.schematicComponent.size.width,
19889
+ height: options.schematicComponent.size.height
19890
+ });
19891
+ const textHeight = bounds.maxY - bounds.minY;
19892
+ if (bounds.minY > componentBounds.maxY) {
19893
+ bounds.minX -= REFDES_TEXT_BOX_CLEARANCE;
19894
+ bounds.maxX += REFDES_TEXT_BOX_CLEARANCE;
19895
+ bounds.minY = componentBounds.maxY - REFDES_TEXT_BOX_CHIP_OVERLAP;
19896
+ bounds.maxY = componentBounds.maxY + textHeight + REFDES_TEXT_BOX_CLEARANCE;
19897
+ }
19898
+ }
19870
19899
  return {
19871
19900
  chipId: text.schematic_component_id,
19872
19901
  center: getBoundsCenter(bounds),
@@ -19877,10 +19906,6 @@ function schematicTextToTextBox(text) {
19877
19906
  }
19878
19907
 
19879
19908
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
19880
- import {
19881
- getBoundFromCenteredRect as getBoundFromCenteredRect3,
19882
- getBoundsCenter as getBoundsCenter2
19883
- } from "@tscircuit/math-utils";
19884
19909
  var DEFAULT_MAX_MSP_PAIR_DISTANCE = 2.4;
19885
19910
  var SCHEMATIC_RAIL_NET_LABEL_HEIGHT = 0.42;
19886
19911
  function createSchematicTraceSolverInputProblem(group) {
@@ -19896,9 +19921,27 @@ function createSchematicTraceSolverInputProblem(group) {
19896
19921
  const schematicComponentIds = new Set(
19897
19922
  schematicComponents.map((component) => component.schematic_component_id)
19898
19923
  );
19924
+ const schematicComponentsById = new Map(
19925
+ schematicComponents.map((component) => [
19926
+ component.schematic_component_id,
19927
+ component
19928
+ ])
19929
+ );
19899
19930
  const textBoxes = db.schematic_text.list().filter(
19900
19931
  (text) => text.schematic_component_id && schematicComponentIds.has(text.schematic_component_id)
19901
- ).map(schematicTextToTextBox).filter((textBox) => Boolean(textBox));
19932
+ ).map((text) => {
19933
+ const schematicComponent = schematicComponentsById.get(
19934
+ text.schematic_component_id
19935
+ );
19936
+ if (!schematicComponent) return;
19937
+ const sourceComponent = db.source_component.get(
19938
+ schematicComponent.source_component_id
19939
+ );
19940
+ return schematicTextToTextBox(text, {
19941
+ schematicComponent,
19942
+ sourceComponent
19943
+ });
19944
+ }).filter((textBox) => Boolean(textBox));
19902
19945
  const componentNameToSectionId = /* @__PURE__ */ new Map();
19903
19946
  for (const component of group.getDescendants()) {
19904
19947
  if (component.name && component._parsedProps?.schSectionName) {
@@ -19937,7 +19980,7 @@ function createSchematicTraceSolverInputProblem(group) {
19937
19980
  if (sourceComponent?.name) {
19938
19981
  sectionId = componentNameToSectionId.get(sourceComponent.name);
19939
19982
  }
19940
- const layoutBounds = getSchematicComponentWithTextBounds(db, schematicComponent) ?? getBoundFromCenteredRect3({
19983
+ const layoutBounds = getSchematicComponentWithTextBounds(db, schematicComponent) ?? getBoundFromCenteredRect4({
19941
19984
  center: schematicComponent.center,
19942
19985
  width: schematicComponent.size.width,
19943
19986
  height: schematicComponent.size.height
@@ -25238,7 +25281,7 @@ import { identity as identity5 } from "transformation-matrix";
25238
25281
  var package_default = {
25239
25282
  name: "@tscircuit/core",
25240
25283
  type: "module",
25241
- version: "0.0.1393",
25284
+ version: "0.0.1395",
25242
25285
  types: "dist/index.d.ts",
25243
25286
  main: "dist/index.js",
25244
25287
  module: "dist/index.js",
@@ -25289,7 +25332,7 @@ var package_default = {
25289
25332
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
25290
25333
  "@tscircuit/props": "^0.0.567",
25291
25334
  "@tscircuit/schematic-match-adapt": "^0.0.18",
25292
- "@tscircuit/schematic-trace-solver": "^0.0.84",
25335
+ "@tscircuit/schematic-trace-solver": "^0.0.87",
25293
25336
  "@tscircuit/solver-utils": "^0.0.16",
25294
25337
  "@tscircuit/soup-util": "^0.0.41",
25295
25338
  "@types/bun": "^1.2.16",
@@ -28592,7 +28635,7 @@ import { distance as distance16 } from "@tscircuit/math-utils";
28592
28635
  // node_modules/@tscircuit/breakout-point-solver/lib/pad/breakout-pad-collisions.ts
28593
28636
  import {
28594
28637
  doesSegmentIntersectRect,
28595
- getBoundFromCenteredRect as getBoundFromCenteredRect4
28638
+ getBoundFromCenteredRect as getBoundFromCenteredRect5
28596
28639
  } from "@tscircuit/math-utils";
28597
28640
  var degreesToRadians = (degrees) => degrees * Math.PI / 180;
28598
28641
  var rotatePoint = (point6, radians) => {
@@ -28615,7 +28658,7 @@ var getLocalPadPoint = (point6, pad) => {
28615
28658
  };
28616
28659
  var getInflatedPadRect = (pad) => {
28617
28660
  const clearance = pad.clearance ?? 0;
28618
- return getBoundFromCenteredRect4({
28661
+ return getBoundFromCenteredRect5({
28619
28662
  center: { x: 0, y: 0 },
28620
28663
  width: pad.width + clearance * 2,
28621
28664
  height: pad.height + clearance * 2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1394",
4
+ "version": "0.0.1396",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
53
53
  "@tscircuit/props": "^0.0.567",
54
54
  "@tscircuit/schematic-match-adapt": "^0.0.18",
55
- "@tscircuit/schematic-trace-solver": "^0.0.84",
55
+ "@tscircuit/schematic-trace-solver": "^0.0.87",
56
56
  "@tscircuit/solver-utils": "^0.0.16",
57
57
  "@tscircuit/soup-util": "^0.0.41",
58
58
  "@types/bun": "^1.2.16",