@atlaskit/react-ufo 4.7.4 → 4.7.6

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,19 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.7.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`71df791f80bf5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/71df791f80bf5) -
8
+ Remove TTVC debug data for post-interaction-log events
9
+
10
+ ## 4.7.5
11
+
12
+ ### Patch Changes
13
+
14
+ - [`1a2a53c0d8141`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1a2a53c0d8141) -
15
+ Ignore style mutations from adding drag and drop anchor names
16
+
3
17
  ## 4.7.4
4
18
 
5
19
  ### Patch Changes
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _featureFlagsAccessed = require("../../../../feature-flags-accessed");
11
+ 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; } } }; }
12
+ 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; } }
13
+ 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; }
14
+ // copied from '@atlaskit/tmp-editor-statsig/expVal' to avoid circular dependency
15
+ var expVal = function expVal(experimentName, experimentParam, defaultValue) {
16
+ // If client is not initialized, we return the default value
17
+ if (!_featureGateJsClient.default.initializeCompleted()) {
18
+ return defaultValue;
19
+ }
20
+
21
+ // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
22
+ var experimentValue = _featureGateJsClient.default.getExperimentValue(experimentName, experimentParam, defaultValue);
23
+ (0, _featureFlagsAccessed.addFeatureFlagAccessed)("".concat(experimentName, ":").concat(experimentParam), experimentValue);
24
+ return experimentValue;
25
+ };
26
+ var isDnDStyleChange = function isDnDStyleChange(style) {
27
+ return style.startsWith('anchor-name: --node-anchor');
28
+ };
29
+ var parseStyleSet = function parseStyleSet(style) {
30
+ if (!style) {
31
+ return null;
32
+ }
33
+ var set = new Set();
34
+ var _iterator = _createForOfIteratorHelper(style.split(';')),
35
+ _step;
36
+ try {
37
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
38
+ var part = _step.value;
39
+ var t = part.trim();
40
+ if (t) {
41
+ set.add(t);
42
+ }
43
+ }
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ return set;
50
+ };
51
+
52
+ /**
53
+ * Checks if a mutation record represents a style change from Editor's
54
+ * drag and drop feature, which don't cause visual shifts.
55
+ * This should be removed once DnD has been fixed.
56
+ * @param mutation - The mutation record to check
57
+ * @returns boolean indicating if this is a DnD style mutation
58
+ */
59
+ function isDnDStyleMutation(_ref) {
60
+ var target = _ref.target,
61
+ attributeName = _ref.attributeName,
62
+ oldValue = _ref.oldValue,
63
+ newValue = _ref.newValue;
64
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_exclude_dnd_anchor_name_from_ttvc')) {
65
+ return false;
66
+ }
67
+ if (!expVal('platform_editor_tables_scaling_css', 'excludeDnD', false)) {
68
+ return false;
69
+ }
70
+ if (!(target instanceof Element)) {
71
+ return false;
72
+ }
73
+ if (attributeName !== 'style') {
74
+ return false;
75
+ }
76
+ var oldStyles = parseStyleSet(oldValue);
77
+ var newStyles = parseStyleSet(newValue);
78
+ var isDnDMutation = false;
79
+ var _iterator2 = _createForOfIteratorHelper(oldStyles !== null && oldStyles !== void 0 ? oldStyles : []),
80
+ _step2;
81
+ try {
82
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
83
+ var s = _step2.value;
84
+ if (!(newStyles !== null && newStyles !== void 0 && newStyles.has(s))) {
85
+ if (!isDnDStyleChange(s)) {
86
+ return false;
87
+ }
88
+ isDnDMutation = true;
89
+ }
90
+ }
91
+ } catch (err) {
92
+ _iterator2.e(err);
93
+ } finally {
94
+ _iterator2.f();
95
+ }
96
+ var _iterator3 = _createForOfIteratorHelper(newStyles !== null && newStyles !== void 0 ? newStyles : []),
97
+ _step3;
98
+ try {
99
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
100
+ var _s = _step3.value;
101
+ if (!(oldStyles !== null && oldStyles !== void 0 && oldStyles.has(_s))) {
102
+ if (!isDnDStyleChange(_s)) {
103
+ return false;
104
+ }
105
+ isDnDMutation = true;
106
+ }
107
+ }
108
+ } catch (err) {
109
+ _iterator3.e(err);
110
+ } finally {
111
+ _iterator3.f();
112
+ }
113
+ return isDnDMutation;
114
+ }
115
+ var _default = exports.default = isDnDStyleMutation;
@@ -112,8 +112,8 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
112
112
  key: "calculateWithDebugInfo",
113
113
  value: function () {
114
114
  var _calculateWithDebugInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries, include3p) {
115
- var _window, _window2, _window3, _window5;
116
- var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator4, _step4, _entry3, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, enhancedVcLogs, shouldCalculate3p, shouldCalculateDebugDetails, sortedVcLogs, maxViewportPercentageAtTime, maxSoFar, _iterator5, _step5, log, getBiggestPreviousViewportPercentage, ignoredEntriesByTime, _iterator6, _step6, _entry4, _ignoredEntriesByTime, _viewportData$rect, _viewportData$previou, viewportData, timestamp, additionalVcLogs, _iterator7, _step7, _step7$value, _timestamp, ignoredEntries, _viewportPercentage, v3RevisionDebugDetails, _activeInteractionId$, activeInteractionId, activeInteraction, pageVisibilityUpToTTAI, isBackgrounded, _window4, _window4$__ufo_devtoo, _window6, _window6$__on_ufo_vc_;
115
+ var _window, _window2, _window6, _window8;
116
+ var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator4, _step4, _entry3, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, enhancedVcLogs, shouldCalculate3p, shouldCalculateDebugDetails, _window3, _window4, _window5, sortedVcLogs, maxViewportPercentageAtTime, maxSoFar, _iterator5, _step5, log, getBiggestPreviousViewportPercentage, ignoredEntriesByTime, _iterator6, _step6, _entry4, _ignoredEntriesByTime, _viewportData$rect, _viewportData$previou, viewportData, timestamp, additionalVcLogs, _iterator7, _step7, _step7$value, _timestamp, ignoredEntries, _viewportPercentage, v3RevisionDebugDetails, _activeInteractionId$, activeInteractionId, activeInteraction, pageVisibilityUpToTTAI, isBackgrounded, _window7, _window7$__ufo_devtoo, _window9, _window9$__on_ufo_vc_;
117
117
  return _regenerator.default.wrap(function _callee$(_context) {
118
118
  while (1) switch (_context.prev = _context.next) {
119
119
  case 0:
@@ -217,6 +217,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
217
217
  }) : []; // If 3p metric enabled - calculate the debug details
218
218
  shouldCalculate3p = include3p && (0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p'); // Only calculate enhanced debug details if devtool callbacks exist
219
219
  shouldCalculateDebugDetails = (!isPostInteraction || shouldCalculate3p) && (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__on_ufo_vc_debug_data_ready) === 'function');
220
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_fix_post_interaction_check_vc_debug')) {
221
+ shouldCalculateDebugDetails = !isPostInteraction && (typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window4 = window) === null || _window4 === void 0 ? void 0 : _window4.__on_ufo_vc_debug_data_ready) === 'function' || typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__ufo_devtool_vc_3p_debug_data) === 'function');
222
+ }
220
223
  if (shouldCalculateDebugDetails && allEntries && vcLogs) {
221
224
  // Pre-sort vcLogs by time for efficient lookups
222
225
  sortedVcLogs = (0, _toConsumableArray2.default)(vcLogs).sort(function (a, b) {
@@ -335,18 +338,18 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
335
338
  }
336
339
 
337
340
  // Handle devtool callback
338
- if (v3RevisionDebugDetails && typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
341
+ if (v3RevisionDebugDetails && typeof ((_window6 = window) === null || _window6 === void 0 ? void 0 : _window6.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
339
342
  try {
340
- (_window4 = window) === null || _window4 === void 0 || (_window4$__ufo_devtoo = _window4.__ufo_devtool_onVCRevisionReady__) === null || _window4$__ufo_devtoo === void 0 || _window4$__ufo_devtoo.call(_window4, v3RevisionDebugDetails);
343
+ (_window7 = window) === null || _window7 === void 0 || (_window7$__ufo_devtoo = _window7.__ufo_devtool_onVCRevisionReady__) === null || _window7$__ufo_devtoo === void 0 || _window7$__ufo_devtoo.call(_window7, v3RevisionDebugDetails);
341
344
  } catch (e) {
342
345
  // if any error communicating with devtool, we don't want to break the app
343
346
  // eslint-disable-next-line no-console
344
347
  console.error('Error in onVCRevisionReady', e);
345
348
  }
346
349
  }
347
- if (v3RevisionDebugDetails && typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
350
+ if (v3RevisionDebugDetails && typeof ((_window8 = window) === null || _window8 === void 0 ? void 0 : _window8.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
348
351
  try {
349
- (_window6 = window) === null || _window6 === void 0 || (_window6$__on_ufo_vc_ = _window6.__on_ufo_vc_debug_data_ready) === null || _window6$__on_ufo_vc_ === void 0 || _window6$__on_ufo_vc_.call(_window6, v3RevisionDebugDetails);
352
+ (_window9 = window) === null || _window9 === void 0 || (_window9$__on_ufo_vc_ = _window9.__on_ufo_vc_debug_data_ready) === null || _window9$__on_ufo_vc_ === void 0 || _window9$__on_ufo_vc_.call(_window9, v3RevisionDebugDetails);
350
353
  } catch (e) {
351
354
  // eslint-disable-next-line no-console
352
355
  console.error('Error in onVCRevisionReady', e);
@@ -362,7 +365,7 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
362
365
  }
363
366
  }
364
367
  return _context.abrupt("return", vcDetails);
365
- case 40:
368
+ case 41:
366
369
  case "end":
367
370
  return _context.stop();
368
371
  }
@@ -13,6 +13,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
15
  var _vcUtils = require("../../vc-observer/media-wrapper/vc-utils");
16
+ var _isDndStyleMutation = _interopRequireDefault(require("../../vc-observer/observers/non-visual-styles/is-dnd-style-mutation"));
16
17
  var _isNonVisualStyleMutation = _interopRequireDefault(require("../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation"));
17
18
  var _rllPlaceholders = require("../../vc-observer/observers/rll-placeholders");
18
19
  var _intersectionObserver = require("./intersection-observer");
@@ -320,6 +321,21 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
320
321
  }
321
322
  };
322
323
  }
324
+ if ((0, _isDndStyleMutation.default)({
325
+ target: target,
326
+ attributeName: attributeName,
327
+ oldValue: oldValue,
328
+ newValue: newValue
329
+ })) {
330
+ return {
331
+ type: 'mutation:attribute:non-visual-style',
332
+ mutationData: {
333
+ attributeName: attributeName,
334
+ oldValue: oldValue,
335
+ newValue: newValue
336
+ }
337
+ };
338
+ }
323
339
  if ((0, _isNonVisualStyleMutation.default)({
324
340
  target: target,
325
341
  attributeName: attributeName,
@@ -0,0 +1,80 @@
1
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { addFeatureFlagAccessed } from '../../../../feature-flags-accessed';
4
+
5
+ // copied from '@atlaskit/tmp-editor-statsig/expVal' to avoid circular dependency
6
+ const expVal = (experimentName, experimentParam, defaultValue) => {
7
+ // If client is not initialized, we return the default value
8
+ if (!FeatureGates.initializeCompleted()) {
9
+ return defaultValue;
10
+ }
11
+
12
+ // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
13
+ const experimentValue = FeatureGates.getExperimentValue(experimentName, experimentParam, defaultValue);
14
+ addFeatureFlagAccessed(`${experimentName}:${experimentParam}`, experimentValue);
15
+ return experimentValue;
16
+ };
17
+ const isDnDStyleChange = style => {
18
+ return style.startsWith('anchor-name: --node-anchor');
19
+ };
20
+ const parseStyleSet = style => {
21
+ if (!style) {
22
+ return null;
23
+ }
24
+ const set = new Set();
25
+ for (const part of style.split(';')) {
26
+ const t = part.trim();
27
+ if (t) {
28
+ set.add(t);
29
+ }
30
+ }
31
+ return set;
32
+ };
33
+
34
+ /**
35
+ * Checks if a mutation record represents a style change from Editor's
36
+ * drag and drop feature, which don't cause visual shifts.
37
+ * This should be removed once DnD has been fixed.
38
+ * @param mutation - The mutation record to check
39
+ * @returns boolean indicating if this is a DnD style mutation
40
+ */
41
+ function isDnDStyleMutation({
42
+ target,
43
+ attributeName,
44
+ oldValue,
45
+ newValue
46
+ }) {
47
+ if (!fg('platform_editor_exclude_dnd_anchor_name_from_ttvc')) {
48
+ return false;
49
+ }
50
+ if (!expVal('platform_editor_tables_scaling_css', 'excludeDnD', false)) {
51
+ return false;
52
+ }
53
+ if (!(target instanceof Element)) {
54
+ return false;
55
+ }
56
+ if (attributeName !== 'style') {
57
+ return false;
58
+ }
59
+ const oldStyles = parseStyleSet(oldValue);
60
+ const newStyles = parseStyleSet(newValue);
61
+ let isDnDMutation = false;
62
+ for (const s of oldStyles !== null && oldStyles !== void 0 ? oldStyles : []) {
63
+ if (!(newStyles !== null && newStyles !== void 0 && newStyles.has(s))) {
64
+ if (!isDnDStyleChange(s)) {
65
+ return false;
66
+ }
67
+ isDnDMutation = true;
68
+ }
69
+ }
70
+ for (const s of newStyles !== null && newStyles !== void 0 ? newStyles : []) {
71
+ if (!(oldStyles !== null && oldStyles !== void 0 && oldStyles.has(s))) {
72
+ if (!isDnDStyleChange(s)) {
73
+ return false;
74
+ }
75
+ isDnDMutation = true;
76
+ }
77
+ }
78
+ return isDnDMutation;
79
+ }
80
+ export default isDnDStyleMutation;
@@ -56,7 +56,7 @@ export default class AbstractVCCalculatorBase {
56
56
  return labelStacks;
57
57
  }
58
58
  async calculateWithDebugInfo(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries, include3p) {
59
- var _window, _window2, _window3, _window5;
59
+ var _window, _window2, _window6, _window8;
60
60
  const percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99, 100];
61
61
  const viewportEntries = this.filterViewportEntries(filteredEntries);
62
62
  const vcLogs = await calculateTTVCPercentilesWithDebugInfo({
@@ -135,7 +135,11 @@ export default class AbstractVCCalculatorBase {
135
135
  // If 3p metric enabled - calculate the debug details
136
136
  const shouldCalculate3p = include3p && fg('platform_ufo_enable_ttai_with_3p');
137
137
  // Only calculate enhanced debug details if devtool callbacks exist
138
- const shouldCalculateDebugDetails = (!isPostInteraction || shouldCalculate3p) && (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__on_ufo_vc_debug_data_ready) === 'function');
138
+ let shouldCalculateDebugDetails = (!isPostInteraction || shouldCalculate3p) && (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__on_ufo_vc_debug_data_ready) === 'function');
139
+ if (fg('platform_ufo_fix_post_interaction_check_vc_debug')) {
140
+ var _window3, _window4, _window5;
141
+ shouldCalculateDebugDetails = !isPostInteraction && (typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window4 = window) === null || _window4 === void 0 ? void 0 : _window4.__on_ufo_vc_debug_data_ready) === 'function' || typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__ufo_devtool_vc_3p_debug_data) === 'function');
142
+ }
139
143
  if (shouldCalculateDebugDetails && allEntries && vcLogs) {
140
144
  // Pre-sort vcLogs by time for efficient lookups
141
145
  const sortedVcLogs = [...vcLogs].sort((a, b) => a.time - b.time);
@@ -233,20 +237,20 @@ export default class AbstractVCCalculatorBase {
233
237
  }
234
238
 
235
239
  // Handle devtool callback
236
- if (v3RevisionDebugDetails && typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
240
+ if (v3RevisionDebugDetails && typeof ((_window6 = window) === null || _window6 === void 0 ? void 0 : _window6.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
237
241
  try {
238
- var _window4, _window4$__ufo_devtoo;
239
- (_window4 = window) === null || _window4 === void 0 ? void 0 : (_window4$__ufo_devtoo = _window4.__ufo_devtool_onVCRevisionReady__) === null || _window4$__ufo_devtoo === void 0 ? void 0 : _window4$__ufo_devtoo.call(_window4, v3RevisionDebugDetails);
242
+ var _window7, _window7$__ufo_devtoo;
243
+ (_window7 = window) === null || _window7 === void 0 ? void 0 : (_window7$__ufo_devtoo = _window7.__ufo_devtool_onVCRevisionReady__) === null || _window7$__ufo_devtoo === void 0 ? void 0 : _window7$__ufo_devtoo.call(_window7, v3RevisionDebugDetails);
240
244
  } catch (e) {
241
245
  // if any error communicating with devtool, we don't want to break the app
242
246
  // eslint-disable-next-line no-console
243
247
  console.error('Error in onVCRevisionReady', e);
244
248
  }
245
249
  }
246
- if (v3RevisionDebugDetails && typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
250
+ if (v3RevisionDebugDetails && typeof ((_window8 = window) === null || _window8 === void 0 ? void 0 : _window8.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
247
251
  try {
248
- var _window6, _window6$__on_ufo_vc_;
249
- (_window6 = window) === null || _window6 === void 0 ? void 0 : (_window6$__on_ufo_vc_ = _window6.__on_ufo_vc_debug_data_ready) === null || _window6$__on_ufo_vc_ === void 0 ? void 0 : _window6$__on_ufo_vc_.call(_window6, v3RevisionDebugDetails);
252
+ var _window9, _window9$__on_ufo_vc_;
253
+ (_window9 = window) === null || _window9 === void 0 ? void 0 : (_window9$__on_ufo_vc_ = _window9.__on_ufo_vc_debug_data_ready) === null || _window9$__on_ufo_vc_ === void 0 ? void 0 : _window9$__on_ufo_vc_.call(_window9, v3RevisionDebugDetails);
250
254
  } catch (e) {
251
255
  // eslint-disable-next-line no-console
252
256
  console.error('Error in onVCRevisionReady', e);
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { isContainedWithinMediaWrapper } from '../../vc-observer/media-wrapper/vc-utils';
4
+ import isDnDStyleMutation from '../../vc-observer/observers/non-visual-styles/is-dnd-style-mutation';
4
5
  import isNonVisualStyleMutation from '../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation';
5
6
  import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placeholders';
6
7
  import { createIntersectionObserver } from './intersection-observer';
@@ -223,6 +224,21 @@ export default class ViewportObserver {
223
224
  }
224
225
  };
225
226
  }
227
+ if (isDnDStyleMutation({
228
+ target,
229
+ attributeName,
230
+ oldValue,
231
+ newValue
232
+ })) {
233
+ return {
234
+ type: 'mutation:attribute:non-visual-style',
235
+ mutationData: {
236
+ attributeName,
237
+ oldValue,
238
+ newValue
239
+ }
240
+ };
241
+ }
226
242
  if (isNonVisualStyleMutation({
227
243
  target,
228
244
  attributeName,
@@ -0,0 +1,109 @@
1
+ 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; } } }; }
2
+ 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; } }
3
+ 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; }
4
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { addFeatureFlagAccessed } from '../../../../feature-flags-accessed';
7
+
8
+ // copied from '@atlaskit/tmp-editor-statsig/expVal' to avoid circular dependency
9
+ var expVal = function expVal(experimentName, experimentParam, defaultValue) {
10
+ // If client is not initialized, we return the default value
11
+ if (!FeatureGates.initializeCompleted()) {
12
+ return defaultValue;
13
+ }
14
+
15
+ // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
16
+ var experimentValue = FeatureGates.getExperimentValue(experimentName, experimentParam, defaultValue);
17
+ addFeatureFlagAccessed("".concat(experimentName, ":").concat(experimentParam), experimentValue);
18
+ return experimentValue;
19
+ };
20
+ var isDnDStyleChange = function isDnDStyleChange(style) {
21
+ return style.startsWith('anchor-name: --node-anchor');
22
+ };
23
+ var parseStyleSet = function parseStyleSet(style) {
24
+ if (!style) {
25
+ return null;
26
+ }
27
+ var set = new Set();
28
+ var _iterator = _createForOfIteratorHelper(style.split(';')),
29
+ _step;
30
+ try {
31
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
32
+ var part = _step.value;
33
+ var t = part.trim();
34
+ if (t) {
35
+ set.add(t);
36
+ }
37
+ }
38
+ } catch (err) {
39
+ _iterator.e(err);
40
+ } finally {
41
+ _iterator.f();
42
+ }
43
+ return set;
44
+ };
45
+
46
+ /**
47
+ * Checks if a mutation record represents a style change from Editor's
48
+ * drag and drop feature, which don't cause visual shifts.
49
+ * This should be removed once DnD has been fixed.
50
+ * @param mutation - The mutation record to check
51
+ * @returns boolean indicating if this is a DnD style mutation
52
+ */
53
+ function isDnDStyleMutation(_ref) {
54
+ var target = _ref.target,
55
+ attributeName = _ref.attributeName,
56
+ oldValue = _ref.oldValue,
57
+ newValue = _ref.newValue;
58
+ if (!fg('platform_editor_exclude_dnd_anchor_name_from_ttvc')) {
59
+ return false;
60
+ }
61
+ if (!expVal('platform_editor_tables_scaling_css', 'excludeDnD', false)) {
62
+ return false;
63
+ }
64
+ if (!(target instanceof Element)) {
65
+ return false;
66
+ }
67
+ if (attributeName !== 'style') {
68
+ return false;
69
+ }
70
+ var oldStyles = parseStyleSet(oldValue);
71
+ var newStyles = parseStyleSet(newValue);
72
+ var isDnDMutation = false;
73
+ var _iterator2 = _createForOfIteratorHelper(oldStyles !== null && oldStyles !== void 0 ? oldStyles : []),
74
+ _step2;
75
+ try {
76
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
77
+ var s = _step2.value;
78
+ if (!(newStyles !== null && newStyles !== void 0 && newStyles.has(s))) {
79
+ if (!isDnDStyleChange(s)) {
80
+ return false;
81
+ }
82
+ isDnDMutation = true;
83
+ }
84
+ }
85
+ } catch (err) {
86
+ _iterator2.e(err);
87
+ } finally {
88
+ _iterator2.f();
89
+ }
90
+ var _iterator3 = _createForOfIteratorHelper(newStyles !== null && newStyles !== void 0 ? newStyles : []),
91
+ _step3;
92
+ try {
93
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
94
+ var _s = _step3.value;
95
+ if (!(oldStyles !== null && oldStyles !== void 0 && oldStyles.has(_s))) {
96
+ if (!isDnDStyleChange(_s)) {
97
+ return false;
98
+ }
99
+ isDnDMutation = true;
100
+ }
101
+ }
102
+ } catch (err) {
103
+ _iterator3.e(err);
104
+ } finally {
105
+ _iterator3.f();
106
+ }
107
+ return isDnDMutation;
108
+ }
109
+ export default isDnDStyleMutation;
@@ -106,8 +106,8 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
106
106
  key: "calculateWithDebugInfo",
107
107
  value: function () {
108
108
  var _calculateWithDebugInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries, include3p) {
109
- var _window, _window2, _window3, _window5;
110
- var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator4, _step4, _entry3, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, enhancedVcLogs, shouldCalculate3p, shouldCalculateDebugDetails, sortedVcLogs, maxViewportPercentageAtTime, maxSoFar, _iterator5, _step5, log, getBiggestPreviousViewportPercentage, ignoredEntriesByTime, _iterator6, _step6, _entry4, _ignoredEntriesByTime, _viewportData$rect, _viewportData$previou, viewportData, timestamp, additionalVcLogs, _iterator7, _step7, _step7$value, _timestamp, ignoredEntries, _viewportPercentage, v3RevisionDebugDetails, _activeInteractionId$, activeInteractionId, activeInteraction, pageVisibilityUpToTTAI, isBackgrounded, _window4, _window4$__ufo_devtoo, _window6, _window6$__on_ufo_vc_;
109
+ var _window, _window2, _window6, _window8;
110
+ var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator4, _step4, _entry3, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, enhancedVcLogs, shouldCalculate3p, shouldCalculateDebugDetails, _window3, _window4, _window5, sortedVcLogs, maxViewportPercentageAtTime, maxSoFar, _iterator5, _step5, log, getBiggestPreviousViewportPercentage, ignoredEntriesByTime, _iterator6, _step6, _entry4, _ignoredEntriesByTime, _viewportData$rect, _viewportData$previou, viewportData, timestamp, additionalVcLogs, _iterator7, _step7, _step7$value, _timestamp, ignoredEntries, _viewportPercentage, v3RevisionDebugDetails, _activeInteractionId$, activeInteractionId, activeInteraction, pageVisibilityUpToTTAI, isBackgrounded, _window7, _window7$__ufo_devtoo, _window9, _window9$__on_ufo_vc_;
111
111
  return _regeneratorRuntime.wrap(function _callee$(_context) {
112
112
  while (1) switch (_context.prev = _context.next) {
113
113
  case 0:
@@ -211,6 +211,9 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
211
211
  }) : []; // If 3p metric enabled - calculate the debug details
212
212
  shouldCalculate3p = include3p && fg('platform_ufo_enable_ttai_with_3p'); // Only calculate enhanced debug details if devtool callbacks exist
213
213
  shouldCalculateDebugDetails = (!isPostInteraction || shouldCalculate3p) && (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__on_ufo_vc_debug_data_ready) === 'function');
214
+ if (fg('platform_ufo_fix_post_interaction_check_vc_debug')) {
215
+ shouldCalculateDebugDetails = !isPostInteraction && (typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window4 = window) === null || _window4 === void 0 ? void 0 : _window4.__on_ufo_vc_debug_data_ready) === 'function' || typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__ufo_devtool_vc_3p_debug_data) === 'function');
216
+ }
214
217
  if (shouldCalculateDebugDetails && allEntries && vcLogs) {
215
218
  // Pre-sort vcLogs by time for efficient lookups
216
219
  sortedVcLogs = _toConsumableArray(vcLogs).sort(function (a, b) {
@@ -329,18 +332,18 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
329
332
  }
330
333
 
331
334
  // Handle devtool callback
332
- if (v3RevisionDebugDetails && typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
335
+ if (v3RevisionDebugDetails && typeof ((_window6 = window) === null || _window6 === void 0 ? void 0 : _window6.__ufo_devtool_onVCRevisionReady__) === 'function' && !include3p) {
333
336
  try {
334
- (_window4 = window) === null || _window4 === void 0 || (_window4$__ufo_devtoo = _window4.__ufo_devtool_onVCRevisionReady__) === null || _window4$__ufo_devtoo === void 0 || _window4$__ufo_devtoo.call(_window4, v3RevisionDebugDetails);
337
+ (_window7 = window) === null || _window7 === void 0 || (_window7$__ufo_devtoo = _window7.__ufo_devtool_onVCRevisionReady__) === null || _window7$__ufo_devtoo === void 0 || _window7$__ufo_devtoo.call(_window7, v3RevisionDebugDetails);
335
338
  } catch (e) {
336
339
  // if any error communicating with devtool, we don't want to break the app
337
340
  // eslint-disable-next-line no-console
338
341
  console.error('Error in onVCRevisionReady', e);
339
342
  }
340
343
  }
341
- if (v3RevisionDebugDetails && typeof ((_window5 = window) === null || _window5 === void 0 ? void 0 : _window5.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
344
+ if (v3RevisionDebugDetails && typeof ((_window8 = window) === null || _window8 === void 0 ? void 0 : _window8.__on_ufo_vc_debug_data_ready) === 'function' && !include3p) {
342
345
  try {
343
- (_window6 = window) === null || _window6 === void 0 || (_window6$__on_ufo_vc_ = _window6.__on_ufo_vc_debug_data_ready) === null || _window6$__on_ufo_vc_ === void 0 || _window6$__on_ufo_vc_.call(_window6, v3RevisionDebugDetails);
346
+ (_window9 = window) === null || _window9 === void 0 || (_window9$__on_ufo_vc_ = _window9.__on_ufo_vc_debug_data_ready) === null || _window9$__on_ufo_vc_ === void 0 || _window9$__on_ufo_vc_.call(_window9, v3RevisionDebugDetails);
344
347
  } catch (e) {
345
348
  // eslint-disable-next-line no-console
346
349
  console.error('Error in onVCRevisionReady', e);
@@ -356,7 +359,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
356
359
  }
357
360
  }
358
361
  return _context.abrupt("return", vcDetails);
359
- case 40:
362
+ case 41:
360
363
  case "end":
361
364
  return _context.stop();
362
365
  }
@@ -8,6 +8,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
8
8
  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; }
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { isContainedWithinMediaWrapper } from '../../vc-observer/media-wrapper/vc-utils';
11
+ import isDnDStyleMutation from '../../vc-observer/observers/non-visual-styles/is-dnd-style-mutation';
11
12
  import isNonVisualStyleMutation from '../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation';
12
13
  import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placeholders';
13
14
  import { createIntersectionObserver } from './intersection-observer';
@@ -311,6 +312,21 @@ var ViewportObserver = /*#__PURE__*/function () {
311
312
  }
312
313
  };
313
314
  }
315
+ if (isDnDStyleMutation({
316
+ target: target,
317
+ attributeName: attributeName,
318
+ oldValue: oldValue,
319
+ newValue: newValue
320
+ })) {
321
+ return {
322
+ type: 'mutation:attribute:non-visual-style',
323
+ mutationData: {
324
+ attributeName: attributeName,
325
+ oldValue: oldValue,
326
+ newValue: newValue
327
+ }
328
+ };
329
+ }
314
330
  if (isNonVisualStyleMutation({
315
331
  target: target,
316
332
  attributeName: attributeName,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Checks if a mutation record represents a style change from Editor's
3
+ * drag and drop feature, which don't cause visual shifts.
4
+ * This should be removed once DnD has been fixed.
5
+ * @param mutation - The mutation record to check
6
+ * @returns boolean indicating if this is a DnD style mutation
7
+ */
8
+ declare function isDnDStyleMutation({ target, attributeName, oldValue, newValue, }: {
9
+ target?: Node | null;
10
+ attributeName?: string | null;
11
+ oldValue?: string | undefined | null;
12
+ newValue?: string | undefined | null;
13
+ }): boolean;
14
+ export default isDnDStyleMutation;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Checks if a mutation record represents a style change from Editor's
3
+ * drag and drop feature, which don't cause visual shifts.
4
+ * This should be removed once DnD has been fixed.
5
+ * @param mutation - The mutation record to check
6
+ * @returns boolean indicating if this is a DnD style mutation
7
+ */
8
+ declare function isDnDStyleMutation({ target, attributeName, oldValue, newValue, }: {
9
+ target?: Node | null;
10
+ attributeName?: string | null;
11
+ oldValue?: string | undefined | null;
12
+ newValue?: string | undefined | null;
13
+ }): boolean;
14
+ export default isDnDStyleMutation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.7.4",
3
+ "version": "4.7.6",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,6 +27,7 @@
27
27
  "atlaskit:src": "src/index.ts",
28
28
  "dependencies": {
29
29
  "@atlaskit/browser-apis": "^0.0.1",
30
+ "@atlaskit/feature-gate-js-client": "^5.5.0",
30
31
  "@atlaskit/interaction-context": "^3.0.0",
31
32
  "@atlaskit/platform-feature-flags": "^1.1.0",
32
33
  "@babel/runtime": "^7.0.0",
@@ -107,6 +108,9 @@
107
108
  "platform_ufo_enable_timeout_config": {
108
109
  "type": "boolean"
109
110
  },
111
+ "platform_ufo_fix_post_interaction_check_vc_debug": {
112
+ "type": "boolean"
113
+ },
110
114
  "platform_ufo_critical_metrics_payload": {
111
115
  "type": "boolean"
112
116
  },
@@ -149,6 +153,9 @@
149
153
  "platform_ufo_enable_late_mutation_label_stacks": {
150
154
  "type": "boolean"
151
155
  },
156
+ "platform_editor_exclude_dnd_anchor_name_from_ttvc": {
157
+ "type": "boolean"
158
+ },
152
159
  "platform_ufo_enable_finish_interaction_transition": {
153
160
  "type": "boolean"
154
161
  }