@tscircuit/core 0.0.214 → 0.0.216

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
@@ -428,6 +428,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
428
428
  name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
429
429
  } | undefined;
430
430
  }>, "many">>;
431
+ schDisplayLabel: z.ZodOptional<z.ZodString>;
431
432
  }, {
432
433
  path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<{
433
434
  getPortSelector: () => string;
@@ -451,6 +452,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
451
452
  via?: boolean | undefined;
452
453
  to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
453
454
  }[] | undefined;
455
+ schDisplayLabel?: string | undefined;
454
456
  }, {
455
457
  path: (string | {
456
458
  getPortSelector: () => string;
@@ -470,6 +472,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
470
472
  name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
471
473
  } | undefined;
472
474
  }[] | undefined;
475
+ schDisplayLabel?: string | undefined;
473
476
  }>, z.ZodObject<z.objectUtil.extendShape<{
474
477
  key: z.ZodOptional<z.ZodString>;
475
478
  thickness: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
@@ -512,6 +515,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
512
515
  name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
513
516
  } | undefined;
514
517
  }>, "many">>;
518
+ schDisplayLabel: z.ZodOptional<z.ZodString>;
515
519
  }, {
516
520
  from: z.ZodUnion<[z.ZodString, z.ZodType<{
517
521
  getPortSelector: () => string;
@@ -543,6 +547,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
543
547
  via?: boolean | undefined;
544
548
  to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
545
549
  }[] | undefined;
550
+ schDisplayLabel?: string | undefined;
546
551
  }, {
547
552
  from: string | {
548
553
  getPortSelector: () => string;
@@ -565,6 +570,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
565
570
  name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
566
571
  } | undefined;
567
572
  }[] | undefined;
573
+ schDisplayLabel?: string | undefined;
568
574
  }>]>;
569
575
  componentName: string;
570
576
  };
@@ -607,6 +613,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
607
613
  doInitialCreateNetsFromProps(): void;
608
614
  doInitialSourceTraceRender(): void;
609
615
  doInitialPcbTraceRender(): void;
616
+ _doInitialSchematicTraceRenderWithDisplayLabel(): void;
610
617
  doInitialSchematicTraceRender(): void;
611
618
  }
612
619
 
package/dist/index.js CHANGED
@@ -4567,6 +4567,73 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4567
4567
  }
4568
4568
  }
4569
4569
  }
