@tscircuit/core 0.0.2166 → 0.0.2167

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 +65 -58
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10434,7 +10434,30 @@ var CourtyardRect = class extends PrimitiveComponent2 {
10434
10434
  };
10435
10435
 
10436
10436
  // lib/components/primitive-components/Cutout.ts
10437
- import { applyToPoint as applyToPoint8 } from "transformation-matrix";
10437
+ import { applyToPoint as applyToPoint8, decomposeTSR as decomposeTSR2 } from "transformation-matrix";
10438
+
10439
+ // lib/utils/pcb/get-axis-aligned-size-from-rotated-rect.ts
10440
+ function getAxisAlignedSizeFromRotatedRect({
10441
+ width,
10442
+ height,
10443
+ ccwRotationDegrees
10444
+ }) {
10445
+ const angleRad = ccwRotationDegrees * Math.PI / 180;
10446
+ const cosAngle = Math.cos(angleRad);
10447
+ const sinAngle = Math.sin(angleRad);
10448
+ const w2 = width / 2;
10449
+ const h2 = height / 2;
10450
+ const xExtent = Math.abs(w2 * cosAngle) + Math.abs(h2 * sinAngle);
10451
+ const yExtent = Math.abs(w2 * sinAngle) + Math.abs(h2 * cosAngle);
10452
+ return {
10453
+ width: xExtent * 2,
10454
+ height: yExtent * 2,
10455
+ xExtent,
10456
+ yExtent
10457
+ };
10458
+ }
10459
+
10460
+ // lib/components/primitive-components/Cutout.ts
10438
10461
  import { cutoutProps } from "@tscircuit/props";
