@tscircuit/core 0.0.1889 → 0.0.1891

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
@@ -67111,6 +67111,7 @@ declare class Led extends NormalComponent<typeof ledProps, PolarizedPassivePorts
67111
67111
  getFootprinterString(): string | null;
67112
67112
  doInitialSourceRender(): void;
67113
67113
  get pos(): Port;
67114
+ doInitialPcbComponentSizeCalculation(): void;
67114
67115
  get anode(): Port;
67115
67116
  get neg(): Port;
67116
67117
  get cathode(): Port;
package/dist/index.js CHANGED
@@ -16587,7 +16587,7 @@ import {
16587
16587
  } from "@tscircuit/checks";
16588
16588
  import { getBoundsFromPoints as getBoundsFromPoints10 } from "@tscircuit/math-utils";
16589
16589
  import { boardProps } from "@tscircuit/props";
16590
- import { compose as compose14, translate as translate14 } from "transformation-matrix";
16590
+ import { compose as compose15, translate as translate15 } from "transformation-matrix";
16591
16591
 
16592
16592
  // lib/utils/autorouting/getAncestorSubcircuitIds.ts
16593
16593
  var getDescendantSubcircuitIds = (db, root_subcircuit_id) => {
@@ -22753,13 +22753,14 @@ function getWindingTargetOrders(params) {
22753
22753
  return;
22754
22754
  }
22755
22755
  for (let layer = 0; layer < layerSequences2.length; layer++) {
22756
- const next = layerSequences2[layer][offsets[layer]];
22756
+ const offset = offsets[layer];
22757
+ const next = layerSequences2[layer][offset];
22757
22758
  if (!next) continue;
22758
- offsets[layer]++;
22759
+ offsets[layer] = offset + 1;
22759
22760
  current.push(next);
22760
22761
  append();
22761
22762
  current.pop();
22762
- offsets[layer]--;
22763
+ offsets[layer] = offset;
22763
22764
  }
22764
22765
  };
22765
22766
  append();
@@ -32921,8 +32922,8 @@ function selectCompatibleCandidates(params) {
32921
32922
  for (const second of neighbors[first]) {
32922
32923
  if (second <= first || compatible(selection[first], selection[second]))
32923
32924
  continue;
32924
- conflictCounts[first]++;
32925
- conflictCounts[second]++;
32925
+ conflictCounts[first] = conflictCounts[first] + 1;
32926
+ conflictCounts[second] = conflictCounts[second] + 1;
32926
32927
  }
32927
32928
  }
32928
32929
  const maximumConflictCount = Math.max(...conflictCounts);
