@tscircuit/core 0.0.498 → 0.0.500
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 +58 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4646,16 +4646,49 @@ var Trace2 = class extends PrimitiveComponent2 {
|
|
|
4646
4646
|
}));
|
|
4647
4647
|
for (const { selector, port } of portsWithSelectors) {
|
|
4648
4648
|
if (!port) {
|
|
4649
|
-
|
|
4650
|
-
|
|
4649
|
+
let parentSelector;
|
|
4650
|
+
let portToken;
|
|
4651
|
+
const dotIndex = selector.lastIndexOf(".");
|
|
4652
|
+
if (dotIndex !== -1 && dotIndex > selector.lastIndexOf(" ")) {
|
|
4653
|
+
parentSelector = selector.slice(0, dotIndex);
|
|
4654
|
+
portToken = selector.slice(dotIndex + 1);
|
|
4655
|
+
} else {
|
|
4656
|
+
const match = selector.match(/^(.*[ >])?([^ >]+)$/);
|
|
4657
|
+
parentSelector = match?.[1]?.trim() ?? "";
|
|
4658
|
+
portToken = match?.[2] ?? selector;
|
|
4659
|
+
}
|
|
4660
|
+
let targetComponent = parentSelector ? this.getSubcircuit().selectOne(parentSelector) : null;
|
|
4661
|
+
if (!targetComponent && parentSelector && !/[.#\[]/.test(parentSelector)) {
|
|
4662
|
+
targetComponent = this.getSubcircuit().selectOne(`.${parentSelector}`);
|
|
4663
|
+
}
|
|
4651
4664
|
if (!targetComponent) {
|
|
4652
|
-
|
|
4665
|
+
if (parentSelector) {
|
|
4666
|
+
this.renderError(
|
|
4667
|
+
`Could not find port for selector "${selector}". Component "${parentSelector}" not found`
|
|
4668
|
+
);
|
|
4669
|
+
} else {
|
|
4670
|
+
this.renderError(`Could not find port for selector "${selector}"`);
|
|
4671
|
+
}
|
|
4653
4672
|
} else {
|
|
4673
|
+
const ports = targetComponent.children.filter(
|
|
4674
|
+
(c) => c.componentName === "Port"
|
|
4675
|
+
);
|
|
4676
|
+
const portLabel = portToken.includes(".") ? portToken.split(".").pop() ?? "" : portToken;
|
|
4677
|
+
const portNames = ports.map((c) => c.getNameAndAliases()).flat();
|
|
4678
|
+
const hasCustomLabels = portNames.some(
|
|
4679
|
+
(n) => !/^(pin\d+|\d+)$/.test(n)
|
|
4680
|
+
);
|
|
4681
|
+
const labelList = Array.from(new Set(portNames)).join(", ");
|
|
4682
|
+
let detail;
|
|
4683
|
+
if (ports.length === 0) {
|
|
4684
|
+
detail = "It has no ports";
|
|
4685
|
+
} else if (!hasCustomLabels) {
|
|
4686
|
+
detail = `It has ${ports.length} pins and no pinLabels (consider adding pinLabels)`;
|
|
4687
|
+
} else {
|
|
4688
|
+
detail = `It has [${labelList}]`;
|
|
4689
|
+
}
|
|
4654
4690
|
this.renderError(
|
|
4655
|
-
`Could not find port for selector "${selector}"
|
|
4656
|
-
searched component ${targetComponent.getString()}, which has ports: ${targetComponent.children.filter((c) => c.componentName === "Port").map(
|
|
4657
|
-
(c) => `${c.getString()}(${c.getNameAndAliases().join(",")})`
|
|
4658
|
-
).join(" & ")}`
|
|
4691
|
+
`Could not find port for selector "${selector}". Component "${targetComponent.props.name ?? parentSelector}" found, but does not have pin "${portLabel}". ${detail}`
|
|
4659
4692
|
);
|
|
4660
4693
|
}
|
|
4661
4694
|
}
|
|
@@ -6734,6 +6767,23 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
6734
6767
|
maxY: Math.max(...allPoints.map((p) => p.y)) + 1
|
|
6735
6768
|
};
|
|
6736
6769
|
}
|
|
6770
|
+
if (subcircuit_id) {
|
|
6771
|
+
const group = db.pcb_group.getWhere({ subcircuit_id });
|
|
6772
|
+
if (group) {
|
|
6773
|
+
const groupBounds = {
|
|
6774
|
+
minX: group.center.x - group.width / 2,
|
|
6775
|
+
maxX: group.center.x + group.width / 2,
|
|
6776
|
+
minY: group.center.y - group.height / 2,
|
|
6777
|
+
maxY: group.center.y + group.height / 2
|
|
6778
|
+
};
|
|
6779
|
+
bounds = {
|
|
6780
|
+
minX: Math.min(bounds.minX, groupBounds.minX),
|
|
6781
|
+
maxX: Math.max(bounds.maxX, groupBounds.maxX),
|
|
6782
|
+
minY: Math.min(bounds.minY, groupBounds.minY),
|
|
6783
|
+
maxY: Math.max(bounds.maxY, groupBounds.maxY)
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
}
|
|
6737
6787
|
const directTraceConnections = db.source_trace.list().map((trace) => {
|
|
6738
6788
|
const connectedPorts = trace.connected_source_port_ids.map((id) => {
|
|
6739
6789
|
const source_port = db.source_port.get(id);
|
|
@@ -10334,7 +10384,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
10334
10384
|
var package_default = {
|
|
10335
10385
|
name: "@tscircuit/core",
|
|
10336
10386
|
type: "module",
|
|
10337
|
-
version: "0.0.
|
|
10387
|
+
version: "0.0.499",
|
|
10338
10388
|
types: "dist/index.d.ts",
|
|
10339
10389
|
main: "dist/index.js",
|
|
10340
10390
|
module: "dist/index.js",
|