@tscircuit/core 0.0.961 → 0.0.963

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
@@ -22249,6 +22249,10 @@ declare class PcbNoteLine extends PrimitiveComponent<typeof pcbNoteLineProps> {
22249
22249
  width: number;
22250
22250
  height: number;
22251
22251
  };
22252
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
22253
+ deltaX: number;
22254
+ deltaY: number;
22255
+ }): void;
22252
22256
  }
22253
22257
 
22254
22258
  declare class PcbNoteRect extends PrimitiveComponent<typeof pcbNoteRectProps> {
@@ -22413,6 +22417,10 @@ declare class PcbNoteRect extends PrimitiveComponent<typeof pcbNoteRectProps> {
22413
22417
  width: number;
22414
22418
  height: number;
22415
22419
  };
22420
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
22421
+ deltaX: number;
22422
+ deltaY: number;
22423
+ }): void;
22416
22424
  }
22417
22425
 
22418
22426
  declare class PcbNoteText extends PrimitiveComponent<typeof pcbNoteTextProps> {
@@ -22570,6 +22578,10 @@ declare class PcbNoteText extends PrimitiveComponent<typeof pcbNoteTextProps> {
22570
22578
  width: number;
22571
22579
  height: number;
22572
22580
  };
22581
+ _moveCircuitJsonElements({ deltaX, deltaY, }: {
22582
+ deltaX: number;
22583
+ deltaY: number;
22584
+ }): void;
22573
22585
  }
22574
22586
 
