@tscircuit/core 0.0.35 → 0.0.36

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
@@ -534,6 +534,10 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
534
534
  doInitialSourceParentAttachment(): void;
535
535
  doInitialPcbPortRender(): void;
536
536
  doInitialSchematicPortRender(): void;
537
+ _setPositionFromLayout(newCenter: {
538
+ x: number;
539
+ y: number;
540
+ }): void;
537
541
  }
538
542
 
539
543
  type ReactSubtree = {
package/dist/index.js CHANGED
@@ -681,6 +681,9 @@ var Footprint = class extends PrimitiveComponent {
681
681
  x: -(bounds.right + bounds.left) / 2,
682
682
  y: -(bounds.top + bounds.bottom) / 2
683
683
  };
684
+ const containerPos = this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();
685
+ globalOffset.x += containerPos.x;
686
+ globalOffset.y += containerPos.y;
684
687
  for (const { component, selector } of involvedComponents) {
685
688
  const kvx = getKVar(`${selector}_x`);
686
689
  const kvy = getKVar(`${selector}_y`);
@@ -869,6 +872,12 @@ var Port = class extends PrimitiveComponent {
869
872
  });
870
873
  this.schematic_port_id = schematic_port.schematic_port_id;
871
874
  }
875
+ _setPositionFromLayout(newCenter) {
876
+ const { db } = this.root;
877
+ db.schematic_port.update(this.schematic_port_id, {
878
+ center: newCenter
879
+ });
880
+ }
872
881
  };
873
882
 
874
883
  // lib/components/base-components/NormalComponent.ts
@@ -3003,9 +3012,9 @@ var Constraint2 = class extends PrimitiveComponent {
3003
3012
  }
3004
3013
  _getAllReferencedComponents() {
3005
3014
  const componentsWithSelectors = [];
3006
- const subcircuit = this.getSubcircuit();
3015
+ const container = this.getPrimitiveContainer();
3007
3016
  function addComponentFromSelector(selector) {
3008
- const component = subcircuit.selectOne(selector);
3017
+ const component = container.selectOne(selector);
3009
3018
  if (component) {
3010
3019
  const maybeEdge = selector.split(" ").pop();
3011
3020
  const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : void 0;
@@ -51,12 +51,12 @@ export class Constraint extends PrimitiveComponent<typeof constraintProps> {
51
51
  edge: EdgeSpecifier | undefined
52
52
  }> = []
53
53
 
54
- const subcircuit = this.getSubcircuit()
54
+ const container = this.getPrimitiveContainer()!
55
55
 
56
56
  function addComponentFromSelector(selector: string) {
57
57
  // TODO this selector has to be modified in case it contains a leftedge,
58
58
  // center/topedge/rightedge indicator
59
- const component = subcircuit.selectOne(selector)
59
+ const component = container.selectOne(selector)
60
60
  if (component) {
61
61
  const maybeEdge = selector.split(" ").pop() as EdgeSpecifier
62
62
  const edge = edgeSpecifiers.includes(maybeEdge) ? maybeEdge : undefined
@@ -220,6 +220,12 @@ export class Footprint extends PrimitiveComponent<typeof footprintProps> {
220
220
  y: -(bounds.top + bounds.bottom) / 2,
221
221
  }
222
222
 
223
+ const containerPos =
224
+ this.getPrimitiveContainer()!._getGlobalPcbPositionBeforeLayout()
225
+
226
+ globalOffset.x += containerPos.x
227
+ globalOffset.y += containerPos.y
228
+
223
229
  // 4. Update the component positions
224
230
  for (const { component, selector } of involvedComponents) {
225
231
  const kvx = getKVar(`${selector}_x`)
@@ -205,4 +205,12 @@ export class Port extends PrimitiveComponent<typeof portProps> {
205
205
 
206
206
  this.schematic_port_id = schematic_port.schematic_port_id
207
207
  }
208
+
209
+ _setPositionFromLayout(newCenter: { x: number; y: number }): void {
210
+ const { db } = this.root!
211
+
212
+ db.schematic_port.update(this.schematic_port_id!, {
213
+ center: newCenter,
214
+ })
215
+ }
208
216
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/core",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.0.35",
5
+ "version": "0.0.36",
6
6
  "types": "dist/index.d.ts",
7
7
  "main": "dist/index.js",
8
8
  "files": [