@tscircuit/core 0.0.908 → 0.0.909
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 +26 -145
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11836,9 +11836,7 @@ import {
|
|
|
11836
11836
|
convertPackOutputToPackInput,
|
|
11837
11837
|
getGraphicsFromPackOutput
|
|
11838
11838
|
} from "calculate-packing";
|
|
11839
|
-
import {
|
|
11840
|
-
length as length4
|
|
11841
|
-
} from "circuit-json";
|
|
11839
|
+
import { length as length4 } from "circuit-json";
|
|
11842
11840
|
import Debug8 from "debug";
|
|
11843
11841
|
|
|
11844
11842
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/applyComponentConstraintClusters.ts
|
|
@@ -12211,83 +12209,6 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
12211
12209
|
}
|
|
12212
12210
|
};
|
|
12213
12211
|
|
|
12214
|
-
// lib/utils/packing/getObstacleDimensionsFromElement.ts
|
|
12215
|
-
function getObstacleDimensionsFromSmtPad(pad) {
|
|
12216
|
-
switch (pad.shape) {
|
|
12217
|
-
case "rect":
|
|
12218
|
-
case "rotated_rect":
|
|
12219
|
-
case "pill":
|
|
12220
|
-
case "rotated_pill":
|
|
12221
|
-
return {
|
|
12222
|
-
width: pad.width,
|
|
12223
|
-
height: pad.height
|
|
12224
|
-
};
|
|
12225
|
-
case "circle":
|
|
12226
|
-
return {
|
|
12227
|
-
width: pad.radius * 2,
|
|
12228
|
-
height: pad.radius * 2
|
|
12229
|
-
};
|
|
12230
|
-
case "polygon":
|
|
12231
|
-
if (!pad.points || pad.points.length === 0) {
|
|
12232
|
-
return null;
|
|
12233
|
-
}
|
|
12234
|
-
const xs = pad.points.map((p) => p.x);
|
|
12235
|
-
const ys = pad.points.map((p) => p.y);
|
|
12236
|
-
const minX = Math.min(...xs);
|
|
12237
|
-
const maxX = Math.max(...xs);
|
|
12238
|
-
const minY = Math.min(...ys);
|
|
12239
|
-
const maxY = Math.max(...ys);
|
|
12240
|
-
return {
|
|
12241
|
-
width: maxX - minX,
|
|
12242
|
-
height: maxY - minY
|
|
12243
|
-
};
|
|
12244
|
-
default:
|
|
12245
|
-
return null;
|
|
12246
|
-
}
|
|
12247
|
-
}
|
|
12248
|
-
function getObstacleDimensionsFromPlatedHole(hole) {
|
|
12249
|
-
switch (hole.shape) {
|
|
12250
|
-
case "circular_hole_with_rect_pad":
|
|
12251
|
-
case "pill_hole_with_rect_pad":
|
|
12252
|
-
case "rotated_pill_hole_with_rect_pad":
|
|
12253
|
-
return {
|
|
12254
|
-
width: hole.rect_pad_width,
|
|
12255
|
-
height: hole.rect_pad_height
|
|
12256
|
-
};
|
|
12257
|
-
case "circle":
|
|
12258
|
-
return {
|
|
12259
|
-
width: hole.outer_diameter,
|
|
12260
|
-
height: hole.outer_diameter
|
|
12261
|
-
};
|
|
12262
|
-
case "oval":
|
|
12263
|
-
return {
|
|
12264
|
-
width: hole.outer_width,
|
|
12265
|
-
height: hole.outer_height
|
|
12266
|
-
};
|
|
12267
|
-
case "pill":
|
|
12268
|
-
return {
|
|
12269
|
-
width: hole.outer_width,
|
|
12270
|
-
height: hole.outer_height
|
|
12271
|
-
};
|
|
12272
|
-
case "hole_with_polygon_pad":
|
|
12273
|
-
if (!("pad_outline" in hole) || !hole.pad_outline || hole.pad_outline.length === 0) {
|
|
12274
|
-
return null;
|
|
12275
|
-
}
|
|
12276
|
-
const xs = hole.pad_outline.map((p) => p.x);
|
|
12277
|
-
const ys = hole.pad_outline.map((p) => p.y);
|
|
12278
|
-
const minX = Math.min(...xs);
|
|
12279
|
-
const maxX = Math.max(...xs);
|
|
12280
|
-
const minY = Math.min(...ys);
|
|
12281
|
-
const maxY = Math.max(...ys);
|
|
12282
|
-
return {
|
|
12283
|
-
width: maxX - minX,
|
|
12284
|
-
height: maxY - minY
|
|
12285
|
-
};
|
|
12286
|
-
default:
|
|
12287
|
-
return null;
|
|
12288
|
-
}
|
|
12289
|
-
}
|
|
12290
|
-
|
|
12291
12212
|
// lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/Group_doInitialPcbLayoutPack.ts
|
|
12292
12213
|
var DEFAULT_MIN_GAP = "1mm";
|
|
12293
12214
|
var debug6 = Debug8("Group_doInitialPcbLayoutPack");
|
|
@@ -12304,7 +12225,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
12304
12225
|
const gap = pcbPackGap ?? pcbGap ?? gapProp;
|
|
12305
12226
|
const gapMm = length4.parse(gap ?? DEFAULT_MIN_GAP);
|
|
12306
12227
|
const chipMarginsMap = {};
|
|
12307
|
-
const
|
|
12228
|
+
const staticPcbComponentIds = /* @__PURE__ */ new Set();
|
|
12308
12229
|
const collectMargins = (comp) => {
|
|
12309
12230
|
if (comp?.pcb_component_id && comp?._parsedProps) {
|
|
12310
12231
|
const props2 = comp._parsedProps;
|
|
@@ -12326,7 +12247,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
12326
12247
|
const childIsGroupOrNormalComponent = child;
|
|
12327
12248
|
if (childIsGroupOrNormalComponent._isNormalComponent && childIsGroupOrNormalComponent.isRelativelyPositioned?.()) {
|
|
12328
12249
|
if (childIsGroupOrNormalComponent.pcb_component_id) {
|
|
12329
|
-
|
|
12250
|
+
staticPcbComponentIds.add(
|
|
12330
12251
|
childIsGroupOrNormalComponent.pcb_component_id
|
|
12331
12252
|
);
|
|
12332
12253
|
}
|
|
@@ -12337,67 +12258,27 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
12337
12258
|
}
|
|
12338
12259
|
}
|
|
12339
12260
|
}
|
|
12340
|
-
const
|
|
12341
|
-
if (
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
(
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
const smtpads = db.toArray().filter(
|
|
12358
|
-
(el) => el.type === "pcb_smtpad" && el.pcb_component_id === pcb_component_id
|
|
12359
|
-
);
|
|
12360
|
-
for (const pad of smtpads) {
|
|
12361
|
-
const dimensions = getObstacleDimensionsFromSmtPad(pad);
|
|
12362
|
-
if (!dimensions || dimensions.width === 0 || dimensions.height === 0) {
|
|
12363
|
-
continue;
|
|
12364
|
-
}
|
|
12365
|
-
let centerX;
|
|
12366
|
-
let centerY;
|
|
12367
|
-
if (pad.shape === "polygon") {
|
|
12368
|
-
const xs = pad.points.map((p) => p.x);
|
|
12369
|
-
const ys = pad.points.map((p) => p.y);
|
|
12370
|
-
centerX = componentX + (Math.min(...xs) + Math.max(...xs)) / 2;
|
|
12371
|
-
centerY = componentY + (Math.min(...ys) + Math.max(...ys)) / 2;
|
|
12372
|
-
} else {
|
|
12373
|
-
centerX = componentX + pad.x;
|
|
12374
|
-
centerY = componentY + pad.y;
|
|
12375
|
-
}
|
|
12376
|
-
obstaclesFromRelativelyPositionedComponents.push({
|
|
12377
|
-
obstacleId: pad.pcb_smtpad_id,
|
|
12378
|
-
absoluteCenter: { x: centerX, y: centerY },
|
|
12379
|
-
width: dimensions.width,
|
|
12380
|
-
height: dimensions.height
|
|
12381
|
-
});
|
|
12382
|
-
}
|
|
12383
|
-
const platedHoles = db.toArray().filter(
|
|
12384
|
-
(el) => el.type === "pcb_plated_hole" && el.pcb_component_id === pcb_component_id
|
|
12385
|
-
);
|
|
12386
|
-
for (const hole of platedHoles) {
|
|
12387
|
-
const dimensions = getObstacleDimensionsFromPlatedHole(hole);
|
|
12388
|
-
if (!dimensions || dimensions.width === 0 || dimensions.height === 0) {
|
|
12389
|
-
continue;
|
|
12261
|
+
const isDescendantGroup2 = (db2, groupId, ancestorId) => {
|
|
12262
|
+
if (groupId === ancestorId) return true;
|
|
12263
|
+
const group2 = db2.source_group.get(groupId);
|
|
12264
|
+
if (!group2 || !group2.parent_source_group_id) return false;
|
|
12265
|
+
return isDescendantGroup2(db2, group2.parent_source_group_id, ancestorId);
|
|
12266
|
+
};
|
|
12267
|
+
if (excludedPcbGroupIds.size > 0) {
|
|
12268
|
+
for (const element of db.toArray()) {
|
|
12269
|
+
if (element.type !== "pcb_component") continue;
|
|
12270
|
+
const sourceComponent = db.source_component.get(
|
|
12271
|
+
element.source_component_id
|
|
12272
|
+
);
|
|
12273
|
+
if (!sourceComponent?.source_group_id) continue;
|
|
12274
|
+
for (const groupId of excludedPcbGroupIds) {
|
|
12275
|
+
if (isDescendantGroup2(db, sourceComponent.source_group_id, groupId)) {
|
|
12276
|
+
staticPcbComponentIds.add(element.pcb_component_id);
|
|
12277
|
+
}
|
|
12390
12278
|
}
|
|
12391
|
-
const centerX = componentX + hole.x;
|
|
12392
|
-
const centerY = componentY + hole.y;
|
|
12393
|
-
obstaclesFromRelativelyPositionedComponents.push({
|
|
12394
|
-
obstacleId: hole.pcb_plated_hole_id,
|
|
12395
|
-
absoluteCenter: { x: centerX, y: centerY },
|
|
12396
|
-
width: dimensions.width,
|
|
12397
|
-
height: dimensions.height
|
|
12398
|
-
});
|
|
12399
12279
|
}
|
|
12400
12280
|
}
|
|
12281
|
+
const filteredCircuitJson = db.toArray();
|
|
12401
12282
|
let bounds;
|
|
12402
12283
|
if (props.width !== void 0 && props.height !== void 0) {
|
|
12403
12284
|
const widthMm = length4.parse(props.width);
|
|
@@ -12413,15 +12294,15 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
12413
12294
|
...convertPackOutputToPackInput(
|
|
12414
12295
|
convertCircuitJsonToPackOutput(filteredCircuitJson, {
|
|
12415
12296
|
source_group_id: group.source_group_id,
|
|
12416
|
-
shouldAddInnerObstacles: true,
|
|
12417
|
-
chipMarginsMap
|
|
12297
|
+
// shouldAddInnerObstacles: true,
|
|
12298
|
+
chipMarginsMap,
|
|
12299
|
+
staticPcbComponentIds: Array.from(staticPcbComponentIds)
|
|
12418
12300
|
})
|
|
12419
12301
|
),
|
|
12420
12302
|
// @ts-expect-error we're missing some pack order strategies
|
|
12421
12303
|
orderStrategy: packOrderStrategy ?? "largest_to_smallest",
|
|
12422
12304
|
placementStrategy: packPlacementStrategy ?? "minimum_sum_squared_distance_to_network",
|
|
12423
12305
|
minGap: gapMm,
|
|
12424
|
-
obstacles: obstaclesFromRelativelyPositionedComponents,
|
|
12425
12306
|
bounds
|
|
12426
12307
|
};
|
|
12427
12308
|
const clusterMap = applyComponentConstraintClusters(group, packInput);
|
|
@@ -19181,7 +19062,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19181
19062
|
var package_default = {
|
|
19182
19063
|
name: "@tscircuit/core",
|
|
19183
19064
|
type: "module",
|
|
19184
|
-
version: "0.0.
|
|
19065
|
+
version: "0.0.908",
|
|
19185
19066
|
types: "dist/index.d.ts",
|
|
19186
19067
|
main: "dist/index.js",
|
|
19187
19068
|
module: "dist/index.js",
|
|
@@ -19286,7 +19167,7 @@ var package_default = {
|
|
|
19286
19167
|
dependencies: {
|
|
19287
19168
|
"@flatten-js/core": "^1.6.2",
|
|
19288
19169
|
"@lume/kiwi": "^0.4.3",
|
|
19289
|
-
"calculate-packing": "0.0.
|
|
19170
|
+
"calculate-packing": "0.0.66",
|
|
19290
19171
|
"css-select": "5.1.0",
|
|
19291
19172
|
"format-si-unit": "^0.0.3",
|
|
19292
19173
|
nanoid: "^5.0.7",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.909",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"@flatten-js/core": "^1.6.2",
|
|
108
108
|
"@lume/kiwi": "^0.4.3",
|
|
109
|
-
"calculate-packing": "0.0.
|
|
109
|
+
"calculate-packing": "0.0.66",
|
|
110
110
|
"css-select": "5.1.0",
|
|
111
111
|
"format-si-unit": "^0.0.3",
|
|
112
112
|
"nanoid": "^5.0.7",
|