jscad-electronics 0.0.165 → 0.0.166

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/vanilla.js CHANGED
@@ -193,189 +193,8 @@ var ExtrudedPads = ({
193
193
  ] });
194
194
  };
195
195
 
196
- // lib/CeramicChipAntenna.tsx
197
- import { fp as fp2 } from "@tscircuit/footprinter";
198
- var CeramicChipAntenna = ({
199
- footprint = "smdpads2_p5.4mm_pw1mm_ph2mm"
200
- }) => {
201
- const pads = fp2.string(footprint).circuitJson().filter(
202
- (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
203
- );
204
- if (pads.length !== 2) throw new Error("CeramicChipAntenna requires two pads");
205
- const [a, b] = pads;
206
- const angle = Math.atan2(b.y - a.y, b.x - a.x);
207
- return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, 0], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
208
- /* @__PURE__ */ jsx(
209
- Cuboid,
210
- {
211
- size: [4.44, 1.99, 1.14],
212
- center: [0, 0, 0.575],
213
- color: "#4053a3"
214
- }
215
- ),
216
- [-1, 1].map((side) => /* @__PURE__ */ jsx(
217
- Cuboid,
218
- {
219
- size: [0.4, 2, 1.15],
220
- center: [side * 2.4, 0, 0.575],
221
- color: "#c2c4c7"
222
- },
223
- side
224
- )),
225
- /* @__PURE__ */ jsx(
226
- Cuboid,
227
- {
228
- size: [0.9, 2, 0.01],
229
- center: [-1.75, 0, 1.145],
230
- color: "#b1b3b6"
231
- }
232
- )
233
- ] }) });
234
- };
235
-
236
- // lib/MelfResistor.tsx
237
- import { fp as fp3 } from "@tscircuit/footprinter";
238
- var melfResistorSizes = {
239
- "0102": [2.2, 1.1, 0.4],
240
- "0204": [3.6, 1.4, 0.75],
241
- "0207": [5.8, 2.2, 1.15]
242
- };
243
- var MelfResistor = ({
244
- size = "0204",
245
- footprint = "smdpads2_p2.8mm_pw1.2mm_ph1.6mm"
246
- }) => {
247
- const dims = melfResistorSizes[size];
248
- if (!dims) throw new Error("Unsupported MELF resistor size");
249
- const [length, diameter, capLength] = dims;
250
- const pads = fp3.string(footprint).circuitJson().filter(
251
- (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
252
- );
253
- if (pads.length !== 2) throw new Error("MelfResistor requires two pads");
254
- const [a, b] = pads;
255
- const angle = Math.atan2(b.y - a.y, b.x - a.x);
256
- return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, diameter / 2], children: /* @__PURE__ */ jsx(Rotate, { rotation: [0, 0, angle], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, Math.PI / 2, 0], children: [
257
- /* @__PURE__ */ jsx(Colorize, { color: "#426d63", children: /* @__PURE__ */ jsx(
258
- Cylinder,
259
- {
260
- radius: (diameter - 0.08) / 2,
261
- height: length - 2 * capLength + 0.04
262
- }
263
- ) }),
264
- /* @__PURE__ */ jsx(Colorize, { color: "#c6c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
265
- Cylinder,
266
- {
267
- radius: diameter / 2,
268
- height: capLength,
269
- center: [0, 0, side * (length - capLength) / 2]
270
- },
271
- side
272
- )) })
273
- ] }) }) });
274
- };
275
-
276
- // lib/TwoPadCrystal.tsx
277
- import { fp as fp4 } from "@tscircuit/footprinter";
278
- var twoPadCrystalPackages = {
279
- FC135: [3.2, 1.5, 0.9, 0.7],
280
- FC12M: [2.05, 1.2, 0.6, 0.5],
281
- FC1610AN: [1.65, 1.05, 0.5, 0.4],
282
- NX3225GD: [3.2, 2.5, 0.8, 1.2]
283
- };
284
- var TwoPadCrystal = ({
285
- packageName = "FC135",
286
- footprint = "smdpads2_p2.5mm_pw1mm_ph1.8mm"
287
- }) => {
288
- const dims = twoPadCrystalPackages[packageName];
289
- if (!dims) throw new Error("Unsupported two-pad crystal package");
290
- const [length, width10, height10, terminalLength] = dims;
291
- const pads = fp4.string(footprint).circuitJson().filter(
292
- (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
293
- );
294
- if (pads.length !== 2) throw new Error("TwoPadCrystal requires two pads");
295
- const [a, b] = pads;
296
- const angle = Math.atan2(b.y - a.y, b.x - a.x);
297
- return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, 0], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
298
- /* @__PURE__ */ jsx(Colorize, { color: "#e0dcca", children: /* @__PURE__ */ jsx(Cuboid, { size: [length, width10, 0.2], center: [0, 0, 0.13] }) }),
299
- /* @__PURE__ */ jsx(Colorize, { color: "#acb1b8", children: /* @__PURE__ */ jsx(
300
- RoundedCuboid,
301
- {
302
- size: [length - 0.04, width10 - 0.04, height10 - 0.18],
303
- roundRadius: 0.035,
304
- center: [0, 0, (height10 + 0.18) / 2]
305
- }
306
- ) }),
307
- /* @__PURE__ */ jsx(Colorize, { color: "#c6af65", children: [-1, 1].map((side) => /* @__PURE__ */ jsx(
308
- Cuboid,
309
- {
310
- size: [terminalLength, width10 - 0.12, 0.06],
311
- center: [side * (length - terminalLength) / 2, 0, 0.03]
312
- },
313
- side
314
- )) })
315
- ] }) });
316
- };
317
-
318
- // lib/TantalumCapacitor.tsx
319
- import { fp as fp5 } from "@tscircuit/footprinter";
320
- var tantalumCases = {
321
- A: [3.2, 1.6, 1.6, 1.2, 0.8],
322
- B: [3.5, 2.8, 1.9, 2.2, 0.8],
323
- C: [6, 3.2, 2.6, 2.2, 1.3],
324
- D: [7.3, 4.3, 2.9, 2.4, 1.3]
325
- };
326
- var TantalumCapacitor = ({
327
- caseSize = "A",
328
- footprint = "smdpads2_p3.1mm_pw1.4mm_ph1.6mm"
329
- }) => {
330
- const dims = tantalumCases[caseSize];
331
- if (!dims) throw new Error("Unsupported tantalum case");
332
- const [length, width10, height10, leadWidth, leadLength] = dims;
333
- const pads = fp5.string(footprint).circuitJson().filter(
334
- (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
335
- );
336
- if (pads.length !== 2) throw new Error("TantalumCapacitor requires two pads");
337
- const [a, b] = pads;
338
- const angle = Math.atan2(b.y - a.y, b.x - a.x);
339
- return /* @__PURE__ */ jsx(Translate, { offset: [(a.x + b.x) / 2, (a.y + b.y) / 2, 0], children: /* @__PURE__ */ jsxs(Rotate, { rotation: [0, 0, angle], children: [
340
- /* @__PURE__ */ jsx(Colorize, { color: "#d5a64e", children: /* @__PURE__ */ jsxs(Hull, { children: [
341
- /* @__PURE__ */ jsx(Cuboid, { size: [length - 0.1, width10, 0.02], center: [0, 0, 0.21] }),
342
- /* @__PURE__ */ jsx(
343
- Cuboid,
344
- {
345
- size: [length - 0.25, width10 - 0.15, 0.02],
346
- center: [0, 0, height10 - 0.01]
347
- }
348
- )
349
- ] }) }),
350
- /* @__PURE__ */ jsx(Colorize, { color: "#c5c8cb", children: [-1, 1].map((side) => /* @__PURE__ */ jsxs(Union, { children: [
351
- /* @__PURE__ */ jsx(
352
- Cuboid,
353
- {
354
- size: [leadLength, leadWidth, 0.25],
355
- center: [side * (length - leadLength) / 2, 0, 0.125]
356
- }
357
- ),
358
- /* @__PURE__ */ jsx(
359
- Cuboid,
360
- {
361
- size: [0.15, leadWidth, height10 * 0.45],
362
- center: [side * (length - 0.15) / 2, 0, height10 * 0.225]
363
- }
364
- )
365
- ] }, side)) }),
366
- /* @__PURE__ */ jsx(
367
- Cuboid,
368
- {
369
- size: [0.25, width10 - 0.25, 0.01],
370
- center: [-length / 2 + 0.5, 0, height10],
371
- color: "#423426"
372
- }
373
- )
374
- ] }) });
375
- };
376
-
377
196
  // lib/Footprinter3d.tsx
378
- import { fp as fp14 } from "@tscircuit/footprinter";
197
+ import { fp as fp10 } from "@tscircuit/footprinter";
379
198
  import { mp } from "@tscircuit/modelprinter";
380
199
 
381
200
  // lib/ChipBody.tsx
@@ -5361,7 +5180,7 @@ var JSTPH2_0mm = ({
5361
5180
  };
5362
5181
 
5363
5182
  // lib/JSTXH2_5mm.tsx
5364
- import { fp as fp6 } from "@tscircuit/footprinter";
5183
+ import { fp as fp2 } from "@tscircuit/footprinter";
5365
5184
  var JSTXH2_5mm = ({
5366
5185
  numPins = 4,
5367
5186
  showPins = true,
@@ -5470,7 +5289,7 @@ var JSTXH2_5mm = ({
5470
5289
  showPins && Array.from({ length: numPins }).map((_, i) => /* @__PURE__ */ jsx(Colorize, { color: pinColor, children: /* @__PURE__ */ jsx(Translate, { offset: [startX + i * pitch, 0, pinLength / 2 - 3.4], children: /* @__PURE__ */ jsx(Cuboid, { size: [0.64, 0.64, pinLength] }) }) }, i)),
5471
5290
  showFootprint && (() => {
5472
5291
  try {
5473
- const circuitJson = fp6.string(`jst${numPins}_xh`).circuitJson();
5292
+ const circuitJson = fp2.string(`jst${numPins}_xh`).circuitJson();
5474
5293
  const platedHoles = circuitJson.filter(
5475
5294
  (e) => e.type === "pcb_plated_hole"
5476
5295
  );
@@ -5490,10 +5309,10 @@ var JSTXH2_5mm = ({
5490
5309
  };
5491
5310
 
5492
5311
  // lib/JstSh.tsx
5493
- import { fp as fp7 } from "@tscircuit/footprinter";
5312
+ import { fp as fp3 } from "@tscircuit/footprinter";
5494
5313
  import { mm } from "@tscircuit/mm";
5495
5314
  function isJstShFootprint(footprint) {
5496
- const p = fp7.string(footprint).json();
5315
+ const p = fp3.string(footprint).json();
5497
5316
  if (p.fn !== "jst") return false;
5498
5317
  return Boolean(
5499
5318
  p.sh || p.smd && Math.abs(mm(p.p) - 1) < 0.01 && Math.abs(mm(p.mpx ?? 0) - (p.num_pins - 1 + 2.6)) < 0.15 && Math.abs(mm(p.mpy ?? 0) - 2.525) < 0.15
@@ -5505,9 +5324,9 @@ var JstSh = ({ footprint = "jst6_sh" }) => {
5505
5324
  "JstSh requires a named SH or matching 1mm SH top-entry footprint"
5506
5325
  );
5507
5326
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
5508
- const params = fp7.string(canonical).json();
5509
- const pads = fp7.string(canonical).circuitJson().filter((e) => e.type === "pcb_smtpad" && e.shape === "rect");
5510
- const target = fp7.string(footprint).circuitJson().filter(
5327
+ const params = fp3.string(canonical).json();
5328
+ const pads = fp3.string(canonical).circuitJson().filter((e) => e.type === "pcb_smtpad" && e.shape === "rect");
5329
+ const target = fp3.string(footprint).circuitJson().filter(
5511
5330
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
5512
5331
  );
5513
5332
  const n = params.num_pins;
@@ -6067,9 +5886,9 @@ var SmdPinHeader = ({
6067
5886
  import { mm as mm2 } from "@tscircuit/mm";
6068
5887
 
6069
5888
  // lib/utils/getPlatedHoleCenters.ts
6070
- import { fp as fp8 } from "@tscircuit/footprinter";
5889
+ import { fp as fp4 } from "@tscircuit/footprinter";
6071
5890
  var getPlatedHoleCenters = (footprint) => {
6072
- const elements = fp8.string(footprint).circuitJson();
5891
+ const elements = fp4.string(footprint).circuitJson();
6073
5892
  return elements.filter(
6074
5893
  (element) => element.type === "pcb_plated_hole" && Number.isFinite(element.x) && Number.isFinite(element.y)
6075
5894
  ).map((element) => ({
@@ -6080,9 +5899,9 @@ var getPlatedHoleCenters = (footprint) => {
6080
5899
  };
6081
5900
 
6082
5901
  // lib/utils/getSmtPadRects.ts
6083
- import { fp as fp9 } from "@tscircuit/footprinter";
5902
+ import { fp as fp5 } from "@tscircuit/footprinter";
6084
5903
  var getSmtPadRects = (footprint) => {
6085
- const elements = fp9.string(footprint).circuitJson();
5904
+ const elements = fp5.string(footprint).circuitJson();
6086
5905
  return elements.filter(
6087
5906
  (element) => element.type === "pcb_smtpad" && element.shape === "rect" && Number.isFinite(element.x) && Number.isFinite(element.y)
6088
5907
  ).map((element) => ({
@@ -6799,18 +6618,18 @@ var SmdPushButton = ({
6799
6618
  };
6800
6619
 
6801
6620
  // lib/SmdSlideSwitch.tsx
6802
- import { fp as fp10 } from "@tscircuit/footprinter";
6621
+ import { fp as fp6 } from "@tscircuit/footprinter";
6803
6622
  var SmdSlideSwitch = ({
6804
6623
  footprint = "smdslideswitch7",
6805
6624
  position = 0
6806
6625
  }) => {
6807
6626
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
6808
- const params = fp10.string(canonical).json();
6809
- const elements = fp10.string(canonical).circuitJson();
6627
+ const params = fp6.string(canonical).json();
6628
+ const elements = fp6.string(canonical).circuitJson();
6810
6629
  const pads = elements.filter(
6811
6630
  (e) => e.type === "pcb_smtpad" && e.shape === "rect"
6812
6631
  );
6813
- const target = fp10.string(footprint).circuitJson().filter(
6632
+ const target = fp6.string(footprint).circuitJson().filter(
6814
6633
  (e) => e.type === "pcb_smtpad" && (e.shape === "rect" || e.shape === "rotated_rect")
6815
6634
  );
6816
6635
  if (pads.length < 7 || !Number.isFinite(params.mpx) || params.mpx < 3)
@@ -6916,7 +6735,7 @@ var SOT563 = ({ fullWidth = 1.94, fullLength: fullLength10 = 1.6 }) => {
6916
6735
  };
6917
6736
 
6918
6737
  // lib/BGA.tsx
6919
- import { fp as fp11 } from "@tscircuit/footprinter";
6738
+ import { fp as fp7 } from "@tscircuit/footprinter";
6920
6739
  var BGA = ({
6921
6740
  packageWidth = 10,
6922
6741
  packageLength = 10,
@@ -6932,7 +6751,7 @@ var BGA = ({
6932
6751
  const bodyHeight = packageHeight - standoffHeight;
6933
6752
  const bodyOffset = standoffHeight + bodyHeight / 2;
6934
6753
  const ballOffset = Math.max(standoffHeight / 2, ballDiameter / 2);
6935
- const ballsSoup = footprintString ? fp11.string(footprintString).circuitJson() : null;
6754
+ const ballsSoup = footprintString ? fp7.string(footprintString).circuitJson() : null;
6936
6755
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
6937
6756
  /* @__PURE__ */ jsx(Translate, { z: bodyOffset, children: /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Cuboid, { size: [packageWidth, packageLength, bodyHeight] }) }) }),
6938
6757
  !footprintString && Array.from({ length: ballRows * ballColumns }).map((_, index) => {
@@ -6962,7 +6781,7 @@ var BGA = ({
6962
6781
  };
6963
6782
 
6964
6783
  // lib/UsbCMidmount.tsx
6965
- import { fp as fp12 } from "@tscircuit/footprinter";
6784
+ import { fp as fp8 } from "@tscircuit/footprinter";
6966
6785
  var Capsule = ({
6967
6786
  width: width10,
6968
6787
  height: height10,
@@ -6972,14 +6791,14 @@ var UsbCMidmount = ({
6972
6791
  footprint = "usbcmidmount16"
6973
6792
  }) => {
6974
6793
  const canonical = footprint.replace(/_pin1location\([^)]*\)/g, "");
6975
- const params = fp12.string(canonical).json();
6976
- const elements = fp12.string(canonical).circuitJson();
6794
+ const params = fp8.string(canonical).json();
6795
+ const elements = fp8.string(canonical).circuitJson();
6977
6796
  const pads = elements.filter(
6978
6797
  (e) => e.type === "pcb_smtpad" && e.shape === "rect"
6979
6798
  );
6980
6799
  const slots = elements.filter((e) => e.type === "pcb_plated_hole");
6981
6800
  const holes = elements.filter((e) => e.type === "pcb_hole");
6982
- const target = fp12.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6801
+ const target = fp8.string(footprint).circuitJson().find((e) => e.type === "pcb_plated_hole");
6983
6802
  const first = slots[0];
6984
6803
  const angle = first && target && "x" in target ? Math.atan2(target.y, target.x) - Math.atan2(first.y, first.x) : 0;
6985
6804
  const width10 = 8.94, height10 = 3.2, wall = 0.22;
@@ -7063,15 +6882,15 @@ var UsbCMidmount = ({
7063
6882
  };
7064
6883
 
7065
6884
  // lib/SOT143.tsx
7066
- import { fp as fp13 } from "@tscircuit/footprinter";
7067
- var getPads = (footprint) => fp13.string(footprint).circuitJson().filter(
6885
+ import { fp as fp9 } from "@tscircuit/footprinter";
6886
+ var getPads = (footprint) => fp9.string(footprint).circuitJson().filter(
7068
6887
  (element) => element.type === "pcb_smtpad" && (element.shape === "rect" || element.shape === "rotated_rect")
7069
6888
  ).map((pad) => ({ x: pad.x, y: pad.y, pin: pad.port_hints?.[0] }));
7070
6889
  var SOT143 = ({ footprint = "sot143" }) => {
7071
6890
  const pads = getPads(footprint);
7072
6891
  if (pads.length !== 4) throw new Error("SOT143 requires four signal pads");
7073
6892
  const canonical = getPads("sot143");
7074
- const options = fp13.string(footprint).json();
6893
+ const options = fp9.string(footprint).json();
7075
6894
  const origin = canonical[1];
7076
6895
  const target = pads.find((pad) => pad.pin === "2");
7077
6896
  const angle = options.pin1location ? Math.round(
@@ -7658,39 +7477,6 @@ var FlexScreen = (props) => {
7658
7477
 
7659
7478
  // lib/Footprinter3d.tsx
7660
7479
  var Footprinter3d = ({ footprint }) => {
7661
- if (/(?:^|_)antennaRFANT5220110A0T(?:_|$)/.test(footprint))
7662
- return /* @__PURE__ */ jsx(CeramicChipAntenna, { footprint });
7663
- const melfResistor = footprint.match(
7664
- /(?:^|_)melfresistor(0102|0204|0207)(?:_|$)/
7665
- );
7666
- if (melfResistor)
7667
- return /* @__PURE__ */ jsx(
7668
- MelfResistor,
7669
- {
7670
- footprint,
7671
- size: melfResistor[1]
7672
- }
7673
- );
7674
- const tantalum = footprint.match(/(?:^|_)tantalum([ABCD])(?:_|$)/);
7675
- if (tantalum)
7676
- return /* @__PURE__ */ jsx(
7677
- TantalumCapacitor,
7678
- {
7679
- footprint,
7680
- caseSize: tantalum[1]
7681
- }
7682
- );
7683
- const crystal2 = footprint.match(
7684
- /(?:^|_)crystal2(FC135|FC12M|FC1610AN|NX3225GD)(?:_|$)/
7685
- );
7686
- if (crystal2)
7687
- return /* @__PURE__ */ jsx(
7688
- TwoPadCrystal,
7689
- {
7690
- footprint,
7691
- packageName: crystal2[1]
7692
- }
7693
- );
7694
7480
  const modelFn = mp.string(footprint.split("_", 1)[0]).params().fn;
7695
7481
  if (mp.getModelNames().includes(modelFn)) {
7696
7482
  const model = mp.string(footprint).json();
@@ -7715,7 +7501,7 @@ var Footprinter3d = ({ footprint }) => {
7715
7501
  const numPins = pinMatch && pinMatch[1] ? pinMatch[1] : "2";
7716
7502
  normalizedFootprint = `jst${numPins}_xh`;
7717
7503
  }
7718
- const fpJson = fp14.string(normalizedFootprint).json();
7504
+ const fpJson = fp10.string(normalizedFootprint).json();
7719
7505
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
7720
7506
  const color = colorMatch ? colorMatch[1] : void 0;
7721
7507
  const dim = (value, fallback) => {