@openreplay/tracker 16.2.2-beta.19 → 16.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/entry.js +51 -26
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +51 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/index.d.ts +2 -1
- package/dist/cjs/main/modules/cssrules.d.ts +14 -2
- package/dist/lib/entry.js +51 -26
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +51 -26
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/index.d.ts +2 -1
- package/dist/lib/main/modules/cssrules.d.ts +14 -2
- package/dist/types/main/index.d.ts +2 -1
- package/dist/types/main/modules/cssrules.d.ts +14 -2
- package/package.json +1 -1
package/dist/cjs/entry.js
CHANGED
|
@@ -3564,7 +3564,7 @@ function isNodeStillActive(node) {
|
|
|
3564
3564
|
return [false, e];
|
|
3565
3565
|
}
|
|
3566
3566
|
}
|
|
3567
|
-
const defaults = {
|
|
3567
|
+
const defaults$1 = {
|
|
3568
3568
|
interval: SECOND * 30,
|
|
3569
3569
|
batchSize: 2500,
|
|
3570
3570
|
enabled: true,
|
|
@@ -3592,7 +3592,7 @@ class Maintainer {
|
|
|
3592
3592
|
clearInterval(this.interval);
|
|
3593
3593
|
}
|
|
3594
3594
|
};
|
|
3595
|
-
this.options = { ...defaults, ...options };
|
|
3595
|
+
this.options = { ...defaults$1, ...options };
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
3598
|
|
|
@@ -4046,7 +4046,6 @@ function ConstructedStyleSheets (app) {
|
|
|
4046
4046
|
return replace.call(this, text).then((sheet) => {
|
|
4047
4047
|
const sheetID = styleSheetIDMap.get(this);
|
|
4048
4048
|
if (sheetID) {
|
|
4049
|
-
console.log('replace');
|
|
4050
4049
|
app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
|
|
4051
4050
|
}
|
|
4052
4051
|
return sheet;
|
|
@@ -4056,7 +4055,6 @@ function ConstructedStyleSheets (app) {
|
|
|
4056
4055
|
context.CSSStyleSheet.prototype.replaceSync = function (text) {
|
|
4057
4056
|
const sheetID = styleSheetIDMap.get(this);
|
|
4058
4057
|
if (sheetID) {
|
|
4059
|
-
console.log('replaceSync');
|
|
4060
4058
|
app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
|
|
4061
4059
|
}
|
|
4062
4060
|
return replaceSync.call(this, text);
|
|
@@ -5208,7 +5206,7 @@ class App {
|
|
|
5208
5206
|
this.stopCallbacks = [];
|
|
5209
5207
|
this.commitCallbacks = [];
|
|
5210
5208
|
this.activityState = ActivityState.NotActive;
|
|
5211
|
-
this.version = '16.
|
|
5209
|
+
this.version = '16.3.0-beta.0'; // TODO: version compatability check inside each plugin.
|
|
5212
5210
|
this.socketMode = false;
|
|
5213
5211
|
this.compressionThreshold = 24 * 1000;
|
|
5214
5212
|
this.bc = null;
|
|
@@ -8043,6 +8041,11 @@ function Viewport (app) {
|
|
|
8043
8041
|
app.ticker.attach(sendSetViewportSize, 5, false);
|
|
8044
8042
|
}
|
|
8045
8043
|
|
|
8044
|
+
const defaults = {
|
|
8045
|
+
checkCssInterval: 200,
|
|
8046
|
+
scanInMemoryCSS: false,
|
|
8047
|
+
checkLimit: undefined,
|
|
8048
|
+
};
|
|
8046
8049
|
function CSSRules (app, opts) {
|
|
8047
8050
|
if (app === null)
|
|
8048
8051
|
return;
|
|
@@ -8050,34 +8053,48 @@ function CSSRules (app, opts) {
|
|
|
8050
8053
|
app.send(TechnicalInfo('no_stylesheet_prototype_in_window', ''));
|
|
8051
8054
|
return;
|
|
8052
8055
|
}
|
|
8053
|
-
|
|
8056
|
+
const options = { ...defaults, ...opts };
|
|
8057
|
+
// sheetID:index -> ruleText
|
|
8054
8058
|
const ruleSnapshots = new Map();
|
|
8055
8059
|
let checkInterval = null;
|
|
8056
|
-
const
|
|
8057
|
-
|
|
8060
|
+
const trackedSheets = new Set();
|
|
8061
|
+
const checkIntervalMs = options.checkCssInterval || 200;
|
|
8062
|
+
let checkIterations = {};
|
|
8058
8063
|
function checkRuleChanges() {
|
|
8059
|
-
|
|
8064
|
+
if (!options.scanInMemoryCSS)
|
|
8065
|
+
return;
|
|
8066
|
+
const allSheets = trackedSheets.values();
|
|
8067
|
+
for (const sheet of allSheets) {
|
|
8060
8068
|
try {
|
|
8061
|
-
const sheet = document.styleSheets[i];
|
|
8062
8069
|
const sheetID = styleSheetIDMap.get(sheet);
|
|
8063
8070
|
if (!sheetID)
|
|
8064
8071
|
continue;
|
|
8065
|
-
|
|
8072
|
+
if (options.checkLimit) {
|
|
8073
|
+
if (!checkIterations[sheetID]) {
|
|
8074
|
+
checkIterations[sheetID] = 0;
|
|
8075
|
+
}
|
|
8076
|
+
else {
|
|
8077
|
+
checkIterations[sheetID]++;
|
|
8078
|
+
}
|
|
8079
|
+
if (checkIterations[sheetID] > options.checkLimit) {
|
|
8080
|
+
trackedSheets.delete(sheet);
|
|
8081
|
+
return;
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
8066
8084
|
for (let j = 0; j < sheet.cssRules.length; j++) {
|
|
8067
8085
|
try {
|
|
8068
8086
|
const rule = sheet.cssRules[j];
|
|
8069
8087
|
const key = `${sheetID}:${j}`;
|
|
8070
|
-
const newText = rule.cssText;
|
|
8071
8088
|
const oldText = ruleSnapshots.get(key);
|
|
8089
|
+
const newText = rule.cssText;
|
|
8072
8090
|
if (oldText !== newText) {
|
|
8073
|
-
// Rule is new or changed
|
|
8074
8091
|
if (oldText !== undefined) {
|
|
8075
|
-
// Rule changed
|
|
8092
|
+
// Rule is changed
|
|
8076
8093
|
app.send(AdoptedSSDeleteRule(sheetID, j));
|
|
8077
8094
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, newText, j, app.getBaseHref()));
|
|
8078
8095
|
}
|
|
8079
8096
|
else {
|
|
8080
|
-
// Rule added
|
|
8097
|
+
// Rule added
|
|
8081
8098
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, newText, j, app.getBaseHref()));
|
|
8082
8099
|
}
|
|
8083
8100
|
ruleSnapshots.set(key, newText);
|
|
@@ -8087,7 +8104,6 @@ function CSSRules (app, opts) {
|
|
|
8087
8104
|
/* Skip inaccessible rules */
|
|
8088
8105
|
}
|
|
8089
8106
|
}
|
|
8090
|
-
// Check for deleted rules
|
|
8091
8107
|
const keysToCheck = Array.from(ruleSnapshots.keys()).filter((key) => key.startsWith(`${sheetID}:`));
|
|
8092
8108
|
for (const key of keysToCheck) {
|
|
8093
8109
|
const index = parseInt(key.split(':')[1], 10);
|
|
@@ -8098,21 +8114,30 @@ function CSSRules (app, opts) {
|
|
|
8098
8114
|
}
|
|
8099
8115
|
catch (e) {
|
|
8100
8116
|
/* Skip inaccessible sheets */
|
|
8117
|
+
trackedSheets.delete(sheet);
|
|
8101
8118
|
}
|
|
8102
8119
|
}
|
|
8103
8120
|
}
|
|
8104
|
-
|
|
8121
|
+
const emptyRuleReg = /{\s*}/;
|
|
8122
|
+
function isRuleEmpty(rule) {
|
|
8123
|
+
return emptyRuleReg.test(rule);
|
|
8124
|
+
}
|
|
8105
8125
|
const sendInsertDeleteRule = app.safe((sheet, index, rule) => {
|
|
8106
8126
|
const sheetID = styleSheetIDMap.get(sheet);
|
|
8107
8127
|
if (!sheetID)
|
|
8108
8128
|
return;
|
|
8109
8129
|
if (typeof rule === 'string') {
|
|
8110
8130
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, rule, index, app.getBaseHref()));
|
|
8111
|
-
|
|
8131
|
+
if (isRuleEmpty(rule)) {
|
|
8132
|
+
ruleSnapshots.set(`${sheetID}:${index}`, rule);
|
|
8133
|
+
trackedSheets.add(sheet);
|
|
8134
|
+
}
|
|
8112
8135
|
}
|
|
8113
8136
|
else {
|
|
8114
8137
|
app.send(AdoptedSSDeleteRule(sheetID, index));
|
|
8115
|
-
ruleSnapshots.
|
|
8138
|
+
if (ruleSnapshots.has(`${sheetID}:${index}`)) {
|
|
8139
|
+
ruleSnapshots.delete(`${sheetID}:${index}`);
|
|
8140
|
+
}
|
|
8116
8141
|
}
|
|
8117
8142
|
});
|
|
8118
8143
|
const sendReplaceGroupingRule = app.safe((rule) => {
|
|
@@ -8130,7 +8155,10 @@ function CSSRules (app, opts) {
|
|
|
8130
8155
|
if (idx >= 0) {
|
|
8131
8156
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, cssText, idx, app.getBaseHref()));
|
|
8132
8157
|
app.send(AdoptedSSDeleteRule(sheetID, idx + 1));
|
|
8133
|
-
|
|
8158
|
+
if (isRuleEmpty(cssText)) {
|
|
8159
|
+
ruleSnapshots.set(`${sheetID}:${idx}`, cssText);
|
|
8160
|
+
trackedSheets.add(sheet);
|
|
8161
|
+
}
|
|
8134
8162
|
}
|
|
8135
8163
|
});
|
|
8136
8164
|
// Patch prototype methods
|
|
@@ -8160,10 +8188,8 @@ function CSSRules (app, opts) {
|
|
|
8160
8188
|
return result;
|
|
8161
8189
|
};
|
|
8162
8190
|
});
|
|
8163
|
-
// Apply patches
|
|
8164
8191
|
patchContext(window);
|
|
8165
8192
|
app.observer.attachContextCallback(patchContext);
|
|
8166
|
-
// Track style nodes
|
|
8167
8193
|
app.nodes.attachNodeCallback((node) => {
|
|
8168
8194
|
if (!hasTag(node, 'style') || !node.sheet)
|
|
8169
8195
|
return;
|
|
@@ -8185,9 +8211,8 @@ function CSSRules (app, opts) {
|
|
|
8185
8211
|
}
|
|
8186
8212
|
}
|
|
8187
8213
|
});
|
|
8188
|
-
// Start checking and setup cleanup
|
|
8189
8214
|
function startChecking() {
|
|
8190
|
-
if (checkInterval)
|
|
8215
|
+
if (checkInterval || !options.scanInMemoryCSS)
|
|
8191
8216
|
return;
|
|
8192
8217
|
checkInterval = window.setInterval(checkRuleChanges, checkIntervalMs);
|
|
8193
8218
|
}
|
|
@@ -9762,7 +9787,7 @@ class API {
|
|
|
9762
9787
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9763
9788
|
const doNotTrack = this.checkDoNotTrack();
|
|
9764
9789
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9765
|
-
trackerVersion: '16.
|
|
9790
|
+
trackerVersion: '16.3.0-beta.0',
|
|
9766
9791
|
projectKey: this.options.projectKey,
|
|
9767
9792
|
doNotTrack,
|
|
9768
9793
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|
|
@@ -9861,7 +9886,7 @@ class API {
|
|
|
9861
9886
|
Mouse(app, options.mouse);
|
|
9862
9887
|
// inside iframe, we ignore viewport scroll
|
|
9863
9888
|
Scroll(app, this.crossdomainMode);
|
|
9864
|
-
CSSRules(app, options);
|
|
9889
|
+
CSSRules(app, options.css);
|
|
9865
9890
|
ConstructedStyleSheets(app);
|
|
9866
9891
|
Console(app, options);
|
|
9867
9892
|
Exception(app, options);
|