jscad-electronics 0.0.3 → 0.0.4

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 +126 -76
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -77303,6 +77303,7 @@ var require_dist = __commonJS({
77303
77303
  Cylinder: () => Cylinder2,
77304
77304
  CylinderElliptic: () => CylinderElliptic,
77305
77305
  Ellipsoid: () => Ellipsoid,
77306
+ ExtrudeFromSlices: () => ExtrudeFromSlices,
77306
77307
  ExtrudeHelical: () => ExtrudeHelical,
77307
77308
  ExtrudeLinear: () => ExtrudeLinear3,
77308
77309
  ExtrudeRectangular: () => ExtrudeRectangular,
@@ -77325,6 +77326,7 @@ var require_dist = __commonJS({
77325
77326
  convertCSGToThreeGeom: () => convertCSGToThreeGeom,
77326
77327
  createJSCADRenderer: () => createJSCADRenderer,
77327
77328
  normalizePointToArray: () => normalizePointToArray,
77329
+ processRotation: () => processRotation,
77328
77330
  useRenderElementsToJscadPlan: () => useRenderElementsToJscadPlan
77329
77331
  });
77330
77332
  module.exports = __toCommonJS2(lib_exports);
@@ -77471,6 +77473,14 @@ var require_dist = __commonJS({
77471
77473
  );
77472
77474
  return extrudedGeometry;
77473
77475
  }
77476
+ case "extrudeFromSlices": {
77477
+ const { baseSlice, ...extrudeProps } = props;
77478
+ const extrudedGeometry = jscad3.extrusions.extrudeFromSlices(
77479
+ extrudeProps,
77480
+ baseSlice
77481
+ );
77482
+ return extrudedGeometry;
77483
+ }
77474
77484
  case "project": {
77475
77485
  const { children, ...projectProps } = props;
77476
77486
  const childrenGeometry = renderChildren(children);
@@ -77720,11 +77730,60 @@ var require_dist = __commonJS({
77720
77730
  return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("custom", { geometry });
77721
77731
  }
77722
77732
  var import_jsx_runtime92 = require_jsx_runtime();
77723
- var CylinderBase = ({ radius, height: height4 }) => {
77724
- return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("cylinder", { radius, height: height4 });
77733
+ var convertToRadians = (value) => {
77734
+ if (typeof value === "string") {
77735
+ const numericValue = value.replace(/[^\d.-]/g, "");
77736
+ const parsedValue = parseFloat(numericValue);
77737
+ if (!isNaN(parsedValue)) {
77738
+ if (value.toLowerCase().includes("deg")) {
77739
+ return parsedValue * Math.PI / 180;
77740
+ }
77741
+ return parsedValue;
77742
+ }
77743
+ throw new Error(`Invalid rotation value: ${value}`);
77744
+ }
77745
+ return value;
77746
+ };
77747
+ var processRotation = (value) => {
77748
+ if (typeof value === "string" || typeof value === "number") {
77749
+ const angle = convertToRadians(value);
77750
+ return [0, 0, angle];
77751
+ } else if (Array.isArray(value)) {
77752
+ return value.map(convertToRadians);
77753
+ } else if (value && typeof value === "object") {
77754
+ return [
77755
+ convertToRadians(value.x),
77756
+ convertToRadians(value.y),
77757
+ convertToRadians(value.z)
77758
+ ];
77759
+ }
77760
+ return [0, 0, 0];
77761
+ };
77762
+ var RotateBase = ({ rotation, angles, children }) => {
77763
+ const finalRotation = rotation ? processRotation(rotation) : processRotation(angles);
77764
+ return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("rotate", { angles: finalRotation, children });
77725
77765
  };
77726
- var Cylinder2 = withOffsetProp(withColorProp(CylinderBase));
77766
+ var Rotate6 = withOffsetProp(withColorProp(RotateBase));
77727
77767
  var import_jsx_runtime102 = require_jsx_runtime();
77768
+ function withRotationProp(WrappedComponent) {
77769
+ const WithRotation = (props) => {
77770
+ const { rotation, ...restProps } = props;
77771
+ if (!rotation) {
77772
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(WrappedComponent, { ...restProps });
77773
+ }
77774
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Rotate6, { rotation, children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(WrappedComponent, { ...restProps }) });
77775
+ };
77776
+ WithRotation.displayName = `WithRotation(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
77777
+ return WithRotation;
77778
+ }
77779
+ var import_jsx_runtime112 = require_jsx_runtime();
77780
+ var CylinderBase = ({ radius, height: height4 }) => {
77781
+ return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("cylinder", { radius, height: height4 });
77782
+ };
77783
+ var Cylinder2 = withColorProp(
77784
+ withOffsetProp(withRotationProp(CylinderBase))
77785
+ );
77786
+ var import_jsx_runtime122 = require_jsx_runtime();
77728
77787
  var CylinderEllipticBase = ({
77729
77788
  height: height4,
77730
77789
  startRadius,
@@ -77733,7 +77792,7 @@ var require_dist = __commonJS({
77733
77792
  startAngle = 0,
77734
77793
  endAngle = Math.PI * 2
77735
77794
  }) => {
77736
- return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
77795
+ return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
77737
77796
  "cylinderElliptic",
77738
77797
  {
77739
77798
  height: height4,
@@ -77748,12 +77807,12 @@ var require_dist = __commonJS({
77748
77807
  var CylinderElliptic = withOffsetProp(
77749
77808
  withColorProp(CylinderEllipticBase)
77750
77809
  );
77751
- var import_jsx_runtime112 = require_jsx_runtime();
77810
+ var import_jsx_runtime132 = require_jsx_runtime();
77752
77811
  var EllipsoidBase = ({ radius }) => {
77753
- return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("ellipsoid", { radius });
77812
+ return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("ellipsoid", { radius });
77754
77813
  };
77755
77814
  var Ellipsoid = withOffsetProp(withColorProp(EllipsoidBase));
77756
- var import_jsx_runtime122 = require_jsx_runtime();
77815
+ var import_jsx_runtime142 = require_jsx_runtime();
77757
77816
  var ExtrudeHelicalBase = ({
77758
77817
  height: height4,
77759
77818
  angle,
@@ -77763,7 +77822,7 @@ var require_dist = __commonJS({
77763
77822
  segmetsPerRotation,
77764
77823
  children
77765
77824
  }) => {
77766
- return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
77825
+ return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
77767
77826
  "extrudeHelical",
77768
77827
  {
77769
77828
  height: height4,
@@ -77777,14 +77836,14 @@ var require_dist = __commonJS({
77777
77836
  );
77778
77837
  };
77779
77838
  var ExtrudeHelical = withOffsetProp(withColorProp(ExtrudeHelicalBase));
77780
- var import_jsx_runtime132 = require_jsx_runtime();
77839
+ var import_jsx_runtime152 = require_jsx_runtime();
77781
77840
  var ExtrudeLinearBase = ({
77782
77841
  height: height4,
77783
77842
  twistAngle,
77784
77843
  twistSteps,
77785
77844
  children
77786
77845
  }) => {
77787
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
77846
+ return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
77788
77847
  "extrudeLinear",
77789
77848
  {
77790
77849
  height: height4,
@@ -77795,101 +77854,66 @@ var require_dist = __commonJS({
77795
77854
  );
77796
77855
  };
77797
77856
  var ExtrudeLinear3 = withOffsetProp(withColorProp(ExtrudeLinearBase));
77798
- var import_jsx_runtime142 = require_jsx_runtime();
77857
+ var import_jsx_runtime162 = require_jsx_runtime();
77799
77858
  var ExtrudeRectangularBase = ({
77800
77859
  size,
77801
77860
  height: height4,
77802
77861
  children
77803
77862
  }) => {
77804
- return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("extrudeRectangular", { size, height: height4, children });
77863
+ return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("extrudeRectangular", { size, height: height4, children });
77805
77864
  };
77806
77865
  var ExtrudeRectangular = withOffsetProp(
77807
77866
  withColorProp(ExtrudeRectangularBase)
77808
77867
  );
77809
- var import_jsx_runtime152 = require_jsx_runtime();
77868
+ var import_jsx_runtime172 = require_jsx_runtime();
77810
77869
  var ExtrudeRotateBase = ({
77811
77870
  angle,
77812
77871
  startAngle,
77813
77872
  segments,
77814
77873
  children
77815
77874
  }) => {
77816
- return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("extrudeRotate", { angle, startAngle, segments, children });
77875
+ return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("extrudeRotate", { angle, startAngle, segments, children });
77817
77876
  };
77818
77877
  var ExtrudeRotate = withOffsetProp(withColorProp(ExtrudeRotateBase));
77819
- var import_jsx_runtime162 = require_jsx_runtime();
77878
+ var import_jsx_runtime182 = require_jsx_runtime();
77820
77879
  var GeodesicSphereBase = ({ radius, frequency }) => {
77821
- return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("geodesicSphere", { radius, frequency });
77880
+ return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("geodesicSphere", { radius, frequency });
77822
77881
  };
77823
77882
  var GeodesicSphere = withOffsetProp(withColorProp(GeodesicSphereBase));
77824
- var import_jsx_runtime172 = require_jsx_runtime();
77883
+ var import_jsx_runtime192 = require_jsx_runtime();
77825
77884
  var HullBase = ({ children }) => {
77826
- return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("hull", { children });
77885
+ return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)("hull", { children });
77827
77886
  };
77828
77887
  var Hull = withOffsetProp(withColorProp(HullBase));
77829
- var import_jsx_runtime182 = require_jsx_runtime();
77888
+ var import_jsx_runtime20 = require_jsx_runtime();
77830
77889
  var HullChainBase = ({ children }) => {
77831
- return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("hullChain", { children });
77890
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("hullChain", { children });
77832
77891
  };
77833
77892
  var HullChain = withOffsetProp(withColorProp(HullChainBase));
77834
- var import_jsx_runtime192 = require_jsx_runtime();
77893
+ var import_jsx_runtime21 = require_jsx_runtime();
77835
77894
  function Polygon3({ points }) {
77836
- return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)("jscadPolygon", { points });
77895
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("jscadPolygon", { points });
77837
77896
  }
77838
- var import_jsx_runtime20 = require_jsx_runtime();
77897
+ var import_jsx_runtime222 = require_jsx_runtime();
77839
77898
  function Project({ axis, origin, children }) {
77840
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("project", { axis, origin, children });
77899
+ return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)("project", { axis, origin, children });
77841
77900
  }
77842
- var import_jsx_runtime21 = require_jsx_runtime();
77901
+ var import_jsx_runtime23 = require_jsx_runtime();
77843
77902
  function Rectangle({ size }) {
77844
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rectangle", { size });
77903
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("rectangle", { size });
77845
77904
  }
77846
- var import_jsx_runtime222 = require_jsx_runtime();
77847
- var convertToRadians = (value) => {
77848
- if (typeof value === "string") {
77849
- const numericValue = value.replace(/[^\d.-]/g, "");
77850
- const parsedValue = parseFloat(numericValue);
77851
- if (!isNaN(parsedValue)) {
77852
- if (value.toLowerCase().includes("deg")) {
77853
- return parsedValue * Math.PI / 180;
77854
- }
77855
- return parsedValue;
77856
- }
77857
- throw new Error(`Invalid rotation value: ${value}`);
77858
- }
77859
- return value;
77860
- };
77861
- var RotateBase = ({ rotation, angles, children }) => {
77862
- const processRotation = (value) => {
77863
- if (typeof value === "string" || typeof value === "number") {
77864
- const angle = convertToRadians(value);
77865
- return [0, 0, angle];
77866
- } else if (Array.isArray(value)) {
77867
- return value.map(convertToRadians);
77868
- } else if (value && typeof value === "object") {
77869
- return [
77870
- convertToRadians(value.x),
77871
- convertToRadians(value.y),
77872
- convertToRadians(value.z)
77873
- ];
77874
- }
77875
- return [0, 0, 0];
77876
- };
77877
- const finalRotation = rotation ? processRotation(rotation) : processRotation(angles);
77878
- return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)("rotate", { angles: finalRotation, children });
77879
- };
77880
- var Rotate6 = withOffsetProp(withColorProp(RotateBase));
77881
- var import_jsx_runtime23 = require_jsx_runtime();
77905
+ var import_jsx_runtime24 = require_jsx_runtime();
77882
77906
  var RoundedCuboidBase = ({ size, roundRadius }) => {
77883
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("roundedCuboid", { size, roundRadius });
77907
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("roundedCuboid", { size, roundRadius });
77884
77908
  };
77885
77909
  var RoundedCuboid2 = withOffsetProp(withColorProp(RoundedCuboidBase));
77886
- var import_jsx_runtime24 = require_jsx_runtime();
77910
+ var import_jsx_runtime25 = require_jsx_runtime();
77887
77911
  var RoundedCylinderBase = ({
77888
77912
  radius,
77889
77913
  height: height4,
77890
77914
  roundRadius
77891
77915
  }) => {
77892
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
77916
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
77893
77917
  "roundedCylinder",
77894
77918
  {
77895
77919
  radius,
@@ -77901,12 +77925,12 @@ var require_dist = __commonJS({
77901
77925
  var RoundedCylinder = withOffsetProp(
77902
77926
  withColorProp(RoundedCylinderBase)
77903
77927
  );
77904
- var import_jsx_runtime25 = require_jsx_runtime();
77928
+ var import_jsx_runtime26 = require_jsx_runtime();
77905
77929
  var SphereBase = ({ radius, segments }) => {
77906
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("sphere", { radius, segments: segments || 32 });
77930
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("sphere", { radius, segments: segments || 32 });
77907
77931
  };
77908
- var Sphere2 = withColorProp(SphereBase);
77909
- var import_jsx_runtime26 = require_jsx_runtime();
77932
+ var Sphere2 = withColorProp(withOffsetProp(SphereBase));
77933
+ var import_jsx_runtime27 = require_jsx_runtime();
77910
77934
  var TorusBase = ({
77911
77935
  innerRadius,
77912
77936
  outerRadius,
@@ -77916,7 +77940,7 @@ var require_dist = __commonJS({
77916
77940
  outerRotation = 1,
77917
77941
  startAngle = 0
77918
77942
  }) => {
77919
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
77943
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
77920
77944
  "torus",
77921
77945
  {
77922
77946
  innerRadius,
@@ -77930,10 +77954,36 @@ var require_dist = __commonJS({
77930
77954
  );
77931
77955
  };
77932
77956
  var Torus = withOffsetProp(withColorProp(TorusBase));
77933
- var import_jsx_runtime27 = require_jsx_runtime();
77957
+ var import_jsx_runtime28 = require_jsx_runtime();
77934
77958
  function Union3({ children }) {
77935
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("union", { children });
77959
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("union", { children });
77936
77960
  }
77961
+ var import_jsx_runtime29 = require_jsx_runtime();
77962
+ var ExtrudeFromSlicesBase = ({
77963
+ numberOfSlices,
77964
+ capStart,
77965
+ capEnd,
77966
+ close,
77967
+ repair,
77968
+ baseSlice,
77969
+ callback
77970
+ }) => {
77971
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
77972
+ "extrudeFromSlices",
77973
+ {
77974
+ numberOfSlices,
77975
+ capStart,
77976
+ capEnd,
77977
+ close,
77978
+ repair,
77979
+ baseSlice,
77980
+ callback
77981
+ }
77982
+ );
77983
+ };
77984
+ var ExtrudeFromSlices = withOffsetProp(
77985
+ withColorProp(ExtrudeFromSlicesBase)
77986
+ );
77937
77987
  var jscad = __toESM2(require_src(), 1);
77938
77988
  var import_react2 = __toESM2(require_react(), 1);
77939
77989
  var THREE = __toESM2(require_three(), 1);
@@ -78016,7 +78066,7 @@ var require_dist = __commonJS({
78016
78066
  return new import_three2.BufferGeometry();
78017
78067
  }
78018
78068
  var convert_csg_to_three_geom_default = convertCSGToThreeGeom;
78019
- var import_jsx_runtime28 = require_jsx_runtime();
78069
+ var import_jsx_runtime30 = require_jsx_runtime();
78020
78070
  var { createJSCADRoot } = createJSCADRenderer(jscad);
78021
78071
  function JsCadFixture({
78022
78072
  children,
@@ -78111,7 +78161,7 @@ var require_dist = __commonJS({
78111
78161
  gridRef.current.visible = showGrid;
78112
78162
  }
78113
78163
  }, [showGrid]);
78114
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ref: containerRef, style: { width: "100%", minHeight: "400px" } });
78164
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { ref: containerRef, style: { width: "100%", minHeight: "400px" } });
78115
78165
  }
78116
78166
  var jscad2 = __toESM2(require_src(), 1);
78117
78167
  var import_react22 = require_react();
@@ -78163,7 +78213,7 @@ var require_dist = __commonJS({
78163
78213
  }, [children, root, container]);
78164
78214
  return mesh;
78165
78215
  }
78166
- var import_jsx_runtime29 = require_jsx_runtime();
78216
+ var import_jsx_runtime31 = require_jsx_runtime();
78167
78217
  function JSCadThreeMesh({
78168
78218
  children
78169
78219
  }) {
@@ -78171,7 +78221,7 @@ var require_dist = __commonJS({
78171
78221
  if (!mesh) {
78172
78222
  return null;
78173
78223
  }
78174
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("primitive", { object: mesh });
78224
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("primitive", { object: mesh });
78175
78225
  }
78176
78226
  var import_react3 = __toESM2(require_react(), 1);
78177
78227
  var useRenderElementsToJscadPlan = (jscad3, children) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jscad-electronics",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "main": "./dist/index.js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "@tscircuit/soup": "^0.0.41",
24
24
  "@types/react": "^18.3.10",
25
25
  "@types/react-dom": "^18.3.0",
26
- "jscad-fiber": "^0.0.64",
26
+ "jscad-fiber": "^0.0.67",
27
27
  "react": "^18.3.1",
28
28
  "react-cosmos": "^6.1.1",
29
29
  "react-cosmos-plugin-vite": "^6.1.1",
@@ -33,6 +33,6 @@
33
33
  "vite-tsconfig-paths": "^5.0.1"
34
34
  },
35
35
  "dependencies": {
36
- "@tscircuit/footprinter": "^0.0.63"
36
+ "@tscircuit/footprinter": "^0.0.64"
37
37
  }
38
38
  }