@tscircuit/core 0.0.383 → 0.0.385

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
@@ -212,6 +212,7 @@ declare class RootCircuit {
212
212
  */
213
213
  _getBoard(): PrimitiveComponent & {
214
214
  boardThickness: number;
215
+ _connectedSchematicPortPairs: Set<string>;
215
216
  allLayers: LayerRef[];
216
217
  };
217
218
  _guessRootComponent(): void;
@@ -533,6 +534,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
533
534
  schematic_trace_id: string | null;
534
535
  _portsRoutedOnPcb: Port[];
535
536
  subcircuit_connectivity_map_key: string | null;
537
+ _traceConnectionHash: string | null;
536
538
  constructor(props: z.input<typeof traceProps>);
537
539
  get config(): {
538
540
  zodProps: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
@@ -766,6 +768,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
766
768
  */
767
769
  _isExplicitlyConnectedToNet(net: Net): boolean;
768
770
  doInitialCreateNetsFromProps(): void;
771
+ _computeTraceConnectionHash(): string | null;
769
772
  doInitialSourceTraceRender(): void;
770
773
  _insertErrorIfTraceIsOutsideBoard(mergedRoute: PcbTraceRoutePoint[], ports: Port[]): void;
771
774
  doInitialPcbTraceRender(): void;
@@ -1052,6 +1055,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1052
1055
  declare class Board extends Group<typeof boardProps> {
1053
1056
  pcb_board_id: string | null;
1054
1057
  _drcChecksComplete: boolean;
1058
+ _connectedSchematicPortPairs: Set<string>;
1055
1059
  get isSubcircuit(): boolean;
1056
1060
  get config(): {
1057
1061
  componentName: string;
package/dist/index.js CHANGED
@@ -3893,6 +3893,7 @@ var Trace2 = class extends PrimitiveComponent2 {
3893
3893
  schematic_trace_id = null;
3894
3894
  _portsRoutedOnPcb;
3895
3895
  subcircuit_connectivity_map_key = null;
3896
+ _traceConnectionHash = null;
3896
3897
  constructor(props) {
3897
3898
  super(props);
3898
3899
  this._portsRoutedOnPcb = [];
@@ -4011,6 +4012,15 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4011
4012
  doInitialCreateNetsFromProps() {
4012
4013
  createNetsFromProps(this, this.getTracePathNetSelectors());
4013
4014
  }
4015
+ _computeTraceConnectionHash() {
4016
+ const { allPortsFound, ports } = this._findConnectedPorts();
4017
+ if (!allPortsFound || !ports) return null;
4018
+ const sortedPorts = [...ports].sort(
4019
+ (a, b) => (a.pcb_port_id || "").localeCompare(b.pcb_port_id || "")
4020
+ );
4021
+ const allIds = sortedPorts.map((p) => p.pcb_port_id);
4022
+ return allIds.join(",");
4023
+ }
4014
4024
  doInitialSourceTraceRender() {
4015
4025
  const { db } = this.root;
4016
4026
  const { _parsedProps: props, parent } = this;
@@ -4020,6 +4030,15 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4020
4030
  }
4021
4031
  const { allPortsFound, portsWithSelectors: ports } = this._findConnectedPorts();
4022
4032
  if (!allPortsFound) return;
4033
+ this._traceConnectionHash = this._computeTraceConnectionHash();
4034
+ const existingTraces = db.source_trace.list();
4035
+ const existingTrace = existingTraces.find(
4036
+ (t) => t.subcircuit_connectivity_map_key === this.subcircuit_connectivity_map_key && t.connected_source_port_ids.sort().join(",") === this._traceConnectionHash
4037
+ );
4038
+ if (existingTrace) {
4039
+ this.source_trace_id = existingTrace.source_trace_id;
4040
+ return;
4041
+ }
4023
4042
  const nets = this._findConnectedNets().nets;
4024
4043
  const displayName = getTraceDisplayName({ ports, nets });
4025
4044
  const trace = db.source_trace.insert({
@@ -4476,6 +4495,14 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4476
4495
  const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
4477
4496
  const { netsWithSelectors } = this._findConnectedNets();
4478
4497
  if (!allPortsFound) return;
4498
+ const portIds = connectedPorts.map((p) => p.port.schematic_port_id).sort();
4499
+ const portPairKey = portIds.join(",");
4500
+ const board = this.root?._getBoard();
4501
+ if (board?._connectedSchematicPortPairs) {
4502
+ if (board._connectedSchematicPortPairs.has(portPairKey)) {
4503
+ return;
4504
+ }
4505
+ }
4479
4506
  if (this.props.schDisplayLabel && ("from" in this.props && "to" in this.props || "path" in this.props)) {
4480
4507
  this._doInitialSchematicTraceRenderWithDisplayLabel();
4481
4508
  return;
@@ -4626,6 +4653,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4626
4653
  junctions
4627
4654
  });
4628
4655
  this.schematic_trace_id = trace.schematic_trace_id;
4656
+ if (board?._connectedSchematicPortPairs)
4657
+ board._connectedSchematicPortPairs.add(portPairKey);
4629
4658
  }
4630
4659
  };
4631
4660
 
@@ -6506,6 +6535,7 @@ import { checkEachPcbTraceNonOverlapping as checkEachPcbTraceNonOverlapping2 } f
6506
6535
  var Board = class extends Group {
6507
6536
  pcb_board_id = null;
6508
6537
  _drcChecksComplete = false;
6538
+ _connectedSchematicPortPairs = /* @__PURE__ */ new Set();
6509
6539
  get isSubcircuit() {
6510
6540
  return true;
6511
6541
  }
@@ -7713,7 +7743,7 @@ import { identity as identity4 } from "transformation-matrix";
7713
7743
  var package_default = {
7714
7744
  name: "@tscircuit/core",
7715
7745
  type: "module",
7716
- version: "0.0.382",
7746
+ version: "0.0.384",
7717
7747
  types: "dist/index.d.ts",
7718
7748
  main: "dist/index.js",
7719
7749
  module: "dist/index.js",
@@ -7729,6 +7759,7 @@ var package_default = {
7729
7759
  format: "biome format . --write",
7730
7760
  "measure-bundle": "howfat -r table .",
7731
7761
  "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
7762
+ "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
7732
7763
  "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
7733
7764
  "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
7734
7765
  "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.383",
4
+ "version": "0.0.385",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -17,6 +17,7 @@
17
17
  "format": "biome format . --write",
18
18
  "measure-bundle": "howfat -r table .",
19
19
  "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
20
+ "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
20
21
  "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
21
22
  "build:benchmarking:watch": "chokidar \"./{benchmarking,lib}/**/*.{ts,tsx}\" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'",
22
23
  "start:benchmarking": "concurrently \"bun run build:benchmarking:watch\" \"live-server ./benchmarking-dist\""