@tscircuit/core 0.0.548 → 0.0.550

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
@@ -7458,6 +7458,7 @@ declare class NetLabel extends PrimitiveComponent<typeof netLabelProps> {
7458
7458
  };
7459
7459
  _getAnchorSide(): "top" | "bottom" | "left" | "right";
7460
7460
  _getConnectedPorts(): Port[];
7461
+ computeSchematicPropsTransform(): Matrix;
7461
7462
  doInitialSchematicPrimitiveRender(): void;
7462
7463
  _resolveConnectsTo(): string[] | undefined;
7463
7464
  _getNetName(): string;
package/dist/index.js CHANGED
@@ -7725,6 +7725,53 @@ function Group_doInitialPcbLayoutGrid(group) {
7725
7725
  }
7726
7726
  }
7727
7727
 
7728
+ // lib/utils/autorouting/getPresetAutoroutingConfig.ts
7729
+ function getPresetAutoroutingConfig(autorouterConfig) {
7730
+ const defaults = {
7731
+ serverUrl: "https://registry-api.tscircuit.com",
7732
+ serverMode: "job",
7733
+ serverCacheEnabled: true
7734
+ };
7735
+ if (typeof autorouterConfig === "object" && !autorouterConfig.preset) {
7736
+ return {
7737
+ local: !(autorouterConfig.serverUrl || autorouterConfig.serverMode || autorouterConfig.serverCacheEnabled),
7738
+ ...defaults,
7739
+ ...autorouterConfig
7740
+ };
7741
+ }
7742
+ const preset = typeof autorouterConfig === "object" ? autorouterConfig.preset : autorouterConfig;
7743
+ switch (preset) {
7744
+ case "auto-local":
7745
+ return {
7746
+ local: true,
7747
+ groupMode: "subcircuit"
7748
+ };
7749
+ case "sequential-trace":
7750
+ return {
7751
+ local: true,
7752
+ groupMode: "sequential-trace"
7753
+ };
7754
+ case "subcircuit":
7755
+ return {
7756
+ local: true,
7757
+ groupMode: "subcircuit"
7758
+ };
7759
+ case "auto-cloud":
7760
+ return {
7761
+ local: false,
7762
+ groupMode: "subcircuit",
7763
+ serverUrl: defaults.serverUrl,
7764
+ serverMode: defaults.serverMode,
7765
+ serverCacheEnabled: true
7766
+ };
7767
+ default:
7768
+ return {
7769
+ local: true,
7770
+ groupMode: "subcircuit"
7771
+ };
7772
+ }
7773
+ }
7774
+
7728
7775
  // lib/components/primitive-components/Group/Group.ts
7729
7776
  var Group = class extends NormalComponent {
7730
7777
  pcb_group_id = null;
@@ -8327,46 +8374,8 @@ var Group = class extends NormalComponent {
8327
8374
  };
8328
8375
  }
8329
8376
  _getAutorouterConfig() {
8330
- const defaults = {
8331
- serverUrl: "https://registry-api.tscircuit.com",
8332
- serverMode: "job",
8333
- serverCacheEnabled: true
8334
- };
8335
- const autorouter = this._parsedProps.autorouter || this._parsedProps.autorouter?.preset || this.getInheritedProperty("autorouter");
8336
- if (typeof autorouter === "object") {
8337
- return {
8338
- local: !(autorouter.serverUrl || autorouter.serverMode || autorouter.serverCacheEnabled),
8339
- ...defaults,
8340
- ...autorouter
8341
- };
8342
- }
8343
- if (autorouter === "auto-local")
8344
- return {
8345
- local: true,
8346
- groupMode: "subcircuit"
8347
- };
8348
- if (autorouter === "sequential-trace")
8349
- return {
8350
- local: true,
8351
- groupMode: "sequential-trace"
8352
- };
8353
- if (autorouter === "subcircuit")
8354
- return {
8355
- local: true,
8356
- groupMode: "subcircuit"
8357
- };
8358
- if (autorouter === "auto-cloud")
8359
- return {
8360
- local: false,
8361
- groupMode: "subcircuit",
8362
- serverUrl: defaults.serverUrl,
8363
- serverMode: defaults.serverMode,
8364
- serverCacheEnabled: true
8365
- };
8366
- return {
8367
- local: true,
8368
- groupMode: "subcircuit"
8369
- };
8377
+ const autorouter = this._parsedProps.autorouter || this.getInheritedProperty("autorouter");
8378
+ return getPresetAutoroutingConfig(autorouter);
8370
8379
  }
