@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
|
@@ -8,7 +8,20 @@ import { CENSORED_STRING_MARK } from '../../../constants'
|
|
|
8
8
|
import { shouldMaskNode } from './privacy'
|
|
9
9
|
|
|
10
10
|
var serializedNodeIds = new WeakMap()
|
|
11
|
-
var
|
|
11
|
+
export var MAX_SERIALIZED_CANVAS_REGISTRY_SIZE = 2048
|
|
12
|
+
export var MAX_SERIALIZED_NODE_ANCESTOR_DEPTH = 1000
|
|
13
|
+
export var STYLESHEET_SERIALIZATION_MAX_RULE_COUNT = 5000
|
|
14
|
+
export var STYLESHEET_SERIALIZATION_MAX_CHARACTER_COUNT = 256 * 1024
|
|
15
|
+
export var STYLESHEET_SERIALIZATION_MAX_DURATION_MS = 4
|
|
16
|
+
export var STYLESHEET_SERIALIZATION_MAX_SNAPSHOT_BYTES = 512 * 1024
|
|
17
|
+
var serializedCanvasEntries = []
|
|
18
|
+
var serializedCanvasFreeEntryIndexes = []
|
|
19
|
+
var serializedCanvasEntryByNode = new WeakMap()
|
|
20
|
+
var serializedCanvasEntryCount = 0
|
|
21
|
+
var serializedCanvasNextEvictionIndex = 0
|
|
22
|
+
var serializedCanvasScanCursor = 0
|
|
23
|
+
var serializedCanvasScanRemaining = 0
|
|
24
|
+
var serializedCanvasTrackingCount = 0
|
|
12
25
|
var anchorElementByDocument = new WeakMap()
|
|
13
26
|
var hrefByDocument = new WeakMap()
|
|
14
27
|
|
|
@@ -34,10 +47,15 @@ export function hasSerializedNode(node) {
|
|
|
34
47
|
|
|
35
48
|
export function nodeAndAncestorsHaveSerializedNode(node) {
|
|
36
49
|
var current = node
|
|
50
|
+
var depth = 0
|
|
37
51
|
while (current) {
|
|
52
|
+
if (depth >= MAX_SERIALIZED_NODE_ANCESTOR_DEPTH) {
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
38
55
|
if (!hasSerializedNode(current) && !isNodeShadowRoot(current)) {
|
|
39
56
|
return false
|
|
40
57
|
}
|
|
58
|
+
depth += 1
|
|
41
59
|
current = getParentNode(current)
|
|
42
60
|
}
|
|
43
61
|
return true
|
|
@@ -49,14 +67,34 @@ export function getSerializedNodeId(node) {
|
|
|
49
67
|
|
|
50
68
|
export function setSerializedNodeId(node, serializeNodeId) {
|
|
51
69
|
serializedNodeIds.set(node, serializeNodeId)
|
|
52
|
-
if (
|
|
53
|
-
|
|
70
|
+
if (
|
|
71
|
+
serializedCanvasTrackingCount > 0 &&
|
|
72
|
+
node instanceof HTMLCanvasElement
|
|
73
|
+
) {
|
|
74
|
+
registerSerializedCanvasNode(node)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function startSerializedCanvasTracking() {
|
|
79
|
+
serializedCanvasTrackingCount += 1
|
|
80
|
+
var stopped = false
|
|
81
|
+
|
|
82
|
+
return function stopSerializedCanvasTracking() {
|
|
83
|
+
if (stopped) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
stopped = true
|
|
87
|
+
serializedCanvasTrackingCount -= 1
|
|
88
|
+
if (serializedCanvasTrackingCount === 0) {
|
|
89
|
+
clearSerializedCanvasRegistry()
|
|
90
|
+
}
|
|
54
91
|
}
|
|
55
92
|
}
|
|
56
93
|
|
|
57
94
|
function isSerializedCanvasConnectedToDocument(node) {
|
|
58
|
-
|
|
59
|
-
|
|
95
|
+
var isConnected = node.isConnected
|
|
96
|
+
if (typeof isConnected === 'boolean') {
|
|
97
|
+
return isConnected
|
|
60
98
|
}
|
|
61
99
|
|
|
62
100
|
var current = node
|
|
@@ -71,17 +109,178 @@ function isSerializedCanvasConnectedToDocument(node) {
|
|
|
71
109
|
return false
|
|
72
110
|
}
|
|
73
111
|
|
|
74
|
-
|
|
112
|
+
function registerSerializedCanvasNode(node) {
|
|
113
|
+
var existingEntry = serializedCanvasEntryByNode.get(node)
|
|
114
|
+
if (existingEntry && existingEntry.active) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var entry = {
|
|
119
|
+
active: true,
|
|
120
|
+
weakRef:
|
|
121
|
+
typeof WeakRef === 'function' ? new WeakRef(node) : undefined,
|
|
122
|
+
node: typeof WeakRef === 'function' ? undefined : node
|
|
123
|
+
}
|
|
124
|
+
var entryIndex
|
|
125
|
+
if (serializedCanvasFreeEntryIndexes.length) {
|
|
126
|
+
entryIndex = serializedCanvasFreeEntryIndexes.pop()
|
|
127
|
+
} else if (
|
|
128
|
+
serializedCanvasEntries.length <
|
|
129
|
+
MAX_SERIALIZED_CANVAS_REGISTRY_SIZE
|
|
130
|
+
) {
|
|
131
|
+
entryIndex = serializedCanvasEntries.length
|
|
132
|
+
} else {
|
|
133
|
+
entryIndex = serializedCanvasNextEvictionIndex
|
|
134
|
+
serializedCanvasNextEvictionIndex =
|
|
135
|
+
(serializedCanvasNextEvictionIndex + 1) %
|
|
136
|
+
MAX_SERIALIZED_CANVAS_REGISTRY_SIZE
|
|
137
|
+
var evictedEntry = serializedCanvasEntries[entryIndex]
|
|
138
|
+
if (evictedEntry && evictedEntry.active) {
|
|
139
|
+
evictedEntry.active = false
|
|
140
|
+
serializedCanvasEntryCount -= 1
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
entry.index = entryIndex
|
|
145
|
+
serializedCanvasEntries[entryIndex] = entry
|
|
146
|
+
serializedCanvasEntryByNode.set(node, entry)
|
|
147
|
+
serializedCanvasEntryCount += 1
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getSerializedCanvasEntryNode(entry) {
|
|
151
|
+
if (!entry || !entry.active) {
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
return entry.weakRef ? entry.weakRef.deref() : entry.node
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function pruneSerializedCanvasEntry(entry) {
|
|
158
|
+
if (!entry || !entry.active) {
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
entry.active = false
|
|
162
|
+
entry.node = undefined
|
|
163
|
+
if (serializedCanvasEntries[entry.index] === entry) {
|
|
164
|
+
serializedCanvasEntries[entry.index] = undefined
|
|
165
|
+
serializedCanvasFreeEntryIndexes.push(entry.index)
|
|
166
|
+
}
|
|
167
|
+
serializedCanvasEntryCount = Math.max(
|
|
168
|
+
serializedCanvasEntryCount - 1,
|
|
169
|
+
0
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function clearSerializedCanvasRegistry() {
|
|
174
|
+
serializedCanvasEntries = []
|
|
175
|
+
serializedCanvasFreeEntryIndexes = []
|
|
176
|
+
serializedCanvasEntryByNode = new WeakMap()
|
|
177
|
+
serializedCanvasEntryCount = 0
|
|
178
|
+
serializedCanvasNextEvictionIndex = 0
|
|
179
|
+
resetSerializedCanvasScan()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function resetSerializedCanvasScan() {
|
|
183
|
+
serializedCanvasScanCursor = 0
|
|
184
|
+
serializedCanvasScanRemaining = 0
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function getSerializedCanvasNodes(maxScanCount) {
|
|
188
|
+
if (typeof maxScanCount === 'number') {
|
|
189
|
+
return getSerializedCanvasNodesWithinScanLimit(maxScanCount)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
var connectedSerializedCanvasNodes = []
|
|
193
|
+
for (
|
|
194
|
+
var entryIndex = 0;
|
|
195
|
+
entryIndex < serializedCanvasEntries.length;
|
|
196
|
+
entryIndex += 1
|
|
197
|
+
) {
|
|
198
|
+
var entry = serializedCanvasEntries[entryIndex]
|
|
199
|
+
var node = getSerializedCanvasEntryNode(entry)
|
|
200
|
+
if (hasSerializedNode(node) && isSerializedCanvasConnectedToDocument(node)) {
|
|
201
|
+
connectedSerializedCanvasNodes.push(node)
|
|
202
|
+
} else {
|
|
203
|
+
pruneSerializedCanvasEntry(entry)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
resetSerializedCanvasScan()
|
|
207
|
+
|
|
208
|
+
return connectedSerializedCanvasNodes
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function getSerializedCanvasNodesSnapshot(maxScanCount) {
|
|
212
|
+
var resultLimit = Math.max(Math.floor(maxScanCount), 0)
|
|
213
|
+
if (
|
|
214
|
+
!isFinite(resultLimit) ||
|
|
215
|
+
resultLimit === 0 ||
|
|
216
|
+
!serializedCanvasEntryCount ||
|
|
217
|
+
!serializedCanvasEntries.length
|
|
218
|
+
) {
|
|
219
|
+
return []
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Full-snapshot bitmap baselines need a complete bounded view independent
|
|
223
|
+
// from the partial round-robin pass shared by continuous and command
|
|
224
|
+
// schedulers. Scan the bounded registry until enough active canvases are
|
|
225
|
+
// collected so sparse/disconnected slots cannot hide later canvases, without
|
|
226
|
+
// reading or updating the shared cursor.
|
|
227
|
+
var connectedSerializedCanvasNodes = []
|
|
228
|
+
for (
|
|
229
|
+
var entryIndex = 0;
|
|
230
|
+
entryIndex < serializedCanvasEntries.length &&
|
|
231
|
+
connectedSerializedCanvasNodes.length < resultLimit;
|
|
232
|
+
entryIndex += 1
|
|
233
|
+
) {
|
|
234
|
+
var entry = serializedCanvasEntries[entryIndex]
|
|
235
|
+
var node = getSerializedCanvasEntryNode(entry)
|
|
236
|
+
if (hasSerializedNode(node) && isSerializedCanvasConnectedToDocument(node)) {
|
|
237
|
+
connectedSerializedCanvasNodes.push(node)
|
|
238
|
+
} else {
|
|
239
|
+
pruneSerializedCanvasEntry(entry)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return connectedSerializedCanvasNodes
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function getSerializedCanvasNodesWithinScanLimit(maxScanCount) {
|
|
246
|
+
var scanLimit = Math.max(Math.floor(maxScanCount), 0)
|
|
247
|
+
if (
|
|
248
|
+
!isFinite(scanLimit) ||
|
|
249
|
+
scanLimit === 0 ||
|
|
250
|
+
!serializedCanvasEntryCount ||
|
|
251
|
+
!serializedCanvasEntries.length
|
|
252
|
+
) {
|
|
253
|
+
return []
|
|
254
|
+
}
|
|
255
|
+
if (!serializedCanvasScanRemaining) {
|
|
256
|
+
serializedCanvasScanCursor = 0
|
|
257
|
+
serializedCanvasScanRemaining = serializedCanvasEntries.length
|
|
258
|
+
}
|
|
259
|
+
|
|
75
260
|
var connectedSerializedCanvasNodes = []
|
|
261
|
+
var scannedNodeCount = 0
|
|
262
|
+
while (
|
|
263
|
+
scannedNodeCount < scanLimit &&
|
|
264
|
+
serializedCanvasScanRemaining > 0
|
|
265
|
+
) {
|
|
266
|
+
var entry = serializedCanvasEntries[serializedCanvasScanCursor]
|
|
267
|
+
serializedCanvasScanCursor =
|
|
268
|
+
(serializedCanvasScanCursor + 1) %
|
|
269
|
+
serializedCanvasEntries.length
|
|
270
|
+
scannedNodeCount += 1
|
|
271
|
+
serializedCanvasScanRemaining -= 1
|
|
76
272
|
|
|
77
|
-
|
|
273
|
+
var node = getSerializedCanvasEntryNode(entry)
|
|
78
274
|
if (hasSerializedNode(node) && isSerializedCanvasConnectedToDocument(node)) {
|
|
79
275
|
connectedSerializedCanvasNodes.push(node)
|
|
80
|
-
|
|
276
|
+
} else {
|
|
277
|
+
pruneSerializedCanvasEntry(entry)
|
|
81
278
|
}
|
|
82
|
-
|
|
83
|
-
})
|
|
279
|
+
}
|
|
84
280
|
|
|
281
|
+
if (serializedCanvasScanRemaining === 0) {
|
|
282
|
+
resetSerializedCanvasScan()
|
|
283
|
+
}
|
|
85
284
|
return connectedSerializedCanvasNodes
|
|
86
285
|
}
|
|
87
286
|
|
|
@@ -201,22 +400,196 @@ export function getCssRulesString(cssStyleSheet) {
|
|
|
201
400
|
if (!cssStyleSheet) {
|
|
202
401
|
return null
|
|
203
402
|
}
|
|
204
|
-
var
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} catch {
|
|
208
|
-
// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
|
|
403
|
+
var rootRules = getReadableStyleSheetRules(cssStyleSheet)
|
|
404
|
+
if (!rootRules) {
|
|
405
|
+
return null
|
|
209
406
|
}
|
|
210
|
-
|
|
407
|
+
var serializationState = {
|
|
408
|
+
parts: [],
|
|
409
|
+
visitedStyleSheets: new Set(),
|
|
410
|
+
ruleCount: 0,
|
|
411
|
+
characterCount: 0,
|
|
412
|
+
characterLimit:
|
|
413
|
+
STYLESHEET_SERIALIZATION_MAX_CHARACTER_COUNT - 64,
|
|
414
|
+
deadline:
|
|
415
|
+
getSerializationTime() + STYLESHEET_SERIALIZATION_MAX_DURATION_MS,
|
|
416
|
+
exceeded: false
|
|
417
|
+
}
|
|
418
|
+
var completed = appendStyleSheetRules(
|
|
419
|
+
cssStyleSheet,
|
|
420
|
+
serializationState,
|
|
421
|
+
cssStyleSheet.href,
|
|
422
|
+
rootRules
|
|
423
|
+
)
|
|
424
|
+
// `_cssText` replaces the stylesheet in the player, so a rule prefix cannot
|
|
425
|
+
// safely represent the source sheet. Let linked stylesheets fall back to
|
|
426
|
+
// their href and inline styles fall back to their bounded text child.
|
|
427
|
+
if (!completed) {
|
|
211
428
|
return null
|
|
212
429
|
}
|
|
213
430
|
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(
|
|
214
|
-
|
|
215
|
-
rules,
|
|
216
|
-
isSafari() ? getCssRuleStringForSafari : getCssRuleString
|
|
217
|
-
).join('')
|
|
431
|
+
serializationState.parts.join('')
|
|
218
432
|
)
|
|
219
|
-
|
|
433
|
+
if (
|
|
434
|
+
styleSheetCssText.length >
|
|
435
|
+
STYLESHEET_SERIALIZATION_MAX_CHARACTER_COUNT
|
|
436
|
+
) {
|
|
437
|
+
return null
|
|
438
|
+
}
|
|
439
|
+
return styleSheetCssText
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function appendStyleSheetRules(
|
|
443
|
+
cssStyleSheet,
|
|
444
|
+
serializationState,
|
|
445
|
+
inheritedHref,
|
|
446
|
+
knownRules
|
|
447
|
+
) {
|
|
448
|
+
if (
|
|
449
|
+
!cssStyleSheet ||
|
|
450
|
+
serializationState.visitedStyleSheets.has(cssStyleSheet)
|
|
451
|
+
) {
|
|
452
|
+
return true
|
|
453
|
+
}
|
|
454
|
+
if (!hasStyleSheetSerializationBudget(serializationState)) {
|
|
455
|
+
return false
|
|
456
|
+
}
|
|
457
|
+
serializationState.visitedStyleSheets.add(cssStyleSheet)
|
|
458
|
+
var styleSheetHref = cssStyleSheet.href || inheritedHref
|
|
459
|
+
var rules = knownRules || getReadableStyleSheetRules(cssStyleSheet)
|
|
460
|
+
if (!rules) {
|
|
461
|
+
return false
|
|
462
|
+
}
|
|
463
|
+
for (var ruleIndex = 0; ruleIndex < rules.length; ruleIndex += 1) {
|
|
464
|
+
var rule = rules[ruleIndex]
|
|
465
|
+
if (isCSSImportRule(rule)) {
|
|
466
|
+
var importedHref =
|
|
467
|
+
(rule.styleSheet && rule.styleSheet.href) ||
|
|
468
|
+
(rule.href && styleSheetHref
|
|
469
|
+
? makeUrlAbsolute(rule.href, styleSheetHref)
|
|
470
|
+
: rule.href)
|
|
471
|
+
var importedRules = getReadableStyleSheetRules(rule.styleSheet)
|
|
472
|
+
if (importedRules) {
|
|
473
|
+
if (
|
|
474
|
+
!appendStyleSheetRules(
|
|
475
|
+
rule.styleSheet,
|
|
476
|
+
serializationState,
|
|
477
|
+
importedHref,
|
|
478
|
+
importedRules
|
|
479
|
+
)
|
|
480
|
+
) {
|
|
481
|
+
return false
|
|
482
|
+
}
|
|
483
|
+
} else if (
|
|
484
|
+
!appendStyleSheetRuleText(
|
|
485
|
+
rule,
|
|
486
|
+
serializationState,
|
|
487
|
+
styleSheetHref,
|
|
488
|
+
false
|
|
489
|
+
)
|
|
490
|
+
) {
|
|
491
|
+
return false
|
|
492
|
+
}
|
|
493
|
+
continue
|
|
494
|
+
}
|
|
495
|
+
if (
|
|
496
|
+
!appendStyleSheetRuleText(
|
|
497
|
+
rule,
|
|
498
|
+
serializationState,
|
|
499
|
+
styleSheetHref,
|
|
500
|
+
true
|
|
501
|
+
)
|
|
502
|
+
) {
|
|
503
|
+
return false
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return true
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function getReadableStyleSheetRules(cssStyleSheet) {
|
|
510
|
+
if (!cssStyleSheet) {
|
|
511
|
+
return
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
return cssStyleSheet.rules || cssStyleSheet.cssRules
|
|
515
|
+
} catch (_) {
|
|
516
|
+
// If CSS is protected by CORS we cannot access cssRules. The containing
|
|
517
|
+
// @import rule itself is still useful and is retained by the caller.
|
|
518
|
+
// See https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface.
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function appendStyleSheetRuleText(
|
|
523
|
+
rule,
|
|
524
|
+
serializationState,
|
|
525
|
+
styleSheetHref,
|
|
526
|
+
shouldPatchSafari
|
|
527
|
+
) {
|
|
528
|
+
var rawRuleText = rule && rule.cssText
|
|
529
|
+
if (typeof rawRuleText !== 'string') {
|
|
530
|
+
return true
|
|
531
|
+
}
|
|
532
|
+
if (
|
|
533
|
+
!hasStyleSheetSerializationBudget(
|
|
534
|
+
serializationState,
|
|
535
|
+
rawRuleText.length
|
|
536
|
+
)
|
|
537
|
+
) {
|
|
538
|
+
return false
|
|
539
|
+
}
|
|
540
|
+
var ruleText =
|
|
541
|
+
shouldPatchSafari && isSafari()
|
|
542
|
+
? getCssRuleStringForSafari(rule)
|
|
543
|
+
: rawRuleText
|
|
544
|
+
ruleText = switchToAbsoluteUrl(ruleText, styleSheetHref)
|
|
545
|
+
if (
|
|
546
|
+
ruleText.length !== rawRuleText.length &&
|
|
547
|
+
!hasStyleSheetSerializationBudget(
|
|
548
|
+
serializationState,
|
|
549
|
+
ruleText.length - rawRuleText.length,
|
|
550
|
+
false
|
|
551
|
+
)
|
|
552
|
+
) {
|
|
553
|
+
return false
|
|
554
|
+
}
|
|
555
|
+
serializationState.ruleCount += 1
|
|
556
|
+
serializationState.characterCount += ruleText.length
|
|
557
|
+
serializationState.parts.push(ruleText)
|
|
558
|
+
return true
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function hasStyleSheetSerializationBudget(
|
|
562
|
+
serializationState,
|
|
563
|
+
additionalCharacterCount,
|
|
564
|
+
shouldCountRule
|
|
565
|
+
) {
|
|
566
|
+
if (additionalCharacterCount === undefined) {
|
|
567
|
+
additionalCharacterCount = 0
|
|
568
|
+
}
|
|
569
|
+
if (shouldCountRule === undefined) {
|
|
570
|
+
shouldCountRule = true
|
|
571
|
+
}
|
|
572
|
+
if (
|
|
573
|
+
serializationState.exceeded ||
|
|
574
|
+
(shouldCountRule &&
|
|
575
|
+
serializationState.ruleCount >=
|
|
576
|
+
STYLESHEET_SERIALIZATION_MAX_RULE_COUNT) ||
|
|
577
|
+
serializationState.characterCount + additionalCharacterCount >
|
|
578
|
+
(serializationState.characterLimit ||
|
|
579
|
+
STYLESHEET_SERIALIZATION_MAX_CHARACTER_COUNT) ||
|
|
580
|
+
getSerializationTime() > serializationState.deadline
|
|
581
|
+
) {
|
|
582
|
+
serializationState.exceeded = true
|
|
583
|
+
return false
|
|
584
|
+
}
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function getSerializationTime() {
|
|
589
|
+
if (typeof performance !== 'undefined' && performance.now) {
|
|
590
|
+
return performance.now()
|
|
591
|
+
}
|
|
592
|
+
return Date.now()
|
|
220
593
|
}
|
|
221
594
|
export function isCSSImportRule(rule) {
|
|
222
595
|
return 'styleSheet' in rule
|
|
@@ -257,11 +630,50 @@ export function serializeStyleSheets(cssStyleSheets) {
|
|
|
257
630
|
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
|
|
258
631
|
return undefined
|
|
259
632
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
633
|
+
var serializedStyleSheets = []
|
|
634
|
+
var serializationState = {
|
|
635
|
+
ruleCount: 0,
|
|
636
|
+
characterCount: 0,
|
|
637
|
+
deadline:
|
|
638
|
+
getSerializationTime() + STYLESHEET_SERIALIZATION_MAX_DURATION_MS,
|
|
639
|
+
exceeded: false
|
|
640
|
+
}
|
|
641
|
+
for (
|
|
642
|
+
var styleSheetIndex = 0;
|
|
643
|
+
styleSheetIndex < cssStyleSheets.length;
|
|
644
|
+
styleSheetIndex += 1
|
|
645
|
+
) {
|
|
646
|
+
var cssStyleSheet = cssStyleSheets[styleSheetIndex]
|
|
647
|
+
if (!hasStyleSheetSerializationBudget(serializationState, 0, false)) {
|
|
648
|
+
break
|
|
649
|
+
}
|
|
650
|
+
var rules = getReadableStyleSheetRules(cssStyleSheet)
|
|
651
|
+
if (!rules) {
|
|
652
|
+
continue
|
|
653
|
+
}
|
|
654
|
+
var cssRules = []
|
|
655
|
+
var completed = true
|
|
656
|
+
for (var ruleIndex = 0; ruleIndex < rules.length; ruleIndex += 1) {
|
|
657
|
+
var cssText = rules[ruleIndex].cssText
|
|
658
|
+
if (typeof cssText !== 'string') {
|
|
659
|
+
continue
|
|
660
|
+
}
|
|
661
|
+
if (
|
|
662
|
+
!hasStyleSheetSerializationBudget(
|
|
663
|
+
serializationState,
|
|
664
|
+
cssText.length
|
|
665
|
+
)
|
|
666
|
+
) {
|
|
667
|
+
completed = false
|
|
668
|
+
break
|
|
669
|
+
}
|
|
670
|
+
serializationState.ruleCount += 1
|
|
671
|
+
serializationState.characterCount += cssText.length
|
|
672
|
+
cssRules.push(cssText)
|
|
673
|
+
}
|
|
674
|
+
if (!completed) {
|
|
675
|
+
break
|
|
676
|
+
}
|
|
265
677
|
|
|
266
678
|
var styleSheet = {
|
|
267
679
|
cssRules: cssRules,
|
|
@@ -271,8 +683,155 @@ export function serializeStyleSheets(cssStyleSheets) {
|
|
|
271
683
|
? Array.from(cssStyleSheet.media)
|
|
272
684
|
: undefined
|
|
273
685
|
}
|
|
274
|
-
|
|
275
|
-
}
|
|
686
|
+
serializedStyleSheets.push(styleSheet)
|
|
687
|
+
}
|
|
688
|
+
return serializedStyleSheets
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Incrementally serializes constructable/adopted stylesheets. Unlike the
|
|
693
|
+
* legacy synchronous helper above, this task never treats a per-frame
|
|
694
|
+
* deadline, rule count, or the old 256 KiB watermark as a successful partial
|
|
695
|
+
* result. The owning DOM serializer publishes only after every readable rule
|
|
696
|
+
* has been copied, while still yielding between small rule batches.
|
|
697
|
+
*/
|
|
698
|
+
export function createStyleSheetsSerializerTask(cssStyleSheets) {
|
|
699
|
+
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
|
|
700
|
+
return null
|
|
701
|
+
}
|
|
702
|
+
var serializedStyleSheets = []
|
|
703
|
+
var styleSheetIndex = 0
|
|
704
|
+
var currentRules
|
|
705
|
+
var currentRuleIndex = 0
|
|
706
|
+
var currentSerializedStyleSheet
|
|
707
|
+
var approxBytes = 0
|
|
708
|
+
|
|
709
|
+
return {
|
|
710
|
+
serializedStyleSheets: serializedStyleSheets,
|
|
711
|
+
approxBytes: 0,
|
|
712
|
+
isComplete: false,
|
|
713
|
+
isMaxApproxBytesReached: false,
|
|
714
|
+
advance: function (
|
|
715
|
+
deadline,
|
|
716
|
+
maxApproxBytes,
|
|
717
|
+
hardMaxApproxBytes
|
|
718
|
+
) {
|
|
719
|
+
if (typeof maxApproxBytes !== 'number') {
|
|
720
|
+
maxApproxBytes = Number.MAX_SAFE_INTEGER
|
|
721
|
+
}
|
|
722
|
+
if (typeof hardMaxApproxBytes !== 'number') {
|
|
723
|
+
hardMaxApproxBytes = maxApproxBytes
|
|
724
|
+
}
|
|
725
|
+
hardMaxApproxBytes = Math.min(
|
|
726
|
+
hardMaxApproxBytes,
|
|
727
|
+
STYLESHEET_SERIALIZATION_MAX_SNAPSHOT_BYTES
|
|
728
|
+
)
|
|
729
|
+
maxApproxBytes = Math.min(
|
|
730
|
+
maxApproxBytes,
|
|
731
|
+
hardMaxApproxBytes
|
|
732
|
+
)
|
|
733
|
+
this.isMaxApproxBytesReached = false
|
|
734
|
+
while (styleSheetIndex < cssStyleSheets.length) {
|
|
735
|
+
if (!currentRules) {
|
|
736
|
+
if (approxBytes + 32 > maxApproxBytes) {
|
|
737
|
+
if (approxBytes + 32 <= hardMaxApproxBytes) {
|
|
738
|
+
this.approxBytes = approxBytes
|
|
739
|
+
this.isMaxApproxBytesReached = true
|
|
740
|
+
return false
|
|
741
|
+
}
|
|
742
|
+
if (
|
|
743
|
+
approxBytes + 24 <= hardMaxApproxBytes &&
|
|
744
|
+
approxBytes + 24 > maxApproxBytes
|
|
745
|
+
) {
|
|
746
|
+
this.approxBytes = approxBytes
|
|
747
|
+
this.isMaxApproxBytesReached = true
|
|
748
|
+
return false
|
|
749
|
+
}
|
|
750
|
+
if (approxBytes + 24 <= hardMaxApproxBytes) {
|
|
751
|
+
serializedStyleSheets.push({
|
|
752
|
+
cssRules: [],
|
|
753
|
+
isTruncated: true
|
|
754
|
+
})
|
|
755
|
+
approxBytes += 24
|
|
756
|
+
}
|
|
757
|
+
styleSheetIndex = cssStyleSheets.length
|
|
758
|
+
break
|
|
759
|
+
}
|
|
760
|
+
var cssStyleSheet = cssStyleSheets[styleSheetIndex]
|
|
761
|
+
currentRules = getReadableStyleSheetRules(cssStyleSheet)
|
|
762
|
+
currentRuleIndex = 0
|
|
763
|
+
if (!currentRules) {
|
|
764
|
+
styleSheetIndex += 1
|
|
765
|
+
continue
|
|
766
|
+
}
|
|
767
|
+
currentSerializedStyleSheet = {
|
|
768
|
+
cssRules: [],
|
|
769
|
+
disabled: cssStyleSheet.disabled || undefined,
|
|
770
|
+
media:
|
|
771
|
+
cssStyleSheet.media && cssStyleSheet.media.length > 0
|
|
772
|
+
? Array.from(cssStyleSheet.media)
|
|
773
|
+
: undefined
|
|
774
|
+
}
|
|
775
|
+
serializedStyleSheets.push(currentSerializedStyleSheet)
|
|
776
|
+
approxBytes += 32
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
while (currentRuleIndex < currentRules.length) {
|
|
780
|
+
if (getSerializationTime() >= deadline) {
|
|
781
|
+
this.approxBytes = approxBytes
|
|
782
|
+
return false
|
|
783
|
+
}
|
|
784
|
+
var cssText = currentRules[currentRuleIndex].cssText
|
|
785
|
+
if (typeof cssText !== 'string') {
|
|
786
|
+
currentRuleIndex += 1
|
|
787
|
+
continue
|
|
788
|
+
}
|
|
789
|
+
var cssTextApproxBytes = cssText.length * 2 + 8
|
|
790
|
+
if (approxBytes + cssTextApproxBytes > maxApproxBytes) {
|
|
791
|
+
if (
|
|
792
|
+
approxBytes + cssTextApproxBytes <=
|
|
793
|
+
hardMaxApproxBytes
|
|
794
|
+
) {
|
|
795
|
+
// The outer DOM serializer grows its byte watermark between
|
|
796
|
+
// FullSnapshot slices. Keep the current rule pending until that
|
|
797
|
+
// soft budget grows instead of turning a temporary yield into a
|
|
798
|
+
// permanently truncated stylesheet.
|
|
799
|
+
this.approxBytes = approxBytes
|
|
800
|
+
this.isMaxApproxBytesReached = true
|
|
801
|
+
return false
|
|
802
|
+
}
|
|
803
|
+
if (
|
|
804
|
+
approxBytes + 24 <= hardMaxApproxBytes &&
|
|
805
|
+
approxBytes + 24 > maxApproxBytes
|
|
806
|
+
) {
|
|
807
|
+
this.approxBytes = approxBytes
|
|
808
|
+
this.isMaxApproxBytesReached = true
|
|
809
|
+
return false
|
|
810
|
+
}
|
|
811
|
+
// Preserve complete CSS rules only. A partial rule can invalidate
|
|
812
|
+
// the remainder of the sheet in the player. The explicit marker
|
|
813
|
+
// makes this a local, diagnosable stylesheet degradation instead
|
|
814
|
+
// of a silent omission or a whole FullSnapshot failure.
|
|
815
|
+
if (approxBytes + 24 <= hardMaxApproxBytes) {
|
|
816
|
+
currentSerializedStyleSheet.isTruncated = true
|
|
817
|
+
approxBytes += 24
|
|
818
|
+
}
|
|
819
|
+
currentRuleIndex = currentRules.length
|
|
820
|
+
break
|
|
821
|
+
}
|
|
822
|
+
currentRuleIndex += 1
|
|
823
|
+
currentSerializedStyleSheet.cssRules.push(cssText)
|
|
824
|
+
approxBytes += cssTextApproxBytes
|
|
825
|
+
}
|
|
826
|
+
currentRules = undefined
|
|
827
|
+
currentSerializedStyleSheet = undefined
|
|
828
|
+
styleSheetIndex += 1
|
|
829
|
+
}
|
|
830
|
+
this.approxBytes = approxBytes
|
|
831
|
+
this.isComplete = true
|
|
832
|
+
return true
|
|
833
|
+
}
|
|
834
|
+
}
|
|
276
835
|
}
|
|
277
836
|
export function absoluteToDoc(doc, attributeValue) {
|
|
278
837
|
if (!attributeValue || attributeValue.trim() === '') {
|