@atlaskit/react-ufo 4.6.1 → 4.7.0

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,22 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`dbde6617644d6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dbde6617644d6) -
8
+ [NO-ISSUE] Exclude contenteditable, data-has-collab-initialised, and translate attributes from VC
9
+ calculation
10
+
11
+ ## 4.6.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`4dd6789885500`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4dd6789885500) -
16
+ Fix unhandled hidden timing error
17
+ - [`25fbcd6f57e2f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25fbcd6f57e2f) -
18
+ clean up fg
19
+
3
20
  ## 4.6.1
4
21
 
5
22
  ### Patch Changes
@@ -64,6 +64,11 @@ function setupHiddenTimingCapture() {
64
64
  }
65
65
  }
66
66
  function getPageVisibilityState(start, end) {
67
+ // Input validation - return default for invalid inputs
68
+ if (!Number.isFinite(start) || !Number.isFinite(end)) {
69
+ return 'visible';
70
+ }
71
+
67
72
  // Desirable default value is visible
68
73
  if (timings.length === 0) {
69
74
  return 'visible';
@@ -76,19 +81,18 @@ function getPageVisibilityState(start, end) {
76
81
  // currentSize is capped at SIZE.
77
82
  for (var i = 0; i < currentSize; i++) {
78
83
  var tmpIdx = (insertIndex + i) % currentSize;
79
- if (timings[tmpIdx].time <= end) {
84
+ // Add bounds checking before accessing array element
85
+ if (timings[tmpIdx] && timings[tmpIdx].time <= end) {
80
86
  endIdx = tmpIdx;
81
87
  if (timings[tmpIdx].time <= start) {
82
88
  startIdx = tmpIdx;
83
89
  }
84
90
  }
85
91
  }
86
- if (endIdx - startIdx === 0) {
87
- if (timings[startIdx].hidden) {
88
- hiddenState = 'hidden';
89
- } else {
90
- hiddenState = 'visible';
91
- }
92
+
93
+ // Add bounds checking before accessing timings array
94
+ if (endIdx - startIdx === 0 && timings[startIdx]) {
95
+ hiddenState = timings[startIdx].hidden ? 'hidden' : 'visible';
92
96
  }
93
97
  return hiddenState;
94
98
  }
@@ -117,12 +117,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
117
117
  return _regenerator.default.wrap(function _callee$(_context) {
118
118
  while (1) switch (_context.prev = _context.next) {
119
119
  case 0:
120
- percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
121
- if ((0, _platformFeatureFlags.fg)('platform_ufo_send_vc_100')) {
122
- percentiles.push(100);
123
- }
120
+ percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99, 100];
124
121
  viewportEntries = this.filterViewportEntries(filteredEntries);
125
- _context.next = 5;
122
+ _context.next = 4;
126
123
  return (0, _percentileCalc.calculateTTVCPercentilesWithDebugInfo)({
127
124
  viewport: {
128
125
  width: (0, _getViewportWidth.default)(),
@@ -132,31 +129,31 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
132
129
  stopTime: stopTime,
133
130
  orderedEntries: viewportEntries
134
131
  });
135
- case 5:
132
+ case 4:
136
133
  vcLogs = _context.sent;
137
134
  vcDetails = {};
138
135
  percentileIndex = 0;
139
136
  entryDataBuffer = new Set();
140
137
  if (!vcLogs) {
141
- _context.next = 29;
138
+ _context.next = 28;
142
139
  break;
143
140
  }
144
141
  _iterator4 = _createForOfIteratorHelper(vcLogs);
145
- _context.prev = 11;
142
+ _context.prev = 10;
146
143
  _iterator4.s();
147
- case 13:
144
+ case 12:
148
145
  if ((_step4 = _iterator4.n()).done) {
149
- _context.next = 21;
146
+ _context.next = 20;
150
147
  break;
151
148
  }
152
149
  _entry3 = _step4.value;
153
150
  time = _entry3.time, viewportPercentage = _entry3.viewportPercentage, entries = _entry3.entries; // Only process entries if we haven't reached all percentiles
154
151
  if (!(percentileIndex >= percentiles.length)) {
155
- _context.next = 18;
152
+ _context.next = 17;
156
153
  break;
157
154
  }
158
- return _context.abrupt("break", 21);
159
- case 18:
155
+ return _context.abrupt("break", 20);
156
+ case 17:
160
157
  // Check if this entry matches any checkpoint percentiles
161
158
  if (viewportPercentage >= percentiles[percentileIndex]) {
162
159
  elementNames = entries.map(function (e) {
@@ -178,21 +175,21 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
178
175
  return entryDataBuffer.add(e);
179
176
  });
180
177
  }
181
- case 19:
182
- _context.next = 13;
178
+ case 18:
179
+ _context.next = 12;
183
180
  break;
184
- case 21:
185
- _context.next = 26;
181
+ case 20:
182
+ _context.next = 25;
186
183
  break;
187
- case 23:
188
- _context.prev = 23;
189
- _context.t0 = _context["catch"](11);
184
+ case 22:
185
+ _context.prev = 22;
186
+ _context.t0 = _context["catch"](10);
190
187
  _iterator4.e(_context.t0);
191
- case 26:
192
- _context.prev = 26;
188
+ case 25:
189
+ _context.prev = 25;
193
190
  _iterator4.f();
194
- return _context.finish(26);
195
- case 29:
191
+ return _context.finish(25);
192
+ case 28:
196
193
  // Fill in any missing percentiles with the last known values
197
194
  previousResult = {
198
195
  t: 0,
@@ -367,11 +364,11 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
367
364
  }
368
365
  }
369
366
  return _context.abrupt("return", vcDetails);
370
- case 41:
367
+ case 40:
371
368
  case "end":
372
369
  return _context.stop();
373
370
  }
374
- }, _callee, this, [[11, 23, 26, 29]]);
371
+ }, _callee, this, [[10, 22, 25, 28]]);
375
372
  }));
