@tscircuit/core 0.0.942 → 0.0.943

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
@@ -20206,6 +20206,7 @@ declare class Constraint extends PrimitiveComponent<typeof constraintProps> {
20206
20206
 
20207
20207
  declare class FabricationNoteRect extends PrimitiveComponent<typeof fabricationNoteRectProps> {
20208
20208
  fabrication_note_rect_id: string | null;
20209
+ isPcbPrimitive: boolean;
20209
20210
  get config(): {
20210
20211
  componentName: string;
20211
20212
  zodProps: zod.ZodObject<Omit<{
@@ -20365,10 +20366,15 @@ declare class FabricationNoteRect extends PrimitiveComponent<typeof fabricationN
20365
20366
  width: number;
20366
20367
  height: number;
20367
20368
  };
20369
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
20370
+ deltaX: number;
20371
+ deltaY: number;
20372
+ }): void;
20368
20373
  }
20369
20374
 
20370
20375
  declare class FabricationNotePath extends PrimitiveComponent<typeof fabricationNotePathProps> {
20371
20376
  fabrication_note_path_id: string | null;
20377
+ isPcbPrimitive: boolean;
20372
20378
  get config(): {
20373
20379
  componentName: string;
20374
20380
  zodProps: zod.ZodObject<Omit<{
@@ -20535,9 +20541,19 @@ declare class FabricationNotePath extends PrimitiveComponent<typeof fabricationN
20535
20541
  }>;
20536
20542
  };
20537
20543
  doInitialPcbPrimitiveRender(): void;
20544
+ getPcbSize(): {
20545
+ width: number;
20546
+ height: number;
20547
+ };
20548
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
20549
+ deltaX: number;
20550
+ deltaY: number;
20551
+ }): void;
20538
20552
  }
20539
20553
 
20540
20554
  declare class FabricationNoteText extends PrimitiveComponent<typeof fabricationNoteTextProps> {
20555
+ pcb_fabrication_note_text_id: string | null;
20556
+ isPcbPrimitive: boolean;
20541
20557
  get config(): {
20542
20558
  componentName: string;
20543
20559
  zodProps: zod.ZodObject<{
@@ -20686,6 +20702,14 @@ declare class FabricationNoteText extends PrimitiveComponent<typeof fabricationN
20686
20702
  }>;
20687
20703
  };
20688
20704
  doInitialPcbPrimitiveRender(): void;
20705
+ getPcbSize(): {
20706
+ width: number;
20707
+ height: number;
20708
+ };
20709
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
20710
+ deltaX: number;
20711
+ deltaY: number;
20712
+ }): void;
20689
20713
  }
20690
20714
 
20691
20715
  declare class FabricationNoteDimension extends PrimitiveComponent<typeof fabricationNoteDimensionProps> {
@@ -20873,6 +20897,10 @@ declare class FabricationNoteDimension extends PrimitiveComponent<typeof fabrica
20873
20897
  };
20874
20898
  private _resolvePoint;
20875
20899
  doInitialPcbPrimitiveRender(): void;
20900
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
20901
+ deltaX: number;
20902
+ deltaY: number;
20903
+ }): void;
20876
20904
  getPcbSize(): {
20877
20905
  width: number;
20878
20906
  height: number;
@@ -24628,7 +24656,7 @@ declare class SilkscreenCircle extends PrimitiveComponent<typeof silkscreenCircl
24628
24656
  width: number;
24629
24657
  height: number;
24630
24658
  };
24631
- _repositionOnPcb({ deltaX, deltaY }: {
24659
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
24632
24660
  deltaX: number;
24633
24661
  deltaY: number;
24634
24662
  }): void;
@@ -24804,7 +24832,7 @@ declare class SilkscreenPath extends PrimitiveComponent<typeof silkscreenPathPro
24804
24832
  x: number;
24805
24833
  y: number;
24806
24834
  }): void;
24807
- _repositionOnPcb({ deltaX, deltaY }: {
24835
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
24808
24836
  deltaX: number;
24809
24837
  deltaY: number;
24810
24838
  }): void;
@@ -24970,7 +24998,7 @@ declare class SilkscreenRect extends PrimitiveComponent<typeof silkscreenRectPro
24970
24998
  width: number;
