@tscircuit/core 0.0.1474 → 0.0.1475
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 +63 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19665,7 +19665,15 @@ function getTreeChildChipId(child, index) {
|
|
|
19665
19665
|
}
|
|
19666
19666
|
return null;
|
|
19667
19667
|
}
|
|
19668
|
-
|
|
19668
|
+
var getSchematicComponentForSourceComponent = ({
|
|
19669
|
+
db,
|
|
19670
|
+
sourceComponentId,
|
|
19671
|
+
schematicSheetId
|
|
19672
|
+
}) => db.schematic_component.getWhere({
|
|
19673
|
+
source_component_id: sourceComponentId,
|
|
19674
|
+
...schematicSheetId ? { schematic_sheet_id: schematicSheetId } : {}
|
|
19675
|
+
});
|
|
19676
|
+
function convertTreeToMatchPackInputProblem(tree, db, group, opts = {}) {
|
|
19669
19677
|
const problem = {
|
|
19670
19678
|
chipMap: {},
|
|
19671
19679
|
chipPinMap: {},
|
|
@@ -19699,8 +19707,10 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19699
19707
|
}
|
|
19700
19708
|
if (child.nodeType === "component" && child.sourceComponent) {
|
|
19701
19709
|
const chipId = getTreeChildChipId(child, index);
|
|
19702
|
-
const schematicComponent =
|
|
19703
|
-
|
|
19710
|
+
const schematicComponent = getSchematicComponentForSourceComponent({
|
|
19711
|
+
db,
|
|
19712
|
+
sourceComponentId: child.sourceComponent.source_component_id,
|
|
19713
|
+
schematicSheetId: opts.schematicSheetId
|
|
19704
19714
|
});
|
|
19705
19715
|
if (!schematicComponent) return;
|
|
19706
19716
|
const component = group.children.find(
|
|
@@ -19980,7 +19990,7 @@ function convertTreeToMatchPackInputProblem(tree, db, group) {
|
|
|
19980
19990
|
}
|
|
19981
19991
|
return { inputProblem: problem, nestedGroupMatchpackProxyMap };
|
|
19982
19992
|
}
|
|
19983
|
-
function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
19993
|
+
function applySchematicMatchPackLayoutToTree(group, tree, opts = {}) {
|
|
19984
19994
|
const { db } = group.root;
|
|
19985
19995
|
debug6(
|
|
19986
19996
|
`[${group.name}] Starting matchpack layout with ${tree.childNodes.length} children`
|
|
@@ -19993,7 +20003,7 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
19993
20003
|
return;
|
|
19994
20004
|
}
|
|
19995
20005
|
debug6("Converting circuit tree to InputProblem...");
|
|
19996
|
-
const { inputProblem, nestedGroupMatchpackProxyMap } = convertTreeToMatchPackInputProblem(tree, db, group);
|
|
20006
|
+
const { inputProblem, nestedGroupMatchpackProxyMap } = convertTreeToMatchPackInputProblem(tree, db, group, opts);
|
|
19997
20007
|
if (debug6.enabled) {
|
|
19998
20008
|
group.root?.emit("debug:logOutput", {
|
|
19999
20009
|
type: "debug:logOutput",
|
|
@@ -20080,8 +20090,10 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
20080
20090
|
debug6(`Skipping position update for fixed chip ${chipId}`);
|
|
20081
20091
|
continue;
|
|
20082
20092
|
}
|
|
20083
|
-
const schematicComponent =
|
|
20084
|
-
|
|
20093
|
+
const schematicComponent = getSchematicComponentForSourceComponent({
|
|
20094
|
+
db,
|
|
20095
|
+
sourceComponentId: treeNode.sourceComponent.source_component_id,
|
|
20096
|
+
schematicSheetId: opts.schematicSheetId
|
|
20085
20097
|
});
|
|
20086
20098
|
if (schematicComponent) {
|
|
20087
20099
|
debug6(`Moving component ${chipId} to (${newCenter.x}, ${newCenter.y})`);
|
|
@@ -20228,9 +20240,9 @@ function applySchematicMatchPackLayoutToTree(group, tree) {
|
|
|
20228
20240
|
import {
|
|
20229
20241
|
getCircuitJsonTree as getCircuitJsonTree2
|
|
20230
20242
|
} from "@tscircuit/circuit-json-util";
|
|
20231
|
-
function
|
|
20243
|
+
function getSchematicSheetIdBySourceGroupId({
|
|
20232
20244
|
circuitJson,
|
|
20233
|
-
|
|
20245
|
+
schematicSheetIdBySourceComponentId
|
|
20234
20246
|
}) {
|
|
20235
20247
|
const parentBySourceGroupId = /* @__PURE__ */ new Map();
|
|
20236
20248
|
for (const element of circuitJson) {
|
|
@@ -20241,34 +20253,36 @@ function getSchematicSheetIdByGroupId({
|
|
|
20241
20253
|
);
|
|
20242
20254
|
}
|
|
20243
20255
|
}
|
|
20244
|
-
const
|
|
20256
|
+
const schematicSheetIdBySourceGroupId = /* @__PURE__ */ new Map();
|
|
20245
20257
|
for (const element of circuitJson) {
|
|
20246
20258
|
if (element.type !== "source_component") continue;
|
|
20247
20259
|
if (!element.source_group_id) continue;
|
|
20248
|
-
const
|
|
20249
|
-
|
|
20250
|
-
|
|
20251
|
-
|
|
20252
|
-
|
|
20253
|
-
|
|
20260
|
+
const schematicSheetId = schematicSheetIdBySourceComponentId.get(
|
|
20261
|
+
element.source_component_id
|
|
20262
|
+
);
|
|
20263
|
+
if (schematicSheetId === void 0) continue;
|
|
20264
|
+
let sourceGroupId = element.source_group_id;
|
|
20265
|
+
while (sourceGroupId && !schematicSheetIdBySourceGroupId.has(sourceGroupId)) {
|
|
20266
|
+
schematicSheetIdBySourceGroupId.set(sourceGroupId, schematicSheetId);
|
|
20267
|
+
sourceGroupId = parentBySourceGroupId.get(sourceGroupId);
|
|
20254
20268
|
}
|
|
20255
20269
|
}
|
|
20256
|
-
return
|
|
20270
|
+
return schematicSheetIdBySourceGroupId;
|
|
20257
20271
|
}
|
|
20258
20272
|
function getCircuitJsonScopedToSchematicSheet({
|
|
20259
20273
|
circuitJson,
|
|
20260
|
-
|
|
20274
|
+
schematicSheetId,
|
|
20261
20275
|
rootSourceGroupId,
|
|
20262
|
-
|
|
20263
|
-
|
|
20276
|
+
schematicSheetIdBySourceComponentId,
|
|
20277
|
+
schematicSheetIdBySourceGroupId
|
|
20264
20278
|
}) {
|
|
20265
|
-
const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId ||
|
|
20279
|
+
const isGroupOnSheet = (sourceGroupId) => sourceGroupId === rootSourceGroupId || schematicSheetIdBySourceGroupId.get(sourceGroupId) === schematicSheetId;
|
|
20266
20280
|
return circuitJson.filter((element) => {
|
|
20267
20281
|
if (element.type === "source_group") {
|
|
20268
20282
|
return isGroupOnSheet(element.source_group_id);
|
|
20269
20283
|
}
|
|
20270
20284
|
if (element.type === "source_component") {
|
|
20271
|
-
if (
|
|
20285
|
+
if (schematicSheetIdBySourceComponentId.get(element.source_component_id) !== schematicSheetId) {
|
|
20272
20286
|
return false;
|
|
20273
20287
|
}
|
|
20274
20288
|
return element.source_group_id ? isGroupOnSheet(element.source_group_id) : true;
|
|
@@ -20278,36 +20292,44 @@ function getCircuitJsonScopedToSchematicSheet({
|
|
|
20278
20292
|
}
|
|
20279
20293
|
function getSchematicCircuitJsonTrees(circuitJson, opts) {
|
|
20280
20294
|
const { source_group_id } = opts;
|
|
20281
|
-
const
|
|
20295
|
+
const schematicSheetIdBySourceComponentId = /* @__PURE__ */ new Map();
|
|
20282
20296
|
for (const element of circuitJson) {
|
|
20283
20297
|
if (element.type !== "schematic_component") continue;
|
|
20284
20298
|
if (!element.source_component_id) continue;
|
|
20285
20299
|
if (!element.schematic_sheet_id) continue;
|
|
20286
|
-
|
|
20300
|
+
schematicSheetIdBySourceComponentId.set(
|
|
20287
20301
|
element.source_component_id,
|
|
20288
20302
|
element.schematic_sheet_id
|
|
20289
20303
|
);
|
|
20290
20304
|
}
|
|
20291
|
-
const
|
|
20292
|
-
|
|
20293
|
-
|
|
20305
|
+
const schematicSheetIds = new Set(
|
|
20306
|
+
schematicSheetIdBySourceComponentId.values()
|
|
20307
|
+
);
|
|
20308
|
+
if (schematicSheetIds.size <= 1) {
|
|
20309
|
+
return [
|
|
20310
|
+
{
|
|
20311
|
+
tree: getCircuitJsonTree2(circuitJson, { source_group_id }),
|
|
20312
|
+
schematicSheetId: schematicSheetIds.values().next().value
|
|
20313
|
+
}
|
|
20314
|
+
];
|
|
20294
20315
|
}
|
|
20295
|
-
const
|
|
20316
|
+
const schematicSheetIdBySourceGroupId = getSchematicSheetIdBySourceGroupId({
|
|
20296
20317
|
circuitJson,
|
|
20297
|
-
|
|
20318
|
+
schematicSheetIdBySourceComponentId
|
|
20298
20319
|
});
|
|
20299
|
-
return Array.from(
|
|
20300
|
-
|
|
20320
|
+
return Array.from(schematicSheetIds).map((schematicSheetId) => ({
|
|
20321
|
+
tree: getCircuitJsonTree2(
|
|
20301
20322
|
getCircuitJsonScopedToSchematicSheet({
|
|
20302
20323
|
circuitJson,
|
|
20303
|
-
|
|
20324
|
+
schematicSheetId,
|
|
20304
20325
|
rootSourceGroupId: source_group_id,
|
|
20305
|
-
|
|
20306
|
-
|
|
20326
|
+
schematicSheetIdBySourceComponentId,
|
|
20327
|
+
schematicSheetIdBySourceGroupId
|
|
20307
20328
|
}),
|
|
20308
20329
|
{ source_group_id }
|
|
20309
|
-
)
|
|
20310
|
-
|
|
20330
|
+
),
|
|
20331
|
+
schematicSheetId
|
|
20332
|
+
}));
|
|
20311
20333
|
}
|
|
20312
20334
|
|
|
20313
20335
|
// lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts
|
|
@@ -20316,8 +20338,8 @@ function Group_doInitialSchematicLayoutMatchPack(group) {
|
|
|
20316
20338
|
const trees = getSchematicCircuitJsonTrees(db.toArray(), {
|
|
20317
20339
|
source_group_id: group.source_group_id
|
|
20318
20340
|
});
|
|
20319
|
-
for (const tree of trees) {
|
|
20320
|
-
applySchematicMatchPackLayoutToTree(group, tree);
|
|
20341
|
+
for (const { tree, schematicSheetId } of trees) {
|
|
20342
|
+
applySchematicMatchPackLayoutToTree(group, tree, { schematicSheetId });
|
|
20321
20343
|
}
|
|
20322
20344
|
}
|
|
20323
20345
|
|
|
@@ -22889,7 +22911,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
22889
22911
|
var package_default = {
|
|
22890
22912
|
name: "@tscircuit/core",
|
|
22891
22913
|
type: "module",
|
|
22892
|
-
version: "0.0.
|
|
22914
|
+
version: "0.0.1474",
|
|
22893
22915
|
types: "dist/index.d.ts",
|
|
22894
22916
|
main: "dist/index.js",
|
|
22895
22917
|
module: "dist/index.js",
|
|
@@ -32741,7 +32763,7 @@ var TestPoint = class extends NormalComponent3 {
|
|
|
32741
32763
|
}
|
|
32742
32764
|
};
|
|
32743
32765
|
|
|
32744
|
-
// lib/components/primitive-components/SchematicBox.ts
|
|
32766
|
+
// lib/components/primitive-components/SchematicBox/SchematicBox.ts
|
|
32745
32767
|
import { schematicBoxProps } from "@tscircuit/props";
|
|
32746
32768
|
|
|
32747
32769
|
// lib/components/primitive-components/getTitleAnchorAndPosition.ts
|
|
@@ -32817,7 +32839,7 @@ function getTitleAnchorAndPosition({
|
|
|
32817
32839
|
}
|
|
32818
32840
|
}
|
|
32819
32841
|
|
|
32820
|
-
// lib/components/primitive-components/SchematicBox.ts
|
|
32842
|
+
// lib/components/primitive-components/SchematicBox/SchematicBox.ts
|
|
32821
32843
|
var SchematicBox = class extends PrimitiveComponent2 {
|
|
32822
32844
|
isSchematicPrimitive = true;
|
|
32823
32845
|
get config() {
|