@tscircuit/core 0.0.1373 → 0.0.1375

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
@@ -79128,6 +79128,7 @@ declare class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> {
79128
79128
 
79129
79129
  declare class NetLabel extends PrimitiveComponent<typeof netLabelProps> {
79130
79130
  source_net_label_id?: string;
79131
+ schematic_net_label_id?: string;
79131
79132
  get config(): {
79132
79133
  componentName: string;
79133
79134
  zodProps: zod.ZodObject<{
package/dist/index.js CHANGED
@@ -3226,11 +3226,11 @@ var getOtherSchematicTraces = ({
3226
3226
  const otherSourceTrace = db.source_trace.get(
3227
3227
  otherSchematicTrace.source_trace_id
3228
3228
  );
3229
- const isSameNet = otherSourceTrace?.subcircuit_connectivity_map_key === mySourceTrace.subcircuit_connectivity_map_key;
3230
- if (differentNetOnly && isSameNet) {
3229
+ const isSameNet2 = otherSourceTrace?.subcircuit_connectivity_map_key === mySourceTrace.subcircuit_connectivity_map_key;
3230
+ if (differentNetOnly && isSameNet2) {
3231
3231
  continue;
3232
3232
  }
3233
- if (sameNetOnly && !isSameNet) {
3233
+ if (sameNetOnly && !isSameNet2) {
3234
3234
  continue;
3235
3235
  }
3236
3236
  traces.push(otherSchematicTrace);
@@ -19957,8 +19957,8 @@ function computeJunctions(traces, opts = {}) {
19957
19957
  for (let j = i + 1; j < traces.length; j++) {
19958
19958
  const B = traces[j];
19959
19959
  const BEnds = endpointsByTrace[j];
19960
- const isSameNet = A.connectivity_key !== void 0 && A.connectivity_key === B.connectivity_key;
19961
- if (isSameNet) {
19960
+ const isSameNet2 = A.connectivity_key !== void 0 && A.connectivity_key === B.connectivity_key;
19961
+ if (isSameNet2) {
19962
19962
  for (const eA of A.edges) {
19963
19963
  for (const eB of B.edges) {
19964
19964
  const p = segmentIntersection(eA.from, eA.to, eB.from, eB.to, tol);
@@ -20374,9 +20374,43 @@ var getNetNameFromPorts = (ports) => {
20374
20374
  return { name: netName, wasAssignedDisplayLabel: false };
20375
20375
  };
20376
20376
 
20377
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getNetLabelTextBounds.ts
20378
+ var NET_LABEL_TEXT_HEIGHT = 0.18;
20379
+ var getNetLabelTextBounds = ({
20380
+ center,
20381
+ text
20382
+ }) => {
20383
+ const width = getSchematicNetLabelTextWidth({ text });
20384
+ const halfWidth = width / 2;
20385
+ const halfHeight = NET_LABEL_TEXT_HEIGHT / 2;
20386
+ return {
20387
+ minX: center.x - halfWidth,
20388
+ maxX: center.x + halfWidth,
20389
+ minY: center.y - halfHeight,
20390
+ maxY: center.y + halfHeight
20391
+ };
20392
+ };
20393
+
20377
20394
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
20378
20395
  import Debug11 from "debug";
20396
+ import { doBoundsOverlap as doBoundsOverlap2 } from "@tscircuit/math-utils";
20379
20397
  var debug9 = Debug11("Group_doInitialSchematicTraceRender");
20398
+ var isSameNet = (label, sourceNet) => label.source_net_id != null && label.source_net_id === sourceNet.source_net_id;
20399
+ var isUserDefinedNetLabelRedundantWithPlacement = (label, solverPlacement) => {
20400
+ if (!isSameNet(label, solverPlacement.sourceNet)) {
20401
+ return false;
20402
+ }
20403
+ if (label.schematicPortIds.some(
20404
+ (id) => solverPlacement.schematicPortIds.has(id)
20405
+ )) {
20406
+ return true;
20407
+ }
20408
+ if (!label.center) return false;
20409
+ return doBoundsOverlap2(
20410
+ getNetLabelTextBounds({ center: label.center, text: label.text }),
20411
+ solverPlacement.bounds
20412
+ );
20413
+ };
20380
20414
  function applyNetLabelPlacements(args) {
20381
20415
  const {
20382
20416
  group,
@@ -20423,6 +20457,15 @@ function applyNetLabelPlacements(args) {
20423
20457
  }
20424
20458
  }
20425
20459
  const globalConnMap = solver.mspConnectionPairSolver.globalConnMap;
20460
+ const userDefinedNetLabels = group.selectAll("netlabel").map((label) => {
20461
+ if (!label.schematic_net_label_id) return null;
20462
+ const dbLabel = db.schematic_net_label.get(label.schematic_net_label_id);
20463
+ if (!dbLabel) return null;
20464
+ return {
20465
+ ...dbLabel,
20466
+ schematicPortIds: label._getConnectedPorts().map((port) => port.schematic_port_id).filter((id) => Boolean(id))
20467
+ };
20468
+ }).filter((label) => label !== null);
20426
20469
  for (const placement of dedupedNetLabelPlacements) {
20427
20470
  debug9(`processing placement: ${placement.netId}`);
20428
20471
  const placementUserNetId = globalConnMap.getIdsConnectedToNet(placement.globalConnNetId).find((id) => userNetIdToConnKey.get(id));
@@ -20467,6 +20510,19 @@ function applyNetLabelPlacements(args) {
20467
20510
  anchor_side,
20468
20511
  text: text2
20469
20512
  });
20513
+ if (!isPowerOrGroundNet) {
20514
+ const solverPlacement = {
20515
+ sourceNet,
20516
+ text: text2,
20517
+ schematicPortIds: new Set(schPortIds),
20518
+ bounds: getNetLabelTextBounds({ center: center2, text: text2 })
20519
+ };
20520
+ if (userDefinedNetLabels.some(
20521
+ (label) => isUserDefinedNetLabelRedundantWithPlacement(label, solverPlacement)
20522
+ )) {
20523
+ continue;
20524
+ }
20525
+ }
20470
20526
  const netLabel2 = {
20471
20527
  text: text2,
20472
20528
  source_net_id: sourceNet.source_net_id,
@@ -24687,7 +24743,7 @@ import { identity as identity5 } from "transformation-matrix";
24687
24743
  var package_default = {
24688
24744
  name: "@tscircuit/core",
24689
24745
  type: "module",
24690
- version: "0.0.1372",
24746
+ version: "0.0.1374",
24691
24747
  types: "dist/index.d.ts",
24692
24748
  main: "dist/index.js",
24693
24749
  module: "dist/index.js",
@@ -24722,7 +24778,7 @@ var package_default = {
24722
24778
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
24723
24779
  "@tscircuit/capacity-autorouter": "^0.0.583",
24724
24780
  "@tscircuit/checks": "0.0.140",
24725
- "@tscircuit/circuit-json-util": "^0.0.96",
24781
+ "@tscircuit/circuit-json-util": "^0.0.97",
24726
24782
  "@tscircuit/common": "^0.0.20",
24727
24783
  "@tscircuit/copper-pour-solver": "0.0.35",
24728
24784
  "@tscircuit/footprinter": "^0.0.357",
@@ -29051,6 +29107,7 @@ import {
29051
29107
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
29052
29108
  var NetLabel = class extends PrimitiveComponent2 {
29053
29109
  source_net_label_id;
29110
+ schematic_net_label_id;
29054
29111
  get config() {
29055
29112
  return {
29056
29113
  componentName: "NetLabel",
@@ -29141,6 +29198,7 @@ var NetLabel = class extends PrimitiveComponent2 {
29141
29198
  schematic_sheet_id: this._resolveSchematicSheetId()
29142
29199
  });
29143
29200
  this.source_net_label_id = netLabel.source_net_id;
29201
+ this.schematic_net_label_id = netLabel.schematic_net_label_id;
29144
29202
  }
29145
29203
  _resolveConnectsTo() {
29146
29204
  const { _parsedProps: props } = this;
@@ -31488,7 +31546,7 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
31488
31546
  import { voltageProbeProps } from "@tscircuit/props";
31489
31547
 
31490
31548
  // lib/utils/schematic/selectBestLabelAlignment.ts
31491
- import { doBoundsOverlap as doBoundsOverlap2 } from "@tscircuit/math-utils";
31549
+ import { doBoundsOverlap as doBoundsOverlap3 } from "@tscircuit/math-utils";
31492
31550
  function getLabelBounds(probePosition, labelText, alignment, labelOffset = 0.3) {
31493
31551
  const charWidth = 0.1;
31494
31552
  const labelWidth = Math.max(labelText.length * charWidth, 0.3);
@@ -31559,7 +31617,7 @@ function getElementBounds(elm) {
31559
31617
  return null;
31560
31618
  }
31561
31619
  function getOverlapArea(a, b) {
31562
- if (!doBoundsOverlap2(a, b)) return 0;
31620
+ if (!doBoundsOverlap3(a, b)) return 0;
31563
31621
  const overlapWidth = Math.min(a.maxX, b.maxX) - Math.max(a.minX, b.minX);
31564
31622
  const overlapHeight = Math.min(a.maxY, b.maxY) - Math.max(a.minY, b.minY);
31565
31623
  return overlapWidth * overlapHeight;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1373",
4
+ "version": "0.0.1375",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
37
37
  "@tscircuit/capacity-autorouter": "^0.0.583",
38
38
  "@tscircuit/checks": "0.0.140",
39
- "@tscircuit/circuit-json-util": "^0.0.96",
39
+ "@tscircuit/circuit-json-util": "^0.0.97",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "0.0.35",
42
42
  "@tscircuit/footprinter": "^0.0.357",