clarity-js 0.7.58 → 0.7.59

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.
@@ -1,5 +1,6 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { SubmitState } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
3
4
  import { bind } from "@src/core/event";
4
5
  import { schedule } from "@src/core/task";
5
6
  import { time } from "@src/core/time";
@@ -20,6 +21,7 @@ function recompute(evt: UIEvent): void {
20
21
  state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
21
22
  schedule(encode.bind(this, Event.Submit));
22
23
  }
24
+ recompute.dn = FunctionNames.SubmitRecompute;
23
25
 
24
26
  export function reset(): void {
25
27
  state = [];
@@ -1,5 +1,6 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { UnloadData } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
3
4
  import * as clarity from "@src/clarity";
4
5
  import { bind } from "@src/core/event";
5
6
  import { time } from "@src/core/time";
@@ -16,6 +17,7 @@ function recompute(evt: UIEvent): void {
16
17
  encode(Event.Unload, time(evt));
17
18
  clarity.stop();
18
19
  }
20
+ recompute.dn = FunctionNames.UnloadRecompute;
19
21
 
20
22
  export function reset(): void {
21
23
  data = null;
@@ -1,5 +1,6 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { VisibilityData } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
3
4
  import { bind } from "@src/core/event";
4
5
  import { time } from "@src/core/time";
5
6
  import encode from "./encode";
@@ -15,6 +16,7 @@ function recompute(evt: UIEvent = null): void {
15
16
  data = { visible: "visibilityState" in document ? document.visibilityState : "default" };
16
17
  encode(Event.Visibility, time(evt));
17
18
  }
19
+ recompute.dn = FunctionNames.VisibilityRecompute;
18
20
 
19
21
  export function reset(): void {
20
22
  data = null;
@@ -1,5 +1,6 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { DocumentData } from "@clarity-types/layout";
3
+ import { FunctionNames } from "@clarity-types/performance";
3
4
  import encode from "@src/layout/encode";
4
5
 
5
6
  export let data: DocumentData;
@@ -40,6 +41,7 @@ export function compute(): void {
40
41
  encode(Event.Document);
41
42
  }
42
43
  }
44
+ compute.dn = FunctionNames.DocumentCompute;
43
45
 
44
46
  export function stop(): void {
45
47
  reset();
@@ -1,3 +1,4 @@
1
+ import { FunctionNames } from "@clarity-types/performance";
1
2
  import * as discover from "@src/layout/discover";
2
3
  import * as doc from "@src/layout/document";
3
4
  import * as dom from "@src/layout/dom";
@@ -28,6 +29,7 @@ export function start(): void {
28
29
  style.start();
29
30
  animation.start();
30
31
  }
32
+ start.dn = FunctionNames.LayoutStart;
31
33
 
32
34
  export function stop(): void {
33
35
  region.stop();
@@ -1,6 +1,7 @@
1
1
  import { Priority, Task, Timer } from "@clarity-types/core";
2
2
  import { Code, Event, Metric, Severity } from "@clarity-types/data";
3
3
  import { Constant, MutationHistory, MutationRecordWithTime, MutationQueue, Setting, Source } from "@clarity-types/layout";
4
+ import { FunctionNames } from "@clarity-types/performance";
4
5
  import api from "@src/core/api";
5
6
  import * as core from "@src/core";
6
7
  import { bind } from "@src/core/event";
@@ -89,6 +90,7 @@ export function start(): void {
89
90
  } catch { attachShadow = null; }
90
91
  }
91
92
  }
93
+ start.dn = FunctionNames.MutationStart;
92
94
 
93
95
  export function observe(node: Node): void {
94
96
  // Create a new observer for every time a new DOM tree (e.g. root document or shadowdom root) is discovered on the page
@@ -139,6 +141,7 @@ function handle(m: MutationRecord[]): void {
139
141
  measure(region.compute)();
140
142
  });
141
143
  }
144
+ handle.dn = FunctionNames.MutationHandle;
142
145
 
143
146
  async function processMutation(timer: Timer, mutation: MutationRecord, instance: number, timestamp: number): Promise<void> {
144
147
  let state = task.state(timer);
@@ -299,3 +302,4 @@ function generate(target: Node, type: MutationRecordType): void {
299
302
  type
300
303
  }]);
