@tscircuit/core 0.0.1010 → 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.d.ts CHANGED
@@ -371,6 +371,7 @@ interface ISubcircuit extends PrimitiveComponent {
371
371
  _getSubcircuitLayerCount(): number;
372
372
  subcircuit_id: string | null;
373
373
  getNormalComponentNameMap?: () => Map<string, NormalComponent[]>;
374
+ _isInflatedFromCircuitJson: boolean;
374
375
  }
375
376
 
376
377
  interface SchematicSymbolBounds {
@@ -1653,6 +1654,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1653
1654
  schematic_group_id: string | null;
1654
1655
  subcircuit_id: string | null;
1655
1656
  _hasStartedAsyncAutorouting: boolean;
1657
+ _isInflatedFromCircuitJson: boolean;
1656
1658
  private _normalComponentNameMap;
1657
1659
  /**
1658
1660
  * Returns a cached map of component names to NormalComponent instances within this subcircuit.
package/dist/index.js CHANGED
@@ -2088,6 +2088,7 @@ var Net = class extends PrimitiveComponent2 {
2088
2088
  doInitialPcbRouteNetIslands() {
2089
2089
  if (this.root?.pcbDisabled) return;
2090
2090
  if (this.getSubcircuit()._parsedProps.routingDisabled) return;
2091
+ if (this.getSubcircuit()._isInflatedFromCircuitJson) return;
2091
2092
  if (this.getSubcircuit()._getAutorouterConfig().groupMode !== "sequential-trace")
2092
2093
  return;
2093
2094
  const { db } = this.root;
@@ -4681,7 +4682,7 @@ function getPortFromHints(hints, opts) {
4681
4682
  const pinNumber = getPinNumberFromLabels(hints);
4682
4683
  if (!pinNumber) return null;
4683
4684
  const aliasesFromHints = hints.filter(
4684
- (p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}`
4685
+ (p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}` && p.trim() !== ""
4685
4686
  );
4686
4687
  const aliases = [
4687
4688
  ...aliasesFromHints,
@@ -7013,6 +7014,9 @@ function Trace_doInitialPcbTraceRender(trace) {
7013
7014
  if (subcircuit._parsedProps.routingDisabled) {
7014
7015
  return;
7015
7016
  }
7017
+ if (subcircuit._isInflatedFromCircuitJson) {
7018
+ return;
7019
+ }
7016
7020
  const cachedRoute = subcircuit._parsedProps.pcbRouteCache?.pcbTraces;
7017
7021
  if (cachedRoute) {
7018
7022
  const pcb_trace2 = db.pcb_trace.insert({
@@ -9400,7 +9404,11 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
9400
9404
  const newPorts2 = [];
9401
9405
  for (const fpChild of fp2.children) {
9402
9406
  if (!fpChild.props.portHints) continue;
9403
- let portHintsList = fpChild.props.portHints;
9407
+ const filteredPortHints = fpChild.props.portHints.filter(
9408
+ (hint) => hint && hint.trim() !== ""
9409
+ );
9410
+ if (filteredPortHints.length === 0) continue;
9411
+ let portHintsList = filteredPortHints;
9404
9412
  const hasPinPrefix = portHintsList.some(
9405
9413
  (hint) => hint.startsWith("pin")
9406
9414
  );
@@ -14471,6 +14479,7 @@ var Group6 = class extends NormalComponent3 {
14471
14479
  schematic_group_id = null;
14472
14480
  subcircuit_id = null;
14473
14481
  _hasStartedAsyncAutorouting = false;
14482
+ _isInflatedFromCircuitJson = false;
14474
14483
  _normalComponentNameMap = null;
14475
14484
  /**
14476
14485
  * Returns a cached map of component names to NormalComponent instances within this subcircuit.
@@ -14965,6 +14974,7 @@ var Group6 = class extends NormalComponent3 {
14965
14974
  if (!this.isSubcircuit) return;
14966
14975
  if (this.root?.pcbDisabled) return;
14967
14976
  if (this.getInheritedProperty("routingDisabled")) return;
14977
+ if (this._isInflatedFromCircuitJson) return;
14968
14978
  if (this._shouldUseTraceByTraceRouting()) return;
14969
14979
  if (!this._areChildSubcircuitsRouted()) {
14970
14980
  debug11(
@@ -14985,6 +14995,7 @@ var Group6 = class extends NormalComponent3 {
14985
14995
  const debug11 = Debug13("tscircuit:core:updatePcbTraceRender");
14986
14996
  debug11(`[${this.getString()}] updating...`);
14987
14997
  if (!this.isSubcircuit) return;
14998
+ if (this._isInflatedFromCircuitJson) return;
14988
14999
  if (this._shouldRouteAsync() && this._hasTracesToRoute() && !this._hasStartedAsyncAutorouting) {
14989
15000
  if (this._areChildSubcircuitsRouted()) {
14990
15001
  debug11(
@@ -15156,6 +15167,7 @@ var Group6 = class extends NormalComponent3 {
15156
15167
  }
15157
15168
  _getPcbLayoutMode() {
15158
15169
  const props = this._parsedProps;
15170
+ if (this._isInflatedFromCircuitJson) return "none";
15159
15171
  if (props.pcbRelative) return "none";
15160
15172
  if (props.pcbLayout?.matchAdapt) return "match-adapt";
15161
15173
  if (props.pcbLayout?.flex) return "flex";
@@ -15527,22 +15539,24 @@ var Capacitor = class extends NormalComponent3 {
15527
15539
  }
15528
15540
  };
15529
15541
 
15530
- // lib/components/primitive-components/Group/Subcircuit/inflators/inflatePcbComponent.ts
15531
- import { compose as compose5, translate as translate6, rotate as rotate3, inverse } from "transformation-matrix";
15542
+ // lib/utils/extractPcbPrimitivesFromCircuitJson.ts
15532
15543
  import { transformPCBElements as transformPCBElements2 } from "@tscircuit/circuit-json-util";
15533
- var inflatePcbComponent = (pcbElm, inflatorContext) => {
15534
- const { injectionDb, normalComponent } = inflatorContext;
15535
- if (!normalComponent) return;
15536
- const componentCenter = pcbElm.center || { x: 0, y: 0 };
15537
- const componentRotation = pcbElm.rotation || 0;
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;
15538
15552
  const absoluteToComponentRelativeTransform = inverse(
15539
15553
  compose5(
15540
15554
  translate6(componentCenter.x, componentCenter.y),
15541
15555
  rotate3(componentRotation * Math.PI / 180)
15542
15556
  )
15543
15557
  );
15544
- const relativeElements = injectionDb.toArray().filter(
15545
- (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
15558
+ const relativeElements = db.toArray().filter(
15559
+ (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbComponent.pcb_component_id
15546
15560
  );
15547
15561
  const clonedRelativeElements = structuredClone(relativeElements);
15548
15562
  transformPCBElements2(
@@ -15551,11 +15565,23 @@ var inflatePcbComponent = (pcbElm, inflatorContext) => {
15551
15565
  );
15552
15566
  const components = createComponentsFromCircuitJson(
15553
15567
  {
15554
- componentName: normalComponent.name,
15568
+ componentName,
15555
15569
  componentRotation: "0deg"
15556
15570
  },
15557
15571
  clonedRelativeElements
15558
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
+ });
15559
15585
  normalComponent.addAll(components);
15560
15586
  };
15561
15587
 
@@ -15757,6 +15783,21 @@ var Chip = class extends NormalComponent3 {
15757
15783
  }
15758
15784
  };
15759
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
+
15760
15801
  // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceChip.ts
15761
15802
  var mapInternallyConnectedSourcePortIdsToPinLabels = (sourcePortIds, inflatorContext) => {
15762
15803
  if (!sourcePortIds || sourcePortIds.length === 0) return void 0;
@@ -15790,6 +15831,7 @@ var inflateSourceChip = (sourceElm, inflatorContext) => {
15790
15831
  sourceElm.internally_connected_source_port_ids,
15791
15832
  inflatorContext
15792
15833
  );
15834
+ const footprinterString = cadElm?.footprinter_string ?? null;
15793
15835
  const chip = new Chip({
15794
15836
  name: sourceElm.name,
15795
15837
  manufacturerPartNumber: sourceElm.manufacturer_part_number,
@@ -15808,20 +15850,18 @@ var inflateSourceChip = (sourceElm, inflatorContext) => {
15808
15850
  obstructsWithinBounds: pcbElm?.obstructs_within_bounds,
15809
15851
  internallyConnectedPins
15810
15852
  });
15811
- const footprint = cadElm?.footprinter_string ?? null;
15812
- if (footprint) {
15813
- Object.assign(chip.props, { footprint });
15814
- Object.assign(chip._parsedProps, { footprint });
15815
- if (!cadElm) {
15816
- ;
15817
- chip._addChildrenFromStringFootprint?.();
15818
- }
15853
+ if (footprinterString) {
15854
+ Object.assign(chip.props, { footprint: footprinterString });
15855
+ Object.assign(chip._parsedProps, { footprint: footprinterString });
15819
15856
  }
15820
15857
  if (pcbElm) {
15821
- inflatePcbComponent(pcbElm, {
15858
+ const footprint = inflateFootprintComponent(pcbElm, {
15822
15859
  ...inflatorContext,
15823
15860
  normalComponent: chip
15824
15861
  });
15862
+ if (footprint) {
15863
+ chip.add(footprint);
15864
+ }
15825
15865
  }
15826
15866
  if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
15827
15867
  const group = groupsMap.get(sourceElm.source_group_id);
@@ -16628,6 +16668,9 @@ var Board = class extends Group6 {
16628
16668
  }
16629
16669
  doInitialInflateSubcircuitCircuitJson() {
16630
16670
  const { circuitJson, children } = this._parsedProps;
16671
+ if (circuitJson) {
16672
+ this._isInflatedFromCircuitJson = true;
16673
+ }
16631
16674
  inflateCircuitJson(this, circuitJson, children);
16632
16675
  }
16633
16676
  doInitialPcbComponentRender() {
@@ -19012,6 +19055,9 @@ var Subcircuit = class extends Group6 {
19012
19055
  */
19013
19056
  doInitialInflateSubcircuitCircuitJson() {
19014
19057
  const { circuitJson, children } = this._parsedProps;
19058
+ if (circuitJson) {
19059
+ this._isInflatedFromCircuitJson = true;
19060
+ }
19015
19061
  inflateCircuitJson(this, circuitJson, children);
19016
19062
  }
19017
19063
  };
@@ -21914,7 +21960,7 @@ import { identity as identity5 } from "transformation-matrix";
21914
21960
  var package_default = {
21915
21961
  name: "@tscircuit/core",
21916
21962
  type: "module",
21917
- version: "0.0.1009",
21963
+ version: "0.0.1011",
21918
21964
  types: "dist/index.d.ts",
21919
21965
  main: "dist/index.js",
21920
21966
  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.1010",
4
+ "version": "0.0.1012",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",