@tscircuit/core 0.0.960 → 0.0.961
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 +66 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14002,6 +14002,26 @@ function computeCenterFromAnchorPosition(anchorPosition, ctx) {
|
|
|
14002
14002
|
}
|
|
14003
14003
|
|
|
14004
14004
|
// lib/components/primitive-components/Group/insert-autoplaced-jumpers.ts
|
|
14005
|
+
function groupPadsByInternalConnection(pads, orientation) {
|
|
14006
|
+
const tolerance = 0.01;
|
|
14007
|
+
const groups = [];
|
|
14008
|
+
for (const pad of pads) {
|
|
14009
|
+
const key = orientation === "vertical" ? pad.center.y : pad.center.x;
|
|
14010
|
+
let foundGroup = false;
|
|
14011
|
+
for (const group of groups) {
|
|
14012
|
+
const groupKey = orientation === "vertical" ? group[0].center.y : group[0].center.x;
|
|
14013
|
+
if (Math.abs(key - groupKey) < tolerance) {
|
|
14014
|
+
group.push(pad);
|
|
14015
|
+
foundGroup = true;
|
|
14016
|
+
break;
|
|
14017
|
+
}
|
|
14018
|
+
}
|
|
14019
|
+
if (!foundGroup) {
|
|
14020
|
+
groups.push([pad]);
|
|
14021
|
+
}
|
|
14022
|
+
}
|
|
14023
|
+
return groups.filter((g) => g.length >= 2);
|
|
14024
|
+
}
|
|
14005
14025
|
function insertAutoplacedJumpers(params) {
|
|
14006
14026
|
const { db, output_jumpers, subcircuit_id } = params;
|
|
14007
14027
|
for (let jumperIndex = 0; jumperIndex < output_jumpers.length; jumperIndex++) {
|
|
@@ -14023,10 +14043,26 @@ function insertAutoplacedJumpers(params) {
|
|
|
14023
14043
|
height: jumper.height || 0,
|
|
14024
14044
|
obstructs_within_bounds: false
|
|
14025
14045
|
});
|
|
14026
|
-
|
|
14046
|
+
const padData = [];
|
|
14047
|
+
for (let padIndex = 0; padIndex < jumper.pads.length; padIndex++) {
|
|
14048
|
+
const pad = jumper.pads[padIndex];
|
|
14049
|
+
const pinNumber = padIndex + 1;
|
|
14050
|
+
const sourcePort = db.source_port.insert({
|
|
14051
|
+
source_component_id: sourceComponent.source_component_id,
|
|
14052
|
+
name: `pin${pinNumber}`,
|
|
14053
|
+
pin_number: pinNumber
|
|
14054
|
+
});
|
|
14027
14055
|
const padLayer = pad.layer || pad.layers?.[0] || "top";
|
|
14028
|
-
db.
|
|
14056
|
+
const pcbPort = db.pcb_port.insert({
|
|
14057
|
+
pcb_component_id: pcbComponent.pcb_component_id,
|
|
14058
|
+
source_port_id: sourcePort.source_port_id,
|
|
14059
|
+
x: pad.center.x,
|
|
14060
|
+
y: pad.center.y,
|
|
14061
|
+
layers: [padLayer]
|
|
14062
|
+
});
|
|
14063
|
+
const pcbSmtpad = db.pcb_smtpad.insert({
|
|
14029
14064
|
pcb_component_id: pcbComponent.pcb_component_id,
|
|
14065
|
+
pcb_port_id: pcbPort.pcb_port_id,
|
|
14030
14066
|
shape: "rect",
|
|
14031
14067
|
x: pad.center.x,
|
|
14032
14068
|
y: pad.center.y,
|
|
@@ -14034,6 +14070,33 @@ function insertAutoplacedJumpers(params) {
|
|
|
14034
14070
|
height: pad.height,
|
|
14035
14071
|
layer: padLayer
|
|
14036
14072
|
});
|
|
14073
|
+
padData.push({
|
|
14074
|
+
pad,
|
|
14075
|
+
sourcePortId: sourcePort.source_port_id,
|
|
14076
|
+
pcbSmtpadId: pcbSmtpad.pcb_smtpad_id
|
|
14077
|
+
});
|
|
14078
|
+
}
|
|
14079
|
+
const internalGroups = groupPadsByInternalConnection(
|
|
14080
|
+
jumper.pads,
|
|
14081
|
+
jumper.orientation
|
|
14082
|
+
);
|
|
14083
|
+
for (const group of internalGroups) {
|
|
14084
|
+
const sourcePortIds = [];
|
|
14085
|
+
for (const groupPad of group) {
|
|
14086
|
+
const padInfo = padData.find(
|
|
14087
|
+
(p) => Math.abs(p.pad.center.x - groupPad.center.x) < 0.01 && Math.abs(p.pad.center.y - groupPad.center.y) < 0.01
|
|
14088
|
+
);
|
|
14089
|
+
if (padInfo) {
|
|
14090
|
+
sourcePortIds.push(padInfo.sourcePortId);
|
|
14091
|
+
}
|
|
14092
|
+
}
|
|
14093
|
+
if (sourcePortIds.length >= 2) {
|
|
14094
|
+
db.source_component_internal_connection.insert({
|
|
14095
|
+
source_component_id: sourceComponent.source_component_id,
|
|
14096
|
+
subcircuit_id: subcircuit_id ?? void 0,
|
|
14097
|
+
source_port_ids: sourcePortIds
|
|
14098
|
+
});
|
|
14099
|
+
}
|
|
14037
14100
|
}
|
|
14038
14101
|
}
|
|
14039
14102
|
}
|
|
@@ -20536,7 +20599,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
20536
20599
|
var package_default = {
|
|
20537
20600
|
name: "@tscircuit/core",
|
|
20538
20601
|
type: "module",
|
|
20539
|
-
version: "0.0.
|
|
20602
|
+
version: "0.0.960",
|
|
20540
20603
|
types: "dist/index.d.ts",
|
|
20541
20604
|
main: "dist/index.js",
|
|
20542
20605
|
module: "dist/index.js",
|