@tscircuit/3d-viewer 0.0.372 → 0.0.374

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +406 -237
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -144,8 +144,8 @@ var require_dist = __commonJS({
144
144
  fromValues: (x, y) => [x, y]
145
145
  },
146
146
  vec3: {
147
- create: (x, y, z103) => [x, y, z103],
148
- fromValues: (x, y, z103) => [x, y, z103]
147
+ create: (x, y, z105) => [x, y, z105],
148
+ fromValues: (x, y, z105) => [x, y, z105]
149
149
  }
150
150
  },
151
151
  geometries: {
@@ -532,29 +532,29 @@ var require_fromRotation = __commonJS({
532
532
  var { sin: sin2, cos: cos2 } = require_trigonometry();
533
533
  var identity = require_identity();
534
534
  var fromRotation = (out, rad, axis) => {
535
- let [x, y, z103] = axis;
536
- const lengthSquared = x * x + y * y + z103 * z103;
535
+ let [x, y, z105] = axis;
536
+ const lengthSquared = x * x + y * y + z105 * z105;
537
537
  if (Math.abs(lengthSquared) < EPS) {
538
538
  return identity(out);
539
539
  }
540
540
  const len = 1 / Math.sqrt(lengthSquared);
541
541
  x *= len;
542
542
  y *= len;
543
- z103 *= len;
543
+ z105 *= len;
544
544
  const s = sin2(rad);
545
545
  const c = cos2(rad);
546
546
  const t = 1 - c;
547
547
  out[0] = x * x * t + c;
548
- out[1] = y * x * t + z103 * s;
549
- out[2] = z103 * x * t - y * s;
548
+ out[1] = y * x * t + z105 * s;
549
+ out[2] = z105 * x * t - y * s;
550
550
  out[3] = 0;
551
- out[4] = x * y * t - z103 * s;
551
+ out[4] = x * y * t - z105 * s;
552
552
  out[5] = y * y * t + c;
553
- out[6] = z103 * y * t + x * s;
553
+ out[6] = z105 * y * t + x * s;
554
554
  out[7] = 0;
555
- out[8] = x * z103 * t + y * s;
556
- out[9] = y * z103 * t - x * s;
557
- out[10] = z103 * z103 * t + c;
555
+ out[8] = x * z105 * t + y * s;
556
+ out[9] = y * z105 * t - x * s;
557
+ out[10] = z105 * z105 * t + c;
558
558
  out[11] = 0;
559
559
  out[12] = 0;
560
560
  out[13] = 0;
@@ -808,8 +808,8 @@ var require_distance = __commonJS({
808
808
  var distance2 = (a, b) => {
809
809
  const x = b[0] - a[0];
810
810
  const y = b[1] - a[1];
811
- const z103 = b[2] - a[2];
812
- return Math.sqrt(x * x + y * y + z103 * z103);
811
+ const z105 = b[2] - a[2];
812
+ return Math.sqrt(x * x + y * y + z105 * z105);
813
813
  };
814
814
  module.exports = distance2;
815
815
  }
@@ -857,11 +857,11 @@ var require_fromValues2 = __commonJS({
857
857
  "node_modules/@jscad/modeling/src/maths/vec3/fromValues.js"(exports, module) {
858
858
  "use strict";
859
859
  var create = require_create2();
860
- var fromValues = (x, y, z103) => {
860
+ var fromValues = (x, y, z105) => {
861
861
  const out = create();
862
862
  out[0] = x;
863
863
  out[1] = y;
864
- out[2] = z103;
864
+ out[2] = z105;
865
865
  return out;
866
866
  };
867
867
  module.exports = fromValues;
@@ -872,10 +872,10 @@ var require_fromValues2 = __commonJS({
872
872
  var require_fromVec2 = __commonJS({
873
873
  "node_modules/@jscad/modeling/src/maths/vec3/fromVec2.js"(exports, module) {
874
874
  "use strict";
875
- var fromVector2 = (out, vector, z103 = 0) => {
875
+ var fromVector2 = (out, vector, z105 = 0) => {
876
876
  out[0] = vector[0];
877
877
  out[1] = vector[1];
878
- out[2] = z103;
878
+ out[2] = z105;
879
879
  return out;
880
880
  };
881
881
  module.exports = fromVector2;
@@ -889,8 +889,8 @@ var require_length = __commonJS({
889
889
  var length2 = (vector) => {
890
890
  const x = vector[0];
891
891
  const y = vector[1];
892
- const z103 = vector[2];
893
- return Math.sqrt(x * x + y * y + z103 * z103);
892
+ const z105 = vector[2];
893
+ return Math.sqrt(x * x + y * y + z105 * z105);
894
894
  };
895
895
  module.exports = length2;
896
896
  }
@@ -973,14 +973,14 @@ var require_normalize = __commonJS({
973
973
  var normalize = (out, vector) => {
974
974
  const x = vector[0];
975
975
  const y = vector[1];
976
- const z103 = vector[2];
977
- let len = x * x + y * y + z103 * z103;
976
+ const z105 = vector[2];
977
+ let len = x * x + y * y + z105 * z105;
978
978
  if (len > 0) {
979
979
  len = 1 / Math.sqrt(len);
980
980
  }
981
981
  out[0] = x * len;
982
982
  out[1] = y * len;
983
- out[2] = z103 * len;
983
+ out[2] = z105 * len;
984
984
  return out;
985
985
  };
986
986
  module.exports = normalize;
@@ -1104,8 +1104,8 @@ var require_squaredDistance = __commonJS({
1104
1104
  var squaredDistance = (a, b) => {
1105
1105
  const x = b[0] - a[0];
1106
1106
  const y = b[1] - a[1];
1107
- const z103 = b[2] - a[2];
1108
- return x * x + y * y + z103 * z103;
1107
+ const z105 = b[2] - a[2];
1108
+ return x * x + y * y + z105 * z105;
1109
1109
  };
1110
1110
  module.exports = squaredDistance;
1111
1111
  }
@@ -1118,8 +1118,8 @@ var require_squaredLength = __commonJS({
1118
1118
  var squaredLength = (vector) => {
1119
1119
  const x = vector[0];
1120
1120
  const y = vector[1];
1121
- const z103 = vector[2];
1122
- return x * x + y * y + z103 * z103;
1121
+ const z105 = vector[2];
1122
+ return x * x + y * y + z105 * z105;
1123
1123
  };
1124
1124
  module.exports = squaredLength;
1125
1125
  }
@@ -1155,12 +1155,12 @@ var require_transform = __commonJS({
1155
1155
  var transform2 = (out, vector, matrix) => {
1156
1156
  const x = vector[0];
1157
1157
  const y = vector[1];
1158
- const z103 = vector[2];
1159
- let w = matrix[3] * x + matrix[7] * y + matrix[11] * z103 + matrix[15];
1158
+ const z105 = vector[2];
1159
+ let w = matrix[3] * x + matrix[7] * y + matrix[11] * z105 + matrix[15];
1160
1160
  w = w || 1;
1161
- out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] * z103 + matrix[12]) / w;
1162
- out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z103 + matrix[13]) / w;
1163
- out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z103 + matrix[14]) / w;
1161
+ out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] * z105 + matrix[12]) / w;
1162
+ out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z105 + matrix[13]) / w;
1163
+ out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z105 + matrix[14]) / w;
1164
1164
  return out;
1165
1165
  };
1166
1166
  module.exports = transform2;
@@ -1362,8 +1362,8 @@ var require_isMirroring = __commonJS({
1362
1362
  var isMirroring = (matrix) => {
1363
1363
  const x = matrix[4] * matrix[9] - matrix[8] * matrix[5];
1364
1364
  const y = matrix[8] * matrix[1] - matrix[0] * matrix[9];
1365
- const z103 = matrix[0] * matrix[5] - matrix[4] * matrix[1];
1366
- const d = x * matrix[2] + y * matrix[6] + z103 * matrix[10];
1365
+ const z105 = matrix[0] * matrix[5] - matrix[4] * matrix[1];
1366
+ const d = x * matrix[2] + y * matrix[6] + z105 * matrix[10];
1367
1367
  return d < 0;
1368
1368
  };
1369
1369
  module.exports = isMirroring;
@@ -1465,15 +1465,15 @@ var require_rotate = __commonJS({
1465
1465
  var { sin: sin2, cos: cos2 } = require_trigonometry();
1466
1466
  var copy = require_copy();
1467
1467
  var rotate2 = (out, matrix, radians, axis) => {
1468
- let [x, y, z103] = axis;
1469
- const lengthSquared = x * x + y * y + z103 * z103;
1468
+ let [x, y, z105] = axis;
1469
+ const lengthSquared = x * x + y * y + z105 * z105;
1470
1470
  if (Math.abs(lengthSquared) < EPS) {
1471
1471
  return copy(out, matrix);
1472
1472
  }
1473
1473
  const len = 1 / Math.sqrt(lengthSquared);
1474
1474
  x *= len;
1475
1475
  y *= len;
1476
- z103 *= len;
1476
+ z105 *= len;
1477
1477
  const s = sin2(radians);
1478
1478
  const c = cos2(radians);
1479
1479
  const t = 1 - c;
@@ -1490,14 +1490,14 @@ var require_rotate = __commonJS({
1490
1490
  const a22 = matrix[10];
1491
1491
  const a23 = matrix[11];
1492
1492
  const b00 = x * x * t + c;
1493
- const b01 = y * x * t + z103 * s;
1494
- const b02 = z103 * x * t - y * s;
1495
- const b10 = x * y * t - z103 * s;
1493
+ const b01 = y * x * t + z105 * s;
1494
+ const b02 = z105 * x * t - y * s;
1495
+ const b10 = x * y * t - z105 * s;
1496
1496
  const b11 = y * y * t + c;
1497
- const b12 = z103 * y * t + x * s;
1498
- const b20 = x * z103 * t + y * s;
1499
- const b21 = y * z103 * t - x * s;
1500
- const b22 = z103 * z103 * t + c;
1497
+ const b12 = z105 * y * t + x * s;
1498
+ const b20 = x * z105 * t + y * s;
1499
+ const b21 = y * z105 * t - x * s;
1500
+ const b22 = z105 * z105 * t + c;
1501
1501
  out[0] = a00 * b00 + a10 * b01 + a20 * b02;
1502
1502
  out[1] = a01 * b00 + a11 * b01 + a21 * b02;
1503
1503
  out[2] = a02 * b00 + a12 * b01 + a22 * b02;
@@ -1649,7 +1649,7 @@ var require_scale2 = __commonJS({
1649
1649
  var scale2 = (out, matrix, dimensions) => {
1650
1650
  const x = dimensions[0];
1651
1651
  const y = dimensions[1];
1652
- const z103 = dimensions[2];
1652
+ const z105 = dimensions[2];
1653
1653
  out[0] = matrix[0] * x;
1654
1654
  out[1] = matrix[1] * x;
1655
1655
  out[2] = matrix[2] * x;
@@ -1658,10 +1658,10 @@ var require_scale2 = __commonJS({
1658
1658
  out[5] = matrix[5] * y;
1659
1659
  out[6] = matrix[6] * y;
1660
1660
  out[7] = matrix[7] * y;
1661
- out[8] = matrix[8] * z103;
1662
- out[9] = matrix[9] * z103;
1663
- out[10] = matrix[10] * z103;
1664
- out[11] = matrix[11] * z103;
1661
+ out[8] = matrix[8] * z105;
1662
+ out[9] = matrix[9] * z105;
1663
+ out[10] = matrix[10] * z105;
1664
+ out[11] = matrix[11] * z105;
1665
1665
  out[12] = matrix[12];
1666
1666
  out[13] = matrix[13];
1667
1667
  out[14] = matrix[14];
@@ -1715,7 +1715,7 @@ var require_translate = __commonJS({
1715
1715
  var translate5 = (out, matrix, offsets) => {
1716
1716
  const x = offsets[0];
1717
1717
  const y = offsets[1];
1718
- const z103 = offsets[2];
1718
+ const z105 = offsets[2];
1719
1719
  let a00;
1720
1720
  let a01;
1721
1721
  let a02;
@@ -1729,10 +1729,10 @@ var require_translate = __commonJS({
1729
1729
  let a22;
1730
1730
  let a23;
1731
1731
  if (matrix === out) {
1732
- out[12] = matrix[0] * x + matrix[4] * y + matrix[8] * z103 + matrix[12];
1733
- out[13] = matrix[1] * x + matrix[5] * y + matrix[9] * z103 + matrix[13];
1734
- out[14] = matrix[2] * x + matrix[6] * y + matrix[10] * z103 + matrix[14];
1735
- out[15] = matrix[3] * x + matrix[7] * y + matrix[11] * z103 + matrix[15];
1732
+ out[12] = matrix[0] * x + matrix[4] * y + matrix[8] * z105 + matrix[12];
1733
+ out[13] = matrix[1] * x + matrix[5] * y + matrix[9] * z105 + matrix[13];
1734
+ out[14] = matrix[2] * x + matrix[6] * y + matrix[10] * z105 + matrix[14];
1735
+ out[15] = matrix[3] * x + matrix[7] * y + matrix[11] * z105 + matrix[15];
1736
1736
  } else {
1737
1737
  a00 = matrix[0];
1738
1738
  a01 = matrix[1];
@@ -1758,10 +1758,10 @@ var require_translate = __commonJS({
1758
1758
  out[9] = a21;
1759
1759
  out[10] = a22;
1760
1760
  out[11] = a23;
1761
- out[12] = a00 * x + a10 * y + a20 * z103 + matrix[12];
1762
- out[13] = a01 * x + a11 * y + a21 * z103 + matrix[13];
1763
- out[14] = a02 * x + a12 * y + a22 * z103 + matrix[14];
1764
- out[15] = a03 * x + a13 * y + a23 * z103 + matrix[15];
1761
+ out[12] = a00 * x + a10 * y + a20 * z105 + matrix[12];
1762
+ out[13] = a01 * x + a11 * y + a21 * z105 + matrix[13];
1763
+ out[14] = a02 * x + a12 * y + a22 * z105 + matrix[14];
1764
+ out[15] = a03 * x + a13 * y + a23 * z105 + matrix[15];
1765
1765
  }
1766
1766
  return out;
1767
1767
  };
@@ -3831,11 +3831,11 @@ var require_fromValues4 = __commonJS({
3831
3831
  "node_modules/@jscad/modeling/src/maths/vec4/fromValues.js"(exports, module) {
3832
3832
  "use strict";
3833
3833
  var create = require_create7();
3834
- var fromValues = (x, y, z103, w) => {
3834
+ var fromValues = (x, y, z105, w) => {
3835
3835
  const out = create();
3836
3836
  out[0] = x;
3837
3837
  out[1] = y;
3838
- out[2] = z103;
3838
+ out[2] = z105;
3839
3839
  out[3] = w;
3840
3840
  return out;
3841
3841
  };
@@ -3993,8 +3993,8 @@ var require_projectionOfPoint = __commonJS({
3993
3993
  const a = point2[0] * plane[0] + point2[1] * plane[1] + point2[2] * plane[2] - plane[3];
3994
3994
  const x = point2[0] - a * plane[0];
3995
3995
  const y = point2[1] - a * plane[1];
3996
- const z103 = point2[2] - a * plane[2];
3997
- return vec3.fromValues(x, y, z103);
3996
+ const z105 = point2[2] - a * plane[2];
3997
+ return vec3.fromValues(x, y, z105);
3998
3998
  };
3999
3999
  module.exports = projectionOfPoint;
4000
4000
  }
@@ -4298,11 +4298,11 @@ var require_transform5 = __commonJS({
4298
4298
  "node_modules/@jscad/modeling/src/maths/vec4/transform.js"(exports, module) {
4299
4299
  "use strict";
4300
4300
  var transform2 = (out, vector, matrix) => {
4301
- const [x, y, z103, w] = vector;
4302
- out[0] = matrix[0] * x + matrix[4] * y + matrix[8] * z103 + matrix[12] * w;
4303
- out[1] = matrix[1] * x + matrix[5] * y + matrix[9] * z103 + matrix[13] * w;
4304
- out[2] = matrix[2] * x + matrix[6] * y + matrix[10] * z103 + matrix[14] * w;
4305
- out[3] = matrix[3] * x + matrix[7] * y + matrix[11] * z103 + matrix[15] * w;
4301
+ const [x, y, z105, w] = vector;
4302
+ out[0] = matrix[0] * x + matrix[4] * y + matrix[8] * z105 + matrix[12] * w;
4303
+ out[1] = matrix[1] * x + matrix[5] * y + matrix[9] * z105 + matrix[13] * w;
4304
+ out[2] = matrix[2] * x + matrix[6] * y + matrix[10] * z105 + matrix[14] * w;
4305
+ out[3] = matrix[3] * x + matrix[7] * y + matrix[11] * z105 + matrix[15] * w;
4306
4306
  return out;
4307
4307
  };
4308
4308
  module.exports = transform2;
@@ -4364,8 +4364,8 @@ var require_measureBoundingSphere = __commonJS({
4364
4364
  out[2] = (minz[2] + maxz[2]) * 0.5;
4365
4365
  const x = out[0] - maxx[0];
4366
4366
  const y = out[1] - maxy[1];
4367
- const z103 = out[2] - maxz[2];
4368
- out[3] = Math.sqrt(x * x + y * y + z103 * z103);
4367
+ const z105 = out[2] - maxz[2];
4368
+ out[3] = Math.sqrt(x * x + y * y + z105 * z105);
4369
4369
  cache.set(polygon2, out);
4370
4370
  return out;
4371
4371
  };
@@ -14416,7 +14416,28 @@ var ContainerWithTooltip_default = ContainerWithTooltip;
14416
14416
 
14417
14417
  // src/hooks/use-global-obj-loader.ts
14418
14418
  import { useState as useState2, useEffect as useEffect3 } from "react";
14419
- import { MTLLoader, OBJLoader, VRMLLoader } from "three-stdlib";
14419
+ import { MTLLoader, OBJLoader } from "three-stdlib";
14420
+
14421
+ // src/utils/vrml.ts
14422
+ import { VRMLLoader } from "three-stdlib";
14423
+ function sanitizeVrmlIdentifiers(text) {
14424
+ return text.replace(/(DEF|USE)\s+([^\s]+)/g, (match, type, name) => {
14425
+ return `${type} ${name.replace(/-/g, "_")}`;
14426
+ });
14427
+ }
14428
+ async function loadVrml(url) {
14429
+ const response = await fetch(url);
14430
+ if (!response.ok) {
14431
+ throw new Error(
14432
+ `Failed to fetch "${url}": ${response.status} ${response.statusText}`
14433
+ );
14434
+ }
14435
+ const text = await response.text();
14436
+ const loader = new VRMLLoader();
14437
+ return loader.parse(sanitizeVrmlIdentifiers(text), url);
14438
+ }
14439
+
14440
+ // src/hooks/use-global-obj-loader.ts
14420
14441
  if (typeof window !== "undefined" && !window.TSCIRCUIT_OBJ_LOADER_CACHE) {
14421
14442
  window.TSCIRCUIT_OBJ_LOADER_CACHE = /* @__PURE__ */ new Map();
14422
14443
  }
@@ -14430,8 +14451,7 @@ function useGlobalObjLoader(url) {
14430
14451
  async function loadAndParseObj() {
14431
14452
  try {
14432
14453
  if (cleanUrl.endsWith(".wrl")) {
14433
- const loader = new VRMLLoader();
14434
- return await loader.loadAsync(cleanUrl);
14454
+ return await loadVrml(cleanUrl);
14435
14455
  }
14436
14456
  const response = await fetch(cleanUrl);
14437
14457
  if (!response.ok) {
@@ -14655,7 +14675,7 @@ var import_jscad_planner = __toESM(require_dist(), 1);
14655
14675
  var import_modeling2 = __toESM(require_src(), 1);
14656
14676
 
14657
14677
  // node_modules/@tscircuit/footprinter/dist/index.js
14658
- import { z as z102 } from "zod";
14678
+ import { z as z104 } from "zod";
14659
14679
 
14660
14680
  // node_modules/@tscircuit/mm/dist/index.js
14661
14681
  var unitToMm = {
@@ -14785,6 +14805,8 @@ import { z as z98 } from "zod";
14785
14805
  import { z as z99 } from "zod";
14786
14806
  import { z as z100 } from "zod";
14787
14807
  import { z as z101 } from "zod";
14808
+ import { z as z102 } from "zod";
14809
+ import { z as z103 } from "zod";
14788
14810
  var unitMappings = {
14789
14811
  Hz: {
14790
14812
  baseUnit: "Hz",
@@ -16429,106 +16451,120 @@ var pcb_missing_footprint_error = z90.object({
16429
16451
  expectTypesMatch(
16430
16452
  true
16431
16453
  );
16432
- var pcb_group = z91.object({
16433
- type: z91.literal("pcb_group"),
16434
- pcb_group_id: getZodPrefixedIdWithDefault("pcb_group"),
16435
- source_group_id: z91.string(),
16436
- is_subcircuit: z91.boolean().optional(),
16454
+ var external_footprint_load_error = z91.object({
16455
+ type: z91.literal("external_footprint_load_error"),
16456
+ external_footprint_load_error_id: getZodPrefixedIdWithDefault(
16457
+ "external_footprint_load_error"
16458
+ ),
16459
+ pcb_component_id: z91.string(),
16460
+ source_component_id: z91.string(),
16461
+ pcb_group_id: z91.string().optional(),
16437
16462
  subcircuit_id: z91.string().optional(),
16463
+ footprinter_string: z91.string().optional(),
16464
+ error_type: z91.literal("external_footprint_load_error").default("external_footprint_load_error"),
16465
+ message: z91.string()
16466
+ }).describe("Defines an error when an external footprint fails to load");
16467
+ expectTypesMatch(true);
16468
+ var pcb_group = z92.object({
16469
+ type: z92.literal("pcb_group"),
16470
+ pcb_group_id: getZodPrefixedIdWithDefault("pcb_group"),
16471
+ source_group_id: z92.string(),
16472
+ is_subcircuit: z92.boolean().optional(),
16473
+ subcircuit_id: z92.string().optional(),
16438
16474
  width: length,
16439
16475
  height: length,
16440
16476
  center: point,
16441
- pcb_component_ids: z91.array(z91.string()),
16442
- name: z91.string().optional(),
16443
- description: z91.string().optional(),
16444
- layout_mode: z91.string().optional(),
16445
- autorouter_configuration: z91.object({
16477
+ pcb_component_ids: z92.array(z92.string()),
16478
+ name: z92.string().optional(),
16479
+ description: z92.string().optional(),
16480
+ layout_mode: z92.string().optional(),
16481
+ autorouter_configuration: z92.object({
16446
16482
  trace_clearance: length
16447
16483
  }).optional(),
16448
- autorouter_used_string: z91.string().optional()
16484
+ autorouter_used_string: z92.string().optional()
16449
16485
  }).describe("Defines a group of components on the PCB");
16450
16486
  expectTypesMatch(true);
16451
- var pcb_autorouting_error = z92.object({
16452
- type: z92.literal("pcb_autorouting_error"),
16487
+ var pcb_autorouting_error = z93.object({
16488
+ type: z93.literal("pcb_autorouting_error"),
16453
16489
  pcb_error_id: getZodPrefixedIdWithDefault("pcb_autorouting_error"),
16454
- error_type: z92.literal("pcb_autorouting_error").default("pcb_autorouting_error"),
16455
- message: z92.string(),
16456
- subcircuit_id: z92.string().optional()
16490
+ error_type: z93.literal("pcb_autorouting_error").default("pcb_autorouting_error"),
16491
+ message: z93.string(),
16492
+ subcircuit_id: z93.string().optional()
16457
16493
  }).describe("The autorouting has failed to route a portion of the board");
16458
16494
  expectTypesMatch(true);
16459
- var pcb_manual_edit_conflict_warning = z93.object({
16460
- type: z93.literal("pcb_manual_edit_conflict_warning"),
16495
+ var pcb_manual_edit_conflict_warning = z94.object({
16496
+ type: z94.literal("pcb_manual_edit_conflict_warning"),
16461
16497
  pcb_manual_edit_conflict_warning_id: getZodPrefixedIdWithDefault(
16462
16498
  "pcb_manual_edit_conflict_warning"
16463
16499
  ),
16464
- warning_type: z93.literal("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),
16465
- message: z93.string(),
16466
- pcb_component_id: z93.string(),
16467
- pcb_group_id: z93.string().optional(),
16468
- subcircuit_id: z93.string().optional(),
16469
- source_component_id: z93.string()
16500
+ warning_type: z94.literal("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),
16501
+ message: z94.string(),
16502
+ pcb_component_id: z94.string(),
16503
+ pcb_group_id: z94.string().optional(),
16504
+ subcircuit_id: z94.string().optional(),
16505
+ source_component_id: z94.string()
16470
16506
  }).describe(
16471
16507
  "Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"
16472
16508
  );
16473
16509
  expectTypesMatch(true);
16474
- var pcb_breakout_point = z94.object({
16475
- type: z94.literal("pcb_breakout_point"),
16510
+ var pcb_breakout_point = z95.object({
16511
+ type: z95.literal("pcb_breakout_point"),
16476
16512
  pcb_breakout_point_id: getZodPrefixedIdWithDefault("pcb_breakout_point"),
16477
- pcb_group_id: z94.string(),
16478
- subcircuit_id: z94.string().optional(),
16479
- source_trace_id: z94.string().optional(),
16480
- source_port_id: z94.string().optional(),
16481
- source_net_id: z94.string().optional(),
16513
+ pcb_group_id: z95.string(),
16514
+ subcircuit_id: z95.string().optional(),
16515
+ source_trace_id: z95.string().optional(),
16516
+ source_port_id: z95.string().optional(),
16517
+ source_net_id: z95.string().optional(),
16482
16518
  x: distance,
16483
16519
  y: distance
16484
16520
  }).describe(
16485
16521
  "Defines a routing target within a pcb_group for a source_trace or source_net"
16486
16522
  );
16487
16523
  expectTypesMatch(true);
16488
- var pcb_ground_plane = z95.object({
16489
- type: z95.literal("pcb_ground_plane"),
16524
+ var pcb_ground_plane = z96.object({
16525
+ type: z96.literal("pcb_ground_plane"),
16490
16526
  pcb_ground_plane_id: getZodPrefixedIdWithDefault("pcb_ground_plane"),
16491
- source_pcb_ground_plane_id: z95.string(),
16492
- source_net_id: z95.string(),
16493
- pcb_group_id: z95.string().optional(),
16494
- subcircuit_id: z95.string().optional()
16527
+ source_pcb_ground_plane_id: z96.string(),
16528
+ source_net_id: z96.string(),
16529
+ pcb_group_id: z96.string().optional(),
16530
+ subcircuit_id: z96.string().optional()
16495
16531
  }).describe("Defines a ground plane on the PCB");
16496
16532
  expectTypesMatch(true);
16497
- var pcb_ground_plane_region = z96.object({
16498
- type: z96.literal("pcb_ground_plane_region"),
16533
+ var pcb_ground_plane_region = z97.object({
16534
+ type: z97.literal("pcb_ground_plane_region"),
16499
16535
  pcb_ground_plane_region_id: getZodPrefixedIdWithDefault(
16500
16536
  "pcb_ground_plane_region"
16501
16537
  ),
16502
- pcb_ground_plane_id: z96.string(),
16503
- pcb_group_id: z96.string().optional(),
16504
- subcircuit_id: z96.string().optional(),
16538
+ pcb_ground_plane_id: z97.string(),
16539
+ pcb_group_id: z97.string().optional(),
16540
+ subcircuit_id: z97.string().optional(),
16505
16541
  layer: layer_ref,
16506
- points: z96.array(point)
16542
+ points: z97.array(point)
16507
16543
  }).describe("Defines a polygon region of a ground plane");
16508
16544
  expectTypesMatch(true);
16509
- var pcb_thermal_spoke = z97.object({
16510
- type: z97.literal("pcb_thermal_spoke"),
16545
+ var pcb_thermal_spoke = z98.object({
16546
+ type: z98.literal("pcb_thermal_spoke"),
16511
16547
  pcb_thermal_spoke_id: getZodPrefixedIdWithDefault("pcb_thermal_spoke"),
16512
- pcb_ground_plane_id: z97.string(),
16513
- shape: z97.string(),
16514
- spoke_count: z97.number(),
16548
+ pcb_ground_plane_id: z98.string(),
16549
+ shape: z98.string(),
16550
+ spoke_count: z98.number(),
16515
16551
  spoke_thickness: distance,
16516
16552
  spoke_inner_diameter: distance,
16517
16553
  spoke_outer_diameter: distance,
16518
- pcb_plated_hole_id: z97.string().optional(),
16519
- subcircuit_id: z97.string().optional()
16554
+ pcb_plated_hole_id: z98.string().optional(),
16555
+ subcircuit_id: z98.string().optional()
16520
16556
  }).describe("Pattern for connecting a ground plane to a plated hole");
16521
16557
  expectTypesMatch(true);
16522
- var pcb_copper_pour_base = z98.object({
16523
- type: z98.literal("pcb_copper_pour"),
16558
+ var pcb_copper_pour_base = z99.object({
16559
+ type: z99.literal("pcb_copper_pour"),
16524
16560
  pcb_copper_pour_id: getZodPrefixedIdWithDefault("pcb_copper_pour"),
16525
- pcb_group_id: z98.string().optional(),
16526
- subcircuit_id: z98.string().optional(),
16561
+ pcb_group_id: z99.string().optional(),
16562
+ subcircuit_id: z99.string().optional(),
16527
16563
  layer: layer_ref,
16528
- source_net_id: z98.string().optional()
16564
+ source_net_id: z99.string().optional()
16529
16565
  });
16530
16566
  var pcb_copper_pour_rect = pcb_copper_pour_base.extend({
16531
- shape: z98.literal("rect"),
16567
+ shape: z99.literal("rect"),
16532
16568
  center: point,
16533
16569
  width: length,
16534
16570
  height: length,
@@ -16536,45 +16572,67 @@ var pcb_copper_pour_rect = pcb_copper_pour_base.extend({
16536
16572
  });
16537
16573
  expectTypesMatch(true);
16538
16574
  var pcb_copper_pour_brep = pcb_copper_pour_base.extend({
16539
- shape: z98.literal("brep"),
16575
+ shape: z99.literal("brep"),
16540
16576
  brep_shape
16541
16577
  });
16542
16578
  expectTypesMatch(true);
16543
16579
  var pcb_copper_pour_polygon = pcb_copper_pour_base.extend({
16544
- shape: z98.literal("polygon"),
16545
- points: z98.array(point)
16580
+ shape: z99.literal("polygon"),
16581
+ points: z99.array(point)
16546
16582
  });
16547
16583
  expectTypesMatch(true);
16548
- var pcb_copper_pour = z98.discriminatedUnion("shape", [
16584
+ var pcb_copper_pour = z99.discriminatedUnion("shape", [
16549
16585
  pcb_copper_pour_rect,
16550
16586
  pcb_copper_pour_brep,
16551
16587
  pcb_copper_pour_polygon
16552
16588
  ]).describe("Defines a copper pour on the PCB.");
16553
16589
  expectTypesMatch(true);
16554
- var cad_component = z99.object({
16555
- type: z99.literal("cad_component"),
16556
- cad_component_id: z99.string(),
16557
- pcb_component_id: z99.string(),
16558
- source_component_id: z99.string(),
16590
+ var pcb_component_outside_board_error = z100.object({
16591
+ type: z100.literal("pcb_component_outside_board_error"),
16592
+ pcb_component_outside_board_error_id: getZodPrefixedIdWithDefault(
16593
+ "pcb_component_outside_board_error"
16594
+ ),
16595
+ error_type: z100.literal("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),
16596
+ message: z100.string(),
16597
+ pcb_component_id: z100.string(),
16598
+ pcb_board_id: z100.string(),
16599
+ component_center: point,
16600
+ component_bounds: z100.object({
16601
+ min_x: z100.number(),
16602
+ max_x: z100.number(),
16603
+ min_y: z100.number(),
16604
+ max_y: z100.number()
16605
+ }),
16606
+ subcircuit_id: z100.string().optional(),
16607
+ source_component_id: z100.string().optional()
16608
+ }).describe(
16609
+ "Error emitted when a PCB component is placed outside the board boundaries"
16610
+ );
16611
+ expectTypesMatch(true);
16612
+ var cad_component = z101.object({
16613
+ type: z101.literal("cad_component"),
16614
+ cad_component_id: z101.string(),
16615
+ pcb_component_id: z101.string(),
16616
+ source_component_id: z101.string(),
16559
16617
  position: point3,
16560
16618
  rotation: point3.optional(),
16561
16619
  size: point3.optional(),
16562
16620
  layer: layer_ref.optional(),
16563
- subcircuit_id: z99.string().optional(),
16621
+ subcircuit_id: z101.string().optional(),
16564
16622
  // These are all ways to generate/load the 3d model
16565
- footprinter_string: z99.string().optional(),
16566
- model_obj_url: z99.string().optional(),
16567
- model_stl_url: z99.string().optional(),
16568
- model_3mf_url: z99.string().optional(),
16569
- model_gltf_url: z99.string().optional(),
16570
- model_glb_url: z99.string().optional(),
16571
- model_step_url: z99.string().optional(),
16572
- model_wrl_url: z99.string().optional(),
16573
- model_jscad: z99.any().optional()
16623
+ footprinter_string: z101.string().optional(),
16624
+ model_obj_url: z101.string().optional(),
16625
+ model_stl_url: z101.string().optional(),
16626
+ model_3mf_url: z101.string().optional(),
16627
+ model_gltf_url: z101.string().optional(),
16628
+ model_glb_url: z101.string().optional(),
16629
+ model_step_url: z101.string().optional(),
16630
+ model_wrl_url: z101.string().optional(),
16631
+ model_jscad: z101.any().optional()
16574
16632
  }).describe("Defines a component on the PCB");
16575
16633
  expectTypesMatch(true);
16576
- var wave_shape = z100.enum(["sinewave", "square", "triangle", "sawtooth"]);
16577
- var percentage = z100.union([z100.string(), z100.number()]).transform((val) => {
16634
+ var wave_shape = z102.enum(["sinewave", "square", "triangle", "sawtooth"]);
16635
+ var percentage = z102.union([z102.string(), z102.number()]).transform((val) => {
16578
16636
  if (typeof val === "string") {
16579
16637
  if (val.endsWith("%")) {
16580
16638
  return parseFloat(val.slice(0, -1)) / 100;
@@ -16583,30 +16641,30 @@ var percentage = z100.union([z100.string(), z100.number()]).transform((val) => {
16583
16641
  }
16584
16642
  return val;
16585
16643
  }).pipe(
16586
- z100.number().min(0, "Duty cycle must be non-negative").max(1, "Duty cycle cannot be greater than 100%")
16644
+ z102.number().min(0, "Duty cycle must be non-negative").max(1, "Duty cycle cannot be greater than 100%")
16587
16645
  );
16588
- var simulation_dc_voltage_source = z100.object({
16589
- type: z100.literal("simulation_voltage_source"),
16646
+ var simulation_dc_voltage_source = z102.object({
16647
+ type: z102.literal("simulation_voltage_source"),
16590
16648
  simulation_voltage_source_id: getZodPrefixedIdWithDefault(
16591
16649
  "simulation_voltage_source"
16592
16650
  ),
16593
- is_dc_source: z100.literal(true).optional().default(true),
16594
- positive_source_port_id: z100.string().optional(),
16595
- negative_source_port_id: z100.string().optional(),
16596
- positive_source_net_id: z100.string().optional(),
16597
- negative_source_net_id: z100.string().optional(),
16651
+ is_dc_source: z102.literal(true).optional().default(true),
16652
+ positive_source_port_id: z102.string().optional(),
16653
+ negative_source_port_id: z102.string().optional(),
16654
+ positive_source_net_id: z102.string().optional(),
16655
+ negative_source_net_id: z102.string().optional(),
16598
16656
  voltage
16599
16657
  }).describe("Defines a DC voltage source for simulation");
16600
- var simulation_ac_voltage_source = z100.object({
16601
- type: z100.literal("simulation_voltage_source"),
16658
+ var simulation_ac_voltage_source = z102.object({
16659
+ type: z102.literal("simulation_voltage_source"),
16602
16660
  simulation_voltage_source_id: getZodPrefixedIdWithDefault(
16603
16661
  "simulation_voltage_source"
16604
16662
  ),
16605
- is_dc_source: z100.literal(false),
16606
- terminal1_source_port_id: z100.string().optional(),
16607
- terminal2_source_port_id: z100.string().optional(),
16608
- terminal1_source_net_id: z100.string().optional(),
16609
- terminal2_source_net_id: z100.string().optional(),
16663
+ is_dc_source: z102.literal(false),
16664
+ terminal1_source_port_id: z102.string().optional(),
16665
+ terminal2_source_port_id: z102.string().optional(),
16666
+ terminal1_source_net_id: z102.string().optional(),
16667
+ terminal2_source_net_id: z102.string().optional(),
16610
16668
  voltage: voltage.optional(),
16611
16669
  frequency: frequency.optional(),
16612
16670
  peak_to_peak_voltage: voltage.optional(),
@@ -16614,11 +16672,11 @@ var simulation_ac_voltage_source = z100.object({
16614
16672
  phase: rotation.optional(),
16615
16673
  duty_cycle: percentage.optional()
16616
16674
  }).describe("Defines an AC voltage source for simulation");
16617
- var simulation_voltage_source = z100.union([simulation_dc_voltage_source, simulation_ac_voltage_source]).describe("Defines a voltage source for simulation");
16675
+ var simulation_voltage_source = z102.union([simulation_dc_voltage_source, simulation_ac_voltage_source]).describe("Defines a voltage source for simulation");
16618
16676
  expectTypesMatch(true);
16619
16677
  expectTypesMatch(true);
16620
16678
  expectTypesMatch(true);
16621
- var any_circuit_element = z101.union([
16679
+ var any_circuit_element = z103.union([
16622
16680
  source_trace,
16623
16681
  source_port,
16624
16682
  any_source_component,
@@ -16649,6 +16707,7 @@ var any_circuit_element = z101.union([
16649
16707
  pcb_component,
16650
16708
  pcb_hole,
16651
16709
  pcb_missing_footprint_error,
16710
+ external_footprint_load_error,
16652
16711
  pcb_manual_edit_conflict_warning,
16653
16712
  pcb_plated_hole,
16654
16713
  pcb_keepout,
@@ -16682,6 +16741,7 @@ var any_circuit_element = z101.union([
16682
16741
  pcb_ground_plane_region,
16683
16742
  pcb_thermal_spoke,
16684
16743
  pcb_copper_pour,
16744
+ pcb_component_outside_board_error,
16685
16745
  schematic_box,
16686
16746
  schematic_text,
16687
16747
  schematic_line,
@@ -16890,12 +16950,12 @@ function convertMilToMm(value) {
16890
16950
  }
16891
16951
  return Number(value);
16892
16952
  }
16893
- var lengthInMm = z102.union([z102.string(), z102.number()]).transform((val) => convertMilToMm(val));
16894
- var extendDipDef = (newDefaults) => z102.object({
16895
- fn: z102.string(),
16896
- num_pins: z102.number().optional().default(6),
16897
- wide: z102.boolean().optional(),
16898
- narrow: z102.boolean().optional(),
16953
+ var lengthInMm = z104.union([z104.string(), z104.number()]).transform((val) => convertMilToMm(val));
16954
+ var extendDipDef = (newDefaults) => z104.object({
16955
+ fn: z104.string(),
16956
+ num_pins: z104.number().optional().default(6),
16957
+ wide: z104.boolean().optional(),
16958
+ narrow: z104.boolean().optional(),
16899
16959
  w: lengthInMm.optional(),
16900
16960
  p: lengthInMm.default(newDefaults.p ?? "2.54mm"),
16901
16961
  id: lengthInMm.optional(),
@@ -17422,6 +17482,20 @@ var bga = (raw_params) => {
17422
17482
  parameters
17423
17483
  };
17424
17484
  };
17485
+ var pillpad = (pn, x, y, w, h2) => {
17486
+ return {
17487
+ type: "pcb_smtpad",
17488
+ x,
17489
+ y,
17490
+ width: w,
17491
+ height: h2,
17492
+ radius: h2 / 2,
17493
+ layer: "top",
17494
+ shape: "pill",
17495
+ pcb_smtpad_id: "",
17496
+ port_hints: Array.isArray(pn) ? pn.map((item) => item.toString()) : [pn.toString()]
17497
+ };
17498
+ };
17425
17499
  var extendSoicDef = (newDefaults) => z610.object({
17426
17500
  fn: z610.string(),
17427
17501
  num_pins: z610.number().optional().default(8),
@@ -17429,7 +17503,8 @@ var extendSoicDef = (newDefaults) => z610.object({
17429
17503
  p: length.default(length.parse(newDefaults.p ?? "1.27mm")),
17430
17504
  pw: length.default(length.parse(newDefaults.pw ?? "0.6mm")),
17431
17505
  pl: length.default(length.parse(newDefaults.pl ?? "1.0mm")),
17432
- legsoutside: z610.boolean().optional().default(newDefaults.legsoutside ?? false)
17506
+ legsoutside: z610.boolean().optional().default(newDefaults.legsoutside ?? false),
17507
+ pillpads: z610.boolean().optional().default(newDefaults.pillpads ?? false)
17433
17508
  }).transform((v) => {
17434
17509
  if (!v.pw && !v.pl) {
17435
17510
  v.pw = length.parse("0.6mm");
@@ -17476,7 +17551,11 @@ var soicWithoutParsing = (parameters) => {
17476
17551
  pl: parameters.pl,
17477
17552
  legsoutside: parameters.legsoutside
17478
17553
  });
17479
- pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw));
17554
+ if (parameters.pillpads) {
17555
+ pads.push(pillpad(i + 1, x, y, parameters.pl, parameters.pw));
17556
+ } else {
17557
+ pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw));
17558
+ }
17480
17559
  }
17481
17560
  const m = Math.min(1, parameters.p / 2);
17482
17561
  const sw = parameters.w - (parameters.legsoutside ? 0 : parameters.pl * 2) - 0.2;
@@ -18790,7 +18869,9 @@ var stampboard_def = z172.object({
18790
18869
  pw: length.default(length.parse("1.6mm")),
18791
18870
  pl: length.default(length.parse("2.4mm")),
18792
18871
  innerhole: z172.boolean().default(false),
18793
- innerholeedgedistance: length.default(length.parse("1.61mm"))
18872
+ innerholeedgedistance: length.default(length.parse("1.61mm")),
18873
+ silkscreenlabels: z172.boolean().default(false),
18874
+ silkscreenlabelmargin: length.default(length.parse("0.1mm"))
18794
18875
  });
18795
18876
  var getHeight = (parameters) => {
18796
18877
  const params = stampboard_def.parse(parameters);
@@ -18912,14 +18993,17 @@ var stampboard = (raw_params) => {
18912
18993
  const height10 = params.h ?? getHeight(params);
18913
18994
  const rectpads = [];
18914
18995
  const holes = [];
18996
+ const pinLabels = [];
18915
18997
  let routes = [];
18916
18998
  const innerDiameter = 1;
18917
- const outerDiameter = 1.2;
18999
+ const outerDiameter = innerDiameter;
18918
19000
  const totalPadsNumber = params.left + params.right + (params.bottom ?? 0) + (params.top ?? 0);
19001
+ const maxLabelLength = `pin${totalPadsNumber}`.length;
19002
+ const textHalf = maxLabelLength * 0.7 / 2;
18919
19003
  if (params.right) {
18920
19004
  const yoff = -((params.right - 1) / 2) * params.p;
18921
19005
  for (let i = 0; i < params.right; i++) {
18922
- if (i === 0 && !params.left && !params.bottom) {
19006
+ if (i === 0 && !params.left && !params.bottom && !params.silkscreenlabels) {
18923
19007
  routes = getTriangleDir(
18924
19008
  params.w / 2 - params.pl * 1.4,
18925
19009
  yoff + i * params.p,
@@ -18935,6 +19019,24 @@ var stampboard = (raw_params) => {
18935
19019
  params.pw
18936
19020
  )
18937
19021
  );
19022
+ if (params.silkscreenlabels) {
19023
+ const padIndex = i + 1 + params.left + (params.bottom ?? 0);
19024
+ const label = `pin${padIndex}`;
19025
+ pinLabels.push({
19026
+ type: "pcb_silkscreen_text",
19027
+ pcb_silkscreen_text_id: `pin_${padIndex}`,
19028
+ pcb_component_id: "1",
19029
+ layer: "top",
19030
+ anchor_position: {
19031
+ x: params.w / 2 - params.pl - (textHalf + params.silkscreenlabelmargin),
19032
+ y: yoff + i * params.p
19033
+ },
19034
+ text: label,
19035
+ font_size: 0.7,
19036
+ font: "tscircuit2024",
19037
+ anchor_alignment: "center"
19038
+ });
19039
+ }
18938
19040
  if (params.innerhole) {
18939
19041
  holes.push(
18940
19042
  platedhole(
@@ -18958,12 +19060,12 @@ var stampboard = (raw_params) => {
18958
19060
  }
18959
19061
  }
18960
19062
  if (params.left) {
18961
- const yoff = -((params.left - 1) / 2) * params.p;
19063
+ const yoff = (params.left - 1) / 2 * params.p;
18962
19064
  for (let i = 0; i < params.left; i++) {
18963
- if (i === params.left - 1) {
19065
+ if (i === 0 && !params.silkscreenlabels) {
18964
19066
  routes = getTriangleDir(
18965
19067
  -params.w / 2 + params.pl * 1.4,
18966
- yoff + i * params.p,
19068
+ yoff - i * params.p,
18967
19069
  "left"
18968
19070
  );
18969
19071
  }
@@ -18971,17 +19073,35 @@ var stampboard = (raw_params) => {
18971
19073
  rectpad(
18972
19074
  i + 1,
18973
19075
  -params.w / 2 + params.pl / 2,
18974
- yoff + i * params.p,
19076
+ yoff - i * params.p,
18975
19077
  params.pl,
18976
19078
  params.pw
18977
19079
  )
18978
19080
  );
19081
+ if (params.silkscreenlabels) {
19082
+ const padIndex = i + 1;
19083
+ const label = `pin${padIndex}`;
19084
+ pinLabels.push({
19085
+ type: "pcb_silkscreen_text",
19086
+ pcb_silkscreen_text_id: `pin_${padIndex}`,
19087
+ pcb_component_id: "1",
19088
+ layer: "top",
19089
+ anchor_position: {
19090
+ x: -params.w / 2 + params.pl + (textHalf + params.silkscreenlabelmargin),
19091
+ y: yoff - i * params.p
19092
+ },
19093
+ text: label,
19094
+ font_size: 0.7,
19095
+ font: "tscircuit2024",
19096
+ anchor_alignment: "center"
19097
+ });
19098
+ }
18979
19099
  if (params.innerhole) {
18980
19100
  holes.push(
18981
19101
  platedhole(
18982
19102
  i + 1 + totalPadsNumber,
18983
19103
  -params.w / 2,
18984
- yoff + i * params.p,
19104
+ yoff - i * params.p,
18985
19105
  innerDiameter,
18986
19106
  outerDiameter
18987
19107
  )
@@ -18990,7 +19110,7 @@ var stampboard = (raw_params) => {
18990
19110
  platedhole(
18991
19111
  i + 1 + totalPadsNumber * 2,
18992
19112
  -params.w / 2 + params.innerholeedgedistance,
18993
- yoff + i * params.p,
19113
+ yoff - i * params.p,
18994
19114
  innerDiameter,
18995
19115
  outerDiameter
18996
19116
  )
@@ -18999,11 +19119,11 @@ var stampboard = (raw_params) => {
18999
19119
  }
19000
19120
  }
19001
19121
  if (params.top) {
19002
- const xoff = -((params.top - 1) / 2) * params.p;
19122
+ const xoff = (params.top - 1) / 2 * params.p;
19003
19123
  for (let i = 0; i < params.top; i++) {
19004
- if (i === params.top - 1 && !params.left && !params.bottom && !params.right) {
19124
+ if (i === 0 && !params.left && !params.bottom && !params.right && !params.silkscreenlabels) {
19005
19125
  routes = getTriangleDir(
19006
- xoff + i * params.p,
19126
+ xoff - i * params.p,
19007
19127
  height10 / 2 - params.pl * 1.4,
19008
19128
  "top"
19009
19129
  );
@@ -19011,17 +19131,36 @@ var stampboard = (raw_params) => {
19011
19131
  rectpads.push(
19012
19132
  rectpad(
19013
19133
  i + 1 + params.left + params.right + (params.bottom ?? 0),
19014
- xoff + i * params.p,
19134
+ xoff - i * params.p,
19015
19135
  height10 / 2 - params.pl / 2,
19016
19136
  params.pw,
19017
19137
  params.pl
19018
19138
  )
19019
19139
  );
19140
+ if (params.silkscreenlabels) {
19141
+ const padIndex = i + 1 + params.left + params.right + (params.bottom ?? 0);
19142
+ const label = `pin${padIndex}`;
19143
+ pinLabels.push({
19144
+ type: "pcb_silkscreen_text",
19145
+ pcb_silkscreen_text_id: `pin_${padIndex}`,
19146
+ pcb_component_id: "1",
19147
+ layer: "top",
19148
+ anchor_position: {
19149
+ x: xoff - i * params.p,
19150
+ y: height10 / 2 - params.pl - (textHalf + params.silkscreenlabelmargin)
19151
+ },
19152
+ text: label,
19153
+ font_size: 0.7,
19154
+ font: "tscircuit2024",
19155
+ anchor_alignment: "center",
19156
+ ccw_rotation: 270
19157
+ });
19158
+ }
19020
19159
  if (params.innerhole) {
19021
19160
  holes.push(
19022
19161
  platedhole(
19023
19162
  i + 1 + params.left + params.right + (params.bottom ?? 0) + totalPadsNumber,
19024
- xoff + i * params.p,
19163
+ xoff - i * params.p,
19025
19164
  height10 / 2,
19026
19165
  innerDiameter,
19027
19166
  outerDiameter
@@ -19030,7 +19169,7 @@ var stampboard = (raw_params) => {
19030
19169
  holes.push(
19031
19170
  platedhole(
19032
19171
  i + 1 + params.left + params.right + (params.bottom ?? 0) + totalPadsNumber * 2,
19033
- xoff + i * params.p,
19172
+ xoff - i * params.p,
19034
19173
  height10 / 2 - params.innerholeedgedistance,
19035
19174
  innerDiameter,
19036
19175
  outerDiameter
@@ -19042,7 +19181,7 @@ var stampboard = (raw_params) => {
19042
19181
  if (params.bottom) {
19043
19182
  const xoff = -((params.bottom - 1) / 2) * params.p;
19044
19183
  for (let i = 0; i < params.bottom; i++) {
19045
- if (i === 0 && !params.left) {
19184
+ if (i === 0 && !params.left && !params.silkscreenlabels) {
19046
19185
  routes = getTriangleDir(
19047
19186
  xoff + i * params.p,
19048
19187
  -height10 / 2 + params.pl * 1.4,
@@ -19058,6 +19197,25 @@ var stampboard = (raw_params) => {
19058
19197
  params.pl
19059
19198
  )
19060
19199
  );
19200
+ if (params.silkscreenlabels) {
19201
+ const padIndex = i + 1 + params.left;
19202
+ const label = `pin${padIndex}`;
19203
+ pinLabels.push({
19204
+ type: "pcb_silkscreen_text",
19205
+ pcb_silkscreen_text_id: `pin_${padIndex}`,
19206
+ pcb_component_id: "1",
19207
+ layer: "top",
19208
+ anchor_position: {
19209
+ x: xoff + i * params.p,
19210
+ y: -height10 / 2 + params.pl + (textHalf + params.silkscreenlabelmargin)
19211
+ },
19212
+ text: label,
19213
+ font_size: 0.7,
19214
+ font: "tscircuit2024",
19215
+ anchor_alignment: "center",
19216
+ ccw_rotation: 90
19217
+ });
19218
+ }
19061
19219
  if (params.innerhole) {
19062
19220
  holes.push(
19063
19221
  platedhole(
@@ -19111,8 +19269,9 @@ var stampboard = (raw_params) => {
19111
19269
  circuitJson: [
19112
19270
  ...rectpads,
19113
19271
  ...holes,
19272
+ ...pinLabels,
19114
19273
  silkscreenPath,
19115
- silkscreenTriangle,
19274
+ ...params.silkscreenlabels ? [] : [silkscreenTriangle],
19116
19275
  silkscreenRefText
19117
19276
  ],
19118
19277
  parameters: params
@@ -22686,20 +22845,6 @@ var solderjumper = (params) => {
22686
22845
  parameters: params
22687
22846
  };
22688
22847
  };
22689
- var pillpad = (pn, x, y, w, h2) => {
22690
- return {
22691
- type: "pcb_smtpad",
22692
- x,
22693
- y,
22694
- width: w,
22695
- height: h2,
22696
- radius: h2 / 2,
22697
- layer: "top",
22698
- shape: "pill",
22699
- pcb_smtpad_id: "",
22700
- port_hints: Array.isArray(pn) ? pn.map((item) => item.toString()) : [pn.toString()]
22701
- };
22702
- };
22703
22848
  var commonSchema = {
22704
22849
  fn: z542.literal("sot457"),
22705
22850
  num_pins: z542.literal(6).default(6),
@@ -23222,6 +23367,7 @@ var smtpad_def = z592.object({
23222
23367
  circle: z592.boolean().optional(),
23223
23368
  rect: z592.boolean().optional(),
23224
23369
  square: z592.boolean().optional(),
23370
+ pill: z592.boolean().optional(),
23225
23371
  d: length.optional(),
23226
23372
  pd: length.optional(),
23227
23373
  diameter: length.optional(),
@@ -23242,6 +23388,7 @@ var smtpad_def = z592.object({
23242
23388
  if (v.circle) shape = "circle";
23243
23389
  if (v.square) shape = "square";
23244
23390
  if (v.rect) shape = "rect";
23391
+ if (v.pill) shape = "pill";
23245
23392
  let radius;
23246
23393
  let width10;
23247
23394
  let height10;
@@ -23263,7 +23410,10 @@ var smtpad_def = z592.object({
23263
23410
  if (v.h !== void 0) height10 = mm(v.h);
23264
23411
  else if (v.ph !== void 0) height10 = mm(v.ph);
23265
23412
  else if (v.height !== void 0) height10 = mm(v.height);
23266
- else height10 = width10;
23413
+ else if (shape === "square") height10 = width10;
23414
+ else if (shape === "rect")
23415
+ height10 = width10;
23416
+ else height10 = mm("1mm");
23267
23417
  }
23268
23418
  return {
23269
23419
  fn: v.fn,
@@ -23276,14 +23426,22 @@ var smtpad_def = z592.object({
23276
23426
  var smtpad = (raw_params) => {
23277
23427
  const params = smtpad_def.parse(raw_params);
23278
23428
  const { shape, radius, width: width10, height: height10 } = params;
23429
+ let pad2;
23430
+ let silkscreenOffset;
23431
+ if (shape === "circle") {
23432
+ pad2 = circlepad(1, { x: 0, y: 0, radius });
23433
+ silkscreenOffset = radius + 0.5;
23434
+ } else if (shape === "pill") {
23435
+ pad2 = pillpad(1, 0, 0, width10, height10);
23436
+ silkscreenOffset = Math.max(width10, height10) / 2 + 0.5;
23437
+ } else {
23438
+ pad2 = rectpad(1, 0, 0, width10, height10);
23439
+ silkscreenOffset = height10 / 2 + 0.5;
23440
+ }
23279
23441
  return {
23280
23442
  circuitJson: [
23281
- shape === "circle" ? circlepad(1, { x: 0, y: 0, radius }) : rectpad(1, 0, 0, width10, height10),
23282
- silkscreenRef(
23283
- 0,
23284
- shape === "circle" ? radius + 0.5 : height10 / 2 + 0.5,
23285
- 0.2
23286
- )
23443
+ pad2,
23444
+ silkscreenRef(0, silkscreenOffset, 0.2)
23287
23445
  ],
23288
23446
  parameters: params
23289
23447
  };
@@ -23464,10 +23622,12 @@ var m2host = (raw_params) => {
23464
23622
  const pn = i + 1;
23465
23623
  if (pn >= 24 && pn <= 31) continue;
23466
23624
  const y = startY - i * halfPitch;
23467
- const x = i % 2 === 0 ? 0 : -rowOffset / 2;
23468
- const padLengthWithOffset = padLength + (i % 2 === 0 ? 0 : 0.25);
23625
+ const isBottomLayer = pn % 2 === 0;
23626
+ const padLengthWithOffset = padLength + (isBottomLayer ? 0.25 : 0);
23627
+ const rightEdgeOffset = 0.5;
23628
+ const x = rightEdgeOffset - padLengthWithOffset / 2;
23469
23629
  const pad2 = rectpad(pn, x, y, padLengthWithOffset, padWidth);
23470
- pad2.layer = pn % 2 === 0 ? "bottom" : "top";
23630
+ pad2.layer = isBottomLayer ? "bottom" : "top";
23471
23631
  pads.push(pad2);
23472
23632
  }
23473
23633
  const cutoutWidth = 46 * 0.0254;
@@ -23548,7 +23708,7 @@ var m2host = (raw_params) => {
23548
23708
  };
23549
23709
  };
23550
23710
  function isNotNull(value) {
23551
- return value !== null;
23711
+ return value !== null && value !== void 0;
23552
23712
  }
23553
23713
  var applyOrigin = (elements, origin) => {
23554
23714
  if (!origin) return elements;
@@ -23621,12 +23781,22 @@ var applyOrigin = (elements, origin) => {
23621
23781
  break;
23622
23782
  }
23623
23783
  if (dx === 0 && dy === 0) return elements;
23624
- for (const pad2 of pads) {
23625
- pad2.x -= dx;
23626
- pad2.y -= dy;
23627
- if (pad2.center) {
23628
- pad2.center.x -= dx;
23629
- pad2.center.y -= dy;
23784
+ for (const el of elements) {
23785
+ if (typeof el.x === "number") el.x -= dx;
23786
+ if (typeof el.y === "number") el.y -= dy;
23787
+ if (el.center && typeof el.center.x === "number") {
23788
+ el.center.x -= dx;
23789
+ el.center.y -= dy;
23790
+ }
23791
+ if (el.type === "pcb_silkscreen_path") {
23792
+ for (const pt of el.route) {
23793
+ pt.x -= dx;
23794
+ pt.y -= dy;
23795
+ }
23796
+ }
23797
+ if (el.type === "pcb_silkscreen_text" && el.anchor_position) {
23798
+ el.anchor_position.x -= dx;
23799
+ el.anchor_position.y -= dy;
23630
23800
  }
23631
23801
  }
23632
23802
  return elements;
@@ -23636,8 +23806,9 @@ var string2 = (def) => {
23636
23806
  const modifiedDef = def.replace(/^((?:\d{4}|\d{5}))(?=$|_)/, "res$1");
23637
23807
  const def_parts = modifiedDef.split(/_(?!metric)/).map((s) => {
23638
23808
  const m = s.match(/([a-z]+)([\(\d\.\+\?].*)?/);
23639
- const [_, fn, v] = m ?? [];
23640
- if (v?.includes("?")) return null;
23809
+ if (!m) return null;
23810
+ const [, fn, v] = m;
23811
+ if (!fn || v?.includes("?")) return null;
23641
23812
  return { fn, v };
23642
23813
  }).filter(isNotNull);
23643
23814
  for (const { fn, v } of def_parts) {
@@ -23863,17 +24034,17 @@ var svgPathPoints = normalizeOnY([
23863
24034
  ]);
23864
24035
  var DIP_PIN_HEIGHT = 5.47;
23865
24036
  var heightAboveSurface = 0.5;
23866
- var DipPinLeg = ({ x, y, z: z103 }) => {
24037
+ var DipPinLeg = ({ x, y, z: z105 }) => {
23867
24038
  const isRotated = x > 0;
23868
24039
  return /* @__PURE__ */ jsxs(Fragment22, { children: [
23869
- /* @__PURE__ */ jsx5(Translate, { offset: { x: x + 0.25 / 2, y, z: z103 }, children: /* @__PURE__ */ jsx5(Rotate, { rotation: ["-90deg", 0, "90deg"], children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: 0.25, children: /* @__PURE__ */ jsx5(Polygon, { points: svgPathPoints.map((p) => [p.x, p.y]) }) }) }) }),
24040
+ /* @__PURE__ */ jsx5(Translate, { offset: { x: x + 0.25 / 2, y, z: z105 }, children: /* @__PURE__ */ jsx5(Rotate, { rotation: ["-90deg", 0, "90deg"], children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: 0.25, children: /* @__PURE__ */ jsx5(Polygon, { points: svgPathPoints.map((p) => [p.x, p.y]) }) }) }) }),
23870
24041
  /* @__PURE__ */ jsx5(
23871
24042
  Translate,
23872
24043
  {
23873
24044
  offset: {
23874
24045
  x,
23875
24046
  y: y + (isRotated ? 1 : -1),
23876
- z: z103
24047
+ z: z105
23877
24048
  },
23878
24049
  children: /* @__PURE__ */ jsx5(Rotate, { rotation: ["-90deg", "90deg", isRotated ? "180deg" : "0deg"], children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: 2, children: /* @__PURE__ */ jsx5(
23879
24050
  Polygon,
@@ -25808,7 +25979,7 @@ import * as THREE11 from "three";
25808
25979
  // package.json
25809
25980
  var package_default = {
25810
25981
  name: "@tscircuit/3d-viewer",
25811
- version: "0.0.371",
25982
+ version: "0.0.373",
25812
25983
  main: "./dist/index.js",
25813
25984
  module: "./dist/index.js",
25814
25985
  type: "module",
@@ -25853,9 +26024,9 @@ var package_default = {
25853
26024
  "@chromatic-com/storybook": "^1.9.0",
25854
26025
  "@jscad/modeling": "^2.12.5",
25855
26026
  "@storybook/blocks": "9.0.0-alpha.17",
25856
- "@storybook/react-vite": "^9.1.2",
26027
+ "@storybook/react-vite": "^9.1.5",
25857
26028
  "@tscircuit/circuit-json-util": "^0.0.67",
25858
- "@tscircuit/core": "^0.0.691",
26029
+ "@tscircuit/core": "^0.0.714",
25859
26030
  "@tscircuit/props": "^0.0.312",
25860
26031
  "@types/jsdom": "^21.1.7",
25861
26032
  "@types/react": "19",
@@ -25864,7 +26035,7 @@ var package_default = {
25864
26035
  "@vitejs/plugin-react": "^4.3.4",
25865
26036
  "bun-match-svg": "^0.0.9",
25866
26037
  "bun-types": "1.2.1",
25867
- "circuit-json": "0.0.246",
26038
+ "circuit-json": "0.0.248",
25868
26039
  "circuit-to-svg": "^0.0.179",
25869
26040
  debug: "^4.4.0",
25870
26041
  "jscad-electronics": "^0.0.38",
@@ -25874,10 +26045,10 @@ var package_default = {
25874
26045
  "react-use-gesture": "^9.1.3",
25875
26046
  semver: "^7.7.0",
25876
26047
  "strip-ansi": "^7.1.0",
25877
- tscircuit: "^0.0.622",
26048
+ tscircuit: "^0.0.630",
25878
26049
  tsup: "^8.3.6",
25879
26050
  typescript: "^5.7.3",
25880
- vite: "^7.1.2",
26051
+ vite: "^7.1.5",
25881
26052
  "vite-tsconfig-paths": "^4.3.2"
25882
26053
  }
25883
26054
  };
@@ -29895,7 +30066,6 @@ import * as THREE25 from "three";
29895
30066
  import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader.js";
29896
30067
  import { OBJLoader as OBJLoader2 } from "three/examples/jsm/loaders/OBJLoader.js";
29897
30068
  import { STLLoader as STLLoader2 } from "three/examples/jsm/loaders/STLLoader.js";
29898
- import { VRMLLoader as VRMLLoader2 } from "three/examples/jsm/loaders/VRMLLoader.js";
29899
30069
  async function load3DModel(url) {
29900
30070
  if (url.endsWith(".stl")) {
29901
30071
  const loader = new STLLoader2();
@@ -29912,8 +30082,7 @@ async function load3DModel(url) {
29912
30082
  return await loader.loadAsync(url);
29913
30083
  }
29914
30084
  if (url.endsWith(".wrl")) {
29915
- const loader = new VRMLLoader2();
29916
- return await loader.loadAsync(url);
30085
+ return await loadVrml(url);
29917
30086
  }
29918
30087
  if (url.endsWith(".gltf") || url.endsWith(".glb")) {
29919
30088
  const loader = new GLTFLoader2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.372",
3
+ "version": "0.0.374",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -45,9 +45,9 @@
45
45
  "@chromatic-com/storybook": "^1.9.0",
46
46
  "@jscad/modeling": "^2.12.5",
47
47
  "@storybook/blocks": "9.0.0-alpha.17",
48
- "@storybook/react-vite": "^9.1.2",
48
+ "@storybook/react-vite": "^9.1.5",
49
49
  "@tscircuit/circuit-json-util": "^0.0.67",
50
- "@tscircuit/core": "^0.0.691",
50
+ "@tscircuit/core": "^0.0.714",
51
51
  "@tscircuit/props": "^0.0.312",
52
52
  "@types/jsdom": "^21.1.7",
53
53
  "@types/react": "19",
@@ -56,7 +56,7 @@
56
56
  "@vitejs/plugin-react": "^4.3.4",
57
57
  "bun-match-svg": "^0.0.9",
58
58
  "bun-types": "1.2.1",
59
- "circuit-json": "0.0.246",
59
+ "circuit-json": "0.0.248",
60
60
  "circuit-to-svg": "^0.0.179",
61
61
  "debug": "^4.4.0",
62
62
  "jscad-electronics": "^0.0.38",
@@ -66,10 +66,10 @@
66
66
  "react-use-gesture": "^9.1.3",
67
67
  "semver": "^7.7.0",
68
68
  "strip-ansi": "^7.1.0",
69
- "tscircuit": "^0.0.622",
69
+ "tscircuit": "^0.0.630",
70
70
  "tsup": "^8.3.6",
71
71
  "typescript": "^5.7.3",
72
- "vite": "^7.1.2",
72
+ "vite": "^7.1.5",
73
73
  "vite-tsconfig-paths": "^4.3.2"
74
74
  }
75
75
  }