@tscircuit/core 0.0.836 → 0.0.838
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 +143 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15487,7 +15487,7 @@ var inflatePcbComponent = (pcbElm, inflatorContext) => {
|
|
|
15487
15487
|
|
|
15488
15488
|
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceResistor.ts
|
|
15489
15489
|
function inflateSourceResistor(sourceElm, inflatorContext) {
|
|
15490
|
-
const { injectionDb, subcircuit } = inflatorContext;
|
|
15490
|
+
const { injectionDb, subcircuit, groupsMap } = inflatorContext;
|
|
15491
15491
|
const pcbElm = injectionDb.pcb_component.getWhere({
|
|
15492
15492
|
source_component_id: sourceElm.source_component_id
|
|
15493
15493
|
});
|
|
@@ -15504,9 +15504,134 @@ function inflateSourceResistor(sourceElm, inflatorContext) {
|
|
|
15504
15504
|
normalComponent: resistor
|
|
15505
15505
|
});
|
|
15506
15506
|
}
|
|
15507
|
-
|
|
15507
|
+
if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
|
|
15508
|
+
const group = groupsMap.get(sourceElm.source_group_id);
|
|
15509
|
+
group.add(resistor);
|
|
15510
|
+
} else {
|
|
15511
|
+
subcircuit.add(resistor);
|
|
15512
|
+
}
|
|
15513
|
+
}
|
|
15514
|
+
|
|
15515
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourcePort.ts
|
|
15516
|
+
function inflateSourcePort(sourcePort, inflatorContext) {
|
|
15517
|
+
const { injectionDb, subcircuit } = inflatorContext;
|
|
15518
|
+
if (sourcePort.source_component_id !== null) {
|
|
15519
|
+
return;
|
|
15520
|
+
}
|
|
15521
|
+
const pcbPortFromInjection = injectionDb.pcb_port.getWhere({
|
|
15522
|
+
source_port_id: sourcePort.source_port_id
|
|
15523
|
+
});
|
|
15524
|
+
const port = new Port({
|
|
15525
|
+
name: sourcePort.name,
|
|
15526
|
+
pinNumber: sourcePort.pin_number
|
|
15527
|
+
});
|
|
15528
|
+
subcircuit.add(port);
|
|
15529
|
+
port.source_port_id = sourcePort.source_port_id;
|
|
15530
|
+
const root = subcircuit.root;
|
|
15531
|
+
if (root && pcbPortFromInjection) {
|
|
15532
|
+
const { db } = root;
|
|
15533
|
+
const pcb_port = db.pcb_port.insert({
|
|
15534
|
+
pcb_component_id: void 0,
|
|
15535
|
+
layers: pcbPortFromInjection.layers,
|
|
15536
|
+
subcircuit_id: subcircuit.subcircuit_id ?? void 0,
|
|
15537
|
+
pcb_group_id: subcircuit.getGroup()?.pcb_group_id ?? void 0,
|
|
15538
|
+
x: pcbPortFromInjection.x,
|
|
15539
|
+
y: pcbPortFromInjection.y,
|
|
15540
|
+
source_port_id: sourcePort.source_port_id,
|
|
15541
|
+
is_board_pinout: false
|
|
15542
|
+
});
|
|
15543
|
+
port.pcb_port_id = pcb_port.pcb_port_id;
|
|
15544
|
+
}
|
|
15545
|
+
}
|
|
15546
|
+
|
|
15547
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceGroup.ts
|
|
15548
|
+
function inflateSourceGroup(sourceGroup, inflatorContext) {
|
|
15549
|
+
const { subcircuit, groupsMap } = inflatorContext;
|
|
15550
|
+
const group = new Group6({
|
|
15551
|
+
name: sourceGroup.name
|
|
15552
|
+
});
|
|
15553
|
+
group.source_group_id = sourceGroup.source_group_id;
|
|
15554
|
+
subcircuit.add(group);
|
|
15555
|
+
if (groupsMap) {
|
|
15556
|
+
groupsMap.set(sourceGroup.source_group_id, group);
|
|
15557
|
+
}
|
|
15558
|
+
return group;
|
|
15508
15559
|
}
|
|
15509
15560
|
|
|
15561
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceChip.ts
|
|
15562
|
+
var mapInternallyConnectedSourcePortIdsToPinLabels = (sourcePortIds, inflatorContext) => {
|
|
15563
|
+
if (!sourcePortIds || sourcePortIds.length === 0) return void 0;
|
|
15564
|
+
const { injectionDb } = inflatorContext;
|
|
15565
|
+
const mapped = sourcePortIds.map(
|
|
15566
|
+
(group) => group.map((sourcePortId) => {
|
|
15567
|
+
const port = injectionDb.source_port.get(
|
|
15568
|
+
sourcePortId
|
|
15569
|
+
);
|
|
15570
|
+
if (!port) return null;
|
|
15571
|
+
if (port.pin_number !== void 0 && port.pin_number !== null) {
|
|
15572
|
+
return `pin${port.pin_number}`;
|
|
15573
|
+
}
|
|
15574
|
+
return port.name;
|
|
15575
|
+
}).filter((value) => value !== null)
|
|
15576
|
+
).filter((group) => group.length > 0);
|
|
15577
|
+
return mapped.length > 0 ? mapped : void 0;
|
|
15578
|
+
};
|
|
15579
|
+
var inflateSourceChip = (sourceElm, inflatorContext) => {
|
|
15580
|
+
const { injectionDb, subcircuit, groupsMap } = inflatorContext;
|
|
15581
|
+
const pcbElm = injectionDb.pcb_component.getWhere({
|
|
15582
|
+
source_component_id: sourceElm.source_component_id
|
|
15583
|
+
});
|
|
15584
|
+
const schematicElm = injectionDb.schematic_component.getWhere({
|
|
15585
|
+
source_component_id: sourceElm.source_component_id
|
|
15586
|
+
});
|
|
15587
|
+
const cadElm = injectionDb.cad_component.getWhere({
|
|
15588
|
+
source_component_id: sourceElm.source_component_id
|
|
15589
|
+
});
|
|
15590
|
+
const internallyConnectedPins = mapInternallyConnectedSourcePortIdsToPinLabels(
|
|
15591
|
+
sourceElm.internally_connected_source_port_ids,
|
|
15592
|
+
inflatorContext
|
|
15593
|
+
);
|
|
15594
|
+
const chip = new Chip({
|
|
15595
|
+
name: sourceElm.name,
|
|
15596
|
+
manufacturerPartNumber: sourceElm.manufacturer_part_number,
|
|
15597
|
+
supplierPartNumbers: sourceElm.supplier_part_numbers ?? void 0,
|
|
15598
|
+
pinLabels: schematicElm?.port_labels ?? void 0,
|
|
15599
|
+
schWidth: schematicElm?.size?.width,
|
|
15600
|
+
schHeight: schematicElm?.size?.height,
|
|
15601
|
+
schPinSpacing: schematicElm?.pin_spacing,
|
|
15602
|
+
schX: schematicElm?.center?.x,
|
|
15603
|
+
schY: schematicElm?.center?.y,
|
|
15604
|
+
layer: pcbElm?.layer,
|
|
15605
|
+
pcbX: pcbElm?.center?.x,
|
|
15606
|
+
pcbY: pcbElm?.center?.y,
|
|
15607
|
+
pcbRotation: pcbElm?.rotation,
|
|
15608
|
+
doNotPlace: pcbElm?.do_not_place,
|
|
15609
|
+
obstructsWithinBounds: pcbElm?.obstructs_within_bounds,
|
|
15610
|
+
internallyConnectedPins
|
|
15611
|
+
});
|
|
15612
|
+
const footprint = cadElm?.footprinter_string ?? "soic8";
|
|
15613
|
+
if (footprint) {
|
|
15614
|
+
Object.assign(chip.props, { footprint });
|
|
15615
|
+
Object.assign(chip._parsedProps, { footprint });
|
|
15616
|
+
if (!cadElm) {
|
|
15617
|
+
;
|
|
15618
|
+
chip._addChildrenFromStringFootprint?.();
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15621
|
+
if (pcbElm) {
|
|
15622
|
+
inflatePcbComponent(pcbElm, {
|
|
15623
|
+
...inflatorContext,
|
|
15624
|
+
normalComponent: chip
|
|
15625
|
+
});
|
|
15626
|
+
}
|
|
15627
|
+
if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
|
|
15628
|
+
const group = groupsMap.get(sourceElm.source_group_id);
|
|
15629
|
+
group.add(chip);
|
|
15630
|
+
} else {
|
|
15631
|
+
subcircuit.add(chip);
|
|
15632
|
+
}
|
|
15633
|
+
};
|
|
15634
|
+
|
|
15510
15635
|
// lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
|
|
15511
15636
|
var Subcircuit = class extends Group6 {
|
|
15512
15637
|
constructor(props) {
|
|
@@ -15536,22 +15661,35 @@ var Subcircuit = class extends Group6 {
|
|
|
15536
15661
|
if (injectionCircuitJson && children?.length > 0) {
|
|
15537
15662
|
throw new Error("Subcircuit cannot have both circuitJson and children");
|
|
15538
15663
|
}
|
|
15539
|
-
const
|
|
15664
|
+
const groupsMap = /* @__PURE__ */ new Map();
|
|
15540
15665
|
const inflationCtx = {
|
|
15541
15666
|
injectionDb,
|
|
15542
|
-
subcircuit: this
|
|
15667
|
+
subcircuit: this,
|
|
15668
|
+
groupsMap
|
|
15543
15669
|
};
|
|
15670
|
+
const sourceGroups = injectionDb.source_group.list();
|
|
15671
|
+
for (const sourceGroup of sourceGroups) {
|
|
15672
|
+
inflateSourceGroup(sourceGroup, inflationCtx);
|
|
15673
|
+
}
|
|
15674
|
+
const sourceComponents = injectionDb.source_component.list();
|
|
15544
15675
|
for (const sourceComponent of sourceComponents) {
|
|
15545
15676
|
switch (sourceComponent.ftype) {
|
|
15546
15677
|
case "simple_resistor":
|
|
15547
15678
|
inflateSourceResistor(sourceComponent, inflationCtx);
|
|
15548
15679
|
break;
|
|
15680
|
+
case "simple_chip":
|
|
15681
|
+
inflateSourceChip(sourceComponent, inflationCtx);
|
|
15682
|
+
break;
|
|
15549
15683
|
default:
|
|
15550
15684
|
throw new Error(
|
|
15551
15685
|
`No inflator implemented for source component ftype: "${sourceComponent.ftype}"`
|
|
15552
15686
|
);
|
|
15553
15687
|
}
|
|
15554
15688
|
}
|
|
15689
|
+
const sourcePorts = injectionDb.source_port.list();
|
|
15690
|
+
for (const sourcePort of sourcePorts) {
|
|
15691
|
+
inflateSourcePort(sourcePort, inflationCtx);
|
|
15692
|
+
}
|
|
15555
15693
|
}
|
|
15556
15694
|
};
|
|
15557
15695
|
|
|
@@ -17565,7 +17703,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
17565
17703
|
var package_default = {
|
|
17566
17704
|
name: "@tscircuit/core",
|
|
17567
17705
|
type: "module",
|
|
17568
|
-
version: "0.0.
|
|
17706
|
+
version: "0.0.837",
|
|
17569
17707
|
types: "dist/index.d.ts",
|
|
17570
17708
|
main: "dist/index.js",
|
|
17571
17709
|
module: "dist/index.js",
|