@gemx-dev/clarity-visualize 0.8.64 → 0.8.66

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.
@@ -388,10 +388,6 @@ var EnrichHelper = /** @class */ (function () {
388
388
  var selectorBeta = helper.selector.get(input, 1 /* Layout.Selector.Beta */);
389
389
  d.selectorBeta = selectorBeta.length > 0 ? selectorBeta : null;
390
390
  d.hashBeta = selectorBeta.length > 0 ? helper.hash(d.selectorBeta) : null;
391
- var rawClass = (d.attributes || {})['class'] || '';
392
- if (rawClass.includes('gp_ls-is-cached')) {
393
- console.log("[Enrich] id=".concat(d.id, " tag=").concat(d.tag, " | class=\"").concat(rawClass, "\" | selectorBeta=\"").concat(selectorBeta, "\" | hashBeta=").concat(d.hashBeta));
394
- }
395
391
  /* Track state for future reference */
396
392
  node.alpha = selectorAlpha;
397
393
  node.beta = selectorBeta;
@@ -1000,7 +996,9 @@ var HeatmapHelper = /** @class */ (function () {
1000
996
  if (e.tagName === "CANVAS" /* Constant.Canvas */ || (e.id && e.id.indexOf("clarity-" /* Constant.ClarityPrefix */) === 0)) {
1001
997
  continue;
1002
998
  }
1003
- visibility = e === el;
999
+ // Consider visible if the top element is the element itself OR a descendant of it
1000
+ // (e.g. a BUTTON containing P/SPAN children — children will appear on top in elementsFromPoint)
1001
+ visibility = e === el || el.contains(e);
1004
1002
  shadowElement = e.shadowRoot && e.shadowRoot != doc ? e.shadowRoot : null;
1005
1003
  break;
1006
1004
  }
@@ -1767,9 +1765,6 @@ var LayoutHelper = /** @class */ (function () {
1767
1765
  // In case of selector collision, prefer the first inserted node
1768
1766
  _this.hashMapAlpha[data.hashAlpha] = _this.get(data.hashAlpha) || parent;
1769
1767
  _this.hashMapBeta[data.hashBeta] = _this.get(data.hashBeta) || parent;
1770
- if (data.hashBeta === '2e36mrf7c' || data.hashBeta === '19lq10ve5') {
1771
- console.log("[Layout] addToHashMap hashBeta=".concat(data.hashBeta, " | hashAlpha=").concat(data.hashAlpha, " | tag=").concat(parent === null || parent === void 0 ? void 0 : parent.tagName));
1772
- }
1773
1768
  };
1774
1769
  this.resize = function (el, width, height) {
1775
1770
  if (el && el.nodeType === 1 /* NodeType.ELEMENT_NODE */ && width && height) {
@@ -2401,7 +2396,7 @@ var Visualizer = /** @class */ (function () {
2401
2396
  this._excludeClassNames = [];
2402
2397
  this.configure = function (opts) {
2403
2398
  _this._excludeClassNames = opts.excludeClassNames || [];
2404
- helper.selector.configure(_this._excludeClassNames);
2399
+ helper.selector.config(_this._excludeClassNames);
2405
2400
  };
2406
2401
  this.dom = function (event) { return __awaiter(_this, void 0, void 0, function () {
2407
2402
  return __generator(this, function (_a) {
@@ -2439,33 +2434,25 @@ var Visualizer = /** @class */ (function () {
2439
2434
  return false;
2440
2435
  }
2441
2436
  };
2442
- this.html = function (decoded, target, portalCanvasId, hash, useproxy, logerror, shortCircuitStrategy, signal) {
2437
+ this.html = function (decoded, target, portalCanvasId, hash, useproxy, logerror, shortCircuitStrategy) {
2443
2438
  if (hash === void 0) { hash = null; }
2444
2439
  if (shortCircuitStrategy === void 0) { shortCircuitStrategy = 0 /* ShortCircuitStrategy.None */; }
2445
2440
  return __awaiter(_this, void 0, void 0, function () {
2446
- var merged, CHUNK_BUDGET_MS, chunkStart, entry, _a, domEvent, e_1;
2441
+ var merged, entry, _a, domEvent, e_1;
2447
2442
  return __generator(this, function (_b) {
2448
2443
  switch (_b.label) {
2449
2444
  case 0:
2450
- if (!(decoded && decoded.length > 0 && target)) return [3 /*break*/, 13];
2445
+ if (!(decoded && decoded.length > 0 && target)) return [3 /*break*/, 11];
2451
2446
  _b.label = 1;
2452
2447
  case 1:
2453
- _b.trys.push([1, 12, , 13]);
2448
+ _b.trys.push([1, 10, , 11]);
2454
2449
  merged = this.merge(decoded);
2455
- if (signal === null || signal === void 0 ? void 0 : signal.aborted)
2456
- return [2 /*return*/, this];
2457
2450
  return [4 /*yield*/, this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy: useproxy, portalCanvasId: portalCanvasId })];
2458
2451
  case 2:
2459
2452
  _b.sent();
2460
- if (signal === null || signal === void 0 ? void 0 : signal.aborted)
2461
- return [2 /*return*/, this];
2462
- CHUNK_BUDGET_MS = 8;
2463
- chunkStart = performance.now();
2464
2453
  _b.label = 3;
2465
2454
  case 3:
2466
- if (!(merged.events.length > 0)) return [3 /*break*/, 11];
2467
- if (signal === null || signal === void 0 ? void 0 : signal.aborted)
2468
- return [2 /*return*/, this];
2455
+ if (!(merged.events.length > 0)) return [3 /*break*/, 9];
2469
2456
  entry = merged.events.shift();
2470
2457
  _a = entry.event;
2471
2458
  switch (_a) {
@@ -2491,22 +2478,15 @@ var Visualizer = /** @class */ (function () {
2491
2478
  case 7:
2492
2479
  _b.sent();
2493
2480
  return [3 /*break*/, 8];
2494
- case 8:
2495
- if (!(performance.now() - chunkStart >= CHUNK_BUDGET_MS)) return [3 /*break*/, 10];
2496
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 0); })];
2497
- case 9:
2498
- _b.sent();
2499
- chunkStart = performance.now();
2500
- _b.label = 10;
2501
- case 10: return [3 /*break*/, 3];
2502
- case 11: return [3 /*break*/, 13];
2503
- case 12:
2481
+ case 8: return [3 /*break*/, 3];
2482
+ case 9: return [3 /*break*/, 11];
2483
+ case 10:
2504
2484
  e_1 = _b.sent();
2505
2485
  if (logerror) {
2506
2486
  logerror(e_1);
2507
2487
  }
2508
- return [3 /*break*/, 13];
2509
- case 13: return [2 /*return*/, this];
2488
+ return [3 /*break*/, 11];
2489
+ case 11: return [2 /*return*/, this];
2510
2490
  }
2511
2491
  });
2512
2492
  });
@@ -2538,7 +2518,7 @@ var Visualizer = /** @class */ (function () {
2538
2518
  decoded = decoded.sort(_this.sortPayloads);
2539
2519
  // Re-initialize enrich class if someone ends up calling merge function directly
2540
2520
  _this.enrich = _this.enrich || new EnrichHelper();
2541
- helper.selector.configure(_this._excludeClassNames);
2521
+ helper.selector.config(_this._excludeClassNames);
2542
2522
  _this.enrich.reset();
2543
2523
  // Walk through payloads and generate merged payload from an array of decoded payloads
2544
2524
  for (var _i = 0, decoded_1 = decoded; _i < decoded_1.length; _i++) {
@@ -2579,7 +2559,7 @@ var Visualizer = /** @class */ (function () {
2579
2559
  this.reset();
2580
2560
  if (options.excludeClassNames) {
2581
2561
  this._excludeClassNames = options.excludeClassNames;
2582
- helper.selector.configure(options.excludeClassNames);
2562
+ helper.selector.config(options.excludeClassNames);
2583
2563
  }
2584
2564
  // Infer options
2585
2565
  options.pointer = "pointer" in options ? options.pointer : true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemx-dev/clarity-visualize",
3
- "version": "0.8.64",
3
+ "version": "0.8.66",
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.64"
12
+ "@gemx-dev/clarity-decode": "^0.8.66"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@rollup/plugin-commonjs": "^24.0.0",
package/src/heatmap.ts CHANGED
@@ -366,7 +366,9 @@ export class HeatmapHelper {
366
366
  for (let e of elements) {
367
367
  // Ignore if top element ends up being the canvas element we added for heatmap visualization
368
368
  if (e.tagName === Constant.Canvas || (e.id && e.id.indexOf(Constant.ClarityPrefix) === 0)) { continue; }
369
- visibility = e === el;
369
+ // Consider visible if the top element is the element itself OR a descendant of it
370
+ // (e.g. a BUTTON containing P/SPAN children — children will appear on top in elementsFromPoint)
371
+ visibility = e === el || el.contains(e);
370
372
  shadowElement = e.shadowRoot && e.shadowRoot != doc ? e.shadowRoot : null;
371
373
  break;
372
374
  }
package/src/visualizer.ts CHANGED
@@ -27,7 +27,7 @@ export class Visualizer implements VisualizerType {
27
27
 
28
28
  public configure = (opts: { excludeClassNames?: string[] }): void => {
29
29
  this._excludeClassNames = opts.excludeClassNames || [];
30
- helper.selector.configure(this._excludeClassNames);
30
+ helper.selector.config(this._excludeClassNames);
31
31
  }
32
32
 
33
33
  public dom = async (event: Layout.DomEvent): Promise<void> => {
@@ -123,7 +123,7 @@ export class Visualizer implements VisualizerType {
123
123
  decoded = decoded.sort(this.sortPayloads);
124
124
  // Re-initialize enrich class if someone ends up calling merge function directly
125
125
  this.enrich = this.enrich || new EnrichHelper();
126
- helper.selector.configure(this._excludeClassNames);
126
+ helper.selector.config(this._excludeClassNames);
127
127
  this.enrich.reset();
128
128
  // Walk through payloads and generate merged payload from an array of decoded payloads
129
129
  for (let payload of decoded) {
@@ -158,7 +158,7 @@ export class Visualizer implements VisualizerType {
158
158
  this.reset();
159
159
  if (options.excludeClassNames) {
160
160
  this._excludeClassNames = options.excludeClassNames;
161
- helper.selector.configure(options.excludeClassNames);
161
+ helper.selector.config(options.excludeClassNames);
162
162
  }
163
163
  // Infer options
164
164
  options.pointer = "pointer" in options ? options.pointer : true;