@tscircuit/core 0.0.1370 → 0.0.1371
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 +91 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18192,9 +18192,6 @@ function Group_doInitialSchematicLayoutMatchAdapt(group) {
|
|
|
18192
18192
|
}
|
|
18193
18193
|
}
|
|
18194
18194
|
|
|
18195
|
-
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
18196
|
-
import { getCircuitJsonTree as getCircuitJsonTree2 } from "@tscircuit/circuit-json-util";
|
|
18197
|
-
|
|
18198
18195
|
// lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts
|
|
18199
18196
|
import "@tscircuit/circuit-json-util";
|
|
18200
18197
|
import { LayoutPipelineSolver } from "@tscircuit/matchpack";
|
|
@@ -19040,13 +19037,101 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19040
19037
|
debug6("Matchpack layout completed successfully");
|
|
19041
19038
|
}
|
|
19042
19039
|
|
|
19040
|
+
// lib/components/primitive-components/Group/getSchematicCircuitJsonTrees.ts
|
|
19041
|
+
import {
|
|
19042
|
+
getCircuitJsonTree as getCircuitJsonTree2
|
|
19043
|
+
} from "@tscircuit/circuit-json-util";
|
|
19044
|
+
function getSchematicSheetIdByGroupId({
|
|
19045
|
+
circuitJson,
|
|
19046
|
+
sheetIdBySourceComponentId
|
|
19047
|
+
}) {
|
|
19048
|
+
const parentBySourceGroupId = /* @__PURE__ */ new Map();
|
|
19049
|
+
for (const element of circuitJson) {
|
|
19050
|
+
if (element.type === "source_group") {
|
|
19051
|
+
parentBySourceGroupId.set(
|
|
19052
|
+
element.source_group_id,
|
|
19053
|
+
element.parent_source_group_id
|
|
19054
|
+
);
|
|
19055
|
+
}
|
|
19056
|
+
}
|
|
19057
|
+
const sheetIdByGroupId = /* @__PURE__ */ new Map();
|
|
19058
|
+
for (const element of circuitJson) {
|
|
19059
|
+
if (element.type !== "source_component") continue;
|
|
19060
|
+
if (!element.source_group_id) continue;
|
|
19061
|
+
const sheetId = sheetIdBySourceComponentId.get(element.source_component_id);
|
|
19062
|
+
if (sheetId === void 0) continue;
|
|
19063
|
+
let groupId = element.source_group_id;
|
|
19064
|
+
while (groupId && !sheetIdByGroupId.has(groupId)) {
|
|
19065
|
+
sheetIdByGroupId.set(groupId, sheetId);
|
|
19066
|
+
groupId = parentBySourceGroupId.get(groupId);
|
|
19067
|
+
}
|
|
19068
|
+
}
|
|
19069
|
+
return sheetIdByGroupId;
|
|
19070
|
+
}
|
|
19071
|
+
function getCircuitJsonScopedToSchematicSheet({
|
|
19072
|
+
circuitJson,
|
|
19073
|
+
sheetId,
|
|
19074
|
+
rootSourceGroupId,
|
|
19075
|
+
sheetIdBySourceComponentId,
|
|
19076
|
+
sheetIdByGroupId
|
|
19077
|
+
}) {
|
|
19078
|
+
const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId || sheetIdByGroupId.get(sourceGroupId) === sheetId;
|
|
19079
|
+
return circuitJson.filter((element) => {
|
|
19080
|
+
if (element.type === "source_group") {
|
|
19081
|
+
return isGroupOnSheet(element.source_group_id);
|
|
19082
|
+
}
|
|
19083
|
+
if (element.type === "source_component") {
|
|
19084
|
+
if (sheetIdBySourceComponentId.get(element.source_component_id) !== sheetId) {
|
|
19085
|
+
return false;
|
|
19086
|
+
}
|
|
19087
|
+
return element.source_group_id ? isGroupOnSheet(element.source_group_id) : true;
|
|
19088
|
+
}
|
|
19089
|
+
return true;
|
|
19090
|
+
});
|
|
19091
|
+
}
|
|
19092
|
+
function getSchematicCircuitJsonTrees(circuitJson, opts) {
|
|
19093
|
+
const { source_group_id } = opts;
|
|
19094
|
+
const sheetIdBySourceComponentId = /* @__PURE__ */ new Map();
|
|
19095
|
+
for (const element of circuitJson) {
|
|
19096
|
+
if (element.type !== "schematic_component") continue;
|
|
19097
|
+
if (!element.source_component_id) continue;
|
|
19098
|
+
if (!element.schematic_sheet_id) continue;
|
|
19099
|
+
sheetIdBySourceComponentId.set(
|
|
19100
|
+
element.source_component_id,
|
|
19101
|
+
element.schematic_sheet_id
|
|
19102
|
+
);
|
|
19103
|
+
}
|
|
19104
|
+
const sheetIds = new Set(sheetIdBySourceComponentId.values());
|
|
19105
|
+
if (sheetIds.size <= 1) {
|
|
19106
|
+
return [getCircuitJsonTree2(circuitJson, { source_group_id })];
|
|
19107
|
+
}
|
|
19108
|
+
const sheetIdByGroupId = getSchematicSheetIdByGroupId({
|
|
19109
|
+
circuitJson,
|
|
19110
|
+
sheetIdBySourceComponentId
|
|
19111
|
+
});
|
|
19112
|
+
return Array.from(sheetIds).map(
|
|
19113
|
+
(sheetId) => getCircuitJsonTree2(
|
|
19114
|
+
getCircuitJsonScopedToSchematicSheet({
|
|
19115
|
+
circuitJson,
|
|
19116
|
+
sheetId,
|
|
19117
|
+
rootSourceGroupId: source_group_id,
|
|
19118
|
+
sheetIdBySourceComponentId,
|
|
19119
|
+
sheetIdByGroupId
|
|
19120
|
+
}),
|
|
19121
|
+
{ source_group_id }
|
|
19122
|
+
)
|
|
19123
|
+
);
|
|
19124
|
+
}
|
|
19125
|
+
|
|
19043
19126
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
19044
19127
|
function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
19045
19128
|
const { db } = group.root;
|
|
19046
|
-
const
|
|
19129
|
+
const trees = getSchematicCircuitJsonTrees(db.toArray(), {
|
|
19047
19130
|
source_group_id: group.source_group_id
|
|
19048
19131
|
});
|
|
19049
|
-
|
|
19132
|
+
for (const tree of trees) {
|
|
19133
|
+
applySchematicMatchPackLayoutToTree(group, tree);
|
|
19134
|
+
}
|
|
19050
19135
|
}
|
|
19051
19136
|
|
|
19052
19137
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutSections.ts
|
|
@@ -24575,7 +24660,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
24575
24660
|
var package_default = {
|
|
24576
24661
|
name: "@tscircuit/core",
|
|
24577
24662
|
type: "module",
|
|
24578
|
-
version: "0.0.
|
|
24663
|
+
version: "0.0.1370",
|
|
24579
24664
|
types: "dist/index.d.ts",
|
|
24580
24665
|
main: "dist/index.js",
|
|
24581
24666
|
module: "dist/index.js",
|