@tscircuit/core 0.0.86 → 0.0.88

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
@@ -1,7 +1,6 @@
1
1
  import * as zod from 'zod';
2
2
  import { ZodType, z } from 'zod';
3
- import { AnySoupElement, PCBTraceError, PCBPlacementError, AnySourceComponent, RouteHintPoint } from '@tscircuit/soup';
4
- import { LayerRef } from 'circuit-json';
3
+ import { LayerRef, AnyCircuitElement, PCBTraceError, PCBPlacementError, AnySourceComponent, RouteHintPoint } from 'circuit-json';
5
4
  import { SoupUtilObjects } from '@tscircuit/soup-util';
6
5
  import { ReactElement } from 'react';
7
6
  import { Matrix } from 'transformation-matrix';
@@ -27,8 +26,8 @@ declare class Circuit {
27
26
  };
28
27
  _guessRootComponent(): void;
29
28
  render(): void;
30
- getSoup(): AnySoupElement[];
31
- getCircuitJson(): AnySoupElement[];
29
+ getSoup(): AnyCircuitElement[];
30
+ getCircuitJson(): AnyCircuitElement[];
32
31
  getSvg(options: {
33
32
  view: "pcb";
34
33
  layer?: string;
package/dist/index.js CHANGED
@@ -542,7 +542,7 @@ var PrimitiveComponent = class extends Renderable {
542
542
  if (typeof message === "string") {
543
543
  return super.renderError(message);
544
544
  }
545
- this.root?.db.pcb_error.insert(message);
545
+ this.root?.db.pcb_placement_error.insert(message);
546
546
  }
547
547
  getString() {
548
548
  const { lowercaseComponentName: cname, _parsedProps: props, parent } = this;
@@ -1401,7 +1401,7 @@ var PlatedHole = class extends PrimitiveComponent {
1401
1401
  const pcb_plated_hole = db.pcb_plated_hole.insert({
1402
1402
  pcb_component_id,
1403
1403
  pcb_port_id: this.matchedPort?.pcb_port_id,
1404
- // @ts-ignore - some issue with @tscircuit/soup union type
1404
+ // @ts-ignore - some issue with circuit-json union type
1405
1405
  outer_diameter: props.outerDiameter,
1406
1406
  hole_diameter: props.holeDiameter,
1407
1407
  shape: "circle",
@@ -1674,6 +1674,7 @@ var Net = class extends PrimitiveComponent {
1674
1674
  ]
1675
1675
  }
1676
1676
  ])
1677
+ // Remove as any when autorouting-dataset has been updated
1677
1678
  );
1678
1679
  const trace = solution[0];
1679
1680
  if (!trace) {
@@ -2344,6 +2345,21 @@ var mergeRoutes = (routes) => {
2344
2345
  merged.push(...next_route.reverse());
2345
2346
  }
2346
2347
  }
2348
+ for (let i = 1; i < merged.length - 1; i++) {
2349
+ const lastPoint = merged[i - 1];
2350
+ const currentPoint = merged[i];
2351
+ if (lastPoint.route_type !== "wire") continue;
2352
+ if (currentPoint.route_type !== "wire") continue;
2353
+ if (lastPoint.layer !== currentPoint.layer) {
2354
+ merged.splice(i, 0, {
2355
+ x: lastPoint.x,
2356
+ y: lastPoint.y,
2357
+ from_layer: lastPoint.layer,
2358
+ to_layer: currentPoint.layer,
2359
+ route_type: "via"
2360
+ });
2361
+ }
2362
+ }
2347
2363
  return merged;
2348
2364
  };
2349
2365
 
@@ -2615,11 +2631,13 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2615
2631
  );
2616
2632
  const [obstacles, errGettingObstacles] = tryNow(
2617
2633
  () => getObstaclesFromSoup(this.root.db.toArray())
2634
+ // Remove as any when autorouting-dataset gets updated
2618
2635
  );