301
304
  }
305
+ generate.dn = FunctionNames.MutationGenerate;
@@ -1,5 +1,6 @@
1
1
  import { Event, Setting } from "@clarity-types/data";
2
2
  import { InteractionState, RegionData, RegionState, RegionQueue, RegionVisibility } from "@clarity-types/layout";
3
+ import { FunctionNames } from "@clarity-types/performance";
3
4
  import { time } from "@src/core/time";
4
5
  import * as dom from "@src/layout/dom";
5
6
  import encode from "@src/layout/encode";
@@ -76,6 +77,7 @@ export function compute(): void {
76
77
  // Schedule encode only when we have at least one valid data entry
77
78
  if (state.length > 0) { encode(Event.Region); }
78
79
  }
80
+ compute.dn = FunctionNames.RegionCompute;
79
81
 
80
82
  function handler(entries: IntersectionObserverEntry[]): void {
81
83
  for (let entry of entries) {
@@ -1,3 +1,4 @@
1
+ import { FunctionNames } from "@clarity-types/performance";
1
2
  import * as navigation from "@src/performance/navigation";
2
3
  import * as observer from "@src/performance/observer";
3
4
 
@@ -5,6 +6,7 @@ export function start(): void {
5
6
  navigation.reset();
6
7
  observer.start();
7
8
  }
9
+ start.dn = FunctionNames.PerformanceStart;
8
10
 
9
11
  export function stop(): void {
10
12
  observer.stop();
@@ -1,4 +1,5 @@
1
1
  import { Code, Constant, Dimension, Metric, Severity, PerformanceEventTiming } from "@clarity-types/data";
2
+ import { FunctionNames } from "@clarity-types/performance";
2
3
  import config from "@src/core/config";
3
4
  import { bind } from "@src/core/event";
4
5
  import measure from "@src/core/measure";
@@ -49,10 +50,12 @@ function observe(): void {
49
50
  }
50
51
  } catch { internal.log(Code.PerformanceObserver, Severity.Warning); }
51
52
  }
53
+ observe.dn = FunctionNames.ObserverObserve;
52
54
 
53
55
  function handle(entries: PerformanceObserverEntryList): void {
54
56
  process(entries.getEntries());
55
57
  }
58
+ handle.dn = FunctionNames.ObserverHandle;
56
59
 
57
60
  function process(entries: PerformanceEntryList): void {
58
61
  let visible = "visibilityState" in document ? document.visibilityState === "visible" : true;
package/types/data.d.ts CHANGED
@@ -194,7 +194,8 @@ export const enum Code {
194
194
  * @deprecated No longer support ContentSecurityPolicy
195
195
  */
196
196
  ContentSecurityPolicy = 7,
197
- Config = 8
197
+ Config = 8,
198
+ FunctionExecutionTime = 9
198
199
  }
199
200
 
200
201
  export const enum Severity {
@@ -31,3 +31,35 @@ export interface NavigationData {
31
31
  encodedSize: number;
32
32
  decodedSize: number;
33
33
  }
34
+
35
+ export const enum FunctionNames {
36
+ HistoryCompute = 1,
37
+ Restart = 2,
38
+ DiagnosticStart = 3,
39
+ ScriptHandler = 4,
40
+ ChangeRecompute = 5,
41
+ ClickHandler = 6,
42
+ ClipboardRecompute = 7,
43
+ InteractionStart = 8,
44
+ InputRecompute = 9,
45
+ PointerMouse = 10,
46
+ PointerTouch = 11,
47
+ ResizeRecompute = 12,
48
+ ScrollRecompute = 13,
49
+ ScrollCompute = 14,
50
+ SelectionRecompute = 15,
51
+ SubmitRecompute = 16,
52
+ UnloadRecompute = 17,
53
+ VisibilityRecompute = 18,
54
+ DocumentCompute = 19,
55
+ LayoutStart = 20,
56
+ MutationStart = 21,
57
+ MutationHandle = 22,
58
+ MutationGenerate = 23,
59
+ RegionCompute = 24,
60
+ PerformanceStart = 25,
61
+ ObserverObserve = 26,
62
+ ObserverHandle = 27
63
+ }
64
+
65
+ declare global { interface Function { dn?: FunctionNames; } }