@tscircuit/core 0.0.943 → 0.0.945

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 (3) hide show
  1. package/dist/index.d.ts +1631 -470
  2. package/dist/index.js +133 -13
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ __export(components_exports, {
20
20
  CopperPour: () => CopperPour,
21
21
  CopperText: () => CopperText,
22
22
  Crystal: () => Crystal,
23
+ CurrentSource: () => CurrentSource,
23
24
  Cutout: () => Cutout,
24
25
  Diode: () => Diode,
25
26
  FabricationNoteDimension: () => FabricationNoteDimension,
@@ -17035,6 +17036,104 @@ var VoltageSource = class extends NormalComponent3 {
17035
17036
  terminal2 = this.portMap.terminal2;
17036
17037
  };
17037
17038
 
17039
+ // lib/components/normal-components/CurrentSource.ts
17040
+ import { currentSourceProps } from "@tscircuit/props";
17041
+ import { formatSiUnit as formatSiUnit6 } from "format-si-unit";
17042
+ var CurrentSource = class extends NormalComponent3 {
17043
+ get config() {
17044
+ const symbolName = "current_source";
17045
+ return {
17046
+ componentName: "CurrentSource",
17047
+ schematicSymbolName: symbolName,
17048
+ zodProps: currentSourceProps,
17049
+ sourceFtype: "simple_current_source"
17050
+ };
17051
+ }
17052
+ runRenderPhaseForChildren(phase) {
17053
+ if (phase.startsWith("Pcb")) {
17054
+ return;
17055
+ }
17056
+ for (const child of this.children) {
17057
+ child.runRenderPhaseForChildren(phase);
17058
+ child.runRenderPhase(phase);
17059
+ }
17060
+ }
17061
+ doInitialPcbComponentRender() {
17062
+ }
17063
+ initPorts() {
17064
+ super.initPorts({
17065
+ additionalAliases: {
17066
+ pin1: ["pos"],
17067
+ pin2: ["neg"]
17068
+ }
17069
+ });
17070
+ }
17071
+ _getSchematicSymbolDisplayValue() {
17072
+ const { current, frequency: frequency2, peakToPeakCurrent } = this._parsedProps;
17073
+ const parts = [];
17074
+ if (current !== void 0) {
17075
+ parts.push(`${formatSiUnit6(current)}A`);
17076
+ }
17077
+ if (peakToPeakCurrent !== void 0) {
17078
+ parts.push(`${formatSiUnit6(peakToPeakCurrent)}A p-p`);
17079
+ }
17080
+ if (frequency2 !== void 0) {
17081
+ parts.push(`${formatSiUnit6(frequency2)}Hz`);
17082
+ }
17083
+ return parts.length > 0 ? parts.join(" ") : void 0;
17084
+ }
17085
+ doInitialSourceRender() {
17086
+ const { db } = this.root;
17087
+ const { _parsedProps: props } = this;
17088
+ const source_component = db.source_component.insert({
17089
+ ftype: "simple_current_source",
17090
+ name: this.name,
17091
+ current: props.current,
17092
+ frequency: props.frequency,
17093
+ peak_to_peak_current: props.peakToPeakCurrent,
17094
+ wave_shape: props.waveShape,
17095
+ phase: props.phase,
17096
+ duty_cycle: props.dutyCycle,
17097
+ supplier_part_numbers: props.supplierPartNumbers,
17098
+ are_pins_interchangeable: true
17099
+ });
17100
+ this.source_component_id = source_component.source_component_id;
17101
+ }
17102
+ doInitialSimulationRender() {
17103
+ const { db } = this.root;
17104
+ const { _parsedProps: props } = this;
17105
+ const isAc = props.frequency !== void 0 || props.peakToPeakCurrent !== void 0 || props.waveShape !== void 0;
17106
+ const posPort = this.portMap.pos;
17107
+ const negPort = this.portMap.neg;
17108
+ if (isAc) {
17109
+ db.simulation_current_source.insert({
17110
+ type: "simulation_current_source",
17111
+ is_dc_source: false,
17112
+ terminal1_source_port_id: posPort.source_port_id,
17113
+ terminal2_source_port_id: negPort.source_port_id,
17114
+ current: props.current,
17115
+ // DC offset
17116
+ frequency: props.frequency,
17117
+ peak_to_peak_current: props.peakToPeakCurrent,
17118
+ wave_shape: props.waveShape,
17119
+ phase: props.phase,
17120
+ duty_cycle: props.dutyCycle
17121
+ });
17122
+ } else {
17123
+ if (props.current === void 0) return;
17124
+ db.simulation_current_source.insert({
17125
+ type: "simulation_current_source",
17126
+ is_dc_source: true,
17127
+ positive_source_port_id: posPort.source_port_id,
17128
+ negative_source_port_id: negPort.source_port_id,
17129
+ current: props.current
17130
+ });
17131
+ }
17132
+ }
17133
+ pos = this.portMap.pos;
17134
+ neg = this.portMap.neg;
17135
+ };
17136
+
17038
17137
  // lib/components/primitive-components/Constraint.ts
17039
17138
  import { constraintProps } from "@tscircuit/props";
17040
17139
  import "zod";
@@ -18106,6 +18205,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18106
18205
 
18107
18206
  // lib/components/primitive-components/SilkscreenRect.ts
18108
18207
  import { silkscreenRectProps } from "@tscircuit/props";
18208
+ import { decomposeTSR as decomposeTSR6 } from "transformation-matrix";
18109
18209
  var SilkscreenRect = class extends PrimitiveComponent2 {
18110
18210
  pcb_silkscreen_rect_id = null;
18111
18211
  isPcbPrimitive = true;
@@ -18115,6 +18215,18 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18115
18215
  zodProps: silkscreenRectProps
18116
18216
  };
18117
18217
  }
18218
+ /**
18219
+ * Check if the component is rotated 90 or 270 degrees based on global transform.
18220
+ * For these rotations, we need to swap width/height instead of using ccw_rotation.
18221
+ */
18222
+ _isRotated90Degrees() {
18223
+ const globalTransform = this._computePcbGlobalTransformBeforeLayout();
18224
+ const decomposedTransform = decomposeTSR6(globalTransform);
18225
+ const rotationDegrees = decomposedTransform.rotation.angle * 180 / Math.PI;
18226
+ const normalizedRotationDegrees = (rotationDegrees % 360 + 360) % 360;
18227
+ const rotationTolerance = 0.01;
18228
+ return Math.abs(normalizedRotationDegrees - 90) < rotationTolerance || Math.abs(normalizedRotationDegrees - 270) < rotationTolerance;
18229
+ }
18118
18230
  doInitialPcbPrimitiveRender() {
18119
18231
  if (this.root?.pcbDisabled) return;
18120
18232
  const { db } = this.root;
@@ -18128,6 +18240,9 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18128
18240
  }
18129
18241
  const subcircuit = this.getSubcircuit();
18130
18242
  const position = this._getGlobalPcbPositionBeforeLayout();
18243
+ const isRotated90Degrees = this._isRotated90Degrees();
18244
+ const finalWidth = isRotated90Degrees ? props.height : props.width;
18245
+ const finalHeight = isRotated90Degrees ? props.width : props.height;
18131
18246
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18132
18247
  const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
18133
18248
  pcb_component_id,
@@ -18136,8 +18251,8 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18136
18251
  x: position.x,
18137
18252
  y: position.y
18138
18253
  },