22575
22587
  declare class PcbNotePath extends PrimitiveComponent<typeof pcbNotePathProps> {
package/dist/index.js CHANGED
@@ -14155,6 +14155,129 @@ function splitPcbTracesOnJumperSegments(route) {
14155
14155
  return segments;
14156
14156
  }
14157
14157
 
14158
+ // lib/components/primitive-components/Group/add-port-ids-to-traces-at-jumper-pads.ts
14159
+ function getJumperPadInfos(db) {
14160
+ const padInfos = [];
14161
+ const pcbSmtpads = db.pcb_smtpad.list();
14162
+ const jumperSmtpads = pcbSmtpads.filter((pad) => {
14163
+ const component = db.pcb_component.get(pad.pcb_component_id);
14164
+ if (!component) return false;
14165
+ const sourceComponent = db.source_component.get(
14166
+ component.source_component_id
14167
+ );
14168
+ return sourceComponent?.name?.startsWith("__autoplaced_jumper");
14169
+ });
14170
+ for (const smtpad of jumperSmtpads) {
14171
+ if (smtpad.shape === "polygon") continue;
14172
+ if (!smtpad.pcb_port_id) continue;
14173
+ if (smtpad.shape === "rect" || smtpad.shape === "rotated_rect") {
14174
+ const halfWidth = smtpad.width / 2;
14175
+ const halfHeight = smtpad.height / 2;
14176
+ padInfos.push({
14177
+ pcb_port_id: smtpad.pcb_port_id,
14178
+ x: smtpad.x,
14179
+ y: smtpad.y,
14180
+ minX: smtpad.x - halfWidth,
14181
+ maxX: smtpad.x + halfWidth,
14182
+ minY: smtpad.y - halfHeight,
14183
+ maxY: smtpad.y + halfHeight
14184
+ });
14185
+ } else if (smtpad.shape === "circle") {
14186
+ const radius = smtpad.radius;
14187
+ padInfos.push({
14188
+ pcb_port_id: smtpad.pcb_port_id,
14189
+ x: smtpad.x,
14190
+ y: smtpad.y,
14191
+ minX: smtpad.x - radius,
14192
+ maxX: smtpad.x + radius,
14193
+ minY: smtpad.y - radius,
14194
+ maxY: smtpad.y + radius
14195
+ });
14196
+ }
14197
+ }
14198
+ return padInfos;
14199
+ }
14200
+ function findJumperPortAtPosition(padInfos, x, y, tolerance = 0.01) {
14201
+ for (const pad of padInfos) {
14202
+ if (Math.abs(pad.x - x) < tolerance && Math.abs(pad.y - y) < tolerance) {
14203
+ return pad.pcb_port_id;
14204
+ }
14205
+ }
14206
+ return void 0;
14207
+ }
14208
+ function findJumperPortContainingPoint(padInfos, x, y) {
14209
+ for (const pad of padInfos) {
14210
+ if (x >= pad.minX && x <= pad.maxX && y >= pad.minY && y <= pad.maxY) {
14211
+ return pad;
14212
+ }
14213
+ }
14214
+ return void 0;
14215
+ }
14216
+ function splitRouteAtJumperPads(route, padInfos) {
14217
+ if (route.length === 0 || padInfos.length === 0) return [route];
14218
+ const segments = [];
14219
+ let currentSegment = [];
14220
+ for (let i = 0; i < route.length; i++) {
14221
+ const point2 = route[i];
14222
+ currentSegment.push(point2);
14223
+ if (point2.route_type === "wire" && i > 0 && i < route.length - 1) {
14224
+ const padInfo = findJumperPortContainingPoint(padInfos, point2.x, point2.y);
14225
+ if (padInfo) {
14226
+ if (!point2.end_pcb_port_id) {
14227
+ point2.end_pcb_port_id = padInfo.pcb_port_id;
14228
+ }
14229
+ segments.push(currentSegment);
14230
+ const newStartPoint = { ...point2 };
14231
+ delete newStartPoint.end_pcb_port_id;
14232
+ if (!newStartPoint.start_pcb_port_id) {
14233
+ newStartPoint.start_pcb_port_id = padInfo.pcb_port_id;
14234
+ }
14235
+ currentSegment = [newStartPoint];
14236
+ }
14237
+ }
14238
+ }
14239
+ if (currentSegment.length > 0) {
14240
+ segments.push(currentSegment);
14241
+ }
14242
+ return segments;
14243
+ }
14244
+ function addPortIdsToTracesAtJumperPads(segments, db) {
14245
+ const padInfos = getJumperPadInfos(db);
14246
+ if (padInfos.length === 0) return segments;
14247
+ const result = [];
14248
+ for (const segment2 of segments) {
14249
+ const subSegments = splitRouteAtJumperPads(segment2, padInfos);
14250
+ for (const subSegment of subSegments) {
14251
+ if (subSegment.length > 0) {
14252
+ const firstPoint = subSegment[0];
14253
+ const lastPoint = subSegment[subSegment.length - 1];
14254
+ if (firstPoint.route_type === "wire" && !firstPoint.start_pcb_port_id) {
14255
+ const portId = findJumperPortAtPosition(
14256
+ padInfos,
14257
+ firstPoint.x,
14258
+ firstPoint.y
14259
+ );
14260
+ if (portId) {
14261
+ firstPoint.start_pcb_port_id = portId;
14262
+ }
14263
+ }
14264
+ if (lastPoint.route_type === "wire" && !lastPoint.end_pcb_port_id) {
14265
+ const portId = findJumperPortAtPosition(
14266
+ padInfos,
14267
+ lastPoint.x,
14268
+ lastPoint.y
14269
+ );
14270
+ if (portId) {
14271
+ lastPoint.end_pcb_port_id = portId;
14272
+ }
14273
+ }
14274
+ result.push(subSegment);
14275
+ }
14276
+ }
14277
+ }
14278
+ return result;
14279
+ }
14280
+
14158
14281
  // lib/components/primitive-components/Group/Group.ts
14159
14282
  var Group6 = class extends NormalComponent3 {
14160
14283
  pcb_group_id = null;
@@ -14700,12 +14823,12 @@ var Group6 = class extends NormalComponent3 {
14700
14823
  const sourceTraceId = pcb_trace.connection_name;
14701
14824
  pcb_trace.source_trace_id = sourceTraceId;
14702
14825
  }
14703
- const segments = splitPcbTracesOnJumperSegments(pcb_trace.route);
14826
+ let segments = splitPcbTracesOnJumperSegments(pcb_trace.route);
14704
14827
  if (segments === null) {
14705
- db.pcb_trace.insert(pcb_trace);
14706
- continue;
14828
+ segments = [pcb_trace.route];
14707
14829
  }
14708
- for (const segment2 of segments) {
14830
+ const processedSegments = addPortIdsToTracesAtJumperPads(segments, db);
14831
+ for (const segment2 of processedSegments) {
14709
14832
  if (segment2.length > 0) {
14710
14833
  db.pcb_trace.insert({
14711
14834
  ...pcb_trace,
@@ -17983,6 +18106,23 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
17983
18106
  height: Math.abs(props.y2 - props.y1)
17984
18107
  };
17985
18108
  }
18109
+ _moveCircuitJsonElements({
18110
+ deltaX,
18111
+ deltaY
18112
+ }) {
18113
+ if (this.root?.pcbDisabled) return;
18114
+ const { db } = this.root;
18115
+ if (!this.pcb_note_line_id) return;
18116
+ const line = db.pcb_note_line.get(this.pcb_note_line_id);
18117
+ if (line) {
18118
+ db.pcb_note_line.update(this.pcb_note_line_id, {
18119
+ x1: line.x1 + deltaX,
18120
+ y1: line.y1 + deltaY,
18121
+ x2: line.x2 + deltaX,
18122
+ y2: line.y2 + deltaY
18123
+ });
18124
+ }
18125
+ }
17986
18126
  };
17987
18127
 
17988
18128
  // lib/components/primitive-components/PcbNoteRect.ts
@@ -18028,6 +18168,23 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
18028
18168
  const height = typeof props.height === "string" ? parseFloat(props.height) : props.height;
18029
18169
  return { width, height };
18030
18170
  }
18171
+ _moveCircuitJsonElements({
18172
+ deltaX,
18173
+ deltaY
18174
+ }) {
18175
+ if (this.root?.pcbDisabled) return;
18176
+ const { db } = this.root;
18177
+ if (!this.pcb_note_rect_id) return;
18178
+ const rect = db.pcb_note_rect.get(this.pcb_note_rect_id);
18179
+ if (rect) {
18180
+ db.pcb_note_rect.update(this.pcb_note_rect_id, {
18181
+ center: {
18182
+ x: rect.center.x + deltaX,
18183
+ y: rect.center.y + deltaY
18184
+ }
18185
+ });
18186
+ }
18187
+ }
18031
18188
  };
18032
18189
 
18033
18190
  // lib/components/primitive-components/PcbNoteText.ts
@@ -18072,6 +18229,23 @@ var PcbNoteText = class extends PrimitiveComponent2 {
18072
18229
  const height = fontSize;
18073
18230
  return { width, height };
18074
18231
  }
18232
+ _moveCircuitJsonElements({
18233
+ deltaX,
18234
+ deltaY
18235
+ }) {
18236
+ if (this.root?.pcbDisabled) return;
18237
+ const { db } = this.root;
18238
+ if (!this.pcb_note_text_id) return;
18239
+ const text = db.pcb_note_text.get(this.pcb_note_text_id);
18240
+ if (text) {
18241
+ db.pcb_note_text.update(this.pcb_note_text_id, {
18242
+ anchor_position: {
18243
+ x: text.anchor_position.x + deltaX,
18244
+ y: text.anchor_position.y + deltaY
18245
+ }
18246
+ });
18247
+ }
18248
+ }
18075
18249
  };
18076
18250
 
18077
18251
  // lib/components/primitive-components/PcbNotePath.ts
@@ -20599,7 +20773,7 @@ import { identity as identity5 } from "transformation-matrix";
20599
20773
  var package_default = {
20600
20774
  name: "@tscircuit/core",
20601
20775
  type: "module",
20602
- version: "0.0.960",
20776
+ version: "0.0.962",
20603
20777
  types: "dist/index.d.ts",
20604
20778
  main: "dist/index.js",
20605
20779
  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.961",
4
+ "version": "0.0.963",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",