@gemx-dev/clarity-visualize 0.8.63 → 0.8.65
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/build/clarity.visualize.js +52 -11
- package/build/clarity.visualize.min.js +1 -1
- package/build/clarity.visualize.module.js +52 -11
- package/package.json +2 -2
- package/src/heatmap.ts +34 -4
- package/src/visualizer.ts +3 -3
|
@@ -106,8 +106,9 @@ var selectorMap = {};
|
|
|
106
106
|
function reset$8() {
|
|
107
107
|
selectorMap = {};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function config$2(classNames) {
|
|
110
110
|
extraExcludeClassNames = classNames || [];
|
|
111
|
+
console.log("[Selector] config called \u2014 extraExcludeClassNames set to: [".concat(extraExcludeClassNames.join(', '), "]"));
|
|
111
112
|
}
|
|
112
113
|
function get$1(input, type) {
|
|
113
114
|
var a = input.attributes;
|
|
@@ -131,7 +132,13 @@ function get$1(input, type) {
|
|
|
131
132
|
input.tag = input.tag.indexOf("svg:" /* Constant.SvgPrefix */) === 0 ? input.tag.substr("svg:" /* Constant.SvgPrefix */.length) : input.tag;
|
|
132
133
|
var selector = "".concat(prefix).concat(input.tag).concat(suffix);
|
|
133
134
|
var id = "id" /* Constant.Id */ in a && a["id" /* Constant.Id */].length > 0 ? a["id" /* Constant.Id */] : null;
|
|
134
|
-
var
|
|
135
|
+
var rawClasses = "class" /* Constant.Class */ in a ? a["class" /* Constant.Class */].trim().split(/\s+/) : [];
|
|
136
|
+
var filteredClasses = rawClasses.filter(function (c) { return filter(c); });
|
|
137
|
+
var removedClasses = rawClasses.filter(function (c) { return !filter(c); });
|
|
138
|
+
if (removedClasses.length > 0) {
|
|
139
|
+
console.log("[Selector] tag=\"".concat(input.tag, "\" id=\"").concat(input.id, "\" \u2014 removed classes: [").concat(removedClasses.join(', '), "] | kept: [").concat(filteredClasses.join(', '), "] | extraExclude: [").concat(extraExcludeClassNames.join(', '), "]"));
|
|
140
|
+
}
|
|
141
|
+
var classes = input.tag !== "BODY" /* Constant.BodyTag */ && filteredClasses.length > 0 ? filteredClasses.join("." /* Constant.Period */) : null;
|
|
135
142
|
if (classes && classes.length > 0) {
|
|
136
143
|
if (type === 0 /* Selector.Alpha */) {
|
|
137
144
|
// In Alpha mode, update selector to use class names, with relative positioning within the parent id container.
|
|
@@ -144,16 +151,19 @@ function get$1(input, type) {
|
|
|
144
151
|
selectorMap[key].push(input.id);
|
|
145
152
|
}
|
|
146
153
|
selector = "".concat(key).concat("~" /* Constant.Tilde */).concat(selectorMap[key].indexOf(input.id));
|
|
154
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
|
|
147
155
|
}
|
|
148
156
|
else {
|
|
149
157
|
// In Beta mode, we continue to look at query selectors in context of the full page
|
|
150
158
|
selector = "".concat(prefix).concat(input.tag, ".").concat(classes).concat(suffix);
|
|
159
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
162
|
// Update selector to use "id" field when available. There are two exceptions:
|
|
154
163
|
// (1) if "id" appears to be an auto generated string token, e.g. guid or a random id containing digits
|
|
155
164
|
// (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
|
|
156
165
|
selector = id && filter(id) ? "".concat(getDomPrefix(prefix)).concat("#" /* Constant.Hash */).concat(id) : selector;
|
|
166
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
|
|
157
167
|
return selector;
|
|
158
168
|
}
|
|
159
169
|
}
|
|
@@ -180,7 +190,9 @@ function filter(value) {
|
|
|
180
190
|
if (!value) {
|
|
181
191
|
return false;
|
|
182
192
|
} // Do not process empty strings
|
|
183
|
-
|
|
193
|
+
var excludeClassNames = getExcludeClassNames();
|
|
194
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ filter ~ excludeClassNames:", excludeClassNames);
|
|
195
|
+
if (excludeClassNames.some(function (x) { return value.toLowerCase().indexOf(x) >= 0; })) {
|
|
184
196
|
return false;
|
|
185
197
|
}
|
|
186
198
|
for (var i = 0; i < value.length; i++) {
|
|
@@ -192,12 +204,14 @@ function filter(value) {
|
|
|
192
204
|
return true;
|
|
193
205
|
}
|
|
194
206
|
function getExcludeClassNames() {
|
|
207
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ getExcludeClassNames ~ extraExcludeClassNames:", extraExcludeClassNames);
|
|
208
|
+
console.log("\uD83D\uDE80 \uD83D\uDC25 ~ getExcludeClassNames ~ excludeClassNames:", excludeClassNames);
|
|
195
209
|
return __spreadArray(__spreadArray([], excludeClassNames, true), extraExcludeClassNames, true);
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
var selector = /*#__PURE__*/Object.freeze({
|
|
199
213
|
__proto__: null,
|
|
200
|
-
|
|
214
|
+
config: config$2,
|
|
201
215
|
get: get$1,
|
|
202
216
|
reset: reset$8
|
|
203
217
|
});
|
|
@@ -916,7 +930,8 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
916
930
|
continue;
|
|
917
931
|
}
|
|
918
932
|
var r = el.getBoundingClientRect();
|
|
919
|
-
var
|
|
933
|
+
var isDebugHash = element.hash === "270qs0pw7";
|
|
934
|
+
var v = _this.visible(el, r, height, isDebugHash ? element.hash : undefined);
|
|
920
935
|
if (!v && _this.max !== null) {
|
|
921
936
|
console.warn("[Heatmap] SKIP hash=\"".concat(element.hash, "\" \u2014 not visible on re-render"), { rect: { top: r.top, left: r.left, width: r.width, height: r.height }, maxIsSet: _this.max !== null });
|
|
922
937
|
continue;
|
|
@@ -955,13 +970,28 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
955
970
|
console.groupEnd();
|
|
956
971
|
return output;
|
|
957
972
|
};
|
|
958
|
-
this.visible = function (el, r, height) {
|
|
973
|
+
this.visible = function (el, r, height, debugHash) {
|
|
959
974
|
var doc = _this.state.window.document;
|
|
960
975
|
var visibility = r.height > height ? true : false;
|
|
976
|
+
if (debugHash) {
|
|
977
|
+
console.group("[Heatmap visible] hash=".concat(debugHash, " tag=").concat(el === null || el === void 0 ? void 0 : el.tagName));
|
|
978
|
+
console.log(" rect: top=".concat(r.top.toFixed(1), " bottom=").concat(r.bottom.toFixed(1), " left=").concat(r.left.toFixed(1), " width=").concat(r.width.toFixed(1), " height=").concat(r.height.toFixed(1)));
|
|
979
|
+
console.log(" viewport height=".concat(height, " | r.height > height? ").concat(r.height > height));
|
|
980
|
+
}
|
|
961
981
|
if (visibility === false && r.width > 0 && r.height > 0) {
|
|
982
|
+
var checkX = r.left + (r.width / 2);
|
|
983
|
+
var checkY = r.top + (r.height / 2);
|
|
984
|
+
if (debugHash) {
|
|
985
|
+
console.log(" elementsFromPoint(".concat(checkX.toFixed(1), ", ").concat(checkY.toFixed(1), ")"));
|
|
986
|
+
}
|
|
962
987
|
while (!visibility && doc) {
|
|
963
988
|
var shadowElement = null;
|
|
964
|
-
var elements = doc.elementsFromPoint(
|
|
989
|
+
var elements = doc.elementsFromPoint(checkX, checkY);
|
|
990
|
+
if (debugHash) {
|
|
991
|
+
var topElements = elements.slice(0, 5).map(function (e) { return "".concat(e.tagName).concat(e.id ? '#' + e.id : '').concat(e.className ? '.' + String(e.className).trim().split(/\s+/).slice(0, 2).join('.') : ''); });
|
|
992
|
+
console.log(" top elements at center: [".concat(topElements.join(', '), "]"));
|
|
993
|
+
console.log(" is el in top elements? ".concat(elements.includes(el), " | el matches first non-canvas? ").concat(elements.find(function (e) { return !(e.tagName === "CANVAS" /* Constant.Canvas */ || (e.id && e.id.indexOf("clarity-" /* Constant.ClarityPrefix */) === 0)); }) === el));
|
|
994
|
+
}
|
|
965
995
|
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
|
|
966
996
|
var e = elements_1[_i];
|
|
967
997
|
// Ignore if top element ends up being the canvas element we added for heatmap visualization
|
|
@@ -975,7 +1005,18 @@ var HeatmapHelper = /** @class */ (function () {
|
|
|
975
1005
|
doc = shadowElement;
|
|
976
1006
|
}
|
|
977
1007
|
}
|
|
978
|
-
|
|
1008
|
+
else if (debugHash) {
|
|
1009
|
+
if (r.width === 0 || r.height === 0) {
|
|
1010
|
+
console.log(" SKIP elementsFromPoint \u2014 zero dimension: width=".concat(r.width, " height=").concat(r.height));
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
var result = visibility && r.bottom >= 0 && r.top <= height;
|
|
1014
|
+
if (debugHash) {
|
|
1015
|
+
console.log(" visibility=".concat(visibility, " | r.bottom(").concat(r.bottom.toFixed(1), ") >= 0? ").concat(r.bottom >= 0, " | r.top(").concat(r.top.toFixed(1), ") <= height(").concat(height, ")? ").concat(r.top <= height));
|
|
1016
|
+
console.log(" => final result: ".concat(result));
|
|
1017
|
+
console.groupEnd();
|
|
1018
|
+
}
|
|
1019
|
+
return result;
|
|
979
1020
|
};
|
|
980
1021
|
this.waitForDialogs = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
981
1022
|
var isPortalCanvas;
|
|
@@ -2355,7 +2396,7 @@ var Visualizer = /** @class */ (function () {
|
|
|
2355
2396
|
this._excludeClassNames = [];
|
|
2356
2397
|
this.configure = function (opts) {
|
|
2357
2398
|
_this._excludeClassNames = opts.excludeClassNames || [];
|
|
2358
|
-
helper.selector.
|
|
2399
|
+
helper.selector.config(_this._excludeClassNames);
|
|
2359
2400
|
};
|
|
2360
2401
|
this.dom = function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
2361
2402
|
return __generator(this, function (_a) {
|
|
@@ -2477,7 +2518,7 @@ var Visualizer = /** @class */ (function () {
|
|
|
2477
2518
|
decoded = decoded.sort(_this.sortPayloads);
|
|
2478
2519
|
// Re-initialize enrich class if someone ends up calling merge function directly
|
|
2479
2520
|
_this.enrich = _this.enrich || new EnrichHelper();
|
|
2480
|
-
helper.selector.
|
|
2521
|
+
helper.selector.config(_this._excludeClassNames);
|
|
2481
2522
|
_this.enrich.reset();
|
|
2482
2523
|
// Walk through payloads and generate merged payload from an array of decoded payloads
|
|
2483
2524
|
for (var _i = 0, decoded_1 = decoded; _i < decoded_1.length; _i++) {
|
|
@@ -2518,7 +2559,7 @@ var Visualizer = /** @class */ (function () {
|
|
|
2518
2559
|
this.reset();
|
|
2519
2560
|
if (options.excludeClassNames) {
|
|
2520
2561
|
this._excludeClassNames = options.excludeClassNames;
|
|
2521
|
-
helper.selector.
|
|
2562
|
+
helper.selector.config(options.excludeClassNames);
|
|
2522
2563
|
}
|
|
2523
2564
|
// Infer options
|
|
2524
2565
|
options.pointer = "pointer" in options ? options.pointer : true;
|