@tscircuit/core 0.0.818 → 0.0.820

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 +28 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10135,6 +10135,7 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
10135
10135
  originalDirection,
10136
10136
  placement.ccwRotationDegrees
10137
10137
  );
10138
+ port.side_of_component = port.facing_direction || port.side_of_component;
10138
10139
  }
10139
10140
  for (const text of texts) {
10140
10141
  const dx = text.position.x - newCenter.x;
@@ -14943,7 +14944,7 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
14943
14944
  );
14944
14945
  }
14945
14946
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
14946
- const text = props.text ?? this._formatDistanceText({ from, to });
14947
+ const text = props.text ?? this._formatDistanceText({ from, to, units: props.units ?? "mm" });
14947
14948
  const fabrication_note_dimension = db.pcb_fabrication_note_dimension.insert(
14948
14949
  {
14949
14950
  pcb_component_id,
@@ -14973,15 +14974,21 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
14973
14974
  }
14974
14975
  _formatDistanceText({
14975
14976
  from,
14976
- to
14977
+ to,
14978
+ units
14977
14979
  }) {
14978
14980
  const dx = to.x - from.x;
14979
14981
  const dy = to.y - from.y;
14980
- const distance6 = Math.sqrt(dx * dx + dy * dy);
14981
- const roundedDistance = Math.round(distance6);
14982
- const isWholeNumber = Math.abs(distance6 - roundedDistance) < 1e-9;
14983
- const valueText = isWholeNumber ? `${roundedDistance}` : distance6.toFixed(2);
14984
- return `${valueText}mm`;
14982
+ const distanceInMillimeters = Math.sqrt(dx * dx + dy * dy);
14983
+ const distanceInUnits = units === "in" ? distanceInMillimeters / 25.4 : distanceInMillimeters;
14984
+ const roundedDistance = Math.round(distanceInUnits);
14985
+ const isWholeNumber = Math.abs(distanceInUnits - roundedDistance) < 1e-9;
14986
+ if (isWholeNumber) {
14987
+ return `${roundedDistance}${units}`;
14988
+ }
14989
+ const decimalPlaces = units === "in" ? 3 : 2;
14990
+ const valueText = units === "in" ? Number(distanceInUnits.toFixed(decimalPlaces)).toString() : distanceInUnits.toFixed(decimalPlaces);
14991
+ return `${valueText}${units}`;
14985
14992
  }
14986
14993
  };
14987
14994
 
@@ -15209,7 +15216,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15209
15216
  const subcircuit = this.getSubcircuit();
15210
15217
  const group = this.getGroup();
15211
15218
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
15212
- const text = props.text ?? this._formatDistanceText({ from, to });
15219
+ const text = props.text ?? this._formatDistanceText({ from, to, units: props.units ?? "mm" });
15213
15220
  const pcb_note_dimension = db.pcb_note_dimension.insert({
15214
15221
  pcb_component_id,
15215
15222
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -15235,15 +15242,21 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15235
15242
  }
15236
15243
  _formatDistanceText({
15237
15244
  from,
15238
- to
15245
+ to,
15246
+ units
15239
15247
  }) {
15240
15248
  const dx = to.x - from.x;
15241
15249
  const dy = to.y - from.y;
15242
- const distance6 = Math.sqrt(dx * dx + dy * dy);
15243
- const roundedDistance = Math.round(distance6);
15244
- const isWholeNumber = Math.abs(distance6 - roundedDistance) < 1e-9;
15245
- const valueText = isWholeNumber ? `${roundedDistance}` : distance6.toFixed(2);
15246
- return `${valueText}mm`;
15250
+ const distanceInMillimeters = Math.sqrt(dx * dx + dy * dy);
15251
+ const distanceInUnits = units === "in" ? distanceInMillimeters / 25.4 : distanceInMillimeters;
15252
+ const roundedDistance = Math.round(distanceInUnits);
15253
+ const isWholeNumber = Math.abs(distanceInUnits - roundedDistance) < 1e-9;
15254
+ if (isWholeNumber) {
15255
+ return `${roundedDistance}${units}`;
15256
+ }
15257
+ const decimalPlaces = units === "in" ? 3 : 2;
15258
+ const valueText = units === "in" ? Number(distanceInUnits.toFixed(decimalPlaces)).toString() : distanceInUnits.toFixed(decimalPlaces);
15259
+ return `${valueText}${units}`;
15247
15260
  }
15248
15261
  };
15249
15262
 
@@ -17267,7 +17280,7 @@ import { identity as identity6 } from "transformation-matrix";
17267
17280
  var package_default = {
17268
17281
  name: "@tscircuit/core",
17269
17282
  type: "module",
17270
- version: "0.0.817",
17283
+ version: "0.0.819",
17271
17284
  types: "dist/index.d.ts",
17272
17285
  main: "dist/index.js",
17273
17286
  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.818",
4
+ "version": "0.0.820",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",