clarity-js 0.8.12 → 0.8.13-beta
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/build/clarity.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +3952 -4179
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +3952 -4179
- package/build/clarity.performance.js +1 -1
- package/package.json +69 -76
- package/rollup.config.ts +88 -84
- package/src/clarity.ts +28 -34
- package/src/core/api.ts +1 -8
- package/src/core/config.ts +2 -2
- package/src/core/event.ts +32 -36
- package/src/core/hash.ts +6 -5
- package/src/core/history.ts +11 -10
- package/src/core/index.ts +11 -21
- package/src/core/measure.ts +5 -9
- package/src/core/report.ts +3 -3
- package/src/core/scrub.ts +20 -29
- package/src/core/task.ts +45 -73
- package/src/core/time.ts +3 -3
- package/src/core/timeout.ts +2 -2
- package/src/core/version.ts +1 -1
- package/src/data/baseline.ts +55 -60
- package/src/data/consent.ts +2 -2
- package/src/data/custom.ts +13 -8
- package/src/data/dimension.ts +7 -11
- package/src/data/encode.ts +30 -36
- package/src/data/envelope.ts +38 -38
- package/src/data/extract.ts +77 -86
- package/src/data/index.ts +6 -10
- package/src/data/limit.ts +1 -1
- package/src/data/metadata.ts +266 -305
- package/src/data/metric.ts +8 -18
- package/src/data/ping.ts +4 -8
- package/src/data/signal.ts +18 -18
- package/src/data/summary.ts +4 -6
- package/src/data/token.ts +8 -10
- package/src/data/upgrade.ts +3 -7
- package/src/data/upload.ts +49 -100
- package/src/data/variable.ts +20 -27
- package/src/diagnostic/encode.ts +2 -2
- package/src/diagnostic/fraud.ts +4 -3
- package/src/diagnostic/internal.ts +5 -11
- package/src/diagnostic/script.ts +8 -12
- package/src/global.ts +1 -1
- package/src/insight/blank.ts +4 -4
- package/src/insight/encode.ts +17 -23
- package/src/insight/snapshot.ts +37 -57
- package/src/interaction/change.ts +6 -9
- package/src/interaction/click.ts +28 -34
- package/src/interaction/clipboard.ts +2 -2
- package/src/interaction/encode.ts +31 -35
- package/src/interaction/input.ts +9 -11
- package/src/interaction/pointer.ts +24 -35
- package/src/interaction/resize.ts +5 -5
- package/src/interaction/scroll.ts +11 -14
- package/src/interaction/selection.ts +8 -12
- package/src/interaction/submit.ts +2 -2
- package/src/interaction/timeline.ts +9 -13
- package/src/interaction/unload.ts +1 -1
- package/src/interaction/visibility.ts +2 -2
- package/src/layout/animation.ts +41 -47
- package/src/layout/discover.ts +5 -5
- package/src/layout/document.ts +19 -31
- package/src/layout/dom.ts +91 -141
- package/src/layout/encode.ts +37 -52
- package/src/layout/mutation.ts +318 -321
- package/src/layout/node.ts +81 -104
- package/src/layout/offset.ts +6 -7
- package/src/layout/region.ts +40 -60
- package/src/layout/schema.ts +8 -15
- package/src/layout/selector.ts +25 -47
- package/src/layout/style.ts +36 -44
- package/src/layout/target.ts +10 -14
- package/src/layout/traverse.ts +11 -17
- package/src/performance/blank.ts +1 -1
- package/src/performance/encode.ts +4 -4
- package/src/performance/interaction.ts +70 -58
- package/src/performance/navigation.ts +2 -2
- package/src/performance/observer.ts +26 -59
- package/src/queue.ts +9 -16
- package/tsconfig.json +1 -1
- package/tslint.json +32 -25
- package/types/core.d.ts +13 -13
- package/types/data.d.ts +29 -33
- package/types/diagnostic.d.ts +1 -1
- package/types/interaction.d.ts +4 -4
- package/types/layout.d.ts +21 -36
- package/types/performance.d.ts +5 -6
- package/.lintstagedrc.yml +0 -3
- package/biome.json +0 -43
package/src/layout/animation.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { Event } from "@clarity-types/data";
|
|
2
|
-
import { AnimationOperation,
|
|
3
|
-
import * as core from "@src/core";
|
|
2
|
+
import { AnimationOperation, AnimationState } from "@clarity-types/layout";
|
|
4
3
|
import { time } from "@src/core/time";
|
|
5
4
|
import { shortid } from "@src/data/metadata";
|
|
6
|
-
import { getId } from "@src/layout/dom";
|
|
7
5
|
import encode from "@src/layout/encode";
|
|
6
|
+
import { getId } from "@src/layout/dom";
|
|
7
|
+
import * as core from "@src/core";
|
|
8
8
|
|
|
9
9
|
export let state: AnimationState[] = [];
|
|
10
10
|
let elementAnimate: (keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions) => Animation = null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const animationId =
|
|
17
|
-
const operationCount =
|
|
11
|
+
let animationPlay: () => void = null;
|
|
12
|
+
let animationPause: () => void = null;
|
|
13
|
+
let animationCommitStyles: () => void = null;
|
|
14
|
+
let animationCancel: () => void = null;
|
|
15
|
+
let animationFinish: () => void = null;
|
|
16
|
+
const animationId = 'clarityAnimationId';
|
|
17
|
+
const operationCount = 'clarityOperationCount';
|
|
18
18
|
const maxOperations = 20;
|
|
19
19
|
|
|
20
20
|
export function start(): void {
|
|
21
21
|
if (
|
|
22
|
-
window
|
|
23
|
-
window.
|
|
24
|
-
window
|
|
25
|
-
window
|
|
26
|
-
window
|
|
22
|
+
window["Animation"] &&
|
|
23
|
+
window["Animation"].prototype &&
|
|
24
|
+
window["KeyframeEffect"] &&
|
|
25
|
+
window["KeyframeEffect"].prototype &&
|
|
26
|
+
window["KeyframeEffect"].prototype.getKeyframes &&
|
|
27
|
+
window["KeyframeEffect"].prototype.getTiming
|
|
27
28
|
) {
|
|
28
29
|
reset();
|
|
29
30
|
overrideAnimationHelper(animationPlay, "play");
|
|
@@ -33,39 +34,33 @@ export function start(): void {
|
|
|
33
34
|
overrideAnimationHelper(animationFinish, "finish");
|
|
34
35
|
if (elementAnimate === null) {
|
|
35
36
|
elementAnimate = Element.prototype.animate;
|
|
36
|
-
Element.prototype.animate = function
|
|
37
|
-
|
|
37
|
+
Element.prototype.animate = function(): Animation {
|
|
38
|
+
var createdAnimation = elementAnimate.apply(this, arguments);
|
|
38
39
|
trackAnimationOperation(createdAnimation, "play");
|
|
39
40
|
return createdAnimation;
|
|
40
|
-
}
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
if (document.getAnimations) {
|
|
43
|
-
for (
|
|
44
|
+
for (var animation of document.getAnimations()) {
|
|
44
45
|
if (animation.playState === "finished") {
|
|
45
46
|
trackAnimationOperation(animation, "finish");
|
|
46
|
-
}
|
|
47
|
+
}
|
|
48
|
+
else if (animation.playState === "paused" || animation.playState === "idle") {
|
|
47
49
|
trackAnimationOperation(animation, "pause");
|
|
48
|
-
}
|
|
50
|
+
}
|
|
51
|
+
else if (animation.playState === "running") {
|
|
49
52
|
trackAnimationOperation(animation, "play");
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
}
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export function reset(): void {
|
|
57
60
|
state = [];
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
function track(
|
|
61
|
-
time: number,
|
|
62
|
-
id: string,
|
|
63
|
-
operation: AnimationOperation,
|
|
64
|
-
keyFrames?: string,
|
|
65
|
-
timing?: string,
|
|
66
|
-
targetId?: number,
|
|
67
|
-
timeline?: string,
|
|
68
|
-
): void {
|
|
63
|
+
function track(time: number, id: string, operation: AnimationOperation, keyFrames?: string, timing?: string, targetId?: number, timeline?: string): void {
|
|
69
64
|
state.push({
|
|
70
65
|
time,
|
|
71
66
|
event: Event.Animation,
|
|
@@ -75,8 +70,8 @@ function track(
|
|
|
75
70
|
keyFrames,
|
|
76
71
|
timing,
|
|
77
72
|
targetId,
|
|
78
|
-
timeline
|
|
79
|
-
}
|
|
73
|
+
timeline
|
|
74
|
+
}
|
|
80
75
|
});
|
|
81
76
|
|
|
82
77
|
encode(Event.Animation);
|
|
@@ -88,30 +83,29 @@ export function stop(): void {
|
|
|
88
83
|
|
|
89
84
|
function overrideAnimationHelper(functionToOverride: () => void, name: string) {
|
|
90
85
|
if (functionToOverride === null) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
86
|
+
functionToOverride = Animation.prototype[name];
|
|
87
|
+
Animation.prototype[name] = function(): void {
|
|
88
|
+
trackAnimationOperation(this, name);
|
|
89
|
+
return functionToOverride.apply(this, arguments);
|
|
90
|
+
}
|
|
97
91
|
}
|
|
98
|
-
}
|
|
92
|
+
}
|
|
99
93
|
|
|
100
94
|
function trackAnimationOperation(animation: Animation, name: string) {
|
|
101
95
|
if (core.active()) {
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
let effect = <KeyframeEffect>animation.effect;
|
|
97
|
+
let target = effect?.target ? getId(effect.target) : null;
|
|
104
98
|
if (target !== null && effect.getKeyframes && effect.getTiming) {
|
|
105
99
|
if (!animation[animationId]) {
|
|
106
100
|
animation[animationId] = shortid();
|
|
107
101
|
animation[operationCount] = 0;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
|
|
103
|
+
let keyframes = effect.getKeyframes();
|
|
104
|
+
let timing = effect.getTiming();
|
|
111
105
|
track(time(), animation[animationId], AnimationOperation.Create, JSON.stringify(keyframes), JSON.stringify(timing), target);
|
|
112
106
|
}
|
|
113
107
|
|
|
114
|
-
if (animation[operationCount]++ < maxOperations)
|
|
108
|
+
if (animation[operationCount]++ < maxOperations) {
|
|
115
109
|
let operation: AnimationOperation = null;
|
|
116
110
|
switch (name) {
|
|
117
111
|
case "play":
|
|
@@ -134,6 +128,6 @@ function trackAnimationOperation(animation: Animation, name: string) {
|
|
|
134
128
|
track(time(), animation[animationId], operation);
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
|
-
}
|
|
131
|
+
}
|
|
138
132
|
}
|
|
139
133
|
}
|
package/src/layout/discover.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Priority,
|
|
1
|
+
import { Priority, Timer } from "@clarity-types/core";
|
|
2
2
|
import { Event, Metric } from "@clarity-types/data";
|
|
3
3
|
import { Source } from "@clarity-types/layout";
|
|
4
4
|
import measure from "@src/core/measure";
|
|
5
5
|
import * as task from "@src/core/task";
|
|
6
6
|
import { time } from "@src/core/time";
|
|
7
7
|
import { id } from "@src/data/metadata";
|
|
8
|
-
import * as scroll from "@src/interaction/scroll";
|
|
9
8
|
import * as doc from "@src/layout/document";
|
|
10
9
|
import encode from "@src/layout/encode";
|
|
11
10
|
import * as region from "@src/layout/region";
|
|
12
|
-
import { checkDocumentStyles } from "@src/layout/style";
|
|
13
11
|
import traverse from "@src/layout/traverse";
|
|
12
|
+
import { checkDocumentStyles } from "@src/layout/style";
|
|
13
|
+
import * as scroll from "@src/interaction/scroll";
|
|
14
14
|
|
|
15
15
|
export function start(): void {
|
|
16
16
|
task.schedule(discover, Priority.High).then((): void => {
|
|
@@ -21,8 +21,8 @@ export function start(): void {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function discover(): Promise<void> {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let ts = time();
|
|
25
|
+
let timer: Timer = { id: id(), cost: Metric.LayoutCost };
|
|
26
26
|
task.start(timer);
|
|
27
27
|
await traverse(document, timer, Source.Discover, ts);
|
|
28
28
|
checkDocumentStyles(document, ts);
|
package/src/layout/document.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Event } from "@clarity-types/data";
|
|
2
|
-
import
|
|
2
|
+
import { DocumentData } from "@clarity-types/layout";
|
|
3
3
|
import { FunctionNames } from "@clarity-types/performance";
|
|
4
4
|
import encode from "@src/layout/encode";
|
|
5
5
|
|
|
@@ -16,37 +16,25 @@ export function start(): void {
|
|
|
16
16
|
|
|
17
17
|
export function compute(): void {
|
|
18
18
|
compute.dn = FunctionNames.DocumentCompute;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
bodyScrollWidth,
|
|
30
|
-
bodyOffsetWidth,
|
|
31
|
-
documentClientWidth,
|
|
32
|
-
documentScrollWidth,
|
|
33
|
-
documentOffsetWidth,
|
|
34
|
-
);
|
|
19
|
+
let body = document.body;
|
|
20
|
+
let d = document.documentElement;
|
|
21
|
+
let bodyClientWidth = body ? body.clientWidth : null;
|
|
22
|
+
let bodyScrollWidth = body ? body.scrollWidth : null;
|
|
23
|
+
let bodyOffsetWidth = body ? body.offsetWidth : null;
|
|
24
|
+
let documentClientWidth = d ? d.clientWidth : null;
|
|
25
|
+
let documentScrollWidth = d ? d.scrollWidth : null;
|
|
26
|
+
let documentOffsetWidth = d ? d.offsetWidth : null;
|
|
27
|
+
let width = Math.max(bodyClientWidth, bodyScrollWidth, bodyOffsetWidth,
|
|
28
|
+
documentClientWidth, documentScrollWidth, documentOffsetWidth);
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
bodyScrollHeight,
|
|
45
|
-
bodyOffsetHeight,
|
|
46
|
-
documentClientHeight,
|
|
47
|
-
documentScrollHeight,
|
|
48
|
-
documentOffsetHeight,
|
|
49
|
-
);
|
|
30
|
+
let bodyClientHeight = body ? body.clientHeight : null;
|
|
31
|
+
let bodyScrollHeight = body ? body.scrollHeight : null;
|
|
32
|
+
let bodyOffsetHeight = body ? body.offsetHeight : null;
|
|
33
|
+
let documentClientHeight = d ? d.clientHeight : null;
|
|
34
|
+
let documentScrollHeight = d ? d.scrollHeight : null;
|
|
35
|
+
let documentOffsetHeight = d ? d.offsetHeight : null;
|
|
36
|
+
let height = Math.max(bodyClientHeight, bodyScrollHeight, bodyOffsetHeight,
|
|
37
|
+
documentClientHeight, documentScrollHeight, documentOffsetHeight);
|
|
50
38
|
|
|
51
39
|
// Check that width or height has changed from before, and also that width & height are not null values
|
|
52
40
|
if ((data === null || width !== data.width || height !== data.height) && width !== null && height !== null) {
|