@tscircuit/core 0.0.1011 → 0.0.1012
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 +54 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4682,7 +4682,7 @@ function getPortFromHints(hints, opts) {
|
|
|
4682
4682
|
const pinNumber = getPinNumberFromLabels(hints);
|
|
4683
4683
|
if (!pinNumber) return null;
|
|
4684
4684
|
const aliasesFromHints = hints.filter(
|
|
4685
|
-
(p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}`
|
|
4685
|
+
(p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}` && p.trim() !== ""
|
|
4686
4686
|
);
|
|
4687
4687
|
const aliases = [
|
|
4688
4688
|
...aliasesFromHints,
|
|
@@ -9404,7 +9404,11 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
9404
9404
|
const newPorts2 = [];
|
|
9405
9405
|
for (const fpChild of fp2.children) {
|
|
9406
9406
|
if (!fpChild.props.portHints) continue;
|
|
9407
|
-
|
|
9407
|
+
const filteredPortHints = fpChild.props.portHints.filter(
|
|
9408
|
+
(hint) => hint && hint.trim() !== ""
|
|
9409
|
+
);
|
|
9410
|
+
if (filteredPortHints.length === 0) continue;
|
|
9411
|
+
let portHintsList = filteredPortHints;
|
|
9408
9412
|
const hasPinPrefix = portHintsList.some(
|
|
9409
9413
|
(hint) => hint.startsWith("pin")
|
|
9410
9414
|
);
|
|
@@ -15535,22 +15539,24 @@ var Capacitor = class extends NormalComponent3 {
|
|
|
15535
15539
|
}
|
|
15536
15540
|
};
|
|
15537
15541
|
|
|
15538
|
-
// lib/
|
|
15539
|
-
import { compose as compose5, translate as translate6, rotate as rotate3, inverse } from "transformation-matrix";
|
|
15542
|
+
// lib/utils/extractPcbPrimitivesFromCircuitJson.ts
|
|
15540
15543
|
import { transformPCBElements as transformPCBElements2 } from "@tscircuit/circuit-json-util";
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
|
|
15545
|
-
|
|
15544
|
+
import { compose as compose5, inverse, rotate as rotate3, translate as translate6 } from "transformation-matrix";
|
|
15545
|
+
var extractPcbPrimitivesFromCircuitJson = ({
|
|
15546
|
+
pcbComponent,
|
|
15547
|
+
db,
|
|
15548
|
+
componentName
|
|
15549
|
+
}) => {
|
|
15550
|
+
const componentCenter = pcbComponent.center || { x: 0, y: 0 };
|
|
15551
|
+
const componentRotation = pcbComponent.rotation || 0;
|
|
15546
15552
|
const absoluteToComponentRelativeTransform = inverse(
|
|
15547
15553
|
compose5(
|
|
15548
15554
|
translate6(componentCenter.x, componentCenter.y),
|
|
15549
15555
|
rotate3(componentRotation * Math.PI / 180)
|
|
15550
15556
|
)
|
|
15551
15557
|
);
|
|
15552
|
-
const relativeElements =
|
|
15553
|
-
(elm) => "pcb_component_id" in elm && elm.pcb_component_id ===
|
|
15558
|
+
const relativeElements = db.toArray().filter(
|
|
15559
|
+
(elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbComponent.pcb_component_id
|
|
15554
15560
|
);
|
|
15555
15561
|
const clonedRelativeElements = structuredClone(relativeElements);
|
|
15556
15562
|
transformPCBElements2(
|
|
@@ -15559,11 +15565,23 @@ var inflatePcbComponent = (pcbElm, inflatorContext) => {
|
|
|
15559
15565
|
);
|
|
15560
15566
|
const components = createComponentsFromCircuitJson(
|
|
15561
15567
|
{
|
|
15562
|
-
componentName
|
|
15568
|
+
componentName,
|
|
15563
15569
|
componentRotation: "0deg"
|
|
15564
15570
|
},
|
|
15565
15571
|
clonedRelativeElements
|
|
15566
15572
|
);
|
|
15573
|
+
return components;
|
|
15574
|
+
};
|
|
15575
|
+
|
|
15576
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflatePcbComponent.ts
|
|
15577
|
+
var inflatePcbComponent = (pcbElm, inflatorContext) => {
|
|
15578
|
+
const { injectionDb, normalComponent } = inflatorContext;
|
|
15579
|
+
if (!normalComponent) return;
|
|
15580
|
+
const components = extractPcbPrimitivesFromCircuitJson({
|
|
15581
|
+
pcbComponent: pcbElm,
|
|
15582
|
+
db: injectionDb,
|
|
15583
|
+
componentName: normalComponent.name
|
|
15584
|
+
});
|
|
15567
15585
|
normalComponent.addAll(components);
|
|
15568
15586
|
};
|
|
15569
15587
|
|
|
@@ -15765,6 +15783,21 @@ var Chip = class extends NormalComponent3 {
|
|
|
15765
15783
|
}
|
|
15766
15784
|
};
|
|
15767
15785
|
|
|
15786
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateFootprintComponent.ts
|
|
15787
|
+
var inflateFootprintComponent = (pcbElm, inflatorContext) => {
|
|
15788
|
+
const { injectionDb, normalComponent } = inflatorContext;
|
|
15789
|
+
if (!normalComponent) return null;
|
|
15790
|
+
const primitives = extractPcbPrimitivesFromCircuitJson({
|
|
15791
|
+
pcbComponent: pcbElm,
|
|
15792
|
+
db: injectionDb,
|
|
15793
|
+
componentName: normalComponent.name
|
|
15794
|
+
});
|
|
15795
|
+
if (primitives.length === 0) return null;
|
|
15796
|
+
const footprint = new Footprint({});
|
|
15797
|
+
footprint.addAll(primitives);
|
|
15798
|
+
return footprint;
|
|
15799
|
+
};
|
|
15800
|
+
|
|
15768
15801
|
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceChip.ts
|
|
15769
15802
|
var mapInternallyConnectedSourcePortIdsToPinLabels = (sourcePortIds, inflatorContext) => {
|
|
15770
15803
|
if (!sourcePortIds || sourcePortIds.length === 0) return void 0;
|
|
@@ -15798,6 +15831,7 @@ var inflateSourceChip = (sourceElm, inflatorContext) => {
|
|
|
15798
15831
|
sourceElm.internally_connected_source_port_ids,
|
|
15799
15832
|
inflatorContext
|
|
15800
15833
|
);
|
|
15834
|
+
const footprinterString = cadElm?.footprinter_string ?? null;
|
|
15801
15835
|
const chip = new Chip({
|
|
15802
15836
|
name: sourceElm.name,
|
|
15803
15837
|
manufacturerPartNumber: sourceElm.manufacturer_part_number,
|
|
@@ -15816,20 +15850,18 @@ var inflateSourceChip = (sourceElm, inflatorContext) => {
|
|
|
15816
15850
|
obstructsWithinBounds: pcbElm?.obstructs_within_bounds,
|
|
15817
15851
|
internallyConnectedPins
|
|
15818
15852
|
});
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
Object.assign(chip.
|
|
15822
|
-
Object.assign(chip._parsedProps, { footprint });
|
|
15823
|
-
if (!cadElm) {
|
|
15824
|
-
;
|
|
15825
|
-
chip._addChildrenFromStringFootprint?.();
|
|
15826
|
-
}
|
|
15853
|
+
if (footprinterString) {
|
|
15854
|
+
Object.assign(chip.props, { footprint: footprinterString });
|
|
15855
|
+
Object.assign(chip._parsedProps, { footprint: footprinterString });
|
|
15827
15856
|
}
|
|
15828
15857
|
if (pcbElm) {
|
|
15829
|
-
|
|
15858
|
+
const footprint = inflateFootprintComponent(pcbElm, {
|
|
15830
15859
|
...inflatorContext,
|
|
15831
15860
|
normalComponent: chip
|
|
15832
15861
|
});
|
|
15862
|
+
if (footprint) {
|
|
15863
|
+
chip.add(footprint);
|
|
15864
|
+
}
|
|
15833
15865
|
}
|
|
15834
15866
|
if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
|
|
15835
15867
|
const group = groupsMap.get(sourceElm.source_group_id);
|
|
@@ -21928,7 +21960,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
21928
21960
|
var package_default = {
|
|
21929
21961
|
name: "@tscircuit/core",
|
|
21930
21962
|
type: "module",
|
|
21931
|
-
version: "0.0.
|
|
21963
|
+
version: "0.0.1011",
|
|
21932
21964
|
types: "dist/index.d.ts",
|
|
21933
21965
|
main: "dist/index.js",
|
|
21934
21966
|
module: "dist/index.js",
|