@sarmal/core 0.31.0 → 0.34.0

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 (51) hide show
  1. package/README.md +2 -2
  2. package/dist/auto-init.cjs +42 -4
  3. package/dist/auto-init.cjs.map +1 -1
  4. package/dist/auto-init.js +42 -4
  5. package/dist/auto-init.js.map +1 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/curves/artemis2.d.cts +1 -1
  8. package/dist/curves/artemis2.d.ts +1 -1
  9. package/dist/curves/astroid.d.cts +1 -1
  10. package/dist/curves/astroid.d.ts +1 -1
  11. package/dist/curves/deltoid.d.cts +1 -1
  12. package/dist/curves/deltoid.d.ts +1 -1
  13. package/dist/curves/epicycloid3.d.cts +1 -1
  14. package/dist/curves/epicycloid3.d.ts +1 -1
  15. package/dist/curves/epitrochoid7.d.cts +1 -1
  16. package/dist/curves/epitrochoid7.d.ts +1 -1
  17. package/dist/curves/index.d.cts +1 -1
  18. package/dist/curves/index.d.ts +1 -1
  19. package/dist/curves/lame.d.cts +1 -1
  20. package/dist/curves/lame.d.ts +1 -1
  21. package/dist/curves/lissajous32.d.cts +1 -1
  22. package/dist/curves/lissajous32.d.ts +1 -1
  23. package/dist/curves/lissajous43.d.cts +1 -1
  24. package/dist/curves/lissajous43.d.ts +1 -1
  25. package/dist/curves/rose3.d.cts +1 -1
  26. package/dist/curves/rose3.d.ts +1 -1
  27. package/dist/curves/rose5.d.cts +1 -1
  28. package/dist/curves/rose5.d.ts +1 -1
  29. package/dist/curves/rose52.d.cts +1 -1
  30. package/dist/curves/rose52.d.ts +1 -1
  31. package/dist/curves/star.d.cts +1 -1
  32. package/dist/curves/star.d.ts +1 -1
  33. package/dist/curves/star4.d.cts +1 -1
  34. package/dist/curves/star4.d.ts +1 -1
  35. package/dist/curves/star7.d.cts +1 -1
  36. package/dist/curves/star7.d.ts +1 -1
  37. package/dist/index.cjs +375 -7
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +80 -4
  40. package/dist/index.d.ts +80 -4
  41. package/dist/index.js +375 -8
  42. package/dist/index.js.map +1 -1
  43. package/dist/{renderer-shared-jqw_Q1WO.d.cts → renderer-shared-C3KCEABq.d.cts} +8 -4
  44. package/dist/{renderer-shared-OR--cv-t.d.ts → renderer-shared-DyOI68gd.d.ts} +8 -4
  45. package/dist/terminal.cjs.map +1 -1
  46. package/dist/terminal.d.cts +2 -2
  47. package/dist/terminal.d.ts +2 -2
  48. package/dist/terminal.js.map +1 -1
  49. package/dist/{types-zbxUgcmZ.d.cts → types-_f27GDkU.d.cts} +30 -9
  50. package/dist/{types-zbxUgcmZ.d.ts → types-_f27GDkU.d.ts} +30 -9
  51. package/package.json +4 -4
package/dist/auto-init.js CHANGED
@@ -511,7 +511,8 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
511
511
  "headColor",
512
512
  "skeletonColor",
513
513
  "trailStyle",
514
- "headRadius"
514
+ "headRadius",
515
+ "trailWidth"
515
516
  ]);
