@sarmal/core 0.20.0 → 0.23.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 (45) hide show
  1. package/dist/auto-init.cjs +38 -6
  2. package/dist/auto-init.cjs.map +1 -1
  3. package/dist/auto-init.d.cts +1 -1
  4. package/dist/auto-init.d.ts +1 -1
  5. package/dist/auto-init.js +38 -6
  6. package/dist/auto-init.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 +38 -6
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +2 -2
  40. package/dist/index.d.ts +2 -2
  41. package/dist/index.js +38 -6
  42. package/dist/index.js.map +1 -1
  43. package/dist/{types-frtEoAq6.d.cts → types-C0b4MPtI.d.cts} +4 -0
  44. package/dist/{types-frtEoAq6.d.ts → types-C0b4MPtI.d.ts} +4 -0
  45. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Artemis II free-return lunar trajectory curve
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Artemis II free-return lunar trajectory curve
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Astroid curve - a 4-cusped hypocycloid
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Astroid curve - a 4-cusped hypocycloid
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Deltoid curve - a 3-cusped hypocycloid
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Deltoid curve - a 3-cusped hypocycloid
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Epicycloid with 3 cusps
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Epicycloid with 3 cusps
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Epitrochoid with 7 lobes and dynamic variation
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Epitrochoid with 7 lobes and dynamic variation
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
  export { artemis2 } from "./artemis2.cjs";
3
3
  export { astroid } from "./astroid.cjs";
4
4
  export { deltoid } from "./deltoid.cjs";
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
  export { artemis2 } from "./artemis2.js";
3
3
  export { astroid } from "./astroid.js";
4
4
  export { deltoid } from "./deltoid.js";
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Lamé curve (superellipse) with time-varying exponent
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Lamé curve (superellipse) with time-varying exponent
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Lissajous curve with frequency ratio 3:2
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Lissajous curve with frequency ratio 3:2
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Lissajous curve with frequency ratio 4:3
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Lissajous curve with frequency ratio 4:3
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Rose curve with 3 petals
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Rose curve with 3 petals
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Rose curve with 5 petals
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Rose curve with 5 petals
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * Rose curve with n=5/2 that traces 5 petals over two full revolutions
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * Rose curve with n=5/2 that traces 5 petals over two full revolutions
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * 5-pointed star based on Fourier harmonics.
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * 5-pointed star based on Fourier harmonics.
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * 4-pointed star based on Fourier harmonics.
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * 4-pointed star based on Fourier harmonics.
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.cjs";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.cjs";
2
2
 
