@openreplay/tracker 4.1.4 → 4.1.6
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/guards.d.ts +1 -0
- package/cjs/app/index.d.ts +2 -0
- package/cjs/app/index.js +34 -26
- package/cjs/app/messages.d.ts +1 -1
- package/cjs/app/messages.gen.d.ts +4 -1
- package/cjs/app/messages.gen.js +32 -5
- package/cjs/app/messages.js +2 -2
- package/cjs/app/nodes.d.ts +1 -1
- package/cjs/app/nodes.js +4 -4
- package/cjs/app/observer/top_observer.js +2 -0
- package/cjs/common/interaction.d.ts +6 -1
- package/cjs/common/messages.gen.d.ts +26 -5
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +11 -6
- package/cjs/modules/constructedStyleSheets.js +14 -11
- package/cjs/modules/cssrules.js +6 -6
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +8 -8
- package/cjs/modules/focus.d.ts +2 -0
- package/cjs/modules/focus.js +45 -0
- package/cjs/modules/fonts.d.ts +2 -0
- package/cjs/modules/fonts.js +57 -0
- package/cjs/modules/img.js +1 -1
- package/cjs/utils.d.ts +1 -1
- package/cjs/utils.js +2 -2
- package/lib/app/guards.d.ts +1 -0
- package/lib/app/index.d.ts +2 -0
- package/lib/app/index.js +34 -26
- package/lib/app/messages.d.ts +1 -1
- package/lib/app/messages.gen.d.ts +4 -1
- package/lib/app/messages.gen.js +26 -2
- package/lib/app/messages.js +2 -2
- package/lib/app/nodes.d.ts +1 -1
- package/lib/app/nodes.js +4 -4
- package/lib/app/observer/top_observer.js +2 -0
- package/lib/common/interaction.d.ts +6 -1
- package/lib/common/messages.gen.d.ts +26 -5
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +11 -6
- package/lib/modules/constructedStyleSheets.js +15 -12
- package/lib/modules/cssrules.js +6 -6
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +8 -8
- package/lib/modules/focus.d.ts +2 -0
- package/lib/modules/focus.js +42 -0
- package/lib/modules/fonts.d.ts +2 -0
- package/lib/modules/fonts.js +54 -0
- package/lib/modules/img.js +2 -2
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { isDocument } from '../app/guards.js';
|
|
2
|
+
import { LoadFontFace } from '../app/messages.gen.js';
|
|
3
|
+
export default function (app) {
|
|
4
|
+
if (!window.FontFace) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const docFonts = new Map();
|
|
8
|
+
const patchWindow = (wnd) => {
|
|
9
|
+
class FontFaceInterceptor extends wnd.FontFace {
|
|
10
|
+
constructor(...args) {
|
|
11
|
+
//maybe do this on load(). In this case check if the document.fonts.load(...) function calls the font's load()
|
|
12
|
+
if (typeof args[1] === 'string') {
|
|
13
|
+
let desc = '';
|
|
14
|
+
if (args[2]) {
|
|
15
|
+
app.safe(() => {
|
|
16
|
+
desc = JSON.stringify(args[2]);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const ffData = [args[0], args[1], desc];
|
|
20
|
+
const ffDataArr = docFonts.get(wnd.document) || [];
|
|
21
|
+
ffDataArr.push(ffData);
|
|
22
|
+
docFonts.set(wnd.document, ffDataArr);
|
|
23
|
+
const parentID = wnd === window ? 0 : app.nodes.getID(wnd.document);
|
|
24
|
+
if (parentID === undefined) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (app.active()) {
|
|
28
|
+
app.send(LoadFontFace(parentID, ...ffData));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
super(...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
wnd.FontFace = FontFaceInterceptor;
|
|
35
|
+
};
|
|
36
|
+
app.observer.attachContextCallback(patchWindow);
|
|
37
|
+
patchWindow(window);
|
|
38
|
+
app.nodes.attachNodeCallback((node) => {
|
|
39
|
+
if (!isDocument(node)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const ffDataArr = docFonts.get(node);
|
|
43
|
+
if (!ffDataArr) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const parentID = node.defaultView === window ? 0 : app.nodes.getID(node);
|
|
47
|
+
if (parentID === undefined) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
ffDataArr.forEach((ffData) => {
|
|
51
|
+
app.send(LoadFontFace(parentID, ...ffData));
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
package/lib/modules/img.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isURL, IS_FIREFOX, MAX_STR_LEN } from '../utils.js';
|
|
2
2
|
import { ResourceTiming, SetNodeAttributeURLBased, SetNodeAttribute } from '../app/messages.gen.js';
|
|
3
3
|
import { hasTag } from '../app/guards.js';
|
|
4
4
|
function resolveURL(url, location = document.location) {
|
|
@@ -52,7 +52,7 @@ export default function (app) {
|
|
|
52
52
|
const sendImgError = app.safe(function (img) {
|
|
53
53
|
const resolvedSrc = resolveURL(img.src || ''); // Src type is null sometimes. - is it true?
|
|
54
54
|
if (isURL(resolvedSrc)) {
|
|
55
|
-
app.send(ResourceTiming(timestamp(), 0, 0, 0, 0, 0, resolvedSrc, 'img'));
|
|
55
|
+
app.send(ResourceTiming(app.timestamp(), 0, 0, 0, 0, 0, resolvedSrc, 'img'));
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
const sendImgAttrs = app.safe(function (img) {
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const IN_BROWSER: boolean;
|
|
2
2
|
export declare const IS_FIREFOX: false | RegExpMatchArray | null;
|
|
3
3
|
export declare const MAX_STR_LEN = 100000;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const now: () => number;
|
|
5
5
|
export declare const stars: (str: string) => string;
|
|
6
6
|
export declare function normSpaces(str: string): string;
|
|
7
7
|
export declare function isURL(s: string): boolean;
|
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ export const IS_FIREFOX = IN_BROWSER && navigator.userAgent.match(/firefox|fxios
|
|
|
4
4
|
export const MAX_STR_LEN = 1e5;
|
|
5
5
|
const navigationStart = IN_BROWSER && (performance.timing.navigationStart || performance.timeOrigin);
|
|
6
6
|
// performance.now() is buggy in some browsers
|
|
7
|
-
export const
|
|
7
|
+
export const now = IN_BROWSER && performance.now() && navigationStart
|
|
8
8
|
? () => Math.round(performance.now() + navigationStart)
|
|
9
9
|
: () => Date.now();
|
|
10
10
|
export const stars = 'repeat' in String.prototype
|