8371
8380
  /**
8372
8381
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
@@ -9492,6 +9501,11 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
9492
9501
 
9493
9502
  // lib/components/primitive-components/NetLabel.ts
9494
9503
  import { netLabelProps } from "@tscircuit/props";
9504
+ import {
9505
+ applyToPoint as applyToPoint7,
9506
+ identity as identity4,
9507
+ translate as translate6
9508
+ } from "transformation-matrix";
9495
9509
  var NetLabel = class extends PrimitiveComponent2 {
9496
9510
  source_net_label_id;
9497
9511
  get config() {
@@ -9532,6 +9546,21 @@ var NetLabel = class extends PrimitiveComponent2 {
9532
9546
  }
9533
9547
  return connectedPorts;
9534
9548
  }
9549
+ computeSchematicPropsTransform() {
9550
+ const { _parsedProps: props } = this;
9551
+ if (props.schX === void 0 && props.schY === void 0) {
9552
+ const connectedPorts = this._getConnectedPorts();
9553
+ if (connectedPorts.length > 0) {
9554
+ const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
9555
+ const parentCenter = applyToPoint7(
9556
+ this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
9557
+ { x: 0, y: 0 }
9558
+ );
9559
+ return translate6(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
9560
+ }
9561
+ }
9562
+ return super.computeSchematicPropsTransform();
9563
+ }
9535
9564
  doInitialSchematicPrimitiveRender() {
9536
9565
  if (this.root?.schematicDisabled) return;
9537
9566
  const { db } = this.root;
@@ -9788,7 +9817,7 @@ var Via = class extends PrimitiveComponent2 {
9788
9817
  };
9789
9818
 
9790
9819
  // lib/components/primitive-components/Cutout.ts
9791
- import { applyToPoint as applyToPoint7 } from "transformation-matrix";
9820
+ import { applyToPoint as applyToPoint8 } from "transformation-matrix";
9792
9821
  import { cutoutProps } from "@tscircuit/props";
9793
9822
  var Cutout = class extends PrimitiveComponent2 {
9794
9823
  pcb_cutout_id = null;
@@ -9829,7 +9858,7 @@ var Cutout = class extends PrimitiveComponent2 {
9829
9858
  } else if (props.shape === "polygon") {
9830
9859
  const transform = this._computePcbGlobalTransformBeforeLayout();
9831
9860
  const transformedPoints = props.points.map(
9832
- (p) => applyToPoint7(transform, p)
9861
+ (p) => applyToPoint8(transform, p)
9833
9862
  );
9834
9863
  const polygonData = {
9835
9864
  shape: "polygon",
@@ -10690,13 +10719,13 @@ var SchematicBox = class extends PrimitiveComponent2 {
10690
10719
  // lib/RootCircuit.ts
10691
10720
  import { su as su5 } from "@tscircuit/circuit-json-util";
10692
10721
  import { isValidElement as isValidElement2 } from "react";
10693
- import { identity as identity4 } from "transformation-matrix";
10722
+ import { identity as identity5 } from "transformation-matrix";
10694
10723
 
10695
10724
  // package.json
10696
10725
  var package_default = {
10697
10726
  name: "@tscircuit/core",
10698
10727
  type: "module",
10699
- version: "0.0.546",
10728
+ version: "0.0.549",
10700
10729
  types: "dist/index.d.ts",
10701
10730
  main: "dist/index.js",
10702
10731
  module: "dist/index.js",
@@ -10927,10 +10956,10 @@ var RootCircuit = class {
10927
10956
  throw new Error("project.preview is not yet implemented");
10928
10957
  }
10929
10958
  computeSchematicGlobalTransform() {
10930
- return identity4();
10959
+ return identity5();
10931
10960
  }
10932
10961
  _computePcbGlobalTransformBeforeLayout() {
10933
- return identity4();
10962
+ return identity5();
10934
10963
  }
10935
10964
  selectAll(selector) {
10936
10965
  this._guessRootComponent();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.548",
4
+ "version": "0.0.550",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",