@atlaskit/react-ufo 3.10.0 → 3.10.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#151997](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151997)
8
+ [`d8723519dfff4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d8723519dfff4) -
9
+ Fix memory leak on TTVC v3
10
+
11
+ ## 3.10.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#150909](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/150909)
16
+ [`3fca421422bb6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3fca421422bb6) -
17
+ FF cleanup - platform_ufo_vc_observer_new
18
+ - [#150909](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/150909)
19
+ [`568e2ae966df9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/568e2ae966df9) -
20
+ FF cleanup - platform_ufo_vc_observer_new
21
+
3
22
  ## 3.10.0
4
23
 
5
24
  ### Minor Changes
@@ -8,6 +8,7 @@ exports.getCapabilityRate = getCapabilityRate;
8
8
  exports.getConfig = getConfig;
9
9
  exports.getDoNotAbortActivePressInteraction = getDoNotAbortActivePressInteraction;
10
10
  exports.getDoNotAbortActivePressInteractionOnTransition = getDoNotAbortActivePressInteractionOnTransition;
11
+ exports.getEnabledVCRevisions = getEnabledVCRevisions;
11
12
  exports.getExperimentalInteractionRate = getExperimentalInteractionRate;
12
13
  exports.getInteractionRate = getInteractionRate;
13
14
  exports.getPostInteractionRate = getPostInteractionRate;
@@ -15,8 +16,10 @@ exports.getRemoveInteractionsUFOPrefixes = getRemoveInteractionsUFOPrefixes;
15
16
  exports.getRemovePageSegmentsUFOPrefixes = getRemovePageSegmentsUFOPrefixes;
16
17
  exports.getTypingPerformanceTracingMethod = getTypingPerformanceTracingMethod;
17
18
  exports.getUfoNameOverrides = getUfoNameOverrides;
19
+ exports.isVCRevisionEnabled = isVCRevisionEnabled;
18
20
  exports.setUFOConfig = setUFOConfig;
19
21
  var config;
22
+ var DEFAULT_TTVC_REVISION = 'fy25.02';
20
23
 
21
24
  // Defensively typed, since this is directly user-editable
22
25
  // and they could delete empty members
@@ -27,6 +30,24 @@ function setUFOConfig(newConfig) {
27
30
  function getConfig() {
28
31
  return config;
29
32
  }
33
+ function getEnabledVCRevisions() {
34
+ try {
35
+ var _config$vc;
36
+ if (!config) {
37
+ return [];
38
+ }
39
+ if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
40
+ var _config$vc2, _config$vc3;
41
+ return Array.isArray((_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.enabledVCRevisions) && ((_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.enabledVCRevisions.length) > 0 ? config.vc.enabledVCRevisions : [DEFAULT_TTVC_REVISION];
42
+ }
43
+ return [];
44
+ } catch (_unused) {
45
+ return [];
46
+ }
47
+ }
48
+ function isVCRevisionEnabled(revision) {
49
+ return getEnabledVCRevisions().includes(revision);
50
+ }
30
51
  function getInteractionRate(name, interactionKind) {
31
52
  try {
32
53
  if (!config) {
@@ -138,7 +159,7 @@ function getCapabilityRate(capability) {
138
159
  }
139
160
  }
140
161
  return 0;
141
- } catch (_unused) {
162
+ } catch (_unused2) {
142
163
  return 0;
143
164
  }
144
165
  }
@@ -22,7 +22,7 @@ function getVCMetrics(_x) {
22
22
  }
23
23
  function _getVCMetrics() {
24
24
  _getVCMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction) {
25
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI, _config$vc2;
25
+ var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
26
26
  var config, interactionStatus, pageVisibilityUpToTTAI, isSSREnabled, ssr, tti, prefix, result, _result$ufoVcRev, ttvcV2Revision, VC;
27
27
  return _regenerator.default.wrap(function _callee$(_context) {
28
28
  while (1) switch (_context.prev = _context.next) {
@@ -71,7 +71,7 @@ function _getVCMetrics() {
71
71
  (0, _vc.getVCObserver)().stop();
72
72
  }
73
73
  _interactionMetrics.postInteractionLog.setLastInteractionFinishVCResult(result);
74
- if (config !== null && config !== void 0 && (_config$vc2 = config.vc) !== null && _config$vc2 !== void 0 && (_config$vc2 = _config$vc2.enabledVCRevisions) !== null && _config$vc2 !== void 0 && _config$vc2.includes('fy25.01')) {
74
+ if ((0, _config.isVCRevisionEnabled)('fy25.01')) {
75
75
  _context.next = 27;
76
76
  break;
77
77
  }
@@ -12,7 +12,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
15
  var _config = require("../config");
17
16
  var _noOpVcObserver = require("./no-op-vc-observer");
18
17
  var _vcObserver = require("./vc-observer");
@@ -22,12 +21,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
22
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
22
  var VCObserverWrapper = /*#__PURE__*/function () {
24
23
  function VCObserverWrapper() {
25
- var _getConfig;
26
24
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
25
  (0, _classCallCheck2.default)(this, VCObserverWrapper);
28
26
  this.newVCObserver = null;
29
- var isNewVCObserverEnabled = (0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new') || ((_getConfig = (0, _config.getConfig)()) === null || _getConfig === void 0 || (_getConfig = _getConfig.vc) === null || _getConfig === void 0 || (_getConfig = _getConfig.enabledVCRevisions) === null || _getConfig === void 0 ? void 0 : _getConfig.includes('fy25.03'));
30
- if (isNewVCObserverEnabled) {
27
+ if ((0, _config.isVCRevisionEnabled)('fy25.03')) {
31
28
  this.newVCObserver = new _vcObserverNew.default({
32
29
  selectorConfig: opts.selectorConfig
33
30
  });
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getVCRevisionsData = getVCRevisionsData;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
9
  var _config = require("../../config");
11
10
  var _hiddenTiming = require("../../hidden-timing");
12
11
  var _revisions = require("./revisions/revisions");
@@ -46,7 +45,6 @@ function createVCDetails(calculatedVC, shouldHaveVCmetric) {
46
45
 
47
46
  // Optimized implementation (current one)
48
47
  function getVCRevisionsData(_ref) {
49
- var _ufoConfig$vc, _ufoConfig$vc2;
50
48
  var fullPrefix = _ref.fullPrefix,
51
49
  interaction = _ref.interaction,
52
50
  isVCClean = _ref.isVCClean,
@@ -55,8 +53,7 @@ function getVCRevisionsData(_ref) {
55
53
  ssr = _ref.ssr,
56
54
  calculatedVC = _ref.calculatedVC,
57
55
  calculatedVCNext = _ref.calculatedVCNext;
58
- var ufoConfig = (0, _config.getConfig)();
59
- if (!(0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new') && !(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc = ufoConfig.vc) !== null && _ufoConfig$vc !== void 0 && (_ufoConfig$vc = _ufoConfig$vc.enabledVCRevisions) !== null && _ufoConfig$vc !== void 0 && _ufoConfig$vc.includes('fy25.03'))) {
56
+ if (!(0, _config.isVCRevisionEnabled)('fy25.03')) {
60
57
  if (!multiHeatmap) {
61
58
  return null;
62
59
  }
@@ -92,7 +89,7 @@ function getVCRevisionsData(_ref) {
92
89
  'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
93
90
  vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
94
91
  };
95
- if (!(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc2 = ufoConfig.vc) !== null && _ufoConfig$vc2 !== void 0 && (_ufoConfig$vc2 = _ufoConfig$vc2.enabledVCRevisions) !== null && _ufoConfig$vc2 !== void 0 && _ufoConfig$vc2.includes('fy25.01'))) {
92
+ if (!(0, _config.isVCRevisionEnabled)('fy25.01')) {
96
93
  return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [ttvcV2Revision]);
97
94
  }
98
95
 
@@ -45,8 +45,7 @@ function filterComponentsLog(log) {
45
45
  }
46
46
  var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
47
47
  function VCObserver(options) {
48
- var _this = this,
49
- _getConfig5;
48
+ var _this = this;
50
49
  (0, _classCallCheck2.default)(this, VCObserver);
51
50
  /* abort logic */
52
51
  (0, _defineProperty2.default)(this, "abortReason", {
@@ -106,7 +105,6 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
106
105
  });
107
106
  (0, _defineProperty2.default)(this, "getVCResult", /*#__PURE__*/function () {
108
107
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
109
- var _getConfig, _getConfig2;
110
108
  var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, isVCClean, revisionsData, speedIndex, isTTVCv3Enabled;
111
109
  return _regenerator.default.wrap(function _callee$(_context) {
112
110
  while (1) switch (_context.prev = _context.next) {
@@ -122,7 +120,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
122
120
  return _context.abrupt("return", {});
123
121
  case 6:
124
122
  abortReason = rawData.abortReason, abortReasonInfo = rawData.abortReasonInfo, heatmap = rawData.heatmap, heatmapNext = rawData.heatmapNext, outOfBoundaryInfo = rawData.outOfBoundaryInfo, totalTime = rawData.totalTime, componentsLog = rawData.componentsLog, viewport = rawData.viewport, devToolsEnabled = rawData.devToolsEnabled, ratios = rawData.ratios, multiHeatmap = rawData.multiHeatmap;
125
- isTTVCv1Disabled = !((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.vc) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.enabledVCRevisions) !== null && _getConfig !== void 0 && _getConfig.includes('fy25.01')); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
123
+ isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01'); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
126
124
  // we want to report abort by scroll events the same way as other abort reasons
127
125
  // i.e. not have the concept of `abortReason.blocking` anymore
128
126
  if (!(abortReasonInfo !== null && (0, _platformFeatureFlags.fg)('platform_ufo_add_vc_abort_reason_by_revisions'))) {
@@ -319,7 +317,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
319
317
  }
320
318
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
321
319
  case 32:
322
- isTTVCv3Enabled = (0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new') || ((_getConfig2 = (0, _config.getConfig)()) === null || _getConfig2 === void 0 || (_getConfig2 = _getConfig2.vc) === null || _getConfig2 === void 0 || (_getConfig2 = _getConfig2.enabledVCRevisions) === null || _getConfig2 === void 0 ? void 0 : _getConfig2.includes('fy25.03'));
320
+ isTTVCv3Enabled = (0, _config.isVCRevisionEnabled)('fy25.03');
323
321
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
324
322
  'metrics:vc': VC
325
323
  }, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), isVCClean), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), isTTVCv3Enabled ? undefined : VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:total"), totalPainted), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:next"), vcNext.VC), "".concat(fullPrefix, "vc:next:updates"), isTTVCv3Enabled ? undefined : vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
@@ -334,10 +332,9 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
334
332
  };
335
333
  }());
336
334
  (0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) {
337
- var _getConfig3;
338
335
  _this.measureStart();
339
336
  _this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
340
- if (!(0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new') && !((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.enabledVCRevisions) !== null && _getConfig3 !== void 0 && _getConfig3.includes('fy25.03'))) {
337
+ if (!(0, _config.isVCRevisionEnabled)('fy25.03')) {
341
338
  _this.onViewportChangeDetected({
342
339
  timestamp: rawTime,
343
340
  intersectionRect: intersectionRect,
@@ -354,14 +351,13 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
354
351
  });
355
352
  (0, _defineProperty2.default)(this, "legacyHandleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) {
356
353
  if (_this.abortReason.reason === null || _this.abortReason.blocking === false) {
357
- var _getConfig4;
358
354
  var time = Math.round(rawTime - _this.startTime);
359
355
  var mappedValues = _this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
360
356
  _this.vcRatios[targetName] = _this.getElementRatio(mappedValues);
361
357
  if (!ignoreReason) {
362
358
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmapNext);
363
359
  }
364
- var isTTVCv1Disabled = !((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.vc) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.enabledVCRevisions) !== null && _getConfig4 !== void 0 && _getConfig4.includes('fy25.01'));
360
+ var isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01');
365
361
  if (!isTTVCv1Disabled && (!ignoreReason || ignoreReason === 'not-visible') && type !== 'attr') {
366
362
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
367
363
  }
@@ -499,7 +495,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
499
495
  dataVC: true
500
496
  }
501
497
  });
502
- this.heatmap = !((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.vc) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.enabledVCRevisions) !== null && _getConfig5 !== void 0 && _getConfig5.includes('fy25.01')) ? [] : this.getCleanHeatmap();
498
+ this.heatmap = !(0, _config.isVCRevisionEnabled)('fy25.01') ? [] : this.getCleanHeatmap();
503
499
  this.heatmapNext = this.getCleanHeatmap();
504
500
  this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
505
501
  viewport: this.viewport,
@@ -579,7 +575,6 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
579
575
  }, {
580
576
  key: "resetState",
581
577
  value: function resetState() {
582
- var _getConfig6;
583
578
  this.abortReason = {
584
579
  reason: null,
585
580
  info: '',
@@ -587,7 +582,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
587
582
  blocking: false
588
583
  };
589
584
  this.detachAbortListeners();
590
- this.heatmap = !((_getConfig6 = (0, _config.getConfig)()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.vc) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.enabledVCRevisions) !== null && _getConfig6 !== void 0 && _getConfig6.includes('fy25.01')) ? [] : this.getCleanHeatmap();
585
+ this.heatmap = !(0, _config.isVCRevisionEnabled)('fy25.01') ? [] : this.getCleanHeatmap();
591
586
  this.heatmapNext = this.getCleanHeatmap();
592
587
  this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
593
588
  viewport: this.viewport,
@@ -8,8 +8,7 @@ var _config = require("../../../config");
8
8
  var _fy25_ = require("./fy25_01");
9
9
  var _fy25_2 = require("./fy25_02");
10
10
  function getRevisions() {
11
- var _getConfig;
12
- if (!((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.vc) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.enabledVCRevisions) !== null && _getConfig !== void 0 && _getConfig.includes('fy25.01'))) {
11
+ if (!(0, _config.isVCRevisionEnabled)('fy25.01')) {
13
12
  return [{
14
13
  name: 'fy25.02',
15
14
  classifier: _fy25_2.revFY25_02Classifier
@@ -44,19 +44,31 @@ function sameRectDimensions(a, b) {
44
44
  }
45
45
  return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;
46
46
  }
47
+ var createElementMutationsWatcher = function createElementMutationsWatcher(removedNodeRects) {
48
+ return function (_ref) {
49
+ var rect = _ref.rect;
50
+ var wasDeleted = removedNodeRects.some(function (nr) {
51
+ return sameRectDimensions(nr, rect);
52
+ });
53
+ if (wasDeleted) {
54
+ return 'mutation:element-replacement';
55
+ }
56
+ return 'mutation:element';
57
+ };
58
+ };
47
59
  var ViewportObserver = exports.default = /*#__PURE__*/function () {
48
- function ViewportObserver(_ref) {
60
+ function ViewportObserver(_ref2) {
49
61
  var _this = this;
50
- var onChange = _ref.onChange;
62
+ var onChange = _ref2.onChange;
51
63
  (0, _classCallCheck2.default)(this, ViewportObserver);
52
64
  this.mapVisibleNodeRects = new WeakMap();
53
65
  this.intersectionObserver = (0, _intersectionObserver.createIntersectionObserver)({
54
- onEntry: function onEntry(_ref2) {
55
- var target = _ref2.target,
56
- rect = _ref2.rect,
57
- time = _ref2.time,
58
- type = _ref2.type,
59
- mutationData = _ref2.mutationData;
66
+ onEntry: function onEntry(_ref3) {
67
+ var target = _ref3.target,
68
+ rect = _ref3.rect,
69
+ time = _ref3.time,
70
+ type = _ref3.type,
71
+ mutationData = _ref3.mutationData;
60
72
  if (!target) {
61
73
  return;
62
74
  }
@@ -75,10 +87,10 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
75
87
  }
76
88
  });
77
89
  this.mutationObserver = (0, _mutationObserver.default)({
78
- onChildListMutation: function onChildListMutation(_ref3) {
90
+ onChildListMutation: function onChildListMutation(_ref4) {
79
91
  var _removedNodes$map;
80
- var addedNodes = _ref3.addedNodes,
81
- removedNodes = _ref3.removedNodes;
92
+ var addedNodes = _ref4.addedNodes,
93
+ removedNodes = _ref4.removedNodes;
82
94
  var removedNodeRects = (_removedNodes$map = removedNodes === null || removedNodes === void 0 ? void 0 : removedNodes.map(function (n) {
83
95
  return _this.mapVisibleNodeRects.get(n);
84
96
  })) !== null && _removedNodes$map !== void 0 ? _removedNodes$map : [];
@@ -101,16 +113,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
101
113
  (_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
102
114
  return;
103
115
  }
104
- (_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, function (_ref4) {
105
- var rect = _ref4.rect;
106
- var wasDeleted = removedNodeRects.some(function (nr) {
107
- return sameRectDimensions(nr, rect);
108
- });
109
- if (wasDeleted) {
110
- return 'mutation:element-replacement';
111
- }
112
- return 'mutation:element';
113
- });
116
+ (_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
114
117
  });
115
118
  },
116
119
  onAttributeMutation: function onAttributeMutation(_ref5) {
@@ -1,4 +1,5 @@
1
1
  let config;
2
+ const DEFAULT_TTVC_REVISION = 'fy25.02';
2
3
 
3
4
  // Defensively typed, since this is directly user-editable
4
5
  // and they could delete empty members
@@ -9,6 +10,24 @@ export function setUFOConfig(newConfig) {
9
10
  export function getConfig() {
10
11
  return config;
11
12
  }
13
+ export function getEnabledVCRevisions() {
14
+ try {
15
+ var _config$vc;
16
+ if (!config) {
17
+ return [];
18
+ }
19
+ if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
20
+ var _config$vc2, _config$vc3;
21
+ return Array.isArray((_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.enabledVCRevisions) && ((_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.enabledVCRevisions.length) > 0 ? config.vc.enabledVCRevisions : [DEFAULT_TTVC_REVISION];
22
+ }
23
+ return [];
24
+ } catch {
25
+ return [];
26
+ }
27
+ }
28
+ export function isVCRevisionEnabled(revision) {
29
+ return getEnabledVCRevisions().includes(revision);
30
+ }
12
31
  export function getInteractionRate(name, interactionKind) {
13
32
  try {
14
33
  if (!config) {
@@ -1,12 +1,12 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
- import { getConfig } from '../../config';
2
+ import { getConfig, isVCRevisionEnabled } from '../../config';
3
3
  import { postInteractionLog } from '../../interaction-metrics';
4
4
  import { getVCObserver } from '../../vc';
5
5
  import getInteractionStatus from './get-interaction-status';
6
6
  import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
7
7
  import getSSRDoneTimeValue from './get-ssr-done-time-value';
8
8
  async function getVCMetrics(interaction) {
9
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI, _config$vc2, _config$vc2$enabledVC;
9
+ var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI;
10
10
  const config = getConfig();
11
11
  if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
12
12
  return {};
@@ -40,7 +40,7 @@ async function getVCMetrics(interaction) {
40
40
  getVCObserver().stop();
41
41
  }
42
42
  postInteractionLog.setLastInteractionFinishVCResult(result);
43
- if (!(config !== null && config !== void 0 && (_config$vc2 = config.vc) !== null && _config$vc2 !== void 0 && (_config$vc2$enabledVC = _config$vc2.enabledVCRevisions) !== null && _config$vc2$enabledVC !== void 0 && _config$vc2$enabledVC.includes('fy25.01'))) {
43
+ if (!isVCRevisionEnabled('fy25.01')) {
44
44
  var _result$ufoVcRev;
45
45
  const ttvcV2Revision = result === null || result === void 0 ? void 0 : (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(({
46
46
  revision
@@ -1,15 +1,12 @@
1
1
  var _process, _process$env;
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- import { getConfig } from '../config';
2
+ import { isVCRevisionEnabled } from '../config';
4
3
  import { VCObserverNOOP } from './no-op-vc-observer';
5
4
  import { VCObserver } from './vc-observer';
6
5
  import VCObserverNew from './vc-observer-new';
7
6
  class VCObserverWrapper {
8
7
  constructor(opts = {}) {
9
- var _getConfig, _getConfig$vc, _getConfig$vc$enabled;
10
8
  this.newVCObserver = null;
11
- const isNewVCObserverEnabled = fg('platform_ufo_vc_observer_new') || ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : (_getConfig$vc = _getConfig.vc) === null || _getConfig$vc === void 0 ? void 0 : (_getConfig$vc$enabled = _getConfig$vc.enabledVCRevisions) === null || _getConfig$vc$enabled === void 0 ? void 0 : _getConfig$vc$enabled.includes('fy25.03'));
12
- if (isNewVCObserverEnabled) {
9
+ if (isVCRevisionEnabled('fy25.03')) {
13
10
  this.newVCObserver = new VCObserverNew({
14
11
  selectorConfig: opts.selectorConfig
15
12
  });
@@ -1,5 +1,4 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
- import { getConfig } from '../../config';
1
+ import { isVCRevisionEnabled } from '../../config';
3
2
  import { getPageVisibilityState } from '../../hidden-timing';
4
3
  import { getRevisions } from './revisions/revisions';
5
4
  const VCParts = ['25', '50', '75', '80', '85', '90', '95', '98', '99'];
@@ -38,9 +37,7 @@ export function getVCRevisionsData({
38
37
  calculatedVC,
39
38
  calculatedVCNext
40
39
  }) {
41
- var _ufoConfig$vc, _ufoConfig$vc$enabled, _ufoConfig$vc2, _ufoConfig$vc2$enable;
42
- const ufoConfig = getConfig();
43
- if (!fg('platform_ufo_vc_observer_new') && !(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc = ufoConfig.vc) !== null && _ufoConfig$vc !== void 0 && (_ufoConfig$vc$enabled = _ufoConfig$vc.enabledVCRevisions) !== null && _ufoConfig$vc$enabled !== void 0 && _ufoConfig$vc$enabled.includes('fy25.03'))) {
40
+ if (!isVCRevisionEnabled('fy25.03')) {
44
41
  if (!multiHeatmap) {
45
42
  return null;
46
43
  }
@@ -74,7 +71,7 @@ export function getVCRevisionsData({
74
71
  'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
75
72
  vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
76
73
  };
77
- if (!(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc2 = ufoConfig.vc) !== null && _ufoConfig$vc2 !== void 0 && (_ufoConfig$vc2$enable = _ufoConfig$vc2.enabledVCRevisions) !== null && _ufoConfig$vc2$enable !== void 0 && _ufoConfig$vc2$enable.includes('fy25.01'))) {
74
+ if (!isVCRevisionEnabled('fy25.01')) {
78
75
  return {
79
76
  [`${fullPrefix}vc:rev`]: [ttvcV2Revision]
80
77
  };
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- import { getConfig } from '../../config';
3
+ import { isVCRevisionEnabled } from '../../config';
4
4
  import { attachAbortListeners } from './attachAbortListeners';
5
5
  import { getVCRevisionsData } from './getVCRevisionsData';
6
6
  import { getViewportHeight, getViewportWidth } from './getViewport';
@@ -25,7 +25,6 @@ function filterComponentsLog(log) {
25
25
  }
26
26
  export class VCObserver {
27
27
  constructor(options) {
28
- var _getConfig5, _getConfig5$vc, _getConfig5$vc$enable;
29
28
  /* abort logic */
30
29
  _defineProperty(this, "abortReason", {
31
30
  reason: null,
@@ -97,7 +96,6 @@ export class VCObserver {
97
96
  vc,
98
97
  isEventAborted
99
98
  }) => {
100
- var _getConfig, _getConfig$vc, _getConfig$vc$enabled, _getConfig2, _getConfig2$vc, _getConfig2$vc$enable;
101
99
  const startTime = performance.now();
102
100
  // add local measurement
103
101
  const fullPrefix = prefix !== undefined && prefix !== '' ? `${prefix}:` : '';
@@ -118,7 +116,7 @@ export class VCObserver {
118
116
  ratios,
119
117
  multiHeatmap
120
118
  } = rawData;
121
- const isTTVCv1Disabled = !((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$vc = _getConfig.vc) !== null && _getConfig$vc !== void 0 && (_getConfig$vc$enabled = _getConfig$vc.enabledVCRevisions) !== null && _getConfig$vc$enabled !== void 0 && _getConfig$vc$enabled.includes('fy25.01'));
119
+ const isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01');
122
120
 
123
121
  // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
124
122
  // we want to report abort by scroll events the same way as other abort reasons
@@ -337,7 +335,7 @@ export class VCObserver {
337
335
  ...speedIndex
338
336
  };
339
337
  }
340
- const isTTVCv3Enabled = fg('platform_ufo_vc_observer_new') || ((_getConfig2 = getConfig()) === null || _getConfig2 === void 0 ? void 0 : (_getConfig2$vc = _getConfig2.vc) === null || _getConfig2$vc === void 0 ? void 0 : (_getConfig2$vc$enable = _getConfig2$vc.enabledVCRevisions) === null || _getConfig2$vc$enable === void 0 ? void 0 : _getConfig2$vc$enable.includes('fy25.03'));
338
+ const isTTVCv3Enabled = isVCRevisionEnabled('fy25.03');
341
339
  return {
342
340
  'metrics:vc': VC,
343
341
  [`${fullPrefix}vc:state`]: true,
@@ -360,10 +358,9 @@ export class VCObserver {
360
358
  };
361
359
  });
362
360
  _defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
363
- var _getConfig3, _getConfig3$vc, _getConfig3$vc$enable;
364
361
  this.measureStart();
365
362
  this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
366
- if (!fg('platform_ufo_vc_observer_new') && !((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$vc = _getConfig3.vc) !== null && _getConfig3$vc !== void 0 && (_getConfig3$vc$enable = _getConfig3$vc.enabledVCRevisions) !== null && _getConfig3$vc$enable !== void 0 && _getConfig3$vc$enable.includes('fy25.03'))) {
363
+ if (!isVCRevisionEnabled('fy25.03')) {
367
364
  this.onViewportChangeDetected({
368
365
  timestamp: rawTime,
369
366
  intersectionRect,
@@ -380,14 +377,13 @@ export class VCObserver {
380
377
  });
381
378
  _defineProperty(this, "legacyHandleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
382
379
  if (this.abortReason.reason === null || this.abortReason.blocking === false) {
383
- var _getConfig4, _getConfig4$vc, _getConfig4$vc$enable;
384
380
  const time = Math.round(rawTime - this.startTime);
385
381
  const mappedValues = this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
386
382
  this.vcRatios[targetName] = this.getElementRatio(mappedValues);
387
383
  if (!ignoreReason) {
388
384
  this.applyChangesToHeatMap(mappedValues, time, this.heatmapNext);
389
385
  }
390
- const isTTVCv1Disabled = !((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$vc = _getConfig4.vc) !== null && _getConfig4$vc !== void 0 && (_getConfig4$vc$enable = _getConfig4$vc.enabledVCRevisions) !== null && _getConfig4$vc$enable !== void 0 && _getConfig4$vc$enable.includes('fy25.01'));
386
+ const isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01');
391
387
  if (!isTTVCv1Disabled && (!ignoreReason || ignoreReason === 'not-visible') && type !== 'attr') {
392
388
  this.applyChangesToHeatMap(mappedValues, time, this.heatmap);
393
389
  }
@@ -526,7 +522,7 @@ export class VCObserver {
526
522
  dataVC: true
527
523
  }
528
524
  });
529
- this.heatmap = !((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$vc = _getConfig5.vc) !== null && _getConfig5$vc !== void 0 && (_getConfig5$vc$enable = _getConfig5$vc.enabledVCRevisions) !== null && _getConfig5$vc$enable !== void 0 && _getConfig5$vc$enable.includes('fy25.01')) ? [] : this.getCleanHeatmap();
525
+ this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
530
526
  this.heatmapNext = this.getCleanHeatmap();
531
527
  this.multiHeatmap = new MultiRevisionHeatmap({
532
528
  viewport: this.viewport,
@@ -675,7 +671,6 @@ export class VCObserver {
675
671
  }
676
672
  }
677
673
  resetState() {
678
- var _getConfig6, _getConfig6$vc, _getConfig6$vc$enable;
679
674
  this.abortReason = {
680
675
  reason: null,
681
676
  info: '',
@@ -683,7 +678,7 @@ export class VCObserver {
683
678
  blocking: false
684
679
  };
685
680
  this.detachAbortListeners();
686
- this.heatmap = !((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6$vc = _getConfig6.vc) !== null && _getConfig6$vc !== void 0 && (_getConfig6$vc$enable = _getConfig6$vc.enabledVCRevisions) !== null && _getConfig6$vc$enable !== void 0 && _getConfig6$vc$enable.includes('fy25.01')) ? [] : this.getCleanHeatmap();
681
+ this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
687
682
  this.heatmapNext = this.getCleanHeatmap();
688
683
  this.multiHeatmap = new MultiRevisionHeatmap({
689
684
  viewport: this.viewport,
@@ -1,9 +1,8 @@
1
- import { getConfig } from '../../../config';
1
+ import { isVCRevisionEnabled } from '../../../config';
2
2
  import { revFY25_01Classifier } from './fy25_01';
3
3
  import { revFY25_02Classifier } from './fy25_02';
4
4
  export function getRevisions() {
5
- var _getConfig, _getConfig$vc, _getConfig$vc$enabled;
6
- if (!((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$vc = _getConfig.vc) !== null && _getConfig$vc !== void 0 && (_getConfig$vc$enabled = _getConfig$vc.enabledVCRevisions) !== null && _getConfig$vc$enabled !== void 0 && _getConfig$vc$enabled.includes('fy25.01'))) {
5
+ if (!isVCRevisionEnabled('fy25.01')) {
7
6
  return [{
8
7
  name: 'fy25.02',
9
8
  classifier: revFY25_02Classifier
@@ -32,6 +32,15 @@ function sameRectDimensions(a, b) {
32
32
  }
33
33
  return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;
34
34
  }
35
+ const createElementMutationsWatcher = removedNodeRects => ({
36
+ rect
37
+ }) => {
38
+ const wasDeleted = removedNodeRects.some(nr => sameRectDimensions(nr, rect));
39
+ if (wasDeleted) {
40
+ return 'mutation:element-replacement';
41
+ }
42
+ return 'mutation:element';
43
+ };
35
44
  export default class ViewportObserver {
36
45
  constructor({
37
46
  onChange: onChange
@@ -86,15 +95,7 @@ export default class ViewportObserver {
86
95
  (_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 ? void 0 : _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
87
96
  return;
88
97
  }
89
- (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, ({
90
- rect
91
- }) => {
92
- const wasDeleted = removedNodeRects.some(nr => sameRectDimensions(nr, rect));
93
- if (wasDeleted) {
94
- return 'mutation:element-replacement';
95
- }
96
- return 'mutation:element';
97
- });
98
+ (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
98
99
  });
99
100
  },
100
101
  onAttributeMutation: ({
@@ -1,4 +1,5 @@
1
1
  var config;
2
+ var DEFAULT_TTVC_REVISION = 'fy25.02';
2
3
 
3
4
  // Defensively typed, since this is directly user-editable
4
5
  // and they could delete empty members
@@ -9,6 +10,24 @@ export function setUFOConfig(newConfig) {
9
10
  export function getConfig() {
10
11
  return config;
11
12
  }
13
+ export function getEnabledVCRevisions() {
14
+ try {
15
+ var _config$vc;
16
+ if (!config) {
17
+ return [];
18
+ }
19
+ if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
20
+ var _config$vc2, _config$vc3;
21
+ return Array.isArray((_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.enabledVCRevisions) && ((_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.enabledVCRevisions.length) > 0 ? config.vc.enabledVCRevisions : [DEFAULT_TTVC_REVISION];
22
+ }
23
+ return [];
24
+ } catch (_unused) {
25
+ return [];
26
+ }
27
+ }
28
+ export function isVCRevisionEnabled(revision) {
29
+ return getEnabledVCRevisions().includes(revision);
30
+ }
12
31
  export function getInteractionRate(name, interactionKind) {
13
32
  try {
14
33
  if (!config) {
@@ -120,7 +139,7 @@ export function getCapabilityRate(capability) {
120
139
  }
121
140
  }
122
141
  return 0;
123
- } catch (_unused) {
142
+ } catch (_unused2) {
124
143
  return 0;
125
144
  }
126
145
  }
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { getConfig } from '../../config';
7
+ import { getConfig, isVCRevisionEnabled } from '../../config';
8
8
  import { postInteractionLog } from '../../interaction-metrics';
9
9
  import { getVCObserver } from '../../vc';
10
10
  import getInteractionStatus from './get-interaction-status';
@@ -15,7 +15,7 @@ function getVCMetrics(_x) {
15
15
  }
16
16
  function _getVCMetrics() {
17
17
  _getVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
18
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI, _config$vc2;
18
+ var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
19
19
  var config, interactionStatus, pageVisibilityUpToTTAI, isSSREnabled, ssr, tti, prefix, result, _result$ufoVcRev, ttvcV2Revision, VC;
20
20
  return _regeneratorRuntime.wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
@@ -64,7 +64,7 @@ function _getVCMetrics() {
64
64
  getVCObserver().stop();
65
65
  }
66
66
  postInteractionLog.setLastInteractionFinishVCResult(result);
67
- if (config !== null && config !== void 0 && (_config$vc2 = config.vc) !== null && _config$vc2 !== void 0 && (_config$vc2 = _config$vc2.enabledVCRevisions) !== null && _config$vc2 !== void 0 && _config$vc2.includes('fy25.01')) {
67
+ if (isVCRevisionEnabled('fy25.01')) {
68
68
  _context.next = 27;
69
69
  break;
70
70
  }
@@ -7,19 +7,16 @@ var _process;
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
- import { getConfig } from '../config';
10
+ import { isVCRevisionEnabled } from '../config';
12
11
  import { VCObserverNOOP } from './no-op-vc-observer';
13
12
  import { VCObserver } from './vc-observer';
14
13
  import VCObserverNew from './vc-observer-new';
15
14
  var VCObserverWrapper = /*#__PURE__*/function () {
16
15
  function VCObserverWrapper() {
17
- var _getConfig;
18
16
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19
17
  _classCallCheck(this, VCObserverWrapper);
20
18
  this.newVCObserver = null;
21
- var isNewVCObserverEnabled = fg('platform_ufo_vc_observer_new') || ((_getConfig = getConfig()) === null || _getConfig === void 0 || (_getConfig = _getConfig.vc) === null || _getConfig === void 0 || (_getConfig = _getConfig.enabledVCRevisions) === null || _getConfig === void 0 ? void 0 : _getConfig.includes('fy25.03'));
22
- if (isNewVCObserverEnabled) {
19
+ if (isVCRevisionEnabled('fy25.03')) {
23
20
  this.newVCObserver = new VCObserverNew({
24
21
  selectorConfig: opts.selectorConfig
25
22
  });
@@ -2,8 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
3
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
- import { getConfig } from '../../config';
5
+ import { isVCRevisionEnabled } from '../../config';
7
6
  import { getPageVisibilityState } from '../../hidden-timing';
8
7
  import { getRevisions } from './revisions/revisions';
9
8
  var VCParts = ['25', '50', '75', '80', '85', '90', '95', '98', '99'];
@@ -39,7 +38,6 @@ function createVCDetails(calculatedVC, shouldHaveVCmetric) {
39
38
 
40
39
  // Optimized implementation (current one)
41
40
  export function getVCRevisionsData(_ref) {
42
- var _ufoConfig$vc, _ufoConfig$vc2;
43
41
  var fullPrefix = _ref.fullPrefix,
44
42
  interaction = _ref.interaction,
45
43
  isVCClean = _ref.isVCClean,
@@ -48,8 +46,7 @@ export function getVCRevisionsData(_ref) {
48
46
  ssr = _ref.ssr,
49
47
  calculatedVC = _ref.calculatedVC,
50
48
  calculatedVCNext = _ref.calculatedVCNext;
51
- var ufoConfig = getConfig();
52
- if (!fg('platform_ufo_vc_observer_new') && !(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc = ufoConfig.vc) !== null && _ufoConfig$vc !== void 0 && (_ufoConfig$vc = _ufoConfig$vc.enabledVCRevisions) !== null && _ufoConfig$vc !== void 0 && _ufoConfig$vc.includes('fy25.03'))) {
49
+ if (!isVCRevisionEnabled('fy25.03')) {
53
50
  if (!multiHeatmap) {
54
51
  return null;
55
52
  }
@@ -85,7 +82,7 @@ export function getVCRevisionsData(_ref) {
85
82
  'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
86
83
  vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
87
84
  };
88
- if (!(ufoConfig !== null && ufoConfig !== void 0 && (_ufoConfig$vc2 = ufoConfig.vc) !== null && _ufoConfig$vc2 !== void 0 && (_ufoConfig$vc2 = _ufoConfig$vc2.enabledVCRevisions) !== null && _ufoConfig$vc2 !== void 0 && _ufoConfig$vc2.includes('fy25.01'))) {
85
+ if (!isVCRevisionEnabled('fy25.01')) {
89
86
  return _defineProperty({}, "".concat(fullPrefix, "vc:rev"), [ttvcV2Revision]);
90
87
  }
91
88
 
@@ -10,7 +10,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
- import { getConfig } from '../../config';
13
+ import { isVCRevisionEnabled } from '../../config';
14
14
  import { attachAbortListeners } from './attachAbortListeners';
15
15
  import { getVCRevisionsData } from './getVCRevisionsData';
16
16
  import { getViewportHeight, getViewportWidth } from './getViewport';
@@ -38,8 +38,7 @@ function filterComponentsLog(log) {
38
38
  }
39
39
  export var VCObserver = /*#__PURE__*/function () {
40
40
  function VCObserver(options) {
41
- var _this = this,
42
- _getConfig5;
41
+ var _this = this;
43
42
  _classCallCheck(this, VCObserver);
44
43
  /* abort logic */
45
44
  _defineProperty(this, "abortReason", {
@@ -99,7 +98,6 @@ export var VCObserver = /*#__PURE__*/function () {
99
98
  });
100
99
  _defineProperty(this, "getVCResult", /*#__PURE__*/function () {
101
100
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
102
- var _getConfig, _getConfig2;
103
101
  var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, isVCClean, revisionsData, speedIndex, isTTVCv3Enabled;
104
102
  return _regeneratorRuntime.wrap(function _callee$(_context) {
105
103
  while (1) switch (_context.prev = _context.next) {
@@ -115,7 +113,7 @@ export var VCObserver = /*#__PURE__*/function () {
115
113
  return _context.abrupt("return", {});
116
114
  case 6:
117
115
  abortReason = rawData.abortReason, abortReasonInfo = rawData.abortReasonInfo, heatmap = rawData.heatmap, heatmapNext = rawData.heatmapNext, outOfBoundaryInfo = rawData.outOfBoundaryInfo, totalTime = rawData.totalTime, componentsLog = rawData.componentsLog, viewport = rawData.viewport, devToolsEnabled = rawData.devToolsEnabled, ratios = rawData.ratios, multiHeatmap = rawData.multiHeatmap;
118
- isTTVCv1Disabled = !((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.vc) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.enabledVCRevisions) !== null && _getConfig !== void 0 && _getConfig.includes('fy25.01')); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
116
+ isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01'); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
119
117
  // we want to report abort by scroll events the same way as other abort reasons
120
118
  // i.e. not have the concept of `abortReason.blocking` anymore
121
119
  if (!(abortReasonInfo !== null && fg('platform_ufo_add_vc_abort_reason_by_revisions'))) {
@@ -312,7 +310,7 @@ export var VCObserver = /*#__PURE__*/function () {
312
310
  }
313
311
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_defineProperty(_defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, _defineProperty({}, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
314
312
  case 32:
315
- isTTVCv3Enabled = fg('platform_ufo_vc_observer_new') || ((_getConfig2 = getConfig()) === null || _getConfig2 === void 0 || (_getConfig2 = _getConfig2.vc) === null || _getConfig2 === void 0 || (_getConfig2 = _getConfig2.enabledVCRevisions) === null || _getConfig2 === void 0 ? void 0 : _getConfig2.includes('fy25.03'));
313
+ isTTVCv3Enabled = isVCRevisionEnabled('fy25.03');
316
314
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
317
315
  'metrics:vc': VC
318
316
  }, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), isVCClean), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), isTTVCv3Enabled ? undefined : VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:total"), totalPainted), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:next"), vcNext.VC), "".concat(fullPrefix, "vc:next:updates"), isTTVCv3Enabled ? undefined : vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
@@ -327,10 +325,9 @@ export var VCObserver = /*#__PURE__*/function () {
327
325
  };
328
326
  }());
329
327
  _defineProperty(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) {
330
- var _getConfig3;
331
328
  _this.measureStart();
332
329
  _this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
333
- if (!fg('platform_ufo_vc_observer_new') && !((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.enabledVCRevisions) !== null && _getConfig3 !== void 0 && _getConfig3.includes('fy25.03'))) {
330
+ if (!isVCRevisionEnabled('fy25.03')) {
334
331
  _this.onViewportChangeDetected({
335
332
  timestamp: rawTime,
336
333
  intersectionRect: intersectionRect,
@@ -347,14 +344,13 @@ export var VCObserver = /*#__PURE__*/function () {
347
344
  });
348
345
  _defineProperty(this, "legacyHandleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) {
349
346
  if (_this.abortReason.reason === null || _this.abortReason.blocking === false) {
350
- var _getConfig4;
351
347
  var time = Math.round(rawTime - _this.startTime);
352
348
  var mappedValues = _this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
353
349
  _this.vcRatios[targetName] = _this.getElementRatio(mappedValues);
354
350
  if (!ignoreReason) {
355
351
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmapNext);
356
352
  }
357
- var isTTVCv1Disabled = !((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.vc) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.enabledVCRevisions) !== null && _getConfig4 !== void 0 && _getConfig4.includes('fy25.01'));
353
+ var isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01');
358
354
  if (!isTTVCv1Disabled && (!ignoreReason || ignoreReason === 'not-visible') && type !== 'attr') {
359
355
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
360
356
  }
@@ -492,7 +488,7 @@ export var VCObserver = /*#__PURE__*/function () {
492
488
  dataVC: true
493
489
  }
494
490
  });
495
- this.heatmap = !((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.vc) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.enabledVCRevisions) !== null && _getConfig5 !== void 0 && _getConfig5.includes('fy25.01')) ? [] : this.getCleanHeatmap();
491
+ this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
496
492
  this.heatmapNext = this.getCleanHeatmap();
497
493
  this.multiHeatmap = new MultiRevisionHeatmap({
498
494
  viewport: this.viewport,
@@ -572,7 +568,6 @@ export var VCObserver = /*#__PURE__*/function () {
572
568
  }, {
573
569
  key: "resetState",
574
570
  value: function resetState() {
575
- var _getConfig6;
576
571
  this.abortReason = {
577
572
  reason: null,
578
573
  info: '',
@@ -580,7 +575,7 @@ export var VCObserver = /*#__PURE__*/function () {
580
575
  blocking: false
581
576
  };
582
577
  this.detachAbortListeners();
583
- this.heatmap = !((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.vc) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.enabledVCRevisions) !== null && _getConfig6 !== void 0 && _getConfig6.includes('fy25.01')) ? [] : this.getCleanHeatmap();
578
+ this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
584
579
  this.heatmapNext = this.getCleanHeatmap();
585
580
  this.multiHeatmap = new MultiRevisionHeatmap({
586
581
  viewport: this.viewport,
@@ -1,9 +1,8 @@
1
- import { getConfig } from '../../../config';
1
+ import { isVCRevisionEnabled } from '../../../config';
2
2
  import { revFY25_01Classifier } from './fy25_01';
3
3
  import { revFY25_02Classifier } from './fy25_02';
4
4
  export function getRevisions() {
5
- var _getConfig;
6
- if (!((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.vc) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.enabledVCRevisions) !== null && _getConfig !== void 0 && _getConfig.includes('fy25.01'))) {
5
+ if (!isVCRevisionEnabled('fy25.01')) {
7
6
  return [{
8
7
  name: 'fy25.02',
9
8
  classifier: revFY25_02Classifier
@@ -37,19 +37,31 @@ function sameRectDimensions(a, b) {
37
37
  }
38
38
  return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;
39
39
  }
40
+ var createElementMutationsWatcher = function createElementMutationsWatcher(removedNodeRects) {
41
+ return function (_ref) {
42
+ var rect = _ref.rect;
43
+ var wasDeleted = removedNodeRects.some(function (nr) {
44
+ return sameRectDimensions(nr, rect);
45
+ });
46
+ if (wasDeleted) {
47
+ return 'mutation:element-replacement';
48
+ }
49
+ return 'mutation:element';
50
+ };
51
+ };
40
52
  var ViewportObserver = /*#__PURE__*/function () {
41
- function ViewportObserver(_ref) {
53
+ function ViewportObserver(_ref2) {
42
54
  var _this = this;
43
- var onChange = _ref.onChange;
55
+ var onChange = _ref2.onChange;
44
56
  _classCallCheck(this, ViewportObserver);
45
57
  this.mapVisibleNodeRects = new WeakMap();
46
58
  this.intersectionObserver = createIntersectionObserver({
47
- onEntry: function onEntry(_ref2) {
48
- var target = _ref2.target,
49
- rect = _ref2.rect,
50
- time = _ref2.time,
51
- type = _ref2.type,
52
- mutationData = _ref2.mutationData;
59
+ onEntry: function onEntry(_ref3) {
60
+ var target = _ref3.target,
61
+ rect = _ref3.rect,
62
+ time = _ref3.time,
63
+ type = _ref3.type,
64
+ mutationData = _ref3.mutationData;
53
65
  if (!target) {
54
66
  return;
55
67
  }
@@ -68,10 +80,10 @@ var ViewportObserver = /*#__PURE__*/function () {
68
80
  }
69
81
  });
70
82
  this.mutationObserver = createMutationObserver({
71
- onChildListMutation: function onChildListMutation(_ref3) {
83
+ onChildListMutation: function onChildListMutation(_ref4) {
72
84
  var _removedNodes$map;
73
- var addedNodes = _ref3.addedNodes,
74
- removedNodes = _ref3.removedNodes;
85
+ var addedNodes = _ref4.addedNodes,
86
+ removedNodes = _ref4.removedNodes;
75
87
  var removedNodeRects = (_removedNodes$map = removedNodes === null || removedNodes === void 0 ? void 0 : removedNodes.map(function (n) {
76
88
  return _this.mapVisibleNodeRects.get(n);
77
89
  })) !== null && _removedNodes$map !== void 0 ? _removedNodes$map : [];
@@ -94,16 +106,7 @@ var ViewportObserver = /*#__PURE__*/function () {
94
106
  (_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
95
107
  return;
96
108
  }
97
- (_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, function (_ref4) {
98
- var rect = _ref4.rect;
99
- var wasDeleted = removedNodeRects.some(function (nr) {
100
- return sameRectDimensions(nr, rect);
101
- });
102
- if (wasDeleted) {
103
- return 'mutation:element-replacement';
104
- }
105
- return 'mutation:element';
106
- });
109
+ (_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
107
110
  });
108
111
  },
109
112
  onAttributeMutation: function onAttributeMutation(_ref5) {
@@ -99,6 +99,8 @@ export type Config = {
99
99
  };
100
100
  export declare function setUFOConfig(newConfig: Config): void;
101
101
  export declare function getConfig(): Config | undefined;
102
+ export declare function getEnabledVCRevisions(): TTVCRevisions[];
103
+ export declare function isVCRevisionEnabled(revision: TTVCRevisions): boolean;
102
104
  export declare function getInteractionRate(name: string, interactionKind: InteractionKind): number;
103
105
  export declare function getExperimentalInteractionRate(name: string, interactionType: InteractionType): number;
104
106
  export declare function getPostInteractionRate(name: string, interactionType: InteractionType): number;
@@ -99,6 +99,8 @@ export type Config = {
99
99
  };
100
100
  export declare function setUFOConfig(newConfig: Config): void;
101
101
  export declare function getConfig(): Config | undefined;
102
+ export declare function getEnabledVCRevisions(): TTVCRevisions[];
103
+ export declare function isVCRevisionEnabled(revision: TTVCRevisions): boolean;
102
104
  export declare function getInteractionRate(name: string, interactionKind: InteractionKind): number;
103
105
  export declare function getExperimentalInteractionRate(name: string, interactionType: InteractionType): number;
104
106
  export declare function getPostInteractionRate(name: string, interactionType: InteractionType): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "3.10.0",
3
+ "version": "3.10.2",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -133,9 +133,6 @@
133
133
  "ufo_return_relative_request_start": {
134
134
  "type": "boolean"
135
135
  },
136
- "platform_ufo_vc_observer_new": {
137
- "type": "boolean"
138
- },
139
136
  "platform_ufo_add_vc_abort_reason_by_revisions": {
140
137
  "type": "boolean"
141
138
  },