@tscircuit/core 0.0.835 → 0.0.837

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.
Files changed (2) hide show
  1. package/dist/index.js +107 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3019,12 +3019,12 @@ var calculateCcwRotation = (componentRotationStr, elementCcwRotation) => {
3019
3019
  var createComponentsFromCircuitJson = ({
3020
3020
  componentName,
3021
3021
  componentRotation,
3022
- footprint,
3022
+ footprinterString,
3023
3023
  pinLabels,
3024
3024
  pcbPinLabels
3025
- }, soup) => {
3025
+ }, circuitJson) => {
3026
3026
  const components = [];
3027
- for (const elm of soup) {
3027
+ for (const elm of circuitJson) {
3028
3028
  if (elm.type === "pcb_smtpad" && elm.shape === "rect") {
3029
3029
  components.push(
3030
3030
  new SmtPad({
@@ -3209,11 +3209,11 @@ var createComponentsFromCircuitJson = ({
3209
3209
  componentRotation,
3210
3210
  elm.ccw_rotation
3211
3211
  );
3212
- if (footprint.includes("pinrow") && elm.text.includes("PIN")) {
3212
+ if (footprinterString?.includes("pinrow") && elm.text.includes("PIN")) {
3213
3213
  components.push(
3214
3214
  createPinrowSilkscreenText({
3215
3215
  elm,
3216
- pinLabels: pcbPinLabels ?? pinLabels,
3216
+ pinLabels: pcbPinLabels ?? pinLabels ?? {},
3217
3217
  layer: elm.layer,
3218
3218
  readableRotation: ccwRotation,
3219
3219
  anchorAlignment: elm.anchor_alignment
@@ -7378,7 +7378,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7378
7378
  {
7379
7379
  componentName: component.name,
7380
7380
  componentRotation: pcbRotation,
7381
- footprint: footprintUrl,
7381
+ footprinterString: footprintUrl,
7382
7382
  pinLabels,
7383
7383
  pcbPinLabels
7384
7384
  },
@@ -7422,7 +7422,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7422
7422
  {
7423
7423
  componentName: component.name,
7424
7424
  componentRotation: pcbRotation,
7425
- footprint: url,
7425
+ footprinterString: url,
7426
7426
  pinLabels,
7427
7427
  pcbPinLabels
7428
7428
  },
@@ -7477,7 +7477,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7477
7477
  {
7478
7478
  componentName: component.name,
7479
7479
  componentRotation: pcbRotation,
7480
- footprint,
7480
+ footprinterString: footprint,
7481
7481
  pinLabels,
7482
7482
  pcbPinLabels
7483
7483
  },
@@ -7523,7 +7523,7 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
7523
7523
  {
7524
7524
  componentName: component.name,
7525
7525
  componentRotation: pcbRotation,
7526
- footprint: "",
7526
+ footprinterString: "",
7527
7527
  pinLabels,
7528
7528
  pcbPinLabels
7529
7529
  },
@@ -7912,7 +7912,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
7912
7912
  {
7913
7913
  componentName: this.name ?? this.componentName,
7914
7914
  componentRotation: pcbRotation,
7915
- footprint,
7915
+ footprinterString: footprint,
7916
7916
  pinLabels,
7917
7917
  pcbPinLabels
7918
7918
  },
@@ -15469,21 +15469,93 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
15469
15469
  import "@tscircuit/props";
15470
15470
  import { cju } from "@tscircuit/circuit-json-util";
15471
15471
 
15472
+ // lib/components/primitive-components/Group/Subcircuit/inflators/inflatePcbComponent.ts
15473
+ var inflatePcbComponent = (pcbElm, inflatorContext) => {
15474
+ const { injectionDb, normalComponent } = inflatorContext;
15475
+ if (!normalComponent) return;
15476
+ const components = createComponentsFromCircuitJson(
15477
+ {
15478
+ componentName: normalComponent.name,
15479
+ componentRotation: "0deg"
15480
+ },
15481
+ injectionDb.toArray().filter(
15482
+ (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
15483
+ )
15484
+ );
15485
+ normalComponent.addAll(components);
15486
+ };
15487
+
15472
15488
  // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceResistor.ts
15473
- function inflateSourceResistor(sourceElm, context) {
15474
- const { injectionDb, subcircuit } = context;
15489
+ function inflateSourceResistor(sourceElm, inflatorContext) {
15490
+ const { injectionDb, subcircuit, groupsMap } = inflatorContext;
15475
15491
  const pcbElm = injectionDb.pcb_component.getWhere({
15476
- name: sourceElm.name
15492
+ source_component_id: sourceElm.source_component_id
15477
15493
  });
15478
15494
  const cadElm = injectionDb.cad_component.getWhere({
15479
- name: sourceElm.name
15495
+ source_component_id: sourceElm.source_component_id
15480
15496
  });
15481
15497
  const resistor = new Resistor({
15482
15498
  name: sourceElm.name,
15483
- resistance: sourceElm.resistance,
15484
- footprint: cadElm?.footprinter_string
15499
+ resistance: sourceElm.resistance
15485
15500
  });
15486
- subcircuit.add(resistor);
15501
+ if (pcbElm) {
15502
+ inflatePcbComponent(pcbElm, {
15503
+ ...inflatorContext,
15504
+ normalComponent: resistor
15505
+ });
15506
+ }
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;
15487
15559
  }
15488
15560
 
15489
15561
  // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
@@ -15509,17 +15581,23 @@ var Subcircuit = class extends Group6 {
15509
15581
  * - Add components to groups in the appropriate hierarchy
15510
15582
  */
15511
15583
  doInitialInflateSubcircuitCircuitJson() {
15512
- const { circuitJson, children } = this._parsedProps;
15513
- if (!circuitJson) return;
15514
- const { db } = this.root;
15515
- if (circuitJson && children?.length > 0) {
15584
+ const { circuitJson: injectionCircuitJson, children } = this._parsedProps;
15585
+ if (!injectionCircuitJson) return;
15586
+ const injectionDb = cju(injectionCircuitJson);
15587
+ if (injectionCircuitJson && children?.length > 0) {
15516
15588
  throw new Error("Subcircuit cannot have both circuitJson and children");
15517
15589
  }
15518
- const sourceComponents = cju(circuitJson).source_component.list();
15590
+ const groupsMap = /* @__PURE__ */ new Map();
15519
15591
  const inflationCtx = {
15520
- injectionDb: db,
15521
- subcircuit: this
15592
+ injectionDb,
15593
+ subcircuit: this,
15594
+ groupsMap
15522
15595
  };
15596
+ const sourceGroups = injectionDb.source_group.list();
15597
+ for (const sourceGroup of sourceGroups) {
15598
+ inflateSourceGroup(sourceGroup, inflationCtx);
15599
+ }
15600
+ const sourceComponents = injectionDb.source_component.list();
15523
15601
  for (const sourceComponent of sourceComponents) {
15524
15602
  switch (sourceComponent.ftype) {
15525
15603
  case "simple_resistor":
@@ -15531,6 +15609,10 @@ var Subcircuit = class extends Group6 {
15531
15609
  );
15532
15610
  }
15533
15611
  }
15612
+ const sourcePorts = injectionDb.source_port.list();
15613
+ for (const sourcePort of sourcePorts) {
15614
+ inflateSourcePort(sourcePort, inflationCtx);
15615
+ }
15534
15616
  }
15535
15617
  };
15536
15618
 
@@ -17544,7 +17626,7 @@ import { identity as identity6 } from "transformation-matrix";
17544
17626
  var package_default = {
17545
17627
  name: "@tscircuit/core",
17546
17628
  type: "module",
17547
- version: "0.0.834",
17629
+ version: "0.0.836",
17548
17630
  types: "dist/index.d.ts",
17549
17631
  main: "dist/index.js",
17550
17632
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.835",
4
+ "version": "0.0.837",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",