@gemx-dev/clarity-visualize 0.8.56 → 0.8.58
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.
|
@@ -390,7 +390,7 @@ var EnrichHelper = /** @class */ (function () {
|
|
|
390
390
|
* @param canvasId - ID for the canvas element
|
|
391
391
|
* @returns Canvas info with cleanup function
|
|
392
392
|
*/
|
|
393
|
-
function createParentWindowCanvas(iframeDoc) {
|
|
393
|
+
function createParentWindowCanvas(iframeDoc, portalCanvasId) {
|
|
394
394
|
var _a, _b;
|
|
395
395
|
// Check if we're inside an iframe
|
|
396
396
|
if (iframeDoc.defaultView === ((_a = iframeDoc.defaultView) === null || _a === void 0 ? void 0 : _a.top)) {
|
|
@@ -409,10 +409,11 @@ function createParentWindowCanvas(iframeDoc) {
|
|
|
409
409
|
if (!iframeParent)
|
|
410
410
|
throw new Error('Iframe parent not found');
|
|
411
411
|
// Create canvas as sibling to iframe
|
|
412
|
-
var
|
|
412
|
+
var canvasId = "".concat("clarity-heatmap-canvas" /* Constant.HeatmapCanvas */, "-").concat(portalCanvasId);
|
|
413
|
+
var canvas_1 = parentDoc.getElementById(canvasId);
|
|
413
414
|
if (canvas_1 === null) {
|
|
414
415
|
canvas_1 = parentDoc.createElement('canvas');
|
|
415
|
-
canvas_1.id =
|
|
416
|
+
canvas_1.id = canvasId;
|
|
416
417
|
canvas_1.width = 0;
|
|
417
418
|
canvas_1.height = 0;
|
|
418
419
|
canvas_1.style.position = "absolute" /* Constant.Absolute */;
|
|
@@ -795,7 +796,7 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
795
796
|
var doc = _this.state.window.document;
|
|
796
797
|
var win = _this.state.window;
|
|
797
798
|
var de = doc.documentElement;
|
|
798
|
-
var isPortalCanvas = _this.state.options.
|
|
799
|
+
var isPortalCanvas = !!_this.state.options.portalCanvasId;
|
|
799
800
|
if (isPortalCanvas)
|
|
800
801
|
return _this.createPortalCanvas(doc, win, de);
|
|
801
802
|
var canvas = doc.getElementById("clarity-heatmap-canvas" /* Constant.HeatmapCanvas */);
|
|
@@ -936,7 +937,7 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
936
937
|
return __generator(this, function (_a) {
|
|
937
938
|
switch (_a.label) {
|
|
938
939
|
case 0:
|
|
939
|
-
isPortalCanvas = this.state.options.
|
|
940
|
+
isPortalCanvas = !!this.state.options.portalCanvasId;
|
|
940
941
|
if (!isPortalCanvas)
|
|
941
942
|
return [2 /*return*/];
|
|
942
943
|
return [4 /*yield*/, waitForDialogsRendered()];
|
|
@@ -952,7 +953,7 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
952
953
|
try {
|
|
953
954
|
canvas = (_a = _this.parentCanvasInfo) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
954
955
|
if (!canvas) {
|
|
955
|
-
_this.parentCanvasInfo = createParentWindowCanvas(doc);
|
|
956
|
+
_this.parentCanvasInfo = createParentWindowCanvas(doc, _this.state.options.portalCanvasId);
|
|
956
957
|
canvas = _this.parentCanvasInfo.canvas;
|
|
957
958
|
// Add event listeners only once when canvas is created
|
|
958
959
|
win.addEventListener("scroll", _this.redraw, true);
|
|
@@ -963,7 +964,7 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
963
964
|
}
|
|
964
965
|
}
|
|
965
966
|
canvas.width = de.clientWidth;
|
|
966
|
-
canvas.height = de.clientHeight
|
|
967
|
+
canvas.height = de.clientHeight; // TODO: GEMX VERIFY
|
|
967
968
|
canvas.style.top = '0';
|
|
968
969
|
canvas.style.left = '0';
|
|
969
970
|
canvas.getContext("2d" /* Constant.Context */).clearRect(0, 0, canvas.width, canvas.height);
|
|
@@ -2342,7 +2343,7 @@ var Visualizer = /** @class */ (function () {
|
|
|
2342
2343
|
return false;
|
|
2343
2344
|
}
|
|
2344
2345
|
};
|
|
2345
|
-
this.html = function (decoded, target,
|
|
2346
|
+
this.html = function (decoded, target, portalCanvasId, hash, useproxy, logerror, shortCircuitStrategy) {
|
|
2346
2347
|
if (hash === void 0) { hash = null; }
|
|
2347
2348
|
if (shortCircuitStrategy === void 0) { shortCircuitStrategy = 0 /* ShortCircuitStrategy.None */; }
|
|
2348
2349
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2355,7 +2356,7 @@ var Visualizer = /** @class */ (function () {
|
|
|
2355
2356
|
case 1:
|
|
2356
2357
|
_b.trys.push([1, 10, , 11]);
|
|
2357
2358
|
merged = this.merge(decoded);
|
|
2358
|
-
return [4 /*yield*/, this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy: useproxy,
|
|
2359
|
+
return [4 /*yield*/, this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy: useproxy, portalCanvasId: portalCanvasId })];
|
|
2359
2360
|
case 2:
|
|
2360
2361
|
_b.sent();
|
|
2361
2362
|
_b.label = 3;
|
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.58",
|
|
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.58"
|
|
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;
|
|
@@ -286,7 +289,7 @@ export function applyBestCanvasStrategy(
|
|
|
286
289
|
|
|
287
290
|
// Strategy 1: Parent window canvas (best for iframe contexts)
|
|
288
291
|
if (selectedStrategy === 'auto' || selectedStrategy === 'parent-window') {
|
|
289
|
-
const parentCanvas = createParentWindowCanvas(doc);
|
|
292
|
+
const parentCanvas = createParentWindowCanvas(doc, canvasId);
|
|
290
293
|
if (parentCanvas) {
|
|
291
294
|
return {
|
|
292
295
|
canvas: parentCanvas.canvas,
|
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;
|