@tscircuit/core 0.0.1810 → 0.0.1811

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
@@ -1799,6 +1799,20 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
1799
1799
  width: number;
1800
1800
  height: number;
1801
1801
  };
1802
+ /**
1803
+ * Bounds in the primitive's footprint-local PCB frame before parent
1804
+ * transforms are applied. This is a right-handed frame with +X right, +Y
1805
+ * toward the top of the board, +Z above the board, and all values in mm.
1806
+ *
1807
+ * Most primitives are centered on their local origin. Path-like primitives
1808
+ * can override this when their authored coordinates are not centered.
1809
+ */
1810
+ _getPcbLocalBoundsBeforeLayout(): {
1811
+ left: number;
1812
+ right: number;
1813
+ top: number;
1814
+ bottom: number;
1815
+ };
1802
1816
  protected _getPcbComponentLayer(): LayerRef | undefined;
1803
1817
  /**
1804
1818
  * Determine if this pcb primitive should be flipped because the primitive
@@ -15472,7 +15486,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, Polarized
15472
15486
  doInitialSourceRender(): void;
15473
15487
  }
15474
15488
 
15475
- declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "feed"> {
15489
+ declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "feed" | "pin2" | "ground" | "gnd" | "feed2"> {
15476
15490
  get config(): {
15477
15491
  componentName: string;
15478
15492
  zodProps: zod.ZodObject<{
@@ -19353,6 +19367,8 @@ declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "fee
19353
19367
  mfn: zod.ZodOptional<zod.ZodString>;
19354
19368
  manufacturerPartNumber: zod.ZodOptional<zod.ZodString>;
19355
19369
  } & {
19370
+ antennaShape: zod.ZodOptional<zod.ZodEnum<["2.4ghz_quarter_wave_monopole", "2.4ghz_meandered_monopole", "2.4ghz_inverted_f", "2.4ghz_meandered_inverted_f", "2.4ghz_folded_dipole"]>>;
19371
+ frequencyBand: zod.ZodOptional<zod.ZodEnum<["2.4ghz", "5ghz", "6ghz", "dual_band_2.4ghz_5ghz", "tri_band_2.4ghz_5ghz_6ghz"]>>;
19356
19372
  pcbPath: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodEffects<zod.ZodObject<{
19357
19373
  x: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
19358
19374
  y: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
@@ -20071,6 +20087,8 @@ declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "fee
20071
20087
  manufacturerPartNumber?: string | undefined;
20072
20088
  schSectionName?: string | undefined;
20073
20089
  schSheetName?: string | undefined;
20090
+ antennaShape?: "2.4ghz_quarter_wave_monopole" | "2.4ghz_meandered_monopole" | "2.4ghz_inverted_f" | "2.4ghz_meandered_inverted_f" | "2.4ghz_folded_dipole" | undefined;
20091
+ frequencyBand?: "2.4ghz" | "5ghz" | "6ghz" | "dual_band_2.4ghz_5ghz" | "tri_band_2.4ghz_5ghz_6ghz" | undefined;
20074
20092
  pcbPath?: (string | {
20075
20093
  x: number;
20076
20094
  y: number;
@@ -20742,6 +20760,8 @@ declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "fee
20742
20760
  manufacturerPartNumber?: string | undefined;
20743
20761
  schSectionName?: string | undefined;
20744
20762
  schSheetName?: string | undefined;
20763
+ antennaShape?: "2.4ghz_quarter_wave_monopole" | "2.4ghz_meandered_monopole" | "2.4ghz_inverted_f" | "2.4ghz_meandered_inverted_f" | "2.4ghz_folded_dipole" | undefined;
20764
+ frequencyBand?: "2.4ghz" | "5ghz" | "6ghz" | "dual_band_2.4ghz_5ghz" | "tri_band_2.4ghz_5ghz_6ghz" | undefined;
20745
20765
  pcbPath?: (string | {
20746
20766
  x: string | number;
20747
20767
  y: string | number;
@@ -20759,6 +20779,7 @@ declare class Antenna extends NormalComponent<typeof antennaProps, "pin1" | "fee
20759
20779
  };
20760
20780
  getRefDesPrefixes(): string[];
20761
20781
  initPorts(): void;
20782
+ doInitialReactSubtreesRender(): void;
20762
20783
  doInitialCreateTracesFromProps(): void;
20763
20784
  }
20764
20785
 
@@ -106767,6 +106788,17 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
106767
106788
  width: number;
106768
106789
  height: number;
106769
106790
  };
106791
+ /**
106792
+ * The route points are authored in the containing footprint's right-handed
106793
+ * local PCB frame: +X right, +Y toward the top of the board, +Z above the
106794
+ * board, with coordinates and widths in mm.
106795
+ */
106796
+ _getPcbLocalBoundsBeforeLayout(): {
106797
+ left: number;
106798
+ right: number;
106799
+ top: number;
106800
+ bottom: number;
106801
+ };
106770
106802
  }
