@gemx-dev/clarity-visualize 0.8.46 → 0.8.47
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 +2 -3
- package/src/heatmap.ts +9 -8
- package/src/layout.ts +25 -1
- package/tsconfig.json +1 -10
- package/types/visualize.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemx-dev/clarity-visualize",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.47",
|
|
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.
|
|
12
|
+
"@gemx-dev/clarity-decode": "^0.8.47"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"husky": "^8.0.0",
|
|
22
22
|
"lint-staged": "^13.1.0",
|
|
23
23
|
"rollup": "^3.0.0",
|
|
24
|
-
"ts-node": "^10.1.0",
|
|
25
24
|
"tslint": "^6.1.3",
|
|
26
25
|
"typescript": "^4.3.5"
|
|
27
26
|
},
|
package/src/heatmap.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class HeatmapHelper {
|
|
|
20
20
|
this.state = state;
|
|
21
21
|
this.layout = layout;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
public reset = (): void => {
|
|
25
25
|
this.data = null;
|
|
26
26
|
this.scrollData = null;
|
|
@@ -43,7 +43,7 @@ export class HeatmapHelper {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
public clear = (): void => {
|
|
46
|
+
public clear = () : void => {
|
|
47
47
|
let doc = this.state.window.document;
|
|
48
48
|
let win = this.state.window;
|
|
49
49
|
let canvas = doc.getElementById(Constant.HeatmapCanvas) as HTMLCanvasElement;
|
|
@@ -68,8 +68,8 @@ export class HeatmapHelper {
|
|
|
68
68
|
let doc = this.state.window.document;
|
|
69
69
|
var body = doc.body;
|
|
70
70
|
var de = doc.documentElement;
|
|
71
|
-
var height = Math.max(body.scrollHeight, body.offsetHeight,
|
|
72
|
-
de.clientHeight, de.scrollHeight, de.offsetHeight);
|
|
71
|
+
var height = Math.max( body.scrollHeight, body.offsetHeight,
|
|
72
|
+
de.clientHeight, de.scrollHeight, de.offsetHeight );
|
|
73
73
|
canvas.height = Math.min(height, Setting.ScrollCanvasMaxHeight);
|
|
74
74
|
canvas.style.top = 0 + Constant.Pixel;
|
|
75
75
|
if (canvas.width > 0 && canvas.height > 0) {
|
|
@@ -148,7 +148,7 @@ export class HeatmapHelper {
|
|
|
148
148
|
// For each pixel, we have 4 entries in data array: (r,g,b,a)
|
|
149
149
|
// To pick the right color from gradient pixels, we look at the alpha value of the pixel
|
|
150
150
|
// Alpha value ranges from 0-255
|
|
151
|
-
let alpha = pixels.data[i
|
|
151
|
+
let alpha = pixels.data[i+3];
|
|
152
152
|
if (alpha > 0) {
|
|
153
153
|
let offset = (alpha - 1) * 4;
|
|
154
154
|
pixels.data[i] = gradient.data[offset];
|
|
@@ -177,7 +177,7 @@ export class HeatmapHelper {
|
|
|
177
177
|
win.addEventListener("scroll", this.redraw, true);
|
|
178
178
|
win.addEventListener("resize", this.redraw, true);
|
|
179
179
|
this.observer = this.state.window["ResizeObserver"] ? new ResizeObserver(this.redraw) : null;
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
if (this.observer) { this.observer.observe(doc.body); }
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -253,7 +253,7 @@ export class HeatmapHelper {
|
|
|
253
253
|
let v = this.visible(el, r, height);
|
|
254
254
|
// Process clicks for only visible elements
|
|
255
255
|
if (this.max === null || v) {
|
|
256
|
-
for
|
|
256
|
+
for(let i = 0; i < element.points; i++) {
|
|
257
257
|
let x = Math.round(r.left + (element.x[i] / Data.Setting.ClickPrecision) * r.width);
|
|
258
258
|
let y = Math.round(r.top + (element.y[i] / Data.Setting.ClickPrecision) * r.height);
|
|
259
259
|
let k = `${x}${Constant.Separator}${y}${Constant.Separator}${v ? 1 : 0}`;
|
|
@@ -281,7 +281,8 @@ export class HeatmapHelper {
|
|
|
281
281
|
let doc: Document | ShadowRoot = this.state.window.document;
|
|
282
282
|
let visibility = r.height > height ? true : false;
|
|
283
283
|
if (visibility === false && r.width > 0 && r.height > 0) {
|
|
284
|
-
while (!visibility && doc)
|
|
284
|
+
while (!visibility && doc)
|
|
285
|
+
{
|
|
285
286
|
let shadowElement = null;
|
|
286
287
|
let elements = doc.elementsFromPoint(r.left + (r.width / 2), r.top + (r.height / 2));
|
|
287
288
|
for (let e of elements) {
|
package/src/layout.ts
CHANGED
|
@@ -452,6 +452,13 @@ export class LayoutHelper {
|
|
|
452
452
|
this.setAttributes(iframeElement, node);
|
|
453
453
|
insert(node, parent, iframeElement, pivot);
|
|
454
454
|
break;
|
|
455
|
+
case "SCRIPT":
|
|
456
|
+
{
|
|
457
|
+
node.id = -1; // We want to ensure children of script tags are not processed
|
|
458
|
+
node.value = null; // We don't want to set any potential script content
|
|
459
|
+
this.insertDefaultElement(node, parent, pivot, doc, insert);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
455
462
|
default:
|
|
456
463
|
this.insertDefaultElement(node, parent, pivot, doc, insert);
|
|
457
464
|
break;
|
|
@@ -634,7 +641,7 @@ export class LayoutHelper {
|
|
|
634
641
|
node.setAttribute(Constant.Hide, size);
|
|
635
642
|
}
|
|
636
643
|
} else {
|
|
637
|
-
node.setAttribute(attribute, v);
|
|
644
|
+
node.setAttribute(attribute, this.isSuspiciousAttribute(attribute, v) ? Constant.Empty : v);
|
|
638
645
|
}
|
|
639
646
|
} catch (ex) {
|
|
640
647
|
console.warn("Node: " + node + " | " + JSON.stringify(attributes));
|
|
@@ -663,6 +670,23 @@ export class LayoutHelper {
|
|
|
663
670
|
}
|
|
664
671
|
}
|
|
665
672
|
|
|
673
|
+
private isSuspiciousAttribute(name: string, value: string): boolean {
|
|
674
|
+
// Block event handlers entirely
|
|
675
|
+
if (name.startsWith('on')) {
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Check for JavaScript protocols and dangerous patterns
|
|
680
|
+
const dangerous = [
|
|
681
|
+
/^\s*javascript:/i,
|
|
682
|
+
/^\s*data:text\/html/i,
|
|
683
|
+
/^\s*vbscript:/i
|
|
684
|
+
];
|
|
685
|
+
|
|
686
|
+
return dangerous.some(pattern => pattern.test(value));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
666
690
|
private getMobileCustomStyle = (): string => {
|
|
667
691
|
if(this.isMobile){
|
|
668
692
|
return `*{scrollbar-width: none; scrollbar-gutter: unset;};`
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"module": "esnext",
|
|
4
|
-
"target": "es6",
|
|
5
|
-
"lib": ["es6", "dom", "es2016", "es2017"],
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"noImplicitReturns": true,
|
|
9
|
-
"noUnusedLocals": true,
|
|
10
|
-
"noUnusedParameters": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
4
|
"baseUrl": ".",
|
|
14
5
|
"paths": {
|
|
15
6
|
"@src/*": ["src/*"],
|
package/types/visualize.d.ts
CHANGED
|
@@ -199,7 +199,7 @@ export const enum Constant {
|
|
|
199
199
|
NewPassword = "new-password",
|
|
200
200
|
StyleSheet = "stylesheet",
|
|
201
201
|
OriginalBackgroundColor = "data-clarity-background-color",
|
|
202
|
-
OriginalOpacity = "data-clarity-opacity"
|
|
202
|
+
OriginalOpacity = "data-clarity-opacity",
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
export const enum Setting {
|