@tscircuit/core 0.0.887 → 0.0.888

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 +53 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16436,17 +16436,29 @@ import "@tscircuit/props";
16436
16436
  import { cju } from "@tscircuit/circuit-json-util";
16437
16437
 
16438
16438
  // lib/components/primitive-components/Group/Subcircuit/inflators/inflatePcbComponent.ts
16439
+ import { compose as compose5, translate as translate6, rotate as rotate3, inverse } from "transformation-matrix";
16440
+ import { transformPCBElements as transformPCBElements2 } from "@tscircuit/circuit-json-util";
16439
16441
  var inflatePcbComponent = (pcbElm, inflatorContext) => {
16440
16442
  const { injectionDb, normalComponent } = inflatorContext;
16441
16443
  if (!normalComponent) return;
16444
+ const componentCenter = pcbElm.center || { x: 0, y: 0 };
16445
+ const componentRotation = pcbElm.rotation || 0;
16446
+ const absoluteToComponentRelativeTransform = inverse(
16447
+ compose5(
16448
+ translate6(componentCenter.x, componentCenter.y),
16449
+ rotate3(componentRotation * Math.PI / 180)
16450
+ )
16451
+ );
16452
+ const relativeElements = injectionDb.toArray().filter(
16453
+ (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
16454
+ );
16455
+ transformPCBElements2(relativeElements, absoluteToComponentRelativeTransform);
16442
16456
  const components = createComponentsFromCircuitJson(
16443
16457
  {
16444
16458
  componentName: normalComponent.name,
16445
16459
  componentRotation: "0deg"
16446
16460
  },
16447
- injectionDb.toArray().filter(
16448
- (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
16449
- )
16461
+ relativeElements
16450
16462
  );
16451
16463
  normalComponent.addAll(components);
16452
16464
  };
@@ -16462,7 +16474,13 @@ function inflateSourceResistor(sourceElm, inflatorContext) {
16462
16474
  });
16463
16475
  const resistor = new Resistor({
16464
16476
  name: sourceElm.name,
16465
- resistance: sourceElm.resistance
16477
+ resistance: sourceElm.resistance,
16478
+ layer: pcbElm?.layer,
16479
+ pcbX: pcbElm?.center?.x,
16480
+ pcbY: pcbElm?.center?.y,
16481
+ pcbRotation: pcbElm?.rotation,
16482
+ doNotPlace: pcbElm?.do_not_place,
16483
+ obstructsWithinBounds: pcbElm?.obstructs_within_bounds
16466
16484
  });
16467
16485
  if (pcbElm) {
16468
16486
  inflatePcbComponent(pcbElm, {
@@ -16609,7 +16627,13 @@ function inflateSourceCapacitor(sourceElm, inflatorContext) {
16609
16627
  });
16610
16628
  const capacitor = new Capacitor({
16611
16629
  name: sourceElm.name,
16612
- capacitance: sourceElm.capacitance
16630
+ capacitance: sourceElm.capacitance,
16631
+ layer: pcbElm?.layer,
16632
+ pcbX: pcbElm?.center?.x,
16633
+ pcbY: pcbElm?.center?.y,
16634
+ pcbRotation: pcbElm?.rotation,
16635
+ doNotPlace: pcbElm?.do_not_place,
16636
+ obstructsWithinBounds: pcbElm?.obstructs_within_bounds
16613
16637
  });
16614
16638
  if (pcbElm) {
16615
16639
  inflatePcbComponent(pcbElm, {
@@ -16674,7 +16698,13 @@ function inflateSourceInductor(sourceElm, inflatorContext) {
16674
16698
  });
16675
16699
  const inductor = new Inductor({
16676
16700
  name: sourceElm.name,
16677
- inductance: sourceElm.inductance
16701
+ inductance: sourceElm.inductance,
16702
+ layer: pcbElm?.layer,
16703
+ pcbX: pcbElm?.center?.x,
16704
+ pcbY: pcbElm?.center?.y,
16705
+ pcbRotation: pcbElm?.rotation,
16706
+ doNotPlace: pcbElm?.do_not_place,
16707
+ obstructsWithinBounds: pcbElm?.obstructs_within_bounds
16678
16708
  });
16679
16709
  if (pcbElm) {
16680
16710
  inflatePcbComponent(pcbElm, {
@@ -16700,7 +16730,13 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
16700
16730
  source_component_id: sourceElm.source_component_id
16701
16731
  });
16702
16732
  const diode = new Diode({
16703
- name: sourceElm.name
16733
+ name: sourceElm.name,
16734
+ layer: pcbElm?.layer,
16735
+ pcbX: pcbElm?.center?.x,
16736
+ pcbY: pcbElm?.center?.y,
16737
+ pcbRotation: pcbElm?.rotation,
16738
+ doNotPlace: pcbElm?.do_not_place,
16739
+ obstructsWithinBounds: pcbElm?.obstructs_within_bounds
16704
16740
  });
16705
16741
  if (pcbElm) {
16706
16742
  inflatePcbComponent(pcbElm, {
@@ -16827,7 +16863,13 @@ function inflateSourceTransistor(sourceElm, inflatorContext) {
16827
16863
  });
16828
16864
  const transistor = new Transistor({
16829
16865
  name: sourceElm.name,
16830
- type: sourceElm.transistor_type
16866
+ type: sourceElm.transistor_type,
16867
+ layer: pcbElm?.layer,
16868
+ pcbX: pcbElm?.center?.x,
16869
+ pcbY: pcbElm?.center?.y,
16870
+ pcbRotation: pcbElm?.rotation,
16871
+ doNotPlace: pcbElm?.do_not_place,
16872
+ obstructsWithinBounds: pcbElm?.obstructs_within_bounds
16831
16873
  });
16832
16874
  if (pcbElm) {
16833
16875
  inflatePcbComponent(pcbElm, {
@@ -17035,7 +17077,7 @@ import { netLabelProps } from "@tscircuit/props";
17035
17077
  import {
17036
17078
  applyToPoint as applyToPoint17,
17037
17079
  identity as identity5,
17038
- translate as translate6
17080
+ translate as translate7
17039
17081
  } from "transformation-matrix";
17040
17082
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
17041
17083
  var NetLabel = class extends PrimitiveComponent2 {
@@ -17088,7 +17130,7 @@ var NetLabel = class extends PrimitiveComponent2 {
17088
17130
  this.parent?.computeSchematicGlobalTransform?.() ?? identity5(),
17089
17131
  { x: 0, y: 0 }
17090
17132
  );
17091
- return translate6(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
17133
+ return translate7(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
17092
17134
  }
17093
17135
  }
17094
17136
  return super.computeSchematicPropsTransform();
@@ -18820,7 +18862,7 @@ import { identity as identity6 } from "transformation-matrix";
18820
18862
  var package_default = {
18821
18863
  name: "@tscircuit/core",
18822
18864
  type: "module",
18823
- version: "0.0.886",
18865
+ version: "0.0.887",
18824
18866
  types: "dist/index.d.ts",
18825
18867
  main: "dist/index.js",
18826
18868
  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.887",
4
+ "version": "0.0.888",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",