@tscircuit/core 0.0.155 → 0.0.157

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
@@ -9,7 +9,7 @@ import { Matrix } from 'transformation-matrix';
9
9
  import { SoupUtilObjects } from '@tscircuit/soup-util';
10
10
  import * as _tscircuit_layout from '@tscircuit/layout';
11
11
 
12
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "PcbComponentSizeCalculation", "CadModelRender"];
12
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "PcbComponentSizeCalculation", "CadModelRender"];
13
13
  type RenderPhase = (typeof orderedRenderPhases)[number];
14
14
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
15
15
  type RenderPhaseStates = Record<RenderPhase, {
@@ -351,11 +351,17 @@ declare class Net extends PrimitiveComponent<typeof netProps> {
351
351
  renderError(message: Parameters<typeof PrimitiveComponent.prototype.renderError>[0]): void;
352
352
  }
353
353
 
354
- declare class Trace extends PrimitiveComponent<typeof traceProps> {
354
+ interface TraceI extends PrimitiveComponent<typeof traceProps> {
355
+ source_trace_id: string | null;
356
+ subcircuit_connectivity_map_key: string | null;
357
+ }
358
+
359
+ declare class Trace extends PrimitiveComponent<typeof traceProps> implements TraceI {
355
360
  source_trace_id: string | null;
356
361
  pcb_trace_id: string | null;
357
362
  schematic_trace_id: string | null;
358
363
  _portsRoutedOnPcb: Port[];
364
+ subcircuit_connectivity_map_key: string | null;
359
365
  constructor(props: z.input<typeof traceProps>);
360
366
  get config(): {
361
367
  zodProps: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
@@ -841,6 +847,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
841
847
  };
842
848
  doInitialCreateTraceHintsFromProps(): void;
843
849
  _getSimpleRouteJsonFromPcbTraces(): SimpleRouteJson;
850
+ doInitialSourceAddConnectivityMapKey(): void;
844
851
  doInitialPcbTraceRender(): void;
845
852
  updatePcbTraceRender(): void;
846
853
  doInitialSchematicLayout(): void;
package/dist/index.js CHANGED
@@ -62,6 +62,7 @@ var orderedRenderPhases = [
62
62
  "PortDiscovery",
63
63
  "PortMatching",
64
64
  "SourceTraceRender",
65
+ "SourceAddConnectivityMapKey",
65
66
  "SchematicComponentRender",
66
67
  "SchematicPortRender",
67
68
  "SchematicLayout",
@@ -1654,7 +1655,7 @@ var Port = class extends PrimitiveComponent {
1654
1655
  const matchedPcbElm = this.matchedComponents.find((c) => c.isPcbPrimitive);
1655
1656
  if (!matchedPcbElm) {
1656
1657
  throw new Error(
1657
- `Port ${this} has no matched pcb component, can't get global schematic position`
1658
+ `Port ${this} has no matched pcb component, can't get global pcb position`
1658
1659
  );
1659
1660
  }
1660
1661
  return matchedPcbElm?._getGlobalPcbPositionBeforeLayout() ?? { x: 0, y: 0 };
@@ -2047,6 +2048,14 @@ var getAllDimensionsForSchematicBox = (params) => {
2047
2048
  sideLengths.bottom + params.schPinSpacing * 2
2048
2049
  );
2049
2050
  }
2051
+ const labelWidth = params.pinLabels ? Math.max(
2052
+ ...Object.values(params.pinLabels).map(
2053
+ (label) => label.length * 0.1
2054
+ // Estimated text width
2055
+ )
2056
+ ) : 0;
2057
+ const LABEL_PADDING = 1.1;
2058
+ schWidth = Math.max(schWidth, labelWidth + LABEL_PADDING);
2050
2059
  let schHeight = params.schHeight;
2051
2060
  if (!schHeight) {
2052
2061
  schHeight = Math.max(
@@ -2805,7 +2814,8 @@ var NormalComponent = class extends PrimitiveComponent {
2805
2814
  schPinSpacing: pinSpacing,
2806
2815
  schPinStyle: props.schPinStyle,
2807
2816
  pinCount,
2808
- schPortArrangement: this._getSchematicPortArrangement()
2817
+ schPortArrangement: this._getSchematicPortArrangement(),
2818
+ pinLabels: props.pinLabels
2809
2819
  });
2810
2820
  return dimensions;
2811
2821
  }
@@ -2929,6 +2939,7 @@ var TraceHint = class extends PrimitiveComponent {
2929
2939
  // lib/components/primitive-components/Group/Group.ts
2930
2940
  import * as SAL from "@tscircuit/schematic-autolayout";
2931
2941
  import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
2942
+ import { ConnectivityMap } from "circuit-json-to-connectivity-map";
2932
2943
  var Group = class extends NormalComponent {
2933
2944
  _asyncAutoroutingResult = null;
2934
2945
  get config() {
@@ -3001,6 +3012,35 @@ var Group = class extends NormalComponent {
3001
3012
  minTraceWidth: this._parsedProps.minTraceWidth ?? 0.1
3002
3013
  };
3003
3014
  }
3015
+ doInitialSourceAddConnectivityMapKey() {
3016
+ if (!this.isSubcircuit) return;
3017
+ const { db } = this.root;
3018
+ const traces = this.selectAll("trace");
3019
+ const connMap = new ConnectivityMap({});
3020
+ connMap.addConnections(
3021
+ traces.map((t) => {
3022
+ const source_trace = db.source_trace.get(
3023
+ t.source_trace_id
3024
+ );
3025
+ if (!source_trace) return null;
3026
+ return [
3027
+ source_trace.source_trace_id,
3028
+ ...source_trace.connected_source_port_ids,
3029
+ ...source_trace.connected_source_net_ids
3030
+ ];
3031
+ }).filter((c) => c !== null)
3032
+ );
3033
+ for (const trace of traces) {
3034
+ if (!trace.source_trace_id) continue;
3035
+ const connNetId = connMap.getNetConnectedToId(trace.source_trace_id);
3036
+ if (!connNetId) continue;
3037
+ const { name: subcircuitName } = this._parsedProps;
3038
+ trace.subcircuit_connectivity_map_key = `${subcircuitName ?? `unnamedsubcircuit${this._renderId}`}_${connNetId}`;
3039
+ db.source_trace.update(trace.source_trace_id, {
3040
+ subcircuit_connectivity_map_key: trace.subcircuit_connectivity_map_key
3041
+ });
3042
+ }
3043
+ }
3004
3044
  doInitialPcbTraceRender() {
3005
3045
  if (this._shouldUseTraceByTraceRouting()) return;
3006
3046
  if (this.props.autorouter?.serverUrl) {
@@ -3484,6 +3524,7 @@ var Trace = class extends PrimitiveComponent {
3484
3524
  pcb_trace_id = null;
3485
3525
  schematic_trace_id = null;
3486
3526
  _portsRoutedOnPcb;
3527
+ subcircuit_connectivity_map_key = null;
3487
3528
  constructor(props) {
3488
3529
  super(props);
3489
3530
  this._portsRoutedOnPcb = [];
@@ -3957,7 +3998,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
3957
3998
  );
3958
3999
  const trace = db.schematic_trace.insert({
3959
4000
  source_trace_id: this.source_trace_id,
3960
- edges
4001
+ edges,
4002
+ junctions: []
3961
4003
  });
3962
4004
  this.schematic_trace_id = trace.schematic_trace_id;
3963
4005
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.155",
4
+ "version": "0.0.157",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -43,9 +43,9 @@
43
43
  "@tscircuit/props": "^0.0.86",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.5",
45
45
  "@tscircuit/soup-util": "^0.0.33",
46
- "circuit-json": "^0.0.97",
46
+ "circuit-json": "^0.0.98",
47
47
  "circuit-json-to-connectivity-map": "^0.0.17",
48
- "circuit-to-svg": "^0.0.62",
48
+ "circuit-to-svg": "^0.0.64",
49
49
  "format-si-unit": "^0.0.2",
50
50
  "nanoid": "^5.0.7",
51
51
  "performance-now": "^2.1.0",