24971
24999
  height: number;
24972
25000
  };
24973
- _repositionOnPcb({ deltaX, deltaY }: {
25001
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
24974
25002
  deltaX: number;
24975
25003
  deltaY: number;
24976
25004
  }): void;
@@ -25159,7 +25187,7 @@ declare class SilkscreenText extends PrimitiveComponent<typeof silkscreenTextPro
25159
25187
  width: number;
25160
25188
  height: number;
25161
25189
  };
25162
- _repositionOnPcb({ deltaX, deltaY }: {
25190
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
25163
25191
  deltaX: number;
25164
25192
  deltaY: number;
25165
25193
  }): void;
@@ -25310,7 +25338,7 @@ declare class SilkscreenLine extends PrimitiveComponent<typeof silkscreenLinePro
25310
25338
  width: number;
25311
25339
  height: number;
25312
25340
  };
25313
- _repositionOnPcb({ deltaX, deltaY }: {
25341
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
25314
25342
  deltaX: number;
25315
25343
  deltaY: number;
25316
25344
  }): void;
package/dist/index.js CHANGED
@@ -2562,7 +2562,10 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
2562
2562
  route: newRoute
2563
2563
  });
2564
2564
  }
2565
- _repositionOnPcb({ deltaX, deltaY }) {
2565
+ _moveCircuitJsonElements({
2566
+ deltaX,
2567
+ deltaY
2568
+ }) {
2566
2569
  if (this.root?.pcbDisabled) return;
2567
2570
  const { db } = this.root;
2568
2571
  if (!this.pcb_silkscreen_path_id) return;
@@ -3223,7 +3226,10 @@ var SilkscreenText = class extends PrimitiveComponent2 {
3223
3226
  const textHeight = fontSize;
3224
3227
  return { width: textWidth * fontSize, height: textHeight * fontSize };
3225
3228
  }
3226
- _repositionOnPcb({ deltaX, deltaY }) {
3229
+ _moveCircuitJsonElements({
3230
+ deltaX,
3231
+ deltaY
3232
+ }) {
3227
3233
  if (this.root?.pcbDisabled) return;
3228
3234
  const { db } = this.root;
3229
3235
  for (const id of this.pcb_silkscreen_text_ids) {
@@ -16004,8 +16010,8 @@ var Board = class extends Group6 {
16004
16010
  y: childOldCenter.y + deltaY
16005
16011
  });
16006
16012
  }
16007
- } else if (child.isPcbPrimitive && "_repositionOnPcb" in child && typeof child._repositionOnPcb === "function") {
16008
- child._repositionOnPcb({ deltaX, deltaY });
16013
+ } else if (child.isPcbPrimitive && "_moveCircuitJsonElements" in child && typeof child._moveCircuitJsonElements === "function") {
16014
+ child._moveCircuitJsonElements({ deltaX, deltaY });
16009
16015
  }
16010
16016
  }
16011
16017
  if (this.pcb_board_id) {
@@ -17097,6 +17103,7 @@ import { fabricationNoteRectProps } from "@tscircuit/props";
17097
17103
  import "transformation-matrix";
17098
17104
  var FabricationNoteRect = class extends PrimitiveComponent2 {
17099
17105
  fabrication_note_rect_id = null;
17106
+ isPcbPrimitive = true;
17100
17107
  get config() {
17101
17108
  return {
17102
17109
  componentName: "FabricationNoteRect",
@@ -17142,6 +17149,23 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17142
17149
  const { _parsedProps: props } = this;
17143
17150
  return { width: props.width, height: props.height };
17144
17151
  }
17152
+ _moveCircuitJsonElements({
17153
+ deltaX,
17154
+ deltaY
17155
+ }) {
17156
+ if (this.root?.pcbDisabled) return;
17157
+ const { db } = this.root;
17158
+ if (!this.fabrication_note_rect_id) return;
17159
+ const rect = db.pcb_fabrication_note_rect.get(this.fabrication_note_rect_id);
17160
+ if (rect) {
17161
+ db.pcb_fabrication_note_rect.update(this.fabrication_note_rect_id, {
17162
+ center: {
17163
+ x: rect.center.x + deltaX,
17164
+ y: rect.center.y + deltaY
17165
+ }
17166
+ });
17167
+ }
17168
+ }
17145
17169
  };
17146
17170
 
17147
17171
  // lib/components/primitive-components/FabricationNotePath.ts
@@ -17149,6 +17173,7 @@ import { fabricationNotePathProps } from "@tscircuit/props";
17149
17173
  import { applyToPoint as applyToPoint10 } from "transformation-matrix";
17150
17174
  var FabricationNotePath = class extends PrimitiveComponent2 {
17151
17175
  fabrication_note_path_id = null;
17176
+ isPcbPrimitive = true;
17152
17177
  get config() {
17153
17178
  return {
17154
17179
  componentName: "FabricationNotePath",
@@ -17188,11 +17213,46 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
17188
17213
  });
17189
17214
  this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
17190
17215
  }
17216
+ getPcbSize() {
17217
+ const { _parsedProps: props } = this;
17218
+ if (props.route.length === 0) return { width: 0, height: 0 };
17219
+ const xs = props.route.map(
17220
+ (point2) => typeof point2.x === "string" ? parseFloat(point2.x) : point2.x
17221
+ );
17222
+ const ys = props.route.map(
17223
+ (point2) => typeof point2.y === "string" ? parseFloat(point2.y) : point2.y
17224
+ );
17225
+ const minX = Math.min(...xs);
17226
+ const maxX = Math.max(...xs);
17227
+ const minY = Math.min(...ys);
17228
+ const maxY = Math.max(...ys);
17229
+ return { width: maxX - minX, height: maxY - minY };
17230
+ }
17231
+ _moveCircuitJsonElements({
17232
+ deltaX,
17233
+ deltaY
17234
+ }) {
17235
+ if (this.root?.pcbDisabled) return;
17236
+ const { db } = this.root;
17237
+ if (!this.fabrication_note_path_id) return;
17238
+ const path = db.pcb_fabrication_note_path.get(this.fabrication_note_path_id);
17239
+ if (path) {
17240
+ db.pcb_fabrication_note_path.update(this.fabrication_note_path_id, {
17241
+ route: path.route.map((p) => ({
17242
+ ...p,
17243
+ x: p.x + deltaX,
17244
+ y: p.y + deltaY
17245
+ }))
17246
+ });
17247
+ }
17248
+ }
17191
17249
  };
17192
17250
 
17193
17251
  // lib/components/primitive-components/FabricationNoteText.ts
17194
17252
  import { fabricationNoteTextProps } from "@tscircuit/props";
17195
17253
  var FabricationNoteText = class extends PrimitiveComponent2 {
17254
+ pcb_fabrication_note_text_id = null;
17255
+ isPcbPrimitive = true;
17196
17256
  get config() {
17197
17257
  return {
17198
17258
  componentName: "FabricationNoteText",
@@ -17206,7 +17266,7 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
17206
17266
  const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17207
17267
  const container = this.getPrimitiveContainer();
17208
17268
  const subcircuit = this.getSubcircuit();
17209
- db.pcb_fabrication_note_text.insert({
17269
+ const pcb_fabrication_note_text = db.pcb_fabrication_note_text.insert({
17210
17270
  anchor_alignment: props.anchorAlignment,
17211
17271
  anchor_position: {
17212
17272
  x: pcbX,
@@ -17221,6 +17281,35 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
17221
17281
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
17222
17282
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
17223
17283
  });
17284
+ this.pcb_fabrication_note_text_id = pcb_fabrication_note_text.pcb_fabrication_note_text_id;
17285
+ }
17286
+ getPcbSize() {
17287
+ const { _parsedProps: props } = this;
17288
+ const fontSize = typeof props.fontSize === "string" ? parseFloat(props.fontSize) : props.fontSize ?? 1;
17289
+ const charWidth = fontSize * 0.6;
17290
+ const width = (props.text ?? "").length * charWidth;
17291
+ const height = fontSize;
17292
+ return { width, height };
17293
+ }
17294
+ _moveCircuitJsonElements({
17295
+ deltaX,
17296
+ deltaY
17297
+ }) {
17298
+ if (this.root?.pcbDisabled) return;
17299
+ const { db } = this.root;
17300
+ if (this.pcb_fabrication_note_text_id) {
17301
+ const text = db.pcb_fabrication_note_text.get(
17302
+ this.pcb_fabrication_note_text_id
17303
+ );
17304
+ if (text) {
17305
+ db.pcb_fabrication_note_text.update(this.pcb_fabrication_note_text_id, {
17306
+ anchor_position: {
17307
+ x: text.anchor_position.x + deltaX,
17308
+ y: text.anchor_position.y + deltaY
17309
+ }
17310
+ });
17311
+ }
17312
+ }
17224
17313
  }
17225
17314
  };
17226
17315
 
@@ -17289,6 +17378,32 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
17289
17378
  );
17290
17379
  this.fabrication_note_dimension_id = fabrication_note_dimension.pcb_fabrication_note_dimension_id;
17291
17380
  }
17381
+ _moveCircuitJsonElements({
17382
+ deltaX,
17383
+ deltaY
17384
+ }) {
17385
+ if (this.root?.pcbDisabled) return;
17386
+ const { db } = this.root;
17387
+ if (!this.fabrication_note_dimension_id) return;
17388
+ const dimension = db.pcb_fabrication_note_dimension.get(
17389
+ this.fabrication_note_dimension_id
17390
+ );
17391
+ if (dimension) {
17392
+ db.pcb_fabrication_note_dimension.update(
17393
+ this.fabrication_note_dimension_id,
17394
+ {
17395
+ from: {
17396
+ x: dimension.from.x + deltaX,
17397
+ y: dimension.from.y + deltaY
17398
+ },
17399
+ to: {
17400
+ x: dimension.to.x + deltaX,
17401
+ y: dimension.to.y + deltaY
17402
+ }
17403
+ }
17404
+ );
17405
+ }
17406
+ }
17292
17407
  getPcbSize() {
17293
17408
  const transform = this._computePcbGlobalTransformBeforeLayout();
17294
17409
  const from = this._resolvePoint(this._parsedProps.from, transform);
@@ -17970,7 +18085,10 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
17970
18085
  const diameter = props.radius * 2;
17971
18086
  return { width: diameter, height: diameter };
17972
18087
  }
17973
- _repositionOnPcb({ deltaX, deltaY }) {
18088
+ _moveCircuitJsonElements({
18089
+ deltaX,
18090
+ deltaY
18091
+ }) {
17974
18092
  if (this.root?.pcbDisabled) return;
17975
18093
  const { db } = this.root;
17976
18094
  if (!this.pcb_silkscreen_circle_id) return;
@@ -18032,7 +18150,10 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18032
18150
  const { _parsedProps: props } = this;
18033
18151
  return { width: props.width, height: props.height };
18034
18152
  }
18035
- _repositionOnPcb({ deltaX, deltaY }) {
18153
+ _moveCircuitJsonElements({
18154
+ deltaX,
18155
+ deltaY
18156
+ }) {
18036
18157
  if (this.root?.pcbDisabled) return;
18037
18158
  const { db } = this.root;
18038
18159
  if (!this.pcb_silkscreen_rect_id) return;
@@ -18091,7 +18212,10 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
18091
18212
  const height = Math.abs(props.y2 - props.y1);
18092
18213
  return { width, height };
18093
18214
  }
18094
- _repositionOnPcb({ deltaX, deltaY }) {
18215
+ _moveCircuitJsonElements({
18216
+ deltaX,
18217
+ deltaY
18218
+ }) {
18095
18219
  if (this.root?.pcbDisabled) return;
18096
18220
  const { db } = this.root;
18097
18221
  if (!this.pcb_silkscreen_line_id) return;
@@ -19785,7 +19909,7 @@ import { identity as identity5 } from "transformation-matrix";
19785
19909
  var package_default = {
19786
19910
  name: "@tscircuit/core",
19787
19911
  type: "module",
19788
- version: "0.0.941",
19912
+ version: "0.0.942",
19789
19913
  types: "dist/index.d.ts",
19790
19914
  main: "dist/index.js",
19791
19915
  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.942",
4
+ "version": "0.0.943",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",