@tscircuit/core 0.0.819 → 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 +27 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14944,7 +14944,7 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
14944
14944
  );
14945
14945
  }
14946
14946
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
14947
- const text = props.text ?? this._formatDistanceText({ from, to });
14947
+ const text = props.text ?? this._formatDistanceText({ from, to, units: props.units ?? "mm" });
14948
14948
  const fabrication_note_dimension = db.pcb_fabrication_note_dimension.insert(
14949
14949
  {
14950
14950
  pcb_component_id,
@@ -14974,15 +14974,21 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
14974
14974
  }
14975
14975
  _formatDistanceText({
14976
14976
  from,
14977
- to
14977
+ to,
14978
+ units
14978
14979
  }) {
14979
14980
  const dx = to.x - from.x;
14980
14981
  const dy = to.y - from.y;
14981
- const distance6 = Math.sqrt(dx * dx + dy * dy);
14982
- const roundedDistance = Math.round(distance6);
14983
- const isWholeNumber = Math.abs(distance6 - roundedDistance) < 1e-9;
14984
- const valueText = isWholeNumber ? `${roundedDistance}` : distance6.toFixed(2);
14985
- 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}`;
14986
14992
  }
14987
14993
  };
14988
14994
 
@@ -15210,7 +15216,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15210
15216
  const subcircuit = this.getSubcircuit();
15211
15217
  const group = this.getGroup();
15212
15218
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
15213
- const text = props.text ?? this._formatDistanceText({ from, to });
15219
+ const text = props.text ?? this._formatDistanceText({ from, to, units: props.units ?? "mm" });
15214
15220
  const pcb_note_dimension = db.pcb_note_dimension.insert({
15215
15221
  pcb_component_id,
15216
15222
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -15236,15 +15242,21 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15236
15242
  }
15237
15243
  _formatDistanceText({
15238
15244
  from,
15239
- to
15245
+ to,
15246
+ units
15240
15247
  }) {
15241
15248
  const dx = to.x - from.x;
15242
15249
  const dy = to.y - from.y;
15243
- const distance6 = Math.sqrt(dx * dx + dy * dy);
15244
- const roundedDistance = Math.round(distance6);
15245
- const isWholeNumber = Math.abs(distance6 - roundedDistance) < 1e-9;
15246
- const valueText = isWholeNumber ? `${roundedDistance}` : distance6.toFixed(2);
15247
- 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}`;
15248
15260
  }
15249
15261
  };
15250
15262
 
@@ -17268,7 +17280,7 @@ import { identity as identity6 } from "transformation-matrix";
17268
17280
  var package_default = {
17269
17281
  name: "@tscircuit/core",
17270
17282
  type: "module",
17271
- version: "0.0.818",
17283
+ version: "0.0.819",
17272
17284
  types: "dist/index.d.ts",
17273
17285
  main: "dist/index.js",
17274
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.819",
4
+ "version": "0.0.820",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",