18139
- width: props.width,
18140
- height: props.height,
18254
+ width: finalWidth,
18255
+ height: finalHeight,
18141
18256
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18142
18257
  pcb_group_id: this?.getGroup()?.pcb_group_id ?? void 0,
18143
18258
  stroke_width: props.strokeWidth ?? 0.1,
@@ -18148,6 +18263,10 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18148
18263
  }
18149
18264
  getPcbSize() {
18150
18265
  const { _parsedProps: props } = this;
18266
+ const isRotated90Degrees = this._isRotated90Degrees();
18267
+ if (isRotated90Degrees) {
18268
+ return { width: props.height, height: props.width };
18269
+ }
18151
18270
  return { width: props.width, height: props.height };
18152
18271
  }
18153
18272
  _moveCircuitJsonElements({
@@ -18672,7 +18791,7 @@ var PinHeader = class extends NormalComponent3 {
18672
18791
 
18673
18792
  // lib/components/normal-components/Resonator.ts
18674
18793
  import { resonatorProps } from "@tscircuit/props";
18675
- import { formatSiUnit as formatSiUnit6 } from "format-si-unit";
18794
+ import { formatSiUnit as formatSiUnit7 } from "format-si-unit";
18676
18795
  function getResonatorSymbolName(variant) {
18677
18796
  switch (variant) {
18678
18797
  case "two_ground_pins":
@@ -18710,9 +18829,9 @@ var Resonator = class extends NormalComponent3 {
18710
18829
  this.source_component_id = source_component.source_component_id;
18711
18830
  }
18712
18831
  _getSchematicSymbolDisplayValue() {
18713
- const freqDisplay = `${formatSiUnit6(this._parsedProps.frequency)}Hz`;
18832
+ const freqDisplay = `${formatSiUnit7(this._parsedProps.frequency)}Hz`;
18714
18833
  if (this._parsedProps.loadCapacitance) {
18715
- return `${freqDisplay} / ${formatSiUnit6(this._parsedProps.loadCapacitance)}F`;
18834
+ return `${freqDisplay} / ${formatSiUnit7(this._parsedProps.loadCapacitance)}F`;
18716
18835
  }
18717
18836
  return freqDisplay;
18718
18837
  }
@@ -18720,7 +18839,7 @@ var Resonator = class extends NormalComponent3 {
18720
18839
 
18721
18840
  // lib/components/normal-components/Potentiometer.ts
18722
18841
  import { potentiometerProps } from "@tscircuit/props";
18723
- import { formatSiUnit as formatSiUnit7 } from "format-si-unit";
18842
+ import { formatSiUnit as formatSiUnit8 } from "format-si-unit";
18724
18843
  function getPotentiometerSymbolName(variant) {
18725
18844
  switch (variant) {
18726
18845
  case "three_pin":
@@ -18741,7 +18860,7 @@ var Potentiometer = class extends NormalComponent3 {
18741
18860
  };
18742
18861
  }
18743
18862
  _getSchematicSymbolDisplayValue() {
18744
- return `${formatSiUnit7(this._parsedProps.maxResistance)}\u03A9`;
18863
+ return `${formatSiUnit8(this._parsedProps.maxResistance)}\u03A9`;
18745
18864
  }
18746
18865
  doInitialSourceRender() {
18747
18866
  const { db } = this.root;
@@ -18825,7 +18944,7 @@ var PushButton = class extends NormalComponent3 {
18825
18944
 
18826
18945
  // lib/components/normal-components/Crystal.ts
18827
18946
  import { crystalProps } from "@tscircuit/props";
18828
- import { formatSiUnit as formatSiUnit8 } from "format-si-unit";
18947
+ import { formatSiUnit as formatSiUnit9 } from "format-si-unit";
18829
18948
  var Crystal = class extends NormalComponent3 {
18830
18949
  // @ts-ignore
18831
18950
  get config() {
@@ -18852,9 +18971,9 @@ var Crystal = class extends NormalComponent3 {
18852
18971
  });
18853
18972
  }
18854
18973
  _getSchematicSymbolDisplayValue() {
18855
- const freqDisplay = `${formatSiUnit8(this._parsedProps.frequency)}Hz`;
18974
+ const freqDisplay = `${formatSiUnit9(this._parsedProps.frequency)}Hz`;
18856
18975
  if (this._parsedProps.loadCapacitance) {
18857
- return `${freqDisplay} / ${formatSiUnit8(
18976
+ return `${freqDisplay} / ${formatSiUnit9(
18858
18977
  this._parsedProps.loadCapacitance
18859
18978
  )}F`;
18860
18979
  }
@@ -19909,7 +20028,7 @@ import { identity as identity5 } from "transformation-matrix";
19909
20028
  var package_default = {
19910
20029
  name: "@tscircuit/core",
19911
20030
  type: "module",
19912
- version: "0.0.942",
20031
+ version: "0.0.944",
19913
20032
  types: "dist/index.d.ts",
19914
20033
  main: "dist/index.js",
19915
20034
  module: "dist/index.js",
@@ -19952,7 +20071,7 @@ var package_default = {
19952
20071
  "@tscircuit/math-utils": "^0.0.29",
19953
20072
  "@tscircuit/miniflex": "^0.0.4",
19954
20073
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
19955
- "@tscircuit/props": "^0.0.435",
20074
+ "@tscircuit/props": "^0.0.438",
19956
20075
  "@tscircuit/schematic-match-adapt": "^0.0.16",
19957
20076
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
19958
20077
  "@tscircuit/solver-utils": "^0.0.3",
@@ -19986,7 +20105,7 @@ var package_default = {
19986
20105
  poppygl: "^0.0.16",
19987
20106
  react: "^19.1.0",
19988
20107
  "react-dom": "^19.1.0",
19989
- "schematic-symbols": "^0.0.202",
20108
+ "schematic-symbols": "^0.0.203",
19990
20109
  spicey: "^0.0.14",
19991
20110
  "ts-expect": "^1.3.0",
19992
20111
  tsup: "^8.2.4",
@@ -20460,6 +20579,7 @@ export {
20460
20579
  CopperPour,
20461
20580
  CopperText,
20462
20581
  Crystal,
20582
+ CurrentSource,
20463
20583
  Cutout,
20464
20584
  Diode,
20465
20585
  FabricationNoteDimension,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.943",
4
+ "version": "0.0.945",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@tscircuit/math-utils": "^0.0.29",
45
45
  "@tscircuit/miniflex": "^0.0.4",
46
46
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
47
- "@tscircuit/props": "^0.0.435",
47
+ "@tscircuit/props": "^0.0.438",
48
48
  "@tscircuit/schematic-match-adapt": "^0.0.16",
49
49
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
50
50
  "@tscircuit/solver-utils": "^0.0.3",
@@ -78,7 +78,7 @@
78
78
  "poppygl": "^0.0.16",
79
79
  "react": "^19.1.0",
80
80
  "react-dom": "^19.1.0",
81
- "schematic-symbols": "^0.0.202",
81
+ "schematic-symbols": "^0.0.203",
82
82
  "spicey": "^0.0.14",
83
83
  "ts-expect": "^1.3.0",
84
84
  "tsup": "^8.2.4",