@digilogiclabs/saas-factory-ui 1.16.3 → 1.16.4

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.js CHANGED
@@ -30685,9 +30685,24 @@ function DiceRoller({
30685
30685
  cancelAnimationFrame(rafHandleRef.current);
30686
30686
  rafHandleRef.current = null;
30687
30687
  }
30688
- const w = arenaRef.current?.offsetWidth ?? 400;
30689
- const h = arenaRef.current?.offsetHeight ?? 260;
30688
+ const rawW = arenaRef.current?.offsetWidth ?? 0;
30689
+ const rawH = arenaRef.current?.offsetHeight ?? 0;
30690
+ const w = rawW > 20 ? rawW : 400;
30691
+ const h = rawH > 20 ? rawH : 260;
30690
30692
  const starts = currentPositionsRef.current ?? defaultPositions(w, h, clampedCount);
30693
+ if (typeof console !== "undefined") {
30694
+ console.log("[DiceRoller] roll()", {
30695
+ rawArena: { w: rawW, h: rawH },
30696
+ physicsArena: { w, h },
30697
+ clampedCount,
30698
+ effectiveSize,
30699
+ starts,
30700
+ refs: {
30701
+ die: dieWrapperRefs.current.map((el) => !!el),
30702
+ cube: cubeRefs.current.map((el) => !!el)
30703
+ }
30704
+ });
30705
+ }
30691
30706
  if (reducedMotion) {
30692
30707
  const final = defaultPositions(w, h, clampedCount);
30693
30708
  currentPositionsRef.current = final;
@@ -30728,40 +30743,38 @@ function DiceRoller({
30728
30743
  if (dieWrapperRefs.current[0]) {
30729
30744
  dieWrapperRefs.current[0].offsetHeight;
30730
30745
  }
30731
- const playbackMs = TUMBLE_MS;
30732
- const startTime = typeof performance !== "undefined" ? performance.now() : Date.now();
30733
- const tick = (now) => {
30734
- const elapsed = now - startTime;
30735
- const progress = Math.max(0, Math.min(1, elapsed / playbackMs));
30736
- const idx = Math.min(
30737
- frames.length - 1,
30738
- Math.floor(progress * frames.length)
30739
- );
30740
- const frame = frames[idx];
30741
- if (frame) {
30746
+ const stepMs = Math.max(20, Math.floor(TUMBLE_MS / frames.length));
30747
+ for (let s = 0; s < frames.length; s++) {
30748
+ const capturedStep = s;
30749
+ const timer = setTimeout(() => {
30750
+ const frame = frames[capturedStep];
30751
+ if (!frame) return;
30742
30752
  for (let i = 0; i < clampedCount; i++) {
30743
30753
  const p = frame[i];
30744
- if (p) writeDiePosition(i, p.x, p.y, p.sx, p.sy);
30754
+ if (!p) continue;
30755
+ writeDiePosition(i, p.x, p.y, p.sx, p.sy);
30745
30756
  }
30746
- currentPositionsRef.current = frame.slice(0, clampedCount).map((f) => ({
30747
- x: f.x,
30748
- y: f.y
30749
- }));
30750
- }
30751
- if (progress < 1) {
30752
- rafHandleRef.current = requestAnimationFrame(tick);
30753
- } else {
30754
- rafHandleRef.current = null;
30755
- for (let i = 0; i < clampedCount; i++) {
30756
- const el = dieWrapperRefs.current[i];
30757
- if (el)
30758
- el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
30759
- const shadow = shadowRefs.current[i];
30760
- if (shadow) shadow.style.opacity = "0.85";
30757
+ if (capturedStep === 0 && typeof console !== "undefined") {
30758
+ const el0 = dieWrapperRefs.current[0];
30759
+ console.log("[DiceRoller] first frame written", {
30760
+ frame0: frame,
30761
+ el0transform: el0?.style.transform,
30762
+ el0bounds: el0 ? { w: el0.offsetWidth, h: el0.offsetHeight } : null
30763
+ });
30761
30764
  }
30762
- }
30763
- };
30764
- rafHandleRef.current = requestAnimationFrame(tick);
30765
+ currentPositionsRef.current = frame.slice(0, clampedCount).map((f) => ({ x: f.x, y: f.y }));
30766
+ if (capturedStep === frames.length - 1) {
30767
+ for (let i = 0; i < clampedCount; i++) {
30768
+ const el = dieWrapperRefs.current[i];
30769
+ if (el)
30770
+ el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
30771
+ const shadow = shadowRefs.current[i];
30772
+ if (shadow) shadow.style.opacity = "0.85";
30773
+ }
30774
+ }
30775
+ }, capturedStep * stepMs);
30776
+ timersRef.current.push(timer);
30777
+ }
30765
30778
  requestAnimationFrame(() => {
30766
30779
  requestAnimationFrame(() => {
30767
30780
  for (let i = 0; i < clampedCount; i++) {