@tscircuit/core 0.0.946 → 0.0.947

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
@@ -22703,6 +22703,10 @@ declare class PcbNotePath extends PrimitiveComponent<typeof pcbNotePathProps> {
22703
22703
  width: number;
22704
22704
  height: number;
22705
22705
  };
22706
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
22707
+ deltaX: number;
22708
+ deltaY: number;
22709
+ }): void;
22706
22710
  }
22707
22711
 
22708
22712
  declare class PcbNoteDimension extends PrimitiveComponent<typeof pcbNoteDimensionProps> {
@@ -22895,6 +22899,10 @@ declare class PcbNoteDimension extends PrimitiveComponent<typeof pcbNoteDimensio
22895
22899
  height: number;
22896
22900
  };
22897
22901
  private _formatDistanceText;
22902
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
22903
+ deltaX: number;
22904
+ deltaY: number;
22905
+ }): void;
22898
22906
  }
22899
22907
 
22900
22908
  declare class Footprint extends PrimitiveComponent<typeof footprintProps> {
@@ -23110,6 +23118,10 @@ declare class BreakoutPoint extends PrimitiveComponent<typeof breakoutPointProps
23110
23118
  x: number;
23111
23119
  y: number;
23112
23120
  }): void;
23121
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
23122
+ deltaX: number;
23123
+ deltaY: number;
23124
+ }): void;
23113
23125
  getPcbSize(): {
23114
23126
  width: number;
23115
23127
  height: number;
@@ -23660,6 +23672,10 @@ declare class Hole extends PrimitiveComponent<typeof holeProps> {
23660
23672
  x: number;
23661
23673
  y: number;
23662
23674
  }): void;
23675
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
23676
+ deltaX: number;
23677
+ deltaY: number;
23678
+ }): void;
23663
23679
  }
23664
23680
 
23665
23681
  declare class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> {
@@ -25660,6 +25676,10 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
25660
25676
  doInitialPortMatching(): void;
25661
25677
  doInitialPcbPrimitiveRender(): void;
25662
25678
  doInitialPcbPortAttachment(): void;
25679
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
25680
+ deltaX: number;
25681
+ deltaY: number;
25682
+ }): void;
25663
25683
  }
25664
25684
 
25665
25685
  declare class SilkscreenCircle extends PrimitiveComponent<typeof silkscreenCircleProps> {
@@ -27297,6 +27317,10 @@ declare class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
27297
27317
  x: number;
27298
27318
  y: number;
27299
27319
  }): void;
27320
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
27321
+ deltaX: number;
27322
+ deltaY: number;
27323
+ }): void;
27300
27324
  }
27301
27325
 
27302
27326
  declare class Fiducial extends PrimitiveComponent<typeof fiducialProps> {
@@ -28436,6 +28460,10 @@ declare class Fiducial extends PrimitiveComponent<typeof fiducialProps> {
28436
28460
  x: number;
28437
28461
  y: number;
28438
28462
  }): void;
28463
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
28464
+ deltaX: number;
28465
+ deltaY: number;
28466
+ }): void;
28439
28467
  }
28440
28468
 
28441
28469
  declare const pcbTraceProps: z.ZodObject<{
@@ -29167,6 +29195,7 @@ declare class CopperPour extends PrimitiveComponent<typeof copperPourProps> {
29167
29195
 
29168
29196
  declare class CopperText extends PrimitiveComponent<typeof copperTextProps> {
29169
29197
  isPcbPrimitive: boolean;
29198
+ pcb_copper_text_id: string | null;
29170
29199
  get config(): {
29171
29200
  componentName: string;
29172
29201
  zodProps: zod.ZodObject<{
@@ -29331,6 +29360,14 @@ declare class CopperText extends PrimitiveComponent<typeof copperTextProps> {
29331
29360
  }>;
29332
29361
  };
29333
29362
  doInitialPcbPrimitiveRender(): void;
29363
+ getPcbSize(): {
29364
+ width: number;
29365
+ height: number;
29366
+ };
29367
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
29368
+ deltaX: number;
29369
+ deltaY: number;
29370
+ }): void;
29334
29371
  }
29335
29372
 
29336
29373
  declare class Cutout extends PrimitiveComponent<typeof cutoutProps> {
@@ -29774,6 +29811,10 @@ declare class Cutout extends PrimitiveComponent<typeof cutoutProps> {
29774
29811
  x: number;
29775
29812
  y: number;
29776
29813
  }): void;
29814
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
29815
+ deltaX: number;
29816
+ deltaY: number;
29817
+ }): void;
29777
29818
  }
