@atlaskit/react-ufo 4.13.1 → 4.14.1

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.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1cd3b31cac6ef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1cd3b31cac6ef) -
8
+ FG cleanup - platform_ufo_ssr_placeholders_for_display_contents
9
+
10
+ ## 4.14.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`55c867098e0ab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55c867098e0ab) -
15
+ Added battery info and webdriver
16
+
3
17
  ## 4.13.1
4
18
 
5
19
  ### Patch Changes
@@ -35,6 +35,7 @@ var ssr = _interopRequireWildcard(require("../ssr"));
35
35
  var _utils = require("./common/utils");
36
36
  var _criticalMetricsPayload = require("./critical-metrics-payload");
37
37
  var _addPerformanceMeasures = require("./utils/add-performance-measures");
38
+ var _getBatteryInfo = require("./utils/get-battery-info");
38
39
  var _getBrowserMetadata = require("./utils/get-browser-metadata");
39
40
  var _getInteractionStatus = _interopRequireDefault(require("./utils/get-interaction-status"));
40
41
  var _getMoreAccuratePageVisibilityUpToTtai = require("./utils/get-more-accurate-page-visibility-up-to-ttai");
@@ -397,7 +398,7 @@ function createInteractionMetricsPayload(_x, _x2, _x3, _x4, _x5) {
397
398
  function _createInteractionMetricsPayload() {
398
399
  _createInteractionMetricsPayload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction, interactionId, experimental, criticalPayloadCount, vcMetrics) {
399
400
  var _window$location, _config$additionalPay;
400
- var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, getReactHydrationStats, payload;
401
+ var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, batteryInfo, getReactHydrationStats, payload;
401
402
  return _regenerator.default.wrap(function _callee$(_context) {
402
403
  while (1) switch (_context.prev = _context.next) {
403
404
  case 0:
@@ -510,15 +511,17 @@ function _createInteractionMetricsPayload() {
510
511
  _context.t2 = _context.t1;
511
512
  _context.t3 = experimental ? (0, _createExperimentalInteractionMetricsPayload.getExperimentalVCMetrics)(interaction) : Promise.resolve(undefined);
512
513
  _context.t4 = (0, _getPaintMetrics.getPaintMetricsToLegacyFormat)(type, end);
513
- _context.t5 = [_context.t2, _context.t3, _context.t4];
514
- _context.next = 34;
515
- return _context.t0.all.call(_context.t0, _context.t5);
516
- case 34:
514
+ _context.t5 = (0, _getBatteryInfo.getBatteryInfoToLegacyFormat)();
515
+ _context.t6 = [_context.t2, _context.t3, _context.t4, _context.t5];
516
+ _context.next = 35;
517
+ return _context.t0.all.call(_context.t0, _context.t6);
518
+ case 35:
517
519
  _yield$Promise$all = _context.sent;
518
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 3);
520
+ _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 4);
519
521
  finalVCMetrics = _yield$Promise$all2[0];
520
522
  experimentalMetrics = _yield$Promise$all2[1];
521
523
  paintMetrics = _yield$Promise$all2[2];
524
+ batteryInfo = _yield$Promise$all2[3];
522
525
  if (!experimental) {
523
526
  (0, _addPerformanceMeasures.addPerformanceMeasures)(interaction.start, (0, _toConsumableArray2.default)((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || []));
524
527
  }
@@ -537,7 +540,7 @@ function _createInteractionMetricsPayload() {
537
540
  source: 'measured',
538
541
  tags: ['observability'],
539
542
  attributes: {
540
- properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
543
+ properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
541
544
  // basic
542
545
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
543
546
  'event:product': config.product,
@@ -556,7 +559,7 @@ function _createInteractionMetricsPayload() {
556
559
  }, criticalPayloadCount !== undefined ? {
557
560
  'ufo:multipayload': true,
558
561
  'ufo:criticalPayloadCount': criticalPayloadCount
559
- } : {}), (0, _getBrowserMetadata.getBrowserMetadataToLegacyFormat)()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), (0, _getNavigationMetrics.getNavigationMetricsToLegacyFormat)(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
562
+ } : {}), (0, _getBrowserMetadata.getBrowserMetadataToLegacyFormat)()), batteryInfo), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), (0, _getNavigationMetrics.getNavigationMetricsToLegacyFormat)(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
560
563
  interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
561
564
  namePrefix: config.namePrefix || '',
562
565
  segmentPrefix: config.segmentPrefix || '',
@@ -603,7 +606,7 @@ function _createInteractionMetricsPayload() {
603
606
  }
604
607
  payload.attributes.properties['event:sizeInKb'] = (0, _getPayloadSize.default)(payload.attributes.properties);
605
608
  return _context.abrupt("return", payload);
606
- case 45:
609
+ case 47:
607
610
  case "end":
608
611
  return _context.stop();
609
612
  }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = getBatteryInfo;
8
+ exports.getBatteryInfoToLegacyFormat = getBatteryInfoToLegacyFormat;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ // Type definitions for battery info
13
+ // Main function returns compact nested format
14
+ function getBatteryInfo() {
15
+ return _getBatteryInfo.apply(this, arguments);
16
+ } // Helper function to get battery info in legacy colon format for backward compatibility
17
+ function _getBatteryInfo() {
18
+ _getBatteryInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
19
+ var battery;
20
+ return _regenerator.default.wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ if ((0, _platformFeatureFlags.fg)('react_ufo_battery_info')) {
24
+ _context.next = 2;
25
+ break;
26
+ }
27
+ return _context.abrupt("return", {});
28
+ case 2:
29
+ if (!(typeof navigator === 'undefined')) {
30
+ _context.next = 4;
31
+ break;
32
+ }
33
+ return _context.abrupt("return", {});
34
+ case 4:
35
+ _context.prev = 4;
36
+ if (!('getBattery' in navigator)) {
37
+ _context.next = 11;
38
+ break;
39
+ }
40
+ _context.next = 8;
41
+ return navigator.getBattery();
42
+ case 8:
43
+ battery = _context.sent;
44
+ if (!(battery && typeof battery.level === 'number' && typeof battery.charging === 'boolean')) {
45
+ _context.next = 11;
46
+ break;
47
+ }
48
+ return _context.abrupt("return", {
49
+ level: Math.round(battery.level * 100) / 100,
50
+ // Round to 0.01
51
+ charging: battery.charging
52
+ });
53
+ case 11:
54
+ _context.next = 15;
55
+ break;
56
+ case 13:
57
+ _context.prev = 13;
58
+ _context.t0 = _context["catch"](4);
59
+ case 15:
60
+ return _context.abrupt("return", {});
61
+ case 16:
62
+ case "end":
63
+ return _context.stop();
64
+ }
65
+ }, _callee, null, [[4, 13]]);
66
+ }));
67
+ return _getBatteryInfo.apply(this, arguments);
68
+ }
69
+ function getBatteryInfoToLegacyFormat() {
70
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
71
+ }
72
+ function _getBatteryInfoToLegacyFormat() {
73
+ _getBatteryInfoToLegacyFormat = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
74
+ var battery, legacyFormat;
75
+ return _regenerator.default.wrap(function _callee2$(_context2) {
76
+ while (1) switch (_context2.prev = _context2.next) {
77
+ case 0:
78
+ _context2.next = 2;
79
+ return getBatteryInfo();
80
+ case 2:
81
+ battery = _context2.sent;
82
+ legacyFormat = {};
83
+ if (battery.level !== undefined) {
84
+ legacyFormat['event:battery:level'] = battery.level;
85
+ }
86
+ if (battery.charging !== undefined) {
87
+ legacyFormat['event:battery:charging'] = battery.charging;
88
+ }
89
+ return _context2.abrupt("return", legacyFormat);
90
+ case 7:
91
+ case "end":
92
+ return _context2.stop();
93
+ }
94
+ }, _callee2);
95
+ }));
96
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
97
+ }
@@ -8,7 +8,6 @@ exports.SSRPlaceholderHandlers = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var ANCESTOR_LOOKUP_LIMIT = 10;
13
12
  var PAGE_LAYOUT_ID = 'page-layout.root';
