@tscircuit/core 0.0.1889 → 0.0.1890

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) => {
@@ -61597,7 +61597,7 @@ function Group_getRoutingPhasePlans(group) {
61597
61597
  var package_default = {
61598
61598
  name: "@tscircuit/core",
61599
61599
  type: "module",
61600
- version: "0.0.1888",
61600
+ version: "0.0.1889",
61601
61601
  types: "dist/index.d.ts",
61602
61602
  main: "dist/index.js",
61603
61603
  module: "dist/index.js",
@@ -64840,6 +64840,86 @@ function inflateSourceInductor(sourceElm, inflatorContext) {
64840
64840
 
64841
64841
  // lib/components/normal-components/Led.ts
64842
64842
  import { ledProps } from "@tscircuit/props";
64843
+
64844
+ // lib/components/normal-components/Led_addPolarityFabricationSymbol.ts
64845
+ import { applyToPoint as applyToPoint31, compose as compose13, rotate as rotate6, translate as translate13 } from "transformation-matrix";
64846
+ var generatedNotes = /* @__PURE__ */ new WeakMap();
64847
+ var getPolarity2 = (port) => {
64848
+ const hints = [port.name, ...port.port_hints ?? []].map(
64849
+ (hint) => hint.toLowerCase().replace(/[^a-z0-9+-]/g, "")
64850
+ );
64851
+ const anode = hints.some(
64852
+ (hint) => ["a", "anode", "pos", "positive", "+"].includes(hint)
64853
+ );
64854
+ const cathode = hints.some(
64855
+ (hint) => ["k", "c", "cathode", "neg", "negative", "-"].includes(hint)
64856
+ );
64857
+ if (anode === cathode) return null;
64858
+ return anode ? "anode" : "cathode";
64859
+ };
64860
+ var Led_addPolarityFabricationSymbol = (led) => {
64861
+ const root = led.root;
64862
+ if (!root) return;
64863
+ const { db } = root;
64864
+ const previous = generatedNotes.get(led);
64865
+ for (const path of previous ?? []) {
64866
+ db.pcb_fabrication_note_path.delete(path.pcb_fabrication_note_path_id);
64867
+ }
64868
+ generatedNotes.delete(led);
64869
+ if (root.pcbDisabled || !led.pcb_component_id) return;
64870
+ const pcb = db.pcb_component.get(led.pcb_component_id);
64871
+ if (!pcb || pcb.layer !== "top" && pcb.layer !== "bottom") return;
64872
+ const ports = db.source_port.list({
64873
+ source_component_id: led.source_component_id
64874
+ });
64875
+ const anodes = ports.filter((port) => getPolarity2(port) === "anode");
64876
+ const cathodes = ports.filter((port) => getPolarity2(port) === "cathode");
64877
+ if (anodes.length !== 1 || cathodes.length !== 1) return;
64878
+ const anode = anodes[0];
64879
+ const cathode = cathodes[0];
64880
+ const a = db.pcb_port.getWhere({ source_port_id: anode.source_port_id });
64881
+ const k = db.pcb_port.getWhere({ source_port_id: cathode.source_port_id });
64882
+ if (!a || !k) return;
64883
+ const distance22 = Math.hypot(k.x - a.x, k.y - a.y);
64884
+ if (distance22 < 1e-6) return;
64885
+ const angle = Math.atan2(k.y - a.y, k.x - a.x);
64886
+ const frame = compose13(
64887
+ translate13((a.x + k.x) / 2, (a.y + k.y) / 2),
64888
+ rotate6(angle)
64889
+ );
64890
+ const point6 = (x, y) => applyToPoint31(frame, { x, y });
64891
+ const common = {
64892
+ pcb_component_id: pcb.pcb_component_id,
64893
+ subcircuit_id: led.getSubcircuit()?.subcircuit_id ?? void 0,
64894
+ layer: pcb.layer
64895
+ };
64896
+ const notes = [];
64897
+ generatedNotes.set(led, notes);
64898
+ const halfLength = Math.min(distance22 * 0.2, 0.4);
64899
+ const halfHeight = halfLength * 0.75;
64900
+ const routes = [
64901
+ [point6(-distance22 / 2, 0), point6(-halfLength, 0)],
64902
+ [
64903
+ point6(-halfLength, -halfHeight),
64904
+ point6(halfLength, 0),
64905
+ point6(-halfLength, halfHeight),
64906
+ point6(-halfLength, -halfHeight)
64907
+ ],
64908
+ [point6(halfLength, -halfHeight), point6(halfLength, halfHeight)],
64909
+ [point6(halfLength, 0), point6(distance22 / 2, 0)]
64910
+ ];
64911
+ for (const route of routes) {
64912
+ notes.push(
64913
+ db.pcb_fabrication_note_path.insert({
64914
+ ...common,
64915
+ route,
64916
+ stroke_width: 0.08
64917
+ })
64918
+ );
64919
+ }
64920
+ };
64921
+
64922
+ // lib/components/normal-components/Led.ts
64843
64923
  var Led = class extends NormalComponent3 {
64844
64924
  get config() {
64845
64925
  const symbolMap = {
@@ -64898,6 +64978,10 @@ var Led = class extends NormalComponent3 {
64898
64978
  get pos() {
64899
64979
  return this.portMap.pos;
64900
64980
  }
64981
+ doInitialPcbComponentSizeCalculation() {
64982
+ super.doInitialPcbComponentSizeCalculation();
64983
+ Led_addPolarityFabricationSymbol(this);
64984
+ }
64901
64985
  get anode() {
64902
64986
  return this.portMap.anode;
64903
64987
  }
@@ -66918,11 +67002,11 @@ import {
66918
67002
  Polygon as Polygon2,
66919
67003
  Segment
66920
67004
  } from "@flatten-js/core";
66921
- import { compose as compose13, rotate as rotate6, translate as translate13 } from "transformation-matrix";
67005
+ import { compose as compose14, rotate as rotate7, translate as translate14 } from "transformation-matrix";
66922
67006
  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)
67007
+ const { a, b, c, d, e, f } = compose14(
67008
+ translate14(center.x, center.y),
67009
+ rotate7(degrees * Math.PI / 180)
66926
67010
  );
66927
67011
  return polygon.transform(new Matrix(a, b, c, d, e, f));
66928
67012
  };
@@ -67610,9 +67694,9 @@ var Board = class extends Group5 {
67610
67694
  _computePcbGlobalTransformBeforeLayout() {
67611
67695
  if (this._panelPositionOffset) {
67612
67696
  const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
67613
- return compose14(
67697
+ return compose15(
67614
67698
  parentTransform,
67615
- translate14(this._panelPositionOffset.x, this._panelPositionOffset.y)
67699
+ translate15(this._panelPositionOffset.x, this._panelPositionOffset.y)
67616
67700
  );
67617
67701
  }
67618
67702
  return super._computePcbGlobalTransformBeforeLayout();
@@ -68243,7 +68327,7 @@ import { distance as distance20 } from "circuit-json";
68243
68327
  // lib/components/normal-components/Subpanel.ts
68244
68328
  import { subpanelProps } from "@tscircuit/props";
68245
68329
  import { distance as distance19 } from "circuit-json";
68246
- import { compose as compose15, identity as identity8, translate as translate15 } from "transformation-matrix";
68330
+ import { compose as compose16, identity as identity8, translate as translate16 } from "transformation-matrix";
68247
68331
 
68248
68332
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
68249
68333
  import * as Flatten from "@flatten-js/core";
@@ -68755,9 +68839,9 @@ var Subpanel = class _Subpanel extends Group5 {
68755
68839
  _computePcbGlobalTransformBeforeLayout() {
68756
68840
  if (this._panelPositionOffset) {
68757
68841
  const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? identity8();
68758
- return compose15(
68842
+ return compose16(
68759
68843
  parentTransform,
68760
- translate15(this._panelPositionOffset.x, this._panelPositionOffset.y)
68844
+ translate16(this._panelPositionOffset.x, this._panelPositionOffset.y)
68761
68845
  );
68762
68846
  }
68763
68847
  return super._computePcbGlobalTransformBeforeLayout();
@@ -70424,7 +70508,7 @@ var AutoroutingPhase = class extends PrimitiveComponent2 {
70424
70508
 
70425
70509
  // lib/components/primitive-components/FabricationNoteDimension.ts
70426
70510
  import { fabricationNoteDimensionProps } from "@tscircuit/props";
70427
- import { applyToPoint as applyToPoint31 } from "transformation-matrix";
70511
+ import { applyToPoint as applyToPoint32 } from "transformation-matrix";
70428
70512
  var FabricationNoteDimension = class extends PrimitiveComponent2 {
70429
70513
  fabrication_note_dimension_id = null;
70430
70514
  isPcbPrimitive = true;
@@ -70443,13 +70527,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
70443
70527
  this.renderError(
70444
70528
  `FabricationNoteDimension could not find selector "${input}"`
70445
70529
  );
70446
- return applyToPoint31(transform, { x: 0, y: 0 });
70530
+ return applyToPoint32(transform, { x: 0, y: 0 });
70447
70531
  }
70448
70532
  return target._getGlobalPcbPositionBeforeLayout();
70449
70533
  }
70450
70534
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
70451
70535
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
70452
- return applyToPoint31(transform, { x: numericX, y: numericY });
70536
+ return applyToPoint32(transform, { x: numericX, y: numericY });
70453
70537
  }
70454
70538
  doInitialPcbPrimitiveRender() {
70455
70539
  if (this.root?.pcbDisabled) return;
@@ -70544,7 +70628,7 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
70544
70628
 
70545
70629
  // lib/components/primitive-components/PcbNoteDimension.ts
70546
70630
  import { pcbNoteDimensionProps } from "@tscircuit/props";
70547
- import { applyToPoint as applyToPoint32 } from "transformation-matrix";
70631
+ import { applyToPoint as applyToPoint33 } from "transformation-matrix";
70548
70632
  var PcbNoteDimension = class extends PrimitiveComponent2 {
70549
70633
  pcb_note_dimension_id = null;
70550
70634
  isPcbPrimitive = true;
@@ -70561,7 +70645,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
70561
70645
  );
70562
70646
  if (!target) {
70563
70647
  this.renderError(`PcbNoteDimension could not find selector "${input}"`);
70564
- return applyToPoint32(transform, { x: 0, y: 0 });
70648
+ return applyToPoint33(transform, { x: 0, y: 0 });
70565
70649
  }
70566
70650
  const targetPcbComponentId = target.pcb_component_id;
70567
70651
  const root = this.root;
@@ -70578,7 +70662,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
70578
70662
  }
70579
70663
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
70580
70664
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
70581
- return applyToPoint32(transform, { x: numericX, y: numericY });
70665
+ return applyToPoint33(transform, { x: numericX, y: numericY });
70582
70666
  }
70583
70667
  doInitialPcbPrimitiveRender() {
70584
70668
  if (this.root?.pcbDisabled) return;
@@ -73329,7 +73413,7 @@ import {
73329
73413
  getTransformedSvgPathRoutes,
73330
73414
  loadImageSource
73331
73415
  } from "@tscircuit/image-utils";
73332
- import { applyToPoint as applyToPoint33 } from "transformation-matrix";
73416
+ import { applyToPoint as applyToPoint34 } from "transformation-matrix";
73333
73417
  var SilkscreenGraphic = class extends PrimitiveComponent2 {
73334
73418
  pcb_silkscreen_graphic_id = null;
73335
73419
  pcb_silkscreen_graphic_ids = [];
@@ -73431,7 +73515,7 @@ var SilkscreenGraphic = class extends PrimitiveComponent2 {
73431
73515
  { x: halfWidth, y: -halfHeight },
73432
73516
  { x: -halfWidth, y: -halfHeight }
73433
73517
  ]).map(
73434
- (point6) => applyToPoint33(transform, point6)
73518
+ (point6) => applyToPoint34(transform, point6)
73435
73519
  )
73436
73520
  },
73437
73521
  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.1890",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",