@gemx-dev/clarity-visualize 0.8.44 → 0.8.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemx-dev/clarity-visualize",
3
- "version": "0.8.44",
3
+ "version": "0.8.45",
4
4
  "description": "Clarity visualize",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "unpkg": "build/clarity.visualize.min.js",
10
10
  "types": "types/index.d.ts",
11
11
  "dependencies": {
12
- "@gemx-dev/clarity-decode": "^0.8.39"
12
+ "@gemx-dev/clarity-decode": "^0.8.45"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@rollup/plugin-commonjs": "^24.0.0",
package/src/data.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Data, Layout } from "clarity-js";
2
- import type { Data as DecodedData, Layout as DecodedLayout } from "clarity-decode";
1
+ import { Data, Layout } from "@gemx-dev/clarity-js";
2
+ import type { Data as DecodedData, Layout as DecodedLayout } from "@gemx-dev/clarity-decode";
3
3
  import { PlaybackState, RegionState } from "@clarity-types/visualize";
4
4
 
5
5
  export class DataHelper {
@@ -34,17 +34,17 @@ export class DataHelper {
34
34
  }
35
35
 
36
36
  public metric = (event: DecodedData.MetricEvent): void => {
37
- if (this.state.options.metadata) {
37
+ if (this.state.options.metadata) {
38
38
  let metricMarkup = [];
39
39
  let regionMarkup = [];
40
40
  // Copy over metrics for future reference
41
41
  for (let m in event.data) {
42
- const eventType = typeof event.data[m];
42
+ const eventType = typeof event.data[m];
43
43
  if (eventType === "number" || (event.event === Data.Event.Dimension && m === Data.Dimension.InteractionNextPaint.toString())) {
44
44
  if (!(m in this.metrics)) { this.metrics[m] = 0; }
45
45
  let key = parseInt(m, 10);
46
46
  let value = eventType === "object" ? Number(event.data[m]?.[0]) : event.data[m];
47
- if (m in DataHelper.METRIC_MAP && (DataHelper.METRIC_MAP[m].unit === "html-price" ||DataHelper.METRIC_MAP[m].unit === "ld-price")) {
47
+ if (m in DataHelper.METRIC_MAP && (DataHelper.METRIC_MAP[m].unit === "html-price" ||DataHelper.METRIC_MAP[m].unit === "ld-price")) {
48
48
  this.metrics[m] = value;
49
49
  } else { this.metrics[m] += value; }
50
50
  this.lean = key === Data.Metric.Playback && value === 0 ? true : this.lean;
@@ -74,7 +74,7 @@ export class DataHelper {
74
74
  public region(event: DecodedLayout.RegionEvent): void {
75
75
  let data = event.data;
76
76
  for (let r of data) {
77
- if (!(r.name in this.regions)) {
77
+ if (!(r.name in this.regions)) {
78
78
  this.regions[r.name] = { interaction: r.interaction , visibility: r.visibility }
79
79
  }
80
80
  this.regionMap[r.id] = r.name;
@@ -83,8 +83,8 @@ export class DataHelper {
83
83
 
84
84
  private key = (unit: string): string => {
85
85
  switch (unit) {
86
- case "html-price":
87
- case "ld-price":
86
+ case "html-price":
87
+ case "ld-price":
88
88
  case "cls":
89
89
  return Data.Constant.Empty;
90
90
  default: return unit;
package/src/enrich.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { helper, Layout } from "clarity-js";
2
- import { Layout as DecodedLayout } from "clarity-decode";
1
+ import { helper, Layout } from "@gemx-dev/clarity-js";
2
+ import { Layout as DecodedLayout } from "@gemx-dev/clarity-decode";
3
3
  import { NodeData } from "@clarity-types/visualize";
4
4
 
5
5
  export class EnrichHelper {
6
-
6
+
7
7
  children: { [key: number]: number[] };
8
8
  nodes: { [key: number]: NodeData };
9
-
9
+
10
10
  constructor() {
11
11
  this.reset();
12
12
  }
@@ -51,7 +51,7 @@ export class EnrichHelper {
51
51
  let selectorAlpha = helper.selector.get(input, Layout.Selector.Alpha);
52
52
  d.selectorAlpha = selectorAlpha.length > 0 ? selectorAlpha : null;
53
53
  d.hashAlpha = selectorAlpha.length > 0 ? helper.hash(d.selectorAlpha) : null;
54
-
54
+
55
55
  // Get beta selector
56
56
  let selectorBeta = helper.selector.get(input, Layout.Selector.Beta);
57
57
  d.selectorBeta = selectorBeta.length > 0 ? selectorBeta : null;
@@ -61,11 +61,11 @@ export class EnrichHelper {
61
61
  node.alpha = selectorAlpha;
62
62
  node.beta = selectorBeta;
63
63
  this.nodes[d.id] = node;
64
- if (d.parent) { this.children[d.parent] = children; }
64
+ if (d.parent) { this.children[d.parent] = children; }
65
65
  });
66
66
  return event;
67
67
  }
68
-
68
+
69
69
  private position = (id: number, tag: string, child: NodeData, children: number[], siblings: NodeData[]): number => {
70
70
  child.position = 1;
71
71
  let idx = children ? children.indexOf(id) : -1;
package/src/heatmap.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Activity, Constant, Heatmap, Setting, ScrollMapInfo, PlaybackState } from "@clarity-types/visualize";
2
- import { Data } from "clarity-js";
2
+ import { Data } from "@gemx-dev/clarity-js";
3
3
  import { LayoutHelper } from "./layout";
4
4
 
5
5
  export class HeatmapHelper {
@@ -1,11 +1,11 @@
1
1
  import { Asset, Constant, PlaybackState, Point, Setting } from "@clarity-types/visualize";
2
- import { Data, Layout } from "clarity-js";
3
- import type { Interaction } from "clarity-decode"
2
+ import { Data, Layout } from "@gemx-dev/clarity-js";
3
+ import type { Interaction } from "@gemx-dev/clarity-decode"
4
4
  import { LayoutHelper } from "./layout";
5
5
  import pointerSvg from "./styles/pointer/pointerIcon.svg";
6
6
  import clickStyle from "./styles/pointer/click.css";
7
- import { BooleanFlag } from "clarity-decode/types/data";
8
- import { ClickVizualizationData } from "clarity-decode/types/interaction";
7
+ import { BooleanFlag } from "@gemx-dev/clarity-decode/types/data";
8
+ import { ClickVizualizationData } from "@gemx-dev/clarity-decode/types/interaction";
9
9
 
10
10
  export class InteractionHelper {
11
11
  static TRAIL_START_COLOR = [242, 97, 12]; // rgb(242,97,12)
@@ -54,8 +54,8 @@ export class InteractionHelper {
54
54
 
55
55
  // Position canvas relative to scroll events on the parent page
56
56
  if (scrollTarget === de || scrollTarget === doc.body) {
57
- if (!scrollable) {
58
- this.state.window.scrollTo(data.x, data.y);
57
+ if (!scrollable) {
58
+ this.state.window.scrollTo(data.x, data.y);
59
59
  }
60
60
  let canvas = this.overlay();
61
61
  if (canvas) {
@@ -195,11 +195,11 @@ export class InteractionHelper {
195
195
  this.state.options.onclickMismatch({
196
196
  time: event.time,
197
197
  x: data.x,
198
- y: data.y,
198
+ y: data.y,
199
199
  nodeId: data.target as number});
200
200
  }
201
201
  }
202
-
202
+
203
203
  p.className = Constant.PointerNone;
204
204
  break;
205
205
  case Data.Event.DoubleClick:
@@ -251,7 +251,7 @@ export class InteractionHelper {
251
251
  this.fadeOutElement(click.click, click.doc);
252
252
  this.visualizedClicks.splice(this.visualizedClicks.indexOf(click), 1);
253
253
  });
254
- }
254
+ }
255
255
  }
256
256
 
257
257
  private fadeOutElement = (element: HTMLElement, document: HTMLElement): void => {
@@ -316,7 +316,7 @@ export class InteractionHelper {
316
316
  let de = doc.documentElement;
317
317
  let click = doc.createElement("DIV");
318
318
  click.className = Constant.ClickLayer;
319
-
319
+
320
320
  click.setAttribute(Constant.Title, `${title} (${x}${Constant.Pixel}, ${y}${Constant.Pixel})`);
321
321
  click.style.left = (x - Setting.ClickRadius / 2) + Constant.Pixel;
322
322
  click.style.top = (y - Setting.ClickRadius / 2) + Constant.Pixel
@@ -334,18 +334,18 @@ export class InteractionHelper {
334
334
  let center = doc.createElement("DIV");
335
335
  center.className = `${Constant.ClickLayer}-center`;
336
336
  click.appendChild(center);
337
- } else {
337
+ } else {
338
338
  // Second pulsating ring
339
339
  let ringTwo = ringOne.cloneNode() as HTMLElement;
340
340
  ringTwo.style.animation = "pulsate-two 1 1s";
341
341
  click.appendChild(ringTwo);
342
342
  }
343
343
  de.appendChild(click);
344
-
344
+
345
345
  // Play sound
346
346
  if (typeof Audio !== Constant.Undefined) {
347
- if (this.clickAudio === null) {
348
- this.clickAudio = new Audio(Asset.Sound);
347
+ if (this.clickAudio === null) {
348
+ this.clickAudio = new Audio(Asset.Sound);
349
349
  click.appendChild(this.clickAudio);
350
350
  }
351
351
  this.clickAudio.play();
@@ -504,7 +504,7 @@ export class InteractionHelper {
504
504
  return clickStyle;
505
505
  } else {
506
506
  return `.${Constant.ClickLayer}, .${Constant.ClickRing}, .${Constant.TouchLayer}, .${Constant.TouchRing} { position: absolute; z-index: ${Setting.ZIndex}; border-radius: 50%; background: radial-gradient(rgba(0,90,158,0.8), transparent); width: ${Setting.ClickRadius}px; height: ${Setting.ClickRadius}px;}` +
507
- `.${Constant.ClickRing} { background: transparent; border: 1px solid rgba(0,90,158,0.8); }`;
507
+ `.${Constant.ClickRing} { background: transparent; border: 1px solid rgba(0,90,158,0.8); }`;
508
508
  }
509
509
  }
510
510
  }
package/src/layout.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Data, Layout } from "clarity-js";
2
- import type { Layout as DecodedLayout } from "clarity-decode";
1
+ import { Data, Layout } from "@gemx-dev/clarity-js";
2
+ import type { Layout as DecodedLayout } from "@gemx-dev/clarity-decode";
3
3
  import { Asset, Constant, type LinkHandler, NodeType, type PlaybackState, Setting } from "@clarity-types/visualize";
4
- import { StyleSheetOperation } from "clarity-js/types/layout";
5
- import { AnimationOperation } from "clarity-js/types/layout";
6
- import { Constant as LayoutConstants } from "clarity-js/types/layout";
4
+ import { StyleSheetOperation } from "@gemx-dev/clarity-js/types/layout";
5
+ import { AnimationOperation } from "@gemx-dev/clarity-js/types/layout";
6
+ import { Constant as LayoutConstants } from "@gemx-dev/clarity-js/types/layout";
7
7
  import sharedStyle from "./styles/shared.css";
8
8
 
9
9
  /* BEGIN blobUnavailableSvgs */
@@ -418,13 +418,13 @@ export class LayoutHelper {
418
418
  }));
419
419
  } else if ((node.attributes["rel"].includes("preload") || node.attributes["rel"].includes("preconnect"))
420
420
  && (node.attributes?.as === "style" || node.attributes?.as === "font")) {
421
- this.fonts.push(new Promise((resolve: () => void): void => {
422
- const proxy = useproxy ?? this.state.options.useproxy;
423
- linkElement.href = proxy ? proxy(linkElement.href, linkElement.id, node.attributes.as) : linkElement.href;
424
- linkElement.onload = linkElement.onerror = this.style.bind(this, linkElement, resolve);
425
- setTimeout(resolve, LayoutHelper.TIMEOUT);
426
- }));
427
- }
421
+ this.fonts.push(new Promise((resolve: () => void): void => {
422
+ const proxy = useproxy ?? this.state.options.useproxy;
423
+ linkElement.href = proxy ? proxy(linkElement.href, linkElement.id, node.attributes.as) : linkElement.href;
424
+ linkElement.onload = linkElement.onerror = this.style.bind(this, linkElement, resolve);
425
+ setTimeout(resolve, LayoutHelper.TIMEOUT);
426
+ }));
427
+ }
428
428
  }
429
429
  insert(node, parent, linkElement, pivot);
430
430
  break;
@@ -612,7 +612,7 @@ export class LayoutHelper {
612
612
  node.setAttribute(`data-clarity-${attribute}`, v);
613
613
  } else if (tag === Constant.ImageTag && attribute.indexOf("src") === 0 && ((v === null || v.length === 0 || v?.startsWith('blob:')))) {
614
614
  if (this.vNext) {
615
- if (v.startsWith('blob:')) {
615
+ if (v.startsWith('blob:')) {
616
616
  if (data.width >= Setting.LargeSvg && data.height >= Setting.LargeSvg) {
617
617
  node.setAttribute(Constant.BlobUnavailable, `${Constant.Large}${Constant.Beta}`);
618
618
  } else {
@@ -626,12 +626,12 @@ export class LayoutHelper {
626
626
  }
627
627
  }
628
628
  } else {
629
- node.setAttribute(attribute, Asset.Transparent);
630
- let size = Constant.Large;
631
- if (data.width) {
632
- size = data.width <= Setting.Medium ? Constant.Medium : (data.width <= Setting.Small ? Constant.Small : size);
633
- }
634
- node.setAttribute(Constant.Hide, size);
629
+ node.setAttribute(attribute, Asset.Transparent);
630
+ let size = Constant.Large;
631
+ if (data.width) {
632
+ size = data.width <= Setting.Medium ? Constant.Medium : (data.width <= Setting.Small ? Constant.Small : size);
633
+ }
634
+ node.setAttribute(Constant.Hide, size);
635
635
  }
636
636
  } else {
637
637
  node.setAttribute(attribute, v);
@@ -692,7 +692,7 @@ export class LayoutHelper {
692
692
  private getIframeUnavailableCss = (): string => {
693
693
  if (this.vNext) {
694
694
  return `${Constant.IFrameTag}[${Constant.UnavailableSmall}] { ${iframeUnavailableSvgSmall} }` +
695
- `${Constant.IFrameTag}[${Constant.Unavailable}] { ${iframeUnavailableSvg[this.locale]} }`;
695
+ `${Constant.IFrameTag}[${Constant.Unavailable}] { ${iframeUnavailableSvg[this.locale]} }`;
696
696
  } else {
697
697
  return `${Constant.IFrameTag}[${Constant.Unavailable}] { background: url(${Asset.Unavailable}) no-repeat center center, url('${Asset.Cross}'); }`;
698
698
  }
@@ -701,7 +701,7 @@ export class LayoutHelper {
701
701
  private getBlobUnavailableCss = (): string => {
702
702
  if (this.vNext) {
703
703
  return `${Constant.ImageTag}[${Constant.BlobUnavailable}=${Constant.Small}${Constant.Beta}] { ${blobUnavailableSvgSmall} }` +
704
- `${Constant.ImageTag}[${Constant.BlobUnavailable}=${Constant.Large}${Constant.Beta}] { ${blobUnavailableSvg[this.locale]} }`;
704
+ `${Constant.ImageTag}[${Constant.BlobUnavailable}=${Constant.Large}${Constant.Beta}] { ${blobUnavailableSvg[this.locale]} }`;
705
705
  }
706
706
  return '';
707
707
  }
@@ -709,12 +709,12 @@ export class LayoutHelper {
709
709
  private getImageHiddenCss = (): string => {
710
710
  if (this.vNext) {
711
711
  return `${Constant.ImageTag}[${Constant.Hide}=${Constant.Small}${Constant.Beta}] { ${imageMaskedSvgSmall} }` +
712
- `${Constant.ImageTag}[${Constant.Hide}=${Constant.Large}${Constant.Beta}] { ${imageMaskedSvg[this.locale]} }`;
712
+ `${Constant.ImageTag}[${Constant.Hide}=${Constant.Large}${Constant.Beta}] { ${imageMaskedSvg[this.locale]} }`;
713
713
  } else {
714
714
  return `${Constant.ImageTag}[${Constant.Hide}] { background-color: #CCC; background-image: url(${Asset.Hide}); background-repeat:no-repeat; background-position: center; }` +
715
- `${Constant.ImageTag}[${Constant.Hide}=${Constant.Small}] { background-size: 18px 18px; }` +
716
- `${Constant.ImageTag}[${Constant.Hide}=${Constant.Medium}] { background-size: 24px 24px; }` +
717
- `${Constant.ImageTag}[${Constant.Hide}=${Constant.Large}] { background-size: 36px 36px; }`;
715
+ `${Constant.ImageTag}[${Constant.Hide}=${Constant.Small}] { background-size: 18px 18px; }` +
716
+ `${Constant.ImageTag}[${Constant.Hide}=${Constant.Medium}] { background-size: 24px 24px; }` +
717
+ `${Constant.ImageTag}[${Constant.Hide}=${Constant.Large}] { background-size: 36px 36px; }`;
718
718
  }
719
719
  }
720
720
 
package/src/visualizer.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Activity, Constant, ErrorLogger, LinkHandler, MergedPayload, Options, PlaybackState, ScrollMapInfo, Setting, ShortCircuitStrategy, Visualizer as VisualizerType } from "@clarity-types/visualize";
2
- import { Data } from "clarity-js";
3
- import type { Data as DecodedData, Interaction, Layout } from "clarity-decode";
2
+ import { Data } from "@gemx-dev/clarity-js";
3
+ import type { Data as DecodedData, Interaction, Layout } from "@gemx-dev/clarity-decode";
4
4
  import { DataHelper } from "./data";
5
5
  import { EnrichHelper } from "./enrich";
6
6
  import { HeatmapHelper } from "./heatmap";
7
7
  import { InteractionHelper } from "./interaction";
8
8
  import { LayoutHelper } from "./layout";
9
- import { Dimension } from "clarity-js/types/data";
9
+ import { Dimension } from "@gemx-dev/clarity-js/types/data";
10
10
 
11
11
  export class Visualizer implements VisualizerType {
12
12
  _state: PlaybackState = null;
@@ -164,7 +164,7 @@ export class Visualizer implements VisualizerType {
164
164
  this.interaction = new InteractionHelper(this.state, this.layout, options.vNext);
165
165
 
166
166
  // If discover event was passed, render it now
167
- if (options.dom) {
167
+ if (options.dom) {
168
168
  await this.layout.dom(options.dom, options.useproxy);
169
169
  }
170
170
 
@@ -224,7 +224,7 @@ export class Visualizer implements VisualizerType {
224
224
  case Data.Event.StyleSheetAdoption:
225
225
  case Data.Event.StyleSheetUpdate:
226
226
  this.layout.styleChange(entry as Layout.StyleSheetEvent);
227
- break;
227
+ break;
228
228
  case Data.Event.Animation:
229
229
  this.layout.animateChange(entry as Layout.AnimationEvent);
230
230
  break;
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MergedPayload, ResizeHandler, Visualize, Visualizer, ShortCircuitStrategy } from "./visualize";
2
- import { Data, Diagnostic, Interaction, Layout } from "clarity-decode"
2
+ import { Data, Diagnostic, Interaction, Layout } from "@gemx-dev/clarity-decode"
3
3
 
4
4
  /**
5
5
  * @deprecated Use Visualizer instead.
@@ -1,4 +1,4 @@
1
- import { Data, Layout } from "clarity-decode";
1
+ import { Data, Layout } from "@gemx-dev/clarity-decode";
2
2
 
3
3
  /**
4
4
  * @deprecated Use Visualizer instead.
@@ -154,7 +154,7 @@ export const enum Constant {
154
154
  Region = "clarity-region",
155
155
  AdoptedStyleSheet = "clarity-adopted-style",
156
156
  CustomStyleTag = "clarity-custom-styles",
157
- Id = "data-clarity-id",
157
+ Id = "data-clarity-id",
158
158
  HashAlpha = "data-clarity-hashalpha",
159
159
  HashBeta = "data-clarity-hashbeta",
160
160
  Hide = "data-clarity-hide",
@@ -164,14 +164,14 @@ export const enum Constant {
164
164
  Suspend = "data-clarity-suspend",
165
165
  Hidden = "hidden",
166
166
  Visible = "visible",
167
- None = "none",
167
+ None = "none",
168
168
  Small = "s",
169
169
  Medium = "m",
170
170
  Large = "l",
171
171
  Beta = "b",
172
172
  Dom = "dom",
173
173
  Context = "2d",
174
- Pixel = "px",
174
+ Pixel = "px",
175
175
  Separator = "X",
176
176
  Absolute = "absolute",
177
177
  Black = "black",