🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

circuit-json-to-connectivity-map

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circuit-json-to-connectivity-map - npm Package Compare versions

Comparing version

to
0.0.14

2

dist/index.d.ts

@@ -10,2 +10,3 @@ import { AnySoupElement, AnyCircuitElement, PCBTrace, PCBPort } from '@tscircuit/soup';

constructor(netMap: Record<string, string[]>);
addConnections(connections: string[][]): void;
getIdsConnectedToNet(netId: string): string[];

@@ -37,2 +38,3 @@ getNetConnectedToId(id: string): string | undefined;

private _buildTraceConnectivityMap;
addTrace(trace: PCBTrace): void;
_arePcbTracesConnected(trace1: PCBTrace, trace2: PCBTrace): boolean;

@@ -39,0 +41,0 @@ areTracesConnected(traceId1: string, traceId2: string): boolean;

@@ -57,2 +57,37 @@ // src/findConnectedNetworks.ts

}
addConnections(connections) {
for (const connection of connections) {
const existingNets = /* @__PURE__ */ new Set();
for (const id of connection) {
const existingNetId = this.idToNetMap[id];
if (existingNetId) {
existingNets.add(existingNetId);
}
}
let targetNetId;
if (existingNets.size === 0) {
targetNetId = `connectivity_net${Object.keys(this.netMap).length}`;
this.netMap[targetNetId] = [];
} else if (existingNets.size === 1) {
targetNetId = existingNets.values().next().value ?? `connectivity_net${Object.keys(this.netMap).length}`;
} else {
targetNetId = existingNets.values().next().value ?? `connectivity_net${Object.keys(this.netMap).length}`;
for (const netId of existingNets) {
if (netId !== targetNetId) {
this.netMap[targetNetId].push(...this.netMap[netId]);
this.netMap[netId] = this.netMap[targetNetId];
for (const id of this.netMap[targetNetId]) {
this.idToNetMap[id] = targetNetId;
}
}
}
}
for (const id of connection) {
if (!this.netMap[targetNetId].includes(id)) {
this.netMap[targetNetId].push(id);
}
this.idToNetMap[id] = targetNetId;
}
}
}
getIdsConnectedToNet(netId) {

@@ -70,3 +105,3 @@ return this.netMap[netId] || [];

areAllIdsConnected(ids) {
let netId = this.getNetConnectedToId(ids[0]);
const netId = this.getNetConnectedToId(ids[0]);
for (const id of ids) {

@@ -194,2 +229,17 @@ const nextNetId = this.getNetConnectedToId(id);

}
addTrace(trace) {
this.traceIdToElm.set(trace.pcb_trace_id, trace);
const connections = [];
for (const rp of trace.route) {
if (rp.route_type === "wire") {
if (rp.start_pcb_port_id) {
connections.push([rp.start_pcb_port_id, trace.pcb_trace_id]);
}
if (rp.end_pcb_port_id) {
connections.push([rp.end_pcb_port_id, trace.pcb_trace_id]);
}
}
}
this.connMap.addConnections(connections);
}
_arePcbTracesConnected(trace1, trace2) {

@@ -196,0 +246,0 @@ for (let i = 0; i < trace1.route.length - 1; i++) {

2

package.json

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "0.0.13",
"version": "0.0.14",
"files": [

@@ -8,0 +8,0 @@ "dist"

Sorry, the diff of this file is not supported yet