@tscircuit/core 0.0.1370 → 0.0.1372
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 +123 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16044,8 +16044,24 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16044
16044
|
}).filter((c) => c !== null);
|
|
16045
16045
|
const source_nets = db.source_net.list().filter((e) => !subcircuit_id || e.subcircuit_id === subcircuit_id);
|
|
16046
16046
|
const connectionsFromNets = [];
|
|
16047
|
+
const connectionFromNetId = /* @__PURE__ */ new Map();
|
|
16048
|
+
const handledNetConnectivityKeys = /* @__PURE__ */ new Set();
|
|
16049
|
+
const sourceTraces = db.source_trace.list();
|
|
16050
|
+
const getSourceConnectivityKey = (id) => id ? connMap.getNetConnectedToId(id) ?? id : null;
|
|
16047
16051
|
for (const net of source_nets) {
|
|
16048
|
-
const
|
|
16052
|
+
const netConnectivityKey = getSourceConnectivityKey(net.source_net_id);
|
|
16053
|
+
if (!netConnectivityKey || handledNetConnectivityKeys.has(netConnectivityKey)) {
|
|
16054
|
+
continue;
|
|
16055
|
+
}
|
|
16056
|
+
handledNetConnectivityKeys.add(netConnectivityKey);
|
|
16057
|
+
const connectedSourceNetIds = source_nets.filter(
|
|
16058
|
+
(sourceNet) => getSourceConnectivityKey(sourceNet.source_net_id) === netConnectivityKey
|
|
16059
|
+
).map((sourceNet) => sourceNet.source_net_id);
|
|
16060
|
+
const connectedSourceTraces = sourceTraces.filter(
|
|
16061
|
+
(st) => [st.source_trace_id, ...st.connected_source_net_ids ?? []].some(
|
|
16062
|
+
(id) => getSourceConnectivityKey(id) === netConnectivityKey
|
|
16063
|
+
)
|
|
16064
|
+
);
|
|
16049
16065
|
let nominalTraceWidthFromConnectedTraces;
|
|
16050
16066
|
for (const sourceTrace of connectedSourceTraces) {
|
|
16051
16067
|
if (sourceTrace.min_trace_thickness === void 0) continue;
|
|
@@ -16070,12 +16086,16 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16070
16086
|
});
|
|
16071
16087
|
}
|
|
16072
16088
|
}
|
|
16073
|
-
|
|
16089
|
+
const connection = {
|
|
16074
16090
|
name: net.source_net_id ?? connMap.getNetConnectedToId(net.source_net_id),
|
|
16075
16091
|
nominalTraceWidth: nominalTraceWidthFromConnectedTraces,
|
|
16076
16092
|
width: nominalTraceWidthFromConnectedTraces,
|
|
16077
16093
|
pointsToConnect
|
|
16078
|
-
}
|
|
16094
|
+
};
|
|
16095
|
+
connectionsFromNets.push(connection);
|
|
16096
|
+
for (const sourceNetId of connectedSourceNetIds) {
|
|
16097
|
+
connectionFromNetId.set(sourceNetId, connection);
|
|
16098
|
+
}
|
|
16079
16099
|
}
|
|
16080
16100
|
const connectionsFromBreakoutPoints = [];
|
|
16081
16101
|
for (const bp of breakoutPoints) {
|
|
@@ -16110,7 +16130,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16110
16130
|
continue;
|
|
16111
16131
|
}
|
|
16112
16132
|
if (bp.source_net_id) {
|
|
16113
|
-
const conn =
|
|
16133
|
+
const conn = connectionFromNetId.get(bp.source_net_id);
|
|
16114
16134
|
if (conn) {
|
|
16115
16135
|
conn.pointsToConnect.push(pt);
|
|
16116
16136
|
} else {
|
|
@@ -18192,9 +18212,6 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
18192
18212
|
}
|
|
18193
18213
|
}
|
|
18194
18214
|
|
|
18195
|
-
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
18196
|
-
import { getCircuitJsonTree as getCircuitJsonTree2 } from "@tscircuit/circuit-json-util";
|
|
18197
|
-
|
|
18198
18215
|
// lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts
|
|
18199
18216
|
import "@tscircuit/circuit-json-util";
|
|
18200
18217
|
import { LayoutPipelineSolver } from "@tscircuit/matchpack";
|
|
@@ -19040,13 +19057,101 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19040
19057
|
debug6("Matchpack layout completed successfully");
|
|
19041
19058
|
}
|
|
19042
19059
|
|
|
19060
|
+
// lib/components/primitive-components/Group/getSchematicCircuitJsonTrees.ts
|
|
19061
|
+
import {
|
|
19062
|
+
getCircuitJsonTree as getCircuitJsonTree2
|
|
19063
|
+
} from "@tscircuit/circuit-json-util";
|
|
19064
|
+
function getSchematicSheetIdByGroupId({
|
|
19065
|
+
circuitJson,
|
|
19066
|
+
sheetIdBySourceComponentId
|
|
19067
|
+
}) {
|
|
19068
|
+
const parentBySourceGroupId = /* @__PURE__ */ new Map();
|
|
19069
|
+
for (const element of circuitJson) {
|
|
19070
|
+
if (element.type === "source_group") {
|
|
19071
|
+
parentBySourceGroupId.set(
|
|
19072
|
+
element.source_group_id,
|
|
19073
|
+
element.parent_source_group_id
|
|
19074
|
+
);
|
|
19075
|
+
}
|
|
19076
|
+
}
|
|
19077
|
+
const sheetIdByGroupId = /* @__PURE__ */ new Map();
|
|
19078
|
+
for (const element of circuitJson) {
|
|
19079
|
+
if (element.type !== "source_component") continue;
|
|
19080
|
+
if (!element.source_group_id) continue;
|
|
19081
|
+
const sheetId = sheetIdBySourceComponentId.get(element.source_component_id);
|
|
19082
|
+
if (sheetId === void 0) continue;
|
|
19083
|
+
let groupId = element.source_group_id;
|
|
19084
|
+
while (groupId && !sheetIdByGroupId.has(groupId)) {
|
|
19085
|
+
sheetIdByGroupId.set(groupId, sheetId);
|
|
19086
|
+
groupId = parentBySourceGroupId.get(groupId);
|
|
19087
|
+
}
|
|
19088
|
+
}
|
|
19089
|
+
return sheetIdByGroupId;
|
|
19090
|
+
}
|
|
19091
|
+
function getCircuitJsonScopedToSchematicSheet({
|
|
19092
|
+
circuitJson,
|
|
19093
|
+
sheetId,
|
|
19094
|
+
rootSourceGroupId,
|
|
19095
|
+
sheetIdBySourceComponentId,
|
|
19096
|
+
sheetIdByGroupId
|
|
19097
|
+
}) {
|
|
19098
|
+
const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId || sheetIdByGroupId.get(sourceGroupId) === sheetId;
|
|
19099
|
+
return circuitJson.filter((element) => {
|
|
19100
|
+
if (element.type === "source_group") {
|
|
19101
|
+
return isGroupOnSheet(element.source_group_id);
|
|
19102
|
+
}
|
|
19103
|
+
if (element.type === "source_component") {
|
|
19104
|
+
if (sheetIdBySourceComponentId.get(element.source_component_id) !== sheetId) {
|
|
19105
|
+
return false;
|
|
19106
|
+
}
|
|
19107
|
+
return element.source_group_id ? isGroupOnSheet(element.source_group_id) : true;
|
|
19108
|
+
}
|
|
19109
|
+
return true;
|
|
19110
|
+
});
|
|
19111
|
+
}
|
|
19112
|
+
function getSchematicCircuitJsonTrees(circuitJson, opts) {
|
|
19113
|
+
const { source_group_id } = opts;
|
|
19114
|
+
const sheetIdBySourceComponentId = /* @__PURE__ */ new Map();
|
|
19115
|
+
for (const element of circuitJson) {
|
|
19116
|
+
if (element.type !== "schematic_component") continue;
|
|
19117
|
+
if (!element.source_component_id) continue;
|
|
19118
|
+
if (!element.schematic_sheet_id) continue;
|
|
19119
|
+
sheetIdBySourceComponentId.set(
|
|
19120
|
+
element.source_component_id,
|
|
19121
|
+
element.schematic_sheet_id
|
|
19122
|
+
);
|
|
19123
|
+
}
|
|
19124
|
+
const sheetIds = new Set(sheetIdBySourceComponentId.values());
|
|
19125
|
+
if (sheetIds.size <= 1) {
|
|
19126
|
+
return [getCircuitJsonTree2(circuitJson, { source_group_id })];
|
|
19127
|
+
}
|
|
19128
|
+
const sheetIdByGroupId = getSchematicSheetIdByGroupId({
|
|
19129
|
+
circuitJson,
|
|
19130
|
+
sheetIdBySourceComponentId
|
|
19131
|
+
});
|
|
19132
|
+
return Array.from(sheetIds).map(
|
|
19133
|
+
(sheetId) => getCircuitJsonTree2(
|
|
19134
|
+
getCircuitJsonScopedToSchematicSheet({
|
|
19135
|
+
circuitJson,
|
|
19136
|
+
sheetId,
|
|
19137
|
+
rootSourceGroupId: source_group_id,
|
|
19138
|
+
sheetIdBySourceComponentId,
|
|
19139
|
+
sheetIdByGroupId
|
|
19140
|
+
}),
|
|
19141
|
+
{ source_group_id }
|
|
19142
|
+
)
|
|
19143
|
+
);
|
|
19144
|
+
}
|
|
19145
|
+
|
|
19043
19146
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
19044
19147
|
function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
19045
19148
|
const { db } = group.root;
|
|
19046
|
-
const
|
|
19149
|
+
const trees = getSchematicCircuitJsonTrees(db.toArray(), {
|
|
19047
19150
|
source_group_id: group.source_group_id
|
|
19048
19151
|
});
|
|
19049
|
-
|
|
19152
|
+
for (const tree of trees) {
|
|
19153
|
+
applySchematicMatchPackLayoutToTree(group, tree);
|
|
19154
|
+
}
|
|
19050
19155
|
}
|
|
19051
19156
|
|
|
19052
19157
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
@@ -23443,6 +23548,7 @@ var Group5 = class extends NormalComponent3 {
|
|
|
23443
23548
|
const subcircuitComponentsByName = /* @__PURE__ */ new Map();
|
|
23444
23549
|
for (const child of this.children) {
|
|
23445
23550
|
if (child.isSubcircuit) continue;
|
|
23551
|
+
if (child instanceof Trace3) continue;
|
|
23446
23552
|
if (child._parsedProps.name) {
|
|
23447
23553
|
const components = subcircuitComponentsByName.get(child._parsedProps.name) || [];
|
|
23448
23554
|
components.push(child);
|
|
@@ -24575,7 +24681,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
24575
24681
|
var package_default = {
|
|
24576
24682
|
name: "@tscircuit/core",
|
|
24577
24683
|
type: "module",
|
|
24578
|
-
version: "0.0.
|
|
24684
|
+
version: "0.0.1371",
|
|
24579
24685
|
types: "dist/index.d.ts",
|
|
24580
24686
|
main: "dist/index.js",
|
|
24581
24687
|
module: "dist/index.js",
|
|
@@ -25682,15 +25788,17 @@ var Subcircuit = class extends Group5 {
|
|
|
25682
25788
|
const parentNetSelector = `> net.${netName}`;
|
|
25683
25789
|
const childNetSelector = `.${this.name} > net.${netName}`;
|
|
25684
25790
|
const traceName = `exposed_net.${netName}`;
|
|
25685
|
-
const
|
|
25791
|
+
const parentNet = parentSubcircuit.children.find(
|
|
25686
25792
|
(child) => child instanceof Net && child._parsedProps.name === netName
|
|
25687
25793
|
);
|
|
25688
|
-
if (!
|
|
25794
|
+
if (!parentNet) {
|
|
25689
25795
|
parentSubcircuit.add(new Net({ name: netName }));
|
|
25690
25796
|
}
|
|
25691
|
-
const existingTrace = parentSubcircuit.children.find(
|
|
25692
|
-
(child
|
|
25693
|
-
|
|
25797
|
+
const existingTrace = parentSubcircuit.children.find((child) => {
|
|
25798
|
+
if (!(child instanceof Trace3)) return false;
|
|
25799
|
+
const childProps = child._parsedProps;
|
|
25800
|
+
return childProps.name === traceName && childProps.from === childNetSelector && childProps.to === parentNetSelector;
|
|
25801
|
+
});
|
|
25694
25802
|
if (existingTrace) continue;
|
|
25695
25803
|
parentSubcircuit.add(
|
|
25696
25804
|
new Trace3({
|