@gemx-dev/clarity-visualize 0.8.57 → 0.8.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.
@@ -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)) {
@@ -401,7 +401,8 @@ function createParentWindowCanvas(iframeDoc) {
401
401
  var parentDoc = parentWindow === null || parentWindow === void 0 ? void 0 : parentWindow.document;
402
402
  if (!parentDoc)
403
403
  throw new Error('Parent document not found');
404
- var iframe = parentDoc.getElementById('clarity-iframe');
404
+ var iframeId = "clarity-iframe-".concat(portalCanvasId);
405
+ var iframe = parentDoc.getElementById(iframeId);
405
406
  if (!iframe)
406
407
  throw new Error('Iframe not found');
407
408
  var targetIframe = iframe;
@@ -409,10 +410,11 @@ function createParentWindowCanvas(iframeDoc) {
409
410
  if (!iframeParent)
410
411
  throw new Error('Iframe parent not found');
411
412
  // Create canvas as sibling to iframe
412
- var canvas_1 = parentDoc.getElementById("clarity-heatmap-canvas" /* Constant.HeatmapCanvas */);
413
+ var canvasId = "".concat("clarity-heatmap-canvas" /* Constant.HeatmapCanvas */, "-").concat(portalCanvasId);
414
+ var canvas_1 = parentDoc.getElementById(canvasId);
413
415
  if (canvas_1 === null) {
414
416
  canvas_1 = parentDoc.createElement('canvas');
415
- canvas_1.id = "clarity-heatmap-canvas" /* Constant.HeatmapCanvas */;
417
+ canvas_1.id = canvasId;
416
418
  canvas_1.width = 0;
417
419
  canvas_1.height = 0;
418
420
  canvas_1.style.position = "absolute" /* Constant.Absolute */;
@@ -795,7 +797,7 @@ var HeatmapHelper = /** @class */ (function () {
795
797
  var doc = _this.state.window.document;
796
798
  var win = _this.state.window;
797
799
  var de = doc.documentElement;
798
- var isPortalCanvas = _this.state.options.portalCanvas;
800
+ var isPortalCanvas = !!_this.state.options.portalCanvasId;
799
801
  if (isPortalCanvas)
800
802
  return _this.createPortalCanvas(doc, win, de);
801
803
  var canvas = doc.getElementById("clarity-heatmap-canvas" /* Constant.HeatmapCanvas */);
@@ -936,7 +938,7 @@ var HeatmapHelper = /** @class */ (function () {
936
938
  return __generator(this, function (_a) {
937
939
  switch (_a.label) {
938
940
  case 0:
939
- isPortalCanvas = this.state.options.portalCanvas;
941
+ isPortalCanvas = !!this.state.options.portalCanvasId;
940
942
  if (!isPortalCanvas)
941
943
  return [2 /*return*/];
942
944
  return [4 /*yield*/, waitForDialogsRendered()];
@@ -952,7 +954,7 @@ var HeatmapHelper = /** @class */ (function () {
952
954
  try {
953
955
  canvas = (_a = _this.parentCanvasInfo) === null || _a === void 0 ? void 0 : _a.canvas;
954
956
  if (!canvas) {
955
- _this.parentCanvasInfo = createParentWindowCanvas(doc);
957
+ _this.parentCanvasInfo = createParentWindowCanvas(doc, _this.state.options.portalCanvasId);
956
958
  canvas = _this.parentCanvasInfo.canvas;
957
959
  // Add event listeners only once when canvas is created
958
960
  win.addEventListener("scroll", _this.redraw, true);
@@ -963,7 +965,7 @@ var HeatmapHelper = /** @class */ (function () {
963
965
  }
964
966
  }
965
967
  canvas.width = de.clientWidth;
966
- canvas.height = de.clientHeight + 4; // TODO: GEMX VERIFY
968
+ canvas.height = de.clientHeight; // TODO: GEMX VERIFY
967
969
  canvas.style.top = '0';
968
970
  canvas.style.left = '0';
969
971
  canvas.getContext("2d" /* Constant.Context */).clearRect(0, 0, canvas.width, canvas.height);
@@ -2342,7 +2344,7 @@ var Visualizer = /** @class */ (function () {
2342
2344
  return false;
2343
2345
  }
2344
2346
  };
2345
- this.html = function (decoded, target, portalCanvas, hash, useproxy, logerror, shortCircuitStrategy) {
2347
+ this.html = function (decoded, target, portalCanvasId, hash, useproxy, logerror, shortCircuitStrategy) {
2346
2348
  if (hash === void 0) { hash = null; }
2347
2349
  if (shortCircuitStrategy === void 0) { shortCircuitStrategy = 0 /* ShortCircuitStrategy.None */; }
2348
2350
  return __awaiter(_this, void 0, void 0, function () {
@@ -2355,7 +2357,7 @@ var Visualizer = /** @class */ (function () {
2355
2357
  case 1:
2356
2358
  _b.trys.push([1, 10, , 11]);
2357
2359
  merged = this.merge(decoded);
2358
- return [4 /*yield*/, this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy: useproxy, portalCanvas: portalCanvas })];
2360
+ return [4 /*yield*/, this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy: useproxy, portalCanvasId: portalCanvasId })];
2359
2361
  case 2:
2360
2362
  _b.sent();
2361
2363
  _b.label = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemx-dev/clarity-visualize",
3
- "version": "0.8.57",
3
+ "version": "0.8.59",
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.57"
12
+ "@gemx-dev/clarity-decode": "^0.8.59"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@rollup/plugin-commonjs": "^24.0.0",
@@ -41,7 +41,8 @@ export function createParentWindowCanvas(
41
41
  const parentDoc = parentWindow?.document;
42
42
  if (!parentDoc) throw new Error('Parent document not found');
43
43
 
44
- const iframe = parentDoc.getElementById('clarity-iframe');
44
+ const iframeId = `clarity-iframe-${portalCanvasId}`;
45
+ const iframe = parentDoc.getElementById(iframeId);
45
46
  if (!iframe) throw new Error('Iframe not found');
46
47
 
47
48
  const targetIframe = iframe as HTMLIFrameElement;
@@ -289,7 +290,7 @@ export function applyBestCanvasStrategy(
289
290
 
290
291
  // Strategy 1: Parent window canvas (best for iframe contexts)
291
292
  if (selectedStrategy === 'auto' || selectedStrategy === 'parent-window') {
292
- const parentCanvas = createParentWindowCanvas(doc);
293
+ const parentCanvas = createParentWindowCanvas(doc, canvasId);
293
294
  if (parentCanvas) {
294
295
  return {
295
296
  canvas: parentCanvas.canvas,