@openreplay/tracker 4.1.4-beta.0 → 4.1.4-beta.1
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 -12
- package/cjs/modules/cssrules.js +2 -0
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/constructedStyleSheets.js +14 -12
- package/lib/modules/cssrules.js +2 -0
- 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.4-beta.0'; // 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.4-beta.0',
|
|
137
137
|
projectKey: options.projectKey,
|
|
138
138
|
doNotTrack,
|
|
139
139
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -47,6 +47,7 @@ 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
52
|
if (!pastOwning.includes(sheetID)) {
|
|
52
53
|
app.send((0, messages_gen_js_1.AdoptedSSAddOwner)(sheetID, nodeID));
|
|
@@ -54,25 +55,22 @@ function default_1(app) {
|
|
|
54
55
|
if (init) {
|
|
55
56
|
const rules = s.cssRules;
|
|
56
57
|
for (let i = 0; i < rules.length; i++) {
|
|
57
|
-
nodeID === 1110 && console.log(rules[i].cssText, root, s, root.adoptedStyleSheets[0], s.cssRules[0]);
|
|
58
58
|
app.send((0, messages_gen_js_1.AdoptedSSInsertRuleURLBased)(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
nowOwning.push(sheetID);
|
|
62
62
|
}
|
|
63
|
-
// nodeID === 0 && console.log(pastOwning, nowOwning, nowOwning.length)
|
|
64
63
|
for (const sheetID of pastOwning) {
|
|
65
64
|
if (!nowOwning.includes(sheetID)) {
|
|
66
65
|
app.send((0, messages_gen_js_1.AdoptedSSRemoveOwner)(sheetID, nodeID));
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
70
|
-
},
|
|
71
|
-
function patchAdoptedStyleSheets(prototype
|
|
69
|
+
}, 20);
|
|
70
|
+
function patchAdoptedStyleSheets(prototype) {
|
|
72
71
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
73
72
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
74
73
|
Object.defineProperty(prototype, 'adoptedStyleSheets', Object.assign(Object.assign({}, nativeAdoptedStyleSheetsDescriptor), { set: function (value) {
|
|
75
|
-
ctx !== window && ctx.Document.prototype === prototype && console.log("custom set!", value, ctx);
|
|
76
74
|
// @ts-ignore
|
|
77
75
|
const retVal = nativeAdoptedStyleSheetsDescriptor.set.call(this, value);
|
|
78
76
|
sendAdoptedStyleSheetsUpdate(this);
|
|
@@ -81,8 +79,6 @@ function default_1(app) {
|
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
const patchContext = (context) => {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
console.log("new context", context, context.document.adoptedStyleSheets.length && context.document.adoptedStyleSheets[0].cssRules[0].cssText);
|
|
86
82
|
// @ts-ignore
|
|
87
83
|
if (context.__openreplay_adpss_patched__) {
|
|
88
84
|
return;
|
|
@@ -91,28 +87,34 @@ function default_1(app) {
|
|
|
91
87
|
// @ts-ignore
|
|
92
88
|
context.__openreplay_adpss_patched__ = true;
|
|
93
89
|
}
|
|
94
|
-
patchAdoptedStyleSheets(context.Document.prototype
|
|
95
|
-
patchAdoptedStyleSheets(context.ShadowRoot.prototype
|
|
96
|
-
//@ts-ignore TODO: configure ts
|
|
90
|
+
patchAdoptedStyleSheets(context.Document.prototype);
|
|
91
|
+
patchAdoptedStyleSheets(context.ShadowRoot.prototype);
|
|
92
|
+
//@ts-ignore TODO: configure ts
|
|
97
93
|
const { replace, replaceSync } = context.CSSStyleSheet.prototype;
|
|
98
94
|
//@ts-ignore
|
|
99
95
|
context.CSSStyleSheet.prototype.replace = function (text) {
|
|
100
|
-
styleSheetIDMap.get(this) ===
|
|
96
|
+
styleSheetIDMap.get(this) === 29 && console.log("replace with", text);
|
|
101
97
|
return replace.call(this, text).then((sheet) => {
|
|
102
98
|
const sheetID = styleSheetIDMap.get(this);
|
|
103
99
|
if (sheetID) {
|
|
104
100
|
app.send((0, messages_gen_js_1.AdoptedSSReplaceURLBased)(sheetID, text, app.getBaseHref()));
|
|
105
101
|
}
|
|
102
|
+
else {
|
|
103
|
+
console.log("repl-async no sheet-id");
|
|
104
|
+
}
|
|
106
105
|
return sheet;
|
|
107
106
|
});
|
|
108
107
|
};
|
|
109
108
|
//@ts-ignore
|
|
110
109
|
context.CSSStyleSheet.prototype.replaceSync = function (text) {
|
|
111
110
|
const sheetID = styleSheetIDMap.get(this);
|
|
112
|
-
sheetID ===
|
|
111
|
+
sheetID === 29 && console.log("replacesnc with", text);
|
|
113
112
|
if (sheetID) {
|
|
114
113
|
app.send((0, messages_gen_js_1.AdoptedSSReplaceURLBased)(sheetID, text, app.getBaseHref()));
|
|
115
114
|
}
|
|
115
|
+
else {
|
|
116
|
+
console.log("replsync no sheet-id", this);
|
|
117
|
+
}
|
|
116
118
|
return replaceSync.call(this, text);
|
|
117
119
|
};
|
|
118
120
|
};
|
package/cjs/modules/cssrules.js
CHANGED
|
@@ -15,8 +15,10 @@ function default_1(app) {
|
|
|
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.
|
|
18
|
+
console.log("no-sheet id", sheet, rule);
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
21
|
+
sheetID === 29 && console.log("repdel", sheet, rule);
|
|
20
22
|
if (typeof rule === 'string') {
|
|
21
23
|
app.send((0, messages_gen_js_1.AdoptedSSInsertRuleURLBased)(sheetID, rule, index, app.getBaseHref()));
|
|
22
24
|
}
|
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.4-beta.0'; // 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.4-beta.0',
|
|
132
132
|
projectKey: options.projectKey,
|
|
133
133
|
doNotTrack,
|
|
134
134
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -43,6 +43,7 @@ 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
48
|
if (!pastOwning.includes(sheetID)) {
|
|
48
49
|
app.send(AdoptedSSAddOwner(sheetID, nodeID));
|
|
@@ -50,25 +51,22 @@ export default function (app) {
|
|
|
50
51
|
if (init) {
|
|
51
52
|
const rules = s.cssRules;
|
|
52
53
|
for (let i = 0; i < rules.length; i++) {
|
|
53
|
-
nodeID === 1110 && console.log(rules[i].cssText, root, s, root.adoptedStyleSheets[0], s.cssRules[0]);
|
|
54
54
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
nowOwning.push(sheetID);
|
|
58
58
|
}
|
|
59
|
-
// nodeID === 0 && console.log(pastOwning, nowOwning, nowOwning.length)
|
|
60
59
|
for (const sheetID of pastOwning) {
|
|
61
60
|
if (!nowOwning.includes(sheetID)) {
|
|
62
61
|
app.send(AdoptedSSRemoveOwner(sheetID, nodeID));
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
66
|
-
},
|
|
67
|
-
function patchAdoptedStyleSheets(prototype
|
|
65
|
+
}, 20);
|
|
66
|
+
function patchAdoptedStyleSheets(prototype) {
|
|
68
67
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
69
68
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
70
69
|
Object.defineProperty(prototype, 'adoptedStyleSheets', Object.assign(Object.assign({}, nativeAdoptedStyleSheetsDescriptor), { set: function (value) {
|
|
71
|
-
ctx !== window && ctx.Document.prototype === prototype && console.log("custom set!", value, ctx);
|
|
72
70
|
// @ts-ignore
|
|
73
71
|
const retVal = nativeAdoptedStyleSheetsDescriptor.set.call(this, value);
|
|
74
72
|
sendAdoptedStyleSheetsUpdate(this);
|
|
@@ -77,8 +75,6 @@ export default function (app) {
|
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
const patchContext = (context) => {
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
console.log("new context", context, context.document.adoptedStyleSheets.length && context.document.adoptedStyleSheets[0].cssRules[0].cssText);
|
|
82
78
|
// @ts-ignore
|
|
83
79
|
if (context.__openreplay_adpss_patched__) {
|
|
84
80
|
return;
|
|
@@ -87,28 +83,34 @@ export default function (app) {
|
|
|
87
83
|
// @ts-ignore
|
|
88
84
|
context.__openreplay_adpss_patched__ = true;
|
|
89
85
|
}
|
|
90
|
-
patchAdoptedStyleSheets(context.Document.prototype
|
|
91
|
-
patchAdoptedStyleSheets(context.ShadowRoot.prototype
|
|
92
|
-
//@ts-ignore TODO: configure ts
|
|
86
|
+
patchAdoptedStyleSheets(context.Document.prototype);
|
|
87
|
+
patchAdoptedStyleSheets(context.ShadowRoot.prototype);
|
|
88
|
+
//@ts-ignore TODO: configure ts
|
|
93
89
|
const { replace, replaceSync } = context.CSSStyleSheet.prototype;
|
|
94
90
|
//@ts-ignore
|
|
95
91
|
context.CSSStyleSheet.prototype.replace = function (text) {
|
|
96
|
-
styleSheetIDMap.get(this) ===
|
|
92
|
+
styleSheetIDMap.get(this) === 29 && console.log("replace with", text);
|
|
97
93
|
return replace.call(this, text).then((sheet) => {
|
|
98
94
|
const sheetID = styleSheetIDMap.get(this);
|
|
99
95
|
if (sheetID) {
|
|
100
96
|
app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
|
|
101
97
|
}
|
|
98
|
+
else {
|
|
99
|
+
console.log("repl-async no sheet-id");
|
|
100
|
+
}
|
|
102
101
|
return sheet;
|
|
103
102
|
});
|
|
104
103
|
};
|
|
105
104
|
//@ts-ignore
|
|
106
105
|
context.CSSStyleSheet.prototype.replaceSync = function (text) {
|
|
107
106
|
const sheetID = styleSheetIDMap.get(this);
|
|
108
|
-
sheetID ===
|
|
107
|
+
sheetID === 29 && console.log("replacesnc with", text);
|
|
109
108
|
if (sheetID) {
|
|
110
109
|
app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
|
|
111
110
|
}
|
|
111
|
+
else {
|
|
112
|
+
console.log("replsync no sheet-id", this);
|
|
113
|
+
}
|
|
112
114
|
return replaceSync.call(this, text);
|
|
113
115
|
};
|
|
114
116
|
};
|
package/lib/modules/cssrules.js
CHANGED
|
@@ -14,8 +14,10 @@ export default function (app) {
|
|
|
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.
|
|
17
|
+
console.log("no-sheet id", sheet, rule);
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
20
|
+
sheetID === 29 && console.log("repdel", sheet, rule);
|
|
19
21
|
if (typeof rule === 'string') {
|
|
20
22
|
app.send(AdoptedSSInsertRuleURLBased(sheetID, rule, index, app.getBaseHref()));
|
|
21
23
|
}
|