geometrix 0.5.23 → 0.5.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -445,7 +445,8 @@ declare function copyLayers(iLayers: tLayers): tLayers;
445
445
  declare enum PType {
446
446
  eNumber = 0,
447
447
  eCheckbox = 1,
448
- eDropdown = 2
448
+ eDropdown = 2,
449
+ eSectionSeparator = 3
449
450
  }
450
451
  interface tParam {
451
452
  name: string;
@@ -468,6 +469,7 @@ interface tParamDef {
468
469
  paramSvg: Record<string, string>;
469
470
  sim: tSimTime;
470
471
  }
472
+ declare const zeroPDef: tParamDef;
471
473
  type tParamVal = Record<string, number>;
472
474
  type tParamChanged = Record<string, boolean>;
473
475
  interface tDesignParamOne {
@@ -503,6 +505,7 @@ declare function designParam(iparamDef: tParamDef, suffix?: string): DesignParam
503
505
  declare function pNumber(name: string, unit: string, init: number, min?: number, max?: number, step?: number): tParam;
504
506
  declare function pCheckbox(name: string, init: boolean): tParam;
505
507
  declare function pDropdown(name: string, values: string[]): tParam;
508
+ declare function pSectionSeparator(name: string): tParam;
506
509
 
507
510
  type tPosiOrien = [number, number, number];
508
511
  interface tSubInst {
@@ -581,18 +584,19 @@ declare enum EFormat {
581
584
  eJSCAD = 6,
582
585
  eZIP = 7
583
586
  }
584
- declare function fileTextContent(fgeom: tGeomFunc, paramVal: tParamVal, eFace: string, exportFormat: EFormat): string;
585
- declare function fileBinContent(fgeom: tGeomFunc, tSim: number, paramVal: tParamVal, exportFormat: EFormat): Promise<Blob>;
587
+ declare function fileTextContent(fgeom: tGeomFunc, paramVal: tParamVal, ipDef: tParamDef, eFace: string, exportFormat: EFormat): string;
588
+ declare function fileBinContent(fgeom: tGeomFunc, tSim: number, paramVal: tParamVal, ipDef: tParamDef, exportFormat: EFormat): Promise<Blob>;
586
589
  declare function fileMime(exportFormat: EFormat): string;
587
590
  declare function fileSuffix(exportFormat: EFormat): string;
588
591
  declare function fileBin(exportFormat: EFormat): boolean;
589
592
 
590
593
  interface tParamValInFile {
591
594
  lastModif: string;
595
+ partName: string;
592
596
  pVal: tParamVal;
593
597
  comment: string;
594
598
  }
595
- declare function createParamFile(lastModif: string, idparams: tParamVal, comment: string): string;
599
+ declare function createParamFile(lastModif: string, iPartName: string, idparams: tParamVal, comment: string): string;
596
600
  declare function parseParamFile(fContentStr: string): [tParamValInFile, string];
597
601
 
598
602
  /** For cli-app and ui-app */
@@ -608,4 +612,4 @@ declare function version_details(appPackage: tPackage): string[];
608
612
 
609
613
  declare function checkImpPages(pages: tAllPageDef): [boolean, string];
610
614
 
611
- export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFaces, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tVolume, tolerance, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi };
615
+ export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFaces, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tVolume, tolerance, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
package/dist/index.js CHANGED
@@ -2737,8 +2737,19 @@ var PType = /* @__PURE__ */ ((PType2) => {
2737
2737
  PType2[PType2["eNumber"] = 0] = "eNumber";
2738
2738
  PType2[PType2["eCheckbox"] = 1] = "eCheckbox";
2739
2739
  PType2[PType2["eDropdown"] = 2] = "eDropdown";
2740
+ PType2[PType2["eSectionSeparator"] = 3] = "eSectionSeparator";
2740
2741
  return PType2;
2741
2742
  })(PType || {});
2743
+ var zeroPDef = {
2744
+ partName: "",
2745
+ params: [],
2746
+ paramSvg: {},
2747
+ sim: {
2748
+ tMax: 0,
2749
+ tStep: 0,
2750
+ tUpdate: 0
2751
+ }
2752
+ };
2742
2753
  function oneDesignParam(iVal, iInit, iChg) {
2743
2754
  const oneDP = { val: iVal, init: iInit, chg: iChg };
2744
2755
  return oneDP;
@@ -2878,6 +2889,19 @@ function pDropdown(name, values) {
2878
2889
  };
2879
2890
  return rParam;
2880
2891
  }
2892
+ function pSectionSeparator(name) {
2893
+ const rParam = {
2894
+ name,
2895
+ unit: "section-separator",
2896
+ init: 0,
2897
+ min: 0,
2898
+ max: 0,
2899
+ step: 0,
2900
+ dropdown: [],
2901
+ pType: 3 /* eSectionSeparator */
2902
+ };
2903
+ return rParam;
2904
+ }
2881
2905
 
2882
2906
  // src/volume.ts
2883
2907
  var EExtrude = /* @__PURE__ */ ((EExtrude2) => {
@@ -2945,9 +2969,10 @@ var PaxWrite = class {
2945
2969
  }
2946
2970
  return figFaces;
2947
2971
  }
2948
- getPaxJson(paramVal, geome0) {
2972
+ getPaxJson(paramVal, geome0, ipDef) {
2949
2973
  const rPaxJson = {
2950
2974
  partName: geome0.partName,
2975
+ pDef: ipDef,
2951
2976
  params: paramVal,
2952
2977
  faces: this.getFigures(geome0.fig),
2953
2978
  volume: geome0.vol,
@@ -2956,8 +2981,8 @@ var PaxWrite = class {
2956
2981
  };
2957
2982
  return rPaxJson;
2958
2983
  }
2959
- getPaxStr(paramVal, geome0) {
2960
- const paxJson = this.getPaxJson(paramVal, geome0);
2984
+ getPaxStr(paramVal, geome0, ipDef) {
2985
+ const paxJson = this.getPaxJson(paramVal, geome0, ipDef);
2961
2986
  const rStr = JSON.stringify(paxJson, null, 2);
2962
2987
  return rStr;
2963
2988
  }
@@ -3254,7 +3279,7 @@ module ${inherit.outName} () {
3254
3279
  if (vol.inherits !== void 0) {
3255
3280
  const subGeoms = this.getAllSubGeoms(vol.inherits);
3256
3281
  for (const oneGeom of subGeoms) {
3257
- const paxJson = paxWrite().getPaxJson({}, oneGeom);
3282
+ const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
3258
3283
  rStr += this.getAllFigures(paxJson.faces, paxJson.partName);
3259
3284
  rStr += this.getVolume(oneGeom.vol);
3260
3285
  }
@@ -3503,7 +3528,7 @@ const ${inherit.outName} =
3503
3528
  if (vol.inherits !== void 0) {
3504
3529
  const subGeoms = this.getAllSubGeoms(vol.inherits);
3505
3530
  for (const oneGeom of subGeoms) {
3506
- const paxJson = paxWrite().getPaxJson({}, oneGeom);
3531
+ const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
3507
3532
  rStr += this.getAllFigures(paxJson.faces, paxJson.partName);
3508
3533
  rStr += this.getVolume(oneGeom.vol);
3509
3534
  }
@@ -3650,21 +3675,21 @@ function figureToDxf(aCtr) {
3650
3675
  const rDxf = dxf.stringify();
3651
3676
  return rDxf;
3652
3677
  }
3653
- function makePax(paramVal, geome0) {
3654
- const rStr = paxWrite().getPaxStr(paramVal, geome0);
3678
+ function makePax(paramVal, geome0, ipDef) {
3679
+ const rStr = paxWrite().getPaxStr(paramVal, geome0, ipDef);
3655
3680
  return rStr;
3656
3681
  }
3657
3682
  function makeOpenscad(geome0) {
3658
- const paxJson = paxWrite().getPaxJson({}, geome0);
3683
+ const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
3659
3684
  const rStr = oscadWrite().getExportFile(paxJson);
3660
3685
  return rStr;
3661
3686
  }
3662
3687
  function makeOpenjscad(geome0) {
3663
- const paxJson = paxWrite().getPaxJson({}, geome0);
3688
+ const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
3664
3689
  const rStr = ojscadWrite().getExportFile(paxJson);
3665
3690
  return rStr;
3666
3691
  }
3667
- async function makeZip(paramVal, geome0, tSim, geome1) {
3692
+ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
3668
3693
  const zipFileWriter = new zip.BlobWriter("application/zip");
3669
3694
  const zipWriter = new zip.ZipWriter(zipFileWriter);
3670
3695
  const partName = geome0.partName;
@@ -3693,7 +3718,7 @@ async function makeZip(paramVal, geome0, tSim, geome1) {
3693
3718
  await zipWriter.add(`deco_${partName}_all_merged.svg`, svgMergedDeco);
3694
3719
  const svgMergedDecoT = new zip.TextReader(figureToSvgDeco(mergedFace));
3695
3720
  await zipWriter.add(`deco_${partName}_all_merged_t${tSim}.svg`, svgMergedDecoT);
3696
- const zPax = new zip.TextReader(makePax(paramVal, geome0));
3721
+ const zPax = new zip.TextReader(makePax(paramVal, geome0, ipDef));
3697
3722
  await zipWriter.add(`${partName}.pax.json`, zPax);
3698
3723
  const zSCad = new zip.TextReader(makeOpenscad(geome0));
3699
3724
  await zipWriter.add(`${partName}_noarc_openscad.scad`, zSCad);
@@ -3716,7 +3741,7 @@ var EFormat = /* @__PURE__ */ ((EFormat2) => {
3716
3741
  EFormat2[EFormat2["eZIP"] = 7] = "eZIP";
3717
3742
  return EFormat2;
3718
3743
  })(EFormat || {});
3719
- function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3744
+ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
3720
3745
  const geome0 = fgeom(0, paramVal);
3721
3746
  let rFileContent = "";
3722
3747
  if (!geome0.calcErr) {
@@ -3742,7 +3767,7 @@ function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3742
3767
  const figu = mergeFaces(geome0.fig);
3743
3768
  rFileContent = figureToDxf(figu.mainList);
3744
3769
  } else if (exportFormat === 4 /* ePAX */) {
3745
- rFileContent = makePax(paramVal, geome0);
3770
+ rFileContent = makePax(paramVal, geome0, ipDef);
3746
3771
  } else if (exportFormat === 5 /* eOPENSCAD */) {
3747
3772
  rFileContent = makeOpenscad(geome0);
3748
3773
  } else if (exportFormat === 6 /* eJSCAD */) {
@@ -3755,13 +3780,13 @@ function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3755
3780
  }
3756
3781
  return rFileContent;
3757
3782
  }
3758
- async function fileBinContent(fgeom, tSim, paramVal, exportFormat) {
3783
+ async function fileBinContent(fgeom, tSim, paramVal, ipDef, exportFormat) {
3759
3784
  const geome0 = fgeom(0, paramVal);
3760
3785
  const geome1 = fgeom(tSim, paramVal);
3761
3786
  let rFileContent = new Blob();
3762
3787
  if (!geome0.calcErr && !geome1.calcErr) {
3763
3788
  if (exportFormat === 7 /* eZIP */) {
3764
- rFileContent = await makeZip(paramVal, geome0, tSim, geome1);
3789
+ rFileContent = await makeZip(paramVal, geome0, tSim, geome1, ipDef);
3765
3790
  } else {
3766
3791
  console.log(`err913: unknown exportFormat ${exportFormat}`);
3767
3792
  }
@@ -3813,9 +3838,10 @@ function fileBin(exportFormat) {
3813
3838
  }
3814
3839
 
3815
3840
  // src/paramFile.ts
3816
- function createParamFile(lastModif, idparams, comment) {
3841
+ function createParamFile(lastModif, iPartName, idparams, comment) {
3817
3842
  const allVal = {
3818
3843
  lastModif,
3844
+ partName: iPartName,
3819
3845
  pVal: idparams,
3820
3846
  comment
3821
3847
  };
@@ -3825,13 +3851,17 @@ function createParamFile(lastModif, idparams, comment) {
3825
3851
  function parseParamFile(fContentStr) {
3826
3852
  const wholeJson = JSON.parse(fContentStr);
3827
3853
  const lastModifKey = "lastModif";
3854
+ const partNameKey = "partName";
3828
3855
  const pValKey = "pVal";
3829
3856
  const commentKey = "comment";
3830
3857
  let rlog = "";
3831
- const rObj = { lastModif: "", pVal: {}, comment: "" };
3858
+ const rObj = { lastModif: "", partName: "", pVal: {}, comment: "" };
3832
3859
  if (Object.hasOwn(wholeJson, lastModifKey)) {
3833
3860
  rObj[lastModifKey] = wholeJson[lastModifKey];
3834
3861
  }
3862
+ if (Object.hasOwn(wholeJson, partNameKey)) {
3863
+ rObj[partNameKey] = wholeJson[partNameKey];
3864
+ }
3835
3865
  if (Object.hasOwn(wholeJson, pValKey)) {
3836
3866
  const paNaVa = wholeJson[pValKey];
3837
3867
  for (const paNa of Object.keys(paNaVa)) {
@@ -3962,6 +3992,7 @@ export {
3962
3992
  pCheckbox,
3963
3993
  pDropdown,
3964
3994
  pNumber,
3995
+ pSectionSeparator,
3965
3996
  paramListToVal,
3966
3997
  parseParamFile,
3967
3998
  paxCircle,
@@ -3981,6 +4012,7 @@ export {
3981
4012
  withinHPiHPi,
3982
4013
  withinPiPi,
3983
4014
  withinZero2Pi,
3984
- withinZeroPi
4015
+ withinZeroPi,
4016
+ zeroPDef
3985
4017
  };
3986
4018
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "0.5.23",
3
+ "version": "0.5.24",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {
@@ -41,19 +41,19 @@
41
41
  "clean": "shx rm -fr dist node_modules"
42
42
  },
43
43
  "dependencies": {
44
- "@zip.js/zip.js": "^2.7.34"
44
+ "@zip.js/zip.js": "^2.7.37"
45
45
  },
46
46
  "devDependencies": {
47
- "@types/node": "^20.11.19",
47
+ "@types/node": "^20.11.25",
48
48
  "@typescript-eslint/eslint-plugin": "^7.0.1",
49
49
  "@typescript-eslint/parser": "^7.0.1",
50
- "eslint": "^8.56.0",
50
+ "eslint": "^8.57.0",
51
51
  "eslint-config-prettier": "^9.1.0",
52
52
  "npm-run-all": "^4.1.5",
53
53
  "prettier": "^3.2.5",
54
54
  "shx": "^0.3.4",
55
55
  "tsup": "^8.0.2",
56
- "typescript": "^5.3.3",
56
+ "typescript": "^5.4.2",
57
57
  "vitest": "^1.3.1"
58
58
  },
59
59
  "exports": {