@tscircuit/core 0.0.961 → 0.0.962
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.js +128 -5
- package/package.json +1 -1
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
|
-
|
|
14826
|
+
let segments = splitPcbTracesOnJumperSegments(pcb_trace.route);
|
|
14704
14827
|
if (segments === null) {
|
|
14705
|
-
|
|
14706
|
-
continue;
|
|
14828
|
+
segments = [pcb_trace.route];
|
|
14707
14829
|
}
|
|
14708
|
-
|
|
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,
|
|
@@ -20599,7 +20722,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
20599
20722
|
var package_default = {
|
|
20600
20723
|
name: "@tscircuit/core",
|
|
20601
20724
|
type: "module",
|
|
20602
|
-
version: "0.0.
|
|
20725
|
+
version: "0.0.961",
|
|
20603
20726
|
types: "dist/index.d.ts",
|
|
20604
20727
|
main: "dist/index.js",
|
|
20605
20728
|
module: "dist/index.js",
|