@tscircuit/core 0.0.1392 → 0.0.1394

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 +104 -16
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -14560,7 +14560,7 @@ import {
14560
14560
  runAllPlacementChecks,
14561
14561
  runAllRoutingChecks
14562
14562
  } from "@tscircuit/checks";
14563
- import { getBoundsFromPoints as getBoundsFromPoints5 } from "@tscircuit/math-utils";
14563
+ import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
14564
14564
  import { boardProps } from "@tscircuit/props";
14565
14565
  import { compose as compose7, translate as translate7 } from "transformation-matrix";
14566
14566
 
@@ -15309,7 +15309,7 @@ import {
15309
15309
  getRerouteSimpleRouteJson,
15310
15310
  reconnectReroutedSimpleRouteJsonRegion
15311
15311
  } from "@tscircuit/capacity-autorouter";
15312
- import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
15312
+ import { getBoundsFromPoints as getBoundsFromPoints5 } from "@tscircuit/math-utils";
15313
15313
  import {
15314
15314
  groupProps
15315
15315
  } from "@tscircuit/props";
@@ -18670,6 +18670,18 @@ import Debug8 from "debug";
18670
18670
  // lib/utils/schematic/getSchematicComponentWithTextBounds.ts
18671
18671
  import { getBoundFromCenteredRect } from "@tscircuit/math-utils";
18672
18672
  import { symbols as symbols3 } from "schematic-symbols";
18673
+
18674
+ // lib/utils/schematic/getSchematicTextWidth.ts
18675
+ function getSchematicTextWidth({
18676
+ text,
18677
+ fontSize
18678
+ }) {
18679
+ const fontScale = fontSize / 0.18;
18680
+ const charWidth = 0.12 * fontScale;
18681
+ return text.length * charWidth;
18682
+ }
18683
+
18684
+ // lib/utils/schematic/getSchematicComponentWithTextBounds.ts
18673
18685
  var SYMBOL_TEXT_FONT_SIZE = 0.18;
