@digilogiclabs/saas-factory-ui 1.16.3 → 1.16.5

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
@@ -30630,7 +30630,10 @@ function DiceRoller({
30630
30630
  (i, x, y, sx = 1, sy = 1) => {
30631
30631
  const el = dieWrapperRefs.current[i];
30632
30632
  if (!el) return;
30633
- el.style.transform = `translate3d(${x - half}px, ${y - half}px, 0) scale3d(${sx}, ${sy}, 1)`;
30633
+ el.style.setProperty("--dice-x", `${x - half}px`);
30634
+ el.style.setProperty("--dice-y", `${y - half}px`);
30635
+ el.style.setProperty("--dice-sx", String(sx));
30636
+ el.style.setProperty("--dice-sy", String(sy));
30634
30637
  },
30635
30638
  [half]
30636
30639
  );
@@ -30644,9 +30647,10 @@ function DiceRoller({
30644
30647
  []
30645
30648
  );
30646
30649
  (0, import_react66.useEffect)(() => {
30647
- const w = arenaRef.current?.offsetWidth ?? arena.w;
30648
- const h = arenaRef.current?.offsetHeight ?? arenaHeight;
30649
- if (w === 0 || h === 0) return;
30650
+ const rawW = arenaRef.current?.offsetWidth ?? 0;
30651
+ const rawH = arenaRef.current?.offsetHeight ?? 0;
30652
+ const w = rawW > 20 ? rawW : arena.w > 20 ? arena.w : 400;
30653
+ const h = rawH > 20 ? rawH : arenaHeight > 20 ? arenaHeight : 260;
30650
30654
  const initial = defaultPositions(w, h, clampedCount);
30651
30655
  currentPositionsRef.current = initial;
30652
30656
  for (let i = 0; i < clampedCount; i++) {
@@ -30654,7 +30658,10 @@ function DiceRoller({
30654
30658
  const el = dieWrapperRefs.current[i];
30655
30659
  if (el) {
30656
30660
  el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
30657
- el.style.transform = `translate3d(${pos.x - half}px, ${pos.y - half}px, 0) scale3d(1, 1, 1)`;
30661
+ el.style.setProperty("--dice-x", `${pos.x - half}px`);
30662
+ el.style.setProperty("--dice-y", `${pos.y - half}px`);
30663
+ el.style.setProperty("--dice-sx", "1");
30664
+ el.style.setProperty("--dice-sy", "1");
30658
30665
  }
30659
30666
  const cube = cubeRefs.current[i];
30660
30667
  if (cube) {
@@ -30685,9 +30692,24 @@ function DiceRoller({
30685
30692
  cancelAnimationFrame(rafHandleRef.current);
30686
30693
  rafHandleRef.current = null;
30687
30694
  }
30688
- const w = arenaRef.current?.offsetWidth ?? 400;
30689
- const h = arenaRef.current?.offsetHeight ?? 260;
30695
+ const rawW = arenaRef.current?.offsetWidth ?? 0;
30696
+ const rawH = arenaRef.current?.offsetHeight ?? 0;
30697
+ const w = rawW > 20 ? rawW : 400;
30698
+ const h = rawH > 20 ? rawH : 260;
30690
30699
  const starts = currentPositionsRef.current ?? defaultPositions(w, h, clampedCount);
30700
+ if (typeof console !== "undefined") {
30701
+ console.log("[DiceRoller] roll()", {
30702
+ rawArena: { w: rawW, h: rawH },
30703
+ physicsArena: { w, h },
30704
+ clampedCount,
30705
+ effectiveSize,
30706
+ starts,
30707
+ refs: {
30708
+ die: dieWrapperRefs.current.map((el) => !!el),
30709
+ cube: cubeRefs.current.map((el) => !!el)
30710
+ }
30711
+ });
30712
+ }
30691
30713
  if (reducedMotion) {
30692
30714
  const final = defaultPositions(w, h, clampedCount);
30693
30715
  currentPositionsRef.current = final;
@@ -30696,7 +30718,10 @@ function DiceRoller({
30696
30718
  const el = dieWrapperRefs.current[i];
30697
30719
  if (el) {
30698
30720
  el.style.transition = "transform 0.2s ease-out";
30699
- el.style.transform = `translate3d(${p.x - half}px, ${p.y - half}px, 0) scale3d(1, 1, 1)`;
30721
+ el.style.setProperty("--dice-x", `${p.x - half}px`);
30722
+ el.style.setProperty("--dice-y", `${p.y - half}px`);
30723
+ el.style.setProperty("--dice-sx", "1");
30724
+ el.style.setProperty("--dice-sy", "1");
30700
30725
  }
30701
30726
  const tgt = SHOW_ROT[vals[i]];
30702
30727
  writeCubeRotation(i, tgt.x, tgt.y, 0, true);
@@ -30728,40 +30753,55 @@ function DiceRoller({
30728
30753
  if (dieWrapperRefs.current[0]) {
30729
30754
  dieWrapperRefs.current[0].offsetHeight;
30730
30755
  }
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) {
30756
+ const stepMs = Math.max(20, Math.floor(TUMBLE_MS / frames.length));
30757
+ for (let s = 0; s < frames.length; s++) {
30758
+ const capturedStep = s;
30759
+ const timer = setTimeout(() => {
30760
+ const frame = frames[capturedStep];
30761
+ if (!frame) return;
30742
30762
  for (let i = 0; i < clampedCount; i++) {
30743
30763
  const p = frame[i];
30744
- if (p) writeDiePosition(i, p.x, p.y, p.sx, p.sy);
30764
+ if (!p) continue;
30765
+ writeDiePosition(i, p.x, p.y, p.sx, p.sy);
30745
30766
  }
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";
30767
+ if (capturedStep === 0 && typeof console !== "undefined") {
30768
+ const el0 = dieWrapperRefs.current[0];
30769
+ const el1 = dieWrapperRefs.current[1];
30770
+ const describe = (el) => {
30771
+ if (!el) return null;
30772
+ const rect = el.getBoundingClientRect();
30773
+ return {
30774
+ inlineTransform: el.style.transform,
30775
+ diceX: el.style.getPropertyValue("--dice-x"),
30776
+ diceY: el.style.getPropertyValue("--dice-y"),
30777
+ computedTransform: typeof getComputedStyle !== "undefined" ? getComputedStyle(el).transform : "n/a",
30778
+ rect: {
30779
+ x: Math.round(rect.x),
30780
+ y: Math.round(rect.y),
30781
+ w: Math.round(rect.width),
30782
+ h: Math.round(rect.height)
30783
+ }
30784
+ };
30785
+ };
30786
+ console.log("[DiceRoller] first frame written", {
30787
+ frame0: frame,
30788
+ el0: describe(el0),
30789
+ el1: describe(el1)
30790
+ });
30761
30791
  }
30762
- }
30763
- };
30764
- rafHandleRef.current = requestAnimationFrame(tick);
30792
+ currentPositionsRef.current = frame.slice(0, clampedCount).map((f) => ({ x: f.x, y: f.y }));
30793
+ if (capturedStep === frames.length - 1) {
30794
+ for (let i = 0; i < clampedCount; i++) {
30795
+ const el = dieWrapperRefs.current[i];
30796
+ if (el)
30797
+ el.style.transition = "transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94)";
30798
+ const shadow = shadowRefs.current[i];
30799
+ if (shadow) shadow.style.opacity = "0.85";
30800
+ }
30801
+ }
30802
+ }, capturedStep * stepMs);
30803
+ timersRef.current.push(timer);
30804
+ }
30765
30805
  requestAnimationFrame(() => {
30766
30806
  requestAnimationFrame(() => {
30767
30807
  for (let i = 0; i < clampedCount; i++) {
@@ -30845,24 +30885,30 @@ function DiceRoller({
30845
30885
  cursor: trigger === "click" ? "pointer" : void 0
30846
30886
  },
30847
30887
  children: Array.from({ length: clampedCount }, (_, d) => {
30888
+ const wrapperStyle = {
30889
+ position: "absolute",
30890
+ left: 0,
30891
+ top: 0,
30892
+ width: effectiveSize,
30893
+ height: effectiveSize,
30894
+ transform: "translate3d(var(--dice-x, 0px), var(--dice-y, 0px), 0) scale3d(var(--dice-sx, 1), var(--dice-sy, 1), 1)",
30895
+ // Parent must preserve 3D so the inner cube's rotateX/Y/Z
30896
+ // still renders with depth — otherwise adding a transform
30897
+ // to the wrapper would flatten its children into 2D.
30898
+ transformStyle: "preserve-3d",
30899
+ willChange: "transform",
30900
+ zIndex: 2,
30901
+ perspective: 700,
30902
+ "--dice-x": "0px",
30903
+ "--dice-y": "0px",
30904
+ "--dice-sx": "1",
30905
+ "--dice-sy": "1"
30906
+ };
30848
30907
  return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
30849
30908
  "div",
30850
30909
  {
30851
30910
  ref: getDieSetter(d),
30852
- style: {
30853
- position: "absolute",
30854
- left: 0,
30855
- top: 0,
30856
- width: effectiveSize,
30857
- height: effectiveSize,
30858
- // Parent must preserve 3D so the inner cube's rotateX/Y/Z
30859
- // still renders with depth — otherwise adding a transform
30860
- // to the wrapper would flatten its children into 2D.
30861
- transformStyle: "preserve-3d",
30862
- willChange: "transform",
30863
- zIndex: 2,
30864
- perspective: 700
30865
- },
30911
+ style: wrapperStyle,
30866
30912
  children: [
30867
30913
  /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
30868
30914
  "div",