@tscircuit/core 0.0.1080 → 0.0.1082
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/README.md +5 -6
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,19 +39,18 @@ const board = new Board({
|
|
|
39
39
|
width: "10mm",
|
|
40
40
|
height: "10mm",
|
|
41
41
|
})
|
|
42
|
-
|
|
42
|
+
circuit.add(board)
|
|
43
43
|
|
|
44
44
|
const R1 = new Resistor({ resistance: "10k", footprint: "0402" })
|
|
45
|
+
const L1 = new Led({ footprint: "0402" })
|
|
45
46
|
board.add(R1)
|
|
46
|
-
|
|
47
|
-
// You can also add elements with React
|
|
48
|
-
board.add(<led footprint="0402" />)
|
|
47
|
+
board.add(L1)
|
|
49
48
|
|
|
50
49
|
const trace = new Trace({ width: "0.2mm" })
|
|
51
|
-
trace.connect(R1.output,
|
|
50
|
+
trace.connect(R1.output, L1.anode)
|
|
52
51
|
board.add(trace)
|
|
53
52
|
|
|
54
|
-
circuit.
|
|
53
|
+
circuit.getCircuitJson() // [{ type: "board", ...}, { type: "resistor", ...}, ...]
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
## Development
|
package/dist/index.js
CHANGED
|
@@ -4438,9 +4438,22 @@ function Trace__findConnectedPorts(trace) {
|
|
|
4438
4438
|
const { _parsedProps: props, parent } = trace;
|
|
4439
4439
|
if (!parent) throw new Error("Trace has no parent");
|
|
4440
4440
|
const portSelectors = trace.getTracePortPathSelectors();
|
|
4441
|
+
const resolveImplicitSinglePort = (selector) => {
|
|
4442
|
+
const hasExplicitPortToken = selector.lastIndexOf(".") > selector.lastIndexOf(" ");
|
|
4443
|
+
if (hasExplicitPortToken) return null;
|
|
4444
|
+
let targetComponent = trace.getSubcircuit().selectOne(selector);
|
|
4445
|
+
if (!targetComponent && !/[.#\[]/.test(selector)) {
|
|
4446
|
+
targetComponent = trace.getSubcircuit().selectOne(`.${selector}`);
|
|
4447
|
+
}
|
|
4448
|
+
if (!targetComponent) return null;
|
|
4449
|
+
const ports = targetComponent.children.filter(
|
|
4450
|
+
(c) => c.componentName === "Port"
|
|
4451
|
+
);
|
|
4452
|
+
return ports.length === 1 ? ports[0] : null;
|
|
4453
|
+
};
|
|
4441
4454
|
const portsWithSelectors = portSelectors.map((selector) => ({
|
|
4442
4455
|
selector,
|
|
4443
|
-
port: trace.getSubcircuit().selectOne(selector, { type: "port" }) ??
|
|
4456
|
+
port: trace.getSubcircuit().selectOne(selector, { type: "port" }) ?? resolveImplicitSinglePort(selector)
|
|
4444
4457
|
}));
|
|
4445
4458
|
for (const { selector, port } of portsWithSelectors) {
|
|
4446
4459
|
if (!port) {
|
|
@@ -18121,7 +18134,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
18121
18134
|
var package_default = {
|
|
18122
18135
|
name: "@tscircuit/core",
|
|
18123
18136
|
type: "module",
|
|
18124
|
-
version: "0.0.
|
|
18137
|
+
version: "0.0.1081",
|
|
18125
18138
|
types: "dist/index.d.ts",
|
|
18126
18139
|
main: "dist/index.js",
|
|
18127
18140
|
module: "dist/index.js",
|