@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
package/dist/index.d.cts CHANGED
@@ -6,14 +6,14 @@ import {
6
6
  R as RendererOptions,
7
7
  P as Point,
8
8
  a as SarmalOptions,
9
- } from "./types-frtEoAq6.cjs";
9
+ } from "./types-DVerJ9cl.cjs";
10
10
  export {
11
11
  J as JumpOptions,
12
12
  b as RuntimeRenderOptions,
13
13
  c as SeekOptions,
14
14
  T as TrailColor,
15
15
  d as TrailStyle,
16
- } from "./types-frtEoAq6.cjs";
16
+ } from "./types-DVerJ9cl.cjs";
17
17
  export { CurveName, curves } from "./curves/index.cjs";
18
18
  export { artemis2 } from "./curves/artemis2.cjs";
19
19
  export { astroid } from "./curves/astroid.cjs";
package/dist/index.d.ts CHANGED
@@ -6,14 +6,14 @@ import {
6
6
  R as RendererOptions,
7
7
  P as Point,
8
8
  a as SarmalOptions,
9
- } from "./types-frtEoAq6.js";
9
+ } from "./types-DVerJ9cl.js";
10
10
  export {
11
11
  J as JumpOptions,
12
12
  b as RuntimeRenderOptions,
13
13
  c as SeekOptions,
14
14
  T as TrailColor,
15
15
  d as TrailStyle,
16
- } from "./types-frtEoAq6.js";
16
+ } from "./types-DVerJ9cl.js";
17
17
  export { CurveName, curves } from "./curves/index.js";
18
18
  export { artemis2 } from "./curves/artemis2.js";
19
19
  export { astroid } from "./curves/astroid.js";
package/dist/index.js CHANGED
@@ -426,6 +426,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
426
426
  "headColor",
427
427
  "skeletonColor",
428
428
  "trailStyle",
429
+ "headRadius",
429
430
  ]);
430
431
  function validateRenderOptions(partial) {
431
432
  for (const key of Object.keys(partial)) {
@@ -445,6 +446,9 @@ function validateRenderOptions(partial) {
445
446
  if (partial.trailStyle !== void 0) {
446
447
  assertTrailStyle(partial.trailStyle);
447
448
  }
449
+ if (partial.headRadius !== void 0) {
450
+ assertHeadRadius(partial.headRadius);
451
+ }
448
452
  }
449
453
  function assertTrailColor(value) {
450
454
  if (typeof value === "string") {
@@ -502,6 +506,18 @@ function assertTrailStyle(value) {
502
506
  );
503
507
  }
504
508
  }
509
+ function assertHeadRadius(value) {
510
+ if (typeof value !== "number") {
511
+ throw new TypeError(
512
+ `[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
513
+ );
514
+ }
515
+ if (!Number.isFinite(value) || value <= 0) {
516
+ throw new TypeError(
517
+ `[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
518
+ );
519
+ }
520
+ }
505
521
  function resolveTrailMainColor(trailColor) {
506
522
  return typeof trailColor === "string" ? trailColor : trailColor[0];
507
523
  }
@@ -569,6 +585,7 @@ function createRenderer(options) {
569
585
  setupCanvas();
570
586
  let logicalWidth = canvas.width / dpr;
571
587
  let logicalHeight = canvas.height / dpr;
588
+ let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
572
589
  let skeleton = [];
573
590
  let skeletonCanvas = null;
574
591
  let trail = [];
@@ -685,7 +702,7 @@ function createRenderer(options) {
685
702
  }
686
703
  const x = head.x * scale + offsetX;
687
704
  const y = head.y * scale + offsetY;
688
- const r = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
705
+ const r = headRadius;
689
706
  ctx.fillStyle = headColor;
690
707
  ctx.beginPath();
691
708
  ctx.arc(x, y, r, 0, Math.PI * 2);
@@ -814,6 +831,9 @@ function createRenderer(options) {
814
831
  if (partial.headColor !== void 0) {
815
832
  userHeadColor = partial.headColor;
816
833
  }
834
+ if (partial.headRadius !== void 0) {
835
+ headRadius = partial.headRadius;
836
+ }
817
837
  if (userHeadColor === null) {
818
838
  headColor = resolveHeadColor(trailColor, trailStyle);
819
839
  } else {
@@ -871,12 +891,12 @@ function createSVGRenderer(options) {
871
891
  let skeletonColor = options.skeletonColor ?? "#ffffff";
872
892
  let userHeadColor = options.headColor ?? null;
873
893
  let headColor = userHeadColor ?? resolveHeadColor(trailColor, trailStyle);
894
+ let headRadius = options.headRadius ?? 1.5;
874
895
  let trailSolid = resolveTrailMainColor(trailColor);
875
896
  let trailPalette = resolveTrailPalette(trailColor);
876
897
  const ariaLabel = options.ariaLabel ?? "Loading";
877
898
  warnIfTrailColorMismatch(trailColor, trailStyle);
878
899
  const viewSize = 100;
879
- const headRadius = options.headRadius ?? 1.5;
880
900
  const svgTrailMinWidth = 0.25;
881
901
  const svgTrailMaxWidth = 1.25;
882
902
  const svgSkeletonStrokeWidth = "0.75";
@@ -1152,6 +1172,10 @@ function createSVGRenderer(options) {
1152
1172
  if (partial.headColor !== void 0) {
1153
1173
  userHeadColor = partial.headColor;
1154
1174
  }
1175
+ if (partial.headRadius !== void 0) {
1176
+ headRadius = partial.headRadius;
1177
+ headCircle.setAttribute("r", String(headRadius));
1178
+ }
1155
1179
  if (userHeadColor === null) {
1156
1180
  headColor = resolveHeadColor(trailColor, trailStyle);
1157
1181
  } else {