516
517
  function validateRenderOptions(partial) {
517
518
  for (const key of Object.keys(partial)) {
@@ -534,6 +535,9 @@ function validateRenderOptions(partial) {
534
535
  if (partial.headRadius !== void 0) {
535
536
  assertHeadRadius(partial.headRadius);
536
537
  }
538
+ if (partial.trailWidth !== void 0) {
539
+ assertTrailWidth(partial.trailWidth);
540
+ }
537
541
  }
538
542
  function assertTrailColor(value) {
539
543
  if (typeof value === "string") {
@@ -603,6 +607,18 @@ function assertHeadRadius(value) {
603
607
  );
604
608
  }
605
609
  }
610
+ function assertTrailWidth(value) {
611
+ if (typeof value !== "number") {
612
+ throw new TypeError(
613
+ `[sarmal] setRenderOptions: trailWidth must be a number, got ${JSON.stringify(value)}`
614
+ );
615
+ }
616
+ if (!Number.isFinite(value) || value <= 0) {
617
+ throw new TypeError(
618
+ `[sarmal] setRenderOptions: trailWidth must be a finite positive number, got ${value}`
619
+ );
620
+ }
621
+ }
606
622
  function resolveTrailMainColor(trailColor) {
607
623
  return typeof trailColor === "string" ? trailColor : trailColor[0];
608
624
  }
@@ -671,7 +687,14 @@ function createRenderer(options) {
671
687
  setupCanvas();
672
688
  let logicalWidth = canvas.width / dpr;
673
689
  let logicalHeight = canvas.height / dpr;
690
+ if (options.headRadius !== void 0) {
691
+ validateRenderOptions({ headRadius: options.headRadius });
692
+ }
693
+ if (options.trailWidth !== void 0) {
694
+ validateRenderOptions({ trailWidth: options.trailWidth });
695
+ }
674
696
  let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
697
+ let trailWidth = options.trailWidth ?? 1;
675
698
  let skeleton = [];
676
699
  let skeletonCanvas = null;
677
700
  let trail = [];
@@ -765,7 +788,9 @@ function createRenderer(options) {
765
788
  i,
766
789
  trailCount,
767
790
  toX,
768
- toY
791
+ toY,
792
+ TRAIL_MIN_WIDTH * trailWidth,
793
+ TRAIL_MAX_WIDTH * trailWidth
769
794
  );
770
795
  if (trailStyle === "default") {
771
796
  ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
@@ -923,6 +948,9 @@ function createRenderer(options) {
923
948
  if (partial.headRadius !== void 0) {
924
949
  headRadius = partial.headRadius;
925
950
  }
951
+ if (partial.trailWidth !== void 0) {
952
+ trailWidth = partial.trailWidth;
953
+ }
926
954
  if (userHeadColor === null) {
927
955
  headColor = resolveHeadColor(trailColor, trailStyle);
928
956
  } else {
@@ -1021,7 +1049,14 @@ function createSVGRenderer(options) {
1021
1049
  const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
1022
1050
  const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
1023
1051
  const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
1052
+ if (options.headRadius !== void 0) {
1053
+ validateRenderOptions({ headRadius: options.headRadius });
1054
+ }
1055
+ if (options.trailWidth !== void 0) {
1056
+ validateRenderOptions({ trailWidth: options.trailWidth });
1057
+ }
1024
1058
  headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
1059
+ let trailWidth = options.trailWidth ?? 1;
1025
1060
  container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
1026
1061
  container.setAttribute("role", "img");
1027
1062
  container.setAttribute("aria-label", ariaLabel);
@@ -1116,8 +1151,8 @@ function createSVGRenderer(options) {
1116
1151
  trailCount,
1117
1152
  px,
1118
1153
  py,
1119
- svgTrailMinWidth,
1120
- svgTrailMaxWidth
1154
+ svgTrailMinWidth * trailWidth,
1155
+ svgTrailMaxWidth * trailWidth
1121
1156
  );
1122
1157
  const d = `M${l0x.toFixed(2)} ${l0y.toFixed(2)} L${l1x.toFixed(2)} ${l1y.toFixed(2)} L${r1x.toFixed(2)} ${r1y.toFixed(2)} L${r0x.toFixed(2)} ${r0y.toFixed(2)} Z`;
1123
1158
  trailPaths[i].setAttribute("d", d);
@@ -1309,6 +1344,9 @@ function createSVGRenderer(options) {
1309
1344
  headRadius = partial.headRadius;
1310
1345
  headCircle.setAttribute("r", String(headRadius));
1311
1346
  }
1347
+ if (partial.trailWidth !== void 0) {
1348
+ trailWidth = partial.trailWidth;
1349
+ }
1312
1350
  if (userHeadColor === null) {
1313
1351
  headColor = resolveHeadColor(trailColor, trailStyle);
1314
1352
  } else {