geometrix 0.5.22 → 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 {
@@ -483,10 +485,13 @@ declare class DesignParam {
483
485
  paramInit: tParamVal;
484
486
  paramChanged: tParamChanged;
485
487
  partName: string;
488
+ suffix: string;
486
489
  paramNames: string[];
487
490
  getParamName(): string[];
488
491
  constructor(iparamDef: tParamDef, suffix?: string);
489
492
  getPartName(): string;
493
+ getPartNameSuffix(): string;
494
+ getSuffix(): string;
490
495
  getParamVal(): tParamVal;
491
496
  getVal(iname: string): number;
492
497
  getInit(iname: string): number;
@@ -500,6 +505,7 @@ declare function designParam(iparamDef: tParamDef, suffix?: string): DesignParam
500
505
  declare function pNumber(name: string, unit: string, init: number, min?: number, max?: number, step?: number): tParam;
501
506
  declare function pCheckbox(name: string, init: boolean): tParam;
502
507
  declare function pDropdown(name: string, values: string[]): tParam;
508
+ declare function pSectionSeparator(name: string): tParam;
503
509
 
504
510
  type tPosiOrien = [number, number, number];
505
511
  interface tSubInst {
@@ -518,7 +524,7 @@ interface tGeom {
518
524
  vol: tVolume;
519
525
  sub: tSubDesign;
520
526
  }
521
- type tGeomFunc = (t: number, ipVal: tParamVal) => tGeom;
527
+ type tGeomFunc = (t: number, ipVal: tParamVal, suffix?: string) => tGeom;
522
528
  interface tPageDef {
523
529
  pTitle: string;
524
530
  pDescription: string;
@@ -578,18 +584,19 @@ declare enum EFormat {
578
584
  eJSCAD = 6,
579
585
  eZIP = 7
580
586
  }
581
- declare function fileTextContent(fgeom: tGeomFunc, paramVal: tParamVal, eFace: string, exportFormat: EFormat): string;
582
- 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>;
583
589
  declare function fileMime(exportFormat: EFormat): string;
584
590
  declare function fileSuffix(exportFormat: EFormat): string;
585
591
  declare function fileBin(exportFormat: EFormat): boolean;
586
592
 
587
593
  interface tParamValInFile {
588
594
  lastModif: string;
595
+ partName: string;
589
596
  pVal: tParamVal;
590
597
  comment: string;
591
598
  }
592
- declare function createParamFile(lastModif: string, idparams: tParamVal, comment: string): string;
599
+ declare function createParamFile(lastModif: string, iPartName: string, idparams: tParamVal, comment: string): string;
593
600
  declare function parseParamFile(fContentStr: string): [tParamValInFile, string];
594
601
 
595
602
  /** For cli-app and ui-app */
@@ -605,4 +612,4 @@ declare function version_details(appPackage: tPackage): string[];
605
612
 
606
613
  declare function checkImpPages(pages: tAllPageDef): [boolean, string];
607
614
 
608
- 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;
@@ -2755,6 +2766,7 @@ var DesignParam = class {
2755
2766
  paramInit = {};
2756
2767
  paramChanged = {};
2757
2768
  partName;
2769
+ suffix;
2758
2770
  paramNames;
2759
2771
  getParamName() {
2760
2772
  const rNames = [];
@@ -2769,12 +2781,19 @@ var DesignParam = class {
2769
2781
  this.paramInit[pi.name] = pi.init;
2770
2782
  this.paramChanged[pi.name] = false;
2771
2783
  }
2772
- this.partName = iparamDef.partName + suffix;
2784
+ this.suffix = suffix;
2785
+ this.partName = iparamDef.partName;
2773
2786
  this.paramNames = this.getParamName();
2774
2787
  }
2775
2788
  getPartName() {
2776
2789
  return this.partName;
2777
2790
  }
2791
+ getPartNameSuffix() {
2792
+ return this.partName + this.suffix;
2793
+ }
2794
+ getSuffix() {
2795
+ return this.suffix;
2796
+ }
2778
2797
  getParamVal() {
2779
2798
  return this.paramVal;
2780
2799
  }
@@ -2870,6 +2889,19 @@ function pDropdown(name, values) {
2870
2889
  };
2871
2890
  return rParam;
2872
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
+ }
2873
2905
 
2874
2906
  // src/volume.ts
2875
2907
  var EExtrude = /* @__PURE__ */ ((EExtrude2) => {
@@ -2937,9 +2969,10 @@ var PaxWrite = class {
2937
2969
  }
2938
2970
  return figFaces;
2939
2971
  }
2940
- getPaxJson(paramVal, geome0) {
2972
+ getPaxJson(paramVal, geome0, ipDef) {
2941
2973
  const rPaxJson = {
2942
2974
  partName: geome0.partName,
2975
+ pDef: ipDef,
2943
2976
  params: paramVal,
2944
2977
  faces: this.getFigures(geome0.fig),
2945
2978
  volume: geome0.vol,
@@ -2948,8 +2981,8 @@ var PaxWrite = class {
2948
2981
  };
2949
2982
  return rPaxJson;
2950
2983
  }
2951
- getPaxStr(paramVal, geome0) {
2952
- const paxJson = this.getPaxJson(paramVal, geome0);
2984
+ getPaxStr(paramVal, geome0, ipDef) {
2985
+ const paxJson = this.getPaxJson(paramVal, geome0, ipDef);
2953
2986
  const rStr = JSON.stringify(paxJson, null, 2);
2954
2987
  return rStr;
2955
2988
  }
@@ -3246,7 +3279,7 @@ module ${inherit.outName} () {
3246
3279
  if (vol.inherits !== void 0) {
3247
3280
  const subGeoms = this.getAllSubGeoms(vol.inherits);
3248
3281
  for (const oneGeom of subGeoms) {
3249
- const paxJson = paxWrite().getPaxJson({}, oneGeom);
3282
+ const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
3250
3283
  rStr += this.getAllFigures(paxJson.faces, paxJson.partName);
3251
3284
  rStr += this.getVolume(oneGeom.vol);
3252
3285
  }
@@ -3495,7 +3528,7 @@ const ${inherit.outName} =
3495
3528
  if (vol.inherits !== void 0) {
3496
3529
  const subGeoms = this.getAllSubGeoms(vol.inherits);
3497
3530
  for (const oneGeom of subGeoms) {
3498
- const paxJson = paxWrite().getPaxJson({}, oneGeom);
3531
+ const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
3499
3532
  rStr += this.getAllFigures(paxJson.faces, paxJson.partName);
3500
3533
  rStr += this.getVolume(oneGeom.vol);
3501
3534
  }
@@ -3642,21 +3675,21 @@ function figureToDxf(aCtr) {
3642
3675
  const rDxf = dxf.stringify();
3643
3676
  return rDxf;
3644
3677
  }
3645
- function makePax(paramVal, geome0) {
3646
- const rStr = paxWrite().getPaxStr(paramVal, geome0);
3678
+ function makePax(paramVal, geome0, ipDef) {
3679
+ const rStr = paxWrite().getPaxStr(paramVal, geome0, ipDef);
3647
3680
  return rStr;
3648
3681
  }
3649
3682
  function makeOpenscad(geome0) {
3650
- const paxJson = paxWrite().getPaxJson({}, geome0);
3683
+ const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
3651
3684
  const rStr = oscadWrite().getExportFile(paxJson);
3652
3685
  return rStr;
3653
3686
  }
3654
3687
  function makeOpenjscad(geome0) {
3655
- const paxJson = paxWrite().getPaxJson({}, geome0);
3688
+ const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
3656
3689
  const rStr = ojscadWrite().getExportFile(paxJson);
3657
3690
  return rStr;
3658
3691
  }
3659
- async function makeZip(paramVal, geome0, tSim, geome1) {
3692
+ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
3660
3693
  const zipFileWriter = new zip.BlobWriter("application/zip");
3661
3694
  const zipWriter = new zip.ZipWriter(zipFileWriter);
3662
3695
  const partName = geome0.partName;
@@ -3685,7 +3718,7 @@ async function makeZip(paramVal, geome0, tSim, geome1) {
3685
3718
  await zipWriter.add(`deco_${partName}_all_merged.svg`, svgMergedDeco);
3686
3719
  const svgMergedDecoT = new zip.TextReader(figureToSvgDeco(mergedFace));
3687
3720
  await zipWriter.add(`deco_${partName}_all_merged_t${tSim}.svg`, svgMergedDecoT);
3688
- const zPax = new zip.TextReader(makePax(paramVal, geome0));
3721
+ const zPax = new zip.TextReader(makePax(paramVal, geome0, ipDef));
3689
3722
  await zipWriter.add(`${partName}.pax.json`, zPax);
3690
3723
  const zSCad = new zip.TextReader(makeOpenscad(geome0));
3691
3724
  await zipWriter.add(`${partName}_noarc_openscad.scad`, zSCad);
@@ -3708,7 +3741,7 @@ var EFormat = /* @__PURE__ */ ((EFormat2) => {
3708
3741
  EFormat2[EFormat2["eZIP"] = 7] = "eZIP";
3709
3742
  return EFormat2;
3710
3743
  })(EFormat || {});
3711
- function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3744
+ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
3712
3745
  const geome0 = fgeom(0, paramVal);
3713
3746
  let rFileContent = "";
3714
3747
  if (!geome0.calcErr) {
@@ -3734,7 +3767,7 @@ function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3734
3767
  const figu = mergeFaces(geome0.fig);
3735
3768
  rFileContent = figureToDxf(figu.mainList);
3736
3769
  } else if (exportFormat === 4 /* ePAX */) {
3737
- rFileContent = makePax(paramVal, geome0);
3770
+ rFileContent = makePax(paramVal, geome0, ipDef);
3738
3771
  } else if (exportFormat === 5 /* eOPENSCAD */) {
3739
3772
  rFileContent = makeOpenscad(geome0);
3740
3773
  } else if (exportFormat === 6 /* eJSCAD */) {
@@ -3747,13 +3780,13 @@ function fileTextContent(fgeom, paramVal, eFace, exportFormat) {
3747
3780
  }
3748
3781
  return rFileContent;
3749
3782
  }
3750
- async function fileBinContent(fgeom, tSim, paramVal, exportFormat) {
3783
+ async function fileBinContent(fgeom, tSim, paramVal, ipDef, exportFormat) {
3751
3784
  const geome0 = fgeom(0, paramVal);
3752
3785
  const geome1 = fgeom(tSim, paramVal);
3753
3786
  let rFileContent = new Blob();
3754
3787
  if (!geome0.calcErr && !geome1.calcErr) {
3755
3788
  if (exportFormat === 7 /* eZIP */) {
3756
- rFileContent = await makeZip(paramVal, geome0, tSim, geome1);
3789
+ rFileContent = await makeZip(paramVal, geome0, tSim, geome1, ipDef);
3757
3790
  } else {
3758
3791
  console.log(`err913: unknown exportFormat ${exportFormat}`);
3759
3792
  }
@@ -3805,9 +3838,10 @@ function fileBin(exportFormat) {
3805
3838
  }
3806
3839
 
3807
3840
  // src/paramFile.ts
3808
- function createParamFile(lastModif, idparams, comment) {
3841
+ function createParamFile(lastModif, iPartName, idparams, comment) {
3809
3842
  const allVal = {
3810
3843
  lastModif,
3844
+ partName: iPartName,
3811
3845
  pVal: idparams,
3812
3846
  comment
3813
3847
  };
@@ -3817,13 +3851,17 @@ function createParamFile(lastModif, idparams, comment) {
3817
3851
  function parseParamFile(fContentStr) {
3818
3852
  const wholeJson = JSON.parse(fContentStr);
3819
3853
  const lastModifKey = "lastModif";
3854
+ const partNameKey = "partName";
3820
3855
  const pValKey = "pVal";
3821
3856
  const commentKey = "comment";
3822
3857
  let rlog = "";
3823
- const rObj = { lastModif: "", pVal: {}, comment: "" };
3858
+ const rObj = { lastModif: "", partName: "", pVal: {}, comment: "" };
3824
3859
  if (Object.hasOwn(wholeJson, lastModifKey)) {
3825
3860
  rObj[lastModifKey] = wholeJson[lastModifKey];
3826
3861
  }
3862
+ if (Object.hasOwn(wholeJson, partNameKey)) {
3863
+ rObj[partNameKey] = wholeJson[partNameKey];
3864
+ }
3827
3865
  if (Object.hasOwn(wholeJson, pValKey)) {
3828
3866
  const paNaVa = wholeJson[pValKey];
3829
3867
  for (const paNa of Object.keys(paNaVa)) {
@@ -3954,6 +3992,7 @@ export {
3954
3992
  pCheckbox,
3955
3993
  pDropdown,
3956
3994
  pNumber,
3995
+ pSectionSeparator,
3957
3996
  paramListToVal,
3958
3997
  parseParamFile,
3959
3998
  paxCircle,
@@ -3973,6 +4012,7 @@ export {
3973
4012
  withinHPiHPi,
3974
4013
  withinPiPi,
3975
4014
  withinZero2Pi,
3976
- withinZeroPi
4015
+ withinZeroPi,
4016
+ zeroPDef
3977
4017
  };
3978
4018
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "0.5.22",
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": {