3
3
  /**
4
4
  * 7-pointed star based on Fourier harmonics.
@@ -1,4 +1,4 @@
1
- import { C as CurveDef } from "../types-frtEoAq6.js";
1
+ import { C as CurveDef } from "../types-C0b4MPtI.js";
2
2
 
3
3
  /**
4
4
  * 7-pointed star based on Fourier harmonics.
package/dist/index.cjs CHANGED
@@ -428,6 +428,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
428
428
  "headColor",
429
429
  "skeletonColor",
430
430
  "trailStyle",
431
+ "headRadius",
431
432
  ]);
432
433
  function validateRenderOptions(partial) {
433
434
  for (const key of Object.keys(partial)) {
@@ -447,6 +448,9 @@ function validateRenderOptions(partial) {
447
448
  if (partial.trailStyle !== void 0) {
448
449
  assertTrailStyle(partial.trailStyle);
449
450
  }
451
+ if (partial.headRadius !== void 0) {
452
+ assertHeadRadius(partial.headRadius);
453
+ }
450
454
  }
451
455
  function assertTrailColor(value) {
452
456
  if (typeof value === "string") {
@@ -504,6 +508,18 @@ function assertTrailStyle(value) {
504
508
  );
505
509
  }
506
510
  }
511
+ function assertHeadRadius(value) {
512
+ if (typeof value !== "number") {
513
+ throw new TypeError(
514
+ `[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
515
+ );
516
+ }
517
+ if (!Number.isFinite(value) || value <= 0) {
518
+ throw new TypeError(
519
+ `[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
520
+ );
521
+ }
522
+ }
507
523
  function resolveTrailMainColor(trailColor) {
508
524
  return typeof trailColor === "string" ? trailColor : trailColor[0];
509
525
  }
@@ -532,9 +548,9 @@ function warnIfTrailColorMismatch(trailColor, trailStyle) {
532
548
  );
533
549
  }
534
550
  }
535
- var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160));
536
551
 
537
552
  // src/renderer.ts
553
+ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160));
538
554
  var WHITE_HEX = "#ffffff";
539
555
  function hexToRgbComponents(hex) {
540
556
  const n = parseInt(hex.slice(1), 16);
@@ -571,6 +587,7 @@ function createRenderer(options) {
571
587
  setupCanvas();
572
588
  let logicalWidth = canvas.width / dpr;
573
589
  let logicalHeight = canvas.height / dpr;
590
+ let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
574
591
  let skeleton = [];
575
592
  let skeletonCanvas = null;
576
593
  let trail = [];
@@ -687,7 +704,7 @@ function createRenderer(options) {
687
704
  }
688
705
  const x = head.x * scale + offsetX;
689
706
  const y = head.y * scale + offsetY;
690
- const r = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
707
+ const r = headRadius;
691
708
  ctx.fillStyle = headColor;
692
709
  ctx.beginPath();
693
710
  ctx.arc(x, y, r, 0, Math.PI * 2);
@@ -816,6 +833,9 @@ function createRenderer(options) {
816
833
  if (partial.headColor !== void 0) {
817
834
  userHeadColor = partial.headColor;
818
835
  }
836
+ if (partial.headRadius !== void 0) {
837
+ headRadius = partial.headRadius;
838
+ }
819
839
  if (userHeadColor === null) {
820
840
  headColor = resolveHeadColor(trailColor, trailStyle);
821
841
  } else {
@@ -834,6 +854,8 @@ function createRenderer(options) {
834
854
 
835
855
  // src/renderer-svg.ts
836
856
  var EMPTY_PARAMS2 = {};
857
+ var SVG_DEFAULT_HEAD_RADIUS = 0.5;
858
+ var SKELETON_STROKE_WIDTH_PX = 1.5;
837
859
  var HIGH_TRAIL_LENGTH_THRESHOLD = 5e3;
838
860
  function pointsToPathString(pts, scale, offsetX, offsetY) {
839
861
  if (pts.length < 2) {
@@ -873,15 +895,21 @@ function createSVGRenderer(options) {
873
895
  let skeletonColor = options.skeletonColor ?? "#ffffff";
874
896
  let userHeadColor = options.headColor ?? null;
875
897
  let headColor = userHeadColor ?? resolveHeadColor(trailColor, trailStyle);
898
+ let headRadius;
876
899
  let trailSolid = resolveTrailMainColor(trailColor);
877
900
  let trailPalette = resolveTrailPalette(trailColor);
878
901
  const ariaLabel = options.ariaLabel ?? "Loading";
879
902
  warnIfTrailColorMismatch(trailColor, trailStyle);
880
903
  const viewSize = 100;
881
- const headRadius = options.headRadius ?? 1.5;
882
- const svgTrailMinWidth = 0.25;
883
- const svgTrailMaxWidth = 1.25;
884
- const svgSkeletonStrokeWidth = "0.75";
904
+ function getContainerPixelSize() {
905
+ const rect = container.getBoundingClientRect();
906
+ return rect.width && rect.height ? Math.min(rect.width, rect.height) : 200;
907
+ }
908
+ const containerPx = getContainerPixelSize();
909
+ const svgTrailMinWidth = (TRAIL_MIN_WIDTH * viewSize) / containerPx;
910
+ const svgTrailMaxWidth = (TRAIL_MAX_WIDTH * viewSize) / containerPx;
911
+ const svgSkeletonStrokeWidth = String((SKELETON_STROKE_WIDTH_PX * viewSize) / containerPx);
912
+ headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
885
913
  container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
886
914
  container.setAttribute("role", "img");
887
915
  container.setAttribute("aria-label", ariaLabel);
@@ -1154,6 +1182,10 @@ function createSVGRenderer(options) {
1154
1182
  if (partial.headColor !== void 0) {
1155
1183
  userHeadColor = partial.headColor;
1156
1184
  }
1185
+ if (partial.headRadius !== void 0) {
1186
+ headRadius = partial.headRadius;
1187
+ headCircle.setAttribute("r", String(headRadius));
1188
+ }
1157
1189
  if (userHeadColor === null) {
1158
1190
  headColor = resolveHeadColor(trailColor, trailStyle);
1159
1191
  } else {