@cloudcare/browser-rum 3.3.23 → 3.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/boot/buildEnv.js +2 -5
- package/esm/boot/buildEnv.js.map +1 -1
- package/esm/boot/disabledRumPublicApi.js +2 -35
- package/esm/boot/disabledRumPublicApi.js.map +1 -1
- package/esm/boot/perStartRum.js +2 -260
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +2 -338
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/recorderApiStub.js +2 -21
- package/esm/boot/recorderApiStub.js.map +1 -1
- package/esm/boot/rum.entry.js +2 -13
- package/esm/boot/rum.entry.js.map +1 -1
- package/esm/boot/rum.js +2 -184
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rum.slim.entry.js +2 -7
- package/esm/boot/rum.slim.entry.js.map +1 -1
- package/esm/boot/rumEntryFactory.js +2 -18
- package/esm/boot/rumEntryFactory.js.map +1 -1
- package/esm/boot/rumPublicApi.js +2 -344
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/rumRecorderApiStub.js +2 -13
- package/esm/boot/rumRecorderApiStub.js.map +1 -1
- package/esm/boot/rumSlimConfiguration.js +2 -10
- package/esm/boot/rumSlimConfiguration.js.map +1 -1
- package/esm/boot/sessionReplayPublicApi.js +2 -43
- package/esm/boot/sessionReplayPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +2 -444
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/constants.js +2 -28
- package/esm/constants.js.map +1 -1
- package/esm/domain/assembly.js +2 -213
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +2 -323
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/commonContext.js +2 -8
- package/esm/domain/contexts/commonContext.js.map +1 -1
- package/esm/domain/contexts/displayContext.js +2 -16
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/contexts/foregroundContexts.js +2 -103
- package/esm/domain/contexts/foregroundContexts.js.map +1 -1
- package/esm/domain/contexts/internalContext.js +2 -41
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js +2 -104
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +2 -85
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +2 -45
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js +2 -592
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +2 -225
- package/esm/domain/deflate/deflateWorker.js.map +1 -1
- package/esm/domain/deflate/index.js +2 -3
- package/esm/domain/deflate/index.js.map +1 -1
- package/esm/domain/domMutationObservable.js +2 -62
- package/esm/domain/domMutationObservable.js.map +1 -1
- package/esm/domain/encoderStreamId.js +2 -6
- package/esm/domain/encoderStreamId.js.map +1 -1
- package/esm/domain/firstInputPolyfill.js +2 -77
- package/esm/domain/firstInputPolyfill.js.map +1 -1
- package/esm/domain/initViewportObservable.js +2 -36
- package/esm/domain/initViewportObservable.js.map +1 -1
- package/esm/domain/locationChangeObservable.js +2 -65
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceObservable.js +2 -116
- package/esm/domain/performanceObservable.js.map +1 -1
- package/esm/domain/performanceUtils.js +2 -45
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/plugins.js +2 -59
- package/esm/domain/plugins.js.map +1 -1
- package/esm/domain/privacy.js +2 -266
- package/esm/domain/privacy.js.map +1 -1
- package/esm/domain/replay/record/canvasAutoSnapshot.js +2 -9
- package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +2 -1275
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserver.js +2 -1207
- package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +2 -111
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +2 -50
- package/esm/domain/replay/record/canvasContext.js.map +1 -1
- package/esm/domain/replay/record/canvasContinuousScheduler.js +2 -378
- package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeBridge.js +2 -692
- package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +2 -164
- package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -1
- package/esm/domain/replay/record/canvasFrameSignature.js +2 -75
- package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -1
- package/esm/domain/replay/record/canvasMutationRecord.js +2 -26
- package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -1
- package/esm/domain/replay/record/canvasObserver.js +2 -420
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasSerializeArgs.js +2 -101
- package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasWebGLPluginHost.js +2 -26
- package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
- package/esm/domain/replay/record/elementsScrollPositions.js +2 -23
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/esm/domain/replay/record/index.js +2 -4
- package/esm/domain/replay/record/index.js.map +1 -1
- package/esm/domain/replay/record/mutationBatch.js +2 -562
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +2 -2332
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationResourceBudget.js +2 -137
- package/esm/domain/replay/record/mutationResourceBudget.js.map +1 -1
- package/esm/domain/replay/record/observers.js +2 -624
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +2 -1
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js +2 -3511
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +2 -677
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +2 -735
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/record/shadowRootsController.js +2 -902
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
- package/esm/domain/replay/record/utils.js +2 -36
- package/esm/domain/replay/record/utils.js.map +1 -1
- package/esm/domain/replay/record/viewports.js +2 -58
- package/esm/domain/replay/record/viewports.js.map +1 -1
- package/esm/domain/replay/replayStats.js +2 -59
- package/esm/domain/replay/replayStats.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +2 -31
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/esm/domain/replay/segmentCollection/index.js +2 -3
- package/esm/domain/replay/segmentCollection/index.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segment.js +2 -415
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +2 -1114
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/startRecordBridge.js +2 -13
- package/esm/domain/replay/startRecordBridge.js.map +1 -1
- package/esm/domain/replay/timeAnchor.js +2 -20
- package/esm/domain/replay/timeAnchor.js.map +1 -1
- package/esm/domain/requestCollection.js +2 -121
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +2 -83
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js +2 -62
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js +2 -67
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +2 -279
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +2 -233
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -21
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +2 -67
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +2 -263
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +2 -93
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js +2 -12
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js +2 -19
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js +2 -55
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -38
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -69
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -294
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +2 -232
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +2 -218
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +2 -19
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +2 -191
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js +2 -47
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +2 -42
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +2 -117
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -20
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +2 -49
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js +2 -41
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +2 -44
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +2 -153
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -54
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +2 -50
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +2 -73
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js +2 -84
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js +2 -38
- package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +2 -15
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +2 -418
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +2 -127
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/rumSessionManager.js +2 -208
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/ddtraceTracer.js +2 -40
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/getDocumentTraceId.js +2 -69
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js +2 -42
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/sampler.js +2 -61
- package/esm/domain/tracing/sampler.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js +2 -90
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/traceIdentifier.js +2 -57
- package/esm/domain/tracing/traceIdentifier.js.map +1 -1
- package/esm/domain/tracing/tracer.js +2 -128
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js +2 -69
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js +2 -42
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js +2 -41
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/domain/trackEventCounts.js +2 -49
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/usr/index.js +2 -38
- package/esm/domain/usr/index.js.map +1 -1
- package/esm/domain/visitorId/index.js +2 -406
- package/esm/domain/visitorId/index.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js +2 -142
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/index.js +2 -4
- package/esm/index.js.map +1 -1
- package/esm/transport/startRumBatch.js +2 -74
- package/esm/transport/startRumBatch.js.map +1 -1
- package/esm/transport/startRumEventBridge.js +2 -9
- package/esm/transport/startRumEventBridge.js.map +1 -1
- package/esm/types/index.js +2 -1
- package/esm/types/index.js.map +1 -1
- package/esm/types/sessionReplayConstants.js +2 -46
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,902 +1,2 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
|
|
3
|
-
import { getParentNode, instrumentMethod, isNodeShadowRoot, noop, setTimeout } from '@cloudcare/browser-core';
|
|
4
|
-
import { getMutationPayloadApproxBytes, startMutationObserver } from './mutationObserver';
|
|
5
|
-
import { initInputObserver } from './observers';
|
|
6
|
-
import { MUTATION_RESOURCE_FLUSH } from './mutationResourceBudget';
|
|
7
|
-
export var SHADOW_ROOT_CLEANUP_BATCH_SIZE = 32;
|
|
8
|
-
export var SHADOW_ROOT_CLEANUP_BUDGET_MS = 4;
|
|
9
|
-
export var SHADOW_ROOT_FLUSH_MAX_COUNT = 64;
|
|
10
|
-
export var SHADOW_ROOT_FLUSH_BUDGET_MS = 4;
|
|
11
|
-
// Kept as an internal compatibility export for existing diagnostics/tests.
|
|
12
|
-
// It is now the per-turn activation/flush slice, not a total observer cap.
|
|
13
|
-
export var SHADOW_ROOT_ACTIVE_CONTROLLER_LIMIT = SHADOW_ROOT_FLUSH_MAX_COUNT;
|
|
14
|
-
// Kept as an internal compatibility export for diagnostics. Retired
|
|
15
|
-
// generations are now invalidated in O(1) and disconnected in bounded slices;
|
|
16
|
-
// this value no longer triggers synchronous cleanup.
|
|
17
|
-
export var SHADOW_ROOT_RETIRED_CONTROLLER_LIMIT = 512;
|
|
18
|
-
export var SHADOW_ROOT_SKIPPED_ANCESTOR_MAX_DEPTH = 1000;
|
|
19
|
-
var attachShadowSubscribers = [];
|
|
20
|
-
var attachShadowInstrumentation;
|
|
21
|
-
export var initShadowRootsController = function initShadowRootsController(configuration, data) {
|
|
22
|
-
var mutationCb = data.mutationCb;
|
|
23
|
-
var mutationOverflowCb = data.mutationOverflowCb;
|
|
24
|
-
var mutationActivityCb = data.mutationActivityCb;
|
|
25
|
-
var inputCb = data.inputCb;
|
|
26
|
-
var isNodeIgnored = data.isNodeIgnored;
|
|
27
|
-
var isInputNodeIgnored = data.isInputNodeIgnored || isNodeIgnored;
|
|
28
|
-
var isMutationNodeIgnored = isNodeIgnored && function (node) {
|
|
29
|
-
return isNodeIgnored(node, true);
|
|
30
|
-
};
|
|
31
|
-
var isNodePublished = data.isNodePublished;
|
|
32
|
-
var mutationNodeSerializationCb = data.mutationNodeSerializationCb;
|
|
33
|
-
var mutationResourceBudget = data.mutationResourceBudget;
|
|
34
|
-
var startMutationObserverImpl = false ? data.startMutationObserver || startMutationObserver : startMutationObserver;
|
|
35
|
-
var initInputObserverImpl = false ? data.initInputObserver || initInputObserver : initInputObserver;
|
|
36
|
-
var scheduleCleanupImpl = false ? data.scheduleCleanup || defaultScheduleCleanup : defaultScheduleCleanup;
|
|
37
|
-
var getCurrentTimeImpl = false ? data.getCurrentTime || getCurrentTime : getCurrentTime;
|
|
38
|
-
var cleanupErrorCb = false ? data.cleanupErrorCb : undefined;
|
|
39
|
-
var stopAttachShadowObserver = data.shadowRootCreatedCb ? subscribeToOpenShadowRoots(function (shadowRoot, host) {
|
|
40
|
-
if (stopped) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
data.shadowRootCreatedCb(shadowRoot, host);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
if (mutationOverflowCb) {
|
|
47
|
-
mutationOverflowCb({
|
|
48
|
-
reason: 'dynamic_shadow_root_capture_error',
|
|
49
|
-
error: String(error)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}) : noop;
|
|
54
|
-
var nextGenerationId = 0;
|
|
55
|
-
var activeGeneration = createGeneration();
|
|
56
|
-
var controllerByShadowRoot = new SDKMap();
|
|
57
|
-
// Persist only the latest registration identity. This distinguishes a root
|
|
58
|
-
// retired by a baseline reset from a never-registered nested root without
|
|
59
|
-
// walking the retired generation during reset.
|
|
60
|
-
var latestEntryByShadowRoot = new WeakMap();
|
|
61
|
-
var cleanupQueueHead;
|
|
62
|
-
var cleanupQueueTail;
|
|
63
|
-
var cleanupScheduled = false;
|
|
64
|
-
var retiredControllerCount = 0;
|
|
65
|
-
var currentFlush;
|
|
66
|
-
var pendingFlushIterator;
|
|
67
|
-
var pendingFlushGeneration;
|
|
68
|
-
var pendingFlushEntry;
|
|
69
|
-
var disconnectedCleanupIterator;
|
|
70
|
-
var disconnectedCleanupGeneration;
|
|
71
|
-
var disconnectedCleanupScheduled = false;
|
|
72
|
-
var baselineResetIterator;
|
|
73
|
-
var baselineResetGeneration;
|
|
74
|
-
var stopped = false;
|
|
75
|
-
var recoveryShadowRoots;
|
|
76
|
-
var mutationDependencyState = {
|
|
77
|
-
$rPublishedRoots: new WeakSet(),
|
|
78
|
-
$rLocallyDroppedRoots: new WeakSet()
|
|
79
|
-
};
|
|
80
|
-
var shadowRootsController = {
|
|
81
|
-
$rMutationDependencyState: mutationDependencyState,
|
|
82
|
-
addShadowRoot: function addShadowRoot(shadowRoot, provisionalOwner) {
|
|
83
|
-
if (stopped) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (controllerByShadowRoot.has(shadowRoot)) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
var entry = {
|
|
90
|
-
active: true,
|
|
91
|
-
registered: false,
|
|
92
|
-
shadowRoot: shadowRoot,
|
|
93
|
-
generation: activeGeneration,
|
|
94
|
-
mutationObserverDeactivated: false,
|
|
95
|
-
pendingOverflowAfterReset: false,
|
|
96
|
-
unpublishedMutationOverflowReported: false,
|
|
97
|
-
provisionalOwner: provisionalOwner,
|
|
98
|
-
deactivateMutationObserver: function deactivateMutationObserver() {},
|
|
99
|
-
refreshAndFlushPendingRootForNode: function refreshAndFlushPendingRootForNode() {},
|
|
100
|
-
resetMutationObserver: function resetMutationObserver() {},
|
|
101
|
-
stopMutationObserver: function stopMutationObserver() {},
|
|
102
|
-
stopInputObserver: function stopInputObserver() {}
|
|
103
|
-
};
|
|
104
|
-
if (provisionalOwner) {
|
|
105
|
-
if (!provisionalOwner.provisionalShadowRoots) {
|
|
106
|
-
provisionalOwner.provisionalShadowRoots = [];
|
|
107
|
-
}
|
|
108
|
-
provisionalOwner.provisionalShadowRoots.push(shadowRoot);
|
|
109
|
-
}
|
|
110
|
-
latestEntryByShadowRoot.set(shadowRoot, entry);
|
|
111
|
-
var mutationObserverController;
|
|
112
|
-
try {
|
|
113
|
-
mutationObserverController = startMutationObserverImpl(createGatedCallback(entry, 'mutation', mutationCb), configuration, createGatedShadowRootsController(entry), shadowRoot, data.mutationPerfCb, createGatedCallback(entry, 'overflow', mutationOverflowCb), createGatedCallback(entry, 'activity', mutationActivityCb), mutationNodeSerializationCb, isMutationNodeIgnored, isNodePublished, function () {
|
|
114
|
-
return isEntryActive(entry);
|
|
115
|
-
}, mutationResourceBudget);
|
|
116
|
-
entry.flush = mutationObserverController.flush || function () {};
|
|
117
|
-
entry.deactivateMutationObserver = mutationObserverController.deactivate || function () {};
|
|
118
|
-
entry.refreshAndFlushPendingRootForNode = mutationObserverController.refreshAndFlushPendingRootForNode || function () {};
|
|
119
|
-
entry.resetMutationObserver = mutationObserverController.reset || function () {};
|
|
120
|
-
entry.stopMutationObserver = mutationObserverController.stop || function () {};
|
|
121
|
-
|
|
122
|
-
// The change event does not bubble across a shadow root, so each active
|
|
123
|
-
// generation needs its own listener. The callback is generation-gated
|
|
124
|
-
// before the controller becomes visible in the active map.
|
|
125
|
-
var gatedInputCb = createGatedCallback(entry, 'input', inputCb);
|
|
126
|
-
entry.stopInputObserver = (isInputNodeIgnored ? initInputObserverImpl(gatedInputCb, configuration, shadowRoot, isInputNodeIgnored) : initInputObserverImpl(gatedInputCb, configuration, shadowRoot)) || function () {};
|
|
127
|
-
entry.registered = true;
|
|
128
|
-
controllerByShadowRoot.set(shadowRoot, entry);
|
|
129
|
-
return true;
|
|
130
|
-
} catch (error) {
|
|
131
|
-
entry.active = false;
|
|
132
|
-
stopControllerEntry(entry, false);
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
removeShadowRoot: function removeShadowRoot(shadowRoot) {
|
|
137
|
-
var entry = controllerByShadowRoot.get(shadowRoot);
|
|
138
|
-
if (!entry) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
entry.active = false;
|
|
142
|
-
entry.registered = false;
|
|
143
|
-
controllerByShadowRoot["delete"](shadowRoot);
|
|
144
|
-
stopControllerEntry(entry, true);
|
|
145
|
-
},
|
|
146
|
-
cleanupDisconnectedShadowRoots: function cleanupDisconnectedShadowRoots() {
|
|
147
|
-
if (stopped || controllerByShadowRoot.size === 0) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
runDisconnectedShadowRootCleanupSlice();
|
|
151
|
-
},
|
|
152
|
-
refreshAndFlushPendingRootForNode: function refreshAndFlushPendingRootForNode(node) {
|
|
153
|
-
if (stopped || !node) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
var rootNode;
|
|
157
|
-
try {
|
|
158
|
-
rootNode = node.getRootNode();
|
|
159
|
-
} catch (_) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
var entry = controllerByShadowRoot.get(rootNode);
|
|
163
|
-
if (!entry || !entry.active || !entry.registered) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
return entry.refreshAndFlushPendingRootForNode(node);
|
|
167
|
-
},
|
|
168
|
-
commitProvisionalShadowRoots: function commitProvisionalShadowRoots(owner) {
|
|
169
|
-
var shadowRoots = owner.provisionalShadowRoots || [];
|
|
170
|
-
for (var shadowRootIndex = 0; shadowRootIndex < shadowRoots.length; shadowRootIndex += 1) {
|
|
171
|
-
var shadowRoot = shadowRoots[shadowRootIndex];
|
|
172
|
-
var entry = controllerByShadowRoot.get(shadowRoot);
|
|
173
|
-
if (entry && entry.provisionalOwner === owner) {
|
|
174
|
-
entry.provisionalOwner = undefined;
|
|
175
|
-
// Recovery can begin while a serialized host add is still pending.
|
|
176
|
-
// If that add is admitted before the generation reset, its root now
|
|
177
|
-
// belongs to the previous published tree and must participate in a
|
|
178
|
-
// later rollback just like roots captured at $rBeginRecovery time.
|
|
179
|
-
if (recoveryShadowRoots && entry.active && entry.registered && recoveryShadowRoots.indexOf(shadowRoot) === -1) {
|
|
180
|
-
recoveryShadowRoots.push(shadowRoot);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
owner.provisionalShadowRoots = undefined;
|
|
185
|
-
},
|
|
186
|
-
rollbackProvisionalShadowRoots: function rollbackProvisionalShadowRoots(owner) {
|
|
187
|
-
var shadowRoots = owner.provisionalShadowRoots || [];
|
|
188
|
-
var retiredControllers = new SDKMap();
|
|
189
|
-
for (var shadowRootIndex = 0; shadowRootIndex < shadowRoots.length; shadowRootIndex += 1) {
|
|
190
|
-
var shadowRoot = shadowRoots[shadowRootIndex];
|
|
191
|
-
var entry = controllerByShadowRoot.get(shadowRoot);
|
|
192
|
-
if (!entry || entry.provisionalOwner !== owner) {
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
entry.provisionalOwner = undefined;
|
|
196
|
-
entry.active = false;
|
|
197
|
-
entry.registered = false;
|
|
198
|
-
controllerByShadowRoot["delete"](shadowRoot);
|
|
199
|
-
retiredControllers.set(shadowRoot, entry);
|
|
200
|
-
}
|
|
201
|
-
owner.provisionalShadowRoots = undefined;
|
|
202
|
-
retireControllerEntries(retiredControllers);
|
|
203
|
-
},
|
|
204
|
-
isNodeInSkippedShadowRoot: function isNodeInSkippedShadowRoot(node) {
|
|
205
|
-
if (stopped) {
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
var current = node;
|
|
209
|
-
var depth = 0;
|
|
210
|
-
while (current) {
|
|
211
|
-
if (depth >= SHADOW_ROOT_SKIPPED_ANCESTOR_MAX_DEPTH) {
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
current = getParentNode(current);
|
|
216
|
-
} catch (_) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
if (!current) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
if (isNodeShadowRoot(current)) {
|
|
223
|
-
var entry = latestEntryByShadowRoot.get(current);
|
|
224
|
-
if (entry && !isEntryActive(entry)) {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
depth += 1;
|
|
229
|
-
}
|
|
230
|
-
return false;
|
|
231
|
-
},
|
|
232
|
-
stop: function stop() {
|
|
233
|
-
if (stopped) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
try {
|
|
237
|
-
stopAttachShadowObserver();
|
|
238
|
-
} catch (error) {
|
|
239
|
-
reportCleanupError(error);
|
|
240
|
-
}
|
|
241
|
-
stopped = true;
|
|
242
|
-
recoveryShadowRoots = undefined;
|
|
243
|
-
retireActiveGeneration();
|
|
244
|
-
},
|
|
245
|
-
flush: function flush() {
|
|
246
|
-
if (stopped || controllerByShadowRoot.size === 0) {
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
var generation = activeGeneration;
|
|
250
|
-
var shadowRootCount = controllerByShadowRoot.size;
|
|
251
|
-
var flushState = currentFlush && currentFlush.generation === generation ? currentFlush : {
|
|
252
|
-
events: [],
|
|
253
|
-
eventApproxBytes: 0,
|
|
254
|
-
eventCount: 0,
|
|
255
|
-
eventBudgetReservation: undefined,
|
|
256
|
-
generation: generation,
|
|
257
|
-
overflow: undefined
|
|
258
|
-
};
|
|
259
|
-
currentFlush = flushState;
|
|
260
|
-
var deadline = getCurrentTimeImpl() + SHADOW_ROOT_FLUSH_BUDGET_MS;
|
|
261
|
-
if (!pendingFlushIterator || pendingFlushGeneration !== generation) {
|
|
262
|
-
pendingFlushIterator = controllerByShadowRoot.values();
|
|
263
|
-
pendingFlushGeneration = generation;
|
|
264
|
-
}
|
|
265
|
-
var iterator = pendingFlushIterator;
|
|
266
|
-
var flushedShadowRootCount = 0;
|
|
267
|
-
var failure;
|
|
268
|
-
var iteratorCompleted = false;
|
|
269
|
-
while (flushedShadowRootCount < SHADOW_ROOT_FLUSH_MAX_COUNT) {
|
|
270
|
-
if (flushedShadowRootCount > 0 && getCurrentTimeImpl() >= deadline) {
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
var entry = pendingFlushEntry;
|
|
274
|
-
if (!entry) {
|
|
275
|
-
var nextEntry = iterator.next();
|
|
276
|
-
if (nextEntry.done) {
|
|
277
|
-
iteratorCompleted = true;
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
entry = nextEntry.value;
|
|
281
|
-
}
|
|
282
|
-
if (!isEntryActive(entry)) {
|
|
283
|
-
pendingFlushEntry = undefined;
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
try {
|
|
287
|
-
var flushSucceeded = entry.flush();
|
|
288
|
-
flushedShadowRootCount += 1;
|
|
289
|
-
if (flushSucceeded === false || flushState.overflow) {
|
|
290
|
-
failure = {
|
|
291
|
-
reason: 'shadow_root_flush_overflow',
|
|
292
|
-
cause: flushState.overflow && flushState.overflow.reason,
|
|
293
|
-
shadowRootCount: shadowRootCount,
|
|
294
|
-
flushedShadowRootCount: flushedShadowRootCount,
|
|
295
|
-
$rSuppressMutationOverflow: flushState.overflow ? flushState.overflow.$rSuppressMutationOverflow : flushSucceeded === false && mutationResourceBudget && mutationResourceBudget.isFailed()
|
|
296
|
-
};
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
if (flushSucceeded === 'pending') {
|
|
300
|
-
// A single root can itself own a paged raw-mutation transaction.
|
|
301
|
-
// Keep the iterator pinned to that root until its final chunk is
|
|
302
|
-
// committed; advancing here would let a boundary reset/stop drop
|
|
303
|
-
// the unfinished transaction while reporting a successful flush.
|
|
304
|
-
pendingFlushEntry = entry;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
pendingFlushEntry = undefined;
|
|
308
|
-
} catch (error) {
|
|
309
|
-
failure = {
|
|
310
|
-
reason: 'shadow_root_flush_error',
|
|
311
|
-
error: String(error),
|
|
312
|
-
shadowRootCount: shadowRootCount,
|
|
313
|
-
flushedShadowRootCount: flushedShadowRootCount
|
|
314
|
-
};
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
if (failure) {
|
|
319
|
-
clearPendingShadowRootFlush();
|
|
320
|
-
return failFlush(generation, failure);
|
|
321
|
-
}
|
|
322
|
-
if (!iteratorCompleted) {
|
|
323
|
-
// Keep every page buffered in one logical commit. The caller can
|
|
324
|
-
// yield and invoke flush() again; native callbacks occurring between
|
|
325
|
-
// pages join the same generation-gated transaction.
|
|
326
|
-
return 'pending';
|
|
327
|
-
}
|
|
328
|
-
currentFlush = undefined;
|
|
329
|
-
var eventsToDispatch = coalesceMutationEvents(flushState.events.filter(function (event) {
|
|
330
|
-
return isEntryActive(event.entry);
|
|
331
|
-
}));
|
|
332
|
-
try {
|
|
333
|
-
for (var eventIndex = 0; eventIndex < eventsToDispatch.length; eventIndex += 1) {
|
|
334
|
-
var event = eventsToDispatch[eventIndex];
|
|
335
|
-
var eventEntries = event.entries || [event.entry];
|
|
336
|
-
if (!eventEntries.some(function (entry) {
|
|
337
|
-
return isEntryActive(entry);
|
|
338
|
-
})) {
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
event.callback(event.value);
|
|
342
|
-
}
|
|
343
|
-
} finally {
|
|
344
|
-
releaseShadowRootFlushBudget(flushState);
|
|
345
|
-
}
|
|
346
|
-
if (iteratorCompleted) {
|
|
347
|
-
clearPendingShadowRootFlush();
|
|
348
|
-
}
|
|
349
|
-
return isGenerationActive(generation);
|
|
350
|
-
},
|
|
351
|
-
$rResetPendingMutationsForBaseline: function $rResetPendingMutationsForBaseline() {
|
|
352
|
-
if (stopped || controllerByShadowRoot.size === 0) {
|
|
353
|
-
clearPendingShadowRootBaselineReset();
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
var generation = activeGeneration;
|
|
357
|
-
if (!baselineResetIterator || baselineResetGeneration !== generation) {
|
|
358
|
-
baselineResetIterator = controllerByShadowRoot.values();
|
|
359
|
-
baselineResetGeneration = generation;
|
|
360
|
-
}
|
|
361
|
-
var deadline = getCurrentTimeImpl() + SHADOW_ROOT_FLUSH_BUDGET_MS;
|
|
362
|
-
var resetCount = 0;
|
|
363
|
-
while (resetCount < SHADOW_ROOT_FLUSH_MAX_COUNT) {
|
|
364
|
-
if (resetCount > 0 && getCurrentTimeImpl() >= deadline) {
|
|
365
|
-
return 'pending';
|
|
366
|
-
}
|
|
367
|
-
var nextEntry = baselineResetIterator.next();
|
|
368
|
-
if (nextEntry.done) {
|
|
369
|
-
clearPendingShadowRootBaselineReset();
|
|
370
|
-
return true;
|
|
371
|
-
}
|
|
372
|
-
var entry = nextEntry.value;
|
|
373
|
-
if (!isEntryActive(entry)) {
|
|
374
|
-
continue;
|
|
375
|
-
}
|
|
376
|
-
try {
|
|
377
|
-
// reset() performs takeRecords(), reports mutation activity, and
|
|
378
|
-
// discards the obsolete raw/task generation without serializing it.
|
|
379
|
-
// The caller restarts the mixed-time FullSnapshot when that activity
|
|
380
|
-
// advances its DOM version.
|
|
381
|
-
entry.resetMutationObserver();
|
|
382
|
-
} catch (error) {
|
|
383
|
-
clearPendingShadowRootBaselineReset();
|
|
384
|
-
if (mutationOverflowCb) {
|
|
385
|
-
mutationOverflowCb({
|
|
386
|
-
reason: 'shadow_root_baseline_reset_error',
|
|
387
|
-
error: String(error)
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
resetCount += 1;
|
|
393
|
-
}
|
|
394
|
-
return 'pending';
|
|
395
|
-
},
|
|
396
|
-
reset: function reset() {
|
|
397
|
-
if (stopped) {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
retireActiveGeneration();
|
|
401
|
-
},
|
|
402
|
-
$rBeginRecovery: function $rBeginRecovery() {
|
|
403
|
-
if (stopped || recoveryShadowRoots) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
recoveryShadowRoots = [];
|
|
407
|
-
controllerByShadowRoot.forEach(function (entry, shadowRoot) {
|
|
408
|
-
if (entry.active && entry.registered && !entry.provisionalOwner) {
|
|
409
|
-
recoveryShadowRoots.push(shadowRoot);
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
},
|
|
413
|
-
$rCommitRecovery: function $rCommitRecovery() {
|
|
414
|
-
recoveryShadowRoots = undefined;
|
|
415
|
-
},
|
|
416
|
-
$rRollbackRecovery: function $rRollbackRecovery() {
|
|
417
|
-
if (stopped || !recoveryShadowRoots) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
var shadowRoots = recoveryShadowRoots;
|
|
421
|
-
recoveryShadowRoots = undefined;
|
|
422
|
-
// Retire observers registered by the incomplete snapshot before
|
|
423
|
-
// rebuilding the bounded observer set from the previous published
|
|
424
|
-
// baseline. Observer installation is complete for every registered
|
|
425
|
-
// root; explicit flushing is independently time-sliced.
|
|
426
|
-
retireActiveGeneration();
|
|
427
|
-
// This synchronous reinstall is deliberately limited to the abandoned
|
|
428
|
-
// replacement-baseline path. Paging it would leave a window where
|
|
429
|
-
// mutations inside a previously published root are not observed, so
|
|
430
|
-
// correctness takes precedence over latency on this rare failure path.
|
|
431
|
-
shadowRoots.forEach(function (shadowRoot) {
|
|
432
|
-
try {
|
|
433
|
-
if (shadowRootBelongsToObservedDocument(shadowRoot)) {
|
|
434
|
-
shadowRootsController.addShadowRoot(shadowRoot);
|
|
435
|
-
}
|
|
436
|
-
} catch (error) {
|
|
437
|
-
reportCleanupError(error);
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
return shadowRootsController;
|
|
443
|
-
function createGeneration() {
|
|
444
|
-
return {
|
|
445
|
-
active: true,
|
|
446
|
-
id: ++nextGenerationId
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
function isGenerationActive(generation) {
|
|
450
|
-
return !stopped && generation.active && generation === activeGeneration;
|
|
451
|
-
}
|
|
452
|
-
function shadowRootBelongsToObservedDocument(shadowRoot) {
|
|
453
|
-
try {
|
|
454
|
-
return Boolean(shadowRoot.host && shadowRoot.host.isConnected && shadowRoot.host.ownerDocument === document);
|
|
455
|
-
} catch (_) {
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
function isEntryActive(entry) {
|
|
460
|
-
return entry.active && entry.registered && controllerByShadowRoot.get(entry.shadowRoot) === entry && isGenerationActive(entry.generation);
|
|
461
|
-
}
|
|
462
|
-
function createGatedCallback(entry, type, callback) {
|
|
463
|
-
if (!callback) {
|
|
464
|
-
return undefined;
|
|
465
|
-
}
|
|
466
|
-
return function (value) {
|
|
467
|
-
if (type === 'mutation' && isEntryShadowRootIgnored(entry)) {
|
|
468
|
-
if (!entry.unpublishedMutationOverflowReported) {
|
|
469
|
-
entry.unpublishedMutationOverflowReported = true;
|
|
470
|
-
var unpublishedMutationOverflow = {
|
|
471
|
-
reason: 'shadow_root_mutation_before_publication'
|
|
472
|
-
};
|
|
473
|
-
if (currentFlush && currentFlush.generation === entry.generation) {
|
|
474
|
-
currentFlush.overflow = unpublishedMutationOverflow;
|
|
475
|
-
} else if (mutationOverflowCb) {
|
|
476
|
-
mutationOverflowCb(unpublishedMutationOverflow);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
var pendingOverflowAfterReset = type === 'overflow' && entry.pendingOverflowAfterReset && !stopped;
|
|
482
|
-
if (!isEntryActive(entry) && !pendingOverflowAfterReset) {
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (pendingOverflowAfterReset) {
|
|
486
|
-
entry.pendingOverflowAfterReset = false;
|
|
487
|
-
}
|
|
488
|
-
if (currentFlush && currentFlush.generation === entry.generation) {
|
|
489
|
-
if (type === 'overflow') {
|
|
490
|
-
currentFlush.overflow = value || {
|
|
491
|
-
reason: 'shadow_root_observer_overflow'
|
|
492
|
-
};
|
|
493
|
-
} else {
|
|
494
|
-
if (!reserveShadowRootFlushEvent(currentFlush, type, value)) {
|
|
495
|
-
var shouldReportOverflow = !mutationResourceBudget || mutationResourceBudget.failOnce();
|
|
496
|
-
currentFlush.overflow = {
|
|
497
|
-
reason: 'aggregate_shadow_flush_watermark',
|
|
498
|
-
mutationApproxBytes: currentFlush.eventApproxBytes + estimateShadowRootFlushEventApproxBytes(type, value),
|
|
499
|
-
$rSuppressMutationOverflow: !shouldReportOverflow
|
|
500
|
-
};
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
currentFlush.events.push({
|
|
504
|
-
callback: callback,
|
|
505
|
-
entry: entry,
|
|
506
|
-
type: type,
|
|
507
|
-
value: value
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
callback(value);
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
function coalesceMutationEvents(events) {
|
|
516
|
-
var result = [];
|
|
517
|
-
var mergedMutationEvent;
|
|
518
|
-
events.forEach(function (event) {
|
|
519
|
-
if (event.type !== 'mutation') {
|
|
520
|
-
// Only adjacent mutation callbacks are one coalescing window. Input
|
|
521
|
-
// and other state events can arrive between paged root flushes; moving
|
|
522
|
-
// a later mutation ahead of that event would corrupt replay ordering.
|
|
523
|
-
mergedMutationEvent = undefined;
|
|
524
|
-
result.push(event);
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
if (!mergedMutationEvent) {
|
|
528
|
-
mergedMutationEvent = {
|
|
529
|
-
callback: event.callback,
|
|
530
|
-
entries: [],
|
|
531
|
-
entry: event.entry,
|
|
532
|
-
type: event.type,
|
|
533
|
-
value: {
|
|
534
|
-
adds: [],
|
|
535
|
-
removes: [],
|
|
536
|
-
texts: [],
|
|
537
|
-
attributes: []
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
result.push(mergedMutationEvent);
|
|
541
|
-
}
|
|
542
|
-
mergedMutationEvent.entries.push(event.entry);
|
|
543
|
-
Array.prototype.push.apply(mergedMutationEvent.value.adds, event.value.adds);
|
|
544
|
-
Array.prototype.push.apply(mergedMutationEvent.value.removes, event.value.removes);
|
|
545
|
-
Array.prototype.push.apply(mergedMutationEvent.value.texts, event.value.texts);
|
|
546
|
-
Array.prototype.push.apply(mergedMutationEvent.value.attributes, event.value.attributes);
|
|
547
|
-
});
|
|
548
|
-
return result;
|
|
549
|
-
}
|
|
550
|
-
function reserveShadowRootFlushEvent(flushState, type, value) {
|
|
551
|
-
var eventApproxBytes = estimateShadowRootFlushEventApproxBytes(type, value);
|
|
552
|
-
var nextEventCount = flushState.eventCount + 1;
|
|
553
|
-
var nextEventApproxBytes = flushState.eventApproxBytes + eventApproxBytes;
|
|
554
|
-
if (mutationResourceBudget) {
|
|
555
|
-
if (!flushState.eventBudgetReservation) {
|
|
556
|
-
flushState.eventBudgetReservation = mutationResourceBudget.reserve(MUTATION_RESOURCE_FLUSH, {
|
|
557
|
-
eventCount: nextEventCount,
|
|
558
|
-
approxBytes: nextEventApproxBytes
|
|
559
|
-
});
|
|
560
|
-
if (!flushState.eventBudgetReservation) {
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
} else if (!flushState.eventBudgetReservation.update({
|
|
564
|
-
eventCount: nextEventCount,
|
|
565
|
-
approxBytes: nextEventApproxBytes
|
|
566
|
-
})) {
|
|
567
|
-
return false;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
flushState.eventCount = nextEventCount;
|
|
571
|
-
flushState.eventApproxBytes = nextEventApproxBytes;
|
|
572
|
-
return true;
|
|
573
|
-
}
|
|
574
|
-
function releaseShadowRootFlushBudget(flushState) {
|
|
575
|
-
if (flushState && flushState.eventBudgetReservation) {
|
|
576
|
-
flushState.eventBudgetReservation();
|
|
577
|
-
flushState.eventBudgetReservation = undefined;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
function estimateShadowRootFlushEventApproxBytes(type, value) {
|
|
581
|
-
if (type === 'mutation') {
|
|
582
|
-
return getMutationPayloadApproxBytes(value);
|
|
583
|
-
}
|
|
584
|
-
var approxBytes = 64;
|
|
585
|
-
if (!value || _typeof(value) !== 'object') {
|
|
586
|
-
return approxBytes + (typeof value === 'string' ? value.length * 2 : 0);
|
|
587
|
-
}
|
|
588
|
-
Object.keys(value).slice(0, 64).forEach(function (name) {
|
|
589
|
-
var propertyValue = value[name];
|
|
590
|
-
approxBytes += name.length * 2 + 16;
|
|
591
|
-
if (typeof propertyValue === 'string') {
|
|
592
|
-
approxBytes += propertyValue.length * 2;
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
return approxBytes;
|
|
596
|
-
}
|
|
597
|
-
function isEntryShadowRootIgnored(entry) {
|
|
598
|
-
if (!isNodeIgnored) {
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
601
|
-
try {
|
|
602
|
-
return isNodeIgnored(entry.shadowRoot);
|
|
603
|
-
} catch (_) {
|
|
604
|
-
return true;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function createGatedShadowRootsController(entry) {
|
|
608
|
-
return {
|
|
609
|
-
$rMutationDependencyState: mutationDependencyState,
|
|
610
|
-
addShadowRoot: function addShadowRoot(shadowRoot, provisionalOwner) {
|
|
611
|
-
if (isEntryActive(entry)) {
|
|
612
|
-
return shadowRootsController.addShadowRoot(shadowRoot, provisionalOwner);
|
|
613
|
-
}
|
|
614
|
-
return false;
|
|
615
|
-
},
|
|
616
|
-
removeShadowRoot: function removeShadowRoot(shadowRoot) {
|
|
617
|
-
if (isEntryActive(entry)) {
|
|
618
|
-
shadowRootsController.removeShadowRoot(shadowRoot);
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
cleanupDisconnectedShadowRoots: function cleanupDisconnectedShadowRoots() {
|
|
622
|
-
if (isEntryActive(entry)) {
|
|
623
|
-
shadowRootsController.cleanupDisconnectedShadowRoots();
|
|
624
|
-
}
|
|
625
|
-
},
|
|
626
|
-
reset: function reset() {
|
|
627
|
-
if (isEntryActive(entry)) {
|
|
628
|
-
// A removed-subtree traversal overflow resets the shadow-root
|
|
629
|
-
// registry immediately, then reports its reason through the
|
|
630
|
-
// observer overflow callback. Keep that one callback armed across
|
|
631
|
-
// the generation swap so recovery is not lost. Every other callback
|
|
632
|
-
// from the retired generation remains gated.
|
|
633
|
-
entry.pendingOverflowAfterReset = true;
|
|
634
|
-
shadowRootsController.reset();
|
|
635
|
-
}
|
|
636
|
-
},
|
|
637
|
-
commitProvisionalShadowRoots: function commitProvisionalShadowRoots(owner) {
|
|
638
|
-
shadowRootsController.commitProvisionalShadowRoots(owner);
|
|
639
|
-
},
|
|
640
|
-
rollbackProvisionalShadowRoots: function rollbackProvisionalShadowRoots(owner) {
|
|
641
|
-
shadowRootsController.rollbackProvisionalShadowRoots(owner);
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
function failFlush(generation, overflow) {
|
|
646
|
-
releaseShadowRootFlushBudget(currentFlush);
|
|
647
|
-
currentFlush = undefined;
|
|
648
|
-
if (generation === activeGeneration) {
|
|
649
|
-
retireActiveGeneration();
|
|
650
|
-
}
|
|
651
|
-
if (!stopped && mutationOverflowCb && !overflow.$rSuppressMutationOverflow) {
|
|
652
|
-
mutationOverflowCb(overflow);
|
|
653
|
-
}
|
|
654
|
-
return false;
|
|
655
|
-
}
|
|
656
|
-
function retireActiveGeneration() {
|
|
657
|
-
releaseShadowRootFlushBudget(currentFlush);
|
|
658
|
-
currentFlush = undefined;
|
|
659
|
-
clearPendingShadowRootFlush();
|
|
660
|
-
clearPendingShadowRootBaselineReset();
|
|
661
|
-
clearDisconnectedShadowRootCleanup();
|
|
662
|
-
var retiredGeneration = activeGeneration;
|
|
663
|
-
var retiredControllers = controllerByShadowRoot;
|
|
664
|
-
retiredGeneration.active = false;
|
|
665
|
-
// These sets describe dependencies inside one published replay baseline.
|
|
666
|
-
// Reusing them after a reset would make a node dropped in an old
|
|
667
|
-
// generation permanently poison later moves of the same live node.
|
|
668
|
-
mutationDependencyState.$rPublishedRoots = new WeakSet();
|
|
669
|
-
mutationDependencyState.$rLocallyDroppedRoots = new WeakSet();
|
|
670
|
-
activeGeneration = createGeneration();
|
|
671
|
-
controllerByShadowRoot = new SDKMap();
|
|
672
|
-
retireControllerEntries(retiredControllers);
|
|
673
|
-
}
|
|
674
|
-
function clearPendingShadowRootFlush() {
|
|
675
|
-
pendingFlushIterator = undefined;
|
|
676
|
-
pendingFlushGeneration = undefined;
|
|
677
|
-
pendingFlushEntry = undefined;
|
|
678
|
-
}
|
|
679
|
-
function clearPendingShadowRootBaselineReset() {
|
|
680
|
-
baselineResetIterator = undefined;
|
|
681
|
-
baselineResetGeneration = undefined;
|
|
682
|
-
}
|
|
683
|
-
function runDisconnectedShadowRootCleanupSlice() {
|
|
684
|
-
if (!disconnectedCleanupIterator || disconnectedCleanupGeneration !== activeGeneration) {
|
|
685
|
-
disconnectedCleanupIterator = controllerByShadowRoot.entries();
|
|
686
|
-
disconnectedCleanupGeneration = activeGeneration;
|
|
687
|
-
}
|
|
688
|
-
var deadline = getCurrentTimeImpl() + SHADOW_ROOT_CLEANUP_BUDGET_MS;
|
|
689
|
-
var scanned = 0;
|
|
690
|
-
while (scanned < SHADOW_ROOT_CLEANUP_BATCH_SIZE) {
|
|
691
|
-
var nextEntry = disconnectedCleanupIterator.next();
|
|
692
|
-
if (nextEntry.done) {
|
|
693
|
-
clearDisconnectedShadowRootCleanup();
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
scanned += 1;
|
|
697
|
-
var shadowRoot = nextEntry.value[0];
|
|
698
|
-
if (!shadowRootBelongsToObservedDocument(shadowRoot)) {
|
|
699
|
-
try {
|
|
700
|
-
shadowRootsController.removeShadowRoot(shadowRoot);
|
|
701
|
-
} catch (_) {}
|
|
702
|
-
}
|
|
703
|
-
if (getCurrentTimeImpl() >= deadline) {
|
|
704
|
-
break;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
scheduleDisconnectedShadowRootCleanup();
|
|
708
|
-
}
|
|
709
|
-
function scheduleDisconnectedShadowRootCleanup() {
|
|
710
|
-
if (disconnectedCleanupScheduled || !disconnectedCleanupIterator || stopped) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
disconnectedCleanupScheduled = true;
|
|
714
|
-
setTimeout(function () {
|
|
715
|
-
disconnectedCleanupScheduled = false;
|
|
716
|
-
if (!stopped && disconnectedCleanupIterator) {
|
|
717
|
-
runDisconnectedShadowRootCleanupSlice();
|
|
718
|
-
}
|
|
719
|
-
}, 0);
|
|
720
|
-
}
|
|
721
|
-
function clearDisconnectedShadowRootCleanup() {
|
|
722
|
-
disconnectedCleanupIterator = undefined;
|
|
723
|
-
disconnectedCleanupGeneration = undefined;
|
|
724
|
-
}
|
|
725
|
-
function retireControllerEntries(retiredControllers) {
|
|
726
|
-
if (retiredControllers.size > 0) {
|
|
727
|
-
// The generation (or provisional map membership) has already been
|
|
728
|
-
// invalidated, so native observer ingress is gated without walking every
|
|
729
|
-
// entry here. Physical observer/listener teardown remains bounded below.
|
|
730
|
-
var cleanupItem = {
|
|
731
|
-
controllers: retiredControllers,
|
|
732
|
-
iterator: retiredControllers.entries(),
|
|
733
|
-
next: undefined
|
|
734
|
-
};
|
|
735
|
-
retiredControllerCount += retiredControllers.size;
|
|
736
|
-
if (cleanupQueueTail) {
|
|
737
|
-
cleanupQueueTail.next = cleanupItem;
|
|
738
|
-
} else {
|
|
739
|
-
cleanupQueueHead = cleanupItem;
|
|
740
|
-
}
|
|
741
|
-
cleanupQueueTail = cleanupItem;
|
|
742
|
-
scheduleCleanup();
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
function scheduleCleanup() {
|
|
746
|
-
if (cleanupScheduled || !cleanupQueueHead) {
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
cleanupScheduled = true;
|
|
750
|
-
try {
|
|
751
|
-
scheduleCleanupImpl(runCleanupSlice);
|
|
752
|
-
} catch (error) {
|
|
753
|
-
cleanupScheduled = false;
|
|
754
|
-
reportCleanupError(error);
|
|
755
|
-
if (scheduleCleanupImpl !== defaultScheduleCleanup) {
|
|
756
|
-
cleanupScheduled = true;
|
|
757
|
-
try {
|
|
758
|
-
defaultScheduleCleanup(runCleanupSlice);
|
|
759
|
-
} catch (fallbackError) {
|
|
760
|
-
cleanupScheduled = false;
|
|
761
|
-
reportCleanupError(fallbackError);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
function runCleanupSlice() {
|
|
767
|
-
cleanupScheduled = false;
|
|
768
|
-
var deadline = getCurrentTimeImpl() + SHADOW_ROOT_CLEANUP_BUDGET_MS;
|
|
769
|
-
var cleanedControllerCount = 0;
|
|
770
|
-
while (cleanupQueueHead) {
|
|
771
|
-
var cleanupItem = cleanupQueueHead;
|
|
772
|
-
var nextEntry = cleanupItem.iterator.next();
|
|
773
|
-
if (nextEntry.done) {
|
|
774
|
-
cleanupQueueHead = cleanupItem.next;
|
|
775
|
-
cleanupItem.next = undefined;
|
|
776
|
-
if (!cleanupQueueHead) {
|
|
777
|
-
cleanupQueueTail = undefined;
|
|
778
|
-
}
|
|
779
|
-
continue;
|
|
780
|
-
}
|
|
781
|
-
var shadowRoot = nextEntry.value[0];
|
|
782
|
-
var entry = nextEntry.value[1];
|
|
783
|
-
cleanupItem.controllers["delete"](shadowRoot);
|
|
784
|
-
retiredControllerCount = Math.max(retiredControllerCount - 1, 0);
|
|
785
|
-
entry.active = false;
|
|
786
|
-
entry.registered = false;
|
|
787
|
-
entry.pendingOverflowAfterReset = false;
|
|
788
|
-
stopControllerEntry(entry, false);
|
|
789
|
-
cleanedControllerCount += 1;
|
|
790
|
-
if (cleanedControllerCount >= SHADOW_ROOT_CLEANUP_BATCH_SIZE || getCurrentTimeImpl() >= deadline) {
|
|
791
|
-
break;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (!cleanupQueueHead) {
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
scheduleCleanup();
|
|
798
|
-
}
|
|
799
|
-
function deactivateControllerEntry(entry) {
|
|
800
|
-
if (entry.mutationObserverDeactivated) {
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
entry.mutationObserverDeactivated = true;
|
|
804
|
-
try {
|
|
805
|
-
entry.deactivateMutationObserver();
|
|
806
|
-
} catch (error) {
|
|
807
|
-
return error;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
function stopControllerEntry(entry, shouldThrow) {
|
|
811
|
-
var firstError = deactivateControllerEntry(entry);
|
|
812
|
-
try {
|
|
813
|
-
entry.stopMutationObserver();
|
|
814
|
-
} catch (error) {
|
|
815
|
-
if (!firstError) {
|
|
816
|
-
firstError = error;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
try {
|
|
820
|
-
entry.stopInputObserver();
|
|
821
|
-
} catch (error) {
|
|
822
|
-
if (!firstError) {
|
|
823
|
-
firstError = error;
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
if (firstError) {
|
|
827
|
-
reportCleanupError(firstError);
|
|
828
|
-
}
|
|
829
|
-
if (firstError && shouldThrow) {
|
|
830
|
-
throw firstError;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
function reportCleanupError(error) {
|
|
834
|
-
if (!cleanupErrorCb) {
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
try {
|
|
838
|
-
cleanupErrorCb(error);
|
|
839
|
-
} catch (_) {}
|
|
840
|
-
}
|
|
841
|
-
function defaultScheduleCleanup(callback) {
|
|
842
|
-
setTimeout(callback, 0);
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
function getCurrentTime() {
|
|
846
|
-
if (typeof performance !== 'undefined' && performance.now) {
|
|
847
|
-
return performance.now();
|
|
848
|
-
}
|
|
849
|
-
return Date.now();
|
|
850
|
-
}
|
|
851
|
-
function subscribeToOpenShadowRoots(callback) {
|
|
852
|
-
if (typeof Element === 'undefined' || !Element.prototype || typeof Element.prototype.attachShadow !== 'function') {
|
|
853
|
-
return noop;
|
|
854
|
-
}
|
|
855
|
-
var subscriber = {
|
|
856
|
-
callback: callback
|
|
857
|
-
};
|
|
858
|
-
attachShadowSubscribers.push(subscriber);
|
|
859
|
-
if (!attachShadowInstrumentation) {
|
|
860
|
-
try {
|
|
861
|
-
attachShadowInstrumentation = instrumentMethod(Element.prototype, 'attachShadow', function (call) {
|
|
862
|
-
var host = call.target;
|
|
863
|
-
call.onPostCall(function (shadowRoot) {
|
|
864
|
-
// Closed roots are intentionally outside the replay contract.
|
|
865
|
-
// Checking the public host property avoids reading the caller's
|
|
866
|
-
// options twice and only admits roots exposed as mode: "open".
|
|
867
|
-
if (!shadowRoot || host.shadowRoot !== shadowRoot) {
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
attachShadowSubscribers.slice().forEach(function (activeSubscriber) {
|
|
871
|
-
try {
|
|
872
|
-
activeSubscriber.callback(shadowRoot, host);
|
|
873
|
-
} catch (_) {}
|
|
874
|
-
});
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
} catch (error) {
|
|
878
|
-
removeAttachShadowSubscriber(subscriber);
|
|
879
|
-
throw error;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
var subscriptionStopped = false;
|
|
883
|
-
return function () {
|
|
884
|
-
if (subscriptionStopped) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
subscriptionStopped = true;
|
|
888
|
-
removeAttachShadowSubscriber(subscriber);
|
|
889
|
-
if (attachShadowSubscribers.length === 0 && attachShadowInstrumentation) {
|
|
890
|
-
var instrumentation = attachShadowInstrumentation;
|
|
891
|
-
attachShadowInstrumentation = undefined;
|
|
892
|
-
instrumentation.stop();
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
function removeAttachShadowSubscriber(subscriber) {
|
|
897
|
-
var subscriberIndex = attachShadowSubscribers.indexOf(subscriber);
|
|
898
|
-
if (subscriberIndex !== -1) {
|
|
899
|
-
attachShadowSubscribers.splice(subscriberIndex, 1);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
//# sourceMappingURL=shadowRootsController.js.map
|
|
1
|
+
function _typeof(o){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}import{SDKMap}from"@cloudcare/browser-core";import{getParentNode,instrumentMethod,isNodeShadowRoot,noop,setTimeout}from"@cloudcare/browser-core";import{getMutationPayloadApproxBytes,startMutationObserver}from"./mutationObserver";import{initInputObserver}from"./observers";import{MUTATION_RESOURCE_FLUSH}from"./mutationResourceBudget";export var SHADOW_ROOT_CLEANUP_BATCH_SIZE=32;export var SHADOW_ROOT_CLEANUP_BUDGET_MS=4;export var SHADOW_ROOT_FLUSH_MAX_COUNT=64;export var SHADOW_ROOT_FLUSH_BUDGET_MS=4;export var SHADOW_ROOT_ACTIVE_CONTROLLER_LIMIT=SHADOW_ROOT_FLUSH_MAX_COUNT;export var SHADOW_ROOT_RETIRED_CONTROLLER_LIMIT=512;export var SHADOW_ROOT_SKIPPED_ANCESTOR_MAX_DEPTH=1e3;var attachShadowInstrumentation,attachShadowSubscribers=[];export var initShadowRootsController=function initShadowRootsController(configuration,data){var cleanupQueueHead,cleanupQueueTail,currentFlush,pendingFlushIterator,pendingFlushGeneration,pendingFlushEntry,disconnectedCleanupIterator,disconnectedCleanupGeneration,baselineResetIterator,baselineResetGeneration,recoveryShadowRoots,mutationCb=data.mutationCb,mutationOverflowCb=data.mutationOverflowCb,mutationActivityCb=data.mutationActivityCb,inputCb=data.inputCb,isNodeIgnored=data.isNodeIgnored,isInputNodeIgnored=data.isInputNodeIgnored||isNodeIgnored,isMutationNodeIgnored=isNodeIgnored&&function(node){return isNodeIgnored(node,!0)},isNodePublished=data.isNodePublished,mutationNodeSerializationCb=data.mutationNodeSerializationCb,mutationResourceBudget=data.mutationResourceBudget,startMutationObserverImpl=startMutationObserver,initInputObserverImpl=initInputObserver,scheduleCleanupImpl=defaultScheduleCleanup,getCurrentTimeImpl=getCurrentTime,cleanupErrorCb=void 0,stopAttachShadowObserver=data.shadowRootCreatedCb?function subscribeToOpenShadowRoots(callback){if("undefined"==typeof Element||!Element.prototype||"function"!=typeof Element.prototype.attachShadow)return noop;var subscriber={callback:callback};if(attachShadowSubscribers.push(subscriber),!attachShadowInstrumentation)try{attachShadowInstrumentation=instrumentMethod(Element.prototype,"attachShadow",(function(call){var host=call.target;call.onPostCall((function(shadowRoot){shadowRoot&&host.shadowRoot===shadowRoot&&attachShadowSubscribers.slice().forEach((function(activeSubscriber){try{activeSubscriber.callback(shadowRoot,host)}catch(_){}}))}))}))}catch(error){throw removeAttachShadowSubscriber(subscriber),error}var subscriptionStopped=!1;return function(){if(!subscriptionStopped&&(subscriptionStopped=!0,removeAttachShadowSubscriber(subscriber),0===attachShadowSubscribers.length&&attachShadowInstrumentation)){var instrumentation=attachShadowInstrumentation;attachShadowInstrumentation=void 0,instrumentation.stop()}}}((function(shadowRoot,host){if(!stopped)try{data.shadowRootCreatedCb(shadowRoot,host)}catch(error){mutationOverflowCb&&mutationOverflowCb({reason:"dynamic_shadow_root_capture_error",error:String(error)})}})):noop,nextGenerationId=0,activeGeneration=createGeneration(),controllerByShadowRoot=new SDKMap,latestEntryByShadowRoot=new WeakMap,cleanupScheduled=!1,retiredControllerCount=0,disconnectedCleanupScheduled=!1,stopped=!1,mutationDependencyState={$rPublishedRoots:new WeakSet,$rLocallyDroppedRoots:new WeakSet},shadowRootsController={$rMutationDependencyState:mutationDependencyState,addShadowRoot:function addShadowRoot(shadowRoot,provisionalOwner){if(stopped)return!1;if(controllerByShadowRoot.has(shadowRoot))return!0;var mutationObserverController,entry={active:!0,registered:!1,shadowRoot:shadowRoot,generation:activeGeneration,mutationObserverDeactivated:!1,pendingOverflowAfterReset:!1,unpublishedMutationOverflowReported:!1,provisionalOwner:provisionalOwner,deactivateMutationObserver:function deactivateMutationObserver(){},refreshAndFlushPendingRootForNode:function refreshAndFlushPendingRootForNode(){},resetMutationObserver:function resetMutationObserver(){},stopMutationObserver:function stopMutationObserver(){},stopInputObserver:function stopInputObserver(){}};provisionalOwner&&(provisionalOwner.provisionalShadowRoots||(provisionalOwner.provisionalShadowRoots=[]),provisionalOwner.provisionalShadowRoots.push(shadowRoot)),latestEntryByShadowRoot.set(shadowRoot,entry);try{mutationObserverController=startMutationObserverImpl(createGatedCallback(entry,"mutation",mutationCb),configuration,function createGatedShadowRootsController(entry){return{$rMutationDependencyState:mutationDependencyState,addShadowRoot:function addShadowRoot(shadowRoot,provisionalOwner){return!!isEntryActive(entry)&&shadowRootsController.addShadowRoot(shadowRoot,provisionalOwner)},removeShadowRoot:function removeShadowRoot(shadowRoot){isEntryActive(entry)&&shadowRootsController.removeShadowRoot(shadowRoot)},cleanupDisconnectedShadowRoots:function cleanupDisconnectedShadowRoots(){isEntryActive(entry)&&shadowRootsController.cleanupDisconnectedShadowRoots()},reset:function reset(){isEntryActive(entry)&&(entry.pendingOverflowAfterReset=!0,shadowRootsController.reset())},commitProvisionalShadowRoots:function commitProvisionalShadowRoots(owner){shadowRootsController.commitProvisionalShadowRoots(owner)},rollbackProvisionalShadowRoots:function rollbackProvisionalShadowRoots(owner){shadowRootsController.rollbackProvisionalShadowRoots(owner)}}}(entry),shadowRoot,data.mutationPerfCb,createGatedCallback(entry,"overflow",mutationOverflowCb),createGatedCallback(entry,"activity",mutationActivityCb),mutationNodeSerializationCb,isMutationNodeIgnored,isNodePublished,(function(){return isEntryActive(entry)}),mutationResourceBudget),entry.flush=mutationObserverController.flush||function(){},entry.deactivateMutationObserver=mutationObserverController.deactivate||function(){},entry.refreshAndFlushPendingRootForNode=mutationObserverController.refreshAndFlushPendingRootForNode||function(){},entry.resetMutationObserver=mutationObserverController.reset||function(){},entry.stopMutationObserver=mutationObserverController.stop||function(){};var gatedInputCb=createGatedCallback(entry,"input",inputCb);return entry.stopInputObserver=(isInputNodeIgnored?initInputObserverImpl(gatedInputCb,configuration,shadowRoot,isInputNodeIgnored):initInputObserverImpl(gatedInputCb,configuration,shadowRoot))||function(){},entry.registered=!0,controllerByShadowRoot.set(shadowRoot,entry),!0}catch(error){throw entry.active=!1,stopControllerEntry(entry,!1),error}},removeShadowRoot:function removeShadowRoot(shadowRoot){var entry=controllerByShadowRoot.get(shadowRoot);entry&&(entry.active=!1,entry.registered=!1,controllerByShadowRoot.delete(shadowRoot),stopControllerEntry(entry,!0))},cleanupDisconnectedShadowRoots:function cleanupDisconnectedShadowRoots(){stopped||0===controllerByShadowRoot.size||runDisconnectedShadowRootCleanupSlice()},refreshAndFlushPendingRootForNode:function refreshAndFlushPendingRootForNode(node){if(!stopped&&node){var rootNode;try{rootNode=node.getRootNode()}catch(_){return}var entry=controllerByShadowRoot.get(rootNode);if(entry&&entry.active&&entry.registered)return entry.refreshAndFlushPendingRootForNode(node)}},commitProvisionalShadowRoots:function commitProvisionalShadowRoots(owner){for(var shadowRoots=owner.provisionalShadowRoots||[],shadowRootIndex=0;shadowRootIndex<shadowRoots.length;shadowRootIndex+=1){var shadowRoot=shadowRoots[shadowRootIndex],entry=controllerByShadowRoot.get(shadowRoot);entry&&entry.provisionalOwner===owner&&(entry.provisionalOwner=void 0,recoveryShadowRoots&&entry.active&&entry.registered&&-1===recoveryShadowRoots.indexOf(shadowRoot)&&recoveryShadowRoots.push(shadowRoot))}owner.provisionalShadowRoots=void 0},rollbackProvisionalShadowRoots:function rollbackProvisionalShadowRoots(owner){for(var shadowRoots=owner.provisionalShadowRoots||[],retiredControllers=new SDKMap,shadowRootIndex=0;shadowRootIndex<shadowRoots.length;shadowRootIndex+=1){var shadowRoot=shadowRoots[shadowRootIndex],entry=controllerByShadowRoot.get(shadowRoot);entry&&entry.provisionalOwner===owner&&(entry.provisionalOwner=void 0,entry.active=!1,entry.registered=!1,controllerByShadowRoot.delete(shadowRoot),retiredControllers.set(shadowRoot,entry))}owner.provisionalShadowRoots=void 0,retireControllerEntries(retiredControllers)},isNodeInSkippedShadowRoot:function isNodeInSkippedShadowRoot(node){if(stopped)return!0;for(var current=node,depth=0;current;){if(depth>=SHADOW_ROOT_SKIPPED_ANCESTOR_MAX_DEPTH)return!0;try{current=getParentNode(current)}catch(_){return!0}if(!current)return!1;if(isNodeShadowRoot(current)){var entry=latestEntryByShadowRoot.get(current);if(entry&&!isEntryActive(entry))return!0}depth+=1}return!1},stop:function stop(){if(!stopped){try{stopAttachShadowObserver()}catch(error){reportCleanupError(error)}stopped=!0,recoveryShadowRoots=void 0,retireActiveGeneration()}},flush:function flush(){if(stopped||0===controllerByShadowRoot.size)return!0;var generation=activeGeneration,shadowRootCount=controllerByShadowRoot.size,flushState=currentFlush&¤tFlush.generation===generation?currentFlush:{events:[],eventApproxBytes:0,eventCount:0,eventBudgetReservation:void 0,generation:generation,overflow:void 0};currentFlush=flushState;var deadline=getCurrentTimeImpl()+SHADOW_ROOT_FLUSH_BUDGET_MS;pendingFlushIterator&&pendingFlushGeneration===generation||(pendingFlushIterator=controllerByShadowRoot.values(),pendingFlushGeneration=generation);for(var failure,iterator=pendingFlushIterator,flushedShadowRootCount=0,iteratorCompleted=!1;flushedShadowRootCount<SHADOW_ROOT_FLUSH_MAX_COUNT&&!(flushedShadowRootCount>0&&getCurrentTimeImpl()>=deadline);){var entry=pendingFlushEntry;if(!entry){var nextEntry=iterator.next();if(nextEntry.done){iteratorCompleted=!0;break}entry=nextEntry.value}if(isEntryActive(entry))try{var flushSucceeded=entry.flush();if(flushedShadowRootCount+=1,!1===flushSucceeded||flushState.overflow){failure={reason:"shadow_root_flush_overflow",cause:flushState.overflow&&flushState.overflow.reason,shadowRootCount:shadowRootCount,flushedShadowRootCount:flushedShadowRootCount,$rSuppressMutationOverflow:flushState.overflow?flushState.overflow.$rSuppressMutationOverflow:!1===flushSucceeded&&mutationResourceBudget&&mutationResourceBudget.isFailed()};break}if("pending"===flushSucceeded){pendingFlushEntry=entry;break}pendingFlushEntry=void 0}catch(error){failure={reason:"shadow_root_flush_error",error:String(error),shadowRootCount:shadowRootCount,flushedShadowRootCount:flushedShadowRootCount};break}else pendingFlushEntry=void 0}if(failure)return clearPendingShadowRootFlush(),function failFlush(generation,overflow){releaseShadowRootFlushBudget(currentFlush),currentFlush=void 0,generation===activeGeneration&&retireActiveGeneration();stopped||!mutationOverflowCb||overflow.$rSuppressMutationOverflow||mutationOverflowCb(overflow);return!1}(generation,failure);if(!iteratorCompleted)return"pending";currentFlush=void 0;var eventsToDispatch=function coalesceMutationEvents(events){var mergedMutationEvent,result=[];return events.forEach((function(event){if("mutation"!==event.type)return mergedMutationEvent=void 0,void result.push(event);mergedMutationEvent||(mergedMutationEvent={callback:event.callback,entries:[],entry:event.entry,type:event.type,value:{adds:[],removes:[],texts:[],attributes:[]}},result.push(mergedMutationEvent)),mergedMutationEvent.entries.push(event.entry),Array.prototype.push.apply(mergedMutationEvent.value.adds,event.value.adds),Array.prototype.push.apply(mergedMutationEvent.value.removes,event.value.removes),Array.prototype.push.apply(mergedMutationEvent.value.texts,event.value.texts),Array.prototype.push.apply(mergedMutationEvent.value.attributes,event.value.attributes)})),result}(flushState.events.filter((function(event){return isEntryActive(event.entry)})));try{for(var eventIndex=0;eventIndex<eventsToDispatch.length;eventIndex+=1){var event=eventsToDispatch[eventIndex];(event.entries||[event.entry]).some((function(entry){return isEntryActive(entry)}))&&event.callback(event.value)}}finally{releaseShadowRootFlushBudget(flushState)}return iteratorCompleted&&clearPendingShadowRootFlush(),isGenerationActive(generation)},$rResetPendingMutationsForBaseline:function $rResetPendingMutationsForBaseline(){if(stopped||0===controllerByShadowRoot.size)return clearPendingShadowRootBaselineReset(),!0;var generation=activeGeneration;baselineResetIterator&&baselineResetGeneration===generation||(baselineResetIterator=controllerByShadowRoot.values(),baselineResetGeneration=generation);for(var deadline=getCurrentTimeImpl()+SHADOW_ROOT_FLUSH_BUDGET_MS,resetCount=0;resetCount<SHADOW_ROOT_FLUSH_MAX_COUNT;){if(resetCount>0&&getCurrentTimeImpl()>=deadline)return"pending";var nextEntry=baselineResetIterator.next();if(nextEntry.done)return clearPendingShadowRootBaselineReset(),!0;var entry=nextEntry.value;if(isEntryActive(entry)){try{entry.resetMutationObserver()}catch(error){return clearPendingShadowRootBaselineReset(),mutationOverflowCb&&mutationOverflowCb({reason:"shadow_root_baseline_reset_error",error:String(error)}),!1}resetCount+=1}}return"pending"},reset:function reset(){stopped||retireActiveGeneration()},$rBeginRecovery:function $rBeginRecovery(){stopped||recoveryShadowRoots||(recoveryShadowRoots=[],controllerByShadowRoot.forEach((function(entry,shadowRoot){entry.active&&entry.registered&&!entry.provisionalOwner&&recoveryShadowRoots.push(shadowRoot)})))},$rCommitRecovery:function $rCommitRecovery(){recoveryShadowRoots=void 0},$rRollbackRecovery:function $rRollbackRecovery(){if(!stopped&&recoveryShadowRoots){var shadowRoots=recoveryShadowRoots;recoveryShadowRoots=void 0,retireActiveGeneration(),shadowRoots.forEach((function(shadowRoot){try{shadowRootBelongsToObservedDocument(shadowRoot)&&shadowRootsController.addShadowRoot(shadowRoot)}catch(error){reportCleanupError(error)}}))}}};return shadowRootsController;function createGeneration(){return{active:!0,id:++nextGenerationId}}function isGenerationActive(generation){return!stopped&&generation.active&&generation===activeGeneration}function shadowRootBelongsToObservedDocument(shadowRoot){try{return Boolean(shadowRoot.host&&shadowRoot.host.isConnected&&shadowRoot.host.ownerDocument===document)}catch(_){return!1}}function isEntryActive(entry){return entry.active&&entry.registered&&controllerByShadowRoot.get(entry.shadowRoot)===entry&&isGenerationActive(entry.generation)}function createGatedCallback(entry,type,callback){if(callback)return function(value){if("mutation"===type&&function isEntryShadowRootIgnored(entry){if(!isNodeIgnored)return!1;try{return isNodeIgnored(entry.shadowRoot)}catch(_){return!0}}(entry)){if(!entry.unpublishedMutationOverflowReported){entry.unpublishedMutationOverflowReported=!0;var unpublishedMutationOverflow={reason:"shadow_root_mutation_before_publication"};currentFlush&¤tFlush.generation===entry.generation?currentFlush.overflow=unpublishedMutationOverflow:mutationOverflowCb&&mutationOverflowCb(unpublishedMutationOverflow)}}else{var pendingOverflowAfterReset="overflow"===type&&entry.pendingOverflowAfterReset&&!stopped;if(isEntryActive(entry)||pendingOverflowAfterReset)if(pendingOverflowAfterReset&&(entry.pendingOverflowAfterReset=!1),currentFlush&¤tFlush.generation===entry.generation)if("overflow"===type)currentFlush.overflow=value||{reason:"shadow_root_observer_overflow"};else{if(!function reserveShadowRootFlushEvent(flushState,type,value){var eventApproxBytes=estimateShadowRootFlushEventApproxBytes(type,value),nextEventCount=flushState.eventCount+1,nextEventApproxBytes=flushState.eventApproxBytes+eventApproxBytes;if(mutationResourceBudget)if(flushState.eventBudgetReservation){if(!flushState.eventBudgetReservation.update({eventCount:nextEventCount,approxBytes:nextEventApproxBytes}))return!1}else if(flushState.eventBudgetReservation=mutationResourceBudget.reserve(MUTATION_RESOURCE_FLUSH,{eventCount:nextEventCount,approxBytes:nextEventApproxBytes}),!flushState.eventBudgetReservation)return!1;return flushState.eventCount=nextEventCount,flushState.eventApproxBytes=nextEventApproxBytes,!0}(currentFlush,type,value)){var shouldReportOverflow=!mutationResourceBudget||mutationResourceBudget.failOnce();return void(currentFlush.overflow={reason:"aggregate_shadow_flush_watermark",mutationApproxBytes:currentFlush.eventApproxBytes+estimateShadowRootFlushEventApproxBytes(type,value),$rSuppressMutationOverflow:!shouldReportOverflow})}currentFlush.events.push({callback:callback,entry:entry,type:type,value:value})}else callback(value)}}}function releaseShadowRootFlushBudget(flushState){flushState&&flushState.eventBudgetReservation&&(flushState.eventBudgetReservation(),flushState.eventBudgetReservation=void 0)}function estimateShadowRootFlushEventApproxBytes(type,value){if("mutation"===type)return getMutationPayloadApproxBytes(value);var approxBytes=64;return value&&"object"===_typeof(value)?(Object.keys(value).slice(0,64).forEach((function(name){var propertyValue=value[name];approxBytes+=2*name.length+16,"string"==typeof propertyValue&&(approxBytes+=2*propertyValue.length)})),approxBytes):approxBytes+("string"==typeof value?2*value.length:0)}function retireActiveGeneration(){releaseShadowRootFlushBudget(currentFlush),currentFlush=void 0,clearPendingShadowRootFlush(),clearPendingShadowRootBaselineReset(),clearDisconnectedShadowRootCleanup();var retiredControllers=controllerByShadowRoot;activeGeneration.active=!1,mutationDependencyState.$rPublishedRoots=new WeakSet,mutationDependencyState.$rLocallyDroppedRoots=new WeakSet,activeGeneration=createGeneration(),controllerByShadowRoot=new SDKMap,retireControllerEntries(retiredControllers)}function clearPendingShadowRootFlush(){pendingFlushIterator=void 0,pendingFlushGeneration=void 0,pendingFlushEntry=void 0}function clearPendingShadowRootBaselineReset(){baselineResetIterator=void 0,baselineResetGeneration=void 0}function runDisconnectedShadowRootCleanupSlice(){disconnectedCleanupIterator&&disconnectedCleanupGeneration===activeGeneration||(disconnectedCleanupIterator=controllerByShadowRoot.entries(),disconnectedCleanupGeneration=activeGeneration);for(var deadline=getCurrentTimeImpl()+SHADOW_ROOT_CLEANUP_BUDGET_MS,scanned=0;scanned<SHADOW_ROOT_CLEANUP_BATCH_SIZE;){var nextEntry=disconnectedCleanupIterator.next();if(nextEntry.done)return void clearDisconnectedShadowRootCleanup();scanned+=1;var shadowRoot=nextEntry.value[0];if(!shadowRootBelongsToObservedDocument(shadowRoot))try{shadowRootsController.removeShadowRoot(shadowRoot)}catch(_){}if(getCurrentTimeImpl()>=deadline)break}!function scheduleDisconnectedShadowRootCleanup(){if(disconnectedCleanupScheduled||!disconnectedCleanupIterator||stopped)return;disconnectedCleanupScheduled=!0,setTimeout((function(){disconnectedCleanupScheduled=!1,!stopped&&disconnectedCleanupIterator&&runDisconnectedShadowRootCleanupSlice()}),0)}()}function clearDisconnectedShadowRootCleanup(){disconnectedCleanupIterator=void 0,disconnectedCleanupGeneration=void 0}function retireControllerEntries(retiredControllers){if(retiredControllers.size>0){var cleanupItem={controllers:retiredControllers,iterator:retiredControllers.entries(),next:void 0};retiredControllerCount+=retiredControllers.size,cleanupQueueTail?cleanupQueueTail.next=cleanupItem:cleanupQueueHead=cleanupItem,cleanupQueueTail=cleanupItem,scheduleCleanup()}}function scheduleCleanup(){if(!cleanupScheduled&&cleanupQueueHead){cleanupScheduled=!0;try{scheduleCleanupImpl(runCleanupSlice)}catch(error){if(cleanupScheduled=!1,reportCleanupError(error),scheduleCleanupImpl!==defaultScheduleCleanup){cleanupScheduled=!0;try{defaultScheduleCleanup(runCleanupSlice)}catch(fallbackError){cleanupScheduled=!1,reportCleanupError(fallbackError)}}}}}function runCleanupSlice(){cleanupScheduled=!1;for(var deadline=getCurrentTimeImpl()+SHADOW_ROOT_CLEANUP_BUDGET_MS,cleanedControllerCount=0;cleanupQueueHead;){var cleanupItem=cleanupQueueHead,nextEntry=cleanupItem.iterator.next();if(nextEntry.done)cleanupQueueHead=cleanupItem.next,cleanupItem.next=void 0,cleanupQueueHead||(cleanupQueueTail=void 0);else{var shadowRoot=nextEntry.value[0],entry=nextEntry.value[1];if(cleanupItem.controllers.delete(shadowRoot),retiredControllerCount=Math.max(retiredControllerCount-1,0),entry.active=!1,entry.registered=!1,entry.pendingOverflowAfterReset=!1,stopControllerEntry(entry,!1),(cleanedControllerCount+=1)>=SHADOW_ROOT_CLEANUP_BATCH_SIZE||getCurrentTimeImpl()>=deadline)break}}cleanupQueueHead&&scheduleCleanup()}function stopControllerEntry(entry,shouldThrow){var firstError=function deactivateControllerEntry(entry){if(!entry.mutationObserverDeactivated){entry.mutationObserverDeactivated=!0;try{entry.deactivateMutationObserver()}catch(error){return error}}}(entry);try{entry.stopMutationObserver()}catch(error){firstError||(firstError=error)}try{entry.stopInputObserver()}catch(error){firstError||(firstError=error)}if(firstError&&reportCleanupError(firstError),firstError&&shouldThrow)throw firstError}function reportCleanupError(error){if(cleanupErrorCb)try{cleanupErrorCb(error)}catch(_){}}function defaultScheduleCleanup(callback){setTimeout(callback,0)}};function getCurrentTime(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()}function removeAttachShadowSubscriber(subscriber){var subscriberIndex=attachShadowSubscribers.indexOf(subscriber);-1!==subscriberIndex&&attachShadowSubscribers.splice(subscriberIndex,1)}
|
|
2
|
+
//# sourceMappingURL=shadowRootsController.js.map
|