376
373
  function calculateWithDebugInfo(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
377
374
  return _calculateWithDebugInfo.apply(this, arguments);
@@ -64,7 +64,7 @@ var VCCalculator_FY25_03 = exports.default = /*#__PURE__*/function (_AbstractVCC
64
64
  if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
65
65
  return false;
66
66
  }
67
- if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && (0, _platformFeatureFlags.fg)('platform_ufo_exclude_3p_extensions_from_ttvc')) {
67
+ if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || attributeName === 'contenteditable' || attributeName === 'data-has-collab-initialised' || attributeName === 'translate' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && (0, _platformFeatureFlags.fg)('platform_ufo_exclude_3p_extensions_from_ttvc')) {
68
68
  return false;
69
69
  }
70
70
  return true;
@@ -57,6 +57,11 @@ export function setupHiddenTimingCapture() {
57
57
  }
58
58
  }
59
59
  export function getPageVisibilityState(start, end) {
60
+ // Input validation - return default for invalid inputs
61
+ if (!Number.isFinite(start) || !Number.isFinite(end)) {
62
+ return 'visible';
63
+ }
64
+
60
65
  // Desirable default value is visible
61
66
  if (timings.length === 0) {
62
67
  return 'visible';
@@ -69,19 +74,18 @@ export function getPageVisibilityState(start, end) {
69
74
  // currentSize is capped at SIZE.
70
75
  for (let i = 0; i < currentSize; i++) {
71
76
  const tmpIdx = (insertIndex + i) % currentSize;
72
- if (timings[tmpIdx].time <= end) {
77
+ // Add bounds checking before accessing array element
78
+ if (timings[tmpIdx] && timings[tmpIdx].time <= end) {
73
79
  endIdx = tmpIdx;
74
80
  if (timings[tmpIdx].time <= start) {
75
81
  startIdx = tmpIdx;
76
82
  }
77
83
  }
78
84
  }
79
- if (endIdx - startIdx === 0) {
80
- if (timings[startIdx].hidden) {
81
- hiddenState = 'hidden';
82
- } else {
83
- hiddenState = 'visible';
84
- }
85
+
86
+ // Add bounds checking before accessing timings array
87
+ if (endIdx - startIdx === 0 && timings[startIdx]) {
88
+ hiddenState = timings[startIdx].hidden ? 'hidden' : 'visible';
85
89
  }
86
90
  return hiddenState;
87
91
  }
@@ -57,10 +57,7 @@ export default class AbstractVCCalculatorBase {
57
57
  }
58
58
  async calculateWithDebugInfo(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries, include3p) {
59
59
  var _window, _window2, _window3, _window5;
60
- const percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
61
- if (fg('platform_ufo_send_vc_100')) {
62
- percentiles.push(100);
63
- }
60
+ const percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99, 100];
64
61
  const viewportEntries = this.filterViewportEntries(filteredEntries);
65
62
  const vcLogs = await calculateTTVCPercentilesWithDebugInfo({
66
63
  viewport: {
@@ -43,7 +43,7 @@ export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
43
43
  if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
44
44
  return false;
45
45
  }
46
- if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
46
+ if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || attributeName === 'contenteditable' || attributeName === 'data-has-collab-initialised' || attributeName === 'translate' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
47
47
  return false;
48
48
  }
49
49
  return true;
@@ -57,6 +57,11 @@ export function setupHiddenTimingCapture() {
57
57
  }
58
58
  }
59
59
  export function getPageVisibilityState(start, end) {
60
+ // Input validation - return default for invalid inputs
61
+ if (!Number.isFinite(start) || !Number.isFinite(end)) {
62
+ return 'visible';
63
+ }
64
+
60
65
  // Desirable default value is visible
61
66
  if (timings.length === 0) {
62
67
  return 'visible';
@@ -69,19 +74,18 @@ export function getPageVisibilityState(start, end) {
69
74
  // currentSize is capped at SIZE.
70
75
  for (var i = 0; i < currentSize; i++) {
71
76
  var tmpIdx = (insertIndex + i) % currentSize;
72
- if (timings[tmpIdx].time <= end) {
77
+ // Add bounds checking before accessing array element
78
+ if (timings[tmpIdx] && timings[tmpIdx].time <= end) {
73
79
  endIdx = tmpIdx;
74
80
  if (timings[tmpIdx].time <= start) {
75
81
  startIdx = tmpIdx;
76
82
  }
77
83
  }
78
84
  }
79
- if (endIdx - startIdx === 0) {
80
- if (timings[startIdx].hidden) {
81
- hiddenState = 'hidden';
82
- } else {
83
- hiddenState = 'visible';
84
- }
85
+
86
+ // Add bounds checking before accessing timings array
87
+ if (endIdx - startIdx === 0 && timings[startIdx]) {
88
+ hiddenState = timings[startIdx].hidden ? 'hidden' : 'visible';
85
89
  }
86
90
  return hiddenState;
87
91
  }
@@ -111,12 +111,9 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
111
111
  return _regeneratorRuntime.wrap(function _callee$(_context) {
112
112
  while (1) switch (_context.prev = _context.next) {
113
113
  case 0:
114
- percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
115
- if (fg('platform_ufo_send_vc_100')) {
116
- percentiles.push(100);
117
- }
114
+ percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99, 100];
118
115
  viewportEntries = this.filterViewportEntries(filteredEntries);
119
- _context.next = 5;
116
+ _context.next = 4;
120
117
  return calculateTTVCPercentilesWithDebugInfo({
121
118
  viewport: {
122
119
  width: getViewportWidth(),
@@ -126,31 +123,31 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
126
123
  stopTime: stopTime,
127
124
  orderedEntries: viewportEntries
128
125
  });
129
- case 5:
126
+ case 4:
130
127
  vcLogs = _context.sent;
131
128
  vcDetails = {};
132
129
  percentileIndex = 0;
133
130
  entryDataBuffer = new Set();
134
131
  if (!vcLogs) {
135
- _context.next = 29;
132
+ _context.next = 28;
136
133
  break;
137
134
  }
138
135
  _iterator4 = _createForOfIteratorHelper(vcLogs);
139
- _context.prev = 11;
136
+ _context.prev = 10;
140
137
  _iterator4.s();
141
- case 13:
138
+ case 12:
142
139
  if ((_step4 = _iterator4.n()).done) {
143
- _context.next = 21;
140
+ _context.next = 20;
144
141
  break;
145
142
  }
146
143
  _entry3 = _step4.value;
147
144
  time = _entry3.time, viewportPercentage = _entry3.viewportPercentage, entries = _entry3.entries; // Only process entries if we haven't reached all percentiles
148
145
  if (!(percentileIndex >= percentiles.length)) {
149
- _context.next = 18;
146
+ _context.next = 17;
150
147
  break;
151
148
  }
152
- return _context.abrupt("break", 21);
153
- case 18:
149
+ return _context.abrupt("break", 20);
150
+ case 17:
154
151
  // Check if this entry matches any checkpoint percentiles
155
152
  if (viewportPercentage >= percentiles[percentileIndex]) {
156
153
  elementNames = entries.map(function (e) {
@@ -172,21 +169,21 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
172
169
  return entryDataBuffer.add(e);
173
170
  });
174
171
  }
175
- case 19:
176
- _context.next = 13;
172
+ case 18:
173
+ _context.next = 12;
177
174
  break;
178
- case 21:
179
- _context.next = 26;
175
+ case 20:
176
+ _context.next = 25;
180
177
  break;
181
- case 23:
182
- _context.prev = 23;
183
- _context.t0 = _context["catch"](11);
178
+ case 22:
179
+ _context.prev = 22;
180
+ _context.t0 = _context["catch"](10);
184
181
  _iterator4.e(_context.t0);
185
- case 26:
186
- _context.prev = 26;
182
+ case 25:
183
+ _context.prev = 25;
187
184
  _iterator4.f();
188
- return _context.finish(26);
189
- case 29:
185
+ return _context.finish(25);
186
+ case 28:
190
187
  // Fill in any missing percentiles with the last known values
191
188
  previousResult = {
192
189
  t: 0,
@@ -361,11 +358,11 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
361
358
  }
362
359
  }
363
360
  return _context.abrupt("return", vcDetails);
364
- case 41:
361
+ case 40:
365
362
  case "end":
366
363
  return _context.stop();
367
364
  }
368
- }, _callee, this, [[11, 23, 26, 29]]);
365
+ }, _callee, this, [[10, 22, 25, 28]]);
369
366
  }));
370
367
  function calculateWithDebugInfo(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
371
368
  return _calculateWithDebugInfo.apply(this, arguments);
@@ -57,7 +57,7 @@ var VCCalculator_FY25_03 = /*#__PURE__*/function (_AbstractVCCalculator) {
57
57
  if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
58
58
  return false;
59
59
  }
60
- if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
60
+ if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || attributeName === 'contenteditable' || attributeName === 'data-has-collab-initialised' || attributeName === 'translate' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
61
61
  return false;
62
62
  }
63
63
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.6.1",
3
+ "version": "4.7.0",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -141,9 +141,6 @@
141
141
  "platform_ufo_ssr_placeholder_resolution_ttvc_v3": {
142
142
  "type": "boolean"
143
143
  },
144
- "platform_ufo_send_vc_100": {
145
- "type": "boolean"
146
- },
147
144
  "platform_ufo_display_content_resolution_ttvc_v3": {
148
145
  "type": "boolean"
149
146
  },