@gemx-dev/clarity-visualize 0.8.56 → 0.8.57
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 -2
- package/src/custom/canvas-layer.ts +6 -3
- package/src/heatmap.ts +4 -4
- package/src/visualizer.ts +2 -2
- package/types/visualize.d.ts +2 -2
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.57",
|
|
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.57"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
@@ -28,12 +28,14 @@ export interface ParentCanvasInfo {
|
|
|
28
28
|
*/
|
|
29
29
|
export function createParentWindowCanvas(
|
|
30
30
|
iframeDoc: Document,
|
|
31
|
+
portalCanvasId: string
|
|
31
32
|
): ParentCanvasInfo | null {
|
|
32
33
|
// Check if we're inside an iframe
|
|
33
34
|
if (iframeDoc.defaultView === iframeDoc.defaultView?.top) {
|
|
34
35
|
throw new Error('Not in iframe: ' + iframeDoc.defaultView);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
|
|
38
|
+
|
|
37
39
|
try {
|
|
38
40
|
const parentWindow = iframeDoc.defaultView?.parent;
|
|
39
41
|
const parentDoc = parentWindow?.document;
|
|
@@ -47,10 +49,11 @@ export function createParentWindowCanvas(
|
|
|
47
49
|
if (!iframeParent) throw new Error('Iframe parent not found');
|
|
48
50
|
|
|
49
51
|
// Create canvas as sibling to iframe
|
|
50
|
-
|
|
52
|
+
const canvasId = `${Constant.HeatmapCanvas}-${portalCanvasId}`;
|
|
53
|
+
let canvas = parentDoc.getElementById(canvasId) as HTMLCanvasElement;
|
|
51
54
|
if (canvas === null) {
|
|
52
55
|
canvas = parentDoc.createElement('canvas');
|
|
53
|
-
canvas.id =
|
|
56
|
+
canvas.id = canvasId;
|
|
54
57
|
canvas.width = 0;
|
|
55
58
|
canvas.height = 0;
|
|
56
59
|
canvas.style.position = Constant.Absolute;
|
package/src/heatmap.ts
CHANGED
|
@@ -191,7 +191,7 @@ export class HeatmapHelper {
|
|
|
191
191
|
let win = this.state.window;
|
|
192
192
|
let de = doc.documentElement;
|
|
193
193
|
|
|
194
|
-
const isPortalCanvas = this.state.options.
|
|
194
|
+
const isPortalCanvas = !!this.state.options.portalCanvasId;
|
|
195
195
|
if (isPortalCanvas) return this.createPortalCanvas(doc, win, de);
|
|
196
196
|
|
|
197
197
|
let canvas = doc.getElementById(Constant.HeatmapCanvas) as HTMLCanvasElement;
|
|
@@ -328,7 +328,7 @@ export class HeatmapHelper {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
private waitForDialogs = async (): Promise<void> => {
|
|
331
|
-
const isPortalCanvas = this.state.options.
|
|
331
|
+
const isPortalCanvas = !!this.state.options.portalCanvasId;
|
|
332
332
|
if (!isPortalCanvas) return ;
|
|
333
333
|
|
|
334
334
|
await dialogCustom.waitForDialogsRendered();
|
|
@@ -340,7 +340,7 @@ export class HeatmapHelper {
|
|
|
340
340
|
try {
|
|
341
341
|
canvas = this.parentCanvasInfo?.canvas;
|
|
342
342
|
if (!canvas) {
|
|
343
|
-
this.parentCanvasInfo = canvasLayer.createParentWindowCanvas(doc);
|
|
343
|
+
this.parentCanvasInfo = canvasLayer.createParentWindowCanvas(doc, this.state.options.portalCanvasId);
|
|
344
344
|
canvas = this.parentCanvasInfo.canvas;
|
|
345
345
|
|
|
346
346
|
// Add event listeners only once when canvas is created
|
|
@@ -352,7 +352,7 @@ export class HeatmapHelper {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
canvas.width = de.clientWidth;
|
|
355
|
-
canvas.height = de.clientHeight
|
|
355
|
+
canvas.height = de.clientHeight; // TODO: GEMX VERIFY
|
|
356
356
|
canvas.style.top = '0';
|
|
357
357
|
canvas.style.left = '0';
|
|
358
358
|
canvas.getContext(Constant.Context).clearRect(0, 0, canvas.width, canvas.height);
|
package/src/visualizer.ts
CHANGED
|
@@ -53,12 +53,12 @@ export class Visualizer implements VisualizerType {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
public html = async (decoded: DecodedData.DecodedPayload[], target: Window,
|
|
56
|
+
public html = async (decoded: DecodedData.DecodedPayload[], target: Window, portalCanvasId?: string, hash: string = null, useproxy?: LinkHandler, logerror?: ErrorLogger, shortCircuitStrategy: ShortCircuitStrategy = ShortCircuitStrategy.None): Promise<Visualizer> => {
|
|
57
57
|
if (decoded && decoded.length > 0 && target) {
|
|
58
58
|
try {
|
|
59
59
|
// Flatten the payload and parse all events out of them, sorted by time
|
|
60
60
|
let merged = this.merge(decoded);
|
|
61
|
-
await this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy,
|
|
61
|
+
await this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy, portalCanvasId });
|
|
62
62
|
// Render all mutations on top of the initial markup
|
|
63
63
|
while (merged.events.length > 0) {
|
|
64
64
|
let entry = merged.events.shift();
|
package/types/visualize.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface Visualize {
|
|
|
20
20
|
export class Visualizer {
|
|
21
21
|
readonly state: PlaybackState;
|
|
22
22
|
dom: (event: Layout.DomEvent) => Promise<void>;
|
|
23
|
-
html: (decoded: Data.DecodedPayload[], target: Window,
|
|
23
|
+
html: (decoded: Data.DecodedPayload[], target: Window, portalCanvasId?: string, hash?: string, useproxy?: LinkHandler, logerror?: ErrorLogger, shortCircuitStrategy?: ShortCircuitStrategy) => Promise<Visualizer>;
|
|
24
24
|
clickmap: (activity?: Activity) => void;
|
|
25
25
|
clearmap: () => void;
|
|
26
26
|
scrollmap: (data?: ScrollMapInfo[], averageFold?: number, addMarkers?: boolean) => void;
|
|
@@ -65,7 +65,7 @@ export interface Options {
|
|
|
65
65
|
metadata?: HTMLElement;
|
|
66
66
|
pointer?: boolean;
|
|
67
67
|
canvas?: boolean;
|
|
68
|
-
|
|
68
|
+
portalCanvasId?: string;
|
|
69
69
|
keyframes?: boolean;
|
|
70
70
|
mobile?: boolean;
|
|
71
71
|
vNext?: boolean;
|