@@ -61597,7 +61598,7 @@ function Group_getRoutingPhasePlans(group) {
61597
61598
  var package_default = {
61598
61599
  name: "@tscircuit/core",
61599
61600
  type: "module",
61600
- version: "0.0.1888",
61601
+ version: "0.0.1890",
61601
61602
  types: "dist/index.d.ts",
61602
61603
  main: "dist/index.js",
61603
61604
  module: "dist/index.js",
@@ -61637,7 +61638,7 @@ var package_default = {
61637
61638
  "@tscircuit/common": "^0.0.20",
61638
61639
  "@tscircuit/copper-pour-solver": "^0.0.54",
61639
61640
  "@tscircuit/create-fdm-enclosure": "0.0.4",
61640
- "@tscircuit/fanout-solver": "0.0.71",
61641
+ "@tscircuit/fanout-solver": "0.0.72",
61641
61642
  "@tscircuit/footprinter": "^0.0.426",
61642
61643
  "@tscircuit/image-utils": "^0.0.8",
61643
61644
  "@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",
@@ -64840,6 +64841,86 @@ function inflateSourceInductor(sourceElm, inflatorContext) {
64840
64841
 
64841
64842
  // lib/components/normal-components/Led.ts
64842
64843
  import { ledProps } from "@tscircuit/props";
64844
+
64845
+ // lib/components/normal-components/Led_addPolarityFabricationSymbol.ts
64846
+ import { applyToPoint as applyToPoint31, compose as compose13, rotate as rotate6, translate as translate13 } from "transformation-matrix";
64847
+ var generatedNotes = /* @__PURE__ */ new WeakMap();
64848
+ var getPolarity2 = (port) => {
64849
+ const hints = [port.name, ...port.port_hints ?? []].map(
64850
+ (hint) => hint.toLowerCase().replace(/[^a-z0-9+-]/g, "")
64851
+ );
64852
+ const anode = hints.some(
64853
+ (hint) => ["a", "anode", "pos", "positive", "+"].includes(hint)
64854
+ );
64855
+ const cathode = hints.some(
64856
+ (hint) => ["k", "c", "cathode", "neg", "negative", "-"].includes(hint)
64857
+ );
64858
+ if (anode === cathode) return null;
64859
+ return anode ? "anode" : "cathode";
64860
+ };
64861
+ var Led_addPolarityFabricationSymbol = (led) => {
64862
+ const root = led.root;
64863
+ if (!root) return;
64864
+ const { db } = root;
64865
+ const previous = generatedNotes.get(led);
64866
+ for (const path of previous ?? []) {
64867
+ db.pcb_fabrication_note_path.delete(path.pcb_fabrication_note_path_id);
64868
+ }
64869
+ generatedNotes.delete(led);
64870
+ if (root.pcbDisabled || !led.pcb_component_id) return;
64871
+ const pcb = db.pcb_component.get(led.pcb_component_id);
64872
+ if (!pcb || pcb.layer !== "top" && pcb.layer !== "bottom") return;
64873
+ const ports = db.source_port.list({
64874
+ source_component_id: led.source_component_id
64875
+ });
64876
+ const anodes = ports.filter((port) => getPolarity2(port) === "anode");
64877
+ const cathodes = ports.filter((port) => getPolarity2(port) === "cathode");
64878
+ if (anodes.length !== 1 || cathodes.length !== 1) return;
64879
+ const anode = anodes[0];
64880
+ const cathode = cathodes[0];
64881
+ const a = db.pcb_port.getWhere({ source_port_id: anode.source_port_id });
64882
+ const k = db.pcb_port.getWhere({ source_port_id: cathode.source_port_id });
64883
+ if (!a || !k) return;
64884
+ const distance22 = Math.hypot(k.x - a.x, k.y - a.y);
64885
+ if (distance22 < 1e-6) return;
64886
+ const angle = Math.atan2(k.y - a.y, k.x - a.x);
64887
+ const frame = compose13(
64888
+ translate13((a.x + k.x) / 2, (a.y + k.y) / 2),
64889
+ rotate6(angle)
64890
+ );
64891
+ const point6 = (x, y) => applyToPoint31(frame, { x, y });
64892
+ const common = {
64893
+ pcb_component_id: pcb.pcb_component_id,
64894
+ subcircuit_id: led.getSubcircuit()?.subcircuit_id ?? void 0,
64895
+ layer: pcb.layer
64896
+ };
64897
+ const notes = [];
64898
+ generatedNotes.set(led, notes);
64899
+ const halfLength = Math.min(distance22 * 0.2, 0.4);
64900
+ const halfHeight = halfLength * 0.75;
64901
+ const routes = [
64902
+ [point6(-distance22 / 2, 0), point6(-halfLength, 0)],
64903
+ [
64904
+ point6(-halfLength, -halfHeight),
64905
+ point6(halfLength, 0),
64906
+ point6(-halfLength, halfHeight),
64907
+ point6(-halfLength, -halfHeight)
64908
+ ],
64909
+ [point6(halfLength, -halfHeight), point6(halfLength, halfHeight)],
64910
+ [point6(halfLength, 0), point6(distance22 / 2, 0)]
64911
+ ];
64912
+ for (const route of routes) {
64913
+ notes.push(
64914
+ db.pcb_fabrication_note_path.insert({
64915
+ ...common,
64916
+ route,
64917
+ stroke_width: 0.08
64918
+ })
64919
+ );
64920
+ }
64921
+ };
64922
+
64923
+ // lib/components/normal-components/Led.ts
64843
64924
  var Led = class extends NormalComponent3 {
64844
64925
  get config() {
64845
64926
  const symbolMap = {
@@ -64898,6 +64979,10 @@ var Led = class extends NormalComponent3 {
64898
64979
  get pos() {
64899
64980
  return this.portMap.pos;
64900
64981
  }
64982
+ doInitialPcbComponentSizeCalculation() {
64983
+ super.doInitialPcbComponentSizeCalculation();
64984
+ Led_addPolarityFabricationSymbol(this);
64985
+ }
64901
64986
  get anode() {
64902
64987
  return this.portMap.anode;
64903
64988
  }
@@ -66918,11 +67003,11 @@ import {
66918
67003
  Polygon as Polygon2,
66919
67004
  Segment
66920
67005
  } from "@flatten-js/core";
66921
- import { compose as compose13, rotate as rotate6, translate as translate13 } from "transformation-matrix";
67006
+ import { compose as compose14, rotate as rotate7, translate as translate14 } from "transformation-matrix";
66922
67007
  var placePolygon = (polygon, center, degrees = 0) => {
66923
- const { a, b, c, d, e, f } = compose13(
66924
- translate13(center.x, center.y),
66925
- rotate6(degrees * Math.PI / 180)
67008
+ const { a, b, c, d, e, f } = compose14(
67009
+ translate14(center.x, center.y),
67010
+ rotate7(degrees * Math.PI / 180)
66926
67011
  );
66927
67012
  return polygon.transform(new Matrix(a, b, c, d, e, f));
66928
67013
  };
@@ -67610,9 +67695,9 @@ var Board = class extends Group5 {
67610
67695
  _computePcbGlobalTransformBeforeLayout() {
67611
67696
  if (this._panelPositionOffset) {
67612
67697
  const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
67613
- return compose14(
67698
+ return compose15(
67614
67699
  parentTransform,
67615
- translate14(this._panelPositionOffset.x, this._panelPositionOffset.y)
67700
+ translate15(this._panelPositionOffset.x, this._panelPositionOffset.y)
67616
67701
  );
67617
67702
  }
67618
67703
  return super._computePcbGlobalTransformBeforeLayout();
@@ -68243,7 +68328,7 @@ import { distance as distance20 } from "circuit-json";
68243
68328
  // lib/components/normal-components/Subpanel.ts
68244
68329
  import { subpanelProps } from "@tscircuit/props";
68245
68330
  import { distance as distance19 } from "circuit-json";
68246
- import { compose as compose15, identity as identity8, translate as translate15 } from "transformation-matrix";
68331
+ import { compose as compose16, identity as identity8, translate as translate16 } from "transformation-matrix";
68247
68332
 
68248
68333
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
68249
68334
  import * as Flatten from "@flatten-js/core";
@@ -68755,9 +68840,9 @@ var Subpanel = class _Subpanel extends Group5 {
68755
68840
  _computePcbGlobalTransformBeforeLayout() {
68756
68841
  if (this._panelPositionOffset) {
68757
68842
  const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? identity8();
68758
- return compose15(
68843
+ return compose16(
68759
68844
  parentTransform,
68760
- translate15(this._panelPositionOffset.x, this._panelPositionOffset.y)
68845
+ translate16(this._panelPositionOffset.x, this._panelPositionOffset.y)
68761
68846
  );
68762
68847
  }
68763
68848
  return super._computePcbGlobalTransformBeforeLayout();
@@ -70424,7 +70509,7 @@ var AutoroutingPhase = class extends PrimitiveComponent2 {
70424
70509
 
70425
70510
  // lib/components/primitive-components/FabricationNoteDimension.ts
70426
70511
  import { fabricationNoteDimensionProps } from "@tscircuit/props";
70427
- import { applyToPoint as applyToPoint31 } from "transformation-matrix";
70512
+ import { applyToPoint as applyToPoint32 } from "transformation-matrix";
70428
70513
  var FabricationNoteDimension = class extends PrimitiveComponent2 {
70429
70514
  fabrication_note_dimension_id = null;
70430
70515
  isPcbPrimitive = true;
@@ -70443,13 +70528,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
70443
70528
  this.renderError(
70444
70529
  `FabricationNoteDimension could not find selector "${input}"`
70445
70530
  );
70446
- return applyToPoint31(transform, { x: 0, y: 0 });
70531
+ return applyToPoint32(transform, { x: 0, y: 0 });
70447
70532
  }
70448
70533
  return target._getGlobalPcbPositionBeforeLayout();
70449
70534
  }
70450
70535
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
70451
70536
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
70452
- return applyToPoint31(transform, { x: numericX, y: numericY });
70537
+ return applyToPoint32(transform, { x: numericX, y: numericY });
70453
70538
  }
70454
70539
  doInitialPcbPrimitiveRender() {
70455
70540
  if (this.root?.pcbDisabled) return;
@@ -70544,7 +70629,7 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
70544
70629
 
70545
70630
  // lib/components/primitive-components/PcbNoteDimension.ts
70546
70631
  import { pcbNoteDimensionProps } from "@tscircuit/props";
70547
- import { applyToPoint as applyToPoint32 } from "transformation-matrix";
70632
+ import { applyToPoint as applyToPoint33 } from "transformation-matrix";
70548
70633
  var PcbNoteDimension = class extends PrimitiveComponent2 {
70549
70634
  pcb_note_dimension_id = null;
70550
70635
  isPcbPrimitive = true;
@@ -70561,7 +70646,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
70561
70646
  );
70562
70647
  if (!target) {
70563
70648
  this.renderError(`PcbNoteDimension could not find selector "${input}"`);
70564
- return applyToPoint32(transform, { x: 0, y: 0 });
70649
+ return applyToPoint33(transform, { x: 0, y: 0 });
70565
70650
  }
70566
70651
  const targetPcbComponentId = target.pcb_component_id;
70567
70652
  const root = this.root;
@@ -70578,7 +70663,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
70578
70663
  }
70579
70664
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
70580
70665
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
70581
- return applyToPoint32(transform, { x: numericX, y: numericY });
70666
+ return applyToPoint33(transform, { x: numericX, y: numericY });
70582
70667
  }
70583
70668
  doInitialPcbPrimitiveRender() {
70584
70669
  if (this.root?.pcbDisabled) return;
@@ -73329,7 +73414,7 @@ import {
73329
73414
  getTransformedSvgPathRoutes,
73330
73415
  loadImageSource
73331
73416
  } from "@tscircuit/image-utils";
73332
- import { applyToPoint as applyToPoint33 } from "transformation-matrix";
73417
+ import { applyToPoint as applyToPoint34 } from "transformation-matrix";
73333
73418
  var SilkscreenGraphic = class extends PrimitiveComponent2 {
73334
73419
  pcb_silkscreen_graphic_id = null;
73335
73420
  pcb_silkscreen_graphic_ids = [];
@@ -73431,7 +73516,7 @@ var SilkscreenGraphic = class extends PrimitiveComponent2 {
73431
73516
  { x: halfWidth, y: -halfHeight },
73432
73517
  { x: -halfWidth, y: -halfHeight }
73433
73518
  ]).map(
73434
- (point6) => applyToPoint33(transform, point6)
73519
+ (point6) => applyToPoint34(transform, point6)
73435
73520
  )
73436
73521
  },
73437
73522
  inner_rings: []
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1889",
4
+ "version": "0.0.1891",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "@tscircuit/common": "^0.0.20",
42
42
  "@tscircuit/copper-pour-solver": "^0.0.54",
43
43
  "@tscircuit/create-fdm-enclosure": "0.0.4",
44
- "@tscircuit/fanout-solver": "0.0.71",
44
+ "@tscircuit/fanout-solver": "0.0.72",
45
45
  "@tscircuit/footprinter": "^0.0.426",
46
46
  "@tscircuit/image-utils": "^0.0.8",
47
47
  "@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",