@openreplay/tracker 4.1.4 → 4.1.5
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/cjs/app/index.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/modules/constructedStyleSheets.js +14 -7
- package/cjs/modules/cssrules.js +7 -7
- package/cjs/modules/exception.js +1 -1
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/constructedStyleSheets.js +14 -7
- package/lib/modules/cssrules.js +7 -7
- package/lib/modules/exception.js +1 -1
- package/package.json +1 -1
package/cjs/app/index.js
CHANGED
|
@@ -32,7 +32,7 @@ class App {
|
|
|
32
32
|
this.stopCallbacks = [];
|
|
33
33
|
this.commitCallbacks = [];
|
|
34
34
|
this.activityState = ActivityState.NotActive;
|
|
35
|
-
this.version = '4.1.
|
|
35
|
+
this.version = '4.1.5'; // TODO: version compatability check inside each plugin.
|
|
36
36
|
this.projectKey = projectKey;
|
|
37
37
|
this.options = Object.assign({
|
|
38
38
|
revID: '',
|
package/cjs/index.js
CHANGED
|
@@ -133,7 +133,7 @@ class API {
|
|
|
133
133
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
134
134
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
135
135
|
req.send(JSON.stringify({
|
|
136
|
-
trackerVersion: '4.1.
|
|
136
|
+
trackerVersion: '4.1.5',
|
|
137
137
|
projectKey: options.projectKey,
|
|
138
138
|
doNotTrack,
|
|
139
139
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -28,12 +28,12 @@ function default_1(app) {
|
|
|
28
28
|
}
|
|
29
29
|
const styleSheetIDMap = new Map();
|
|
30
30
|
const adoptedStyleSheetsOwnings = new Map();
|
|
31
|
-
const sendAdoptedStyleSheetsUpdate = (root) => {
|
|
31
|
+
const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
|
|
32
32
|
let nodeID = app.nodes.getID(root);
|
|
33
33
|
if (root === document) {
|
|
34
34
|
nodeID = 0; // main document doesn't have nodeID. ID count starts from the documentElement
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
36
|
+
if (nodeID === undefined) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
let pastOwning = adoptedStyleSheetsOwnings.get(nodeID);
|
|
@@ -47,8 +47,8 @@ function default_1(app) {
|
|
|
47
47
|
const init = !sheetID;
|
|
48
48
|
if (!sheetID) {
|
|
49
49
|
sheetID = nextID();
|
|
50
|
+
styleSheetIDMap.set(s, sheetID);
|
|
50
51
|
}
|
|
51
|
-
nowOwning.push(sheetID);
|
|
52
52
|
if (!pastOwning.includes(sheetID)) {
|
|
53
53
|
app.send((0, messages_gen_js_1.AdoptedSSAddOwner)(sheetID, nodeID));
|
|
54
54
|
}
|
|
@@ -58,6 +58,7 @@ function default_1(app) {
|
|
|
58
58
|
app.send((0, messages_gen_js_1.AdoptedSSInsertRuleURLBased)(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
nowOwning.push(sheetID);
|
|
61
62
|
}
|
|
62
63
|
for (const sheetID of pastOwning) {
|
|
63
64
|
if (!nowOwning.includes(sheetID)) {
|
|
@@ -65,7 +66,13 @@ function default_1(app) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
68
|
-
};
|
|
69
|
+
}, 20); // Misterious bug:
|
|
70
|
+
/* On the page https://explore.fast.design/components/fast-accordion
|
|
71
|
+
the only rule inside the only adoptedStyleSheet of the iframe-s document
|
|
72
|
+
gets changed during first milliseconds after the load.
|
|
73
|
+
Howerer, none of the documented methods (replace, insertRule) is triggered.
|
|
74
|
+
The rule is not substituted (remains the same object), however the text gets changed.
|
|
75
|
+
*/
|
|
69
76
|
function patchAdoptedStyleSheets(prototype) {
|
|
70
77
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
71
78
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
@@ -88,8 +95,8 @@ function default_1(app) {
|
|
|
88
95
|
}
|
|
89
96
|
patchAdoptedStyleSheets(context.Document.prototype);
|
|
90
97
|
patchAdoptedStyleSheets(context.ShadowRoot.prototype);
|
|
91
|
-
//@ts-ignore TODO:
|
|
92
|
-
const {
|
|
98
|
+
//@ts-ignore TODO: upgrade ts to 4.8+
|
|
99
|
+
const { replace, replaceSync } = context.CSSStyleSheet.prototype;
|
|
93
100
|
//@ts-ignore
|
|
94
101
|
context.CSSStyleSheet.prototype.replace = function (text) {
|
|
95
102
|
return replace.call(this, text).then((sheet) => {
|
|
@@ -110,7 +117,7 @@ function default_1(app) {
|
|
|
110
117
|
};
|
|
111
118
|
};
|
|
112
119
|
patchContext(window);
|
|
113
|
-
app.observer.attachContextCallback(patchContext);
|
|
120
|
+
app.observer.attachContextCallback(app.safe(patchContext));
|
|
114
121
|
app.attachStopCallback(() => {
|
|
115
122
|
styleSheetIDMap.clear();
|
|
116
123
|
adoptedStyleSheetsOwnings.clear();
|
package/cjs/modules/cssrules.js
CHANGED
|
@@ -11,7 +11,7 @@ function default_1(app) {
|
|
|
11
11
|
app.send((0, messages_gen_js_1.TechnicalInfo)('no_stylesheet_prototype_in_window', ''));
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const sendInsertDeleteRule = app.safe((sheet, index, rule) => {
|
|
15
15
|
const sheetID = constructedStyleSheets_js_1.styleSheetIDMap.get(sheet);
|
|
16
16
|
if (!sheetID) {
|
|
17
17
|
// OK-case. Sheet haven't been registered yet. Rules will be sent on registration.
|
|
@@ -51,15 +51,15 @@ function default_1(app) {
|
|
|
51
51
|
app.debug.warn('Rule index not found in', sheet, topmostRule);
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
const patchContext = (context) => {
|
|
54
|
+
const patchContext = app.safe((context) => {
|
|
55
55
|
const { insertRule, deleteRule } = context.CSSStyleSheet.prototype;
|
|
56
|
-
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule } = context.CSSGroupingRule.prototype;
|
|
56
|
+
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule, } = context.CSSGroupingRule.prototype;
|
|
57
57
|
context.CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
|
|
58
|
-
|
|
58
|
+
sendInsertDeleteRule(this, index, rule);
|
|
59
59
|
return insertRule.call(this, rule, index);
|
|
60
60
|
};
|
|
61
61
|
context.CSSStyleSheet.prototype.deleteRule = function (index) {
|
|
62
|
-
|
|
62
|
+
sendInsertDeleteRule(this, index);
|
|
63
63
|
return deleteRule.call(this, index);
|
|
64
64
|
};
|
|
65
65
|
context.CSSGroupingRule.prototype.insertRule = function (rule, index = 0) {
|
|
@@ -72,7 +72,7 @@ function default_1(app) {
|
|
|
72
72
|
sendReplaceGroupingRule(this);
|
|
73
73
|
return result;
|
|
74
74
|
};
|
|
75
|
-
};
|
|
75
|
+
});
|
|
76
76
|
patchContext(window);
|
|
77
77
|
app.observer.attachContextCallback(patchContext);
|
|
78
78
|
app.nodes.attachNodeCallback((node) => {
|
|
@@ -92,7 +92,7 @@ function default_1(app) {
|
|
|
92
92
|
app.send((0, messages_gen_js_1.AdoptedSSAddOwner)(sheetID, nodeID));
|
|
93
93
|
const rules = sheet.cssRules;
|
|
94
94
|
for (let i = 0; i < rules.length; i++) {
|
|
95
|
-
|
|
95
|
+
sendInsertDeleteRule(sheet, i, rules[i].cssText);
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
}
|
package/cjs/modules/exception.js
CHANGED
|
@@ -70,7 +70,7 @@ function default_1(app, opts) {
|
|
|
70
70
|
app.attachEventListener(context, 'error', handler);
|
|
71
71
|
}
|
|
72
72
|
if (options.captureExceptions) {
|
|
73
|
-
app.observer.attachContextCallback(patchContext);
|
|
73
|
+
app.observer.attachContextCallback(patchContext); // TODO: attach once-per-iframe (?)
|
|
74
74
|
patchContext(window);
|
|
75
75
|
}
|
|
76
76
|
}
|
package/lib/app/index.js
CHANGED
|
@@ -29,7 +29,7 @@ export default class App {
|
|
|
29
29
|
this.stopCallbacks = [];
|
|
30
30
|
this.commitCallbacks = [];
|
|
31
31
|
this.activityState = ActivityState.NotActive;
|
|
32
|
-
this.version = '4.1.
|
|
32
|
+
this.version = '4.1.5'; // TODO: version compatability check inside each plugin.
|
|
33
33
|
this.projectKey = projectKey;
|
|
34
34
|
this.options = Object.assign({
|
|
35
35
|
revID: '',
|
package/lib/index.js
CHANGED
|
@@ -128,7 +128,7 @@ export default class API {
|
|
|
128
128
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
129
129
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
130
130
|
req.send(JSON.stringify({
|
|
131
|
-
trackerVersion: '4.1.
|
|
131
|
+
trackerVersion: '4.1.5',
|
|
132
132
|
projectKey: options.projectKey,
|
|
133
133
|
doNotTrack,
|
|
134
134
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -24,12 +24,12 @@ export default function (app) {
|
|
|
24
24
|
}
|
|
25
25
|
const styleSheetIDMap = new Map();
|
|
26
26
|
const adoptedStyleSheetsOwnings = new Map();
|
|
27
|
-
const sendAdoptedStyleSheetsUpdate = (root) => {
|
|
27
|
+
const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
|
|
28
28
|
let nodeID = app.nodes.getID(root);
|
|
29
29
|
if (root === document) {
|
|
30
30
|
nodeID = 0; // main document doesn't have nodeID. ID count starts from the documentElement
|
|
31
31
|
}
|
|
32
|
-
if (
|
|
32
|
+
if (nodeID === undefined) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
let pastOwning = adoptedStyleSheetsOwnings.get(nodeID);
|
|
@@ -43,8 +43,8 @@ export default function (app) {
|
|
|
43
43
|
const init = !sheetID;
|
|
44
44
|
if (!sheetID) {
|
|
45
45
|
sheetID = nextID();
|
|
46
|
+
styleSheetIDMap.set(s, sheetID);
|
|
46
47
|
}
|
|
47
|
-
nowOwning.push(sheetID);
|
|
48
48
|
if (!pastOwning.includes(sheetID)) {
|
|
49
49
|
app.send(AdoptedSSAddOwner(sheetID, nodeID));
|
|
50
50
|
}
|
|
@@ -54,6 +54,7 @@ export default function (app) {
|
|
|
54
54
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
nowOwning.push(sheetID);
|
|
57
58
|
}
|
|
58
59
|
for (const sheetID of pastOwning) {
|
|
59
60
|
if (!nowOwning.includes(sheetID)) {
|
|
@@ -61,7 +62,13 @@ export default function (app) {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
64
|
-
};
|
|
65
|
+
}, 20); // Misterious bug:
|
|
66
|
+
/* On the page https://explore.fast.design/components/fast-accordion
|
|
67
|
+
the only rule inside the only adoptedStyleSheet of the iframe-s document
|
|
68
|
+
gets changed during first milliseconds after the load.
|
|
69
|
+
Howerer, none of the documented methods (replace, insertRule) is triggered.
|
|
70
|
+
The rule is not substituted (remains the same object), however the text gets changed.
|
|
71
|
+
*/
|
|
65
72
|
function patchAdoptedStyleSheets(prototype) {
|
|
66
73
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
67
74
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
@@ -84,8 +91,8 @@ export default function (app) {
|
|
|
84
91
|
}
|
|
85
92
|
patchAdoptedStyleSheets(context.Document.prototype);
|
|
86
93
|
patchAdoptedStyleSheets(context.ShadowRoot.prototype);
|
|
87
|
-
//@ts-ignore TODO:
|
|
88
|
-
const {
|
|
94
|
+
//@ts-ignore TODO: upgrade ts to 4.8+
|
|
95
|
+
const { replace, replaceSync } = context.CSSStyleSheet.prototype;
|
|
89
96
|
//@ts-ignore
|
|
90
97
|
context.CSSStyleSheet.prototype.replace = function (text) {
|
|
91
98
|
return replace.call(this, text).then((sheet) => {
|
|
@@ -106,7 +113,7 @@ export default function (app) {
|
|
|
106
113
|
};
|
|
107
114
|
};
|
|
108
115
|
patchContext(window);
|
|
109
|
-
app.observer.attachContextCallback(patchContext);
|
|
116
|
+
app.observer.attachContextCallback(app.safe(patchContext));
|
|
110
117
|
app.attachStopCallback(() => {
|
|
111
118
|
styleSheetIDMap.clear();
|
|
112
119
|
adoptedStyleSheetsOwnings.clear();
|
package/lib/modules/cssrules.js
CHANGED
|
@@ -10,7 +10,7 @@ export default function (app) {
|
|
|
10
10
|
app.send(TechnicalInfo('no_stylesheet_prototype_in_window', ''));
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const sendInsertDeleteRule = app.safe((sheet, index, rule) => {
|
|
14
14
|
const sheetID = styleSheetIDMap.get(sheet);
|
|
15
15
|
if (!sheetID) {
|
|
16
16
|
// OK-case. Sheet haven't been registered yet. Rules will be sent on registration.
|
|
@@ -50,15 +50,15 @@ export default function (app) {
|
|
|
50
50
|
app.debug.warn('Rule index not found in', sheet, topmostRule);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
const patchContext = (context) => {
|
|
53
|
+
const patchContext = app.safe((context) => {
|
|
54
54
|
const { insertRule, deleteRule } = context.CSSStyleSheet.prototype;
|
|
55
|
-
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule } = context.CSSGroupingRule.prototype;
|
|
55
|
+
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule, } = context.CSSGroupingRule.prototype;
|
|
56
56
|
context.CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
|
|
57
|
-
|
|
57
|
+
sendInsertDeleteRule(this, index, rule);
|
|
58
58
|
return insertRule.call(this, rule, index);
|
|
59
59
|
};
|
|
60
60
|
context.CSSStyleSheet.prototype.deleteRule = function (index) {
|
|
61
|
-
|
|
61
|
+
sendInsertDeleteRule(this, index);
|
|
62
62
|
return deleteRule.call(this, index);
|
|
63
63
|
};
|
|
64
64
|
context.CSSGroupingRule.prototype.insertRule = function (rule, index = 0) {
|
|
@@ -71,7 +71,7 @@ export default function (app) {
|
|
|
71
71
|
sendReplaceGroupingRule(this);
|
|
72
72
|
return result;
|
|
73
73
|
};
|
|
74
|
-
};
|
|
74
|
+
});
|
|
75
75
|
patchContext(window);
|
|
76
76
|
app.observer.attachContextCallback(patchContext);
|
|
77
77
|
app.nodes.attachNodeCallback((node) => {
|
|
@@ -91,7 +91,7 @@ export default function (app) {
|
|
|
91
91
|
app.send(AdoptedSSAddOwner(sheetID, nodeID));
|
|
92
92
|
const rules = sheet.cssRules;
|
|
93
93
|
for (let i = 0; i < rules.length; i++) {
|
|
94
|
-
|
|
94
|
+
sendInsertDeleteRule(sheet, i, rules[i].cssText);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}
|
package/lib/modules/exception.js
CHANGED
|
@@ -65,7 +65,7 @@ export default function (app, opts) {
|
|
|
65
65
|
app.attachEventListener(context, 'error', handler);
|
|
66
66
|
}
|
|
67
67
|
if (options.captureExceptions) {
|
|
68
|
-
app.observer.attachContextCallback(patchContext);
|
|
68
|
+
app.observer.attachContextCallback(patchContext); // TODO: attach once-per-iframe (?)
|
|
69
69
|
patchContext(window);
|
|
70
70
|
}
|
|
71
71
|
}
|