10439
10462
  var Cutout = class extends PrimitiveComponent2 {
10440
10463
  pcb_cutout_id = null;
@@ -10454,16 +10477,17 @@ var Cutout = class extends PrimitiveComponent2 {
10454
10477
  const globalPosition = this._getGlobalPcbPositionBeforeLayout();
10455
10478
  const container = this.getPrimitiveContainer();
10456
10479
  const pcb_component_id = this.parent?.pcb_component_id ?? container?.pcb_component_id ?? void 0;
10457
- const parentRotation = container?._parsedProps.pcbRotation ?? 0;
10458
10480
  let inserted_pcb_cutout = void 0;
10459
10481
  if (props.shape === "rect") {
10460
- const rotationDeg = typeof parentRotation === "string" ? parseInt(parentRotation.replace("deg", ""), 10) : parentRotation;
10461
- const isRotated90 = Math.abs(rotationDeg % 180) === 90;
10482
+ const globalTransform = this._computePcbGlobalTransformBeforeLayout();
10483
+ const isReflected = globalTransform.a * globalTransform.d - globalTransform.b * globalTransform.c < 0;
10484
+ const { rotation: rotation5 } = decomposeTSR2(globalTransform, false, isReflected);
10462
10485
  const rectData = {
10463
10486
  shape: "rect",
10464
10487
  center: globalPosition,
10465
- width: isRotated90 ? props.height : props.width,
10466
- height: isRotated90 ? props.width : props.height,
10488
+ width: props.width,
10489
+ height: props.height,
10490
+ rotation: rotation5.angle * 180 / Math.PI,
10467
10491
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
10468
10492
  pcb_group_id,
10469
10493
  pcb_component_id
@@ -10524,17 +10548,21 @@ var Cutout = class extends PrimitiveComponent2 {
10524
10548
  const cutout = db2.pcb_cutout.get(this.pcb_cutout_id);
10525
10549
  if (!cutout) return super._getPcbCircuitJsonBounds();
10526
10550
  if (cutout.shape === "rect") {
10551
+ const { width, height, xExtent, yExtent } = getAxisAlignedSizeFromRotatedRect({
10552
+ width: cutout.width,
10553
+ height: cutout.height,
10554
+ ccwRotationDegrees: cutout.rotation ?? 0
10555
+ });
10527
10556
  return {
10528
10557
  center: cutout.center,
10529
10558
  bounds: {
10530
- left: cutout.center.x - cutout.width / 2,
10531
- top: cutout.center.y + cutout.height / 2,
10532
- // Assuming Y is up
10533
- right: cutout.center.x + cutout.width / 2,
10534
- bottom: cutout.center.y - cutout.height / 2
10559
+ left: cutout.center.x - xExtent,
10560
+ top: cutout.center.y + yExtent,
10561
+ right: cutout.center.x + xExtent,
10562
+ bottom: cutout.center.y - yExtent
10535
10563
  },
10536
- width: cutout.width,
10537
- height: cutout.height
10564
+ width,
10565
+ height
10538
10566
  };
10539
10567
  } else if (cutout.shape === "circle") {
10540
10568
  return {
@@ -10845,7 +10873,7 @@ function resolvePcbProperty({
10845
10873
  }
10846
10874
 
10847
10875
  // lib/components/primitive-components/FabricationNoteText.ts
10848
- import { decomposeTSR as decomposeTSR2 } from "transformation-matrix";
10876
+ import { decomposeTSR as decomposeTSR3 } from "transformation-matrix";
10849
10877
  var FabricationNoteText = class extends PrimitiveComponent2 {
10850
10878
  pcb_fabrication_note_text_id = null;
10851
10879
  isPcbPrimitive = true;
@@ -10860,7 +10888,7 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
10860
10888
  const { db: db2 } = this.root;
10861
10889
  const { _parsedProps: props } = this;
10862
10890
  const position = this._getGlobalPcbPositionBeforeLayout();
10863
- const decomposedTransform = decomposeTSR2(
10891
+ const decomposedTransform = decomposeTSR3(
10864
10892
  this._computePcbGlobalTransformBeforeLayout()
10865
10893
  );
10866
10894
  const ccwRotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
@@ -11094,7 +11122,7 @@ var Hole = class extends PrimitiveComponent2 {
11094
11122
 
11095
11123
  // lib/components/primitive-components/Keepout.ts
11096
11124
  import { pcbKeepoutProps } from "@tscircuit/props";
11097
- import { decomposeTSR as decomposeTSR3 } from "transformation-matrix";
11125
+ import { decomposeTSR as decomposeTSR4 } from "transformation-matrix";
11098
11126
  var Keepout = class extends PrimitiveComponent2 {
11099
11127
  pcb_keepout_id = null;
11100
11128
  isPcbPrimitive = true;
@@ -11119,7 +11147,7 @@ var Keepout = class extends PrimitiveComponent2 {
11119
11147
  const pcbKeepoutOwnershipProps = pcbComponentId ? { pcb_component_id: pcbComponentId } : {};
11120
11148
  const pcbGroupId = this.getGroup()?.pcb_group_id ?? void 0;
11121
11149
  const position = this._getGlobalPcbPositionBeforeLayout();
11122
- const decomposedMat = decomposeTSR3(
11150
+ const decomposedMat = decomposeTSR4(
11123
11151
  this._computePcbGlobalTransformBeforeLayout()
11124
11152
  );
11125
11153
  const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) % 180 < 0.01;
@@ -11450,7 +11478,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
11450
11478
  // lib/components/primitive-components/PcbSoldermaskOpening.ts
11451
11479
  import { pcbSoldermaskOpeningProps } from "@tscircuit/props";
11452
11480
  import { getBoundsFromPoints as getBoundsFromPoints2 } from "@tscircuit/math-utils";
11453
- import { applyToPoint as applyToPoint15, decomposeTSR as decomposeTSR4 } from "transformation-matrix";
11481
+ import { applyToPoint as applyToPoint15, decomposeTSR as decomposeTSR5 } from "transformation-matrix";
11454
11482
  var PcbSoldermaskOpening = class extends PrimitiveComponent2 {
11455
11483
  pcb_soldermask_opening_id = null;
11456
11484
  isPcbPrimitive = true;
@@ -11501,7 +11529,7 @@ var PcbSoldermaskOpening = class extends PrimitiveComponent2 {
11501
11529
  subcircuit_id: this.getSubcircuit().subcircuit_id ?? void 0
11502
11530
  };
11503
11531
  const center = applyToPoint15(transform, { x: 0, y: 0 });
11504
- const rotation5 = decomposeTSR4(transform, false, isFlipped).rotation.angle * 180 / Math.PI;
11532
+ const rotation5 = decomposeTSR5(transform, false, isFlipped).rotation.angle * 180 / Math.PI;
11505
11533
  const geometry = props.shape === "polygon" ? {
11506
11534
  shape: "polygon",
11507
11535
  points: props.points.map((point6) => applyToPoint15(transform, point6))
@@ -11797,7 +11825,7 @@ var PcbVia = class extends PrimitiveComponent2 {
11797
11825
  // lib/components/primitive-components/PlatedHole.ts
11798
11826
  import { platedHoleProps } from "@tscircuit/props";
11799
11827
  import "circuit-json";
11800
- import { decomposeTSR as decomposeTSR5 } from "transformation-matrix";
11828
+ import { decomposeTSR as decomposeTSR6 } from "transformation-matrix";
11801
11829
 
11802
11830
  // lib/components/primitive-components/Port/selectPortForPcbPrimitive.ts
11803
11831
  var getPinNumberFromHints = (hints) => {
@@ -11937,7 +11965,7 @@ var PlatedHole = class extends PrimitiveComponent2 {
11937
11965
  const soldermaskMargin = props.solderMaskMargin;
11938
11966
  const isCoveredWithSolderMask = props.coveredWithSolderMask ?? false;
11939
11967
  this.emitSolderMaskMarginWarning(isCoveredWithSolderMask, soldermaskMargin);
11940
- const decomposedTransform = decomposeTSR5(
11968
+ const decomposedTransform = decomposeTSR6(
11941
11969
  this._computePcbGlobalTransformBeforeLayout()
11942
11970
  );
11943
11971
  const rotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
@@ -12974,7 +13002,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
12974
13002
 
12975
13003
  // lib/components/primitive-components/SilkscreenRect.ts
12976
13004
  import { silkscreenRectProps } from "@tscircuit/props";
12977
- import { decomposeTSR as decomposeTSR6 } from "transformation-matrix";
13005
+ import { decomposeTSR as decomposeTSR7 } from "transformation-matrix";
12978
13006
  var SilkscreenRect = class extends PrimitiveComponent2 {
12979
13007
  pcb_silkscreen_rect_id = null;
12980
13008
  isPcbPrimitive = true;
@@ -12990,7 +13018,7 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
12990
13018
  */
12991
13019
  _isRotated90Degrees() {
12992
13020
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
12993
- const decomposedTransform = decomposeTSR6(globalTransform);
13021
+ const decomposedTransform = decomposeTSR7(globalTransform);
12994
13022
  const rotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
12995
13023
  const normalizedRotationDegrees = (rotationDegrees % 360 + 360) % 360;
12996
13024
  const rotationTolerance = 0.01;
@@ -13062,7 +13090,7 @@ import { silkscreenTextProps } from "@tscircuit/props";
13062
13090
  import {
13063
13091
  applyToPoint as applyToPoint25,
13064
13092
  compose as compose5,
13065
- decomposeTSR as decomposeTSR7,
13093
+ decomposeTSR as decomposeTSR8,
13066
13094
  flipY as flipY3,
13067
13095
  identity as identity6
13068
13096
  } from "transformation-matrix";
@@ -13088,7 +13116,7 @@ var SilkscreenText = class extends PrimitiveComponent2 {
13088
13116
  rotation5 = props.pcbRotation;
13089
13117
  } else {
13090
13118
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
13091
- const decomposedTransform = decomposeTSR7(globalTransform);
13119
+ const decomposedTransform = decomposeTSR8(globalTransform);
13092
13120
  rotation5 = decomposedTransform.rotation.angle * 180 / Math.PI;
13093
13121
  }
13094
13122
  if (isFlipped) {
@@ -13212,28 +13240,7 @@ import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-uti
13212
13240
  import {
13213
13241
  distance as distance5
13214
13242
  } from "circuit-json";
13215
- import { applyToPoint as applyToPoint27, decomposeTSR as decomposeTSR8 } from "transformation-matrix";
13216
-
13217
- // lib/utils/pcb/get-axis-aligned-size-from-rotated-rect.ts
13218
- function getAxisAlignedSizeFromRotatedRect({
13219
- width,
13220
- height,
13221
- ccwRotationDegrees
13222
- }) {
13223
- const angleRad = ccwRotationDegrees * Math.PI / 180;
13224
- const cosAngle = Math.cos(angleRad);
13225
- const sinAngle = Math.sin(angleRad);
13226
- const w2 = width / 2;
13227
- const h2 = height / 2;
13228
- const xExtent = Math.abs(w2 * cosAngle) + Math.abs(h2 * sinAngle);
13229
- const yExtent = Math.abs(w2 * sinAngle) + Math.abs(h2 * cosAngle);
13230
- return {
13231
- width: xExtent * 2,
13232
- height: yExtent * 2,
13233
- xExtent,
13234
- yExtent
13235
- };
13236
- }
13243
+ import { applyToPoint as applyToPoint27, decomposeTSR as decomposeTSR9 } from "transformation-matrix";
13237
13244
 
13238
13245
  // lib/utils/pcb/get-polygon-solder-paste-contours.ts
13239
13246
  import Flatten from "@flatten-js/core";
@@ -13429,7 +13436,7 @@ var SmtPad = class extends PrimitiveComponent2 {
13429
13436
  const subcircuit = this.getSubcircuit();
13430
13437
  const position = this._getGlobalPcbPositionBeforeLayout();
13431
13438
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
13432
- const decomposedTransform = decomposeTSR8(
13439
+ const decomposedTransform = decomposeTSR9(
13433
13440
  this._computePcbGlobalTransformBeforeLayout()
13434
13441
  );
13435
13442
  const rotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
@@ -13893,7 +13900,7 @@ var SmtPad = class extends PrimitiveComponent2 {
13893
13900
 
13894
13901
  // lib/components/primitive-components/SolderPaste.ts
13895
13902
  import { solderPasteProps } from "@tscircuit/props";
13896
- import { applyToPoint as applyToPoint28, decomposeTSR as decomposeTSR9 } from "transformation-matrix";
13903
+ import { applyToPoint as applyToPoint28, decomposeTSR as decomposeTSR10 } from "transformation-matrix";
13897
13904
  var isStandalonePcbSolderPaste = (element) => element.type === "pcb_solder_paste" && !element.pcb_smtpad_id && (element.shape === "circle" || element.shape === "rect" || element.shape === "rotated_rect");
13898
13905
  var SolderPaste = class _SolderPaste extends PrimitiveComponent2 {
13899
13906
  pcb_solder_paste_id = null;
@@ -13955,7 +13962,7 @@ var SolderPaste = class _SolderPaste extends PrimitiveComponent2 {
13955
13962
  const transform = this._computePcbGlobalTransformBeforeLayout();
13956
13963
  const { maybeFlipLayer, isFlipped } = this._getPcbPrimitiveFlippedHelpers();
13957
13964
  const center = applyToPoint28(transform, { x: 0, y: 0 });
13958
- const rotation5 = decomposeTSR9(transform, false, isFlipped).rotation.angle * 180 / Math.PI;
13965
+ const rotation5 = decomposeTSR10(transform, false, isFlipped).rotation.angle * 180 / Math.PI;
13959
13966
  const base = {
13960
13967
  ...center,
13961
13968
  layer: maybeFlipLayer(authoredLayer),
@@ -15760,7 +15767,7 @@ import {
15760
15767
  isValidElement
15761
15768
  } from "react";
15762
15769
  import { symbols as symbols2 } from "schematic-symbols";
15763
- import { decomposeTSR as decomposeTSR11 } from "transformation-matrix";
15770
+ import { decomposeTSR as decomposeTSR12 } from "transformation-matrix";
15764
15771
  import { z as z10 } from "zod";
15765
15772
 
15766
15773
  // lib/components/primitive-components/CadAssembly.ts
@@ -16251,7 +16258,7 @@ var constructAssetUrl = (targetUrl, baseUrl) => {
16251
16258
  };
16252
16259
 
16253
16260
  // lib/components/primitive-components/CadModel.ts
16254
- import { decomposeTSR as decomposeTSR10 } from "transformation-matrix";
16261
+ import { decomposeTSR as decomposeTSR11 } from "transformation-matrix";
16255
16262
  import { z as z9 } from "zod";
16256
16263
 
16257
16264
  // lib/components/base-components/NormalComponent/utils/getFileExtension.ts
@@ -16445,7 +16452,7 @@ var CadModel = class extends PrimitiveComponent2 {
16445
16452
  if (!props || typeof props.modelUrl !== "string" && typeof props.stepUrl !== "string")
16446
16453
  return;
16447
16454
  const parentTransform = parent._computePcbGlobalTransformBeforeLayout();
16448
- const decomposedTransform = decomposeTSR10(parentTransform);
16455
+ const decomposedTransform = decomposeTSR11(parentTransform);
16449
16456
  const accumulatedRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
16450
16457
  const sourceRotationOffset = props.pcbRotationOffset ?? props.rotationOffset;
16451
16458
  const rotationOffset = rotation3.parse({ x: 0, y: 0, z: 0 });
@@ -19293,7 +19300,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
19293
19300
  }
19294
19301
  getGlobalTransformRotation() {
19295
19302
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
19296
- const decomposedTransform = decomposeTSR11(globalTransform);
19303
+ const decomposedTransform = decomposeTSR12(globalTransform);
19297
19304
  return decomposedTransform.rotation.angle * 180 / Math.PI;
19298
19305
  }
19299
19306
  _footprintChildCache;
@@ -19853,7 +19860,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
19853
19860
  const computedLayer = this.props.layer === "bottom" ? "bottom" : "top";
19854
19861
  const pcbComponent = db2.pcb_component.get(this.pcb_component_id);
19855
19862
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
19856
- const decomposedTransform = decomposeTSR11(globalTransform);
19863
+ const decomposedTransform = decomposeTSR12(globalTransform);
19857
19864
  const preLayoutRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
19858
19865
  const totalRotation = pcbComponent?.position_mode === "packed" ? pcbComponent.rotation ?? preLayoutRotation : preLayoutRotation;
19859
19866
  const isBottomLayer = computedLayer === "bottom";
@@ -119448,7 +119455,7 @@ var RoutingPhasePreparationError = class extends Error {
119448
119455
  var package_default = {
119449
119456
  name: "@tscircuit/core",
119450
119457
  type: "module",
119451
- version: "0.0.2165",
119458
+ version: "0.0.2166",
119452
119459
  types: "dist/index.d.ts",
119453
119460
  main: "dist/index.js",
119454
119461
  module: "dist/index.js",
@@ -134983,7 +134990,7 @@ var PcbBend = class extends PrimitiveComponent2 {
134983
134990
 
134984
134991
  // lib/components/primitive-components/PcbStiffener.ts
134985
134992
  import { pcbStiffenerProps } from "@tscircuit/props";
134986
- import { applyToPoint as applyToPoint46, decomposeTSR as decomposeTSR12 } from "transformation-matrix";
134993
+ import { applyToPoint as applyToPoint46, decomposeTSR as decomposeTSR13 } from "transformation-matrix";
134987
134994
  var PcbStiffener = class extends PrimitiveComponent2 {
134988
134995
  pcb_stiffener_id = null;
134989
134996
  get config() {
@@ -135007,7 +135014,7 @@ var PcbStiffener = class extends PrimitiveComponent2 {
135007
135014
  const geometry = props.shape === "rect" ? {
135008
135015
  shape: "rect",
135009
135016
  center: applyToPoint46(transform, { x: 0, y: 0 }),
135010
- rotation: decomposeTSR12(transform).rotation.angle * 180 / Math.PI,
135017
+ rotation: decomposeTSR13(transform).rotation.angle * 180 / Math.PI,
135011
135018
  width: props.width,
135012
135019
  height: props.height
135013
135020
  } : {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.2166",
4
+ "version": "0.0.2167",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",