@tscircuit/core 0.0.1302 → 0.0.1304
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 +49 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5795,6 +5795,9 @@ var underscorifyPortArrangement = (portArrangement) => {
|
|
|
5795
5795
|
return void 0;
|
|
5796
5796
|
};
|
|
5797
5797
|
|
|
5798
|
+
// lib/utils/createComponentsFromCircuitJson.ts
|
|
5799
|
+
import { getUnitVectorFromDirection as getUnitVectorFromDirection2 } from "@tscircuit/math-utils";
|
|
5800
|
+
|
|
5798
5801
|
// lib/components/primitive-components/CourtyardCircle.ts
|
|
5799
5802
|
import { courtyardCircleProps } from "@tscircuit/props";
|
|
5800
5803
|
var CourtyardCircle = class extends PrimitiveComponent2 {
|
|
@@ -9328,6 +9331,18 @@ var calculateCcwRotation = (componentRotationStr, elementCcwRotation) => {
|
|
|
9328
9331
|
return normalizedRotation;
|
|
9329
9332
|
};
|
|
9330
9333
|
var optional = (value) => value ?? void 0;
|
|
9334
|
+
var getFacingDirectionFromSide = (side) => {
|
|
9335
|
+
switch (side) {
|
|
9336
|
+
case "left":
|
|
9337
|
+
case "right":
|
|
9338
|
+
return side;
|
|
9339
|
+
case "top":
|
|
9340
|
+
return "up";
|
|
9341
|
+
case "bottom":
|
|
9342
|
+
return "down";
|
|
9343
|
+
}
|
|
9344
|
+
return null;
|
|
9345
|
+
};
|
|
9331
9346
|
var createComponentsFromCircuitJson = ({
|
|
9332
9347
|
componentName,
|
|
9333
9348
|
componentRotation,
|
|
@@ -9337,6 +9352,7 @@ var createComponentsFromCircuitJson = ({
|
|
|
9337
9352
|
}, circuitJson) => {
|
|
9338
9353
|
const components = [];
|
|
9339
9354
|
const schematicSymbolsByImportedId = /* @__PURE__ */ new Map();
|
|
9355
|
+
const schematicComponentsByImportedId = /* @__PURE__ */ new Map();
|
|
9340
9356
|
for (const elm of circuitJson) {
|
|
9341
9357
|
if (elm.type !== "schematic_symbol") continue;
|
|
9342
9358
|
const schematicSymbol = new SymbolComponent({
|
|
@@ -9345,6 +9361,10 @@ var createComponentsFromCircuitJson = ({
|
|
|
9345
9361
|
schematicSymbolsByImportedId.set(elm.schematic_symbol_id, schematicSymbol);
|
|
9346
9362
|
components.push(schematicSymbol);
|
|
9347
9363
|
}
|
|
9364
|
+
for (const elm of circuitJson) {
|
|
9365
|
+
if (elm.type !== "schematic_component") continue;
|
|
9366
|
+
schematicComponentsByImportedId.set(elm.schematic_component_id, elm);
|
|
9367
|
+
}
|
|
9348
9368
|
const addSchematicPrimitive = (elm, primitive) => {
|
|
9349
9369
|
const schematicSymbolId = elm.schematic_symbol_id;
|
|
9350
9370
|
const parentSymbol = typeof schematicSymbolId === "string" ? schematicSymbolsByImportedId.get(schematicSymbolId) : void 0;
|
|
@@ -9886,6 +9906,33 @@ var createComponentsFromCircuitJson = ({
|
|
|
9886
9906
|
fillColor: elm.fill_color
|
|
9887
9907
|
})
|
|
9888
9908
|
);
|
|
9909
|
+
} else if (elm.type === "schematic_port") {
|
|
9910
|
+
const schematicComponentId = elm.schematic_component_id;
|
|
9911
|
+
if (typeof schematicComponentId !== "string") continue;
|
|
9912
|
+
const schematicComponent = schematicComponentsByImportedId.get(schematicComponentId);
|
|
9913
|
+
const schematicSymbolId = schematicComponent?.schematic_symbol_id;
|
|
9914
|
+
const parentSymbol = typeof schematicSymbolId === "string" ? schematicSymbolsByImportedId.get(schematicSymbolId) : void 0;
|
|
9915
|
+
if (parentSymbol && schematicComponent?.is_box_with_pins === true && elm.center && elm.side_of_component) {
|
|
9916
|
+
const distance19 = elm.distance_from_component_edge;
|
|
9917
|
+
const facingDirection = getFacingDirectionFromSide(
|
|
9918
|
+
elm.side_of_component
|
|
9919
|
+
);
|
|
9920
|
+
if (!facingDirection) continue;
|
|
9921
|
+
const directionVector = getUnitVectorFromDirection2(facingDirection);
|
|
9922
|
+
const portCenter = {
|
|
9923
|
+
x: elm.center.x + directionVector.x * distance19,
|
|
9924
|
+
y: elm.center.y + directionVector.y * distance19
|
|
9925
|
+
};
|
|
9926
|
+
parentSymbol.add(
|
|
9927
|
+
new SchematicLine({
|
|
9928
|
+
x1: elm.center.x,
|
|
9929
|
+
y1: elm.center.y,
|
|
9930
|
+
x2: portCenter.x,
|
|
9931
|
+
y2: portCenter.y,
|
|
9932
|
+
isDashed: false
|
|
9933
|
+
})
|
|
9934
|
+
);
|
|
9935
|
+
}
|
|
9889
9936
|
}
|
|
9890
9937
|
}
|
|
9891
9938
|
return components;
|
|
@@ -23381,7 +23428,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
23381
23428
|
var package_default = {
|
|
23382
23429
|
name: "@tscircuit/core",
|
|
23383
23430
|
type: "module",
|
|
23384
|
-
version: "0.0.
|
|
23431
|
+
version: "0.0.1303",
|
|
23385
23432
|
types: "dist/index.d.ts",
|
|
23386
23433
|
main: "dist/index.js",
|
|
23387
23434
|
module: "dist/index.js",
|
|
@@ -23431,7 +23478,7 @@ var package_default = {
|
|
|
23431
23478
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
23432
23479
|
"@tscircuit/props": "^0.0.545",
|
|
23433
23480
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
23434
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
23481
|
+
"@tscircuit/schematic-trace-solver": "^0.0.63",
|
|
23435
23482
|
"@tscircuit/solver-utils": "^0.0.3",
|
|
23436
23483
|
"@tscircuit/soup-util": "^0.0.41",
|
|
23437
23484
|
"@types/bun": "^1.2.16",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1304",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
52
52
|
"@tscircuit/props": "^0.0.545",
|
|
53
53
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
54
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
54
|
+
"@tscircuit/schematic-trace-solver": "^0.0.63",
|
|
55
55
|
"@tscircuit/solver-utils": "^0.0.3",
|
|
56
56
|
"@tscircuit/soup-util": "^0.0.41",
|
|
57
57
|
"@types/bun": "^1.2.16",
|