106771
106803
 
106772
106804
  declare const pcbViaProps: z.ZodObject<{
package/dist/index.js CHANGED
@@ -1872,6 +1872,23 @@ var PrimitiveComponent2 = class extends Renderable {
1872
1872
  height: 0
1873
1873
  };
1874
1874
  }
1875
+ /**
1876
+ * Bounds in the primitive's footprint-local PCB frame before parent
1877
+ * transforms are applied. This is a right-handed frame with +X right, +Y
1878
+ * toward the top of the board, +Z above the board, and all values in mm.
1879
+ *
1880
+ * Most primitives are centered on their local origin. Path-like primitives
1881
+ * can override this when their authored coordinates are not centered.
1882
+ */
1883
+ _getPcbLocalBoundsBeforeLayout() {
1884
+ const { width, height } = this.getPcbSize();
1885
+ return {
1886
+ left: -width / 2,
1887
+ right: width / 2,
1888
+ top: height / 2,
1889
+ bottom: -height / 2
1890
+ };
1891
+ }
1875
1892
  _getPcbComponentLayer() {
1876
1893
  return this._parsedProps.layer;
1877
1894
  }
@@ -9240,9 +9257,9 @@ var PcbNoteText = class extends PrimitiveComponent2 {
9240
9257
  };
9241
9258
 
9242
9259
  // lib/components/primitive-components/PcbTrace.ts
9243
- import { z as z7 } from "zod";
9244
9260
  import { pcb_trace_route_point } from "circuit-json";
9245
9261
  import { applyToPoint as applyToPoint13 } from "transformation-matrix";