29778
29819
 
29779
29820
  declare class Battery extends NormalComponent<typeof batteryProps, PassivePorts> {
package/dist/index.js CHANGED
@@ -2491,6 +2491,30 @@ var SmtPad = class extends PrimitiveComponent2 {
2491
2491
  }
2492
2492
  this.matchedPort?._setPositionFromLayout(newCenter);
2493
2493
  }
2494
+ _moveCircuitJsonElements({
2495
+ deltaX,
2496
+ deltaY
2497
+ }) {
2498
+ if (this.root?.pcbDisabled) return;
2499
+ const { db } = this.root;
2500
+ if (!this.pcb_smtpad_id) return;
2501
+ const pad = db.pcb_smtpad.get(this.pcb_smtpad_id);
2502
+ if (pad.shape === "rect" || pad.shape === "circle" || pad.shape === "rotated_rect" || pad.shape === "pill") {
2503
+ this._setPositionFromLayout({ x: pad.x + deltaX, y: pad.y + deltaY });
2504
+ } else if (pad.shape === "polygon") {
2505
+ db.pcb_smtpad.update(this.pcb_smtpad_id, {
2506
+ points: pad.points.map((p) => ({
2507
+ x: p.x + deltaX,
2508
+ y: p.y + deltaY
2509
+ }))
2510
+ });
2511
+ const newCenter = {
2512
+ x: this._getPcbCircuitJsonBounds().center.x + deltaX / 2,
2513
+ y: this._getPcbCircuitJsonBounds().center.y + deltaY / 2
2514
+ };
2515
+ this.matchedPort?._setPositionFromLayout(newCenter);
2516
+ }
2517
+ }
2494
2518
  };
2495
2519
 
2496
2520
  // lib/components/primitive-components/SilkscreenPath.ts
@@ -2967,6 +2991,22 @@ var PlatedHole = class extends PrimitiveComponent2 {
2967
2991
  pcb_port_id: this.matchedPort?.pcb_port_id
2968
2992
  });
2969
2993
  }
2994
+ _moveCircuitJsonElements({
2995
+ deltaX,
2996
+ deltaY
2997
+ }) {
2998
+ if (this.root?.pcbDisabled) return;
2999
+ const { db } = this.root;
3000
+ if (!this.pcb_plated_hole_id) return;
3001
+ const hole = db.pcb_plated_hole.get(this.pcb_plated_hole_id);
3002
+ if (hole) {
3003
+ const newCenter = {
3004
+ x: hole.x + deltaX,
3005
+ y: hole.y + deltaY
3006
+ };
3007
+ this._setPositionFromLayout(newCenter);
3008
+ }
3009
+ }
2970
3010
  };
2971
3011
 
2972
3012
  // lib/components/primitive-components/Keepout.ts
@@ -3154,6 +3194,21 @@ var Hole = class extends PrimitiveComponent2 {
3154
3194
  y: newCenter.y
3155
3195
  });
3156
3196
  }
3197
+ _moveCircuitJsonElements({
3198
+ deltaX,
3199
+ deltaY
3200
+ }) {
3201
+ if (this.root?.pcbDisabled) return;
3202
+ const { db } = this.root;
3203
+ if (!this.pcb_hole_id) return;
3204
+ const hole = db.pcb_hole.get(this.pcb_hole_id);
3205
+ if (hole) {
3206
+ db.pcb_hole.update(this.pcb_hole_id, {
3207
+ x: hole.x + deltaX,
3208
+ y: hole.y + deltaY
3209
+ });
3210
+ }
3211
+ }
3157
3212
  };
3158
3213
 
3159
3214
  // lib/components/primitive-components/SilkscreenText.ts
@@ -3400,6 +3455,27 @@ var Cutout = class extends PrimitiveComponent2 {
3400
3455
  });
