jscad-electronics 0.0.32 → 0.0.34

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.
@@ -0,0 +1,1747 @@
1
+ // lib/vanilla/h.ts
2
+ var Fragment = Symbol("Fragment");
3
+ function h(type, props, ...restChildren) {
4
+ const provided = restChildren.length ? restChildren : props?.children !== void 0 ? [props.children] : [];
5
+ const flatChildren = [];
6
+ const stack = (Array.isArray(provided) ? provided : [provided]).flat(
7
+ Infinity
8
+ );
9
+ for (const ch of stack) {
10
+ if (ch == null || ch === false) continue;
11
+ if (Array.isArray(ch)) flatChildren.push(...ch);
12
+ else flatChildren.push(ch);
13
+ }
14
+ return {
15
+ type,
16
+ props: (props && props.children !== void 0 ? { ...props, children: void 0 } : props) || {},
17
+ children: flatChildren
18
+ };
19
+ }
20
+
21
+ // lib/Footprinter3d.tsx
22
+ import { fp } from "@tscircuit/footprinter";
23
+
24
+ // lib/vanilla/primitives.ts
25
+ var Cuboid = Symbol("Cuboid");
26
+ var Cube = Symbol("Cube");
27
+ var Cylinder = Symbol("Cylinder");
28
+ var Sphere = Symbol("Sphere");
29
+ var RoundedCuboid = Symbol("RoundedCuboid");
30
+ var Translate = Symbol("Translate");
31
+ var Rotate = Symbol("Rotate");
32
+ var Union = Symbol("Union");
33
+ var Subtract = Symbol("Subtract");
34
+ var Hull = Symbol("Hull");
35
+ var Colorize = Symbol("Colorize");
36
+ var Polygon = Symbol("Polygon");
37
+ var ExtrudeLinear = Symbol("ExtrudeLinear");
38
+
39
+ // lib/vanilla/react-shim.ts
40
+ var Fragment2 = Fragment;
41
+ var jsx = (type, props, _key) => h(type, props);
42
+ var jsxs = (type, props, _key) => h(type, props);
43
+
44
+ // lib/ChipBody.tsx
45
+ var ChipBody = ({
46
+ center,
47
+ width: width10,
48
+ length,
49
+ height: height10,
50
+ heightAboveSurface: heightAboveSurface2 = 0.15
51
+ }) => {
52
+ return /* @__PURE__ */ jsx(Colorize, { color: "#555", children: /* @__PURE__ */ jsx(Translate, { offset: center, children: /* @__PURE__ */ jsx(Translate, { offset: { x: 0, y: 0, z: height10 / 2 + heightAboveSurface2 }, children: /* @__PURE__ */ jsx(RoundedCuboid, { roundRadius: 0.2, size: [width10, length, height10] }) }) }) });
53
+ };
54
+
55
+ // lib/utils/range.ts
56
+ var range = (end) => Array.from({ length: end }, (_, i) => i);
57
+
58
+ // lib/utils/getExpandedStroke.ts
59
+ function getExpandedStroke(strokeInput, width10) {
60
+ if (strokeInput.length < 2) {
61
+ throw new Error("Stroke must have at least two points");
62
+ }
63
+ const stroke = Array.isArray(strokeInput[0]) ? strokeInput.map(([x, y]) => ({ x, y })) : strokeInput;
64
+ const halfWidth = width10 / 2;
65
+ const leftSide = [];
66
+ const rightSide = [];
67
+ function getNormal(p1, p2) {
68
+ const dx = p2.x - p1.x;
69
+ const dy = p2.y - p1.y;
70
+ const length = Math.sqrt(dx * dx + dy * dy);
71
+ return { x: -dy / length, y: dx / length };
72
+ }
73
+ function addPoint(point, normal, factor) {
74
+ const newPoint = {
75
+ x: point.x + normal.x * halfWidth * factor,
76
+ y: point.y + normal.y * halfWidth * factor
77
+ };
78
+ if (factor > 0) {
79
+ leftSide.push(newPoint);
80
+ } else {
81
+ rightSide.unshift(newPoint);
82
+ }
83
+ }
84
+ const firstNormal = getNormal(stroke[0], stroke[1]);
85
+ addPoint(stroke[0], firstNormal, 1);
86
+ addPoint(stroke[0], firstNormal, -1);
87
+ for (let i = 1; i < stroke.length - 1; i++) {
88
+ const prev = stroke[i - 1];
89
+ const current = stroke[i];
90
+ const next = stroke[i + 1];
91
+ const normalPrev = getNormal(prev, current);
92
+ const normalNext = getNormal(current, next);
93
+ const miterX = normalPrev.x + normalNext.x;
94
+ const miterY = normalPrev.y + normalNext.y;
95
+ const miterLength = Math.sqrt(miterX * miterX + miterY * miterY);
96
+ const miterLimit = 2;
97
+ if (miterLength / 2 > miterLimit * halfWidth) {
98
+ addPoint(current, normalPrev, 1);
99
+ addPoint(current, normalNext, 1);
100
+ addPoint(current, normalPrev, -1);
101
+ addPoint(current, normalNext, -1);
102
+ } else {
103
+ const scale = 1 / miterLength;
104
+ addPoint(current, { x: miterX * scale, y: miterY * scale }, 1);
105
+ addPoint(current, { x: miterX * scale, y: miterY * scale }, -1);
106
+ }
107
+ }
108
+ const lastNormal = getNormal(
109
+ stroke[stroke.length - 2],
110
+ stroke[stroke.length - 1]
111
+ );
112
+ addPoint(stroke[stroke.length - 1], lastNormal, 1);
113
+ addPoint(stroke[stroke.length - 1], lastNormal, -1);
114
+ return [...leftSide, ...rightSide];
115
+ }
116
+
117
+ // lib/DualInlinePackage.tsx
118
+ var normalizeOnY = (points) => {
119
+ const minX = Math.min(...points.map((p) => p.x));
120
+ const maxX = Math.max(...points.map((p) => p.x));
121
+ const minY = Math.min(...points.map((p) => p.y));
122
+ const maxY = Math.max(...points.map((p) => p.y));
123
+ const height10 = maxY - minY;
124
+ const factor = 5.47 / height10;
125
+ return points.map((p) => ({
126
+ x: (p.x - minX - (maxX - minX) / 2) * factor,
127
+ y: (p.y - minY) * factor
128
+ }));
129
+ };
130
+ var svgPathPoints = normalizeOnY([
131
+ { x: 20, y: 105 },
132
+ { x: 20, y: 109 },
133
+ { x: 20, y: 102 },
134
+ { x: 26, y: 102 },
135
+ { x: 26, y: 109 },
136
+ { x: 24, y: 111 },
137
+ { x: 24, y: 118 },
138
+ { x: 22, y: 118 },
139
+ { x: 22, y: 111 },
140
+ { x: 20, y: 109 }
141
+ ]);
142
+ var DIP_PIN_HEIGHT = 5.47;
143
+ var heightAboveSurface = 0.5;
144
+ var DipPinLeg = ({ x, y, z }) => {
145
+ const isRotated = x > 0;
146
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
147
+ /* @__PURE__ */ jsx(Translate, { offset: { x: x + 0.25 / 2, y, z }, children: /* @__PURE__ */ jsx(Rotate, { rotation: ["-90deg", 0, "90deg"], children: /* @__PURE__ */ jsx(ExtrudeLinear, { height: 0.25, children: /* @__PURE__ */ jsx(Polygon, { points: svgPathPoints.map((p) => [p.x, p.y]) }) }) }) }),
148
+ /* @__PURE__ */ jsx(
149
+ Translate,
150
+ {
151
+ offset: {
152
+ x,
153
+ y: y + (isRotated ? 1 : -1),
154
+ z
155
+ },
156
+ children: /* @__PURE__ */ jsx(Rotate, { rotation: ["-90deg", "90deg", isRotated ? "180deg" : "0deg"], children: /* @__PURE__ */ jsx(ExtrudeLinear, { height: 2, children: /* @__PURE__ */ jsx(
157
+ Polygon,
158
+ {
159
+ points: getExpandedStroke(
160
+ [
161
+ [0, 0],
162
+ [-1, 0],
163
+ [-1, -1]
164
+ ],
165
+ 0.25
166
+ ).map((p) => [p.x, p.y])
167
+ }
168
+ ) }) })
169
+ }
170
+ )
171
+ ] });
172
+ };
173
+ var Dip = ({
174
+ numPins = 8,
175
+ pitch = 2.54,
176
+ bodyWidth = 6.4
177
+ }) => {
178
+ const numPinsOnEachSide = Math.floor(numPins / 2);
179
+ const crossBodyPinWidth = bodyWidth + 1;
180
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
181
+ range(numPins).map((i) => {
182
+ const yRow = i % numPinsOnEachSide;
183
+ const xRow = (Math.floor(i / numPinsOnEachSide) - 0.5) * 2;
184
+ return /* @__PURE__ */ jsx(
185
+ DipPinLeg,
186
+ {
187
+ x: xRow * crossBodyPinWidth / 2,
188
+ y: yRow * pitch - (numPinsOnEachSide - 1) / 2 * pitch,
189
+ z: DIP_PIN_HEIGHT / 2 + heightAboveSurface
190
+ },
191
+ i
192
+ );
193
+ }),
194
+ /* @__PURE__ */ jsx(
195
+ ChipBody,
196
+ {
197
+ width: bodyWidth,
198
+ length: numPinsOnEachSide * pitch + 0.5,
199
+ height: DIP_PIN_HEIGHT - heightAboveSurface,
200
+ heightAboveSurface,
201
+ center: { x: 0, y: 0, z: heightAboveSurface }
202
+ }
203
+ )
204
+ ] });
205
+ };
206
+
207
+ // lib/SmdChipLead.tsx
208
+ function calculateSCurve(x, {
209
+ height: height10,
210
+ padContactLength,
211
+ curveLength,
212
+ bodyDistance,
213
+ steepness = 10
214
+ }) {
215
+ if (!curveLength) curveLength = bodyDistance * 0.3;
216
+ let flatFromBodySectionLength = bodyDistance - padContactLength - curveLength;
217
+ if (flatFromBodySectionLength < 0) {
218
+ curveLength += flatFromBodySectionLength;
219
+ flatFromBodySectionLength = 0;
220
+ }
221
+ const curveStart = padContactLength * 0.75;
222
+ const curveEnd = padContactLength + curveLength + (bodyDistance - padContactLength - curveLength) * 0.25;
223
+ if (x <= curveStart) return 0;
224
+ if (x >= curveEnd) return height10;
225
+ const t = (x - curveStart) / (curveEnd - curveStart);
226
+ return height10 / (1 + Math.exp(-steepness * (t - 0.5)));
227
+ }
228
+ var SmdChipLead = (props) => {
229
+ const { thickness, width: width10, padContactLength, bodyDistance, height: height10, rotation } = props;
230
+ const N = 15;
231
+ const points = Array.from({ length: N }).map((_, i) => i / (N - 1) * bodyDistance).map((x) => [x, calculateSCurve(x, props)]);
232
+ const polygon = getExpandedStroke(points, thickness);
233
+ return /* @__PURE__ */ jsx(Colorize, { color: "#fff", children: /* @__PURE__ */ jsx(Translate, { offset: { z: 0, y: 0, x: 0, ...props.position }, children: /* @__PURE__ */ jsx(Rotate, { rotation: ["90deg", 0, rotation ?? 0], children: /* @__PURE__ */ jsx(Translate, { offset: { x: 0, y: 0, z: -width10 / 2 }, children: /* @__PURE__ */ jsx(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx(Polygon, { points: polygon.map((p) => [p.x, p.y]) }) }) }) }) }) });
234
+ };
235
+
236
+ // lib/Tssop.tsx
237
+ var Tssop = ({
238
+ pinCount,
239
+ leadLength,
240
+ leadWidth,
241
+ pitch,
242
+ bodyWidth
243
+ }) => {
244
+ const sidePinCount = Math.ceil(pinCount / 2);
245
+ const fullLength10 = pitch * pinCount / 2 + leadWidth / 2;
246
+ const pinOffsetToCenter = (sidePinCount - 1) * pitch / 2;
247
+ const leadThickness = 0.25;
248
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
249
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
250
+ SmdChipLead,
251
+ {
252
+ position: {
253
+ x: -bodyWidth / 2 - leadLength,
254
+ y: i * pitch - pinOffsetToCenter,
255
+ z: leadThickness / 2
256
+ },
257
+ width: leadWidth,
258
+ thickness: leadThickness,
259
+ padContactLength: leadLength,
260
+ bodyDistance: leadLength + 1,
261
+ height: 0.8
262
+ },
263
+ i
264
+ )),
265
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
266
+ SmdChipLead,
267
+ {
268
+ rotation: Math.PI,
269
+ position: {
270
+ x: bodyWidth / 2 + leadLength,
271
+ y: i * pitch - pinOffsetToCenter,
272
+ z: leadThickness / 2
273
+ },
274
+ width: leadWidth,
275
+ thickness: leadThickness,
276
+ padContactLength: leadLength,
277
+ bodyDistance: leadLength + 1,
278
+ height: 0.8
279
+ },
280
+ i
281
+ )),
282
+ /* @__PURE__ */ jsx(
283
+ ChipBody,
284
+ {
285
+ center: { x: 0, y: 0, z: leadThickness / 2 },
286
+ width: bodyWidth - leadWidth - 1,
287
+ length: fullLength10,
288
+ height: 1.5
289
+ }
290
+ )
291
+ ] });
292
+ };
293
+
294
+ // lib/A0402.tsx
295
+ var fullLength = 1;
296
+ var width = 0.5;
297
+ var height = 0.5;
298
+ var terminatorWidth = 0.2;
299
+ var bodyLength = fullLength - terminatorWidth * 2;
300
+ var A0402 = ({ color = "#333" }) => {
301
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
302
+ /* @__PURE__ */ jsx(
303
+ Cuboid,
304
+ {
305
+ size: [bodyLength, width, height],
306
+ offset: [0, 0, height / 2],
307
+ color
308
+ }
309
+ ),
310
+ /* @__PURE__ */ jsx(
311
+ Cuboid,
312
+ {
313
+ size: [terminatorWidth, height, width],
314
+ offset: [fullLength / 2 - terminatorWidth / 2, 0, height / 2],
315
+ color: "#ccc"
316
+ }
317
+ ),
318
+ /* @__PURE__ */ jsx(
319
+ Cuboid,
320
+ {
321
+ size: [terminatorWidth, height, width],
322
+ offset: [-fullLength / 2 + terminatorWidth / 2, 0, height / 2],
323
+ color: "#ccc"
324
+ }
325
+ )
326
+ ] });
327
+ };
328
+
329
+ // lib/A0603.tsx
330
+ var fullLength2 = 1.6;
331
+ var bodyLength2 = fullLength2 - 0.3 * 2;
332
+ var terminatorLength = 0.3;
333
+ var width2 = 0.85;
334
+ var height2 = 0.6;
335
+ var A0603 = ({ color = "#333" }) => {
336
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
337
+ /* @__PURE__ */ jsx(
338
+ Cuboid,
339
+ {
340
+ size: [bodyLength2, width2, height2],
341
+ offset: [0, 0, height2 / 2],
342
+ color
343
+ }
344
+ ),
345
+ /* @__PURE__ */ jsx(
346
+ Cuboid,
347
+ {
348
+ size: [terminatorLength, width2, height2],
349
+ offset: [fullLength2 / 2 - terminatorLength / 2, 0, height2 / 2],
350
+ color: "#ccc"
351
+ }
352
+ ),
353
+ /* @__PURE__ */ jsx(
354
+ Cuboid,
355
+ {
356
+ size: [terminatorLength, width2, height2],
357
+ offset: [-fullLength2 / 2 + terminatorLength / 2, 0, height2 / 2],
358
+ color: "#ccc"
359
+ }
360
+ )
361
+ ] });
362
+ };
363
+
364
+ // lib/A0805.tsx
365
+ var fullLength3 = 2;
366
+ var width3 = 1.25;
367
+ var height3 = 0.55;
368
+ var terminatorWidth2 = 0.5;
369
+ var bodyLength3 = fullLength3 - terminatorWidth2 * 2;
370
+ var A0805 = ({ color = "#333" }) => {
371
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
372
+ /* @__PURE__ */ jsx(
373
+ Cuboid,
374
+ {
375
+ size: [bodyLength3, width3, height3],
376
+ offset: [0, 0, height3 / 2],
377
+ color
378
+ }
379
+ ),
380
+ /* @__PURE__ */ jsx(
381
+ Cuboid,
382
+ {
383
+ size: [terminatorWidth2, width3, height3],
384
+ offset: [fullLength3 / 2 - terminatorWidth2 / 2, 0, height3 / 2],
385
+ color: "#ccc"
386
+ }
387
+ ),
388
+ /* @__PURE__ */ jsx(
389
+ Cuboid,
390
+ {
391
+ size: [terminatorWidth2, width3, height3],
392
+ offset: [-fullLength3 / 2 + terminatorWidth2 / 2, 0, height3 / 2],
393
+ color: "#ccc"
394
+ }
395
+ )
396
+ ] });
397
+ };
398
+
399
+ // lib/qfp.tsx
400
+ var QFP = ({
401
+ pinCount,
402
+ pitch,
403
+ leadWidth,
404
+ padContactLength,
405
+ bodyWidth
406
+ }) => {
407
+ const sidePinCount = pinCount / 4;
408
+ if (!pitch) pitch = getPitch(pinCount, bodyWidth);
409
+ if (!padContactLength) padContactLength = getPadContactLength(pinCount);
410
+ if (!leadWidth) leadWidth = getLeadWidth(pinCount, bodyWidth);
411
+ if (!bodyWidth) bodyWidth = pitch * (sidePinCount + 4);
412
+ const bodyLength10 = bodyWidth;
413
+ const pinOffsetToCenter = (sidePinCount - 1) * pitch / 2;
414
+ const fullLength10 = bodyLength10 + 2 * padContactLength;
415
+ const fullWidth = fullLength10;
416
+ const leadHeight = 0.8;
417
+ const leadThickness = 0.15;
418
+ const bodyDistance = (fullWidth - bodyWidth) / 2;
419
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
420
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
421
+ SmdChipLead,
422
+ {
423
+ position: {
424
+ x: -fullWidth / 2,
425
+ y: i * pitch - pinOffsetToCenter,
426
+ z: leadThickness / 2
427
+ },
428
+ width: leadWidth,
429
+ thickness: leadThickness,
430
+ padContactLength,
431
+ bodyDistance,
432
+ height: leadHeight
433
+ },
434
+ `left-${i}`
435
+ )),
436
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
437
+ SmdChipLead,
438
+ {
439
+ rotation: Math.PI,
440
+ position: {
441
+ x: fullWidth / 2,
442
+ y: i * pitch - pinOffsetToCenter,
443
+ z: leadThickness / 2
444
+ },
445
+ width: leadWidth,
446
+ thickness: leadThickness,
447
+ padContactLength,
448
+ bodyDistance,
449
+ height: leadHeight
450
+ },
451
+ `right-${i}`
452
+ )),
453
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
454
+ SmdChipLead,
455
+ {
456
+ rotation: Math.PI / 2,
457
+ position: {
458
+ x: i * pitch - pinOffsetToCenter,
459
+ y: -fullLength10 / 2,
460
+ z: leadThickness / 2
461
+ },
462
+ width: leadWidth,
463
+ thickness: leadThickness,
464
+ padContactLength,
465
+ bodyDistance,
466
+ height: leadHeight
467
+ },
468
+ `bottom-${i}`
469
+ )),
470
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
471
+ SmdChipLead,
472
+ {
473
+ rotation: -Math.PI / 2,
474
+ position: {
475
+ x: i * pitch - pinOffsetToCenter,
476
+ y: fullLength10 / 2,
477
+ z: leadThickness / 2
478
+ },
479
+ width: leadWidth,
480
+ thickness: leadThickness,
481
+ padContactLength,
482
+ bodyDistance,
483
+ height: leadHeight
484
+ },
485
+ `top-${i}`
486
+ )),
487
+ /* @__PURE__ */ jsx(
488
+ ChipBody,
489
+ {
490
+ center: { x: 0, y: 0, z: leadThickness / 2 },
491
+ width: bodyWidth,
492
+ length: bodyLength10,
493
+ height: 1.5
494
+ }
495
+ )
496
+ ] });
497
+ };
498
+ var getPitch = (pinCount, width10) => {
499
+ switch (pinCount) {
500
+ case 44:
501
+ case 64:
502
+ return 0.8;
503
+ case 52:
504
+ return width10 === 14 ? 1 : 0.65;
505
+ case 208:
506
+ return 0.5;
507
+ default:
508
+ return 0.5;
509
+ }
510
+ };
511
+ var getPadContactLength = (pinCount) => {
512
+ switch (pinCount) {
513
+ case 44:
514
+ case 52:
515
+ case 64:
516
+ return 2.25;
517
+ case 208:
518
+ return 1.65;
519
+ default:
520
+ return 1;
521
+ }
522
+ };
523
+ var getLeadWidth = (pinCount, width10) => {
524
+ switch (pinCount) {
525
+ case 44:
526
+ case 64:
527
+ return 0.5;
528
+ case 52:
529
+ return width10 === 14 ? 0.45 : 0.55;
530
+ case 208:
531
+ return 0.3;
532
+ default:
533
+ return 0.25;
534
+ }
535
+ };
536
+
537
+ // lib/PinRow.tsx
538
+ var PinRow = ({
539
+ numberOfPins,
540
+ pitch = 2.54,
541
+ longSidePinLength = 6
542
+ }) => {
543
+ const pinThickness = 0.63;
544
+ const bodyHeight = 2;
545
+ const bodyWidth = numberOfPins * pitch;
546
+ const shortSidePinLength = 3;
547
+ const xoff = -((numberOfPins - 1) / 2) * pitch;
548
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
549
+ /* @__PURE__ */ jsx(
550
+ Cuboid,
551
+ {
552
+ color: "#222",
553
+ size: [bodyWidth, pinThickness * 3, bodyHeight],
554
+ center: [0, 0, bodyHeight / 2]
555
+ }
556
+ ),
557
+ Array.from({ length: numberOfPins }, (_, i) => /* @__PURE__ */ jsxs(Fragment2, { children: [
558
+ /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
559
+ /* @__PURE__ */ jsx(
560
+ Cuboid,
561
+ {
562
+ color: "gold",
563
+ size: [pinThickness, pinThickness, shortSidePinLength * 0.9],
564
+ center: [
565
+ xoff + i * pitch,
566
+ 0,
567
+ bodyHeight * 0.9 + bodyHeight / 2
568
+ ]
569
+ }
570
+ ),
571
+ /* @__PURE__ */ jsx(
572
+ Cuboid,
573
+ {
574
+ color: "gold",
575
+ size: [
576
+ pinThickness / 1.8,
577
+ pinThickness / 1.8,
578
+ shortSidePinLength
579
+ ],
580
+ center: [xoff + i * pitch, 0, bodyHeight + bodyHeight / 2]
581
+ }
582
+ )
583
+ ] }) }),
584
+ /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
585
+ /* @__PURE__ */ jsx(
586
+ Cuboid,
587
+ {
588
+ color: "gold",
589
+ size: [pinThickness, pinThickness, longSidePinLength * 0.9],
590
+ center: [xoff + i * pitch, 0, -longSidePinLength / 2 * 0.9]
591
+ }
592
+ ),
593
+ /* @__PURE__ */ jsx(
594
+ Cuboid,
595
+ {
596
+ color: "gold",
597
+ size: [
598
+ pinThickness / 1.8,
599
+ pinThickness / 1.8,
600
+ longSidePinLength
601
+ ],
602
+ center: [xoff + i * pitch, 0, -longSidePinLength / 2]
603
+ }
604
+ )
605
+ ] }) })
606
+ ] }))
607
+ ] });
608
+ };
609
+
610
+ // lib/utils/getQuadCoords.ts
611
+ var getQuadCoords = (params) => {
612
+ const SIDES_CCW = ["left", "bottom", "right", "top"];
613
+ const { pin_count, pn, w, h: h2, p, pl, legsoutside } = params;
614
+ const sidePinCount = pin_count / 4;
615
+ const side = SIDES_CCW[Math.floor((pn - 1) / sidePinCount)];
616
+ const pos = (pn - 1) % sidePinCount;
617
+ const ibw = p * (sidePinCount - 1);
618
+ const ibh = p * (sidePinCount - 1);
619
+ const pcdfe = legsoutside ? pl / 2 : -pl / 2;
620
+ switch (side) {
621
+ case "left":
622
+ return { x: -w / 2 - pcdfe, y: ibh / 2 - pos * p, o: "vert" };
623
+ case "bottom":
624
+ return { x: -ibw / 2 + pos * p, y: -h2 / 2 - pcdfe, o: "horz" };
625
+ case "right":
626
+ return { x: w / 2 + pcdfe, y: -ibh / 2 + pos * p, o: "vert" };
627
+ case "top":
628
+ return { x: ibw / 2 - pos * p, y: h2 / 2 + pcdfe, o: "horz" };
629
+ default:
630
+ throw new Error("Invalid pin number");
631
+ }
632
+ };
633
+
634
+ // lib/utils/getQuadPinMap.ts
635
+ var getQuadPinMap = ({
636
+ num_pins,
637
+ cw,
638
+ ccw,
639
+ startingpin
640
+ }) => {
641
+ const pin_map = [];
642
+ const pins_per_side = num_pins / 4;
643
+ let current_position_ccw_normal = 1;
644
+ const sfp = {};
645
+ for (const specifier of startingpin ?? []) {
646
+ sfp[specifier] = true;
647
+ }
648
+ if (!sfp.leftside && !sfp.topside && !sfp.rightside && !sfp.bottomside) {
649
+ sfp.leftside = true;
650
+ }
651
+ if (!sfp.bottompin && !sfp.leftpin && !sfp.rightpin && !sfp.toppin) {
652
+ if (sfp.leftside) {
653
+ sfp.toppin = true;
654
+ } else if (sfp.topside) {
655
+ sfp.rightpin = true;
656
+ } else if (sfp.rightside) {
657
+ sfp.bottompin = true;
658
+ } else if (sfp.bottomside) {
659
+ sfp.leftpin = true;
660
+ }
661
+ }
662
+ if (sfp.leftside && sfp.toppin) {
663
+ current_position_ccw_normal = 1;
664
+ } else if (sfp.leftside && sfp.bottompin) {
665
+ current_position_ccw_normal = pins_per_side;
666
+ } else if (sfp.bottomside && sfp.leftpin) {
667
+ current_position_ccw_normal = pins_per_side + 1;
668
+ } else if (sfp.bottomside && sfp.rightpin) {
669
+ current_position_ccw_normal = pins_per_side * 2;
670
+ } else if (sfp.rightside && sfp.bottompin) {
671
+ current_position_ccw_normal = pins_per_side * 2 + 1;
672
+ } else if (sfp.rightside && sfp.toppin) {
673
+ current_position_ccw_normal = pins_per_side * 3;
674
+ } else if (sfp.topside && sfp.rightpin) {
675
+ current_position_ccw_normal = pins_per_side * 3 + 1;
676
+ } else if (sfp.topside && sfp.leftpin) {
677
+ current_position_ccw_normal = pins_per_side * 4;
678
+ }
679
+ pin_map.push(-1);
680
+ for (let i = 0; i < num_pins; i++) {
681
+ pin_map[current_position_ccw_normal] = i + 1;
682
+ if (ccw || !cw) {
683
+ current_position_ccw_normal++;
684
+ if (current_position_ccw_normal > num_pins) {
685
+ current_position_ccw_normal = 1;
686
+ }
687
+ } else {
688
+ current_position_ccw_normal--;
689
+ if (current_position_ccw_normal < 1) {
690
+ current_position_ccw_normal = num_pins;
691
+ }
692
+ }
693
+ }
694
+ return pin_map;
695
+ };
696
+
697
+ // lib/qfn.tsx
698
+ var QFN = ({
699
+ num_pins = 16,
700
+ bodyWidth = 9,
701
+ bodyLength: bodyLength10 = 9,
702
+ bodyThickness = 0.8,
703
+ thermalPadSize,
704
+ padWidth = 0.25,
705
+ padLength = 0.25,
706
+ pitch = 0.5,
707
+ thermalPadThickness = 0.05
708
+ }) => {
709
+ const pin_map = getQuadPinMap({
710
+ num_pins,
711
+ cw: true,
712
+ ccw: true
713
+ });
714
+ const pinPositions = [];
715
+ const spc = num_pins / 4;
716
+ for (let i = 0; i < num_pins; i++) {
717
+ const {
718
+ x,
719
+ y,
720
+ o: orientation
721
+ } = getQuadCoords({
722
+ pin_count: num_pins,
723
+ pn: i + 1,
724
+ w: bodyWidth,
725
+ h: bodyLength10,
726
+ p: pitch,
727
+ pl: padLength,
728
+ legsoutside: false
729
+ });
730
+ let pw = padWidth;
731
+ let pl = padLength;
732
+ if (orientation === "vert") {
733
+ ;
734
+ [pw, pl] = [pl, pw];
735
+ }
736
+ const pn = pin_map[i + 1];
737
+ pinPositions.push({ pn, x, y, pw, pl });
738
+ }
739
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
740
+ /* @__PURE__ */ jsx(Colorize, { color: "grey", children: /* @__PURE__ */ jsx(
741
+ Cuboid,
742
+ {
743
+ center: { x: 0, y: 0, z: bodyThickness / 2 },
744
+ size: [bodyWidth, bodyLength10, bodyThickness]
745
+ }
746
+ ) }),
747
+ pinPositions.map((p, i) => /* @__PURE__ */ jsx(
748
+ Cuboid,
749
+ {
750
+ center: { x: p.x, y: p.y, z: thermalPadThickness / 2 },
751
+ size: [p.pw, p.pl, thermalPadThickness]
752
+ },
753
+ i
754
+ )),
755
+ thermalPadSize?.length !== void 0 && thermalPadSize?.width !== void 0 && /* @__PURE__ */ jsx(
756
+ Cuboid,
757
+ {
758
+ center: { x: 0, y: 0, z: thermalPadThickness / 2 },
759
+ size: [
760
+ thermalPadSize.width,
761
+ thermalPadSize.length,
762
+ thermalPadThickness
763
+ ]
764
+ }
765
+ )
766
+ ] });
767
+ };
768
+ var qfn_default = QFN;
769
+
770
+ // lib/SOT-235.tsx
771
+ var SOT235 = () => {
772
+ const fullWidth = 2.8;
773
+ const bodyWidth = 1.6;
774
+ const bodyLength10 = 2.9;
775
+ const bodyHeight = 1.2;
776
+ const leadWidth = 0.4;
777
+ const leadThickness = 0.15;
778
+ const leadHeight = 0.95;
779
+ const padContactLength = 0.5;
780
+ const padPitch = 0.95;
781
+ const extendedBodyDistance = fullWidth - bodyWidth;
782
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
783
+ /* @__PURE__ */ jsx(
784
+ SmdChipLead,
785
+ {
786
+ rotation: Math.PI,
787
+ position: {
788
+ x: fullWidth / 2 + extendedBodyDistance / 4,
789
+ y: -1,
790
+ z: leadThickness / 2
791
+ },
792
+ width: leadWidth,
793
+ thickness: leadThickness,
794
+ padContactLength,
795
+ bodyDistance: extendedBodyDistance,
796
+ height: leadHeight
797
+ },
798
+ 1
799
+ ),
800
+ /* @__PURE__ */ jsx(
801
+ SmdChipLead,
802
+ {
803
+ rotation: Math.PI,
804
+ position: {
805
+ x: fullWidth / 2 + extendedBodyDistance / 4,
806
+ y: 1,
807
+ z: leadThickness / 2
808
+ },
809
+ width: leadWidth,
810
+ thickness: leadThickness,
811
+ padContactLength,
812
+ bodyDistance: extendedBodyDistance,
813
+ height: leadHeight
814
+ },
815
+ 2
816
+ ),
817
+ /* @__PURE__ */ jsx(
818
+ SmdChipLead,
819
+ {
820
+ position: {
821
+ x: -fullWidth / 2 - extendedBodyDistance / 4,
822
+ y: 0,
823
+ z: leadThickness / 2
824
+ },
825
+ width: leadWidth,
826
+ thickness: leadThickness,
827
+ padContactLength,
828
+ bodyDistance: extendedBodyDistance,
829
+ height: leadHeight
830
+ },
831
+ 3
832
+ ),
833
+ /* @__PURE__ */ jsx(
834
+ SmdChipLead,
835
+ {
836
+ position: {
837
+ x: -fullWidth / 2 - extendedBodyDistance / 4,
838
+ y: -1,
839
+ z: leadThickness / 2
840
+ },
841
+ width: leadWidth,
842
+ thickness: leadThickness,
843
+ padContactLength,
844
+ bodyDistance: extendedBodyDistance,
845
+ height: leadHeight
846
+ },
847
+ 1
848
+ ),
849
+ /* @__PURE__ */ jsx(
850
+ SmdChipLead,
851
+ {
852
+ position: {
853
+ x: -fullWidth / 2 - extendedBodyDistance / 4,
854
+ y: 1,
855
+ z: leadThickness / 2
856
+ },
857
+ width: leadWidth,
858
+ thickness: leadThickness,
859
+ padContactLength,
860
+ bodyDistance: extendedBodyDistance,
861
+ height: leadHeight
862
+ },
863
+ 2
864
+ ),
865
+ /* @__PURE__ */ jsx(
866
+ ChipBody,
867
+ {
868
+ center: { x: 0, y: 0, z: 0 },
869
+ width: bodyWidth,
870
+ length: bodyLength10,
871
+ height: bodyHeight
872
+ }
873
+ )
874
+ ] });
875
+ };
876
+ var SOT_235_default = SOT235;
877
+
878
+ // lib/A0201.tsx
879
+ var fullLength4 = 0.6;
880
+ var width4 = 0.3;
881
+ var height4 = 0.33;
882
+ var terminatorWidth3 = 0.1;
883
+ var bodyLength4 = fullLength4 - terminatorWidth3 * 2;
884
+ var A0201 = ({ color = "#333" }) => {
885
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
886
+ /* @__PURE__ */ jsx(
887
+ Cuboid,
888
+ {
889
+ size: [bodyLength4, width4, height4],
890
+ offset: [0, 0, height4 / 2],
891
+ color
892
+ }
893
+ ),
894
+ /* @__PURE__ */ jsx(
895
+ Cuboid,
896
+ {
897
+ size: [terminatorWidth3, width4, height4],
898
+ offset: [fullLength4 / 2 - terminatorWidth3 / 2, 0, height4 / 2],
899
+ color: "#ccc"
900
+ }
901
+ ),
902
+ /* @__PURE__ */ jsx(
903
+ Cuboid,
904
+ {
905
+ size: [terminatorWidth3, width4, height4],
906
+ offset: [-fullLength4 / 2 + terminatorWidth3 / 2, 0, height4 / 2],
907
+ color: "#ccc"
908
+ }
909
+ )
910
+ ] });
911
+ };
912
+
913
+ // lib/A01005.tsx
914
+ var fullLength5 = 0.4;
915
+ var width5 = 0.2;
916
+ var height5 = 0.13;
917
+ var terminatorWidth4 = 0.07;
918
+ var bodyLength5 = fullLength5 - terminatorWidth4 * 2;
919
+ var A01005 = ({ color = "#333" }) => {
920
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
921
+ /* @__PURE__ */ jsx(
922
+ Cuboid,
923
+ {
924
+ size: [bodyLength5, width5, height5],
925
+ offset: [0, 0, height5 / 2],
926
+ color
927
+ }
928
+ ),
929
+ /* @__PURE__ */ jsx(
930
+ Cuboid,
931
+ {
932
+ size: [terminatorWidth4, width5, height5],
933
+ offset: [fullLength5 / 2 - terminatorWidth4 / 2, 0, height5 / 2],
934
+ color: "#ccc"
935
+ }
936
+ ),
937
+ /* @__PURE__ */ jsx(
938
+ Cuboid,
939
+ {
940
+ size: [terminatorWidth4, width5, height5],
941
+ offset: [-fullLength5 / 2 + terminatorWidth4 / 2, 0, height5 / 2],
942
+ color: "#ccc"
943
+ }
944
+ )
945
+ ] });
946
+ };
947
+
948
+ // lib/A1206.tsx
949
+ var fullLength6 = 3.2;
950
+ var width6 = 1.6;
951
+ var height6 = 0.9;
952
+ var terminatorWidth5 = 0.5;
953
+ var bodyLength6 = fullLength6 - terminatorWidth5 * 2;
954
+ var A1206 = ({ color = "#333" }) => {
955
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
956
+ /* @__PURE__ */ jsx(
957
+ Cuboid,
958
+ {
959
+ size: [bodyLength6, width6, height6],
960
+ offset: [0, 0, height6 / 2],
961
+ color
962
+ }
963
+ ),
964
+ /* @__PURE__ */ jsx(
965
+ Cuboid,
966
+ {
967
+ size: [terminatorWidth5, width6, height6],
968
+ offset: [fullLength6 / 2 - terminatorWidth5 / 2, 0, height6 / 2],
969
+ color: "#ccc"
970
+ }
971
+ ),
972
+ /* @__PURE__ */ jsx(
973
+ Cuboid,
974
+ {
975
+ size: [terminatorWidth5, width6, height6],
976
+ offset: [-fullLength6 / 2 + terminatorWidth5 / 2, 0, height6 / 2],
977
+ color: "#ccc"
978
+ }
979
+ )
980
+ ] });
981
+ };
982
+
983
+ // lib/A1210.tsx
984
+ var fullLength7 = 3.2;
985
+ var width7 = 2.5;
986
+ var height7 = 1;
987
+ var terminatorWidth6 = 0.6;
988
+ var bodyLength7 = fullLength7 - terminatorWidth6 * 2;
989
+ var A1210 = ({ color = "#333" }) => {
990
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
991
+ /* @__PURE__ */ jsx(
992
+ Cuboid,
993
+ {
994
+ size: [bodyLength7, width7, height7],
995
+ offset: [0, 0, height7 / 2],
996
+ color
997
+ }
998
+ ),
999
+ /* @__PURE__ */ jsx(
1000
+ Cuboid,
1001
+ {
1002
+ size: [terminatorWidth6, width7, height7],
1003
+ offset: [fullLength7 / 2 - terminatorWidth6 / 2, 0, height7 / 2],
1004
+ color: "#ccc"
1005
+ }
1006
+ ),
1007
+ /* @__PURE__ */ jsx(
1008
+ Cuboid,
1009
+ {
1010
+ size: [terminatorWidth6, width7, height7],
1011
+ offset: [-fullLength7 / 2 + terminatorWidth6 / 2, 0, height7 / 2],
1012
+ color: "#ccc"
1013
+ }
1014
+ )
1015
+ ] });
1016
+ };
1017
+
1018
+ // lib/A2010.tsx
1019
+ var fullLength8 = 5;
1020
+ var width8 = 2.5;
1021
+ var height8 = 1.4;
1022
+ var terminatorWidth7 = 0.6;
1023
+ var bodyLength8 = fullLength8 - terminatorWidth7 * 2;
1024
+ var A2010 = ({ color = "#333" }) => {
1025
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1026
+ /* @__PURE__ */ jsx(
1027
+ Cuboid,
1028
+ {
1029
+ size: [bodyLength8, width8, height8],
1030
+ offset: [0, 0, height8 / 2],
1031
+ color
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ jsx(
1035
+ Cuboid,
1036
+ {
1037
+ size: [terminatorWidth7, width8, height8],
1038
+ offset: [fullLength8 / 2 - terminatorWidth7 / 2, 0, height8 / 2],
1039
+ color: "#ccc"
1040
+ }
1041
+ ),
1042
+ /* @__PURE__ */ jsx(
1043
+ Cuboid,
1044
+ {
1045
+ size: [terminatorWidth7, width8, height8],
1046
+ offset: [-fullLength8 / 2 + terminatorWidth7 / 2, 0, height8 / 2],
1047
+ color: "#ccc"
1048
+ }
1049
+ )
1050
+ ] });
1051
+ };
1052
+
1053
+ // lib/A2512.tsx
1054
+ var fullLength9 = 6.3;
1055
+ var width9 = 3.2;
1056
+ var height9 = 1.8;
1057
+ var terminatorWidth8 = 0.8;
1058
+ var bodyLength9 = fullLength9 - terminatorWidth8 * 2;
1059
+ var A2512 = ({ color = "#333" }) => {
1060
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1061
+ /* @__PURE__ */ jsx(
1062
+ Cuboid,
1063
+ {
1064
+ size: [bodyLength9, width9, height9],
1065
+ offset: [0, 0, height9 / 2],
1066
+ color
1067
+ }
1068
+ ),
1069
+ /* @__PURE__ */ jsx(
1070
+ Cuboid,
1071
+ {
1072
+ size: [terminatorWidth8, width9, height9],
1073
+ offset: [fullLength9 / 2 - terminatorWidth8 / 2, 0, height9 / 2],
1074
+ color: "#ccc"
1075
+ }
1076
+ ),
1077
+ /* @__PURE__ */ jsx(
1078
+ Cuboid,
1079
+ {
1080
+ size: [terminatorWidth8, width9, height9],
1081
+ offset: [-fullLength9 / 2 + terminatorWidth8 / 2, 0, height9 / 2],
1082
+ color: "#ccc"
1083
+ }
1084
+ )
1085
+ ] });
1086
+ };
1087
+
1088
+ // lib/FemaleHeader.tsx
1089
+ var FemaleHeader = ({
1090
+ numberOfPins,
1091
+ pitch = 2.54,
1092
+ legsLength = 3,
1093
+ outerDiameter = 0.945,
1094
+ innerDiameter = 0.945
1095
+ }) => {
1096
+ const pinThickness = innerDiameter / 1.5;
1097
+ const bodyDepth = pinThickness * 2 + outerDiameter;
1098
+ const bodyHeight = 5;
1099
+ const bodyWidth = (numberOfPins - 1) * pitch + outerDiameter + pitch / 2;
1100
+ const gapWidth = pinThickness * 1.6;
1101
+ const xoff = -((numberOfPins - 1) / 2) * pitch;
1102
+ const Body = /* @__PURE__ */ jsx(Colorize, { color: "#1a1a1a", children: /* @__PURE__ */ jsxs(Subtract, { children: [
1103
+ /* @__PURE__ */ jsx(
1104
+ Cuboid,
1105
+ {
1106
+ color: "#000",
1107
+ size: [bodyWidth, bodyDepth, bodyHeight],
1108
+ center: [0, 0, bodyHeight / 2]
1109
+ }
1110
+ ),
1111
+ Array.from(
1112
+ { length: numberOfPins },
1113
+ (_, i) => innerDiameter ? /* @__PURE__ */ jsx(
1114
+ Cylinder,
1115
+ {
1116
+ height: bodyHeight + 0.1,
1117
+ radius: innerDiameter / 2,
1118
+ center: [xoff + i * pitch, 0, bodyHeight / 2],
1119
+ color: "#222"
1120
+ },
1121
+ i
1122
+ ) : /* @__PURE__ */ jsx(
1123
+ Cuboid,
1124
+ {
1125
+ size: [gapWidth, gapWidth, bodyHeight],
1126
+ center: [xoff + i * pitch, 0, bodyHeight / 2]
1127
+ },
1128
+ i
1129
+ )
1130
+ )
1131
+ ] }) });
1132
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1133
+ Body,
1134
+ Array.from({ length: numberOfPins }, (_, i) => /* @__PURE__ */ jsxs(Colorize, { color: "silver", children: [
1135
+ /* @__PURE__ */ jsxs(Hull, { children: [
1136
+ /* @__PURE__ */ jsx(
1137
+ Cuboid,
1138
+ {
1139
+ color: "silver",
1140
+ size: [pinThickness, pinThickness, legsLength * 0.9],
1141
+ center: [xoff + i * pitch, 0, -legsLength / 2 * 0.9]
1142
+ }
1143
+ ),
1144
+ /* @__PURE__ */ jsx(
1145
+ Cuboid,
1146
+ {
1147
+ color: "silver",
1148
+ size: [pinThickness / 1.8, pinThickness / 1.8, legsLength],
1149
+ center: [xoff + i * pitch, 0, -legsLength / 2]
1150
+ }
1151
+ )
1152
+ ] }),
1153
+ /* @__PURE__ */ jsx(
1154
+ Cuboid,
1155
+ {
1156
+ color: "silver",
1157
+ size: [gapWidth, gapWidth, gapWidth * 0.5],
1158
+ center: [xoff + i * pitch, 0, gapWidth / 2 * 0.5]
1159
+ }
1160
+ )
1161
+ ] }, i))
1162
+ ] });
1163
+ };
1164
+
1165
+ // lib/PushButton.tsx
1166
+ var PushButton = ({
1167
+ width: width10,
1168
+ length,
1169
+ innerDiameter = 1
1170
+ }) => {
1171
+ const bodyWidth = width10;
1172
+ const bodyLength10 = length;
1173
+ const bodyHeight = width10 * 0.7;
1174
+ const legWidth = innerDiameter / 2.5;
1175
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1176
+ /* @__PURE__ */ jsx(
1177
+ RoundedCuboid,
1178
+ {
1179
+ color: "#1a1a1f",
1180
+ center: [0, 0, bodyHeight / 2],
1181
+ size: [bodyLength10, bodyLength10, bodyHeight],
1182
+ roundRadius: 0.3
1183
+ }
1184
+ ),
1185
+ /* @__PURE__ */ jsx(
1186
+ RoundedCuboid,
1187
+ {
1188
+ color: "#f2f2f2",
1189
+ center: [0, 0, bodyHeight + bodyHeight * 0.1 / 2.5],
1190
+ size: [bodyLength10, bodyLength10, bodyHeight * 0.1],
1191
+ roundRadius: 0.14
1192
+ }
1193
+ ),
1194
+ /* @__PURE__ */ jsx(
1195
+ Cylinder,
1196
+ {
1197
+ color: "#1a1a1f",
1198
+ height: bodyHeight * 0.8,
1199
+ radius: bodyWidth / 3,
1200
+ center: [0, 0, bodyHeight + bodyHeight * 0.8 / 2]
1201
+ }
1202
+ ),
1203
+ /* @__PURE__ */ jsx(
1204
+ Cylinder,
1205
+ {
1206
+ color: "#1a1a1f",
1207
+ height: bodyHeight * 0.2,
1208
+ radius: innerDiameter / 2,
1209
+ center: [
1210
+ bodyLength10 / 3,
1211
+ bodyLength10 / 3,
1212
+ bodyHeight + bodyHeight * 0.1 / 2
1213
+ ]
1214
+ }
1215
+ ),
1216
+ /* @__PURE__ */ jsx(
1217
+ Cylinder,
1218
+ {
1219
+ color: "#1a1a1f",
1220
+ height: bodyHeight * 0.2,
1221
+ radius: innerDiameter / 2,
1222
+ center: [
1223
+ -bodyLength10 / 3,
1224
+ -bodyLength10 / 3,
1225
+ bodyHeight + bodyHeight * 0.1 / 2
1226
+ ]
1227
+ }
1228
+ ),
1229
+ /* @__PURE__ */ jsx(
1230
+ Cylinder,
1231
+ {
1232
+ color: "#1a1a1f",
1233
+ height: bodyHeight * 0.2,
1234
+ radius: innerDiameter / 2,
1235
+ center: [
1236
+ -bodyLength10 / 3,
1237
+ bodyLength10 / 3,
1238
+ bodyHeight + bodyHeight * 0.1 / 2
1239
+ ]
1240
+ }
1241
+ ),
1242
+ /* @__PURE__ */ jsx(
1243
+ Cylinder,
1244
+ {
1245
+ color: "#1a1a1f",
1246
+ height: bodyHeight * 0.2,
1247
+ radius: innerDiameter / 2,
1248
+ center: [
1249
+ bodyLength10 / 3,
1250
+ -bodyLength10 / 3,
1251
+ bodyHeight + bodyHeight * 0.1 / 2
1252
+ ]
1253
+ }
1254
+ ),
1255
+ /* @__PURE__ */ jsx(
1256
+ PushButtonLeg,
1257
+ {
1258
+ thickness: innerDiameter / 3,
1259
+ width: legWidth,
1260
+ horizontalLength: bodyLength10 * 0.8,
1261
+ verticalLength: bodyHeight / 2,
1262
+ position: {
1263
+ x: -bodyWidth / 2,
1264
+ y: -bodyLength10 / 2,
1265
+ z: -bodyHeight * 1.2
1266
+ }
1267
+ }
1268
+ ),
1269
+ /* @__PURE__ */ jsx(
1270
+ PushButtonLeg,
1271
+ {
1272
+ thickness: innerDiameter / 3,
1273
+ width: legWidth,
1274
+ horizontalLength: bodyLength10 * 0.8,
1275
+ verticalLength: bodyHeight / 2,
1276
+ position: {
1277
+ x: -bodyWidth / 2,
1278
+ y: bodyLength10 / 2,
1279
+ z: -bodyHeight * 1.2
1280
+ },
1281
+ rotation: Math.PI
1282
+ }
1283
+ ),
1284
+ /* @__PURE__ */ jsx(
1285
+ PushButtonLeg,
1286
+ {
1287
+ thickness: innerDiameter / 3,
1288
+ width: legWidth,
1289
+ horizontalLength: bodyLength10 * 0.8,
1290
+ verticalLength: bodyHeight / 2,
1291
+ position: { x: bodyWidth / 2, y: bodyLength10 / 2, z: -bodyHeight * 1.2 },
1292
+ rotation: Math.PI
1293
+ }
1294
+ ),
1295
+ /* @__PURE__ */ jsx(
1296
+ PushButtonLeg,
1297
+ {
1298
+ thickness: innerDiameter / 3,
1299
+ width: legWidth,
1300
+ horizontalLength: bodyLength10 * 0.8,
1301
+ verticalLength: bodyHeight / 2,
1302
+ position: {
1303
+ x: bodyWidth / 2 + innerDiameter / 3.6,
1304
+ y: -bodyLength10 / 2,
1305
+ z: -bodyHeight * 1.2
1306
+ }
1307
+ }
1308
+ )
1309
+ ] });
1310
+ };
1311
+ var PushButtonLeg = (props) => {
1312
+ const {
1313
+ thickness,
1314
+ width: width10,
1315
+ horizontalLength,
1316
+ verticalLength,
1317
+ rotation = 0,
1318
+ position
1319
+ } = props;
1320
+ const points = [
1321
+ [0, horizontalLength],
1322
+ [-verticalLength / 3, horizontalLength / 3],
1323
+ [-verticalLength / 5, horizontalLength / 4],
1324
+ [0, 0]
1325
+ ];
1326
+ const polygon = getExpandedStroke(points, thickness);
1327
+ return /* @__PURE__ */ jsx(Colorize, { color: "#f2f2f2", children: /* @__PURE__ */ jsx(
1328
+ Translate,
1329
+ {
1330
+ offset: {
1331
+ x: position?.x || 0,
1332
+ y: position?.y || 0,
1333
+ z: position?.z || 0
1334
+ },
1335
+ children: /* @__PURE__ */ jsx(Rotate, { rotation: [0, 55, rotation], children: /* @__PURE__ */ jsx(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx(Polygon, { points: polygon.map((p) => [p.y, p.x]) }) }) })
1336
+ }
1337
+ ) });
1338
+ };
1339
+
1340
+ // lib/SOIC.tsx
1341
+ var SOIC = ({
1342
+ pinCount,
1343
+ leadLength,
1344
+ leadWidth,
1345
+ pitch,
1346
+ bodyWidth
1347
+ }) => {
1348
+ const sidePinCount = Math.ceil(pinCount / 2);
1349
+ const pinOffsetToCenter = (sidePinCount - 1) * pitch / 2;
1350
+ const leadThickness = 0.25;
1351
+ const bodyHeight = 1;
1352
+ const leadHeight = 0.8;
1353
+ const leadBodyOffset = leadLength * 0;
1354
+ const fullLength10 = pitch * (sidePinCount - 1) + leadWidth + 0.2;
1355
+ const bodyWidthAdjusted = bodyWidth * 0.55;
1356
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1357
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
1358
+ SmdChipLead,
1359
+ {
1360
+ position: {
1361
+ x: -bodyWidth / 2 - leadBodyOffset,
1362
+ y: i * pitch - pinOffsetToCenter,
1363
+ z: leadThickness / 2
1364
+ },
1365
+ width: leadWidth,
1366
+ thickness: leadThickness,
1367
+ padContactLength: leadLength / 2,
1368
+ bodyDistance: leadLength + 0.2,
1369
+ height: leadHeight
1370
+ },
1371
+ i
1372
+ )),
1373
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
1374
+ SmdChipLead,
1375
+ {
1376
+ rotation: Math.PI,
1377
+ position: {
1378
+ x: bodyWidth / 2 + leadBodyOffset,
1379
+ y: i * pitch - pinOffsetToCenter,
1380
+ z: leadThickness / 2
1381
+ },
1382
+ width: leadWidth,
1383
+ thickness: leadThickness,
1384
+ padContactLength: leadLength / 2,
1385
+ bodyDistance: leadLength + 0.2,
1386
+ height: leadHeight
1387
+ },
1388
+ i
1389
+ )),
1390
+ /* @__PURE__ */ jsx(
1391
+ ChipBody,
1392
+ {
1393
+ center: { x: 0, y: 0, z: leadThickness / 2 },
1394
+ width: bodyWidthAdjusted,
1395
+ length: fullLength10,
1396
+ height: bodyHeight
1397
+ }
1398
+ )
1399
+ ] });
1400
+ };
1401
+
1402
+ // lib/VSSOP.tsx
1403
+ var VSSOP = ({
1404
+ pinCount,
1405
+ pitch,
1406
+ leadWidth,
1407
+ leadLength,
1408
+ bodyWidth,
1409
+ bodyLength: bodyLength10
1410
+ }) => {
1411
+ const defaults = pinCount === 8 ? {
1412
+ pitch: 0.65,
1413
+ leadWidth: 0.3,
1414
+ leadLength: 1.6
1415
+ } : {
1416
+ pitch: 0.5,
1417
+ leadWidth: 0.225,
1418
+ leadLength: 1.45
1419
+ };
1420
+ const _pitch = !isNaN(parseFloat(pitch)) ? parseFloat(pitch) : defaults.pitch;
1421
+ const _leadWidth = !isNaN(parseFloat(leadWidth)) ? parseFloat(leadWidth) * 0.8 : defaults.leadWidth;
1422
+ const _leadLength = !isNaN(parseFloat(leadLength)) ? parseFloat(leadLength) : defaults.leadLength;
1423
+ const _bodyWidth = !isNaN(parseFloat(bodyWidth)) ? parseFloat(bodyWidth) * 0.8 : 2.6;
1424
+ const _bodyLength = !isNaN(parseFloat(bodyLength10)) ? parseFloat(bodyLength10) : 2 + Number(_pitch) * 1.4;
1425
+ const sidePinCount = pinCount / 2;
1426
+ const pinOffsetToCenter = (sidePinCount - 1) * _pitch / 2;
1427
+ const leadThickness = 0.15;
1428
+ const leadHeight = 0.8;
1429
+ const componentFullWidth = 4.5;
1430
+ const leadBodyDistance = (componentFullWidth - _bodyWidth) / 2;
1431
+ const padContactLength = leadBodyDistance * 0.5;
1432
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
1433
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
1434
+ SmdChipLead,
1435
+ {
1436
+ position: {
1437
+ x: -componentFullWidth / 2,
1438
+ y: pinOffsetToCenter - i * _pitch,
1439
+ z: leadThickness / 2
1440
+ },
1441
+ width: _leadWidth,
1442
+ thickness: leadThickness,
1443
+ padContactLength: padContactLength + 0.05,
1444
+ bodyDistance: leadBodyDistance + 0.05,
1445
+ height: leadHeight
1446
+ },
1447
+ `left-${i}`
1448
+ )),
1449
+ Array.from({ length: sidePinCount }).map((_, i) => /* @__PURE__ */ jsx(
1450
+ SmdChipLead,
1451
+ {
1452
+ rotation: Math.PI,
1453
+ position: {
1454
+ x: componentFullWidth / 2,
1455
+ y: pinOffsetToCenter - i * _pitch,
1456
+ z: leadThickness / 2
1457
+ },
1458
+ width: _leadWidth,
1459
+ thickness: leadThickness,
1460
+ padContactLength: padContactLength + 0.05,
1461
+ bodyDistance: leadBodyDistance + 0.05,
1462
+ height: leadHeight
1463
+ },
1464
+ `right-${i}`
1465
+ )),
1466
+ /* @__PURE__ */ jsx(
1467
+ ChipBody,
1468
+ {
1469
+ center: { x: 0, y: 0, z: leadThickness / 2 },
1470
+ width: _bodyWidth,
1471
+ length: _bodyLength,
1472
+ height: 1
1473
+ }
1474
+ )
1475
+ ] });
1476
+ };
1477
+
1478
+ // lib/Footprinter3d.tsx
1479
+ var Footprinter3d = ({ footprint }) => {
1480
+ const fpJson = fp.string(footprint).json();
1481
+ console.log(footprint, fpJson);
1482
+ switch (fpJson.fn) {
1483
+ case "dip":
1484
+ return /* @__PURE__ */ jsx(Dip, { numPins: fpJson.num_pins, pitch: fpJson.p, bodyWidth: fpJson.w });
1485
+ case "tssop":
1486
+ return /* @__PURE__ */ jsx(
1487
+ Tssop,
1488
+ {
1489
+ pinCount: fpJson.num_pins,
1490
+ leadLength: fpJson.pl,
1491
+ leadWidth: fpJson.pw,
1492
+ pitch: fpJson.p,
1493
+ bodyWidth: fpJson.w
1494
+ }
1495
+ );
1496
+ case "vssop":
1497
+ return /* @__PURE__ */ jsx(
1498
+ VSSOP,
1499
+ {
1500
+ pinCount: fpJson.num_pins,
1501
+ leadLength: fpJson.pl,
1502
+ leadWidth: fpJson.pw,
1503
+ pitch: fpJson.p,
1504
+ bodyWidth: fpJson.w,
1505
+ bodyLength: fpJson.h
1506
+ }
1507
+ );
1508
+ case "qfp":
1509
+ return /* @__PURE__ */ jsx(
1510
+ QFP,
1511
+ {
1512
+ pinCount: fpJson.num_pins,
1513
+ pitch: fpJson.p,
1514
+ leadWidth: fpJson.pw,
1515
+ padContactLength: fpJson.pl,
1516
+ bodyWidth: fpJson.w
1517
+ }
1518
+ );
1519
+ case "qfn":
1520
+ return /* @__PURE__ */ jsx(
1521
+ qfn_default,
1522
+ {
1523
+ num_pins: fpJson.num_pins,
1524
+ bodyWidth: fpJson.w,
1525
+ bodyLength: fpJson.h,
1526
+ pitch: fpJson.p,
1527
+ padLength: fpJson.pl,
1528
+ padWidth: fpJson.pw,
1529
+ thermalPadSize: {
1530
+ width: fpJson.thermalpad.x,
1531
+ length: fpJson.thermalpad.y
1532
+ }
1533
+ }
1534
+ );
1535
+ case "pinrow":
1536
+ if (fpJson.male)
1537
+ return /* @__PURE__ */ jsx(PinRow, { numberOfPins: fpJson.num_pins, pitch: fpJson.p });
1538
+ if (fpJson.female)
1539
+ return /* @__PURE__ */ jsx(FemaleHeader, { numberOfPins: fpJson.num_pins, pitch: fpJson.p });
1540
+ case "cap": {
1541
+ switch (fpJson.imperial) {
1542
+ case "0402":
1543
+ return /* @__PURE__ */ jsx(A0402, { color: "#856c4d" });
1544
+ case "0603":
1545
+ return /* @__PURE__ */ jsx(A0603, { color: "#856c4d" });
1546
+ case "0805":
1547
+ return /* @__PURE__ */ jsx(A0805, { color: "#856c4d" });
1548
+ case "0201":
1549
+ return /* @__PURE__ */ jsx(A0201, { color: "#856c4d" });
1550
+ case "01005":
1551
+ return /* @__PURE__ */ jsx(A01005, { color: "#856c4d" });
1552
+ case "1206":
1553
+ return /* @__PURE__ */ jsx(A1206, { color: "#856c4d" });
1554
+ case "1210":
1555
+ return /* @__PURE__ */ jsx(A1210, { color: "#856c4d" });
1556
+ case "2010":
1557
+ return /* @__PURE__ */ jsx(A2010, { color: "#856c4d" });
1558
+ case "2512":
1559
+ return /* @__PURE__ */ jsx(A2512, { color: "#856c4d" });
1560
+ }
1561
+ }
1562
+ case "sot235":
1563
+ return /* @__PURE__ */ jsx(SOT_235_default, {});
1564
+ case "pushbutton":
1565
+ return /* @__PURE__ */ jsx(
1566
+ PushButton,
1567
+ {
1568
+ width: fpJson.w,
1569
+ length: fpJson.h,
1570
+ innerDiameter: fpJson.id
1571
+ }
1572
+ );
1573
+ case "soic":
1574
+ return /* @__PURE__ */ jsx(
1575
+ SOIC,
1576
+ {
1577
+ pinCount: fpJson.num_pins,
1578
+ leadLength: fpJson.pl,
1579
+ leadWidth: fpJson.pw,
1580
+ pitch: fpJson.p,
1581
+ bodyWidth: fpJson.w
1582
+ }
1583
+ );
1584
+ }
1585
+ switch (fpJson.imperial) {
1586
+ case "0402":
1587
+ return /* @__PURE__ */ jsx(A0402, {});
1588
+ case "0603":
1589
+ return /* @__PURE__ */ jsx(A0603, {});
1590
+ case "0805":
1591
+ return /* @__PURE__ */ jsx(A0805, {});
1592
+ case "0201":
1593
+ return /* @__PURE__ */ jsx(A0201, {});
1594
+ case "01005":
1595
+ return /* @__PURE__ */ jsx(A01005, {});
1596
+ case "1206":
1597
+ return /* @__PURE__ */ jsx(A1206, {});
1598
+ case "1210":
1599
+ return /* @__PURE__ */ jsx(A1210, {});
1600
+ case "2010":
1601
+ return /* @__PURE__ */ jsx(A2010, {});
1602
+ case "2512":
1603
+ return /* @__PURE__ */ jsx(A2512, {});
1604
+ }
1605
+ return null;
1606
+ };
1607
+
1608
+ // lib/vanilla/render.ts
1609
+ import {
1610
+ primitives,
1611
+ transforms,
1612
+ booleans,
1613
+ hulls,
1614
+ geometries,
1615
+ extrusions
1616
+ } from "@jscad/modeling";
1617
+ var isVNode = (n) => n && typeof n === "object" && "type" in n;
1618
+ var degToRad = (v) => {
1619
+ if (typeof v === "number") return v;
1620
+ if (typeof v === "string") {
1621
+ const m = /^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(v);
1622
+ if (m) return parseFloat(m[1]) * Math.PI / 180;
1623
+ const n = Number(v);
1624
+ if (!Number.isNaN(n)) return n;
1625
+ }
1626
+ return 0;
1627
+ };
1628
+ var toVec3 = (v) => {
1629
+ if (Array.isArray(v))
1630
+ return [Number(v[0]) || 0, Number(v[1]) || 0, Number(v[2]) || 0];
1631
+ if (typeof v === "object" && v)
1632
+ return [Number(v.x) || 0, Number(v.y) || 0, Number(v.z) || 0];
1633
+ return [0, 0, 0];
1634
+ };
1635
+ function renderNode(node, colorCtx) {
1636
+ if (node == null || node === false) return [];
1637
+ if (Array.isArray(node)) return node.flatMap((n) => renderNode(n, colorCtx));
1638
+ if (!isVNode(node)) return [];
1639
+ const { type, props, children } = node;
1640
+ if (type === Fragment) {
1641
+ return children.flatMap((c) => renderNode(c, colorCtx));
1642
+ }
1643
+ if (type === Colorize) {
1644
+ const newColor = props?.color;
1645
+ return children.flatMap((c) => renderNode(c, newColor ?? colorCtx));
1646
+ }
1647
+ if (type === Translate) {
1648
+ const off = toVec3(
1649
+ props?.offset ?? { x: props?.x, y: props?.y, z: props?.z }
1650
+ );
1651
+ const geoms = children.flatMap((c) => renderNode(c, colorCtx));
1652
+ return geoms.map(({ geom, color }) => ({
1653
+ geom: transforms.translate(off, geom),
1654
+ color: color ?? colorCtx
1655
+ }));
1656
+ }
1657
+ if (type === Rotate) {
1658
+ const rot = Array.isArray(props?.rotation) ? [
1659
+ degToRad(props.rotation[0]),
1660
+ degToRad(props.rotation[1]),
1661
+ degToRad(props.rotation[2])
1662
+ ] : [
1663
+ degToRad(props?.x ?? 0),
1664
+ degToRad(props?.y ?? 0),
1665
+ degToRad(props?.z ?? 0)
1666
+ ];
1667
+ const geoms = children.flatMap((c) => renderNode(c, colorCtx));
1668
+ return geoms.map(({ geom, color }) => ({
1669
+ geom: transforms.rotateZ(
1670
+ rot[2],
1671
+ transforms.rotateY(rot[1], transforms.rotateX(rot[0], geom))
1672
+ ),
1673
+ color
1674
+ }));
1675
+ }
1676
+ if (type === Union || type === Subtract || type === Hull) {
1677
+ const geoms = children.flatMap((c) => renderNode(c, colorCtx)).map((g) => g.geom);
1678
+ if (geoms.length === 0) return [];
1679
+ let geom;
1680
+ if (type === Union) geom = booleans.union(geoms);
1681
+ else if (type === Subtract)
1682
+ geom = booleans.subtract(geoms[0], geoms.slice(1));
1683
+ else geom = hulls.hull(geoms);
1684
+ return [{ geom }];
1685
+ }
1686
+ if (type === Polygon) {
1687
+ const points = props?.points ?? [];
1688
+ const g2 = geometries.geom2.fromPoints(points);
1689
+ return [{ geom: g2, color: colorCtx ?? props?.color }];
1690
+ }
1691
+ if (type === ExtrudeLinear) {
1692
+ const geoms2 = children.flatMap((c) => renderNode(c, colorCtx)).map((g) => g.geom);
1693
+ if (geoms2.length === 0) return [];
1694
+ const base2 = geoms2.length > 1 ? booleans.union(geoms2) : geoms2[0];
1695
+ const height10 = props?.height ?? props?.h ?? 1;
1696
+ let g3 = extrusions.extrudeLinear({ height: height10 }, base2);
1697
+ return [{ geom: g3, color: colorCtx ?? props?.color }];
1698
+ }
1699
+ if (type === Cuboid || type === Cube || type === Cylinder || type === Sphere || type === RoundedCuboid) {
1700
+ let g;
1701
+ if (type === Cuboid) {
1702
+ const size = props?.size ?? [1, 1, 1];
1703
+ const offset = props?.offset;
1704
+ const center = props?.center ?? (offset ? [offset[0], offset[1], offset[2]] : [0, 0, 0]);
1705
+ g = primitives.cuboid({ size, center });
1706
+ } else if (type === Cube) {
1707
+ const size = props?.size ?? 1;
1708
+ const offset = props?.offset;
1709
+ const center = props?.center ?? (offset ? [offset[0], offset[1], offset[2]] : [0, 0, 0]);
1710
+ g = primitives.cube({ size, center });
1711
+ } else if (type === Cylinder) {
1712
+ const height10 = props?.height ?? 1;
1713
+ const radius = props?.radius ?? 1;
1714
+ const center = props?.center ?? [0, 0, 0];
1715
+ g = primitives.cylinder({ height: height10, radius, center });
1716
+ } else if (type === Sphere) {
1717
+ const radius = props?.radius ?? 1;
1718
+ const center = props?.center ?? [0, 0, 0];
1719
+ g = primitives.sphere({ radius, center });
1720
+ } else {
1721
+ const size = props?.size ?? [1, 1, 1];
1722
+ const roundRadius = props?.roundRadius ?? 0.1;
1723
+ const center = props?.center ?? [0, 0, 0];
1724
+ g = primitives.roundedCuboid({ size, roundRadius, center });
1725
+ }
1726
+ return [{ geom: g, color: colorCtx ?? props?.color }];
1727
+ }
1728
+ if (typeof type === "function") {
1729
+ const out = type(props ?? {});
1730
+ return renderNode(out, colorCtx);
1731
+ }
1732
+ return children.flatMap((c) => renderNode(c, colorCtx));
1733
+ }
1734
+ function render(root) {
1735
+ const geometries2 = renderNode(root);
1736
+ return { geometries: geometries2 };
1737
+ }
1738
+
1739
+ // lib/vanilla/index.ts
1740
+ function getJscadModelForFootprint(footprint) {
1741
+ const vnode = h(Footprinter3d, { footprint });
1742
+ return render(vnode);
1743
+ }
1744
+ export {
1745
+ getJscadModelForFootprint
1746
+ };
1747
+ //# sourceMappingURL=vanilla.js.map