2619
2636
  if (errGettingObstacles) {
2620
2637
  this.renderError({
2621
- type: "pcb_error",
2638
+ type: "pcb_trace_error",
2622
2639
  error_type: "pcb_trace_error",
2640
+ pcb_trace_error_id: this.pcb_trace_id,
2623
2641
  message: `Error getting obstacles for autorouting: ${errGettingObstacles.message}`,
2624
2642
  source_trace_id: this.source_trace_id,
2625
2643
  center: { x: 0, y: 0 },
@@ -2696,10 +2714,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2696
2714
  traces = ijump.solveAndMapToTraces();
2697
2715
  } catch (e) {
2698
2716
  this.renderError({
2699
- type: "pcb_error",
2717
+ type: "pcb_trace_error",
2718
+ pcb_trace_error_id: this.source_trace_id,
2700
2719
  error_type: "pcb_trace_error",
2701
2720
  message: `error solving route: ${e.message}`,
2702
- source_trace_id: this.source_trace_id,
2721
+ source_trace_id: this.pcb_trace_id,
2703
2722
  center: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 },
2704
2723
  pcb_port_ids: ports.map((p) => p.pcb_port_id),
2705
2724
  pcb_trace_id: this.pcb_trace_id,
@@ -2709,8 +2728,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2709
2728
  if (!traces) return;
2710
2729
  if (traces.length === 0) {
2711
2730
  this.renderError({
2712
- type: "pcb_error",
2731
+ type: "pcb_trace_error",
2713
2732
  error_type: "pcb_trace_error",
2733
+ pcb_trace_error_id: this.pcb_trace_id,
2714
2734
  message: `Could not find a route for ${this}`,
2715
2735
  source_trace_id: this.source_trace_id,
2716
2736
  center: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 },
@@ -2732,15 +2752,23 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2732
2752
  if (pcbPortA && trace.route[0].route_type === "wire") {
2733
2753
  trace.route[0].start_pcb_port_id = pcbPortA;
2734
2754
  }
2735
- if (pcbPortB && trace.route[0].route_type === "wire") {
2736
- trace.route[0].end_pcb_port_id = pcbPortB;
2755
+ const lastRoutePoint = trace.route[trace.route.length - 1];
2756
+ if (pcbPortB && lastRoutePoint.route_type === "wire") {
2757
+ lastRoutePoint.end_pcb_port_id = pcbPortB;
2737
2758
  }
2738
2759
  routes.push(trace.route);
2739
2760
  }
2740
2761
  const mergedRoute = mergeRoutes(routes);
2762
+ const pcb_trace = db.pcb_trace.insert({
2763
+ route: mergedRoute,
2764
+ source_trace_id: this.source_trace_id
2765
+ });
2766
+ this._portsRoutedOnPcb = ports;
2767
+ this.pcb_trace_id = pcb_trace.pcb_trace_id;
2741
2768
  for (const point of mergedRoute) {
2742
2769
  if (point.route_type === "via") {
2743
2770
  db.pcb_via.insert({
2771
+ pcb_trace_id: pcb_trace.pcb_trace_id,
2744
2772
  x: point.x,
2745
2773
  y: point.y,
2746
2774
  hole_diameter: 0.3,
@@ -2751,12 +2779,6 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2751
2779
  });
2752
2780
  }
2753
2781
  }
2754
- const pcb_trace = db.pcb_trace.insert({
2755
- route: mergedRoute,
2756
- source_trace_id: this.source_trace_id
2757
- });
2758
- this._portsRoutedOnPcb = ports;
2759
- this.pcb_trace_id = pcb_trace.pcb_trace_id;
2760
2782
  }
2761
2783
  doInitialSchematicTraceRender() {
2762
2784
  const { db } = this.root;
@@ -2970,7 +2992,7 @@ var Capacitor = class extends NormalComponent {
2970
2992
  import { chipProps } from "@tscircuit/props";
2971
2993
 
2972
2994
  // lib/utils/schematic/getAllDimensionsForSchematicBox.ts
2973
- import "@tscircuit/soup";
2995
+ import "circuit-json";
2974
2996
 
2975
2997
  // lib/utils/schematic/getSizeOfSidesFromPortArrangement.ts
2976
2998
  var hasExplicitPinMapping = (pa) => {
@@ -3238,7 +3260,7 @@ var underscorifyPortArrangement = (portArrangement) => {
3238
3260
  };
3239
3261
 
3240
3262
  // lib/soup/underscorifyPinStyles.ts
3241
- import "@tscircuit/soup";
3263
+ import "circuit-json";
3242
3264
  import "zod";
3243
3265
  var underscorifyPinStyles = (pinStyles) => {
3244
3266
  if (!pinStyles) return void 0;
@@ -3703,7 +3725,7 @@ var Circuit = class {
3703
3725
  "${e.message}"`
3704
3726
  );
3705
3727
  });
3706
- return circuitToSvg.circuitJsonToPcbSvg(this.getCircuitJson());
3728
+ return circuitToSvg.convertCircuitJsonToPcbSvg(this.getCircuitJson());
3707
3729
  }
3708
3730
  async preview(previewNameOrOpts) {
3709
3731
  const previewOpts = typeof previewNameOrOpts === "object" ? previewNameOrOpts : { previewName: previewNameOrOpts };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.86",
4
+ "version": "0.0.88",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "@types/react": "^18.3.3",
22
22
  "@types/react-reconciler": "^0.28.8",
23
23
  "bun-match-svg": "0.0.2",
24
- "circuit-to-svg": "^0.0.36",
24
+ "circuit-to-svg": "^0.0.37",
25
25
  "debug": "^4.3.6",
26
26
  "howfat": "^0.3.8",
27
27
  "looks-same": "^9.0.1",
@@ -35,10 +35,9 @@
35
35
  "@tscircuit/infgrid-ijump-astar": "^0.0.21",
36
36
  "@tscircuit/math-utils": "^0.0.4",
37
37
  "@tscircuit/props": "^0.0.65",
38
- "@tscircuit/soup": "^0.0.73",
39
- "@tscircuit/soup-util": "^0.0.28",
40
- "circuit-json": "^0.0.77",
41
- "circuit-json-to-connectivity-map": "^0.0.15",
38
+ "circuit-json": "^0.0.78",
39
+ "@tscircuit/soup-util": "^0.0.31",
40
+ "circuit-json-to-connectivity-map": "^0.0.17",
42
41
  "footprinter": "^0.0.44",
43
42
  "nanoid": "^5.0.7",
44
43
  "performance-now": "^2.1.0",