@tscircuit/core 0.0.893 → 0.0.895

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
@@ -1365,6 +1365,7 @@ interface SubcircuitI {
1365
1365
  add(component: PrimitiveComponent): void;
1366
1366
  root: RootCircuit | null;
1367
1367
  getGroup(): IGroup | null;
1368
+ source_group_id: string | null;
1368
1369
  }
1369
1370
 
1370
1371
  declare class Board extends Group<typeof boardProps> implements BoardI, SubcircuitI {
package/dist/index.js CHANGED
@@ -14598,13 +14598,17 @@ var inflatePcbComponent = (pcbElm, inflatorContext) => {
14598
14598
  const relativeElements = injectionDb.toArray().filter(
14599
14599
  (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
14600
14600
  );
14601
- transformPCBElements2(relativeElements, absoluteToComponentRelativeTransform);
14601
+ const clonedRelativeElements = structuredClone(relativeElements);
14602
+ transformPCBElements2(
14603
+ clonedRelativeElements,
14604
+ absoluteToComponentRelativeTransform
14605
+ );
14602
14606
  const components = createComponentsFromCircuitJson(
14603
14607
  {
14604
14608
  componentName: normalComponent.name,
14605
14609
  componentRotation: "0deg"
14606
14610
  },
14607
- relativeElements
14611
+ clonedRelativeElements
14608
14612
  );
14609
14613
  normalComponent.addAll(components);
14610
14614
  };
@@ -14962,13 +14966,18 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
14962
14966
  function inflateSourceGroup(sourceGroup, inflatorContext) {
14963
14967
  const { subcircuit, groupsMap } = inflatorContext;
14964
14968
  const group = new Group6({
14965
- name: sourceGroup.name
14969
+ name: sourceGroup.name ?? `inflated_group_${sourceGroup.source_group_id}`
14966
14970
  });
14967
14971
  group.source_group_id = sourceGroup.source_group_id;
14968
- subcircuit.add(group);
14969
14972
  if (groupsMap) {
14970
14973
  groupsMap.set(sourceGroup.source_group_id, group);
14971
14974
  }
14975
+ if (sourceGroup.parent_source_group_id && groupsMap?.has(sourceGroup.parent_source_group_id)) {
14976
+ const parentGroup = groupsMap.get(sourceGroup.parent_source_group_id);
14977
+ parentGroup.add(group);
14978
+ } else {
14979
+ subcircuit.add(group);
14980
+ }
14972
14981
  return group;
14973
14982
  }
14974
14983
 
@@ -15190,14 +15199,17 @@ function inflateSourceResistor(sourceElm, inflatorContext) {
15190
15199
  }
15191
15200
 
15192
15201
  // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceTrace.ts
15193
- var getSelectorPath = (component, db) => {
15202
+ var getSelectorPath = (component, inflatorContext) => {
15203
+ const { injectionDb, subcircuit, groupsMap } = inflatorContext;
15194
15204
  const path_parts = [];
15195
15205
  let currentGroupId = component.source_group_id;
15196
- while (currentGroupId) {
15197
- const group = db.source_group.get(currentGroupId);
15198
- if (!group) break;
15199
- path_parts.unshift(`.${group.name}`);
15200
- currentGroupId = group.parent_source_group_id;
15206
+ while (currentGroupId && currentGroupId !== subcircuit.source_group_id) {
15207
+ const sourceGroup = injectionDb.source_group.get(currentGroupId);
15208
+ const groupInstance = groupsMap?.get(currentGroupId);
15209
+ if (!sourceGroup || !groupInstance) break;
15210
+ const groupName = groupInstance.props.name ?? groupInstance.fallbackUnassignedName;
15211
+ path_parts.unshift(`.${groupName}`);
15212
+ currentGroupId = sourceGroup.parent_source_group_id;
15201
15213
  }
15202
15214
  path_parts.push(`.${component.name}`);
15203
15215
  return path_parts.join(" > ");
@@ -15207,7 +15219,9 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
15207
15219
  const connectedSelectors = [];
15208
15220
  for (const sourcePortId of sourceTrace.connected_source_port_ids) {
15209
15221
  const sourcePort = injectionDb.source_port.get(sourcePortId);
15210
- if (!sourcePort) continue;
15222
+ if (!sourcePort) {
15223
+ continue;
15224
+ }
15211
15225
  let selector;
15212
15226
  if (sourcePort.source_component_id) {
15213
15227
  const sourceComponent = injectionDb.source_component.get(
@@ -15219,7 +15233,7 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
15219
15233
  name: sourceComponent.name,
15220
15234
  source_group_id: sourceComponent.source_group_id
15221
15235
  },
15222
- injectionDb
15236
+ inflatorContext
15223
15237
  );
15224
15238
  selector = `${path} > .${sourcePort.name}`;
15225
15239
  }
@@ -15236,7 +15250,9 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
15236
15250
  connectedSelectors.push(`net.${sourceNet.name}`);
15237
15251
  }
15238
15252
  }
15239
- if (connectedSelectors.length < 2) return;
15253
+ if (connectedSelectors.length < 2) {
15254
+ return;
15255
+ }
15240
15256
  const trace = new Trace3({
15241
15257
  path: connectedSelectors
15242
15258
  });
@@ -15522,7 +15538,9 @@ var Board = class extends Group6 {
15522
15538
  const pcbY = this._resolvePcbCoordinate(props.pcbY, "pcbY", {
15523
15539
  allowBoardVariables: false
15524
15540
  });
15525
- if (props.width && props.height || props.outline) return;
15541
+ const pcbBoard = db.pcb_board.get(this.pcb_board_id);
15542
+ if (pcbBoard?.width && pcbBoard?.height || pcbBoard?.outline && pcbBoard.outline.length > 0)
15543
+ return;
15526
15544
  let minX = Infinity;
15527
15545
  let minY = Infinity;
15528
15546
  let maxX = -Infinity;
@@ -15649,8 +15667,12 @@ var Board = class extends Group6 {
15649
15667
  if (this.root?.pcbDisabled) return;
15650
15668
  const { db } = this.root;
15651
15669
  const { _parsedProps: props } = this;
15652
- let computedWidth = props.width ?? 0;
15653
- let computedHeight = props.height ?? 0;
15670
+ const circuitJsonElements = props.circuitJson;
15671
+ const pcbBoardFromCircuitJson = circuitJsonElements?.find(
15672
+ (elm) => elm.type === "pcb_board"
15673
+ );
15674
+ let computedWidth = props.width ?? pcbBoardFromCircuitJson?.width ?? 0;
15675
+ let computedHeight = props.height ?? pcbBoardFromCircuitJson?.height ?? 0;
15654
15676
  const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15655
15677
  let center = {
15656
15678
  x: pcbX + (props.outlineOffsetX ?? 0),
@@ -19202,7 +19224,7 @@ import { identity as identity6 } from "transformation-matrix";
19202
19224
  var package_default = {
19203
19225
  name: "@tscircuit/core",
19204
19226
  type: "module",
19205
- version: "0.0.892",
19227
+ version: "0.0.894",
19206
19228
  types: "dist/index.d.ts",
19207
19229
  main: "dist/index.js",
19208
19230
  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.893",
4
+ "version": "0.0.895",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",