@tscircuit/core 0.0.1430 → 0.0.1431

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
@@ -135849,6 +135849,9 @@ declare class Mosfet extends NormalComponent<typeof mosfetProps> {
135849
135849
  } & {
135850
135850
  channelType: zod.ZodEnum<["n", "p"]>;
135851
135851
  mosfetMode: zod.ZodEnum<["enhancement", "depletion"]>;
135852
+ symbolDrainSide: zod.ZodOptional<zod.ZodEnum<["left", "right", "top", "bottom"]>>;
135853
+ symbolSourceSide: zod.ZodOptional<zod.ZodEnum<["left", "right", "top", "bottom"]>>;
135854
+ symbolGateSide: zod.ZodOptional<zod.ZodEnum<["left", "right", "top", "bottom"]>>;
135852
135855
  connections: zod.ZodOptional<zod.ZodRecord<zod.ZodEnum<["pin1", "drain", "pin2", "source", "pin3", "gate"]>, zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodReadonly<zod.ZodArray<zod.ZodString, "many">>]>, zod.ZodArray<zod.ZodString, "many">]>>>;
135853
135856
  }, "strip", zod.ZodTypeAny, {
135854
135857
  name: string;
@@ -136431,6 +136434,9 @@ declare class Mosfet extends NormalComponent<typeof mosfetProps> {
136431
136434
  schSectionName?: string | undefined;
136432
136435
  schSheetName?: string | undefined;
136433
136436
  connections?: Partial<Record<"pin1" | "pin2" | "source" | "pin3" | "gate" | "drain", string | readonly string[] | string[]>> | undefined;
136437
+ symbolDrainSide?: "left" | "right" | "top" | "bottom" | undefined;
136438
+ symbolSourceSide?: "left" | "right" | "top" | "bottom" | undefined;
136439
+ symbolGateSide?: "left" | "right" | "top" | "bottom" | undefined;
136434
136440
  }, {
136435
136441
  name: string;
136436
136442
  channelType: "n" | "p";
@@ -137014,6 +137020,9 @@ declare class Mosfet extends NormalComponent<typeof mosfetProps> {
137014
137020
  schSectionName?: string | undefined;
137015
137021
  schSheetName?: string | undefined;
137016
137022
  connections?: Partial<Record<"pin1" | "pin2" | "source" | "pin3" | "gate" | "drain", string | readonly string[] | string[]>> | undefined;
137023
+ symbolDrainSide?: "left" | "right" | "top" | "bottom" | undefined;
137024
+ symbolSourceSide?: "left" | "right" | "top" | "bottom" | undefined;
137025
+ symbolGateSide?: "left" | "right" | "top" | "bottom" | undefined;
137017
137026
  }>;
137018
137027
  shouldRenderAsSchematicBox: boolean;
137019
137028
  };
package/dist/index.js CHANGED
@@ -22396,7 +22396,7 @@ function Group_getRoutingPhasePlans(group) {
22396
22396
  var package_default = {
22397
22397
  name: "@tscircuit/core",
22398
22398
  type: "module",
22399
- version: "0.0.1429",
22399
+ version: "0.0.1430",
22400
22400
  types: "dist/index.d.ts",
22401
22401
  main: "dist/index.js",
22402
22402
  module: "dist/index.js",
@@ -22445,7 +22445,7 @@ var package_default = {
22445
22445
  "@tscircuit/math-utils": "^0.0.36",
22446
22446
  "@tscircuit/miniflex": "^0.0.4",
22447
22447
  "@tscircuit/ngspice-spice-engine": "^0.0.19",
22448
- "@tscircuit/props": "^0.0.571",
22448
+ "@tscircuit/props": "^0.0.574",
22449
22449
  "@tscircuit/schematic-match-adapt": "^0.0.18",
22450
22450
  "@tscircuit/schematic-trace-solver": "^0.0.96",
22451
22451
  "@tscircuit/solver-utils": "^0.0.16",
@@ -22480,7 +22480,7 @@ var package_default = {
22480
22480
  poppygl: "^0.0.25",
22481
22481
  react: "^19.1.0",
22482
22482
  "react-dom": "^19.1.0",
22483
- "schematic-symbols": "^0.0.231",
22483
+ "schematic-symbols": "^0.0.232",
22484
22484
  spicets: "^0.0.2",
22485
22485
  spicey: "^0.0.14",
22486
22486
  "stack-svgs": "^0.0.1",
@@ -31785,14 +31785,72 @@ var Crystal = class extends NormalComponent3 {
31785
31785
 
31786
31786
  // lib/components/normal-components/Mosfet.ts
31787
31787
  import { mosfetProps } from "@tscircuit/props";
31788
+
31789
+ // lib/components/normal-components/get-mosfet-schematic-symbol-name.ts
31790
+ var possibleOrientations = [
31791
+ { gate: "left", drain: "top", source: "bottom" },
31792
+ { gate: "left", drain: "bottom", source: "top" },
31793
+ { gate: "right", drain: "top", source: "bottom" },
31794
+ { gate: "right", drain: "bottom", source: "top" },
31795
+ { gate: "top", drain: "left", source: "right" },
31796
+ { gate: "top", drain: "right", source: "left" },
31797
+ { gate: "bottom", drain: "left", source: "right" },
31798
+ { gate: "bottom", drain: "right", source: "left" }
31799
+ ];
31800
+ var getBaselineOrientation = (rotation4) => {
31801
+ const normalizedRotation = (rotation4 % 360 + 360) % 360;
31802
+ if (normalizedRotation % 90 !== 0) {
31803
+ throw new Error(
31804
+ `Schematic rotation ${rotation4} is not supported for Mosfet`
31805
+ );
31806
+ }
31807
+ return [
31808
+ { gate: "left", drain: "top", source: "bottom" },
31809
+ { gate: "top", drain: "right", source: "left" },
31810
+ { gate: "right", drain: "bottom", source: "top" },
31811
+ { gate: "bottom", drain: "left", source: "right" }
31812
+ ][normalizedRotation / 90];
31813
+ };
31814
+ var getRequestedOrientation = (props) => {
31815
+ const requestedSides = {
31816
+ drain: props.symbolDrainSide,
31817
+ source: props.symbolSourceSide,
31818
+ gate: props.symbolGateSide
31819
+ };
31820
+ const baseline = getBaselineOrientation(Number(props.schRotation ?? 0));
31821
+ const matchingOrientations = possibleOrientations.filter(
31822
+ (orientation) => Object.keys(requestedSides).every(
31823
+ (portName) => requestedSides[portName] === void 0 || requestedSides[portName] === orientation[portName]
31824
+ )
31825
+ );
31826
+ if (matchingOrientations.length === 0) {
31827
+ const requestedDescription = Object.entries(requestedSides).filter(([, side]) => side !== void 0).map(([portName, side]) => `${portName}=${side}`).join(", ");
31828
+ throw new Error(
31829
+ `Invalid MOSFET symbol port side combination (${requestedDescription}). The gate must be perpendicular to the drain and source, and the drain and source must be opposite.`
31830
+ );
31831
+ }
31832
+ return matchingOrientations.sort((a, b) => {
31833
+ const score = (orientation) => Object.keys(baseline).filter(
31834
+ (portName) => orientation[portName] !== baseline[portName]
31835
+ ).length;
31836
+ return score(a) - score(b);
31837
+ })[0];
31838
+ };
31839
+ var getMosfetSchematicSymbolName = (props) => {
31840
+ const mosfetMode = props.mosfetMode === "depletion" ? "d" : "e";
31841
+ const baseSymbolName = `${props.channelType}_channel_${mosfetMode}_mosfet_transistor`;
31842
+ const hasSymbolSideProps = props.symbolDrainSide !== void 0 || props.symbolSourceSide !== void 0 || props.symbolGateSide !== void 0;
31843
+ if (!hasSymbolSideProps) return baseSymbolName;
31844
+ const { gate, drain } = getRequestedOrientation(props);
31845
+ return `${baseSymbolName}_gate_${gate}_drain_${drain}`;
31846
+ };
31847
+
31848
+ // lib/components/normal-components/Mosfet.ts
31788
31849
  var Mosfet = class extends NormalComponent3 {
31789
31850
  get config() {
31790
- const mosfetMode = this.props.mosfetMode === "depletion" ? "d" : "e";
31791
- const channelType = this.props.channelType;
31792
- const baseSymbolName = `${channelType}_channel_${mosfetMode}_mosfet_transistor`;
31793
31851
  return {
31794
31852
  componentName: "Mosfet",
31795
- schematicSymbolName: this.props.symbolName ?? baseSymbolName,
31853
+ schematicSymbolName: this.props.symbolName ?? getMosfetSchematicSymbolName(this.props),
31796
31854
  zodProps: mosfetProps,
31797
31855
  shouldRenderAsSchematicBox: false
31798
31856
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1430",
4
+ "version": "0.0.1431",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "@tscircuit/math-utils": "^0.0.36",
51
51
  "@tscircuit/miniflex": "^0.0.4",
52
52
  "@tscircuit/ngspice-spice-engine": "^0.0.19",
53
- "@tscircuit/props": "^0.0.571",
53
+ "@tscircuit/props": "^0.0.574",
54
54
  "@tscircuit/schematic-match-adapt": "^0.0.18",
55
55
  "@tscircuit/schematic-trace-solver": "^0.0.96",
56
56
  "@tscircuit/solver-utils": "^0.0.16",
@@ -85,7 +85,7 @@
85
85
  "poppygl": "^0.0.25",
86
86
  "react": "^19.1.0",
87
87
  "react-dom": "^19.1.0",
88
- "schematic-symbols": "^0.0.231",
88
+ "schematic-symbols": "^0.0.232",
89
89
  "spicets": "^0.0.2",
90
90
  "spicey": "^0.0.14",
91
91
  "stack-svgs": "^0.0.1",