@tscircuit/checks 0.0.176 → 0.0.178
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 +65 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3383,6 +3383,19 @@ var getPcbTraceLength = (pcbTrace) => {
|
|
|
3383
3383
|
}
|
|
3384
3384
|
return traceLength;
|
|
3385
3385
|
};
|
|
3386
|
+
var getReferencedPcbPortIds = (pcbTrace) => {
|
|
3387
|
+
const pcbPortIds = /* @__PURE__ */ new Set();
|
|
3388
|
+
for (const routePoint of pcbTrace.route) {
|
|
3389
|
+
if (routePoint.route_type !== "wire") continue;
|
|
3390
|
+
if (routePoint.start_pcb_port_id) {
|
|
3391
|
+
pcbPortIds.add(routePoint.start_pcb_port_id);
|
|
3392
|
+
}
|
|
3393
|
+
if (routePoint.end_pcb_port_id) {
|
|
3394
|
+
pcbPortIds.add(routePoint.end_pcb_port_id);
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
return pcbPortIds;
|
|
3398
|
+
};
|
|
3386
3399
|
var checkPcbTraceLengths = (circuitJson) => {
|
|
3387
3400
|
const sourceTraces = circuitJson.filter(
|
|
3388
3401
|
(element) => element.type === "source_trace"
|
|
@@ -3390,12 +3403,53 @@ var checkPcbTraceLengths = (circuitJson) => {
|
|
|
3390
3403
|
const pcbTraces = circuitJson.filter(
|
|
3391
3404
|
(element) => element.type === "pcb_trace"
|
|
3392
3405
|
);
|
|
3406
|
+
const pcbPorts = circuitJson.filter(
|
|
3407
|
+
(element) => element.type === "pcb_port"
|
|
3408
|
+
);
|
|
3393
3409
|
const sourceTracesById = new Map(
|
|
3394
3410
|
sourceTraces.map((sourceTrace) => [
|
|
3395
3411
|
sourceTrace.source_trace_id,
|
|
3396
3412
|
sourceTrace
|
|
3397
3413
|
])
|
|
3398
3414
|
);
|
|
3415
|
+
const pcbPortIdsBySourcePortId = /* @__PURE__ */ new Map();
|
|
3416
|
+
for (const pcbPort of pcbPorts) {
|
|
3417
|
+
if (!pcbPort.source_port_id) continue;
|
|
3418
|
+
const pcbPortIds = pcbPortIdsBySourcePortId.get(pcbPort.source_port_id) ?? /* @__PURE__ */ new Set();
|
|
3419
|
+
pcbPortIds.add(pcbPort.pcb_port_id);
|
|
3420
|
+
pcbPortIdsBySourcePortId.set(pcbPort.source_port_id, pcbPortIds);
|
|
3421
|
+
}
|
|
3422
|
+
const pcbTracesBySourceTraceId = /* @__PURE__ */ new Map();
|
|
3423
|
+
for (const pcbTrace of pcbTraces) {
|
|
3424
|
+
if (!pcbTrace.source_trace_id) continue;
|
|
3425
|
+
const matchingPcbTraces = pcbTracesBySourceTraceId.get(pcbTrace.source_trace_id) ?? [];
|
|
3426
|
+
matchingPcbTraces.push(pcbTrace);
|
|
3427
|
+
pcbTracesBySourceTraceId.set(pcbTrace.source_trace_id, matchingPcbTraces);
|
|
3428
|
+
}
|
|
3429
|
+
const exactEndpointPcbTraceIdsBySourceTraceId = /* @__PURE__ */ new Map();
|
|
3430
|
+
for (const sourceTrace of sourceTraces) {
|
|
3431
|
+
if (sourceTrace.connected_source_port_ids.length !== 2) continue;
|
|
3432
|
+
const endpointPcbPortIds = sourceTrace.connected_source_port_ids.map(
|
|
3433
|
+
(sourcePortId) => pcbPortIdsBySourcePortId.get(sourcePortId)
|
|
3434
|
+
);
|
|
3435
|
+
if (endpointPcbPortIds.some((pcbPortIds) => !pcbPortIds?.size)) continue;
|
|
3436
|
+
const exactEndpointPcbTraceIds = new Set(
|
|
3437
|
+
(pcbTracesBySourceTraceId.get(sourceTrace.source_trace_id) ?? []).filter((pcbTrace) => {
|
|
3438
|
+
const referencedPcbPortIds = getReferencedPcbPortIds(pcbTrace);
|
|
3439
|
+
return endpointPcbPortIds.every(
|
|
3440
|
+
(pcbPortIds) => [...pcbPortIds].some(
|
|
3441
|
+
(pcbPortId) => referencedPcbPortIds.has(pcbPortId)
|
|
3442
|
+
)
|
|
3443
|
+
);
|
|
3444
|
+
}).map((pcbTrace) => pcbTrace.pcb_trace_id)
|
|
3445
|
+
);
|
|
3446
|
+
if (exactEndpointPcbTraceIds.size > 0) {
|
|
3447
|
+
exactEndpointPcbTraceIdsBySourceTraceId.set(
|
|
3448
|
+
sourceTrace.source_trace_id,
|
|
3449
|
+
exactEndpointPcbTraceIds
|
|
3450
|
+
);
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3399
3453
|
const warnings = [];
|
|
3400
3454
|
for (const pcbTrace of pcbTraces) {
|
|
3401
3455
|
if (!pcbTrace.source_trace_id) continue;
|
|
@@ -3403,6 +3457,10 @@ var checkPcbTraceLengths = (circuitJson) => {
|
|
|
3403
3457
|
if (!sourceTrace) continue;
|
|
3404
3458
|
const maximumTraceLength = sourceTrace.max_length;
|
|
3405
3459
|
if (typeof maximumTraceLength !== "number") continue;
|
|
3460
|
+
const exactEndpointPcbTraceIds = exactEndpointPcbTraceIdsBySourceTraceId.get(sourceTrace.source_trace_id);
|
|
3461
|
+
if (exactEndpointPcbTraceIds && !exactEndpointPcbTraceIds.has(pcbTrace.pcb_trace_id)) {
|
|
3462
|
+
continue;
|
|
3463
|
+
}
|
|
3406
3464
|
const actualTraceLength = getPcbTraceLength(pcbTrace);
|
|
3407
3465
|
if (actualTraceLength <= maximumTraceLength) continue;
|
|
3408
3466
|
warnings.push({
|
|
@@ -3920,6 +3978,11 @@ function checkAllPinsInComponentAreUnderspecified(circuitJson) {
|
|
|
3920
3978
|
|
|
3921
3979
|
// lib/check-no-power-pin-defined.ts
|
|
3922
3980
|
import { cju as cju8 } from "@tscircuit/circuit-json-util";
|
|
3981
|
+
|
|
3982
|
+
// lib/util/should-check-chip-power-ground-pins.ts
|
|
3983
|
+
var shouldCheckChipPowerGroundPins = (component, ports) => component.ftype === "simple_chip" && ports.filter((port) => port.do_not_connect !== true).length >= 2;
|
|
3984
|
+
|
|
3985
|
+
// lib/check-no-power-pin-defined.ts
|
|
3923
3986
|
function checkNoPowerPinDefined(circuitJson) {
|
|
3924
3987
|
const warnings = [];
|
|
3925
3988
|
const db = cju8(circuitJson);
|
|
@@ -3933,9 +3996,8 @@ function checkNoPowerPinDefined(circuitJson) {
|
|
|
3933
3996
|
portsByComponent.set(port.source_component_id, existing);
|
|
3934
3997
|
}
|
|
3935
3998
|
for (const component of sourceComponents) {
|
|
3936
|
-
if (component.ftype !== "simple_chip") continue;
|
|
3937
3999
|
const componentPorts = portsByComponent.get(component.source_component_id) ?? [];
|
|
3938
|
-
if (componentPorts
|
|
4000
|
+
if (!shouldCheckChipPowerGroundPins(component, componentPorts)) continue;
|
|
3939
4001
|
const hasRequiredPowerPin = componentPorts.some(
|
|
3940
4002
|
(port) => port.requires_power === true
|
|
3941
4003
|
);
|
|
@@ -3968,9 +4030,8 @@ function checkNoGroundPinDefined(circuitJson) {
|
|
|
3968
4030
|
portsByComponent.set(port.source_component_id, existing);
|
|
3969
4031
|
}
|
|
3970
4032
|
for (const component of sourceComponents) {
|
|
3971
|
-
if (component.ftype !== "simple_chip") continue;
|
|
3972
4033
|
const componentPorts = portsByComponent.get(component.source_component_id) ?? [];
|
|
3973
|
-
if (componentPorts
|
|
4034
|
+
if (!shouldCheckChipPowerGroundPins(component, componentPorts)) continue;
|
|
3974
4035
|
const hasRequiredGroundPin = componentPorts.some(
|
|
3975
4036
|
(port) => port.requires_ground === true
|
|
3976
4037
|
);
|