@tscircuit/core 0.0.1285 → 0.0.1286
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 +239 -91
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13687,7 +13687,7 @@ import {
|
|
|
13687
13687
|
groupProps
|
|
13688
13688
|
} from "@tscircuit/props";
|
|
13689
13689
|
import {
|
|
13690
|
-
distance as
|
|
13690
|
+
distance as distance10
|
|
13691
13691
|
} from "circuit-json";
|
|
13692
13692
|
import Debug13 from "debug";
|
|
13693
13693
|
|
|
@@ -19313,6 +19313,178 @@ function addPortIdsToTracesAtJumperPads(segments, db) {
|
|
|
19313
19313
|
return result;
|
|
19314
19314
|
}
|
|
19315
19315
|
|
|
19316
|
+
// lib/components/primitive-components/Group/get-source-trace-id-for-routed-trace.ts
|
|
19317
|
+
import { distance as distance9, pointToSegmentDistance } from "@tscircuit/math-utils";
|
|
19318
|
+
import { ConnectivityMap as ConnectivityMap3 } from "circuit-json-to-connectivity-map";
|
|
19319
|
+
var POINT_EPSILON = 1e-6;
|
|
19320
|
+
function isPointOnWireSegment({
|
|
19321
|
+
point: point6,
|
|
19322
|
+
segmentStart,
|
|
19323
|
+
segmentEnd
|
|
19324
|
+
}) {
|
|
19325
|
+
if (point6.layer && (segmentStart.layer !== point6.layer || segmentEnd.layer !== point6.layer)) {
|
|
19326
|
+
return false;
|
|
19327
|
+
}
|
|
19328
|
+
return pointToSegmentDistance(point6, segmentStart, segmentEnd) <= POINT_EPSILON;
|
|
19329
|
+
}
|
|
19330
|
+
function isPointInSmtPad({
|
|
19331
|
+
point: point6,
|
|
19332
|
+
pad,
|
|
19333
|
+
traceWidth = 0
|
|
19334
|
+
}) {
|
|
19335
|
+
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
19336
|
+
return Math.abs(point6.x - pad.x) <= pad.width / 2 + traceWidth / 2 && Math.abs(point6.y - pad.y) <= pad.height / 2 + traceWidth / 2;
|
|
19337
|
+
}
|
|
19338
|
+
if (pad.shape === "circle") {
|
|
19339
|
+
return distance9(point6, pad) <= pad.radius + traceWidth / 2;
|
|
19340
|
+
}
|
|
19341
|
+
return false;
|
|
19342
|
+
}
|
|
19343
|
+
function isPointInPlatedHole({
|
|
19344
|
+
point: point6,
|
|
19345
|
+
hole,
|
|
19346
|
+
traceWidth = 0
|
|
19347
|
+
}) {
|
|
19348
|
+
return distance9(point6, hole) <= (hole.outer_diameter ?? hole.hole_diameter ?? 0) / 2 + traceWidth / 2;
|
|
19349
|
+
}
|
|
19350
|
+
function getEndpointSourcePortIdsFromGeometry(db, trace) {
|
|
19351
|
+
const sourcePortIds = /* @__PURE__ */ new Set();
|
|
19352
|
+
const route = trace.route;
|
|
19353
|
+
const endpoints = [route[0], route[route.length - 1]].filter(
|
|
19354
|
+
(point6) => Boolean(point6) && point6.route_type === "wire" && point6.x !== void 0 && point6.y !== void 0
|
|
19355
|
+
);
|
|
19356
|
+
for (const endpoint of endpoints) {
|
|
19357
|
+
for (const pcbPort of db.pcb_port.list()) {
|
|
19358
|
+
if (!pcbPort.source_port_id) continue;
|
|
19359
|
+
if (distance9(endpoint, pcbPort) <= 0.01) {
|
|
19360
|
+
sourcePortIds.add(pcbPort.source_port_id);
|
|
19361
|
+
}
|
|
19362
|
+
}
|
|
19363
|
+
for (const smtpad of db.pcb_smtpad.list()) {
|
|
19364
|
+
if (!smtpad.pcb_port_id) continue;
|
|
19365
|
+
if (!isPointInSmtPad({
|
|
19366
|
+
point: endpoint,
|
|
19367
|
+
pad: smtpad,
|
|
19368
|
+
traceWidth: endpoint.width
|
|
19369
|
+
}))
|
|
19370
|
+
continue;
|
|
19371
|
+
const sourcePortId = db.pcb_port.get(smtpad.pcb_port_id)?.source_port_id;
|
|
19372
|
+
if (sourcePortId) sourcePortIds.add(sourcePortId);
|
|
19373
|
+
}
|
|
19374
|
+
for (const hole of db.pcb_plated_hole.list()) {
|
|
19375
|
+
if (!hole.pcb_port_id) continue;
|
|
19376
|
+
if (!isPointInPlatedHole({
|
|
19377
|
+
point: endpoint,
|
|
19378
|
+
hole,
|
|
19379
|
+
traceWidth: endpoint.width
|
|
19380
|
+
}))
|
|
19381
|
+
continue;
|
|
19382
|
+
const sourcePortId = db.pcb_port.get(hole.pcb_port_id)?.source_port_id;
|
|
19383
|
+
if (sourcePortId) sourcePortIds.add(sourcePortId);
|
|
19384
|
+
}
|
|
19385
|
+
}
|
|
19386
|
+
return [...sourcePortIds];
|
|
19387
|
+
}
|
|
19388
|
+
function getWireRouteEndpoints(trace) {
|
|
19389
|
+
const route = trace.route.filter(
|
|
19390
|
+
(point6) => point6.route_type === "wire" && point6.x !== void 0 && point6.y !== void 0
|
|
19391
|
+
);
|
|
19392
|
+
return [route[0], route[route.length - 1]].filter(
|
|
19393
|
+
(point6) => Boolean(point6)
|
|
19394
|
+
);
|
|
19395
|
+
}
|
|
19396
|
+
function getSourceIdsFromConnectedPcbTraces(db, trace) {
|
|
19397
|
+
const sourceIds = /* @__PURE__ */ new Set();
|
|
19398
|
+
const endpoints = getWireRouteEndpoints(trace);
|
|
19399
|
+
if (endpoints.length === 0) return [];
|
|
19400
|
+
for (const existingTrace of db.pcb_trace.list()) {
|
|
19401
|
+
if (!existingTrace.source_trace_id) continue;
|
|
19402
|
+
if (existingTrace.pcb_trace_id === trace.pcb_trace_id) continue;
|
|
19403
|
+
if (!db.source_trace.get(existingTrace.source_trace_id) && !db.source_net.get(existingTrace.source_trace_id)) {
|
|
19404
|
+
continue;
|
|
19405
|
+
}
|
|
19406
|
+
const existingRoute = existingTrace.route.filter(
|
|
19407
|
+
(point6) => point6.route_type === "wire"
|
|
19408
|
+
);
|
|
19409
|
+
for (let i = 0; i < existingRoute.length - 1; i++) {
|
|
19410
|
+
const segmentStart = existingRoute[i];
|
|
19411
|
+
const segmentEnd = existingRoute[i + 1];
|
|
19412
|
+
if (!segmentStart || !segmentEnd) continue;
|
|
19413
|
+
for (const endpoint of endpoints) {
|
|
19414
|
+
if (isPointOnWireSegment({
|
|
19415
|
+
point: endpoint,
|
|
19416
|
+
segmentStart,
|
|
19417
|
+
segmentEnd
|
|
19418
|
+
})) {
|
|
19419
|
+
sourceIds.add(existingTrace.source_trace_id);
|
|
19420
|
+
}
|
|
19421
|
+
}
|
|
19422
|
+
}
|
|
19423
|
+
}
|
|
19424
|
+
return [...sourceIds];
|
|
19425
|
+
}
|
|
19426
|
+
function getSourcePortIdsFromRoutedTrace(db, trace) {
|
|
19427
|
+
const sourcePortIds = /* @__PURE__ */ new Set();
|
|
19428
|
+
for (const point6 of trace.route) {
|
|
19429
|
+
for (const pcbPortId of [point6.start_pcb_port_id, point6.end_pcb_port_id]) {
|
|
19430
|
+
if (!pcbPortId) continue;
|
|
19431
|
+
const sourcePortId = db.pcb_port.get(pcbPortId)?.source_port_id;
|
|
19432
|
+
if (sourcePortId) sourcePortIds.add(sourcePortId);
|
|
19433
|
+
}
|
|
19434
|
+
}
|
|
19435
|
+
if (sourcePortIds.size > 0) return [...sourcePortIds];
|
|
19436
|
+
return getEndpointSourcePortIdsFromGeometry(db, trace);
|
|
19437
|
+
}
|
|
19438
|
+
function buildSourceConnectivityMap(sourceTraces) {
|
|
19439
|
+
const connMap = new ConnectivityMap3({});
|
|
19440
|
+
connMap.addConnections(
|
|
19441
|
+
sourceTraces.map((trace) => [
|
|
19442
|
+
trace.source_trace_id,
|
|
19443
|
+
...trace.connected_source_port_ids,
|
|
19444
|
+
...trace.connected_source_net_ids
|
|
19445
|
+
])
|
|
19446
|
+
);
|
|
19447
|
+
return connMap;
|
|
19448
|
+
}
|
|
19449
|
+
function getSourceTraceIdForRoutedTrace({
|
|
19450
|
+
db,
|
|
19451
|
+
trace,
|
|
19452
|
+
subcircuit_id
|
|
19453
|
+
}) {
|
|
19454
|
+
if (trace.source_trace_id && (db.source_trace.get(trace.source_trace_id) ?? db.source_net.get(trace.source_trace_id))) {
|
|
19455
|
+
return trace.source_trace_id;
|
|
19456
|
+
}
|
|
19457
|
+
const sourcePortIds = getSourcePortIdsFromRoutedTrace(db, trace);
|
|
19458
|
+
if (sourcePortIds.length === 0) {
|
|
19459
|
+
return getSourceIdsFromConnectedPcbTraces(db, trace)[0];
|
|
19460
|
+
}
|
|
19461
|
+
const sourceTraces = db.source_trace.list();
|
|
19462
|
+
const connMap = buildSourceConnectivityMap(sourceTraces);
|
|
19463
|
+
const endpointNetIds = sourcePortIds.map((sourcePortId) => connMap.getNetConnectedToId(sourcePortId)).filter((netId) => Boolean(netId));
|
|
19464
|
+
const exactSourceTrace = sourcePortIds.length >= 2 ? sourceTraces.find(
|
|
19465
|
+
(sourceTrace) => sourcePortIds.every(
|
|
19466
|
+
(sourcePortId) => sourceTrace.connected_source_port_ids.includes(sourcePortId)
|
|
19467
|
+
)
|
|
19468
|
+
) : void 0;
|
|
19469
|
+
if (exactSourceTrace) return exactSourceTrace.source_trace_id;
|
|
19470
|
+
const sourceTracesInEndpointNets = sourceTraces.filter((sourceTrace) => {
|
|
19471
|
+
const sourceTraceNetId = connMap.getNetConnectedToId(
|
|
19472
|
+
sourceTrace.source_trace_id
|
|
19473
|
+
);
|
|
19474
|
+
return endpointNetIds.some((netId) => netId === sourceTraceNetId);
|
|
19475
|
+
});
|
|
19476
|
+
const connectedToEndpoint = sourceTracesInEndpointNets.filter(
|
|
19477
|
+
(sourceTrace) => sourceTrace.connected_source_port_ids.some(
|
|
19478
|
+
(sourcePortId) => sourcePortIds.includes(sourcePortId)
|
|
19479
|
+
)
|
|
19480
|
+
);
|
|
19481
|
+
const candidates = connectedToEndpoint.length > 0 ? connectedToEndpoint : sourceTracesInEndpointNets;
|
|
19482
|
+
if (candidates.length === 0) return void 0;
|
|
19483
|
+
return (candidates.find(
|
|
19484
|
+
(sourceTrace) => sourceTrace.subcircuit_id === subcircuit_id
|
|
19485
|
+
) ?? candidates[0])?.source_trace_id;
|
|
19486
|
+
}
|
|
19487
|
+
|
|
19316
19488
|
// lib/components/primitive-components/Group/insert-autoplaced-jumpers.ts
|
|
19317
19489
|
function groupPadsByInternalConnection(pads, orientation) {
|
|
19318
19490
|
const tolerance = 0.01;
|
|
@@ -19810,8 +19982,8 @@ var Group5 = class extends NormalComponent3 {
|
|
|
19810
19982
|
const groupProps2 = props;
|
|
19811
19983
|
const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
|
|
19812
19984
|
const numericOutline = hasOutline ? groupProps2.outline.map((point6) => ({
|
|
19813
|
-
x:
|
|
19814
|
-
y:
|
|
19985
|
+
x: distance10.parse(point6.x),
|
|
19986
|
+
y: distance10.parse(point6.y)
|
|
19815
19987
|
})) : void 0;
|
|
19816
19988
|
const ctx = this.props;
|
|
19817
19989
|
const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
|
|
@@ -19849,8 +20021,8 @@ var Group5 = class extends NormalComponent3 {
|
|
|
19849
20021
|
const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
|
|
19850
20022
|
if (hasOutline) {
|
|
19851
20023
|
const numericOutline = props.outline.map((point6) => ({
|
|
19852
|
-
x:
|
|
19853
|
-
y:
|
|
20024
|
+
x: distance10.parse(point6.x),
|
|
20025
|
+
y: distance10.parse(point6.y)
|
|
19854
20026
|
}));
|
|
19855
20027
|
const outlineBounds = getBoundsFromPoints4(numericOutline);
|
|
19856
20028
|
if (!outlineBounds) return;
|
|
@@ -20509,41 +20681,8 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20509
20681
|
outputPcbTraces: output_pcb_traces,
|
|
20510
20682
|
pcbTraceIdsToReplace: pcb_trace_ids_to_be_replaced
|
|
20511
20683
|
});
|
|
20512
|
-
const sourceTraceIdByConnectionName = /* @__PURE__ */ new Map();
|
|
20513
|
-
for (const connection of input_simple_route_json?.connections ?? []) {
|
|
20514
|
-
if (connection.source_trace_id) {
|
|
20515
|
-
sourceTraceIdByConnectionName.set(
|
|
20516
|
-
connection.name,
|
|
20517
|
-
connection.source_trace_id
|
|
20518
|
-
);
|
|
20519
|
-
}
|
|
20520
|
-
}
|
|
20521
20684
|
for (const pcb_trace of output_pcb_traces) {
|
|
20522
20685
|
if (pcb_trace.type !== "pcb_trace") continue;
|
|
20523
|
-
const inputConnectionSourceTraceId = sourceTraceIdByConnectionName.get(
|
|
20524
|
-
pcb_trace.connection_name
|
|
20525
|
-
);
|
|
20526
|
-
const possibleSourceTraceIds = [
|
|
20527
|
-
...getSourceTraceIdsFromRerouteName(pcb_trace.source_trace_id),
|
|
20528
|
-
...inputConnectionSourceTraceId ? [inputConnectionSourceTraceId] : [],
|
|
20529
|
-
...getSourceTraceIdsFromRerouteName(pcb_trace.connection_name),
|
|
20530
|
-
...getSourceTraceIdsFromRerouteName(
|
|
20531
|
-
pcb_trace.rootConnectionName
|
|
20532
|
-
)
|
|
20533
|
-
];
|
|
20534
|
-
const validSourceTraceIds = Array.from(
|
|
20535
|
-
new Set(possibleSourceTraceIds)
|
|
20536
|
-
).filter(
|
|
20537
|
-
(possibleSourceTraceId) => Boolean(
|
|
20538
|
-
db.source_trace.get(possibleSourceTraceId) ?? db.source_net.get(possibleSourceTraceId)
|
|
20539
|
-
)
|
|
20540
|
-
);
|
|
20541
|
-
const sourceTraceId = validSourceTraceIds.length === 1 ? validSourceTraceIds[0] : void 0;
|
|
20542
|
-
if (sourceTraceId) {
|
|
20543
|
-
pcb_trace.source_trace_id = sourceTraceId;
|
|
20544
|
-
} else {
|
|
20545
|
-
delete pcb_trace.source_trace_id;
|
|
20546
|
-
}
|
|
20547
20686
|
pcb_trace.subcircuit_id ??= this.subcircuit_id;
|
|
20548
20687
|
const cjRoute = pcb_trace.route.map((point6) => {
|
|
20549
20688
|
if (point6.route_type !== "through_obstacle") return point6;
|
|
@@ -20563,8 +20702,17 @@ var Group5 = class extends NormalComponent3 {
|
|
|
20563
20702
|
const processedSegments = addPortIdsToTracesAtJumperPads(segments, db);
|
|
20564
20703
|
for (const segment2 of processedSegments) {
|
|
20565
20704
|
if (segment2.length > 0) {
|
|
20705
|
+
const sourceTraceId = getSourceTraceIdForRoutedTrace({
|
|
20706
|
+
db,
|
|
20707
|
+
trace: {
|
|
20708
|
+
...pcb_trace,
|
|
20709
|
+
route: segment2
|
|
20710
|
+
},
|
|
20711
|
+
subcircuit_id: this.subcircuit_id
|
|
20712
|
+
});
|
|
20566
20713
|
db.pcb_trace.insert({
|
|
20567
20714
|
...pcb_trace,
|
|
20715
|
+
source_trace_id: sourceTraceId,
|
|
20568
20716
|
route: segment2
|
|
20569
20717
|
});
|
|
20570
20718
|
}
|
|
@@ -21896,7 +22044,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
21896
22044
|
var package_default = {
|
|
21897
22045
|
name: "@tscircuit/core",
|
|
21898
22046
|
type: "module",
|
|
21899
|
-
version: "0.0.
|
|
22047
|
+
version: "0.0.1285",
|
|
21900
22048
|
types: "dist/index.d.ts",
|
|
21901
22049
|
main: "dist/index.js",
|
|
21902
22050
|
module: "dist/index.js",
|
|
@@ -23071,11 +23219,11 @@ var MountedBoard = class extends Subcircuit {
|
|
|
23071
23219
|
|
|
23072
23220
|
// lib/components/normal-components/Panel.ts
|
|
23073
23221
|
import { panelProps } from "@tscircuit/props";
|
|
23074
|
-
import { distance as
|
|
23222
|
+
import { distance as distance14 } from "circuit-json";
|
|
23075
23223
|
|
|
23076
23224
|
// lib/components/normal-components/Subpanel.ts
|
|
23077
23225
|
import { subpanelProps } from "@tscircuit/props";
|
|
23078
|
-
import { distance as
|
|
23226
|
+
import { distance as distance13 } from "circuit-json";
|
|
23079
23227
|
import { compose as compose7, identity as identity6, translate as translate7 } from "transformation-matrix";
|
|
23080
23228
|
|
|
23081
23229
|
// lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
|
|
@@ -23288,15 +23436,15 @@ function generatePanelTabsAndMouseBites(boards, options) {
|
|
|
23288
23436
|
}
|
|
23289
23437
|
|
|
23290
23438
|
// lib/utils/panels/pack-into-grid.ts
|
|
23291
|
-
import { distance as
|
|
23439
|
+
import { distance as distance12 } from "circuit-json";
|
|
23292
23440
|
|
|
23293
23441
|
// lib/utils/panels/get-board-dimensions-from-props.ts
|
|
23294
23442
|
import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
|
|
23295
|
-
import { distance as
|
|
23443
|
+
import { distance as distance11 } from "circuit-json";
|
|
23296
23444
|
var getBoardDimensionsFromProps = (board) => {
|
|
23297
23445
|
const props = board._parsedProps;
|
|
23298
|
-
let width = props.width != null ?
|
|
23299
|
-
let height = props.height != null ?
|
|
23446
|
+
let width = props.width != null ? distance11.parse(props.width) : void 0;
|
|
23447
|
+
let height = props.height != null ? distance11.parse(props.height) : void 0;
|
|
23300
23448
|
if ((width === void 0 || height === void 0) && props.outline?.length) {
|
|
23301
23449
|
const outlineBounds = getBoundsFromPoints6(props.outline);
|
|
23302
23450
|
if (outlineBounds) {
|
|
@@ -23340,8 +23488,8 @@ function packIntoGrid({
|
|
|
23340
23488
|
}
|
|
23341
23489
|
let cols;
|
|
23342
23490
|
let rows;
|
|
23343
|
-
const minCellWidth = cellWidth ?
|
|
23344
|
-
const minCellHeight = cellHeight ?
|
|
23491
|
+
const minCellWidth = cellWidth ? distance12.parse(cellWidth) : 0;
|
|
23492
|
+
const minCellHeight = cellHeight ? distance12.parse(cellHeight) : 0;
|
|
23345
23493
|
if (col !== void 0) {
|
|
23346
23494
|
cols = col;
|
|
23347
23495
|
rows = row ?? Math.ceil(itemsWithDims.length / cols);
|
|
@@ -23440,8 +23588,8 @@ function getItemDimensions(item, db) {
|
|
|
23440
23588
|
const props = subpanel._parsedProps;
|
|
23441
23589
|
if (props.width !== void 0 && props.height !== void 0) {
|
|
23442
23590
|
return {
|
|
23443
|
-
width:
|
|
23444
|
-
height:
|
|
23591
|
+
width: distance12.parse(props.width),
|
|
23592
|
+
height: distance12.parse(props.height)
|
|
23445
23593
|
};
|
|
23446
23594
|
}
|
|
23447
23595
|
const directBoards = subpanel._getDirectBoardChildren();
|
|
@@ -23468,7 +23616,7 @@ function getItemDimensions(item, db) {
|
|
|
23468
23616
|
return getBoardDimensionsFromProps(directBoards[0]);
|
|
23469
23617
|
}
|
|
23470
23618
|
if (subpanel._cachedGridWidth > 0 && subpanel._cachedGridHeight > 0) {
|
|
23471
|
-
const edgePadding =
|
|
23619
|
+
const edgePadding = distance12.parse(props.edgePadding ?? 5);
|
|
23472
23620
|
return {
|
|
23473
23621
|
width: subpanel._cachedGridWidth + edgePadding * 2,
|
|
23474
23622
|
height: subpanel._cachedGridHeight + edgePadding * 2
|
|
@@ -23626,17 +23774,17 @@ var Subpanel = class _Subpanel extends Group5 {
|
|
|
23626
23774
|
edgePaddingTop: edgePaddingTopProp,
|
|
23627
23775
|
edgePaddingBottom: edgePaddingBottomProp
|
|
23628
23776
|
} = this._parsedProps;
|
|
23629
|
-
const edgePadding =
|
|
23630
|
-
const edgePaddingLeft =
|
|
23631
|
-
const edgePaddingRight =
|
|
23777
|
+
const edgePadding = distance13.parse(edgePaddingProp ?? 5);
|
|
23778
|
+
const edgePaddingLeft = distance13.parse(edgePaddingLeftProp ?? edgePadding);
|
|
23779
|
+
const edgePaddingRight = distance13.parse(
|
|
23632
23780
|
edgePaddingRightProp ?? edgePadding
|
|
23633
23781
|
);
|
|
23634
|
-
const edgePaddingTop =
|
|
23635
|
-
const edgePaddingBottom =
|
|
23782
|
+
const edgePaddingTop = distance13.parse(edgePaddingTopProp ?? edgePadding);
|
|
23783
|
+
const edgePaddingBottom = distance13.parse(
|
|
23636
23784
|
edgePaddingBottomProp ?? edgePadding
|
|
23637
23785
|
);
|
|
23638
|
-
const panelWidth =
|
|
23639
|
-
const panelHeight =
|
|
23786
|
+
const panelWidth = distance13.parse(this._parsedProps.width);
|
|
23787
|
+
const panelHeight = distance13.parse(this._parsedProps.height);
|
|
23640
23788
|
availablePanelWidth = panelWidth - edgePaddingLeft - edgePaddingRight;
|
|
23641
23789
|
availablePanelHeight = panelHeight - edgePaddingTop - edgePaddingBottom;
|
|
23642
23790
|
}
|
|
@@ -23711,8 +23859,8 @@ var Subpanel = class _Subpanel extends Group5 {
|
|
|
23711
23859
|
if (!this.pcb_group_id) return;
|
|
23712
23860
|
if (hasExplicitWidth && hasExplicitHeight) {
|
|
23713
23861
|
db.pcb_group.update(this.pcb_group_id, {
|
|
23714
|
-
width:
|
|
23715
|
-
height:
|
|
23862
|
+
width: distance13.parse(this._parsedProps.width),
|
|
23863
|
+
height: distance13.parse(this._parsedProps.height)
|
|
23716
23864
|
});
|
|
23717
23865
|
} else if (gridWidth > 0 || gridHeight > 0) {
|
|
23718
23866
|
const {
|
|
@@ -23722,18 +23870,18 @@ var Subpanel = class _Subpanel extends Group5 {
|
|
|
23722
23870
|
edgePaddingTop: edgePaddingTopProp,
|
|
23723
23871
|
edgePaddingBottom: edgePaddingBottomProp
|
|
23724
23872
|
} = this._parsedProps;
|
|
23725
|
-
const edgePadding =
|
|
23726
|
-
const edgePaddingLeft =
|
|
23727
|
-
const edgePaddingRight =
|
|
23873
|
+
const edgePadding = distance13.parse(edgePaddingProp ?? 5);
|
|
23874
|
+
const edgePaddingLeft = distance13.parse(edgePaddingLeftProp ?? edgePadding);
|
|
23875
|
+
const edgePaddingRight = distance13.parse(
|
|
23728
23876
|
edgePaddingRightProp ?? edgePadding
|
|
23729
23877
|
);
|
|
23730
|
-
const edgePaddingTop =
|
|
23731
|
-
const edgePaddingBottom =
|
|
23878
|
+
const edgePaddingTop = distance13.parse(edgePaddingTopProp ?? edgePadding);
|
|
23879
|
+
const edgePaddingBottom = distance13.parse(
|
|
23732
23880
|
edgePaddingBottomProp ?? edgePadding
|
|
23733
23881
|
);
|
|
23734
23882
|
db.pcb_group.update(this.pcb_group_id, {
|
|
23735
|
-
width: hasExplicitWidth ?
|
|
23736
|
-
height: hasExplicitHeight ?
|
|
23883
|
+
width: hasExplicitWidth ? distance13.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
|
|
23884
|
+
height: hasExplicitHeight ? distance13.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
|
|
23737
23885
|
});
|
|
23738
23886
|
}
|
|
23739
23887
|
}
|
|
@@ -23807,8 +23955,8 @@ var Panel = class extends Subpanel {
|
|
|
23807
23955
|
const { db } = this.root;
|
|
23808
23956
|
const props = this._parsedProps;
|
|
23809
23957
|
const inserted = db.pcb_panel.insert({
|
|
23810
|
-
width: props.width !== void 0 ?
|
|
23811
|
-
height: props.height !== void 0 ?
|
|
23958
|
+
width: props.width !== void 0 ? distance14.parse(props.width) : 0,
|
|
23959
|
+
height: props.height !== void 0 ? distance14.parse(props.height) : 0,
|
|
23812
23960
|
thickness: 1.6,
|
|
23813
23961
|
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
23814
23962
|
covered_with_solder_mask: !(props.noSolderMask ?? false)
|
|
@@ -23827,8 +23975,8 @@ var Panel = class extends Subpanel {
|
|
|
23827
23975
|
if (!this.pcb_panel_id) return;
|
|
23828
23976
|
if (hasExplicitWidth && hasExplicitHeight) {
|
|
23829
23977
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
23830
|
-
width:
|
|
23831
|
-
height:
|
|
23978
|
+
width: distance14.parse(this._parsedProps.width),
|
|
23979
|
+
height: distance14.parse(this._parsedProps.height)
|
|
23832
23980
|
});
|
|
23833
23981
|
} else if (gridWidth > 0 || gridHeight > 0) {
|
|
23834
23982
|
const {
|
|
@@ -23838,18 +23986,18 @@ var Panel = class extends Subpanel {
|
|
|
23838
23986
|
edgePaddingTop: edgePaddingTopProp,
|
|
23839
23987
|
edgePaddingBottom: edgePaddingBottomProp
|
|
23840
23988
|
} = this._parsedProps;
|
|
23841
|
-
const edgePadding =
|
|
23842
|
-
const edgePaddingLeft =
|
|
23843
|
-
const edgePaddingRight =
|
|
23989
|
+
const edgePadding = distance14.parse(edgePaddingProp ?? 5);
|
|
23990
|
+
const edgePaddingLeft = distance14.parse(edgePaddingLeftProp ?? edgePadding);
|
|
23991
|
+
const edgePaddingRight = distance14.parse(
|
|
23844
23992
|
edgePaddingRightProp ?? edgePadding
|
|
23845
23993
|
);
|
|
23846
|
-
const edgePaddingTop =
|
|
23847
|
-
const edgePaddingBottom =
|
|
23994
|
+
const edgePaddingTop = distance14.parse(edgePaddingTopProp ?? edgePadding);
|
|
23995
|
+
const edgePaddingBottom = distance14.parse(
|
|
23848
23996
|
edgePaddingBottomProp ?? edgePadding
|
|
23849
23997
|
);
|
|
23850
23998
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
23851
|
-
width: hasExplicitWidth ?
|
|
23852
|
-
height: hasExplicitHeight ?
|
|
23999
|
+
width: hasExplicitWidth ? distance14.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
|
|
24000
|
+
height: hasExplicitHeight ? distance14.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
|
|
23853
24001
|
});
|
|
23854
24002
|
}
|
|
23855
24003
|
}
|
|
@@ -23860,8 +24008,8 @@ var Panel = class extends Subpanel {
|
|
|
23860
24008
|
const props = this._parsedProps;
|
|
23861
24009
|
const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
|
|
23862
24010
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
23863
|
-
width: props.width !== void 0 ?
|
|
23864
|
-
height: props.height !== void 0 ?
|
|
24011
|
+
width: props.width !== void 0 ? distance14.parse(props.width) : currentPanel?.width,
|
|
24012
|
+
height: props.height !== void 0 ? distance14.parse(props.height) : currentPanel?.height,
|
|
23865
24013
|
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
23866
24014
|
covered_with_solder_mask: !(props.noSolderMask ?? false)
|
|
23867
24015
|
});
|
|
@@ -24901,7 +25049,7 @@ import { BaseSolver } from "@tscircuit/solver-utils";
|
|
|
24901
25049
|
|
|
24902
25050
|
// node_modules/@tscircuit/breakout-point-solver/lib/boundary/get-breakout-boundary-intersection.ts
|
|
24903
25051
|
import {
|
|
24904
|
-
distance as
|
|
25052
|
+
distance as distance15,
|
|
24905
25053
|
getSegmentIntersection
|
|
24906
25054
|
} from "@tscircuit/math-utils";
|
|
24907
25055
|
var getBreakoutBoundaryIntersection = ({
|
|
@@ -24929,12 +25077,12 @@ var getBreakoutBoundaryIntersection = ({
|
|
|
24929
25077
|
]
|
|
24930
25078
|
];
|
|
24931
25079
|
const candidates = boundarySegments.map(([start, end]) => getSegmentIntersection(from, to, start, end)).filter((point6) => point6 !== null);
|
|
24932
|
-
candidates.sort((a, b) =>
|
|
25080
|
+
candidates.sort((a, b) => distance15(from, a) - distance15(from, b));
|
|
24933
25081
|
return candidates[0] ?? null;
|
|
24934
25082
|
};
|
|
24935
25083
|
|
|
24936
25084
|
// node_modules/@tscircuit/breakout-point-solver/lib/boundary/get-available-breakout-boundary-point.ts
|
|
24937
|
-
import { distance as
|
|
25085
|
+
import { distance as distance16 } from "@tscircuit/math-utils";
|
|
24938
25086
|
|
|
24939
25087
|
// node_modules/@tscircuit/breakout-point-solver/lib/pad/breakout-pad-collisions.ts
|
|
24940
25088
|
import {
|
|
@@ -25036,7 +25184,7 @@ var isInsideRequiredSpacing = ({
|
|
|
25036
25184
|
candidate,
|
|
25037
25185
|
usedPoint,
|
|
25038
25186
|
boundaryPointSpacing
|
|
25039
|
-
}) =>
|
|
25187
|
+
}) => distance16(usedPoint, candidate) < boundaryPointSpacing - BOUNDARY_POINT_DISTANCE_TOLERANCE;
|
|
25040
25188
|
var getBoundsEdge = (point6, bounds) => {
|
|
25041
25189
|
if (Math.abs(point6.x - bounds.minX) < BOUNDARY_POINT_DISTANCE_TOLERANCE)
|
|
25042
25190
|
return "left";
|
|
@@ -25227,7 +25375,7 @@ var getAvailableBreakoutBoundaryPoint = ({
|
|
|
25227
25375
|
step
|
|
25228
25376
|
});
|
|
25229
25377
|
edgeCandidates.sort(
|
|
25230
|
-
(a, b) =>
|
|
25378
|
+
(a, b) => distance16(a, idealPoint) - distance16(b, idealPoint)
|
|
25231
25379
|
);
|
|
25232
25380
|
for (const candidate of edgeCandidates) {
|
|
25233
25381
|
if (isCandidateAvailable({
|
|
@@ -25243,7 +25391,7 @@ var getAvailableBreakoutBoundaryPoint = ({
|
|
|
25243
25391
|
}
|
|
25244
25392
|
}
|
|
25245
25393
|
const candidates = getAllBoundsCandidates({ bounds, step });
|
|
25246
|
-
candidates.sort((a, b) =>
|
|
25394
|
+
candidates.sort((a, b) => distance16(a, idealPoint) - distance16(b, idealPoint));
|
|
25247
25395
|
for (const candidate of candidates) {
|
|
25248
25396
|
if (isCandidateAvailable({
|
|
25249
25397
|
candidate,
|
|
@@ -25293,7 +25441,7 @@ var getAvailableBreakoutBoundaryPointForOutsidePorts = ({
|
|
|
25293
25441
|
if (!edge) continue;
|
|
25294
25442
|
const edgeCandidates = getBoundsEdgeCandidates({ edge, bounds, step });
|
|
25295
25443
|
edgeCandidates.sort(
|
|
25296
|
-
(a, b) =>
|
|
25444
|
+
(a, b) => distance16(a, idealPoint) - distance16(b, idealPoint)
|
|
25297
25445
|
);
|
|
25298
25446
|
for (const candidate of edgeCandidates) {
|
|
25299
25447
|
if (isCandidateAvailableForOutsidePorts({
|
|
@@ -25313,7 +25461,7 @@ var getAvailableBreakoutBoundaryPointForOutsidePorts = ({
|
|
|
25313
25461
|
}
|
|
25314
25462
|
for (const idealPoint of idealPoints) {
|
|
25315
25463
|
const candidates = getAllBoundsCandidates({ bounds, step });
|
|
25316
|
-
candidates.sort((a, b) =>
|
|
25464
|
+
candidates.sort((a, b) => distance16(a, idealPoint) - distance16(b, idealPoint));
|
|
25317
25465
|
for (const candidate of candidates) {
|
|
25318
25466
|
if (isCandidateAvailableForOutsidePorts({
|
|
25319
25467
|
candidate,
|
|
@@ -26142,7 +26290,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
26142
26290
|
|
|
26143
26291
|
// lib/components/primitive-components/Fiducial.ts
|
|
26144
26292
|
import "zod";
|
|
26145
|
-
import { distance as
|
|
26293
|
+
import { distance as distance17 } from "circuit-json";
|
|
26146
26294
|
import { fiducialProps } from "@tscircuit/props";
|
|
26147
26295
|
var Fiducial = class extends PrimitiveComponent2 {
|
|
26148
26296
|
pcb_smtpad_id = null;
|
|
@@ -26167,15 +26315,15 @@ var Fiducial = class extends PrimitiveComponent2 {
|
|
|
26167
26315
|
shape: "circle",
|
|
26168
26316
|
x: position.x,
|
|
26169
26317
|
y: position.y,
|
|
26170
|
-
radius:
|
|
26171
|
-
soldermask_margin: props.soldermaskPullback ?
|
|
26318
|
+
radius: distance17.parse(props.padDiameter) / 2,
|
|
26319
|
+
soldermask_margin: props.soldermaskPullback ? distance17.parse(props.soldermaskPullback) : distance17.parse(props.padDiameter) / 2,
|
|
26172
26320
|
is_covered_with_solder_mask: true
|
|
26173
26321
|
});
|
|
26174
26322
|
this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
|
|
26175
26323
|
}
|
|
26176
26324
|
getPcbSize() {
|
|
26177
26325
|
const { _parsedProps: props } = this;
|
|
26178
|
-
const d =
|
|
26326
|
+
const d = distance17.parse(props.padDiameter);
|
|
26179
26327
|
return { width: d, height: d };
|
|
26180
26328
|
}
|
|
26181
26329
|
_setPositionFromLayout(newCenter) {
|