@tscircuit/core 0.0.1837 → 0.0.1839

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -13447,6 +13447,91 @@ var NormalComponent__repositionOnPcb = (component, position) => {
13447
13447
  );
13448
13448
  };
13449
13449
 
13450
+ // lib/components/base-components/NormalComponent/NormalComponent_addInternalConnectionFabricationNotes.ts
13451
+ var INTERNAL_CONNECTION_NOTE_TEXT = "MARKED INTERNALLY CONNECTED";
13452
+ var INTERNAL_CONNECTION_NOTE_FONT_SIZE = 0.12;
13453
+ var INTERNAL_CONNECTION_NOTE_STROKE_WIDTH = 0.05;
13454
+ var INTERNAL_CONNECTION_NOTE_TEXT_OFFSET = 0.12;
13455
+ var hasFabricationNotes = (component) => {
13456
+ const { db } = component.root;
13457
+ const pcbComponentFilter = {
13458
+ pcb_component_id: component.pcb_component_id
13459
+ };
13460
+ return db.pcb_fabrication_note_text.list(pcbComponentFilter).length > 0 || db.pcb_fabrication_note_path.list(pcbComponentFilter).length > 0 || db.pcb_fabrication_note_rect.list(pcbComponentFilter).length > 0 || db.pcb_fabrication_note_dimension.list(pcbComponentFilter).length > 0;
13461
+ };
13462
+ var getLabelPlacementAlongRoute = (route) => {
13463
+ let longestSegment = { from: route[0], to: route[1], length: -Infinity };
13464
+ for (let pointIndex = 1; pointIndex < route.length; pointIndex++) {
13465
+ const from = route[pointIndex - 1];
13466
+ const to = route[pointIndex];
13467
+ const length7 = Math.hypot(to.x - from.x, to.y - from.y);
13468
+ if (length7 > longestSegment.length) {
13469
+ longestSegment = { from, to, length: length7 };
13470
+ }
13471
+ }
13472
+ const deltaX = longestSegment.to.x - longestSegment.from.x;
13473
+ const deltaY = longestSegment.to.y - longestSegment.from.y;
13474
+ const segmentLength = Math.max(longestSegment.length, Number.EPSILON);
13475
+ let ccwRotation = Math.atan2(deltaY, deltaX) * 180 / Math.PI;
13476
+ if (ccwRotation > 90) ccwRotation -= 180;
13477
+ if (ccwRotation < -90) ccwRotation += 180;
13478
+ return {
13479
+ anchorPosition: {
13480
+ x: (longestSegment.from.x + longestSegment.to.x) / 2 - deltaY / segmentLength * INTERNAL_CONNECTION_NOTE_TEXT_OFFSET,
13481
+ y: (longestSegment.from.y + longestSegment.to.y) / 2 + deltaX / segmentLength * INTERNAL_CONNECTION_NOTE_TEXT_OFFSET
13482
+ },
13483
+ ccwRotation: (ccwRotation % 360 + 360) % 360
13484
+ };
13485
+ };
13486
+ var NormalComponent_addInternalConnectionFabricationNotes = (component) => {
13487
+ const root = component.root;
13488
+ if (!root || root.pcbDisabled || !component.pcb_component_id) return;
13489
+ if (component.componentName === "SolderJumper") return;
13490
+ if (hasFabricationNotes(component)) return;
13491
+ const { db } = root;
13492
+ const pcbComponent = db.pcb_component.get(component.pcb_component_id);
13493
+ if (!pcbComponent) return;
13494
+ const fabricationNoteLayer = pcbComponent.layer;
13495
+ if (fabricationNoteLayer !== "top" && fabricationNoteLayer !== "bottom") {
13496
+ return;
13497
+ }
13498
+ const subcircuitId = component.getSubcircuit()?.subcircuit_id ?? void 0;
13499
+ const pcbGroupId = component.getGroup()?.pcb_group_id ?? void 0;
13500
+ for (const connectedPorts of component._getInternallyConnectedPins()) {
13501
+ const connectedPadCenters = connectedPorts.flatMap((port) => {
13502
+ if (!port?.pcb_port_id) return [];
13503
+ const pcbPort = db.pcb_port.get(port.pcb_port_id);
13504
+ return pcbPort ? [{ x: pcbPort.x, y: pcbPort.y }] : [];
13505
+ });
13506
+ const route = connectedPadCenters.filter(
13507
+ (point6, pointIndex) => connectedPadCenters.findIndex(
13508
+ (candidate) => candidate.x === point6.x && candidate.y === point6.y
13509
+ ) === pointIndex
13510
+ );
13511
+ if (route.length < 2) continue;
13512
+ const { anchorPosition, ccwRotation } = getLabelPlacementAlongRoute(route);
13513
+ db.pcb_fabrication_note_path.insert({
13514
+ pcb_component_id: component.pcb_component_id,
13515
+ subcircuit_id: subcircuitId,
13516
+ layer: fabricationNoteLayer,
13517
+ route,
13518
+ stroke_width: INTERNAL_CONNECTION_NOTE_STROKE_WIDTH
13519
+ });
13520
+ db.pcb_fabrication_note_text.insert({
13521
+ pcb_component_id: component.pcb_component_id,
13522
+ pcb_group_id: pcbGroupId,
13523
+ subcircuit_id: subcircuitId,
13524
+ font: "tscircuit2024",
13525
+ font_size: INTERNAL_CONNECTION_NOTE_FONT_SIZE,
13526
+ text: INTERNAL_CONNECTION_NOTE_TEXT,
13527
+ ccw_rotation: ccwRotation,
13528
+ layer: fabricationNoteLayer,
13529
+ anchor_position: anchorPosition,
13530
+ anchor_alignment: "center"
13531
+ });
13532
+ }
13533
+ };
13534
+
13450
13535
  // lib/components/base-components/NormalComponent/NormalComponent_doInitialCheckRefDesConvention.ts
