@cloudcare/browser-rum 3.3.5 → 3.3.7
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/README.md +24 -3
- package/README.zh.md +19 -3
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/buildEnv.js.map +1 -1
- package/cjs/boot/perStartRum.js +42 -6
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +190 -195
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/recorderApiStub.js +3 -29
- package/cjs/boot/recorderApiStub.js.map +1 -1
- package/cjs/boot/rum.entry.js.map +1 -1
- package/cjs/boot/rum.js +8 -0
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rum.slim.entry.js.map +1 -1
- package/cjs/boot/rumEntryFactory.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +36 -3
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/rumRecorderApiStub.js.map +1 -1
- package/cjs/boot/rumSlimConfiguration.js.map +1 -1
- package/cjs/boot/sessionReplayPublicApi.js +14 -27
- package/cjs/boot/sessionReplayPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +333 -108
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/constants.js.map +1 -1
- package/cjs/domain/assembly.js +1 -7
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +38 -43
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/commonContext.js.map +1 -1
- package/cjs/domain/contexts/displayContext.js.map +1 -1
- package/cjs/domain/contexts/foregroundContexts.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +20 -2
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +2 -2
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +517 -39
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +194 -115
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/deflate/index.js.map +1 -1
- package/cjs/domain/domMutationObservable.js.map +1 -1
- package/cjs/domain/encoderStreamId.js.map +1 -1
- package/cjs/domain/firstInputPolyfill.js.map +1 -1
- package/cjs/domain/initViewportObservable.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceObservable.js.map +1 -1
- package/cjs/domain/performanceUtils.js.map +1 -1
- package/cjs/domain/plugins.js +67 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandCapture.js +968 -167
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandObserver.js +1058 -119
- package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +61 -37
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasContext.js +63 -0
- package/cjs/domain/replay/record/canvasContext.js.map +1 -0
- package/cjs/domain/replay/record/canvasContinuousScheduler.js +246 -118
- package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeBridge.js +539 -87
- package/cjs/domain/replay/record/canvasEncodeBridge.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +50 -32
- package/cjs/domain/replay/record/canvasEncodeWorker.js.map +1 -1
- package/cjs/domain/replay/record/canvasFrameSignature.js +49 -17
- package/cjs/domain/replay/record/canvasFrameSignature.js.map +1 -1
- package/cjs/domain/replay/record/canvasMutationRecord.js.map +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +295 -59
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js +33 -0
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
- package/cjs/domain/replay/record/elementsScrollPositions.js +3 -0
- package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/cjs/domain/replay/record/index.js.map +1 -1
- package/cjs/domain/replay/record/mutationBatch.js +542 -25
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +1900 -191
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/mutationResourceBudget.js +144 -0
- package/cjs/domain/replay/record/mutationResourceBudget.js.map +1 -0
- package/cjs/domain/replay/record/observers.js +222 -53
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/privacy.js +31 -8
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js +3083 -321
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +426 -26
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +259 -49
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/record/shadowRootsController.js +875 -21
- package/cjs/domain/replay/record/shadowRootsController.js.map +1 -1
- package/cjs/domain/replay/record/utils.js.map +1 -1
- package/cjs/domain/replay/record/viewports.js.map +1 -1
- package/cjs/domain/replay/replayStats.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/index.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +315 -11
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +956 -71
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/startRecordBridge.js.map +1 -1
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +56 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js +196 -0
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +31 -12
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +23 -3
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
- package/cjs/domain/tracing/sampler.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +2 -2
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/cjs/domain/trackEventCounts.js.map +1 -1
- package/cjs/domain/usr/index.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/transport/startRumBatch.js +3 -1
- package/cjs/transport/startRumBatch.js.map +1 -1
- package/cjs/transport/startRumEventBridge.js.map +1 -1
- package/cjs/types/index.js.map +1 -1
- package/cjs/types/sessionReplayConstants.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/buildEnv.js.map +1 -1
- package/esm/boot/perStartRum.js +42 -6
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +192 -197
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/recorderApiStub.js +3 -29
- package/esm/boot/recorderApiStub.js.map +1 -1
- package/esm/boot/rum.entry.js.map +1 -1
- package/esm/boot/rum.js +8 -0
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rum.slim.entry.js.map +1 -1
- package/esm/boot/rumEntryFactory.js.map +1 -1
- package/esm/boot/rumPublicApi.js +36 -3
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/rumRecorderApiStub.js.map +1 -1
- package/esm/boot/rumSlimConfiguration.js.map +1 -1
- package/esm/boot/sessionReplayPublicApi.js +14 -27
- package/esm/boot/sessionReplayPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +334 -109
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/constants.js.map +1 -1
- package/esm/domain/assembly.js +1 -7
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +39 -44
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/commonContext.js.map +1 -1
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/contexts/foregroundContexts.js.map +1 -1
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +21 -3
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +2 -2
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js +517 -39
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +193 -116
- package/esm/domain/deflate/deflateWorker.js.map +1 -1
- package/esm/domain/deflate/index.js.map +1 -1
- package/esm/domain/domMutationObservable.js.map +1 -1
- package/esm/domain/encoderStreamId.js.map +1 -1
- package/esm/domain/firstInputPolyfill.js.map +1 -1
- package/esm/domain/initViewportObservable.js.map +1 -1
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceObservable.js.map +1 -1
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/plugins.js +59 -0
- package/esm/domain/plugins.js.map +1 -0
- package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +968 -168
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserver.js +1058 -119
- package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +60 -37
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +50 -0
- package/esm/domain/replay/record/canvasContext.js.map +1 -0
- package/esm/domain/replay/record/canvasContinuousScheduler.js +246 -118
- package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeBridge.js +539 -87
- package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +51 -33
- package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -1
- package/esm/domain/replay/record/canvasFrameSignature.js +50 -17
- package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -1
- package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -1
- package/esm/domain/replay/record/canvasObserver.js +295 -59
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasWebGLPluginHost.js +26 -0
- package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
- package/esm/domain/replay/record/elementsScrollPositions.js +3 -0
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/esm/domain/replay/record/index.js.map +1 -1
- package/esm/domain/replay/record/mutationBatch.js +541 -25
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +1892 -195
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationResourceBudget.js +137 -0
- package/esm/domain/replay/record/mutationResourceBudget.js.map +1 -0
- package/esm/domain/replay/record/observers.js +224 -55
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +30 -7
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js +3086 -325
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +422 -25
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +258 -50
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/record/shadowRootsController.js +875 -21
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
- package/esm/domain/replay/record/utils.js.map +1 -1
- package/esm/domain/replay/record/viewports.js.map +1 -1
- package/esm/domain/replay/replayStats.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/esm/domain/replay/segmentCollection/index.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segment.js +315 -10
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +957 -72
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/startRecordBridge.js.map +1 -1
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +55 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +189 -0
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +32 -13
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/rumSessionManager.js +24 -4
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/sampler.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/traceIdentifier.js.map +1 -1
- package/esm/domain/tracing/tracer.js +2 -2
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/usr/index.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/transport/startRumBatch.js +4 -2
- package/esm/transport/startRumBatch.js.map +1 -1
- package/esm/transport/startRumEventBridge.js.map +1 -1
- package/esm/types/index.js.map +1 -1
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +12 -7
- package/src/boot/perStartRum.js +47 -7
- package/src/boot/recorderApi.js +271 -220
- package/src/boot/recorderApiStub.js +3 -29
- package/src/boot/rum.js +11 -0
- package/src/boot/rumPublicApi.js +38 -3
- package/src/boot/sessionReplayPublicApi.js +15 -28
- package/src/boot/startRecording.js +429 -146
- package/src/domain/assembly.js +5 -4
- package/src/domain/configuration.js +76 -101
- package/src/domain/contexts/urlContexts.js +29 -3
- package/src/domain/contexts/viewContexts.js +2 -2
- package/src/domain/deflate/deflateEncoder.js +699 -43
- package/src/domain/deflate/deflateWorker.js +237 -136
- package/src/domain/plugins.js +94 -0
- package/src/domain/replay/record/canvasCommandCapture.js +1374 -180
- package/src/domain/replay/record/canvasCommandObserver.js +1585 -150
- package/src/domain/replay/record/canvasCommandSerializeArgs.js +79 -42
- package/src/domain/replay/record/canvasContext.js +67 -0
- package/src/domain/replay/record/canvasContinuousScheduler.js +379 -143
- package/src/domain/replay/record/canvasEncodeBridge.js +691 -106
- package/src/domain/replay/record/canvasEncodeWorker.js +67 -43
- package/src/domain/replay/record/canvasFrameSignature.js +58 -24
- package/src/domain/replay/record/canvasObserver.js +461 -89
- package/src/domain/replay/record/canvasWebGLPluginHost.js +43 -0
- package/src/domain/replay/record/elementsScrollPositions.js +3 -0
- package/src/domain/replay/record/mutationBatch.js +761 -27
- package/src/domain/replay/record/mutationObserver.js +2992 -261
- package/src/domain/replay/record/mutationResourceBudget.js +191 -0
- package/src/domain/replay/record/observers.js +367 -97
- package/src/domain/replay/record/privacy.js +34 -12
- package/src/domain/replay/record/record.js +4284 -413
- package/src/domain/replay/record/serializationUtils.js +587 -28
- package/src/domain/replay/record/serialize.js +432 -66
- package/src/domain/replay/record/shadowRootsController.js +1108 -30
- package/src/domain/replay/segmentCollection/segment.js +441 -11
- package/src/domain/replay/segmentCollection/segmentCollection.js +1300 -77
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +70 -0
- package/src/domain/rumEventsCollection/resource/webSocketCollection.js +271 -0
- package/src/domain/rumEventsCollection/view/trackLoadingTime.js +12 -3
- package/src/domain/rumEventsCollection/view/trackViews.js +38 -13
- package/src/domain/rumSessionManager.js +33 -2
- package/src/domain/tracing/tracer.js +4 -5
- package/src/transport/startRumBatch.js +6 -1
- package/types/index.d.ts +100 -8
- package/cjs/domain/replay/record/canvasReplayFixtures.js +0 -105
- package/cjs/domain/replay/record/canvasReplayFixtures.js.map +0 -1
- package/esm/domain/replay/record/canvasReplayFixtures.js +0 -96
- package/esm/domain/replay/record/canvasReplayFixtures.js.map +0 -1
- package/src/domain/replay/record/canvasReplayFixtures.js +0 -113
|
@@ -1,49 +1,783 @@
|
|
|
1
1
|
import { noop, throttle, requestIdleCallback } from '@cloudcare/browser-core'
|
|
2
|
+
import { MUTATION_RESOURCE_RAW } from './mutationResourceBudget'
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
|
|
5
|
-
* processed more quickly. If the browser is busy executing small tasks (ex: rendering frames), the
|
|
6
|
-
* mutations will wait MUTATION_PROCESS_MAX_DELAY milliseconds before being processed. If the
|
|
7
|
-
* browser is busy executing a longer task, mutations will be processed after this task.
|
|
8
|
-
*/
|
|
9
4
|
var MUTATION_PROCESS_MAX_DELAY = 120
|
|
10
5
|
export var MUTATION_PROCESS_MIN_DELAY = 48
|
|
11
|
-
export
|
|
6
|
+
export var MAX_PENDING_MUTATION_RECORDS = 256
|
|
7
|
+
export var MAX_PENDING_MUTATION_NODES = 1000
|
|
8
|
+
export var MAX_PENDING_MUTATION_APPROX_BYTES = 256 * 1024
|
|
9
|
+
export var MUTATION_CHUNK_MAX_RECORDS = 64
|
|
10
|
+
// Keep add-heavy normalization below the operation grace used by
|
|
11
|
+
// mutationObserver. A wider pending batch is preserved as one transaction, but
|
|
12
|
+
// normalized over several bounded tasks so a short GC/renderer interruption
|
|
13
|
+
// cannot turn unpublished additions into mandatory FullSnapshot recovery.
|
|
14
|
+
export var MUTATION_CHUNK_MAX_NODES = 32
|
|
15
|
+
export var MUTATION_CHUNK_MAX_APPROX_BYTES = 64 * 1024
|
|
16
|
+
export var MAX_QUEUED_MUTATION_RECORDS = 4096
|
|
17
|
+
export var MAX_QUEUED_MUTATION_NODES = 16384
|
|
18
|
+
export var MAX_QUEUED_MUTATION_APPROX_BYTES = 8 * 1024 * 1024
|
|
19
|
+
var MUTATION_FLUSH_BUDGET_MS = 4
|
|
20
|
+
|
|
21
|
+
export function createMutationBatch(
|
|
22
|
+
processMutationBatch,
|
|
23
|
+
onOverflow,
|
|
24
|
+
mutationResourceBudget
|
|
25
|
+
) {
|
|
12
26
|
var cancelScheduledFlush = noop
|
|
27
|
+
var continuationTimeout
|
|
13
28
|
var pendingMutations = []
|
|
29
|
+
var pendingMutationNodes = 0
|
|
30
|
+
var pendingMutationApproxBytes = 0
|
|
31
|
+
var pendingMutationDirectNodes = 0
|
|
32
|
+
var pendingNativeCallbackCount = 0
|
|
33
|
+
var pendingMutationReservations = []
|
|
34
|
+
var workQueue = []
|
|
35
|
+
var queuedMutationRecords = 0
|
|
36
|
+
var queuedMutationNodes = 0
|
|
37
|
+
var queuedMutationApproxBytes = 0
|
|
38
|
+
var stopped = false
|
|
39
|
+
var coalescedTextReplacementByRemovedNode = new WeakMap()
|
|
40
|
+
|
|
41
|
+
var throttled = throttle(flush, MUTATION_PROCESS_MIN_DELAY, {
|
|
42
|
+
leading: false
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
function scheduleInitialFlush() {
|
|
46
|
+
if (cancelScheduledFlush !== noop) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
cancelScheduledFlush = requestIdleCallback(throttled.throttled, {
|
|
50
|
+
timeout: MUTATION_PROCESS_MAX_DELAY
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function scheduleContinuation() {
|
|
55
|
+
if (
|
|
56
|
+
continuationTimeout !== undefined ||
|
|
57
|
+
stopped ||
|
|
58
|
+
!workQueue.length
|
|
59
|
+
) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
continuationTimeout = setTimeout(function () {
|
|
63
|
+
continuationTimeout = undefined
|
|
64
|
+
drainOneChunk()
|
|
65
|
+
scheduleContinuation()
|
|
66
|
+
}, 0)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function enqueuePending() {
|
|
70
|
+
if (!pendingMutations.length) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
var work = {
|
|
74
|
+
$rMutations: pendingMutations,
|
|
75
|
+
$rMeasurement: {
|
|
76
|
+
mutationRecordCount: pendingMutations.length,
|
|
77
|
+
nodeCount: pendingMutationNodes,
|
|
78
|
+
approxBytes: pendingMutationApproxBytes
|
|
79
|
+
},
|
|
80
|
+
directNodeCount: pendingMutationDirectNodes,
|
|
81
|
+
nativeCallbackCount: pendingNativeCallbackCount,
|
|
82
|
+
reservations: pendingMutationReservations
|
|
83
|
+
}
|
|
84
|
+
enqueueMutationWork(work)
|
|
85
|
+
pendingMutations = []
|
|
86
|
+
pendingMutationNodes = 0
|
|
87
|
+
pendingMutationApproxBytes = 0
|
|
88
|
+
pendingMutationDirectNodes = 0
|
|
89
|
+
pendingNativeCallbackCount = 0
|
|
90
|
+
pendingMutationReservations = []
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function enqueueMutationWork(work) {
|
|
94
|
+
work.$rTextReplacementByRemovedNode =
|
|
95
|
+
coalescedTextReplacementByRemovedNode
|
|
96
|
+
if (shouldChunkMutationWork(work)) {
|
|
97
|
+
initializeChunkedWork(work)
|
|
98
|
+
}
|
|
99
|
+
enqueueWork(work)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function enqueueWork(work) {
|
|
103
|
+
workQueue.push(work)
|
|
104
|
+
queuedMutationRecords += work.$rMeasurement.mutationRecordCount
|
|
105
|
+
queuedMutationNodes += work.$rMeasurement.nodeCount
|
|
106
|
+
queuedMutationApproxBytes += work.$rMeasurement.approxBytes
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function releaseWork(work) {
|
|
110
|
+
queuedMutationRecords -= work.$rMeasurement.mutationRecordCount
|
|
111
|
+
queuedMutationNodes -= work.$rMeasurement.nodeCount
|
|
112
|
+
queuedMutationApproxBytes -= work.$rMeasurement.approxBytes
|
|
113
|
+
releaseReservations(work.reservations)
|
|
114
|
+
if (!workQueue.length && !pendingMutations.length) {
|
|
115
|
+
coalescedTextReplacementByRemovedNode = new WeakMap()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
14
118
|
|
|
15
119
|
function flush() {
|
|
16
120
|
cancelScheduledFlush()
|
|
17
|
-
|
|
121
|
+
cancelScheduledFlush = noop
|
|
122
|
+
throttled.cancel()
|
|
123
|
+
enqueuePending()
|
|
124
|
+
var deadline = getCurrentTime() + MUTATION_FLUSH_BUDGET_MS
|
|
125
|
+
var succeeded = true
|
|
126
|
+
do {
|
|
127
|
+
if (!drainOneChunk()) {
|
|
128
|
+
succeeded = false
|
|
129
|
+
break
|
|
130
|
+
}
|
|
131
|
+
} while (workQueue.length && getCurrentTime() < deadline)
|
|
132
|
+
if (!succeeded) {
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
135
|
+
if (workQueue.length) {
|
|
136
|
+
scheduleContinuation()
|
|
137
|
+
return 'pending'
|
|
138
|
+
}
|
|
139
|
+
return true
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function drainOneChunk() {
|
|
143
|
+
if (stopped || !workQueue.length) {
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
var work = workQueue[0]
|
|
147
|
+
if (work.recordIndex === undefined) {
|
|
148
|
+
workQueue.shift()
|
|
149
|
+
releaseWork(work)
|
|
150
|
+
var batchSucceeded = process(
|
|
151
|
+
work.$rMutations,
|
|
152
|
+
createBatchContext(work)
|
|
153
|
+
)
|
|
154
|
+
if (!batchSucceeded) {
|
|
155
|
+
reset()
|
|
156
|
+
}
|
|
157
|
+
return batchSucceeded
|
|
158
|
+
}
|
|
159
|
+
var chunk = takeChunk(work)
|
|
160
|
+
var isLast = work.$rTransaction.$rPureAdd
|
|
161
|
+
? work.recordIndex < 0
|
|
162
|
+
: work.recordIndex >= work.$rMutations.length
|
|
163
|
+
var succeeded = process(
|
|
164
|
+
chunk,
|
|
165
|
+
createBatchContext(work, work.$rTransaction, isLast)
|
|
166
|
+
)
|
|
167
|
+
if (workQueue[0] !== work) {
|
|
168
|
+
// Recovery callbacks may synchronously reset the whole batch. The old
|
|
169
|
+
// work has already been released in that case; do not shift/release it
|
|
170
|
+
// a second time or let a stale successful return escape.
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
173
|
+
if (!succeeded || isLast) {
|
|
174
|
+
workQueue.shift()
|
|
175
|
+
releaseWork(work)
|
|
176
|
+
}
|
|
177
|
+
if (!succeeded) {
|
|
178
|
+
// Recovery supersedes the whole queued generation. Do not let a later
|
|
179
|
+
// callback escape after the failed atomic transaction.
|
|
180
|
+
reset()
|
|
181
|
+
}
|
|
182
|
+
return succeeded
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function process(mutations, batchContext) {
|
|
186
|
+
try {
|
|
187
|
+
var result = processMutationBatch(mutations, batchContext)
|
|
188
|
+
return batchContext.transaction
|
|
189
|
+
? result === true
|
|
190
|
+
: result !== false
|
|
191
|
+
} catch (_) {
|
|
192
|
+
if (onOverflow) {
|
|
193
|
+
onOverflow({
|
|
194
|
+
reason: 'mutation_processing_error',
|
|
195
|
+
mutationRecordCount: mutations.length
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
return false
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function reset() {
|
|
203
|
+
cancelScheduledFlush()
|
|
204
|
+
cancelScheduledFlush = noop
|
|
205
|
+
throttled.cancel()
|
|
206
|
+
if (continuationTimeout !== undefined) {
|
|
207
|
+
clearTimeout(continuationTimeout)
|
|
208
|
+
continuationTimeout = undefined
|
|
209
|
+
}
|
|
210
|
+
releaseReservations(pendingMutationReservations)
|
|
211
|
+
workQueue.forEach(function (work) {
|
|
212
|
+
releaseReservations(work.reservations)
|
|
213
|
+
})
|
|
18
214
|
pendingMutations = []
|
|
215
|
+
pendingMutationNodes = 0
|
|
216
|
+
pendingMutationApproxBytes = 0
|
|
217
|
+
pendingMutationDirectNodes = 0
|
|
218
|
+
pendingNativeCallbackCount = 0
|
|
219
|
+
pendingMutationReservations = []
|
|
220
|
+
workQueue = []
|
|
221
|
+
queuedMutationRecords = 0
|
|
222
|
+
queuedMutationNodes = 0
|
|
223
|
+
queuedMutationApproxBytes = 0
|
|
224
|
+
coalescedTextReplacementByRemovedNode = new WeakMap()
|
|
19
225
|
}
|
|
20
|
-
|
|
21
|
-
var _throttled = throttle(flush, MUTATION_PROCESS_MIN_DELAY, {
|
|
22
|
-
leading: false
|
|
23
|
-
})
|
|
24
|
-
var throttledFlush = _throttled.throttled
|
|
25
|
-
var cancelThrottle = _throttled.cancel
|
|
226
|
+
|
|
26
227
|
return {
|
|
27
228
|
addMutations: function (mutations) {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
229
|
+
if (!mutations.length || stopped) {
|
|
230
|
+
return true
|
|
231
|
+
}
|
|
232
|
+
var queuedMeasurement = measureMutationsUntilLimit(
|
|
233
|
+
mutations,
|
|
234
|
+
MAX_QUEUED_MUTATION_NODES -
|
|
235
|
+
queuedMutationNodes -
|
|
236
|
+
pendingMutationNodes,
|
|
237
|
+
MAX_QUEUED_MUTATION_APPROX_BYTES -
|
|
238
|
+
queuedMutationApproxBytes -
|
|
239
|
+
pendingMutationApproxBytes
|
|
240
|
+
)
|
|
241
|
+
if (
|
|
242
|
+
queuedMutationRecords +
|
|
243
|
+
pendingMutations.length +
|
|
244
|
+
mutations.length >
|
|
245
|
+
MAX_QUEUED_MUTATION_RECORDS ||
|
|
246
|
+
queuedMutationNodes +
|
|
247
|
+
pendingMutationNodes +
|
|
248
|
+
queuedMeasurement.nodeCount >
|
|
249
|
+
MAX_QUEUED_MUTATION_NODES ||
|
|
250
|
+
queuedMutationApproxBytes +
|
|
251
|
+
pendingMutationApproxBytes +
|
|
252
|
+
queuedMeasurement.approxBytes >
|
|
253
|
+
MAX_QUEUED_MUTATION_APPROX_BYTES
|
|
254
|
+
) {
|
|
255
|
+
reset()
|
|
256
|
+
if (onOverflow) {
|
|
257
|
+
onOverflow({
|
|
258
|
+
reason: 'raw_mutation_queue_watermark',
|
|
259
|
+
mutationRecordCount: mutations.length,
|
|
260
|
+
mutationNodeCount: queuedMeasurement.nodeCount,
|
|
261
|
+
mutationApproxBytes: queuedMeasurement.approxBytes
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
return false
|
|
265
|
+
}
|
|
266
|
+
var mutationResourceReservation
|
|
267
|
+
if (mutationResourceBudget) {
|
|
268
|
+
mutationResourceReservation = mutationResourceBudget.reserve(
|
|
269
|
+
MUTATION_RESOURCE_RAW,
|
|
270
|
+
{
|
|
271
|
+
recordCount: mutations.length,
|
|
272
|
+
nodeCount: queuedMeasurement.nodeCount,
|
|
273
|
+
approxBytes: queuedMeasurement.approxBytes
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
if (!mutationResourceReservation) {
|
|
277
|
+
reset()
|
|
278
|
+
if (onOverflow) {
|
|
279
|
+
onOverflow({
|
|
280
|
+
reason: 'aggregate_raw_mutation_watermark',
|
|
281
|
+
mutationRecordCount: mutations.length,
|
|
282
|
+
mutationNodeCount: queuedMeasurement.nodeCount,
|
|
283
|
+
mutationApproxBytes: queuedMeasurement.approxBytes
|
|
284
|
+
})
|
|
285
|
+
}
|
|
286
|
+
return false
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
var directNodeCount = countDirectMutationNodes(mutations)
|
|
290
|
+
var canStorePending =
|
|
291
|
+
!workQueue.length &&
|
|
292
|
+
(!pendingMutations.length ||
|
|
293
|
+
canMergePendingCallback(
|
|
294
|
+
mutations.length,
|
|
295
|
+
queuedMeasurement,
|
|
296
|
+
directNodeCount
|
|
297
|
+
))
|
|
298
|
+
if (canStorePending) {
|
|
299
|
+
if (!pendingMutations.length) {
|
|
300
|
+
scheduleInitialFlush()
|
|
301
|
+
}
|
|
302
|
+
Array.prototype.push.apply(pendingMutations, mutations)
|
|
303
|
+
if (mutationResourceReservation) {
|
|
304
|
+
pendingMutationReservations.push(
|
|
305
|
+
mutationResourceReservation
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
pendingMutationNodes += queuedMeasurement.nodeCount
|
|
309
|
+
pendingMutationApproxBytes += queuedMeasurement.approxBytes
|
|
310
|
+
pendingMutationDirectNodes += directNodeCount
|
|
311
|
+
pendingNativeCallbackCount += 1
|
|
312
|
+
} else {
|
|
313
|
+
enqueuePending()
|
|
314
|
+
enqueueMutationWork({
|
|
315
|
+
$rMutations: mutations,
|
|
316
|
+
$rMeasurement: {
|
|
317
|
+
mutationRecordCount: mutations.length,
|
|
318
|
+
nodeCount: queuedMeasurement.nodeCount,
|
|
319
|
+
approxBytes: queuedMeasurement.approxBytes
|
|
320
|
+
},
|
|
321
|
+
directNodeCount: directNodeCount,
|
|
322
|
+
nativeCallbackCount: 1,
|
|
323
|
+
reservations: mutationResourceReservation
|
|
324
|
+
? [mutationResourceReservation]
|
|
325
|
+
: []
|
|
31
326
|
})
|
|
327
|
+
scheduleContinuation()
|
|
32
328
|
}
|
|
33
|
-
|
|
329
|
+
return true
|
|
34
330
|
},
|
|
35
|
-
|
|
36
331
|
flush: flush,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
cancelThrottle()
|
|
41
|
-
pendingMutations = []
|
|
332
|
+
reset: reset,
|
|
333
|
+
hasPending: function () {
|
|
334
|
+
return Boolean(pendingMutations.length || workQueue.length)
|
|
42
335
|
},
|
|
43
|
-
|
|
44
336
|
stop: function () {
|
|
45
|
-
|
|
46
|
-
|
|
337
|
+
stopped = true
|
|
338
|
+
reset()
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function canMergePendingCallback(
|
|
343
|
+
mutationRecordCount,
|
|
344
|
+
measurement,
|
|
345
|
+
directNodeCount
|
|
346
|
+
) {
|
|
347
|
+
return (
|
|
348
|
+
pendingMutationDirectNodes + directNodeCount <=
|
|
349
|
+
MUTATION_CHUNK_MAX_NODES &&
|
|
350
|
+
pendingMutations.length + mutationRecordCount <=
|
|
351
|
+
MAX_PENDING_MUTATION_RECORDS &&
|
|
352
|
+
pendingMutationNodes + measurement.nodeCount <=
|
|
353
|
+
MAX_PENDING_MUTATION_NODES &&
|
|
354
|
+
pendingMutationApproxBytes + measurement.approxBytes <=
|
|
355
|
+
MAX_PENDING_MUTATION_APPROX_BYTES
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function initializeChunkedWork(work) {
|
|
361
|
+
var isPureAdd =
|
|
362
|
+
work.nativeCallbackCount === 1 &&
|
|
363
|
+
isReverseChunkableSiblingAddWork(work.$rMutations)
|
|
364
|
+
work.$rTransaction = {
|
|
365
|
+
$rPureAdd: isPureAdd
|
|
366
|
+
}
|
|
367
|
+
work.recordIndex = isPureAdd ? work.$rMutations.length - 1 : 0
|
|
368
|
+
work.addedIndex = isPureAdd
|
|
369
|
+
? getNodeListLength(work.$rMutations[work.recordIndex].addedNodes)
|
|
370
|
+
: 0
|
|
371
|
+
work.removedIndex = 0
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function createBatchContext(work, transaction, isLast) {
|
|
375
|
+
return {
|
|
376
|
+
transaction: transaction,
|
|
377
|
+
isLast: isLast,
|
|
378
|
+
$rTextReplacementByRemovedNode:
|
|
379
|
+
work.$rTextReplacementByRemovedNode
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function hasStructuralRemoval(mutations) {
|
|
384
|
+
for (var index = 0; index < mutations.length; index += 1) {
|
|
385
|
+
if (
|
|
386
|
+
mutations[index].type === 'childList' &&
|
|
387
|
+
getNodeListLength(mutations[index].removedNodes)
|
|
388
|
+
) {
|
|
389
|
+
return true
|
|
47
390
|
}
|
|
48
391
|
}
|
|
392
|
+
return false
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function shouldChunkMutationWork(work) {
|
|
396
|
+
return (
|
|
397
|
+
(work.nativeCallbackCount === 1 &&
|
|
398
|
+
work.directNodeCount >= MUTATION_CHUNK_MAX_NODES &&
|
|
399
|
+
!hasStructuralRemoval(work.$rMutations)) ||
|
|
400
|
+
work.$rMeasurement.mutationRecordCount >
|
|
401
|
+
MAX_PENDING_MUTATION_RECORDS ||
|
|
402
|
+
work.$rMeasurement.nodeCount > MAX_PENDING_MUTATION_NODES ||
|
|
403
|
+
work.$rMeasurement.approxBytes > MAX_PENDING_MUTATION_APPROX_BYTES
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function isReverseChunkableSiblingAddWork(mutations) {
|
|
408
|
+
var hasAdd = false
|
|
409
|
+
var target
|
|
410
|
+
var addedNodeSet = new Set()
|
|
411
|
+
var previousAddedNode
|
|
412
|
+
for (var index = 0; index < mutations.length; index += 1) {
|
|
413
|
+
var mutation = mutations[index]
|
|
414
|
+
if (
|
|
415
|
+
mutation.type !== 'childList' ||
|
|
416
|
+
getNodeListLength(mutation.removedNodes)
|
|
417
|
+
) {
|
|
418
|
+
return false
|
|
419
|
+
}
|
|
420
|
+
if (target === undefined) {
|
|
421
|
+
target = mutation.target
|
|
422
|
+
} else if (mutation.target !== target) {
|
|
423
|
+
return false
|
|
424
|
+
}
|
|
425
|
+
for (
|
|
426
|
+
var addedIndex = 0;
|
|
427
|
+
addedIndex < getNodeListLength(mutation.addedNodes);
|
|
428
|
+
addedIndex += 1
|
|
429
|
+
) {
|
|
430
|
+
var addedNode = mutation.addedNodes[addedIndex]
|
|
431
|
+
if (
|
|
432
|
+
!target ||
|
|
433
|
+
addedNodeSet.has(addedNode) ||
|
|
434
|
+
addedNode.parentNode !== target ||
|
|
435
|
+
(previousAddedNode &&
|
|
436
|
+
!isFollowingSibling(previousAddedNode, addedNode))
|
|
437
|
+
) {
|
|
438
|
+
return false
|
|
439
|
+
}
|
|
440
|
+
addedNodeSet.add(addedNode)
|
|
441
|
+
previousAddedNode = addedNode
|
|
442
|
+
hasAdd = true
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return hasAdd
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function isFollowingSibling(previousNode, node) {
|
|
449
|
+
if (typeof previousNode.compareDocumentPosition !== 'function') {
|
|
450
|
+
return false
|
|
451
|
+
}
|
|
452
|
+
/* eslint-disable no-bitwise */
|
|
453
|
+
return Boolean(
|
|
454
|
+
previousNode.compareDocumentPosition(node) &
|
|
455
|
+
Node.DOCUMENT_POSITION_FOLLOWING
|
|
456
|
+
)
|
|
457
|
+
/* eslint-enable no-bitwise */
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function countDirectMutationNodes(mutations) {
|
|
461
|
+
var nodeCount = 0
|
|
462
|
+
for (var index = 0; index < mutations.length; index += 1) {
|
|
463
|
+
var mutation = mutations[index]
|
|
464
|
+
if (mutation.type === 'childList') {
|
|
465
|
+
nodeCount +=
|
|
466
|
+
getNodeListLength(mutation.addedNodes) +
|
|
467
|
+
getNodeListLength(mutation.removedNodes)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return nodeCount
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function releaseReservations(reservations) {
|
|
474
|
+
if (!reservations) {
|
|
475
|
+
return
|
|
476
|
+
}
|
|
477
|
+
reservations.forEach(function (release) {
|
|
478
|
+
release()
|
|
479
|
+
})
|
|
480
|
+
reservations.length = 0
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function takeChunk(work) {
|
|
484
|
+
if (work.$rTransaction.$rPureAdd) {
|
|
485
|
+
return takePureAddChunk(work)
|
|
486
|
+
}
|
|
487
|
+
var chunk = []
|
|
488
|
+
var nodeCount = 0
|
|
489
|
+
var approxBytes = 0
|
|
490
|
+
while (
|
|
491
|
+
work.recordIndex < work.$rMutations.length &&
|
|
492
|
+
chunk.length < MUTATION_CHUNK_MAX_RECORDS
|
|
493
|
+
) {
|
|
494
|
+
var mutation = work.$rMutations[work.recordIndex]
|
|
495
|
+
var synthetic = mutation
|
|
496
|
+
var isChildList = mutation.type === 'childList'
|
|
497
|
+
var nextAddedIndex = work.addedIndex
|
|
498
|
+
var nextRemovedIndex = work.removedIndex
|
|
499
|
+
var completesChildList = false
|
|
500
|
+
if (mutation.type === 'childList') {
|
|
501
|
+
var addedNodeCount = getNodeListLength(mutation.addedNodes)
|
|
502
|
+
var removedNodeCount = getNodeListLength(mutation.removedNodes)
|
|
503
|
+
var keepStructuralMutationWhole =
|
|
504
|
+
removedNodeCount > 0 &&
|
|
505
|
+
addedNodeCount + removedNodeCount < MAX_PENDING_MUTATION_NODES
|
|
506
|
+
if (keepStructuralMutationWhole) {
|
|
507
|
+
var structuralMeasurement = measureMutation(mutation)
|
|
508
|
+
if (
|
|
509
|
+
chunk.length &&
|
|
510
|
+
(nodeCount + structuralMeasurement.nodeCount >
|
|
511
|
+
MUTATION_CHUNK_MAX_NODES ||
|
|
512
|
+
approxBytes + structuralMeasurement.approxBytes >
|
|
513
|
+
MUTATION_CHUNK_MAX_APPROX_BYTES)
|
|
514
|
+
) {
|
|
515
|
+
// A remove/add pair is one replay-tree transition. If it cannot fit
|
|
516
|
+
// at the tail of this chunk, move the complete native record to the
|
|
517
|
+
// next chunk instead of splitting the two structural sides.
|
|
518
|
+
break
|
|
519
|
+
}
|
|
520
|
+
synthetic = {
|
|
521
|
+
type: 'childList',
|
|
522
|
+
target: mutation.target,
|
|
523
|
+
addedNodes: Array.prototype.slice.call(mutation.addedNodes),
|
|
524
|
+
removedNodes: Array.prototype.slice.call(mutation.removedNodes),
|
|
525
|
+
previousSibling: mutation.previousSibling,
|
|
526
|
+
nextSibling: mutation.nextSibling
|
|
527
|
+
}
|
|
528
|
+
nextAddedIndex = addedNodeCount
|
|
529
|
+
nextRemovedIndex = removedNodeCount
|
|
530
|
+
completesChildList = true
|
|
531
|
+
} else {
|
|
532
|
+
// A large native remove+add record is normalized in bounded slices but
|
|
533
|
+
// admitted as one mutation group by mutationObserver. Consume removals
|
|
534
|
+
// first so every later add slice can inherit whether the native record
|
|
535
|
+
// removed a published node. This preserves the fail-closed replacement
|
|
536
|
+
// dependency without synchronously scanning the whole NodeList.
|
|
537
|
+
var structuralState =
|
|
538
|
+
removedNodeCount > 0
|
|
539
|
+
? getStructuralMutationState(work, work.recordIndex)
|
|
540
|
+
: undefined
|
|
541
|
+
var remainingNodes = Math.max(
|
|
542
|
+
Math.min(
|
|
543
|
+
MUTATION_CHUNK_MAX_NODES - nodeCount - 1,
|
|
544
|
+
Math.floor(
|
|
545
|
+
(MUTATION_CHUNK_MAX_APPROX_BYTES -
|
|
546
|
+
approxBytes -
|
|
547
|
+
32) /
|
|
548
|
+
16
|
|
549
|
+
)
|
|
550
|
+
),
|
|
551
|
+
1
|
|
552
|
+
)
|
|
553
|
+
var removedNodes = structuralState
|
|
554
|
+
? Array.prototype.slice.call(
|
|
555
|
+
mutation.removedNodes,
|
|
556
|
+
work.removedIndex,
|
|
557
|
+
work.removedIndex + remainingNodes
|
|
558
|
+
)
|
|
559
|
+
: []
|
|
560
|
+
remainingNodes -= removedNodes.length
|
|
561
|
+
var addedNodes = Array.prototype.slice.call(
|
|
562
|
+
mutation.addedNodes,
|
|
563
|
+
work.addedIndex,
|
|
564
|
+
work.addedIndex + remainingNodes
|
|
565
|
+
)
|
|
566
|
+
remainingNodes -= addedNodes.length
|
|
567
|
+
if (!structuralState) {
|
|
568
|
+
removedNodes = Array.prototype.slice.call(
|
|
569
|
+
mutation.removedNodes,
|
|
570
|
+
work.removedIndex,
|
|
571
|
+
work.removedIndex + remainingNodes
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
synthetic = {
|
|
575
|
+
type: 'childList',
|
|
576
|
+
target: mutation.target,
|
|
577
|
+
addedNodes: addedNodes,
|
|
578
|
+
removedNodes: removedNodes,
|
|
579
|
+
previousSibling: mutation.previousSibling,
|
|
580
|
+
nextSibling: mutation.nextSibling,
|
|
581
|
+
$rStructuralState: structuralState
|
|
582
|
+
}
|
|
583
|
+
nextAddedIndex += addedNodes.length
|
|
584
|
+
nextRemovedIndex += removedNodes.length
|
|
585
|
+
completesChildList =
|
|
586
|
+
nextAddedIndex >= addedNodeCount &&
|
|
587
|
+
nextRemovedIndex >= removedNodeCount
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
synthetic = cloneMutationRecord(mutation)
|
|
591
|
+
work.recordIndex += 1
|
|
592
|
+
}
|
|
593
|
+
var measurement = measureMutation(synthetic)
|
|
594
|
+
if (
|
|
595
|
+
chunk.length &&
|
|
596
|
+
(nodeCount + measurement.nodeCount > MUTATION_CHUNK_MAX_NODES ||
|
|
597
|
+
approxBytes + measurement.approxBytes >
|
|
598
|
+
MUTATION_CHUNK_MAX_APPROX_BYTES)
|
|
599
|
+
) {
|
|
600
|
+
// The cursor is committed only after the synthetic record fits. This is
|
|
601
|
+
// important at an exact boundary: advancing a child-list cursor before
|
|
602
|
+
// this check would silently drop the rejected slice.
|
|
603
|
+
if (!isChildList) {
|
|
604
|
+
work.recordIndex -= 1
|
|
605
|
+
}
|
|
606
|
+
break
|
|
607
|
+
}
|
|
608
|
+
if (isChildList) {
|
|
609
|
+
if (completesChildList) {
|
|
610
|
+
work.recordIndex += 1
|
|
611
|
+
work.addedIndex = 0
|
|
612
|
+
work.removedIndex = 0
|
|
613
|
+
} else {
|
|
614
|
+
work.addedIndex = nextAddedIndex
|
|
615
|
+
work.removedIndex = nextRemovedIndex
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
chunk.push(synthetic)
|
|
619
|
+
nodeCount += measurement.nodeCount
|
|
620
|
+
approxBytes += measurement.approxBytes
|
|
621
|
+
if (
|
|
622
|
+
nodeCount >= MUTATION_CHUNK_MAX_NODES ||
|
|
623
|
+
approxBytes >= MUTATION_CHUNK_MAX_APPROX_BYTES
|
|
624
|
+
) {
|
|
625
|
+
break
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return chunk
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function getStructuralMutationState(work, recordIndex) {
|
|
632
|
+
if (!work.$rStructuralStateByRecordIndex) {
|
|
633
|
+
work.$rStructuralStateByRecordIndex = []
|
|
634
|
+
}
|
|
635
|
+
var structuralState = work.$rStructuralStateByRecordIndex[recordIndex]
|
|
636
|
+
if (!structuralState) {
|
|
637
|
+
structuralState = { $rHasPublishedRemoval: false }
|
|
638
|
+
work.$rStructuralStateByRecordIndex[recordIndex] = structuralState
|
|
639
|
+
}
|
|
640
|
+
return structuralState
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function takePureAddChunk(work) {
|
|
644
|
+
var chunk = []
|
|
645
|
+
var nodeCount = 0
|
|
646
|
+
var approxBytes = 0
|
|
647
|
+
while (
|
|
648
|
+
work.recordIndex >= 0 &&
|
|
649
|
+
chunk.length < MUTATION_CHUNK_MAX_RECORDS
|
|
650
|
+
) {
|
|
651
|
+
while (work.recordIndex >= 0 && work.addedIndex === 0) {
|
|
652
|
+
work.recordIndex -= 1
|
|
653
|
+
work.addedIndex =
|
|
654
|
+
work.recordIndex >= 0
|
|
655
|
+
? getNodeListLength(
|
|
656
|
+
work.$rMutations[work.recordIndex].addedNodes
|
|
657
|
+
)
|
|
658
|
+
: 0
|
|
659
|
+
}
|
|
660
|
+
if (work.recordIndex < 0) {
|
|
661
|
+
break
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
var mutation = work.$rMutations[work.recordIndex]
|
|
665
|
+
var remainingNodes = Math.max(
|
|
666
|
+
Math.min(
|
|
667
|
+
MUTATION_CHUNK_MAX_NODES - nodeCount - 1,
|
|
668
|
+
Math.floor(
|
|
669
|
+
(MUTATION_CHUNK_MAX_APPROX_BYTES - approxBytes - 32) /
|
|
670
|
+
16
|
|
671
|
+
)
|
|
672
|
+
),
|
|
673
|
+
1
|
|
674
|
+
)
|
|
675
|
+
var sliceStart = Math.max(
|
|
676
|
+
work.addedIndex - remainingNodes,
|
|
677
|
+
0
|
|
678
|
+
)
|
|
679
|
+
var synthetic = {
|
|
680
|
+
type: 'childList',
|
|
681
|
+
target: mutation.target,
|
|
682
|
+
addedNodes: Array.prototype.slice.call(
|
|
683
|
+
mutation.addedNodes,
|
|
684
|
+
sliceStart,
|
|
685
|
+
work.addedIndex
|
|
686
|
+
),
|
|
687
|
+
removedNodes: []
|
|
688
|
+
}
|
|
689
|
+
var measurement = measureMutation(synthetic)
|
|
690
|
+
if (
|
|
691
|
+
chunk.length &&
|
|
692
|
+
(nodeCount + measurement.nodeCount > MUTATION_CHUNK_MAX_NODES ||
|
|
693
|
+
approxBytes + measurement.approxBytes >
|
|
694
|
+
MUTATION_CHUNK_MAX_APPROX_BYTES)
|
|
695
|
+
) {
|
|
696
|
+
break
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
work.addedIndex = sliceStart
|
|
700
|
+
if (work.addedIndex === 0) {
|
|
701
|
+
work.recordIndex -= 1
|
|
702
|
+
work.addedIndex =
|
|
703
|
+
work.recordIndex >= 0
|
|
704
|
+
? getNodeListLength(
|
|
705
|
+
work.$rMutations[work.recordIndex].addedNodes
|
|
706
|
+
)
|
|
707
|
+
: 0
|
|
708
|
+
}
|
|
709
|
+
chunk.push(synthetic)
|
|
710
|
+
nodeCount += measurement.nodeCount
|
|
711
|
+
approxBytes += measurement.approxBytes
|
|
712
|
+
if (
|
|
713
|
+
nodeCount >= MUTATION_CHUNK_MAX_NODES ||
|
|
714
|
+
approxBytes >= MUTATION_CHUNK_MAX_APPROX_BYTES
|
|
715
|
+
) {
|
|
716
|
+
break
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return chunk
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function cloneMutationRecord(mutation) {
|
|
723
|
+
var oldValue = mutation.oldValue
|
|
724
|
+
if (
|
|
725
|
+
typeof oldValue === 'string' &&
|
|
726
|
+
oldValue.length > MUTATION_CHUNK_MAX_APPROX_BYTES / 4
|
|
727
|
+
) {
|
|
728
|
+
oldValue = undefined
|
|
729
|
+
}
|
|
730
|
+
return {
|
|
731
|
+
type: mutation.type,
|
|
732
|
+
target: mutation.target,
|
|
733
|
+
attributeName: mutation.attributeName,
|
|
734
|
+
oldValue: oldValue
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function measureMutationsUntilLimit(mutations, nodeLimit, byteLimit) {
|
|
739
|
+
var nodeCount = 0
|
|
740
|
+
var approxBytes = 0
|
|
741
|
+
for (var index = 0; index < mutations.length; index += 1) {
|
|
742
|
+
var measurement = measureMutation(mutations[index])
|
|
743
|
+
nodeCount += measurement.nodeCount
|
|
744
|
+
approxBytes += measurement.approxBytes
|
|
745
|
+
if (nodeCount > nodeLimit || approxBytes > byteLimit) {
|
|
746
|
+
break
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return { nodeCount: nodeCount, approxBytes: approxBytes }
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function measureMutation(mutation) {
|
|
753
|
+
var nodeCount = 1
|
|
754
|
+
var approxBytes = 32
|
|
755
|
+
if (mutation.type === 'childList') {
|
|
756
|
+
var childNodeCount =
|
|
757
|
+
getNodeListLength(mutation.addedNodes) +
|
|
758
|
+
getNodeListLength(mutation.removedNodes)
|
|
759
|
+
nodeCount += childNodeCount
|
|
760
|
+
approxBytes += childNodeCount * 16
|
|
761
|
+
} else if (mutation.type === 'attributes') {
|
|
762
|
+
approxBytes +=
|
|
763
|
+
getStringApproxBytes(mutation.attributeName) +
|
|
764
|
+
getStringApproxBytes(mutation.oldValue)
|
|
765
|
+
} else if (mutation.type === 'characterData') {
|
|
766
|
+
approxBytes += getStringApproxBytes(mutation.oldValue)
|
|
767
|
+
}
|
|
768
|
+
return { nodeCount: nodeCount, approxBytes: approxBytes }
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function getNodeListLength(nodes) {
|
|
772
|
+
return nodes && typeof nodes.length === 'number' ? nodes.length : 0
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function getStringApproxBytes(value) {
|
|
776
|
+
return typeof value === 'string' ? value.length * 2 : 0
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function getCurrentTime() {
|
|
780
|
+
return typeof performance !== 'undefined' && performance.now
|
|
781
|
+
? performance.now()
|
|
782
|
+
: Date.now()
|
|
49
783
|
}
|