@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.cjs
CHANGED
|
@@ -685,6 +685,25 @@ function replayFit(stageWidth, stageHeight, contentWidth, contentHeight) {
|
|
|
685
685
|
// 垂直居中。
|
|
686
686
|
};
|
|
687
687
|
}
|
|
688
|
+
function replayWidthLayout(stageWidth, contentWidth, contentHeight) {
|
|
689
|
+
const width = finiteReplayNumber(stageWidth);
|
|
690
|
+
const recordedWidth = finiteReplayNumber(contentWidth);
|
|
691
|
+
const recordedHeight = finiteReplayNumber(contentHeight);
|
|
692
|
+
if (width <= 0 || recordedWidth <= 0 || recordedHeight <= 0) return null;
|
|
693
|
+
const scale = width / recordedWidth;
|
|
694
|
+
const height = recordedHeight * scale;
|
|
695
|
+
if (!Number.isFinite(scale) || !Number.isFinite(height) || height <= 0) return null;
|
|
696
|
+
return {
|
|
697
|
+
scale,
|
|
698
|
+
// 普通容器允许按可用宽度放大或缩小。
|
|
699
|
+
height,
|
|
700
|
+
// 官方视口完整占据舞台,业务抽屉负责正文滚动。
|
|
701
|
+
left: 0,
|
|
702
|
+
// 正常容器不增加左右背景留白。
|
|
703
|
+
top: 0
|
|
704
|
+
// 舞台高度与缩放画面一致,无需垂直居中。
|
|
705
|
+
};
|
|
706
|
+
}
|
|
688
707
|
function replayClock(timeMs) {
|
|
689
708
|
const seconds = Math.floor(Math.max(0, finiteReplayNumber(timeMs)) / 1e3);
|
|
690
709
|
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
@@ -794,6 +813,8 @@ function useSessionReplay(options) {
|
|
|
794
813
|
if (engineRef.current === player) engineRef.current = null;
|
|
795
814
|
player = null;
|
|
796
815
|
rootRef.current?.replaceChildren();
|
|
816
|
+
stageRef.current?.style.removeProperty("--adminsmart-replay-recorded-height");
|
|
817
|
+
stageRef.current?.removeAttribute("data-replay-viewport");
|
|
797
818
|
};
|
|
798
819
|
const fail = (code, message) => {
|
|
799
820
|
if (!current || failed) return;
|
|
@@ -807,7 +828,15 @@ function useSessionReplay(options) {
|
|
|
807
828
|
runtimeFailureRef.current = commandFailure;
|
|
808
829
|
const fit = () => {
|
|
809
830
|
if (!current || !player || !stageRef.current) return;
|
|
810
|
-
const
|
|
831
|
+
const stage = stageRef.current;
|
|
832
|
+
const recordedWidth = Number(player.iframe.width);
|
|
833
|
+
const recordedHeight = Number(player.iframe.height);
|
|
834
|
+
const widthLayout = replayWidthLayout(stage.clientWidth, recordedWidth, recordedHeight);
|
|
835
|
+
if (!widthLayout) return;
|
|
836
|
+
stage.style.setProperty("--adminsmart-replay-recorded-height", `${widthLayout.height}px`);
|
|
837
|
+
stage.setAttribute("data-replay-viewport", "recorded");
|
|
838
|
+
const fullscreen = document.fullscreenElement === stage.parentElement;
|
|
839
|
+
const dimensions = fullscreen ? replayFit(stage.clientWidth, stage.clientHeight, recordedWidth, recordedHeight) : widthLayout;
|
|
811
840
|
player.wrapper.style.position = "absolute";
|
|
812
841
|
player.wrapper.style.left = `${dimensions.left}px`;
|
|
813
842
|
player.wrapper.style.top = `${dimensions.top}px`;
|
|
@@ -815,6 +844,7 @@ function useSessionReplay(options) {
|
|
|
815
844
|
player.wrapper.style.transform = `scale(${dimensions.scale})`;
|
|
816
845
|
};
|
|
817
846
|
const scheduleFit = () => {
|
|
847
|
+
if (!current || failed) return;
|
|
818
848
|
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
819
849
|
fitFrame = window.requestAnimationFrame(() => {
|
|
820
850
|
fitFrame = void 0;
|
|
@@ -915,6 +945,7 @@ function useSessionReplay(options) {
|
|
|
915
945
|
observer.observe(stageRef.current);
|
|
916
946
|
}
|
|
917
947
|
window.addEventListener("resize", onLayout);
|
|
948
|
+
document.addEventListener("fullscreenchange", onLayout);
|
|
918
949
|
loadReplayEngine().then((value) => {
|
|
919
950
|
if (!current) return;
|
|
920
951
|
Constructor = value;
|
|
@@ -924,6 +955,7 @@ function useSessionReplay(options) {
|
|
|
924
955
|
current = false;
|
|
925
956
|
observer?.disconnect();
|
|
926
957
|
window.removeEventListener("resize", onLayout);
|
|
958
|
+
document.removeEventListener("fullscreenchange", onLayout);
|
|
927
959
|
if (runtimeFailureRef.current === commandFailure) runtimeFailureRef.current = null;
|
|
928
960
|
if (replayEventsRef.current === prepared) replayEventsRef.current = [];
|
|
929
961
|
releaseEngine();
|