@sarmal/core 0.20.0 → 0.22.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 +26 -2
  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 +26 -2
  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 +26 -2
  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 +26 -2
  42. package/dist/index.js.map +1 -1
  43. package/dist/{types-frtEoAq6.d.cts → types-DVerJ9cl.d.cts} +4 -0
  44. package/dist/{types-frtEoAq6.d.ts → types-DVerJ9cl.d.ts} +4 -0
  45. package/package.json +1 -1
@@ -420,6 +420,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
420
420
  "headColor",
421
421
  "skeletonColor",
422
422
  "trailStyle",
423
+ "headRadius",
423
424
  ]);
424
425
  function validateRenderOptions(partial) {
425
426
  for (const key of Object.keys(partial)) {
@@ -439,6 +440,9 @@ function validateRenderOptions(partial) {
439
440
  if (partial.trailStyle !== void 0) {
440
441
  assertTrailStyle(partial.trailStyle);
441
442
  }
443
+ if (partial.headRadius !== void 0) {
444
+ assertHeadRadius(partial.headRadius);
445
+ }
442
446
  }
443
447
  function assertTrailColor(value) {
444
448
  if (typeof value === "string") {
@@ -496,6 +500,18 @@ function assertTrailStyle(value) {
496
500
  );
497
501
  }
498
502
  }
503
+ function assertHeadRadius(value) {
504
+ if (typeof value !== "number") {
505
+ throw new TypeError(
506
+ `[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
507
+ );
508
+ }
509
+ if (!Number.isFinite(value) || value <= 0) {
510
+ throw new TypeError(
511
+ `[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
512
+ );
513
+ }
514
+ }
499
515
  function resolveTrailMainColor(trailColor) {
500
516
  return typeof trailColor === "string" ? trailColor : trailColor[0];
501
517
  }
@@ -563,6 +579,7 @@ function createRenderer(options) {
563
579
  setupCanvas();
564
580
  let logicalWidth = canvas.width / dpr;
565
581
  let logicalHeight = canvas.height / dpr;
582
+ let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
566
583
  let skeleton = [];
567
584
  let skeletonCanvas = null;
568
585
  let trail = [];
@@ -679,7 +696,7 @@ function createRenderer(options) {
679
696
  }
680
697
  const x = head.x * scale + offsetX;
681
698
  const y = head.y * scale + offsetY;
682
- const r = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
699
+ const r = headRadius;
683
700
  ctx.fillStyle = headColor;
684
701
  ctx.beginPath();
685
702
  ctx.arc(x, y, r, 0, Math.PI * 2);
@@ -808,6 +825,9 @@ function createRenderer(options) {
808
825
  if (partial.headColor !== void 0) {
809
826
  userHeadColor = partial.headColor;
810
827
  }
828
+ if (partial.headRadius !== void 0) {
829
+ headRadius = partial.headRadius;
830
+ }
811
831
  if (userHeadColor === null) {
812
832
  headColor = resolveHeadColor(trailColor, trailStyle);
813
833
  } else {
@@ -865,12 +885,12 @@ function createSVGRenderer(options) {
865
885
  let skeletonColor = options.skeletonColor ?? "#ffffff";
866
886
  let userHeadColor = options.headColor ?? null;
867
887
  let headColor = userHeadColor ?? resolveHeadColor(trailColor, trailStyle);
888
+ let headRadius = options.headRadius ?? 1.5;
868
889
  let trailSolid = resolveTrailMainColor(trailColor);
869
890
  let trailPalette = resolveTrailPalette(trailColor);
870
891
  const ariaLabel = options.ariaLabel ?? "Loading";
871
892
  warnIfTrailColorMismatch(trailColor, trailStyle);
872
893
  const viewSize = 100;
873
- const headRadius = options.headRadius ?? 1.5;
874
894
  const svgTrailMinWidth = 0.25;
875
895
  const svgTrailMaxWidth = 1.25;
876
896
  const svgSkeletonStrokeWidth = "0.75";
@@ -1146,6 +1166,10 @@ function createSVGRenderer(options) {
1146
1166
  if (partial.headColor !== void 0) {
1147
1167
  userHeadColor = partial.headColor;
1148
1168
  }
1169
+ if (partial.headRadius !== void 0) {
1170
+ headRadius = partial.headRadius;
1171
+ headCircle.setAttribute("r", String(headRadius));
1172
+ }
1149
1173
  if (userHeadColor === null) {
1150
1174
  headColor = resolveHeadColor(trailColor, trailStyle);
1151
1175
  } else {