18674
18686
  var TEXT_BOX_ENABLED_FTYPES = /* @__PURE__ */ new Set([
18675
18687
  "simple_resistor",
@@ -18691,7 +18703,7 @@ function getTextBounds({
18691
18703
  anchor,
18692
18704
  fontSize
18693
18705
  }) {
18694
- const width = getSchematicNetLabelTextWidth({ text, font_size: fontSize });
18706
+ const width = getSchematicTextWidth({ text, fontSize });
18695
18707
  const height = fontSize;
18696
18708
  let relMinX;
18697
18709
  let relMaxX;
@@ -19799,11 +19811,78 @@ import Debug12 from "debug";
19799
19811
 
19800
19812
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
19801
19813
  import "@tscircuit/schematic-trace-solver";
19814
+
19815
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicTextBounds.ts
19816
+ import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
19817
+ var DEFAULT_SCHEMATIC_TEXT_FONT_SIZE = 0.18;
19818
+ function getSchematicTextBounds(text) {
19819
+ const fontSize = text.font_size ?? DEFAULT_SCHEMATIC_TEXT_FONT_SIZE;
19820
+ const width = getSchematicTextWidth({
19821
+ text: text.text ?? "",
19822
+ fontSize
19823
+ });
19824
+ const height = fontSize;
19825
+ const anchor = text.anchor ?? "center";
19826
+ let minX;
19827
+ let maxX;
19828
+ if (anchor.includes("left")) {
19829
+ minX = 0;
19830
+ maxX = width;
19831
+ } else if (anchor.includes("right")) {
19832
+ minX = -width;
19833
+ maxX = 0;
19834
+ } else {
19835
+ minX = -width / 2;
19836
+ maxX = width / 2;
19837
+ }
19838
+ let minY;
19839
+ let maxY;
19840
+ if (anchor.includes("top")) {
19841
+ minY = -height;
19842
+ maxY = 0;
19843
+ } else if (anchor.includes("bottom")) {
19844
+ minY = 0;
19845
+ maxY = height;
19846
+ } else {
19847
+ minY = -height / 2;
19848
+ maxY = height / 2;
19849
+ }
19850
+ const rotation4 = (text.rotation ?? 0) * Math.PI / 180;
19851
+ const cos = Math.cos(rotation4);
19852
+ const sin = Math.sin(rotation4);
19853
+ const corners = [
19854
+ { x: minX, y: minY },
19855
+ { x: minX, y: maxY },
19856
+ { x: maxX, y: minY },
19857
+ { x: maxX, y: maxY }
19858
+ ].map((corner) => ({
19859
+ x: text.position.x + corner.x * cos - corner.y * sin,
19860
+ y: text.position.y + corner.x * sin + corner.y * cos
19861
+ }));
19862
+ return getBoundsFromPoints4(corners);
19863
+ }
19864
+
19865
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/schematicTextToTextBounds.ts
19866
+ import { getBoundsCenter } from "@tscircuit/math-utils";
19867
+ function schematicTextToTextBox(text) {
19868
+ if (!text.text) return null;
19869
+ const bounds = getSchematicTextBounds(text);
19870
+ return {
19871
+ chipId: text.schematic_component_id,
19872
+ center: getBoundsCenter(bounds),
19873
+ width: bounds.maxX - bounds.minX,
19874
+ height: bounds.maxY - bounds.minY,
19875
+ text: text.text
19876
+ };
19877
+ }
19878
+
19879
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
19802
19880
  import {
19803
19881
  getBoundFromCenteredRect as getBoundFromCenteredRect3,
19804
- getBoundsCenter
19882
+ getBoundsCenter as getBoundsCenter2
19805
19883
  } from "@tscircuit/math-utils";
19806
19884
  var DEFAULT_MAX_MSP_PAIR_DISTANCE = 2.4;
19885
+ var SCHEMATIC_RAIL_NET_LABEL_HEIGHT = 0.42;
19807
19886
  function createSchematicTraceSolverInputProblem(group) {
19808
19887
  const { db } = group.root;
19809
19888
  const connKeyToSourceNet = /* @__PURE__ */ new Map();
@@ -19814,6 +19893,12 @@ function createSchematicTraceSolverInputProblem(group) {
19814
19893
  ...childGroups.map((a) => a.schematic_group_id)
19815
19894
  ];
19816
19895
  const schematicComponents = db.schematic_component.list().filter((a) => allSchematicGroupIds.includes(a.schematic_group_id));
19896
+ const schematicComponentIds = new Set(
19897
+ schematicComponents.map((component) => component.schematic_component_id)
19898
+ );
19899
+ const textBoxes = db.schematic_text.list().filter(
19900
+ (text) => text.schematic_component_id && schematicComponentIds.has(text.schematic_component_id)
19901
+ ).map(schematicTextToTextBox).filter((textBox) => Boolean(textBox));
19817
19902
  const componentNameToSectionId = /* @__PURE__ */ new Map();
19818
19903
  for (const component of group.getDescendants()) {
19819
19904
  if (component.name && component._parsedProps?.schSectionName) {
@@ -19859,7 +19944,7 @@ function createSchematicTraceSolverInputProblem(group) {
19859
19944
  });
19860
19945
  chips.push({
19861
19946
  chipId,
19862
- center: getBoundsCenter(layoutBounds),
19947
+ center: getBoundsCenter2(layoutBounds),
19863
19948
  width: layoutBounds.maxX - layoutBounds.minX,
19864
19949
  height: layoutBounds.maxY - layoutBounds.minY,
19865
19950
  pins,
@@ -19982,12 +20067,14 @@ function createSchematicTraceSolverInputProblem(group) {
19982
20067
  const netLabelWidth = Number(
19983
20068
  getSchematicNetLabelTextWidth({ text: String(userNetId) }).toFixed(2)
19984
20069
  );
20070
+ const netLabelHeight = sourceNet.is_ground || sourceNet.is_power ? SCHEMATIC_RAIL_NET_LABEL_HEIGHT : void 0;
19985
20071
  netConnections.push({
19986
20072
  netId: userNetId,
19987
20073
  pinIds: schematicPortIds.map(
19988
20074
  (portId) => schematicPortIdToPinId.get(portId)
19989
20075
  ),
19990
- netLabelWidth
20076
+ netLabelWidth,
20077
+ netLabelHeight
19991
20078
  });
19992
20079
  }
19993
20080
  }
@@ -20013,6 +20100,7 @@ function createSchematicTraceSolverInputProblem(group) {
20013
20100
  chips,
20014
20101
  directConnections,
20015
20102
  netConnections,
20103
+ textBoxes,
20016
20104
  availableNetLabelOrientations,
20017
20105
  maxMspPairDistance: group._parsedProps.schMaxTraceDistance ?? DEFAULT_MAX_MSP_PAIR_DISTANCE
20018
20106
  };
@@ -22971,7 +23059,7 @@ var Group5 = class extends NormalComponent3 {
22971
23059
  x: distance10.parse(point6.x),
22972
23060
  y: distance10.parse(point6.y)
22973
23061
  }));
22974
- const outlineBounds = getBoundsFromPoints4(numericOutline);
23062
+ const outlineBounds = getBoundsFromPoints5(numericOutline);
22975
23063
  if (!outlineBounds) return;
22976
23064
  const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
22977
23065
  const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
@@ -25150,7 +25238,7 @@ import { identity as identity5 } from "transformation-matrix";
25150
25238
  var package_default = {
25151
25239
  name: "@tscircuit/core",
25152
25240
  type: "module",
25153
- version: "0.0.1391",
25241
+ version: "0.0.1393",
25154
25242
  types: "dist/index.d.ts",
25155
25243
  main: "dist/index.js",
25156
25244
  module: "dist/index.js",
@@ -25184,7 +25272,7 @@ var package_default = {
25184
25272
  "@tscircuit/alphabet": "0.0.25",
25185
25273
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
25186
25274
  "@tscircuit/capacity-autorouter": "^0.0.628",
25187
- "@tscircuit/checks": "0.0.141",
25275
+ "@tscircuit/checks": "0.0.142",
25188
25276
  "@tscircuit/circuit-json-util": "^0.0.97",
25189
25277
  "@tscircuit/common": "^0.0.20",
25190
25278
  "@tscircuit/copper-pour-solver": "0.0.35",
@@ -25201,7 +25289,7 @@ var package_default = {
25201
25289
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
25202
25290
  "@tscircuit/props": "^0.0.567",
25203
25291
  "@tscircuit/schematic-match-adapt": "^0.0.18",
25204
- "@tscircuit/schematic-trace-solver": "^0.0.75",
25292
+ "@tscircuit/schematic-trace-solver": "^0.0.84",
25205
25293
  "@tscircuit/solver-utils": "^0.0.16",
25206
25294
  "@tscircuit/soup-util": "^0.0.41",
25207
25295
  "@types/bun": "^1.2.16",
@@ -25826,7 +25914,7 @@ var Board = class extends Group5 {
25826
25914
  let width = dbBoard?.width ?? props.width;
25827
25915
  let height = dbBoard?.height ?? props.height;
25828
25916
  if ((width == null || height == null) && props.outline?.length) {
25829
- const outlineBounds = getBoundsFromPoints5(props.outline);
25917
+ const outlineBounds = getBoundsFromPoints6(props.outline);
25830
25918
  if (outlineBounds) {
25831
25919
  width ??= outlineBounds.maxX - outlineBounds.minX;
25832
25920
  height ??= outlineBounds.maxY - outlineBounds.minY;
@@ -25883,7 +25971,7 @@ var Board = class extends Group5 {
25883
25971
  let width = pcbGroup.width ?? 0;
25884
25972
  let height = pcbGroup.height ?? 0;
25885
25973
  if (pcbGroup.outline && pcbGroup.outline.length > 0) {
25886
- const bounds = getBoundsFromPoints5(pcbGroup.outline);
25974
+ const bounds = getBoundsFromPoints6(pcbGroup.outline);
25887
25975
  if (bounds) {
25888
25976
  width = bounds.maxX - bounds.minX;
25889
25977
  height = bounds.maxY - bounds.minY;
@@ -26055,7 +26143,7 @@ var Board = class extends Group5 {
26055
26143
  }
26056
26144
  let outlineTranslation = { x: 0, y: 0 };
26057
26145
  if (outline && outline.length > 0 && (this.parent?.lowercaseComponentName === "panel" || this.parent?.lowercaseComponentName === "subpanel")) {
26058
- const outlineBounds = getBoundsFromPoints5(outline);
26146
+ const outlineBounds = getBoundsFromPoints6(outline);
26059
26147
  if (outlineBounds) {
26060
26148
  const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
26061
26149
  const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
@@ -26198,7 +26286,7 @@ var Board = class extends Group5 {
26198
26286
  if (this.pcb_board_id) {
26199
26287
  db.pcb_board.update(this.pcb_board_id, { center: position });
26200
26288
  if (pcbBoard?.outline) {
26201
- const outlineBounds = getBoundsFromPoints5(pcbBoard.outline);
26289
+ const outlineBounds = getBoundsFromPoints6(pcbBoard.outline);
26202
26290
  if (outlineBounds) {
26203
26291
  const oldOutlineCenter = {
26204
26292
  x: (outlineBounds.minX + outlineBounds.maxX) / 2,
@@ -26600,14 +26688,14 @@ function generatePanelTabsAndMouseBites(boards, options) {
26600
26688
  import { distance as distance12 } from "circuit-json";
26601
26689
 
26602
26690
  // lib/utils/panels/get-board-dimensions-from-props.ts
26603
- import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
26691
+ import { getBoundsFromPoints as getBoundsFromPoints7 } from "@tscircuit/math-utils";
26604
26692
  import { distance as distance11 } from "circuit-json";
26605
26693
  var getBoardDimensionsFromProps = (board) => {
26606
26694
  const props = board._parsedProps;
26607
26695
  let width = props.width != null ? distance11.parse(props.width) : void 0;
26608
26696
  let height = props.height != null ? distance11.parse(props.height) : void 0;
26609
26697
  if ((width === void 0 || height === void 0) && props.outline?.length) {
26610
- const outlineBounds = getBoundsFromPoints6(props.outline);
26698
+ const outlineBounds = getBoundsFromPoints7(props.outline);
26611
26699
  if (outlineBounds) {
26612
26700
  width ??= outlineBounds.maxX - outlineBounds.minX;
26613
26701
  height ??= outlineBounds.maxY - outlineBounds.minY;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1392",
4
+ "version": "0.0.1394",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "@tscircuit/alphabet": "0.0.25",
36
36
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
37
37
  "@tscircuit/capacity-autorouter": "^0.0.628",
38
- "@tscircuit/checks": "0.0.141",
38
+ "@tscircuit/checks": "0.0.142",
39
39
  "@tscircuit/circuit-json-util": "^0.0.97",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "0.0.35",
@@ -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.75",
55
+ "@tscircuit/schematic-trace-solver": "^0.0.84",
56
56
  "@tscircuit/solver-utils": "^0.0.16",
57
57
  "@tscircuit/soup-util": "^0.0.41",
58
58
  "@types/bun": "^1.2.16",