14
13
  var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/function () {
@@ -291,45 +290,40 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
291
290
  }, {
292
291
  key: "getEffectiveBoundingRect",
293
292
  value: function getEffectiveBoundingRect(el) {
294
- var enableDisplayContentsSupport = (0, _platformFeatureFlags.fg)('platform_ufo_ssr_placeholders_for_display_contents');
293
+ var computedStyle = window.getComputedStyle(el);
295
294
 
296
- // Only handle display: contents if feature flag is enabled
297
- if (enableDisplayContentsSupport) {
298
- var computedStyle = window.getComputedStyle(el);
295
+ // If element has display: contents, collect bounding rect from children
296
+ if (computedStyle.display === 'contents') {
297
+ var children = Array.from(el.children);
298
+ if (children.length === 0) {
299
+ // No children, return zero rect
300
+ return new DOMRect(0, 0, 0, 0);
301
+ }
299
302
 
300
- // If element has display: contents, collect bounding rect from children
301
- if (computedStyle.display === 'contents') {
302
- var children = Array.from(el.children);
303
- if (children.length === 0) {
304
- // No children, return zero rect
305
- return new DOMRect(0, 0, 0, 0);
303
+ // Calculate union of all children's bounding rects
304
+ var minX = Infinity;
305
+ var minY = Infinity;
306
+ var maxX = -Infinity;
307
+ var maxY = -Infinity;
308
+ children.forEach(function (child) {
309
+ var childRect = child.getBoundingClientRect();
310
+ // Skip children with zero dimensions (likely also display: contents)
311
+ if (childRect.width > 0 || childRect.height > 0) {
312
+ minX = Math.min(minX, childRect.left);
313
+ minY = Math.min(minY, childRect.top);
314
+ maxX = Math.max(maxX, childRect.right);
315
+ maxY = Math.max(maxY, childRect.bottom);
306
316
  }
317
+ });
307
318
 
308
- // Calculate union of all children's bounding rects
309
- var minX = Infinity;
310
- var minY = Infinity;
311
- var maxX = -Infinity;
312
- var maxY = -Infinity;
313
- children.forEach(function (child) {
314
- var childRect = child.getBoundingClientRect();
315
- // Skip children with zero dimensions (likely also display: contents)
316
- if (childRect.width > 0 || childRect.height > 0) {
317
- minX = Math.min(minX, childRect.left);
318
- minY = Math.min(minY, childRect.top);
319
- maxX = Math.max(maxX, childRect.right);
320
- maxY = Math.max(maxY, childRect.bottom);
321
- }
322
- });
323
-
324
- // If no children with dimensions found, return zero rect
325
- if (minX === Infinity) {
326
- return new DOMRect(0, 0, 0, 0);
327
- }
328
- return new DOMRect(minX, minY, maxX - minX, maxY - minY);
319
+ // If no children with dimensions found, return zero rect
320
+ if (minX === Infinity) {
321
+ return new DOMRect(0, 0, 0, 0);
329
322
  }
323
+ return new DOMRect(minX, minY, maxX - minX, maxY - minY);
330
324
  }
331
325
 
332
- // Normal element or feature flag disabled, return its bounding rect
326
+ // Normal element, return its bounding rect
333
327
  return el.getBoundingClientRect();
334
328
  }
335
329
  }, {
@@ -4,34 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.collectSSRPlaceholderDimensions = collectSSRPlaceholderDimensions;
7
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
7
  // lightweight script to scan the SSR response and collect all elements with data-ssr-placeholder attribute
9
8
  // and save their size/positions in a map __SSR_PLACEHOLDERS_DIMENSIONS__ on the Window object. Each placeholderId is
10
9
  // unique and maps to its corresponding elements bounding client rectangle dimensions.
11
10
  function collectSSRPlaceholderDimensions(document, window) {
12
11
  var enablePageLayoutPlaceholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13
- var enableDisplayContentsSupport = (0, _platformFeatureFlags.fg)('platform_ufo_ssr_placeholders_for_display_contents');
14
12
  var ssrPlaceholders = document === null || document === void 0 ? void 0 : document.querySelectorAll('[data-ssr-placeholder]');
15
13
  ssrPlaceholders.forEach(function (elem) {
16
14
  var placeholderId = elem.getAttribute('data-ssr-placeholder');
17
15
  if (placeholderId) {
18
16
  window.__SSR_PLACEHOLDERS_DIMENSIONS__ = window.__SSR_PLACEHOLDERS_DIMENSIONS__ || {};
19
- if (enableDisplayContentsSupport) {
20
- window.__SSR_PLACEHOLDERS_DIMENSIONS__[placeholderId] = getEffectiveBoundingRect(elem, window);
21
- } else {
22
- window.__SSR_PLACEHOLDERS_DIMENSIONS__[placeholderId] = elem.getBoundingClientRect();
23
- }
17
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__[placeholderId] = getEffectiveBoundingRect(elem, window);
24
18
  }
25
19
  });
26
20
  if (enablePageLayoutPlaceholder) {
27
21
  var pageLayoutRoot = document === null || document === void 0 ? void 0 : document.getElementById('unsafe-design-system-page-layout-root');
28
22
  if (pageLayoutRoot) {
29
23
  window.__SSR_PLACEHOLDERS_DIMENSIONS__ = window.__SSR_PLACEHOLDERS_DIMENSIONS__ || {};
30
- if (enableDisplayContentsSupport) {
31
- window.__SSR_PLACEHOLDERS_DIMENSIONS__['page-layout.root'] = getEffectiveBoundingRect(pageLayoutRoot, window);
32
- } else {
33
- window.__SSR_PLACEHOLDERS_DIMENSIONS__['page-layout.root'] = pageLayoutRoot.getBoundingClientRect();
34
- }
24
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__['page-layout.root'] = getEffectiveBoundingRect(pageLayoutRoot, window);
35
25
  }
36
26
  }
37
27
  }