@tscircuit/core 0.0.944 → 0.0.945

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.
package/dist/index.d.ts CHANGED
@@ -26148,6 +26148,11 @@ declare class SilkscreenRect extends PrimitiveComponent<typeof silkscreenRectPro
26148
26148
  stroke?: "none" | "dashed" | "solid" | undefined;
26149
26149
  }>;
26150
26150
  };
26151
+ /**
26152
+ * Check if the component is rotated 90 or 270 degrees based on global transform.
26153
+ * For these rotations, we need to swap width/height instead of using ccw_rotation.
26154
+ */
26155
+ private _isRotated90Degrees;
26151
26156
  doInitialPcbPrimitiveRender(): void;
26152
26157
  getPcbSize(): {
26153
26158
  width: number;
package/dist/index.js CHANGED
@@ -18205,6 +18205,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18205
18205
 
18206
18206
  // lib/components/primitive-components/SilkscreenRect.ts
18207
18207
  import { silkscreenRectProps } from "@tscircuit/props";
18208
+ import { decomposeTSR as decomposeTSR6 } from "transformation-matrix";
18208
18209
  var SilkscreenRect = class extends PrimitiveComponent2 {
18209
18210
  pcb_silkscreen_rect_id = null;
18210
18211
  isPcbPrimitive = true;
@@ -18214,6 +18215,18 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18214
18215
  zodProps: silkscreenRectProps
18215
18216
  };
18216
18217
  }
18218
+ /**
18219
+ * Check if the component is rotated 90 or 270 degrees based on global transform.
18220
+ * For these rotations, we need to swap width/height instead of using ccw_rotation.
18221
+ */
18222
+ _isRotated90Degrees() {
18223
+ const globalTransform = this._computePcbGlobalTransformBeforeLayout();
18224
+ const decomposedTransform = decomposeTSR6(globalTransform);
18225
+ const rotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
18226
+ const normalizedRotationDegrees = (rotationDegrees % 360 + 360) % 360;
18227
+ const rotationTolerance = 0.01;
18228
+ return Math.abs(normalizedRotationDegrees - 90) < rotationTolerance || Math.abs(normalizedRotationDegrees - 270) < rotationTolerance;
18229
+ }
18217
18230
  doInitialPcbPrimitiveRender() {
18218
18231
  if (this.root?.pcbDisabled) return;
18219
18232
  const { db } = this.root;
@@ -18227,6 +18240,9 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18227
18240
  }
18228
18241
  const subcircuit = this.getSubcircuit();
18229
18242
  const position = this._getGlobalPcbPositionBeforeLayout();
18243
+ const isRotated90Degrees = this._isRotated90Degrees();
18244
+ const finalWidth = isRotated90Degrees ? props.height : props.width;
18245
+ const finalHeight = isRotated90Degrees ? props.width : props.height;
18230
18246
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18231
18247
  const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
18232
18248
  pcb_component_id,
@@ -18235,8 +18251,8 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18235
18251
  x: position.x,
18236
18252
  y: position.y
18237
18253
  },
18238
- width: props.width,
18239
- height: props.height,
18254
+ width: finalWidth,
18255
+ height: finalHeight,
18240
18256
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18241
18257
  pcb_group_id: this?.getGroup()?.pcb_group_id ?? void 0,
18242
18258
  stroke_width: props.strokeWidth ?? 0.1,
@@ -18247,6 +18263,10 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18247
18263
  }
18248
18264
  getPcbSize() {
18249
18265
  const { _parsedProps: props } = this;
18266
+ const isRotated90Degrees = this._isRotated90Degrees();
18267
+ if (isRotated90Degrees) {
18268
+ return { width: props.height, height: props.width };
18269
+ }
18250
18270
  return { width: props.width, height: props.height };
18251
18271
  }
18252
18272
  _moveCircuitJsonElements({
@@ -20008,7 +20028,7 @@ import { identity as identity5 } from "transformation-matrix";
20008
20028
  var package_default = {
20009
20029
  name: "@tscircuit/core",
20010
20030
  type: "module",
20011
- version: "0.0.943",
20031
+ version: "0.0.944",
20012
20032
  types: "dist/index.d.ts",
20013
20033
  main: "dist/index.js",
20014
20034
  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.944",
4
+ "version": "0.0.945",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",