9262
+ import { z as z7 } from "zod";
9246
9263
  var pcbTraceProps = z7.object({
9247
9264
  route: z7.array(pcb_trace_route_point),
9248
9265
  // If this primitive PcbTrace needs to be associated with a source_trace_id
@@ -9304,11 +9321,26 @@ var PcbTrace = class extends PrimitiveComponent2 {
9304
9321
  this.pcb_trace_id = pcb_trace.pcb_trace_id;
9305
9322
  }
9306
9323
  getPcbSize() {
9324
+ const bounds = this._getPcbLocalBoundsBeforeLayout();
9325
+ return {
9326
+ width: bounds.right - bounds.left,
9327
+ height: bounds.top - bounds.bottom
9328
+ };
9329
+ }
9330
+ /**
9331
+ * The route points are authored in the containing footprint's right-handed
9332
+ * local PCB frame: +X right, +Y toward the top of the board, +Z above the
9333
+ * board, with coordinates and widths in mm.
9334
+ */
9335
+ _getPcbLocalBoundsBeforeLayout() {
9307
9336
  const { _parsedProps: props } = this;
9308
9337
  if (!props.route || props.route.length === 0) {
9309
- return { width: 0, height: 0 };
9338
+ return { left: 0, right: 0, top: 0, bottom: 0 };
9310
9339
  }
9311
- let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
9340
+ let minX = Infinity;
9341
+ let maxX = -Infinity;
9342
+ let minY = Infinity;
9343
+ let maxY = -Infinity;
9312
9344
  for (const point6 of props.route) {
9313
9345
  if (point6.route_type === "through_pad") {
9314
9346
  minX = Math.min(minX, point6.start.x, point6.end.x);
@@ -9350,11 +9382,13 @@ var PcbTrace = class extends PrimitiveComponent2 {
9350
9382
  }
9351
9383
  }
9352
9384
  if (minX === Infinity || maxX === -Infinity || minY === Infinity || maxY === -Infinity) {
9353
- return { width: 0, height: 0 };
9385
+ return { left: 0, right: 0, top: 0, bottom: 0 };
9354
9386
  }
9355
9387
  return {
9356
- width: maxX - minX,
9357
- height: maxY - minY
9388
+ left: minX,
9389
+ right: maxX,
9390
+ top: maxY,
9391
+ bottom: minY
9358
9392
  };
9359
9393
  }
9360
9394
  };
@@ -12261,12 +12295,12 @@ function getBoundsOfPcbComponents(components) {
12261
12295
  if (child.isPcbPrimitive && !NON_PHYSICAL_PCB_PRIMITIVE_PREFIXES.some(
12262
12296
  (prefix) => child.componentName.startsWith(prefix)
12263
12297
  )) {
12264
- const { width: width2, height: height2 } = child.getPcbSize();
12298
+ const localBounds = child._getPcbLocalBoundsBeforeLayout();
12265
12299
  const footprintLocalCorners = [
12266
- { x: -width2 / 2, y: -height2 / 2 },
12267
- { x: width2 / 2, y: -height2 / 2 },
12268
- { x: width2 / 2, y: height2 / 2 },
12269
- { x: -width2 / 2, y: height2 / 2 }
12300
+ { x: localBounds.left, y: localBounds.bottom },
12301
+ { x: localBounds.right, y: localBounds.bottom },
12302
+ { x: localBounds.right, y: localBounds.top },
12303
+ { x: localBounds.left, y: localBounds.top }
12270
12304
  ];
12271
12305
  const boardWorldCorners = footprintLocalCorners.map(
12272
12306
  (corner) => applyToPoint24(child._computePcbGlobalTransformBeforeLayout(), corner)
@@ -42174,7 +42208,7 @@ function Group_getRoutingPhasePlans(group) {
42174
42208
  var package_default = {
42175
42209
  name: "@tscircuit/core",
42176
42210
  type: "module",
42177
- version: "0.0.1809",
42211
+ version: "0.0.1810",
42178
42212
  types: "dist/index.d.ts",
42179
42213
  main: "dist/index.js",
42180
42214
  module: "dist/index.js",
@@ -42227,7 +42261,7 @@ var package_default = {
42227
42261
  "@tscircuit/math-utils": "^0.0.36",
42228
42262
  "@tscircuit/miniflex": "^0.0.4",
42229
42263
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
42230
- "@tscircuit/props": "^0.0.643",
42264
+ "@tscircuit/props": "^0.0.644",
42231
42265
  "@tscircuit/schematic-match-adapt": "^0.0.18",
42232
42266
  "@tscircuit/schematic-trace-solver": "^0.0.173",
42233
42267
  "@tscircuit/solver-utils": "^0.0.16",
@@ -42305,7 +42339,7 @@ var package_default = {
42305
42339
  },
42306
42340
  overrides: {
42307
42341
  "@tscircuit/circuit-json-util": "^0.0.106",
42308
- "@tscircuit/props": "^0.0.643",
42342
+ "@tscircuit/props": "^0.0.644",
42309
42343
  "circuit-json": "^0.0.479"
42310
42344
  }
42311
42345
  };
@@ -49051,6 +49085,96 @@ var Panel = class extends Subpanel {
49051
49085
 
49052
49086
  // lib/components/normal-components/Antenna.ts
49053
49087
  import { antennaProps } from "@tscircuit/props";
49088
+
49089
+ // lib/components/normal-components/get-generated-antenna-geometry.ts
49090
+ var getGeneratedAntennaGeometry = (antennaShape) => {
49091
+ switch (antennaShape) {
49092
+ case "2.4ghz_quarter_wave_monopole":
49093
+ return {
49094
+ traceWidth: 0.6,
49095
+ feedPoint: { x: 0, y: 0 },
49096
+ route: [
49097
+ { x: 0, y: 0 },
49098
+ { x: 31, y: 0 }
49099
+ ]
49100
+ };
49101
+ case "2.4ghz_meandered_monopole":
49102
+ return {
49103
+ traceWidth: 0.5,
49104
+ feedPoint: { x: 0, y: 0 },
49105
+ route: [
49106
+ { x: 0, y: 0 },
49107
+ { x: 0, y: 6 },
49108
+ { x: 3, y: 6 },
49109
+ { x: 3, y: 1.5 },
49110
+ { x: 6, y: 1.5 },
49111
+ { x: 6, y: 6 },
49112
+ { x: 9, y: 6 },
49113
+ { x: 9, y: 1.5 },
49114
+ { x: 12, y: 1.5 },
49115
+ { x: 12, y: 6 },
49116
+ { x: 15, y: 6 }
49117
+ ]
49118
+ };
49119
+ case "2.4ghz_inverted_f":
49120
+ return {
49121
+ traceWidth: 0.8,
49122
+ feedPoint: { x: 0, y: 0 },
49123
+ secondaryPort: { point: { x: -4, y: 0 }, role: "ground" },
49124
+ groundViaPoint: { x: -4, y: 0 },
49125
+ route: [
49126
+ { x: -4, y: 0 },
49127
+ { x: -4, y: 3 },
49128
+ { x: 0, y: 3 },
49129
+ { x: 0, y: 0 },
49130
+ { x: 0, y: 3 },
49131
+ { x: -4, y: 3 },
49132
+ { x: -4, y: 8 },
49133
+ { x: 22, y: 8 }
49134
+ ]
49135
+ };
49136
+ case "2.4ghz_meandered_inverted_f":
49137
+ return {
49138
+ traceWidth: 0.5,
49139
+ feedPoint: { x: 0, y: 0 },
49140
+ secondaryPort: { point: { x: -1.7, y: 0 }, role: "ground" },
49141
+ groundViaPoint: { x: -1.7, y: 0 },
49142
+ route: [
49143
+ { x: -1.7, y: 0 },
49144
+ { x: -1.7, y: 4.9 },
49145
+ { x: 0, y: 4.9 },
49146
+ { x: 0, y: 0 },
49147
+ { x: 0, y: 4.9 },
49148
+ { x: -1.7, y: 4.9 },
49149
+ { x: 2.3, y: 4.9 },
49150
+ { x: 2.3, y: 1.4 },
49151
+ { x: 5.3, y: 1.4 },
49152
+ { x: 5.3, y: 4.9 },
49153
+ { x: 8.3, y: 4.9 },
49154
+ { x: 8.3, y: 1.4 },
49155
+ { x: 11.3, y: 1.4 },
49156
+ { x: 11.3, y: 4.9 },
49157
+ { x: 13.3, y: 4.9 }
49158
+ ]
49159
+ };
49160
+ case "2.4ghz_folded_dipole":
49161
+ return {
49162
+ traceWidth: 0.9,
49163
+ feedPoint: { x: 0, y: 0 },
49164
+ secondaryPort: { point: { x: 1.2, y: 0 }, role: "feed2" },
49165
+ route: [
49166
+ { x: 0, y: 0 },
49167
+ { x: -22.4, y: 0 },
49168
+ { x: -22.4, y: 9 },
49169
+ { x: 23.6, y: 9 },
49170
+ { x: 23.6, y: 0 },
49171
+ { x: 1.2, y: 0 }
49172
+ ]
49173
+ };
49174
+ }
49175
+ };
49176
+
49177
+ // lib/components/normal-components/Antenna.ts
49054
49178
  var Antenna = class extends NormalComponent3 {
49055
49179
  get config() {
49056
49180
  return {
@@ -49064,11 +49188,82 @@ var Antenna = class extends NormalComponent3 {
49064
49188
  return ["ANT"];
49065
49189
  }
49066
49190
  initPorts() {
49191
+ const { antennaShape, pcbPath } = this._parsedProps;
49192
+ const secondaryPortRole = pcbPath ? void 0 : antennaShape === "2.4ghz_inverted_f" || antennaShape === "2.4ghz_meandered_inverted_f" ? "ground" : antennaShape === "2.4ghz_folded_dipole" ? "feed2" : void 0;
49067
49193
  super.initPorts({
49068
- pinCount: 1,
49069
- additionalAliases: { pin1: ["feed"] }
49194
+ pinCount: secondaryPortRole ? 2 : 1,
49195
+ additionalAliases: {
49196
+ pin1: ["feed"],
49197
+ ...secondaryPortRole === "ground" ? { pin2: ["ground", "gnd"] } : secondaryPortRole === "feed2" ? { pin2: ["feed2"] } : {}
49198
+ }
49070
49199
  });
49071
49200
  }
49201
+ doInitialReactSubtreesRender() {
49202
+ super.doInitialReactSubtreesRender();
49203
+ const { antennaShape, pcbPath } = this._parsedProps;
49204
+ if (!antennaShape) return;
49205
+ const hasFootprint = this.children.some(
49206
+ (child) => child.componentName === "Footprint"
49207
+ );
49208
+ if (pcbPath && hasFootprint) return;
49209
+ const geometry = pcbPath ? void 0 : getGeneratedAntennaGeometry(antennaShape);
49210
+ const generatedFootprint = new Footprint({
49211
+ name: `${this.name}_generated_antenna`
49212
+ });
49213
+ if (!hasFootprint) {
49214
+ generatedFootprint.add(
49215
+ new SmtPad({
49216
+ shape: "rect",
49217
+ width: 0.8,
49218
+ height: 0.8,
49219
+ pcbX: geometry?.feedPoint.x ?? 0,
49220
+ pcbY: geometry?.feedPoint.y ?? 0,
49221
+ layer: "top",
49222
+ portHints: ["pin1"],
49223
+ coveredWithSolderMask: true
49224
+ })
49225
+ );
49226
+ }
49227
+ if (geometry) {
49228
+ generatedFootprint.add(
49229
+ new PcbTrace({
49230
+ route: geometry.route.map((point6) => ({
49231
+ route_type: "wire",
49232
+ ...point6,
49233
+ width: geometry.traceWidth,
49234
+ layer: "top"
49235
+ }))
49236
+ })
49237
+ );
49238
+ if (geometry.secondaryPort && !hasFootprint) {
49239
+ generatedFootprint.add(
49240
+ new SmtPad({
49241
+ shape: "rect",
49242
+ width: 0.8,
49243
+ height: 0.8,
49244
+ pcbX: geometry.secondaryPort.point.x,
49245
+ pcbY: geometry.secondaryPort.point.y,
49246
+ layer: "top",
49247
+ portHints: ["pin2"],
49248
+ coveredWithSolderMask: true
49249
+ })
49250
+ );
49251
+ }
49252
+ if (geometry.groundViaPoint) {
49253
+ generatedFootprint.add(
49254
+ new PcbVia({
49255
+ pcbX: geometry.groundViaPoint.x,
49256
+ pcbY: geometry.groundViaPoint.y,
49257
+ holeDiameter: 0.3,
49258
+ outerDiameter: 0.7,
49259
+ isTented: true,
49260
+ netIsAssignable: true
49261
+ })
49262
+ );
49263
+ }
49264
+ }
49265
+ this.add(generatedFootprint);
49266
+ }
49072
49267
  doInitialCreateTracesFromProps() {
49073
49268
  super.doInitialCreateTracesFromProps();
49074
49269
  const { pcbPath } = this._parsedProps;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1810",
4
+ "version": "0.0.1811",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "@tscircuit/math-utils": "^0.0.36",
55
55
  "@tscircuit/miniflex": "^0.0.4",
56
56
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
57
- "@tscircuit/props": "^0.0.643",
57
+ "@tscircuit/props": "^0.0.644",
58
58
  "@tscircuit/schematic-match-adapt": "^0.0.18",
59
59
  "@tscircuit/schematic-trace-solver": "^0.0.173",
60
60
  "@tscircuit/solver-utils": "^0.0.16",
@@ -132,7 +132,7 @@
132
132
  },
133
133
  "overrides": {
134
134
  "@tscircuit/circuit-json-util": "^0.0.106",
135
- "@tscircuit/props": "^0.0.643",
135
+ "@tscircuit/props": "^0.0.644",
136
136
  "circuit-json": "^0.0.479"
137
137
  }
138
138
  }