13451
13536
  var defaultExpectedPrefixesByFtype = {
13452
13537
  simple_ammeter: ["A"],
@@ -15469,6 +15554,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
15469
15554
  if (this.root?.pcbDisabled) return;
15470
15555
  if (!this.pcb_component_id) return;
15471
15556
  const { db } = this.root;
15557
+ NormalComponent_addInternalConnectionFabricationNotes(this);
15472
15558
  const bounds = getBoundsOfPcbComponents(this.children);
15473
15559
  if (bounds.width === 0 || bounds.height === 0) return;
15474
15560
  const center = {
@@ -46093,7 +46179,7 @@ function Group_getRoutingPhasePlans(group) {
46093
46179
  var package_default = {
46094
46180
  name: "@tscircuit/core",
46095
46181
  type: "module",
46096
- version: "0.0.1836",
46182
+ version: "0.0.1838",
46097
46183
  types: "dist/index.d.ts",
46098
46184
  main: "dist/index.js",
46099
46185
  module: "dist/index.js",
@@ -46148,7 +46234,7 @@ var package_default = {
46148
46234
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
46149
46235
  "@tscircuit/props": "^0.0.646",
46150
46236
  "@tscircuit/schematic-match-adapt": "^0.0.18",
46151
- "@tscircuit/schematic-trace-solver": "^0.0.178",
46237
+ "@tscircuit/schematic-trace-solver": "^0.0.183",
46152
46238
  "@tscircuit/solver-utils": "^0.0.16",
46153
46239
  "@tscircuit/soup-util": "^0.0.41",
46154
46240
  "@tscircuit/winding-breakout-point-solver": "github:tscircuit/winding-breakout-point-solver#202dbe9eb0088633b6fa094120dba6f2f41f8803",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1837",
4
+ "version": "0.0.1839",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
57
57
  "@tscircuit/props": "^0.0.646",
58
58
  "@tscircuit/schematic-match-adapt": "^0.0.18",
59
- "@tscircuit/schematic-trace-solver": "^0.0.178",
59
+ "@tscircuit/schematic-trace-solver": "^0.0.183",
60
60
  "@tscircuit/solver-utils": "^0.0.16",
61
61
  "@tscircuit/soup-util": "^0.0.41",
62
62
  "@tscircuit/winding-breakout-point-solver": "github:tscircuit/winding-breakout-point-solver#202dbe9eb0088633b6fa094120dba6f2f41f8803",