@cloudcare/browser-rum 3.0.27 → 3.0.29
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/boot/rumPublicApi.js +37 -38
- package/cjs/domain/assembly.js +4 -6
- package/cjs/domain/domMutationCollection.js +2 -2
- package/cjs/domain/performanceCollection.js +2 -3
- package/cjs/domain/replay/record/mutationBatch.js +22 -17
- package/cjs/domain/replay/record/mutationObserver.js +1 -1
- package/cjs/domain/replay/record/observers.js +1 -1
- package/cjs/domain/replay/record/privacy.js +15 -0
- package/cjs/domain/replay/record/serializationUtils.js +73 -0
- package/cjs/domain/replay/record/serialize.js +5 -72
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rumPublicApi.js +38 -39
- package/esm/domain/assembly.js +4 -6
- package/esm/domain/domMutationCollection.js +3 -3
- package/esm/domain/performanceCollection.js +3 -4
- package/esm/domain/replay/record/mutationBatch.js +22 -17
- package/esm/domain/replay/record/mutationObserver.js +2 -2
- package/esm/domain/replay/record/observers.js +2 -2
- package/esm/domain/replay/record/privacy.js +14 -0
- package/esm/domain/replay/record/serializationUtils.js +61 -0
- package/esm/domain/replay/record/serialize.js +2 -69
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
- package/package.json +4 -4
- package/src/boot/rumPublicApi.js +41 -38
- package/src/domain/assembly.js +4 -6
- package/src/domain/domMutationCollection.js +20 -17
- package/src/domain/performanceCollection.js +4 -3
- package/src/domain/replay/record/mutationBatch.js +21 -3
- package/src/domain/replay/record/mutationObserver.js +3 -2
- package/src/domain/replay/record/observers.js +5 -2
- package/src/domain/replay/record/privacy.js +22 -0
- package/src/domain/replay/record/serializationUtils.js +63 -1
- package/src/domain/replay/record/serialize.js +5 -68
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +4 -1
package/cjs/boot/buildEnv.js
CHANGED
package/cjs/boot/rumPublicApi.js
CHANGED
|
@@ -128,51 +128,50 @@ function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
128
128
|
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
var startView = function
|
|
131
|
+
var startView = (0, _browserCore.monitor)(function (options) {
|
|
132
132
|
var sanitizedOptions = _typeof(options) === 'object' ? options : {
|
|
133
133
|
name: options
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
_startViewStrategy(sanitizedOptions);
|
|
137
|
-
};
|
|
138
|
-
|
|
137
|
+
});
|
|
139
138
|
var rumPublicApi = (0, _browserCore.makePublicApi)({
|
|
140
|
-
init: initRum,
|
|
139
|
+
init: (0, _browserCore.monitor)(initRum),
|
|
141
140
|
|
|
142
141
|
/** @deprecated: use setGlobalContextProperty instead */
|
|
143
|
-
addRumGlobalContext: globalContextManager.add,
|
|
144
|
-
setGlobalContextProperty: globalContextManager.setContextProperty,
|
|
142
|
+
addRumGlobalContext: (0, _browserCore.monitor)(globalContextManager.add),
|
|
143
|
+
setGlobalContextProperty: (0, _browserCore.monitor)(globalContextManager.setContextProperty),
|
|
145
144
|
|
|
146
145
|
/** @deprecated: use removeGlobalContextProperty instead */
|
|
147
|
-
removeRumGlobalContext: globalContextManager.remove,
|
|
148
|
-
removeGlobalContextProperty: globalContextManager.removeContextProperty,
|
|
146
|
+
removeRumGlobalContext: (0, _browserCore.monitor)(globalContextManager.remove),
|
|
147
|
+
removeGlobalContextProperty: (0, _browserCore.monitor)(globalContextManager.removeContextProperty),
|
|
149
148
|
|
|
150
149
|
/** @deprecated: use getGlobalContext instead */
|
|
151
|
-
getRumGlobalContext: globalContextManager.get,
|
|
152
|
-
getGlobalContext: globalContextManager.getContext,
|
|
150
|
+
getRumGlobalContext: (0, _browserCore.monitor)(globalContextManager.get),
|
|
151
|
+
getGlobalContext: (0, _browserCore.monitor)(globalContextManager.getContext),
|
|
153
152
|
|
|
154
153
|
/** @deprecated: use setGlobalContext instead */
|
|
155
|
-
setRumGlobalContext: globalContextManager.set,
|
|
156
|
-
setGlobalContext: globalContextManager.setContext,
|
|
157
|
-
clearGlobalContext: globalContextManager.clearContext,
|
|
158
|
-
getInitConfiguration: function
|
|
154
|
+
setRumGlobalContext: (0, _browserCore.monitor)(globalContextManager.set),
|
|
155
|
+
setGlobalContext: (0, _browserCore.monitor)(globalContextManager.setContext),
|
|
156
|
+
clearGlobalContext: (0, _browserCore.monitor)(globalContextManager.clearContext),
|
|
157
|
+
getInitConfiguration: (0, _browserCore.monitor)(function () {
|
|
159
158
|
return getInitConfigurationStrategy();
|
|
160
|
-
},
|
|
161
|
-
getInternalContext: function
|
|
159
|
+
}),
|
|
160
|
+
getInternalContext: (0, _browserCore.monitor)(function (startTime) {
|
|
162
161
|
return getInternalContextStrategy(startTime);
|
|
163
|
-
},
|
|
164
|
-
addDebugSession: function
|
|
165
|
-
clearDebugSession: function
|
|
166
|
-
getDebugSession: function
|
|
167
|
-
addAction: function
|
|
162
|
+
}),
|
|
163
|
+
addDebugSession: (0, _browserCore.monitor)(function (id) {}),
|
|
164
|
+
clearDebugSession: (0, _browserCore.monitor)(function () {}),
|
|
165
|
+
getDebugSession: (0, _browserCore.monitor)(function () {}),
|
|
166
|
+
addAction: (0, _browserCore.monitor)(function (name, context) {
|
|
168
167
|
_addActionStrategy({
|
|
169
168
|
name: name,
|
|
170
169
|
context: (0, _browserCore.deepClone)(context),
|
|
171
170
|
startClocks: (0, _browserCore.clocksNow)(),
|
|
172
171
|
type: _browserCore.ActionType.CUSTOM
|
|
173
172
|
});
|
|
174
|
-
},
|
|
175
|
-
addError: function
|
|
173
|
+
}),
|
|
174
|
+
addError: (0, _browserCore.monitor)(function (error, context) {
|
|
176
175
|
var handlingStack = (0, _browserCore.createHandlingStack)();
|
|
177
176
|
|
|
178
177
|
_addErrorStrategy({
|
|
@@ -181,33 +180,33 @@ function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
181
180
|
context: (0, _browserCore.deepClone)(context),
|
|
182
181
|
startClocks: (0, _browserCore.clocksNow)()
|
|
183
182
|
});
|
|
184
|
-
},
|
|
185
|
-
addTiming: function
|
|
183
|
+
}),
|
|
184
|
+
addTiming: (0, _browserCore.monitor)(function (name, time) {
|
|
186
185
|
_addTimingStrategy(name, time);
|
|
187
|
-
},
|
|
188
|
-
setUser: function
|
|
186
|
+
}),
|
|
187
|
+
setUser: (0, _browserCore.monitor)(function (newUser) {
|
|
189
188
|
if ((0, _browserCore.checkUser)(newUser)) {
|
|
190
189
|
userContextManager.setContext((0, _browserCore.sanitizeUser)(newUser));
|
|
191
190
|
}
|
|
192
|
-
},
|
|
193
|
-
getUser: userContextManager.getContext,
|
|
194
|
-
setUserProperty: function
|
|
191
|
+
}),
|
|
192
|
+
getUser: (0, _browserCore.monitor)(userContextManager.getContext),
|
|
193
|
+
setUserProperty: (0, _browserCore.monitor)(function (key, property) {
|
|
195
194
|
var newUser = {};
|
|
196
195
|
newUser[key] = property;
|
|
197
196
|
var sanitizedProperty = (0, _browserCore.sanitizeUser)(newUser)[key];
|
|
198
197
|
userContextManager.setContextProperty(key, sanitizedProperty);
|
|
199
|
-
},
|
|
200
|
-
removeUserProperty: userContextManager.removeContextProperty,
|
|
198
|
+
}),
|
|
199
|
+
removeUserProperty: (0, _browserCore.monitor)(userContextManager.removeContextProperty),
|
|
201
200
|
|
|
202
201
|
/** @deprecated: renamed to clearUser */
|
|
203
|
-
removeUser: userContextManager.clearContext,
|
|
204
|
-
clearUser: userContextManager.clearContext,
|
|
202
|
+
removeUser: (0, _browserCore.monitor)(userContextManager.clearContext),
|
|
203
|
+
clearUser: (0, _browserCore.monitor)(userContextManager.clearContext),
|
|
205
204
|
startView: startView,
|
|
206
|
-
stopSession: function
|
|
205
|
+
stopSession: (0, _browserCore.monitor)(function () {
|
|
207
206
|
stopSessionStrategy();
|
|
208
|
-
},
|
|
209
|
-
startSessionReplayRecording: recorderApi.start,
|
|
210
|
-
stopSessionReplayRecording: recorderApi.stop
|
|
207
|
+
}),
|
|
208
|
+
startSessionReplayRecording: (0, _browserCore.monitor)(recorderApi.start),
|
|
209
|
+
stopSessionReplayRecording: (0, _browserCore.monitor)(recorderApi.stop)
|
|
211
210
|
});
|
|
212
211
|
return rumPublicApi;
|
|
213
212
|
|
package/cjs/domain/assembly.js
CHANGED
|
@@ -16,9 +16,7 @@ var VIEW_MODIFIABLE_FIELD_PATHS = {
|
|
|
16
16
|
'view.referrer': 'string'
|
|
17
17
|
};
|
|
18
18
|
var USER_CUSTOMIZABLE_FIELD_PATHS = {
|
|
19
|
-
|
|
20
|
-
'_gc.trace_id': 'string',
|
|
21
|
-
'_gc.span_id': 'string'
|
|
19
|
+
context: 'object'
|
|
22
20
|
};
|
|
23
21
|
var modifiableFieldPathsByEvent = {};
|
|
24
22
|
|
|
@@ -99,7 +97,7 @@ function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionM
|
|
|
99
97
|
var context = (0, _browserCore.extend2Lev)({}, commonContext.context, customerContext);
|
|
100
98
|
|
|
101
99
|
if (!(0, _browserCore.isEmptyObject)(context)) {
|
|
102
|
-
serverRumEvent.
|
|
100
|
+
serverRumEvent.context = context;
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
if (!('has_replay' in serverRumEvent.session)) {
|
|
@@ -115,8 +113,8 @@ function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionM
|
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
|
|
118
|
-
if ((0, _browserCore.isEmptyObject)(serverRumEvent.
|
|
119
|
-
delete serverRumEvent.
|
|
116
|
+
if ((0, _browserCore.isEmptyObject)(serverRumEvent.context)) {
|
|
117
|
+
delete serverRumEvent.context;
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
|
|
@@ -10,7 +10,7 @@ var _browserCore = require("@cloudcare/browser-core");
|
|
|
10
10
|
|
|
11
11
|
function createDOMMutationObservable() {
|
|
12
12
|
var MutationObserver = getMutationObserverConstructor();
|
|
13
|
-
var observable = new _browserCore.Observable(function () {
|
|
13
|
+
var observable = new _browserCore.Observable((0, _browserCore.monitor)(function () {
|
|
14
14
|
if (!MutationObserver) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -27,7 +27,7 @@ function createDOMMutationObservable() {
|
|
|
27
27
|
return function () {
|
|
28
28
|
return observer.disconnect();
|
|
29
29
|
};
|
|
30
|
-
});
|
|
30
|
+
}));
|
|
31
31
|
return observable;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -35,10 +35,9 @@ function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if (window.PerformanceObserver) {
|
|
38
|
-
var handlePerformanceEntryList = function
|
|
38
|
+
var handlePerformanceEntryList = (0, _browserCore.monitor)(function (entries) {
|
|
39
39
|
handleRumPerformanceEntries(lifeCycle, configuration, entries.getEntries());
|
|
40
|
-
};
|
|
41
|
-
|
|
40
|
+
});
|
|
42
41
|
var mainEntries = ['resource', 'navigation', 'longtask', 'paint'];
|
|
43
42
|
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift'];
|
|
44
43
|
|
|
@@ -7,18 +7,6 @@ exports.createMutationBatch = createMutationBatch;
|
|
|
7
7
|
|
|
8
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
9
|
|
|
10
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
-
|
|
12
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
17
|
-
|
|
18
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
|
-
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
-
|
|
22
10
|
/**
|
|
23
11
|
* Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
|
|
24
12
|
* processed more quickly. If the browser is busy executing small tasks (ex: rendering frames), the
|
|
@@ -39,20 +27,37 @@ function createMutationBatch(processMutationBatch) {
|
|
|
39
27
|
|
|
40
28
|
return {
|
|
41
29
|
addMutations: function addMutations(mutations) {
|
|
42
|
-
var _pendingMutations;
|
|
43
|
-
|
|
44
30
|
if (pendingMutations.length === 0) {
|
|
45
|
-
cancelScheduledFlush =
|
|
31
|
+
cancelScheduledFlush = requestIdleCallback(flush, {
|
|
46
32
|
timeout: MUTATION_PROCESS_MAX_DELAY
|
|
47
33
|
});
|
|
48
|
-
}
|
|
34
|
+
} // pendingMutations.push(...mutations)
|
|
49
35
|
|
|
50
|
-
(_pendingMutations = pendingMutations).push.apply(_pendingMutations, _toConsumableArray(mutations)); // Array.prototype.push.apply(pendingMutations, mutations)
|
|
51
36
|
|
|
37
|
+
Array.prototype.push.apply(pendingMutations, mutations);
|
|
52
38
|
},
|
|
53
39
|
flush: flush,
|
|
54
40
|
stop: function stop() {
|
|
55
41
|
cancelScheduledFlush();
|
|
56
42
|
}
|
|
57
43
|
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function requestIdleCallback(callback, opts) {
|
|
47
|
+
// Use 'requestIdleCallback' when available: it will throttle the mutation processing if the
|
|
48
|
+
// browser is busy rendering frames (ex: when frames are below 60fps). When not available, the
|
|
49
|
+
// fallback on 'requestAnimationFrame' will still ensure the mutations are processed after any
|
|
50
|
+
// browser rendering process (Layout, Recalculate Style, etc.), so we can serialize DOM nodes
|
|
51
|
+
// efficiently.
|
|
52
|
+
if (window.requestIdleCallback) {
|
|
53
|
+
var id = window.requestIdleCallback((0, _browserCore.monitor)(callback), opts);
|
|
54
|
+
return function () {
|
|
55
|
+
return window.cancelIdleCallback(id);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var id = window.requestAnimationFrame((0, _browserCore.monitor)(callback));
|
|
60
|
+
return function () {
|
|
61
|
+
return window.cancelAnimationFrame(id);
|
|
62
|
+
};
|
|
58
63
|
}
|
|
@@ -42,7 +42,7 @@ function startMutationObserver(mutationCallback, configuration, shadowRootsContr
|
|
|
42
42
|
var mutationBatch = (0, _mutationBatch.createMutationBatch)(function (mutations) {
|
|
43
43
|
processMutations(mutations.concat(observer.takeRecords()), mutationCallback, configuration, shadowRootsController, target);
|
|
44
44
|
});
|
|
45
|
-
var observer = new MutationObserver(mutationBatch.addMutations);
|
|
45
|
+
var observer = new MutationObserver((0, _browserCore.monitor)(mutationBatch.addMutations));
|
|
46
46
|
observer.observe(target, {
|
|
47
47
|
attributeOldValue: true,
|
|
48
48
|
attributes: true,
|
|
@@ -294,7 +294,7 @@ function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
|
294
294
|
var name = target.name;
|
|
295
295
|
|
|
296
296
|
if (type === 'radio' && name && target.checked) {
|
|
297
|
-
(0, _utils.forEach)(document.querySelectorAll(
|
|
297
|
+
(0, _utils.forEach)(document.querySelectorAll('input[type="radio"][name="' + (0, _browserCore.cssEscape)(name) + '"]'), function (el) {
|
|
298
298
|
if (el !== target) {
|
|
299
299
|
// TODO: Consider the privacy implications for various differing input privacy levels
|
|
300
300
|
cbWithDedup(el, {
|
|
@@ -13,6 +13,8 @@ exports.shouldMaskNode = shouldMaskNode;
|
|
|
13
13
|
|
|
14
14
|
var _browserCore = require("@cloudcare/browser-core");
|
|
15
15
|
|
|
16
|
+
var _serializationUtils = require("./serializationUtils");
|
|
17
|
+
|
|
16
18
|
var _constants = require("../../../constants");
|
|
17
19
|
|
|
18
20
|
var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 100000;
|
|
@@ -205,6 +207,19 @@ function getTextContent(textNode, ignoreWhiteSpace, parentNodePrivacyLevel) {
|
|
|
205
207
|
} else {
|
|
206
208
|
textContent = censorText(textContent);
|
|
207
209
|
}
|
|
210
|
+
} else if (isStyle && textContent) {
|
|
211
|
+
try {
|
|
212
|
+
// try to read style sheet
|
|
213
|
+
if (textNode.nextSibling || textNode.previousSibling) {// This is not the only child of the stylesheet.
|
|
214
|
+
// We can't read all of the sheet's .cssRules and expect them
|
|
215
|
+
// to _only_ include the current rule(s) added by the text node.
|
|
216
|
+
// So we'll be conservative and keep textContent as-is.
|
|
217
|
+
} else if (textNode.parentNode && textNode.parentNode.sheet && textNode.parentNode.sheet.cssRules) {
|
|
218
|
+
textContent = (0, _serializationUtils.getCssRulesString)(textNode.parentNode.sheet);
|
|
219
|
+
}
|
|
220
|
+
} catch (err) {}
|
|
221
|
+
|
|
222
|
+
textContent = (0, _serializationUtils.switchToAbsoluteUrl)(textContent, (0, _serializationUtils.getHref)());
|
|
208
223
|
}
|
|
209
224
|
|
|
210
225
|
return textContent;
|
|
@@ -5,10 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.URL_IN_CSS_REF = exports.DATA_URI = exports.ABSOLUTE_URL = void 0;
|
|
7
7
|
exports.absoluteToDoc = absoluteToDoc;
|
|
8
|
+
exports.fixBrowserCompatibilityIssuesInCSS = fixBrowserCompatibilityIssuesInCSS;
|
|
8
9
|
exports.getAbsoluteSrcsetString = getAbsoluteSrcsetString;
|
|
10
|
+
exports.getCssRuleString = getCssRuleString;
|
|
11
|
+
exports.getCssRulesString = getCssRulesString;
|
|
9
12
|
exports.getElementInputValue = getElementInputValue;
|
|
13
|
+
exports.getHref = getHref;
|
|
10
14
|
exports.getSerializedNodeId = getSerializedNodeId;
|
|
11
15
|
exports.hasSerializedNode = hasSerializedNode;
|
|
16
|
+
exports.isCSSImportRule = isCSSImportRule;
|
|
17
|
+
exports.isSVGElement = isSVGElement;
|
|
12
18
|
exports.makeUrlAbsolute = makeUrlAbsolute;
|
|
13
19
|
exports.nodeAndAncestorsHaveSerializedNode = nodeAndAncestorsHaveSerializedNode;
|
|
14
20
|
exports.serializeStyleSheets = serializeStyleSheets;
|
|
@@ -110,8 +116,34 @@ exports.URL_IN_CSS_REF = URL_IN_CSS_REF;
|
|
|
110
116
|
var ABSOLUTE_URL = /^[A-Za-z]+:|^\/\//;
|
|
111
117
|
exports.ABSOLUTE_URL = ABSOLUTE_URL;
|
|
112
118
|
var DATA_URI = /^data:.*,/i;
|
|
119
|
+
/**
|
|
120
|
+
* Browsers sometimes destructively modify the css rules they receive.
|
|
121
|
+
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
122
|
+
* @param cssText - output of `CSSStyleRule.cssText`
|
|
123
|
+
* @returns `cssText` with browser inconsistencies fixed.
|
|
124
|
+
*/
|
|
125
|
+
|
|
113
126
|
exports.DATA_URI = DATA_URI;
|
|
114
127
|
|
|
128
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
129
|
+
/**
|
|
130
|
+
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
131
|
+
* But then Chrome ignores `background-clip` as css input.
|
|
132
|
+
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
133
|
+
*/
|
|
134
|
+
if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
|
|
135
|
+
cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return cssText;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getHref() {
|
|
142
|
+
var a = document.createElement('a');
|
|
143
|
+
a.href = '';
|
|
144
|
+
return a.href;
|
|
145
|
+
}
|
|
146
|
+
|
|
115
147
|
function switchToAbsoluteUrl(cssText, cssHref) {
|
|
116
148
|
return cssText.replace(URL_IN_CSS_REF, function (matchingSubstring, singleQuote, urlWrappedInSingleQuotes, doubleQuote, urlWrappedInDoubleQuotes, urlNotWrappedInQuotes) {
|
|
117
149
|
var url = urlWrappedInSingleQuotes || urlWrappedInDoubleQuotes || urlNotWrappedInQuotes;
|
|
@@ -130,6 +162,47 @@ function switchToAbsoluteUrl(cssText, cssHref) {
|
|
|
130
162
|
});
|
|
131
163
|
}
|
|
132
164
|
|
|
165
|
+
function getCssRulesString(cssStyleSheet) {
|
|
166
|
+
if (!cssStyleSheet) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
var rules;
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
rules = cssStyleSheet.rules || cssStyleSheet.cssRules;
|
|
174
|
+
} catch (_unused) {// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!rules) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
|
|
182
|
+
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function isCSSImportRule(rule) {
|
|
186
|
+
return 'styleSheet' in rule;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isSVGElement(el) {
|
|
190
|
+
return el.tagName === 'svg' || el instanceof SVGElement;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function getCssRuleString(rule) {
|
|
194
|
+
var cssStringified = rule.cssText;
|
|
195
|
+
|
|
196
|
+
if (isCSSImportRule(rule)) {
|
|
197
|
+
try {
|
|
198
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
199
|
+
} catch (_unused2) {// ignore
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return validateStringifiedCssRule(cssStringified);
|
|
204
|
+
}
|
|
205
|
+
|
|
133
206
|
function makeUrlAbsolute(url, baseUrl) {
|
|
134
207
|
try {
|
|
135
208
|
return (0, _browserCore.buildUrl)(url, baseUrl).href;
|
|
@@ -144,7 +144,7 @@ function serializeDocumentFragmentNode(element, options) {
|
|
|
144
144
|
|
|
145
145
|
function serializeElementNode(element, options) {
|
|
146
146
|
var tagName = getValidTagName(element.tagName);
|
|
147
|
-
var isSVG = isSVGElement(element) || undefined; // For performance reason, we don't use getNodePrivacyLevel directly: we leverage the
|
|
147
|
+
var isSVG = (0, _serializationUtils.isSVGElement)(element) || undefined; // For performance reason, we don't use getNodePrivacyLevel directly: we leverage the
|
|
148
148
|
// parentNodePrivacyLevel option to avoid iterating over all parents
|
|
149
149
|
|
|
150
150
|
var nodePrivacyLevel = (0, _privacy.reducePrivacyLevel)((0, _privacy.getNodeSelfPrivacyLevel)(element), options.parentNodePrivacyLevel);
|
|
@@ -310,7 +310,7 @@ function generateNextId() {
|
|
|
310
310
|
var TAG_NAME_REGEX = /[^a-z1-6-_]/;
|
|
311
311
|
|
|
312
312
|
function getValidTagName(tagName) {
|
|
313
|
-
var processedTagName = tagName.toLowerCase().trim();
|
|
313
|
+
var processedTagName = (tagName + '').toLowerCase().trim();
|
|
314
314
|
|
|
315
315
|
if (TAG_NAME_REGEX.test(processedTagName)) {
|
|
316
316
|
// if the tag name is odd and we cannot extract
|
|
@@ -321,67 +321,6 @@ function getValidTagName(tagName) {
|
|
|
321
321
|
|
|
322
322
|
return processedTagName;
|
|
323
323
|
}
|
|
324
|
-
/**
|
|
325
|
-
* Browsers sometimes destructively modify the css rules they receive.
|
|
326
|
-
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
327
|
-
* @param cssText - output of `CSSStyleRule.cssText`
|
|
328
|
-
* @returns `cssText` with browser inconsistencies fixed.
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
333
|
-
/**
|
|
334
|
-
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
335
|
-
* But then Chrome ignores `background-clip` as css input.
|
|
336
|
-
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
337
|
-
*/
|
|
338
|
-
if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
|
|
339
|
-
cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return cssText;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function getCssRulesString(cssStyleSheet) {
|
|
346
|
-
if (!cssStyleSheet) {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var rules;
|
|
351
|
-
|
|
352
|
-
try {
|
|
353
|
-
rules = cssStyleSheet.rules || cssStyleSheet.cssRules;
|
|
354
|
-
} catch (_unused) {// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (!rules) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
|
|
362
|
-
return (0, _serializationUtils.switchToAbsoluteUrl)(styleSheetCssText, cssStyleSheet.href);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function getCssRuleString(rule) {
|
|
366
|
-
var cssStringified = rule.cssText;
|
|
367
|
-
|
|
368
|
-
if (isCSSImportRule(rule)) {
|
|
369
|
-
try {
|
|
370
|
-
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
371
|
-
} catch (_unused2) {// ignore
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return (0, _serializationUtils.validateStringifiedCssRule)(cssStringified);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function isCSSImportRule(rule) {
|
|
379
|
-
return 'styleSheet' in rule;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function isSVGElement(el) {
|
|
383
|
-
return el.tagName === 'svg' || el instanceof SVGElement;
|
|
384
|
-
}
|
|
385
324
|
|
|
386
325
|
function transformAttribute(doc, tagName, name, value) {
|
|
387
326
|
if (!value) return value;
|
|
@@ -395,7 +334,7 @@ function transformAttribute(doc, tagName, name, value) {
|
|
|
395
334
|
} else if (name === 'srcset') {
|
|
396
335
|
return (0, _serializationUtils.getAbsoluteSrcsetString)(doc, value);
|
|
397
336
|
} else if (name === 'style') {
|
|
398
|
-
return (0, _serializationUtils.switchToAbsoluteUrl)(value, getHref());
|
|
337
|
+
return (0, _serializationUtils.switchToAbsoluteUrl)(value, (0, _serializationUtils.getHref)());
|
|
399
338
|
} else if (tagName === 'object' && name === 'data') {
|
|
400
339
|
return (0, _serializationUtils.absoluteToDoc)(doc, value);
|
|
401
340
|
} else {
|
|
@@ -403,12 +342,6 @@ function transformAttribute(doc, tagName, name, value) {
|
|
|
403
342
|
}
|
|
404
343
|
}
|
|
405
344
|
|
|
406
|
-
function getHref() {
|
|
407
|
-
var a = document.createElement('a');
|
|
408
|
-
a.href = '';
|
|
409
|
-
return a.href;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
345
|
function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
413
346
|
if (nodePrivacyLevel === _constants.NodePrivacyLevel.HIDDEN) {
|
|
414
347
|
return {};
|
|
@@ -454,7 +387,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
454
387
|
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
|
|
455
388
|
return s.href === element.href;
|
|
456
389
|
});
|
|
457
|
-
var cssText = getCssRulesString(stylesheet);
|
|
390
|
+
var cssText = (0, _serializationUtils.getCssRulesString)(stylesheet);
|
|
458
391
|
|
|
459
392
|
if (cssText && stylesheet) {
|
|
460
393
|
safeAttrs._cssText = cssText;
|
|
@@ -464,7 +397,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
464
397
|
|
|
465
398
|
if (tagName === 'style' && element.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
|
|
466
399
|
!(element.innerText || element.textContent || '').trim().length) {
|
|
467
|
-
var cssText = getCssRulesString(element.sheet);
|
|
400
|
+
var cssText = (0, _serializationUtils.getCssRulesString)(element.sheet);
|
|
468
401
|
|
|
469
402
|
if (cssText) {
|
|
470
403
|
safeAttrs._cssText = cssText;
|
|
@@ -79,13 +79,13 @@ function getClassSelector(element) {
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
return element.tagName + '.' + (0, _browserCore.cssEscape)(className);
|
|
82
|
+
return (0, _browserCore.cssEscape)(element.tagName) + '.' + (0, _browserCore.cssEscape)(className);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function getTagNameSelector(element) {
|
|
88
|
-
return element.tagName;
|
|
88
|
+
return (0, _browserCore.cssEscape)(element.tagName);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function getStableAttributeSelector(element, actionNameAttribute) {
|
|
@@ -108,7 +108,7 @@ function getStableAttributeSelector(element, actionNameAttribute) {
|
|
|
108
108
|
|
|
109
109
|
function getAttributeSelector(attributeName) {
|
|
110
110
|
if (element.hasAttribute(attributeName)) {
|
|
111
|
-
return element.tagName + '[' + attributeName + '="' + (0, _browserCore.cssEscape)(element.getAttribute(attributeName)) + '"]';
|
|
111
|
+
return (0, _browserCore.cssEscape)(element.tagName) + '[' + attributeName + '="' + (0, _browserCore.cssEscape)(element.getAttribute(attributeName)) + '"]';
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -125,7 +125,7 @@ function getPositionSelector(element) {
|
|
|
125
125
|
sibling = sibling.nextElementSibling;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
var tagName = element.tagName; // 伪元素需要做特殊处理,没有nth-of-type选择器
|
|
128
|
+
var tagName = (0, _browserCore.cssEscape)(element.tagName); // 伪元素需要做特殊处理,没有nth-of-type选择器
|
|
129
129
|
|
|
130
130
|
if (/^::/.test(tagName)) {
|
|
131
131
|
return tagName;
|
|
@@ -298,7 +298,8 @@ function computeSize(entry) {
|
|
|
298
298
|
if (entry.startTime < entry.responseStart) {
|
|
299
299
|
return {
|
|
300
300
|
size: entry.decodedBodySize,
|
|
301
|
-
encodeSize: entry.encodedBodySize
|
|
301
|
+
encodeSize: Number.MAX_SAFE_INTEGER < entry.encodedBodySize ? 0 : entry.encodedBodySize // max safe interger
|
|
302
|
+
|
|
302
303
|
};
|
|
303
304
|
}
|
|
304
305
|
|
package/esm/boot/buildEnv.js
CHANGED