3401
3456
  }
3402
3457
  }
3458
+ _moveCircuitJsonElements({
3459
+ deltaX,
3460
+ deltaY
3461
+ }) {
3462
+ if (!this.pcb_cutout_id) return;
3463
+ const { db } = this.root;
3464
+ const cutout = db.pcb_cutout.get(this.pcb_cutout_id);
3465
+ if (!cutout) return;
3466
+ if (cutout.shape === "rect" || cutout.shape === "circle") {
3467
+ db.pcb_cutout.update(this.pcb_cutout_id, {
3468
+ center: { x: cutout.center.x + deltaX, y: cutout.center.y + deltaY }
3469
+ });
3470
+ } else if (cutout.shape === "polygon") {
3471
+ db.pcb_cutout.update(this.pcb_cutout_id, {
3472
+ points: cutout.points.map((p) => ({
3473
+ x: p.x + deltaX,
3474
+ y: p.y + deltaY
3475
+ }))
3476
+ });
3477
+ }
3478
+ }
3403
3479
  };
3404
3480
 
3405
3481
  // lib/utils/createPinrowSilkscreenText.ts
@@ -17813,6 +17889,24 @@ var PcbNotePath = class extends PrimitiveComponent2 {
17813
17889
  const maxY = Math.max(...ys);
17814
17890
  return { width: maxX - minX, height: maxY - minY };
17815
17891
  }
17892
+ _moveCircuitJsonElements({
17893
+ deltaX,
17894
+ deltaY
17895
+ }) {
17896
+ if (this.root?.pcbDisabled) return;
17897
+ const { db } = this.root;
17898
+ if (!this.pcb_note_path_id) return;
17899
+ const path = db.pcb_note_path.get(this.pcb_note_path_id);
17900
+ if (path) {
17901
+ db.pcb_note_path.update(this.pcb_note_path_id, {
17902
+ route: path.route.map((p) => ({
17903
+ ...p,
17904
+ x: p.x + deltaX,
17905
+ y: p.y + deltaY
17906
+ }))
17907
+ });
17908
+ }
17909
+ }
17816
17910
  };
17817
17911
 
17818
17912
  // lib/components/primitive-components/PcbNoteDimension.ts
@@ -17894,6 +17988,27 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
17894
17988
  const valueText = units === "in" ? Number(distanceInUnits.toFixed(decimalPlaces)).toString() : distanceInUnits.toFixed(decimalPlaces);
17895
17989
  return `${valueText}${units}`;
17896
17990
  }
17991
+ _moveCircuitJsonElements({
17992
+ deltaX,
17993
+ deltaY
17994
+ }) {
17995
+ if (this.root?.pcbDisabled) return;
17996
+ const { db } = this.root;
17997
+ if (!this.pcb_note_dimension_id) return;
17998
+ const dimension = db.pcb_note_dimension.get(this.pcb_note_dimension_id);
17999
+ if (dimension) {
18000
+ db.pcb_note_dimension.update(this.pcb_note_dimension_id, {
18001
+ from: {
18002
+ x: dimension.from.x + deltaX,
18003
+ y: dimension.from.y + deltaY
18004
+ },
18005
+ to: {
18006
+ x: dimension.to.x + deltaX,
18007
+ y: dimension.to.y + deltaY
18008
+ }
18009
+ });
18010
+ }
18011
+ }
17897
18012
  };
17898
18013
 
17899
18014
  // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
@@ -18030,6 +18145,21 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18030
18145
  y: newCenter.y
18031
18146
  });
18032
18147
  }
18148
+ _moveCircuitJsonElements({
18149
+ deltaX,
18150
+ deltaY
18151
+ }) {
18152
+ if (this.root?.pcbDisabled) return;
18153
+ const { db } = this.root;
18154
+ if (!this.pcb_breakout_point_id) return;
18155
+ const point2 = db.pcb_breakout_point.get(this.pcb_breakout_point_id);
18156
+ if (point2) {
18157
+ db.pcb_breakout_point.update(this.pcb_breakout_point_id, {
18158
+ x: point2.x + deltaX,
18159
+ y: point2.y + deltaY
18160
+ });
18161
+ }
18162
+ }
18033
18163
  getPcbSize() {
18034
18164
  return { width: 0, height: 0 };
18035
18165
  }
