@tscircuit/core 0.0.82 → 0.0.84

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 +32 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -582,6 +582,19 @@ var Footprint = class extends PrimitiveComponent {
582
582
  (child) => child.componentName === "Constraint"
583
583
  );
584
584
  if (constraints.length === 0) return;
585
+ const { isFlipped } = this._getPcbPrimitiveFlippedHelpers();
586
+ const maybeFlipLeftRight = (props) => {
587
+ if (isFlipped) {
588
+ if ("left" in props && "right" in props) {
589
+ return {
590
+ ...props,
591
+ left: props.right,
592
+ right: props.left
593
+ };
594
+ }
595
+ }
596
+ return props;
597
+ };
585
598
  const involvedComponents = constraints.flatMap(
586
599
  (constraint) => constraint._getAllReferencedComponents().componentsWithSelectors
587
600
  ).map(({ component, selector, componentSelector, edge }) => ({
@@ -617,7 +630,7 @@ var Footprint = class extends PrimitiveComponent {
617
630
  for (const constraint of constraints) {
618
631
  const props = constraint._parsedProps;
619
632
  if ("xDist" in props) {
620
- const { xDist, left, right, edgeToEdge, centerToCenter } = props;
633
+ const { xDist, left, right, edgeToEdge, centerToCenter } = maybeFlipLeftRight(props);
621
634
  const leftVar = getKVar(`${left}_x`);
622
635
  const rightVar = getKVar(`${right}_x`);
623
636
  const leftBounds = getComponentDetails(left)?.bounds;
@@ -758,7 +771,7 @@ var Footprint = class extends PrimitiveComponent {
758
771
  };
759
772
 
760
773
  // lib/components/base-components/NormalComponent.ts
761
- import "zod";
774
+ import { z as z4 } from "zod";
762
775
 
763
776
  // lib/components/primitive-components/Port.ts
764
777
  import { z as z2 } from "zod";
@@ -1720,6 +1733,12 @@ function getBoundsOfPcbComponents(components) {
1720
1733
  }
1721
1734
 
1722
1735
  // lib/components/base-components/NormalComponent.ts
1736
+ import { rotation } from "circuit-json";
1737
+ var rotation3 = z4.object({
1738
+ x: rotation,
1739
+ y: rotation,
1740
+ z: rotation
1741
+ });
1723
1742
  var NormalComponent = class extends PrimitiveComponent {
1724
1743
  reactSubtrees = [];
1725
1744
  isPrimitiveContainer = true;
@@ -2025,14 +2044,19 @@ var NormalComponent = class extends PrimitiveComponent {
2025
2044
  doInitialCadModelRender() {
2026
2045
  const { db } = this.root;
2027
2046
  const { boardThickness = 0 } = this.root?._getBoard() ?? {};
2028
- const { _parsedProps: props } = this;
2029
- if (props.cadModel) {
2047
+ const cadModel = this._parsedProps.cadModel;
2048
+ if (cadModel) {
2030
2049
  const bounds = this._getPcbCircuitJsonBounds();
2031
2050
  const pcb_component = db.pcb_component.get(this.pcb_component_id);
2032
- const cadModel = props.cadModel;
2033
2051
  if (typeof cadModel === "string") {
2034
2052
  throw new Error("String cadModel not yet implemented");
2035
2053
  }
2054
+ const rotationOffset = rotation3.parse({
2055
+ x: 0,
2056
+ y: 0,
2057
+ z: typeof cadModel.rotationOffset === "number" ? cadModel.rotationOffset : 0,
2058
+ ...typeof cadModel.rotationOffset === "object" ? cadModel.rotationOffset ?? {} : {}
2059
+ });
2036
2060
  const cad_model = db.cad_component.insert({
2037
2061
  // TODO z maybe depends on layer
2038
2062
  position: {
@@ -2041,9 +2065,9 @@ var NormalComponent = class extends PrimitiveComponent {
2041
2065
  z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
2042
2066
  },
2043
2067
  rotation: {
2044
- x: 0,
2045
- y: this.props.layer === "top" ? 0 : 180,
2046
- z: (pcb_component?.rotation ?? 0) + (this.props.layer === "bottom" ? 180 : 0)
2068
+ x: rotationOffset.x,
2069
+ y: (this.props.layer === "top" ? 0 : 180) + rotationOffset.y,
2070
+ z: (pcb_component?.rotation ?? 0) + (this.props.layer === "bottom" ? 180 : 0) + rotationOffset.z
2047
2071
  },
2048
2072
  pcb_component_id: this.pcb_component_id,
2049
2073
  source_component_id: this.source_component_id,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.82",
4
+ "version": "0.0.84",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",