@qq1948037137/adminsmart-ui 0.1.23 → 0.1.24
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 +37 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -626,6 +626,38 @@ function replayRange(totalTime, startOffsetMs = 0, endOffsetMs) {
|
|
|
626
626
|
// 内部转可见。
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
|
+
function replayPlaybackWindow(events, startOffsetMs = 0, endOffsetMs) {
|
|
630
|
+
const firstTimestamp = finiteReplayNumber(events[0]?.timestamp);
|
|
631
|
+
const originalTotal = Math.max(0, finiteReplayNumber(events.at(-1)?.timestamp) - firstTimestamp);
|
|
632
|
+
const range = replayRange(originalTotal, startOffsetMs, endOffsetMs);
|
|
633
|
+
if (endOffsetMs === void 0) return { events: structuredClone(events), range };
|
|
634
|
+
const endTimestamp = firstTimestamp + range.end;
|
|
635
|
+
const withinEnd = events.filter((event) => event.timestamp <= endTimestamp);
|
|
636
|
+
if (!withinEnd.some((event) => event.type === 2))
|
|
637
|
+
throw new Error("\u5F53\u524D\u56DE\u653E\u7A97\u53E3\u65E9\u4E8E\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
638
|
+
const completeEvents = withinEnd.filter((event, index) => {
|
|
639
|
+
if (event.type !== 4) return true;
|
|
640
|
+
for (let next = index + 1; next < withinEnd.length; next += 1) {
|
|
641
|
+
if (withinEnd[next].type === 2) return true;
|
|
642
|
+
if (withinEnd[next].type === 4) break;
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
645
|
+
});
|
|
646
|
+
const copied = structuredClone(completeEvents);
|
|
647
|
+
copied.push({
|
|
648
|
+
type: 5,
|
|
649
|
+
// 官方Custom事件只提供时间调度,不改变页面DOM。
|
|
650
|
+
timestamp: endTimestamp,
|
|
651
|
+
// 请求终点成为官方metadata真实终点,尾部观察时间不缩短。
|
|
652
|
+
data: {
|
|
653
|
+
tag: "adminsmart-replay-boundary",
|
|
654
|
+
// 内部固定标记,不承载业务信息或外部回调。
|
|
655
|
+
payload: null
|
|
656
|
+
// 空载荷不包含用户数据。
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
return { events: copied, range };
|
|
660
|
+
}
|
|
629
661
|
function inclusivePauseOffset(events, target) {
|
|
630
662
|
const logicalTarget = Math.max(0, finiteReplayNumber(target));
|
|
631
663
|
const baseline = finiteReplayNumber(events[0]?.timestamp) + logicalTarget;
|
|
@@ -718,11 +750,13 @@ function useSessionReplay(options) {
|
|
|
718
750
|
publish(initialState("empty"));
|
|
719
751
|
return;
|
|
720
752
|
}
|
|
753
|
+
let playback;
|
|
721
754
|
let prepared;
|
|
722
755
|
try {
|
|
723
|
-
|
|
756
|
+
playback = replayPlaybackWindow(prepareReplayEvents(events), startOffsetMs, endOffsetMs);
|
|
757
|
+
prepared = playback.events;
|
|
724
758
|
} catch (reason) {
|
|
725
|
-
const knownMessages = ["\u5F53\u524D\u56DE\u653E\u6CA1\u6709\u8DB3\u591F\u7684\u9875\u9762\u4E8B\u4EF6", "\u5F53\u524D\u56DE\u653E\u4E8B\u4EF6\u65F6\u95F4\u65E0\u6548\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762", "\u5F53\u524D\u56DE\u653E\u7F3A\u5C11\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762"];
|
|
759
|
+
const knownMessages = ["\u5F53\u524D\u56DE\u653E\u6CA1\u6709\u8DB3\u591F\u7684\u9875\u9762\u4E8B\u4EF6", "\u5F53\u524D\u56DE\u653E\u4E8B\u4EF6\u65F6\u95F4\u65E0\u6548\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762", "\u5F53\u524D\u56DE\u653E\u7F3A\u5C11\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762", "\u5F53\u524D\u56DE\u653E\u7A97\u53E3\u65E9\u4E8E\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762"];
|
|
726
760
|
const problem = { code: "invalid-events", message: reason instanceof Error && knownMessages.includes(reason.message) ? reason.message : "\u5F53\u524D\u56DE\u653E\u6570\u636E\u65E0\u6CD5\u8FD8\u539F\u9875\u9762" };
|
|
727
761
|
publish(initialState("error"));
|
|
728
762
|
callbackRef.current.onError?.(problem);
|
|
@@ -828,7 +862,7 @@ function useSessionReplay(options) {
|
|
|
828
862
|
// 官方日志不会带事件进入控制台。
|
|
829
863
|
});
|
|
830
864
|
engineRef.current = player;
|
|
831
|
-
rangeRef.current =
|
|
865
|
+
rangeRef.current = playback.range;
|
|
832
866
|
const listen = (eventName, handler) => {
|
|
833
867
|
listeners.push([eventName, handler]);
|
|
834
868
|
player.on(eventName, handler);
|