4570
+ _doInitialSchematicTraceRenderWithDisplayLabel() {
4571
+ if (this.root?.schematicDisabled) return;
4572
+ const { db } = this.root;
4573
+ const { _parsedProps: props, parent } = this;
4574
+ if (!parent) throw new Error("Trace has no parent");
4575
+ const { allPortsFound, portsWithSelectors: connectedPorts } = this._findConnectedPorts();
4576
+ if (!allPortsFound) return;
4577
+ const portsWithPosition = connectedPorts.map(({ port }) => ({
4578
+ port,
4579
+ position: port._getGlobalSchematicPositionAfterLayout(),
4580
+ schematic_port_id: port.schematic_port_id ?? void 0,
4581
+ facingDirection: port.facingDirection
4582
+ }));
4583
+ if (portsWithPosition.length < 2) {
4584
+ throw new Error("Expected at least two ports in portsWithPosition.");
4585
+ }
4586
+ let fromPortName;
4587
+ let toPortName;
4588
+ const fromAnchorPos = portsWithPosition[0].position;
4589
+ const fromPort = portsWithPosition[0].port;
4590
+ if ("path" in this.props) {
4591
+ if (this.props.path.length !== 2) {
4592
+ throw new Error("Invalid 'path': Must contain exactly two elements.");
4593
+ }
4594
+ ;
4595
+ [fromPortName, toPortName] = this.props.path;
4596
+ } else {
4597
+ if (!("from" in this.props && "to" in this.props)) {
4598
+ throw new Error("Missing 'from' or 'to' properties in props.");
4599
+ }
4600
+ fromPortName = this.props.from;
4601
+ toPortName = this.props.to;
4602
+ }
4603
+ if (!fromPort.source_port_id) {
4604
+ throw new Error(
4605
+ `Missing source_port_id for the 'from' port (${fromPortName}).`
4606
+ );
4607
+ }
4608
+ const toAnchorPos = portsWithPosition[1].position;
4609
+ const toPort = portsWithPosition[1].port;
4610
+ if (!toPort.source_port_id) {
4611
+ throw new Error(
4612
+ `Missing source_port_id for the 'to' port (${toPortName}).`
4613
+ );
4614
+ }
4615
+ const existingFromNetLabel = db.schematic_net_label.list().find((label) => label.source_net_id === fromPort.source_port_id);
4616
+ const existingToNetLabel = db.schematic_net_label.list().find((label) => label.source_net_id === toPort.source_port_id);
4617
+ if (existingFromNetLabel && existingFromNetLabel.text !== this.props.schDisplayLabel || existingToNetLabel && existingToNetLabel?.text !== this.props.schDisplayLabel) {
4618
+ throw new Error(
4619
+ `Cannot create net label for port ${existingFromNetLabel ? fromPortName : toPortName} because it already has a net label with text "${existingFromNetLabel ? existingFromNetLabel.text : existingToNetLabel?.text}".`
4620
+ );
4621
+ }
4622
+ db.schematic_net_label.insert({
4623
+ text: this.props.schDisplayLabel,
4624
+ source_net_id: fromPort.source_port_id,
4625
+ anchor_position: fromAnchorPos,
4626
+ center: fromAnchorPos,
4627
+ anchor_side: getEnteringEdgeFromDirection(fromPort.facingDirection) ?? "bottom"
4628
+ });
4629
+ db.schematic_net_label.insert({
4630
+ text: this.props.schDisplayLabel,
4631
+ source_net_id: toPort.source_port_id,
4632
+ anchor_position: toAnchorPos,
4633
+ center: toAnchorPos,
4634
+ anchor_side: getEnteringEdgeFromDirection(toPort.facingDirection) ?? "bottom"
4635
+ });
4636
+ }
4570
4637
  doInitialSchematicTraceRender() {
4571
4638
  if (this.root?.schematicDisabled) return;
4572
4639
  const { db } = this.root;
@@ -4580,6 +4647,10 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4580
4647
  name: this.source_trace_id,
4581
4648
  pointsToConnect: []
4582
4649
  };
4650
+ if (this.props.schDisplayLabel && ("from" in this.props && "to" in this.props || "path" in this.props)) {
4651
+ this._doInitialSchematicTraceRenderWithDisplayLabel();
4652
+ return;
4653
+ }
4583
4654
  for (const elm of db.toArray()) {
4584
4655
  if (elm.type === "schematic_component") {
4585
4656
  obstacles.push({
@@ -4701,6 +4772,9 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4701
4772
  firstDominantDirection
4702
4773
  })
4703
4774
  );
4775
+ if (!this.source_trace_id) {
4776
+ throw new Error("Missing source_trace_id for schematic trace insertion.");
4777
+ }
4704
4778
  const trace = db.schematic_trace.insert({
4705
4779
  source_trace_id: this.source_trace_id,
4706
4780
  edges,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.214",
4
+ "version": "0.0.216",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "@types/react": "^18.3.3",
27
27
  "@types/react-reconciler": "^0.28.8",
28
28
  "bun-match-svg": "0.0.8",
29
- "circuit-to-svg": "^0.0.84",
29
+ "circuit-to-svg": "^0.0.87",
30
30
  "debug": "^4.3.6",
31
31
  "howfat": "^0.3.8",
32
32
  "looks-same": "^9.0.1",
@@ -38,15 +38,14 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@lume/kiwi": "^0.4.3",
41
- "@tscircuit/footprinter": "^0.0.89",
41
+ "@tscircuit/footprinter": "^0.0.91",
42
42
  "@tscircuit/infgrid-ijump-astar": "^0.0.24",
43
43
  "@tscircuit/math-utils": "^0.0.5",
44
- "@tscircuit/props": "^0.0.107",
44
+ "@tscircuit/props": "^0.0.108",
45
45
  "@tscircuit/schematic-autolayout": "^0.0.6",
46
46
  "@tscircuit/soup-util": "^0.0.41",
47
47
  "circuit-json": "^0.0.108",
48
48
  "circuit-json-to-connectivity-map": "^0.0.17",
49
- "circuit-to-svg": "0.0.84",
50
49
  "format-si-unit": "^0.0.2",
51
50
  "nanoid": "^5.0.7",
52
51
  "performance-now": "^2.1.0",