@@ -18491,6 +18621,26 @@ var Fiducial = class extends PrimitiveComponent2 {
18491
18621
  y: newCenter.y
18492
18622
  });
18493
18623
  }
18624
+ _moveCircuitJsonElements({
18625
+ deltaX,
18626
+ deltaY
18627
+ }) {
18628
+ if (this.root?.pcbDisabled) return;
18629
+ const { db } = this.root;
18630
+ if (!this.pcb_smtpad_id) return;
18631
+ const pad = db.pcb_smtpad.get(this.pcb_smtpad_id);
18632
+ if (!pad) return;
18633
+ if (pad.shape === "rect" || pad.shape === "circle" || pad.shape === "rotated_rect" || pad.shape === "pill") {
18634
+ this._setPositionFromLayout({ x: pad.x + deltaX, y: pad.y + deltaY });
18635
+ } else if (pad.shape === "polygon") {
18636
+ db.pcb_smtpad.update(this.pcb_smtpad_id, {
18637
+ points: pad.points.map((p) => ({
18638
+ x: p.x + deltaX,
18639
+ y: p.y + deltaY
18640
+ }))
18641
+ });
18642
+ }
18643
+ }
18494
18644
  };
18495
18645
 
18496
18646
  // lib/components/primitive-components/Via.ts
@@ -18713,6 +18863,7 @@ var CopperPour = class extends PrimitiveComponent2 {
18713
18863
  import { copperTextProps } from "@tscircuit/props";
18714
18864
  var CopperText = class extends PrimitiveComponent2 {
18715
18865
  isPcbPrimitive = true;
18866
+ pcb_copper_text_id = null;
18716
18867
  get config() {
18717
18868
  return {
18718
18869
  componentName: "CopperText",
@@ -18726,7 +18877,7 @@ var CopperText = class extends PrimitiveComponent2 {
18726
18877
  const container = this.getPrimitiveContainer();
18727
18878
  const position = this._getGlobalPcbPositionBeforeLayout();
18728
18879
  const subcircuit = this.getSubcircuit();
18729
- db.pcb_copper_text.insert({
18880
+ const pcb_copper_text = db.pcb_copper_text.insert({
18730
18881
  anchor_alignment: props.anchorAlignment,
18731
18882
  anchor_position: {
18732
18883
  x: position.x,
@@ -18743,6 +18894,32 @@ var CopperText = class extends PrimitiveComponent2 {
18743
18894
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18744
18895
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
18745
18896
  });
18897
+ this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
18898
+ }
18899
+ getPcbSize() {
18900
+ const { _parsedProps: props } = this;
18901
+ const fontSize = props.fontSize ?? 1;
18902
+ const text = props.text ?? "";
18903
+ const textWidth = text.length * fontSize;
18904
+ const textHeight = fontSize;
18905
+ return { width: textWidth * fontSize, height: textHeight * fontSize };
18906
+ }
18907
+ _moveCircuitJsonElements({
18908
+ deltaX,
18909
+ deltaY
18910
+ }) {
18911
+ if (this.root?.pcbDisabled) return;
18912
+ const { db } = this.root;
18913
+ if (!this.pcb_copper_text_id) return;
18914
+ const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
18915
+ if (text) {
18916
+ db.pcb_copper_text.update(this.pcb_copper_text_id, {
18917
+ anchor_position: {
18918
+ x: text.anchor_position.x + deltaX,
18919
+ y: text.anchor_position.y + deltaY
18920
+ }
18921
+ });
18922
+ }
18746
18923
  }
18747
18924
  };
18748
18925
 
@@ -20123,7 +20300,7 @@ import { identity as identity5 } from "transformation-matrix";
20123
20300
  var package_default = {
20124
20301
  name: "@tscircuit/core",
20125
20302
  type: "module",
20126
- version: "0.0.945",
20303
+ version: "0.0.946",
20127
20304
  types: "dist/index.d.ts",
20128
20305
  main: "dist/index.js",
20129
20306
  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.946",
4
+ "version": "0.0.947",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",