clarity-js 0.7.56 → 0.7.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/build/clarity.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +93 -50
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +93 -50
- package/build/clarity.performance.js +1 -1
- package/package.json +1 -1
- package/src/core/config.ts +1 -0
- package/src/core/version.ts +1 -1
- package/src/data/metadata.ts +10 -3
- package/src/layout/animation.ts +8 -1
- package/src/layout/mutation.ts +61 -30
- package/types/core.d.ts +1 -0
- package/types/layout.d.ts +8 -2
package/build/clarity.js
CHANGED
|
@@ -138,6 +138,7 @@ var config$2 = {
|
|
|
138
138
|
throttleDom: true,
|
|
139
139
|
conversions: false,
|
|
140
140
|
longTask: 30,
|
|
141
|
+
includeSubdomains: true,
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
function api(method) {
|
|
@@ -165,7 +166,7 @@ function stop$F() {
|
|
|
165
166
|
startTime = 0;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
var version$1 = "0.7.
|
|
169
|
+
var version$1 = "0.7.57";
|
|
169
170
|
|
|
170
171
|
// tslint:disable: no-bitwise
|
|
171
172
|
function hash (input, precision) {
|
|
@@ -2372,6 +2373,7 @@ function traverse (root, timer, source, timestamp) {
|
|
|
2372
2373
|
|
|
2373
2374
|
var observers = [];
|
|
2374
2375
|
var mutations = [];
|
|
2376
|
+
var throttledMutations = {};
|
|
2375
2377
|
var insertRule = null;
|
|
2376
2378
|
var deleteRule = null;
|
|
2377
2379
|
var attachShadow = null;
|
|
@@ -2379,6 +2381,7 @@ var mediaInsertRule = null;
|
|
|
2379
2381
|
var mediaDeleteRule = null;
|
|
2380
2382
|
var queue$2 = [];
|
|
2381
2383
|
var timeout$1 = null;
|
|
2384
|
+
var throttleDelay = null;
|
|
2382
2385
|
var activePeriod = null;
|
|
2383
2386
|
var history$4 = {};
|
|
2384
2387
|
function start$k() {
|
|
@@ -2482,6 +2485,7 @@ function stop$i() {
|
|
|
2482
2485
|
observers = [];
|
|
2483
2486
|
history$4 = {};
|
|
2484
2487
|
mutations = [];
|
|
2488
|
+
throttledMutations = [];
|
|
2485
2489
|
queue$2 = [];
|
|
2486
2490
|
activePeriod = 0;
|
|
2487
2491
|
timeout$1 = null;
|
|
@@ -2499,36 +2503,24 @@ function handle$1(m) {
|
|
|
2499
2503
|
measure(compute$6)();
|
|
2500
2504
|
});
|
|
2501
2505
|
}
|
|
2502
|
-
function
|
|
2506
|
+
function processMutation(timer, mutation, instance, timestamp) {
|
|
2503
2507
|
return __awaiter(this, void 0, void 0, function () {
|
|
2504
|
-
var
|
|
2505
|
-
return __generator(this, function (
|
|
2506
|
-
switch (
|
|
2508
|
+
var state, target, type;
|
|
2509
|
+
return __generator(this, function (_a) {
|
|
2510
|
+
switch (_a.label) {
|
|
2507
2511
|
case 0:
|
|
2508
|
-
timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
|
|
2509
|
-
start$y(timer);
|
|
2510
|
-
_b.label = 1;
|
|
2511
|
-
case 1:
|
|
2512
|
-
if (!(mutations.length > 0)) return [3 /*break*/, 8];
|
|
2513
|
-
record = mutations.shift();
|
|
2514
|
-
instance = time();
|
|
2515
|
-
_i = 0, _a = record.mutations;
|
|
2516
|
-
_b.label = 2;
|
|
2517
|
-
case 2:
|
|
2518
|
-
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
2519
|
-
mutation = _a[_i];
|
|
2520
2512
|
state = state$a(timer);
|
|
2521
|
-
if (!(state === 0 /* Task.Wait */)) return [3 /*break*/,
|
|
2513
|
+
if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 2];
|
|
2522
2514
|
return [4 /*yield*/, suspend$1(timer)];
|
|
2523
|
-
case
|
|
2524
|
-
state =
|
|
2525
|
-
|
|
2526
|
-
case
|
|
2515
|
+
case 1:
|
|
2516
|
+
state = _a.sent();
|
|
2517
|
+
_a.label = 2;
|
|
2518
|
+
case 2:
|
|
2527
2519
|
if (state === 2 /* Task.Stop */) {
|
|
2528
|
-
return [
|
|
2520
|
+
return [2 /*return*/];
|
|
2529
2521
|
}
|
|
2530
2522
|
target = mutation.target;
|
|
2531
|
-
type = config$2.throttleDom ? track$5(mutation, timer, instance,
|
|
2523
|
+
type = config$2.throttleDom ? track$5(mutation, timer, instance, timestamp) : mutation.type;
|
|
2532
2524
|
if (type && target && target.ownerDocument) {
|
|
2533
2525
|
parse$1(target.ownerDocument);
|
|
2534
2526
|
}
|
|
@@ -2537,31 +2529,60 @@ function process$2() {
|
|
|
2537
2529
|
}
|
|
2538
2530
|
switch (type) {
|
|
2539
2531
|
case "attributes" /* Constant.Attributes */:
|
|
2540
|
-
processNode(target, 3 /* Source.Attributes */,
|
|
2532
|
+
processNode(target, 3 /* Source.Attributes */, timestamp);
|
|
2541
2533
|
break;
|
|
2542
2534
|
case "characterData" /* Constant.CharacterData */:
|
|
2543
|
-
processNode(target, 4 /* Source.CharacterData */,
|
|
2535
|
+
processNode(target, 4 /* Source.CharacterData */, timestamp);
|
|
2544
2536
|
break;
|
|
2545
2537
|
case "childList" /* Constant.ChildList */:
|
|
2546
|
-
processNodeList(mutation.addedNodes, 1 /* Source.ChildListAdd */, timer,
|
|
2547
|
-
processNodeList(mutation.removedNodes, 2 /* Source.ChildListRemove */, timer,
|
|
2548
|
-
break;
|
|
2549
|
-
case "suspend" /* Constant.Suspend */:
|
|
2550
|
-
value = get(target);
|
|
2551
|
-
if (value) {
|
|
2552
|
-
value.metadata.suspend = true;
|
|
2553
|
-
}
|
|
2538
|
+
processNodeList(mutation.addedNodes, 1 /* Source.ChildListAdd */, timer, timestamp);
|
|
2539
|
+
processNodeList(mutation.removedNodes, 2 /* Source.ChildListRemove */, timer, timestamp);
|
|
2554
2540
|
break;
|
|
2555
2541
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2542
|
+
return [2 /*return*/];
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
function process$2() {
|
|
2548
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2549
|
+
var timer, record, instance, _i, _a, mutation, processedMutations, _b, _c, key, throttledMutationToProcess;
|
|
2550
|
+
return __generator(this, function (_d) {
|
|
2551
|
+
switch (_d.label) {
|
|
2552
|
+
case 0:
|
|
2553
|
+
timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
|
|
2554
|
+
start$y(timer);
|
|
2555
|
+
_d.label = 1;
|
|
2556
|
+
case 1:
|
|
2557
|
+
if (!(mutations.length > 0)) return [3 /*break*/, 3];
|
|
2558
|
+
record = mutations.shift();
|
|
2559
|
+
instance = time();
|
|
2560
|
+
for (_i = 0, _a = record.mutations; _i < _a.length; _i++) {
|
|
2561
|
+
mutation = _a[_i];
|
|
2562
|
+
processMutation(timer, mutation, instance, record.time);
|
|
2563
|
+
}
|
|
2564
|
+
return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, record.time)];
|
|
2565
|
+
case 2:
|
|
2566
|
+
_d.sent();
|
|
2563
2567
|
return [3 /*break*/, 1];
|
|
2564
|
-
case
|
|
2568
|
+
case 3:
|
|
2569
|
+
processedMutations = false;
|
|
2570
|
+
for (_b = 0, _c = Object.keys(throttledMutations); _b < _c.length; _b++) {
|
|
2571
|
+
key = _c[_b];
|
|
2572
|
+
throttledMutationToProcess = throttledMutations[key];
|
|
2573
|
+
delete throttledMutations[key];
|
|
2574
|
+
processMutation(timer, throttledMutationToProcess.mutation, time(), throttledMutationToProcess.timestamp);
|
|
2575
|
+
processedMutations = true;
|
|
2576
|
+
}
|
|
2577
|
+
if (Object.keys(throttledMutations).length > 0) {
|
|
2578
|
+
processThrottledMutations();
|
|
2579
|
+
}
|
|
2580
|
+
if (!(Object.keys(throttledMutations).length === 0 && processedMutations)) return [3 /*break*/, 5];
|
|
2581
|
+
return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, time())];
|
|
2582
|
+
case 4:
|
|
2583
|
+
_d.sent();
|
|
2584
|
+
_d.label = 5;
|
|
2585
|
+
case 5:
|
|
2565
2586
|
stop$w(timer);
|
|
2566
2587
|
return [2 /*return*/];
|
|
2567
2588
|
}
|
|
@@ -2592,14 +2613,16 @@ function track$5(m, timer, instance, timestamp) {
|
|
|
2592
2613
|
h[0] = inactive ? (h[1] === instance ? h[0] : h[0] + 1) : 1;
|
|
2593
2614
|
h[1] = instance;
|
|
2594
2615
|
// Return updated mutation type based on if we have already hit the threshold or not
|
|
2595
|
-
if (h[0]
|
|
2616
|
+
if (h[0] >= 10 /* Setting.MutationSuspendThreshold */) {
|
|
2596
2617
|
// Store a reference to removedNodes so we can process them later
|
|
2597
2618
|
// when we resume mutations again on user interactions
|
|
2598
2619
|
h[2] = m.removedNodes;
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2620
|
+
if (instance > timestamp + 3000 /* Setting.MutationActivePeriod */) {
|
|
2621
|
+
return m.type;
|
|
2622
|
+
}
|
|
2623
|
+
// we only store the most recent mutation for a given key if it is being throttled
|
|
2624
|
+
throttledMutations[key] = { mutation: m, timestamp: timestamp };
|
|
2625
|
+
return "throttle" /* Constant.Throttle */;
|
|
2603
2626
|
}
|
|
2604
2627
|
}
|
|
2605
2628
|
return m.type;
|
|
@@ -2646,6 +2669,12 @@ function processNodeList(list, source, timer, timestamp) {
|
|
|
2646
2669
|
});
|
|
2647
2670
|
});
|
|
2648
2671
|
}
|
|
2672
|
+
function processThrottledMutations() {
|
|
2673
|
+
if (throttleDelay) {
|
|
2674
|
+
clearTimeout(throttleDelay);
|
|
2675
|
+
}
|
|
2676
|
+
throttleDelay = setTimeout(function () { schedule$1(process$2, 1 /* Priority.High */); }, 33 /* Setting.LookAhead */);
|
|
2677
|
+
}
|
|
2649
2678
|
function schedule(node) {
|
|
2650
2679
|
// Only schedule manual trigger for this node if it's not already in the queue
|
|
2651
2680
|
if (queue$2.indexOf(node) < 0) {
|
|
@@ -3138,6 +3167,7 @@ var state$2 = [];
|
|
|
3138
3167
|
var elementAnimate = null;
|
|
3139
3168
|
var animationPlay = null;
|
|
3140
3169
|
var animationPause = null;
|
|
3170
|
+
var animationCommitStyles = null;
|
|
3141
3171
|
var animationCancel = null;
|
|
3142
3172
|
var animationFinish = null;
|
|
3143
3173
|
var animationId = 'clarityAnimationId';
|
|
@@ -3145,12 +3175,15 @@ var operationCount = 'clarityOperationCount';
|
|
|
3145
3175
|
var maxOperations = 20;
|
|
3146
3176
|
function start$i() {
|
|
3147
3177
|
if (window["Animation"] &&
|
|
3178
|
+
window["Animation"].prototype &&
|
|
3148
3179
|
window["KeyframeEffect"] &&
|
|
3180
|
+
window["KeyframeEffect"].prototype &&
|
|
3149
3181
|
window["KeyframeEffect"].prototype.getKeyframes &&
|
|
3150
3182
|
window["KeyframeEffect"].prototype.getTiming) {
|
|
3151
3183
|
reset$7();
|
|
3152
3184
|
overrideAnimationHelper(animationPlay, "play");
|
|
3153
3185
|
overrideAnimationHelper(animationPause, "pause");
|
|
3186
|
+
overrideAnimationHelper(animationCommitStyles, "commitStyles");
|
|
3154
3187
|
overrideAnimationHelper(animationCancel, "cancel");
|
|
3155
3188
|
overrideAnimationHelper(animationFinish, "finish");
|
|
3156
3189
|
if (elementAnimate === null) {
|
|
@@ -3234,6 +3267,9 @@ function trackAnimationOperation(animation, name) {
|
|
|
3234
3267
|
case "finish":
|
|
3235
3268
|
operation = 4 /* AnimationOperation.Finish */;
|
|
3236
3269
|
break;
|
|
3270
|
+
case "commitStyles":
|
|
3271
|
+
operation = 5 /* AnimationOperation.CommitStyles */;
|
|
3272
|
+
break;
|
|
3237
3273
|
}
|
|
3238
3274
|
if (operation) {
|
|
3239
3275
|
track$4(time(), animation[animationId], operation);
|
|
@@ -4787,7 +4823,7 @@ function shortid() {
|
|
|
4787
4823
|
}
|
|
4788
4824
|
function session() {
|
|
4789
4825
|
var output = { session: shortid(), ts: Math.round(Date.now()), count: 1, upgrade: null, upload: "" /* Constant.Empty */ };
|
|
4790
|
-
var value = getCookie("_clsk" /* Constant.SessionKey
|
|
4826
|
+
var value = getCookie("_clsk" /* Constant.SessionKey */, !config$2.includeSubdomains);
|
|
4791
4827
|
if (value) {
|
|
4792
4828
|
var parts = value.split("|" /* Constant.Pipe */);
|
|
4793
4829
|
// Making it backward & forward compatible by using greater than comparison (v0.6.21)
|
|
@@ -4807,7 +4843,7 @@ function num(string, base) {
|
|
|
4807
4843
|
}
|
|
4808
4844
|
function user() {
|
|
4809
4845
|
var output = { id: shortid(), version: 0, expiry: null, consent: 0 /* BooleanFlag.False */, dob: 0 };
|
|
4810
|
-
var cookie = getCookie("_clck" /* Constant.CookieKey
|
|
4846
|
+
var cookie = getCookie("_clck" /* Constant.CookieKey */, !config$2.includeSubdomains);
|
|
4811
4847
|
if (cookie && cookie.length > 0) {
|
|
4812
4848
|
// Splitting and looking up first part for forward compatibility, in case we wish to store additional information in a cookie
|
|
4813
4849
|
var parts = cookie.split("|" /* Constant.Pipe */);
|
|
@@ -4849,8 +4885,9 @@ function user() {
|
|
|
4849
4885
|
}
|
|
4850
4886
|
return output;
|
|
4851
4887
|
}
|
|
4852
|
-
function getCookie(key) {
|
|
4888
|
+
function getCookie(key, limit) {
|
|
4853
4889
|
var _a;
|
|
4890
|
+
if (limit === void 0) { limit = false; }
|
|
4854
4891
|
if (supported(document, "cookie" /* Constant.Cookie */)) {
|
|
4855
4892
|
var cookies = document.cookie.split(";" /* Constant.Semicolon */);
|
|
4856
4893
|
if (cookies) {
|
|
@@ -4867,6 +4904,12 @@ function getCookie(key) {
|
|
|
4867
4904
|
while (isEncoded) {
|
|
4868
4905
|
_a = decodeCookieValue(decodedValue), isEncoded = _a[0], decodedValue = _a[1];
|
|
4869
4906
|
}
|
|
4907
|
+
// If we are limiting cookies, check if the cookie value is limited
|
|
4908
|
+
if (limit) {
|
|
4909
|
+
return decodedValue.endsWith("".concat("~" /* Constant.Tilde */, "1"))
|
|
4910
|
+
? decodedValue.substring(0, decodedValue.length - 2)
|
|
4911
|
+
: null;
|
|
4912
|
+
}
|
|
4870
4913
|
return decodedValue;
|
|
4871
4914
|
}
|
|
4872
4915
|
}
|