@qq1948037137/adminsmart-ui 0.1.24 → 0.1.25
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.cjs +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/styles/composites.css +13 -0
package/dist/index.js
CHANGED
|
@@ -594,6 +594,25 @@ function replayFit(stageWidth, stageHeight, contentWidth, contentHeight) {
|
|
|
594
594
|
// 垂直居中。
|
|
595
595
|
};
|
|
596
596
|
}
|
|
597
|
+
function replayWidthLayout(stageWidth, contentWidth, contentHeight) {
|
|
598
|
+
const width = finiteReplayNumber(stageWidth);
|
|
599
|
+
const recordedWidth = finiteReplayNumber(contentWidth);
|
|
600
|
+
const recordedHeight = finiteReplayNumber(contentHeight);
|
|
601
|
+
if (width <= 0 || recordedWidth <= 0 || recordedHeight <= 0) return null;
|
|
602
|
+
const scale = width / recordedWidth;
|
|
603
|
+
const height = recordedHeight * scale;
|
|
604
|
+
if (!Number.isFinite(scale) || !Number.isFinite(height) || height <= 0) return null;
|
|
605
|
+
return {
|
|
606
|
+
scale,
|
|
607
|
+
// 普通容器允许按可用宽度放大或缩小。
|
|
608
|
+
height,
|
|
609
|
+
// 官方视口完整占据舞台,业务抽屉负责正文滚动。
|
|
610
|
+
left: 0,
|
|
611
|
+
// 正常容器不增加左右背景留白。
|
|
612
|
+
top: 0
|
|
613
|
+
// 舞台高度与缩放画面一致,无需垂直居中。
|
|
614
|
+
};
|
|
615
|
+
}
|
|
597
616
|
function replayClock(timeMs) {
|
|
598
617
|
const seconds = Math.floor(Math.max(0, finiteReplayNumber(timeMs)) / 1e3);
|
|
599
618
|
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
@@ -703,6 +722,8 @@ function useSessionReplay(options) {
|
|
|
703
722
|
if (engineRef.current === player) engineRef.current = null;
|
|
704
723
|
player = null;
|
|
705
724
|
rootRef.current?.replaceChildren();
|
|
725
|
+
stageRef.current?.style.removeProperty("--adminsmart-replay-recorded-height");
|
|
726
|
+
stageRef.current?.removeAttribute("data-replay-viewport");
|
|
706
727
|
};
|
|
707
728
|
const fail = (code, message) => {
|
|
708
729
|
if (!current || failed) return;
|
|
@@ -716,7 +737,15 @@ function useSessionReplay(options) {
|
|
|
716
737
|
runtimeFailureRef.current = commandFailure;
|
|
717
738
|
const fit = () => {
|
|
718
739
|
if (!current || !player || !stageRef.current) return;
|
|
719
|
-
const
|
|
740
|
+
const stage = stageRef.current;
|
|
741
|
+
const recordedWidth = Number(player.iframe.width);
|
|
742
|
+
const recordedHeight = Number(player.iframe.height);
|
|
743
|
+
const widthLayout = replayWidthLayout(stage.clientWidth, recordedWidth, recordedHeight);
|
|
744
|
+
if (!widthLayout) return;
|
|
745
|
+
stage.style.setProperty("--adminsmart-replay-recorded-height", `${widthLayout.height}px`);
|
|
746
|
+
stage.setAttribute("data-replay-viewport", "recorded");
|
|
747
|
+
const fullscreen = document.fullscreenElement === stage.parentElement;
|
|
748
|
+
const dimensions = fullscreen ? replayFit(stage.clientWidth, stage.clientHeight, recordedWidth, recordedHeight) : widthLayout;
|
|
720
749
|
player.wrapper.style.position = "absolute";
|
|
721
750
|
player.wrapper.style.left = `${dimensions.left}px`;
|
|
722
751
|
player.wrapper.style.top = `${dimensions.top}px`;
|
|
@@ -724,6 +753,7 @@ function useSessionReplay(options) {
|
|
|
724
753
|
player.wrapper.style.transform = `scale(${dimensions.scale})`;
|
|
725
754
|
};
|
|
726
755
|
const scheduleFit = () => {
|
|
756
|
+
if (!current || failed) return;
|
|
727
757
|
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
728
758
|
fitFrame = window.requestAnimationFrame(() => {
|
|
729
759
|
fitFrame = void 0;
|
|
@@ -824,6 +854,7 @@ function useSessionReplay(options) {
|
|
|
824
854
|
observer.observe(stageRef.current);
|
|
825
855
|
}
|
|
826
856
|
window.addEventListener("resize", onLayout);
|
|
857
|
+
document.addEventListener("fullscreenchange", onLayout);
|
|
827
858
|
loadReplayEngine().then((value) => {
|
|
828
859
|
if (!current) return;
|
|
829
860
|
Constructor = value;
|
|
@@ -833,6 +864,7 @@ function useSessionReplay(options) {
|
|
|
833
864
|
current = false;
|
|
834
865
|
observer?.disconnect();
|
|
835
866
|
window.removeEventListener("resize", onLayout);
|
|
867
|
+
document.removeEventListener("fullscreenchange", onLayout);
|
|
836
868
|
if (runtimeFailureRef.current === commandFailure) runtimeFailureRef.current = null;
|
|
837
869
|
if (replayEventsRef.current === prepared) replayEventsRef.current = [];
|
|
838
870
|
releaseEngine();
|