@atlaskit/react-ufo 4.1.13 → 4.2.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/interaction-metrics/index.js +1 -2
  3. package/dist/cjs/interaction-metrics-init/index.js +1 -2
  4. package/dist/cjs/vc/index.js +4 -12
  5. package/dist/cjs/vc/vc-observer/index.js +1 -3
  6. package/dist/cjs/vc/vc-observer/observers/index.js +2 -3
  7. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  8. package/dist/cjs/vc/vc-observer-new/get-element-name.js +29 -1
  9. package/dist/cjs/vc/vc-observer-new/index.js +2 -6
  10. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +8 -14
  11. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +25 -0
  12. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +63 -0
  13. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +28 -0
  14. package/dist/es2019/interaction-metrics/index.js +1 -2
  15. package/dist/es2019/interaction-metrics-init/index.js +1 -2
  16. package/dist/es2019/vc/index.js +4 -12
  17. package/dist/es2019/vc/vc-observer/index.js +1 -3
  18. package/dist/es2019/vc/vc-observer/observers/index.js +2 -3
  19. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +3 -12
  20. package/dist/es2019/vc/vc-observer-new/get-element-name.js +29 -1
  21. package/dist/es2019/vc/vc-observer-new/index.js +2 -6
  22. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +6 -15
  23. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  24. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  25. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  26. package/dist/esm/interaction-metrics/index.js +1 -2
  27. package/dist/esm/interaction-metrics-init/index.js +1 -2
  28. package/dist/esm/vc/index.js +4 -12
  29. package/dist/esm/vc/vc-observer/index.js +1 -3
  30. package/dist/esm/vc/vc-observer/observers/index.js +2 -3
  31. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  32. package/dist/esm/vc/vc-observer-new/get-element-name.js +29 -1
  33. package/dist/esm/vc/vc-observer-new/index.js +2 -6
  34. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +6 -14
  35. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  36. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  37. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  38. package/dist/types/config/index.d.ts +0 -4
  39. package/dist/types/vc/types.d.ts +0 -4
  40. package/dist/types/vc/vc-observer/observers/index.d.ts +0 -4
  41. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  42. package/dist/types/vc/vc-observer-new/index.d.ts +0 -4
  43. package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  44. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  45. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  46. package/dist/types/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  47. package/dist/types-ts4.5/config/index.d.ts +0 -4
  48. package/dist/types-ts4.5/vc/types.d.ts +0 -4
  49. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +0 -4
  50. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  51. package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +0 -4
  52. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  53. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  54. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  55. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  56. package/package.json +4 -1
  57. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -69
  58. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -60
  59. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -62
  60. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
  61. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e4fd6ff836b97`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e4fd6ff836b97) -
8
+ Update `error` selector return by TTVC offenders reporting
9
+
10
+ ## 4.2.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#195899](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195899)
15
+ [`ab2e2b57fa3fc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ab2e2b57fa3fc) -
16
+ Deprecating optional, experimental API about disabling SSR placeholder check of size and position
17
+
3
18
  ## 4.1.13
4
19
 
5
20
  ### Patch Changes
@@ -934,8 +934,7 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
934
934
  oldDomUpdates: config.vc.oldDomUpdates,
935
935
  devToolsEnabled: config.vc.devToolsEnabled,
936
936
  selectorConfig: config.vc.selectorConfig,
937
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
938
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
937
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
939
938
  };
940
939
  vcObserver = (0, _vc.newVCObserver)(vcOptions);
941
940
  }
@@ -95,8 +95,7 @@ function init(analyticsWebClientAsync, config) {
95
95
  oldDomUpdates: config.vc.oldDomUpdates,
96
96
  devToolsEnabled: config.vc.devToolsEnabled,
97
97
  selectorConfig: config.vc.selectorConfig,
98
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
99
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
98
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
100
99
  };
101
100
  _interactionMetrics.postInteractionLog.initializeVCObserver(vcOptions);
102
101
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
@@ -25,7 +25,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
25
25
  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; }
26
26
  var VCObserverWrapper = exports.VCObserverWrapper = /*#__PURE__*/function () {
27
27
  function VCObserverWrapper() {
28
- var _opts$ssrEnablePageLa, _opts$disableSizeAndP;
28
+ var _opts$ssrEnablePageLa;
29
29
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
30
  (0, _classCallCheck2.default)(this, VCObserverWrapper);
31
31
  this.newVCObserver = null;
@@ -33,23 +33,15 @@ var VCObserverWrapper = exports.VCObserverWrapper = /*#__PURE__*/function () {
33
33
 
34
34
  // Initialize SSR placeholder handler once
35
35
  this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers({
36
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false,
37
- disableSizeAndPositionCheck: (_opts$disableSizeAndP = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP !== void 0 ? _opts$disableSizeAndP : {
38
- v: false,
39
- h: false
40
- }
36
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false
41
37
  });
42
38
  if ((0, _config.isVCRevisionEnabled)('fy25.03')) {
43
- var _opts$ssrEnablePageLa2, _opts$disableSizeAndP2;
39
+ var _opts$ssrEnablePageLa2;
44
40
  this.newVCObserver = new _vcObserverNew.default({
45
41
  selectorConfig: opts.selectorConfig,
46
42
  isPostInteraction: opts.isPostInteraction,
47
43
  SSRConfig: {
48
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false,
49
- disableSizeAndPositionCheck: (_opts$disableSizeAndP2 = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP2 !== void 0 ? _opts$disableSizeAndP2 : {
50
- v: false,
51
- h: false
52
- }
44
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false
53
45
  },
54
46
  ssrPlaceholderHandler: this.ssrPlaceholderHandler
55
47
  });
@@ -461,7 +461,6 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
461
461
  this.devToolsEnabled = options.devToolsEnabled || false;
462
462
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
463
463
  var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
464
- disableSizeAndPositionCheck = options.disableSizeAndPositionCheck,
465
464
  ssrPlaceholderHandler = options.ssrPlaceholderHandler;
466
465
  this.observers = new _observers.Observers({
467
466
  selectorConfig: options.selectorConfig || {
@@ -472,8 +471,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
472
471
  dataVC: true
473
472
  },
474
473
  SSRConfig: {
475
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
476
- disableSizeAndPositionCheck: disableSizeAndPositionCheck
474
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
477
475
  },
478
476
  ssrPlaceholderHandler: ssrPlaceholderHandler
479
477
  });
@@ -77,10 +77,9 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
77
77
  if (opts.ssrPlaceholderHandler) {
78
78
  this.ssrPlaceholderHandler = opts.ssrPlaceholderHandler;
79
79
  } else {
80
- var _opts$SSRConfig, _opts$SSRConfig2;
80
+ var _opts$SSRConfig;
81
81
  this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers({
82
- enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
83
- disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
82
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder
84
83
  });
85
84
  }
86
85
  }
@@ -14,12 +14,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
14
14
  function SSRPlaceholderHandlers(_ref) {
15
15
  var _this = this;
16
16
  var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
17
- enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
18
- _ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
19
- disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
20
- v: false,
21
- h: false
22
- } : _ref$disableSizeAndPo;
17
+ enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout;
23
18
  (0, _classCallCheck2.default)(this, SSRPlaceholderHandlers);
24
19
  (0, _defineProperty2.default)(this, "staticPlaceholders", new Map());
25
20
  (0, _defineProperty2.default)(this, "callbacks", new Map());
@@ -108,7 +103,6 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
108
103
  });
109
104
  }
110
105
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
111
- this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
112
106
  if (window.document) {
113
107
  try {
114
108
  // Collect initial placeholders using SSR dimensions
@@ -266,15 +260,11 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
266
260
  }, {
267
261
  key: "hasSameSizePosition",
268
262
  value: function hasSameSizePosition(rect, boundingClientRect) {
269
- var _this$disableSizeAndP, _this$disableSizeAndP2;
270
- if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
271
- return true;
272
- }
273
263
  if (!rect) {
274
264
  return false;
275
265
  }
276
- var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
277
- var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
266
+ var horizontalCheck = Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
267
+ var verticalCheck = Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
278
268
  return horizontalCheck && verticalCheck || false;
279
269
  }
280
270
  }, {
@@ -4,10 +4,38 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
8
  var nameCache = new WeakMap();
8
9
  function getElementName(selectorConfig, element) {
9
10
  if (!(element instanceof HTMLElement)) {
10
- return 'error';
11
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_report_non_htmlelement_selectors')) {
12
+ var elementInstance = 'Unknown';
13
+
14
+ // Types of elements according to LLM
15
+ if (element instanceof Document) {
16
+ elementInstance = 'Document';
17
+ } else if (element instanceof DocumentFragment) {
18
+ elementInstance = 'DocumentFragment';
19
+ } else if (element instanceof Text) {
20
+ elementInstance = 'Text';
21
+ } else if (element instanceof Comment) {
22
+ elementInstance = 'Comment';
23
+ } else if (element instanceof ProcessingInstruction) {
24
+ elementInstance = 'ProcessingInstruction';
25
+ } else if (element instanceof Attr) {
26
+ elementInstance = 'Attr';
27
+ } else if (element instanceof CDATASection) {
28
+ elementInstance = 'CDATASection';
29
+ }
30
+ if (element.parentElement && element.parentElement instanceof HTMLElement) {
31
+ var parentElementSelector = getElementName(selectorConfig, element.parentElement);
32
+ return "".concat(parentElementSelector, " > ").concat(elementInstance);
33
+ } else {
34
+ return elementInstance;
35
+ }
36
+ } else {
37
+ return 'error';
38
+ }
11
39
  }
12
40
  var cachedName = nameCache.get(element);
13
41
  if (cachedName) {
@@ -56,13 +56,9 @@ var VCObserverNew = exports.default = /*#__PURE__*/function () {
56
56
  if (config.ssrPlaceholderHandler) {
57
57
  this.ssrPlaceholderHandler = config.ssrPlaceholderHandler;
58
58
  } else {
59
- var _config$SSRConfig$ena, _config$SSRConfig, _config$SSRConfig$dis, _config$SSRConfig2;
59
+ var _config$SSRConfig$ena, _config$SSRConfig;
60
60
  this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers({
61
- enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false,
62
- disableSizeAndPositionCheck: (_config$SSRConfig$dis = (_config$SSRConfig2 = config.SSRConfig) === null || _config$SSRConfig2 === void 0 ? void 0 : _config$SSRConfig2.disableSizeAndPositionCheck) !== null && _config$SSRConfig$dis !== void 0 ? _config$SSRConfig$dis : {
63
- v: false,
64
- h: false
65
- }
61
+ enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false
66
62
  });
67
63
  }
68
64
  this.viewportObserver = new _viewportObserver.default({
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -16,8 +17,9 @@ var _rllPlaceholders = require("../../vc-observer/observers/rll-placeholders");
16
17
  var _intersectionObserver = require("./intersection-observer");
17
18
  var _mutationObserver = _interopRequireDefault(require("./mutation-observer"));
18
19
  var _performanceObserver = _interopRequireDefault(require("./performance-observer"));
19
- var _checkWithinComponentAndExtractChildProps = _interopRequireDefault(require("./utils/check-within-component-and-extract-child-props"));
20
+ var _checkWithinComponent2 = _interopRequireWildcard(require("./utils/check-within-component"));
20
21
  var _isInVcIgnoreIfNoLayoutShiftMarker = _interopRequireDefault(require("./utils/is-in-vc-ignore-if-no-layout-shift-marker"));
22
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
23
  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; } } }; }
22
24
  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; } }
23
25
  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; }
@@ -229,7 +231,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
229
231
  (_this$intersectionObs6 = _this.intersectionObserver) === null || _this$intersectionObs6 === void 0 || _this$intersectionObs6.watchAndTag(addedNode, 'mutation:media');
230
232
  return _context.abrupt("return", 0);
231
233
  case 44:
232
- _checkWithinComponent = (0, _checkWithinComponentAndExtractChildProps.default)(addedNode, 'UFOThirdPartySegment'), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
234
+ _checkWithinComponent = (0, _checkWithinComponent2.default)(addedNode, 'UFOThirdPartySegment', _this.mapIs3pResult), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
233
235
  if (!isWithinThirdPartySegment) {
234
236
  _context.next = 48;
235
237
  break;
@@ -326,18 +328,6 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
326
328
  }
327
329
  };
328
330
  }
329
- var _checkWithinComponent2 = (0, _checkWithinComponentAndExtractChildProps.default)(target, 'UFOThirdPartySegment'),
330
- isWithinThirdPartySegment = _checkWithinComponent2.isWithin;
331
- if (isWithinThirdPartySegment) {
332
- return {
333
- type: 'mutation:third-party-element',
334
- mutationData: {
335
- attributeName: attributeName,
336
- oldValue: oldValue,
337
- newValue: newValue
338
- }
339
- };
340
- }
341
331
  var lastElementRect = _this.mapVisibleNodeRects.get(target);
342
332
  if (lastElementRect && sameRectSize(rect, lastElementRect)) {
343
333
  return {
@@ -358,6 +348,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
358
348
  }
359
349
  };
360
350
  });
351
+ // }
361
352
  });
362
353
  (0, _defineProperty2.default)(this, "handleLayoutShift", function (_ref8) {
363
354
  var time = _ref8.time,
@@ -386,6 +377,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
386
377
  }
387
378
  });
388
379
  this.mapVisibleNodeRects = new WeakMap();
380
+ this.mapIs3pResult = new WeakMap();
389
381
  this.onChange = onChange;
390
382
  this.isStarted = false;
391
383
  this.intersectionObserver = null;
@@ -446,6 +438,8 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
446
438
  (_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.disconnect();
447
439
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
448
440
  this.isStarted = false;
441
+ // Clean up caches when stopping
442
+ (0, _checkWithinComponent2.cleanupCaches)(this.mapIs3pResult);
449
443
  }
450
444
  }]);
451
445
  }();
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = checkFiberWithinComponent;
8
+ var _getComponentName = _interopRequireDefault(require("./get-component-name"));
9
+ // Helper to check fiber within component
10
+ function checkFiberWithinComponent(fiber, targetComponentName, maxLevel) {
11
+ // Stop when no more levels to traverse
12
+ if (maxLevel <= 0) {
13
+ return false;
14
+ }
15
+ if (!fiber) {
16
+ return false;
17
+ }
18
+ var componentName = (0, _getComponentName.default)(fiber);
19
+ if (componentName === targetComponentName) {
20
+ return true;
21
+ }
22
+
23
+ // Recursively traverse up the fiber tree
24
+ return checkFiberWithinComponent(fiber.return, targetComponentName, maxLevel - 1);
25
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.cleanupCaches = cleanupCaches;
8
+ exports.default = checkWithinComponent;
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _coinflip = _interopRequireDefault(require("../../../../coinflip"));
11
+ var _checkFiberWithinComponent = _interopRequireDefault(require("./check-fiber-within-component"));
12
+ var _findFiberWithCache = _interopRequireDefault(require("./find-fiber-with-cache"));
13
+ var _findReactFiber = _interopRequireDefault(require("./find-react-fiber"));
14
+ var DEFAULT_MAX_LEVEL = 20;
15
+
16
+ // Cache cleanup
17
+ var callCount = 0;
18
+ var CLEANUP_THRESHOLD = 50;
19
+ function maybeCleanup(resultCache) {
20
+ callCount++;
21
+ if (callCount >= CLEANUP_THRESHOLD && (0, _coinflip.default)(0.3)) {
22
+ cleanupCaches(resultCache);
23
+ }
24
+ }
25
+ function cleanupCaches(resultCache) {
26
+ resultCache = new WeakMap();
27
+ callCount = 0;
28
+ }
29
+ function checkWithinComponent(node, targetComponentName, resultCache) {
30
+ maybeCleanup(resultCache);
31
+ if (resultCache.has(node)) {
32
+ var _resultCache$get;
33
+ return {
34
+ isWithin: (_resultCache$get = resultCache.get(node)) !== null && _resultCache$get !== void 0 ? _resultCache$get : false
35
+ };
36
+ }
37
+ var fiber = null;
38
+ var checkedNodes = [];
39
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
40
+ fiber = (0, _findFiberWithCache.default)(node, DEFAULT_MAX_LEVEL, checkedNodes);
41
+ } else {
42
+ fiber = (0, _findReactFiber.default)(node);
43
+ }
44
+ if (!fiber) {
45
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
46
+ checkedNodes.forEach(function (checkedNode) {
47
+ resultCache.set(checkedNode, false);
48
+ });
49
+ }
50
+ return {
51
+ isWithin: false
52
+ };
53
+ }
54
+ var isWithin = (0, _checkFiberWithinComponent.default)(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
55
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_handle_non_react_element_for_3p')) {
56
+ checkedNodes.forEach(function (checkedNode) {
57
+ resultCache.set(checkedNode, isWithin);
58
+ });
59
+ }
60
+ return {
61
+ isWithin: isWithin
62
+ };
63
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = findFiberWithCache;
8
+ var _findReactFiber = _interopRequireDefault(require("./find-react-fiber"));
9
+ function findFiberWithCache(element, maxLevel, checkedNodes) {
10
+ // Stop when no more levels to traverse
11
+ if (maxLevel <= 0) {
12
+ return null;
13
+ }
14
+ checkedNodes.push(element);
15
+ var fiber = (0, _findReactFiber.default)(element);
16
+ if (fiber) {
17
+ return fiber;
18
+ }
19
+
20
+ // Walk up the DOM tree to find the fiber
21
+ var parent = element.parentElement;
22
+ if (!parent) {
23
+ return null;
24
+ }
25
+
26
+ // Recursively check parent
27
+ return findFiberWithCache(parent, maxLevel - 1, checkedNodes);
28
+ }
@@ -809,8 +809,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
809
809
  oldDomUpdates: config.vc.oldDomUpdates,
810
810
  devToolsEnabled: config.vc.devToolsEnabled,
811
811
  selectorConfig: config.vc.selectorConfig,
812
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
813
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
812
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
814
813
  };
815
814
  vcObserver = newVCObserver(vcOptions);
816
815
  }
@@ -85,8 +85,7 @@ export function init(analyticsWebClientAsync, config) {
85
85
  oldDomUpdates: config.vc.oldDomUpdates,
86
86
  devToolsEnabled: config.vc.devToolsEnabled,
87
87
  selectorConfig: config.vc.selectorConfig,
88
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
89
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
88
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
90
89
  };
91
90
  postInteractionLog.initializeVCObserver(vcOptions);
92
91
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
@@ -7,29 +7,21 @@ import { RLLPlaceholderHandlers } from './vc-observer/observers/rll-placeholders
7
7
  import { SSRPlaceholderHandlers } from './vc-observer/observers/ssr-placeholders';
8
8
  export class VCObserverWrapper {
9
9
  constructor(opts = {}) {
10
- var _opts$ssrEnablePageLa, _opts$disableSizeAndP;
10
+ var _opts$ssrEnablePageLa;
11
11
  this.newVCObserver = null;
12
12
  this.oldVCObserver = null;
13
13
 
14
14
  // Initialize SSR placeholder handler once
15
15
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
16
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false,
17
- disableSizeAndPositionCheck: (_opts$disableSizeAndP = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP !== void 0 ? _opts$disableSizeAndP : {
18
- v: false,
19
- h: false
20
- }
16
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false
21
17
  });
22
18
  if (isVCRevisionEnabled('fy25.03')) {
23
- var _opts$ssrEnablePageLa2, _opts$disableSizeAndP2;
19
+ var _opts$ssrEnablePageLa2;
24
20
  this.newVCObserver = new VCObserverNew({
25
21
  selectorConfig: opts.selectorConfig,
26
22
  isPostInteraction: opts.isPostInteraction,
27
23
  SSRConfig: {
28
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false,
29
- disableSizeAndPositionCheck: (_opts$disableSizeAndP2 = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP2 !== void 0 ? _opts$disableSizeAndP2 : {
30
- v: false,
31
- h: false
32
- }
24
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false
33
25
  },
34
26
  ssrPlaceholderHandler: this.ssrPlaceholderHandler
35
27
  });
@@ -501,7 +501,6 @@ export class VCObserver {
501
501
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
502
502
  const {
503
503
  ssrEnablePageLayoutPlaceholder,
504
- disableSizeAndPositionCheck,
505
504
  ssrPlaceholderHandler
506
505
  } = options;
507
506
  this.observers = new Observers({
@@ -513,8 +512,7 @@ export class VCObserver {
513
512
  dataVC: true
514
513
  },
515
514
  SSRConfig: {
516
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
517
- disableSizeAndPositionCheck: disableSizeAndPositionCheck
515
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
518
516
  },
519
517
  ssrPlaceholderHandler: ssrPlaceholderHandler
520
518
  });
@@ -65,10 +65,9 @@ export class Observers {
65
65
  if (opts.ssrPlaceholderHandler) {
66
66
  this.ssrPlaceholderHandler = opts.ssrPlaceholderHandler;
67
67
  } else {
68
- var _opts$SSRConfig, _opts$SSRConfig2;
68
+ var _opts$SSRConfig;
69
69
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
70
- enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
71
- disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
70
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder
72
71
  });
73
72
  }
74
73
  }
@@ -3,11 +3,7 @@ const ANCESTOR_LOOKUP_LIMIT = 10;
3
3
  const PAGE_LAYOUT_ID = 'page-layout.root';
4
4
  export class SSRPlaceholderHandlers {
5
5
  constructor({
6
- enablePageLayoutPlaceholder = false,
7
- disableSizeAndPositionCheck = {
8
- v: false,
9
- h: false
10
- }
6
+ enablePageLayoutPlaceholder = false
11
7
  }) {
12
8
  _defineProperty(this, "staticPlaceholders", new Map());
13
9
  _defineProperty(this, "callbacks", new Map());
@@ -93,7 +89,6 @@ export class SSRPlaceholderHandlers {
93
89
  this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
94
90
  }
95
91
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
96
- this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
97
92
  if (window.document) {
98
93
  try {
99
94
  // Collect initial placeholders using SSR dimensions
@@ -225,15 +220,11 @@ export class SSRPlaceholderHandlers {
225
220
  });
226
221
  }
227
222
  hasSameSizePosition(rect, boundingClientRect) {
228
- var _this$disableSizeAndP, _this$disableSizeAndP2;
229
- if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
230
- return true;
231
- }
232
223
  if (!rect) {
233
224
  return false;
234
225
  }
235
- const horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
236
- const verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
226
+ const horizontalCheck = Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
227
+ const verticalCheck = Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
237
228
  return horizontalCheck && verticalCheck || false;
238
229
  }
239
230
  isDummyRect(rect) {
@@ -1,7 +1,35 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  const nameCache = new WeakMap();
2
3
  function getElementName(selectorConfig, element) {
3
4
  if (!(element instanceof HTMLElement)) {
4
- return 'error';
5
+ if (fg('platform_ufo_report_non_htmlelement_selectors')) {
6
+ let elementInstance = 'Unknown';
7
+
8
+ // Types of elements according to LLM
9
+ if (element instanceof Document) {
10
+ elementInstance = 'Document';
11
+ } else if (element instanceof DocumentFragment) {
12
+ elementInstance = 'DocumentFragment';
13
+ } else if (element instanceof Text) {
14
+ elementInstance = 'Text';
15
+ } else if (element instanceof Comment) {
16
+ elementInstance = 'Comment';
17
+ } else if (element instanceof ProcessingInstruction) {
18
+ elementInstance = 'ProcessingInstruction';
19
+ } else if (element instanceof Attr) {
20
+ elementInstance = 'Attr';
21
+ } else if (element instanceof CDATASection) {
22
+ elementInstance = 'CDATASection';
23
+ }
24
+ if (element.parentElement && element.parentElement instanceof HTMLElement) {
25
+ const parentElementSelector = getElementName(selectorConfig, element.parentElement);
26
+ return `${parentElementSelector} > ${elementInstance}`;
27
+ } else {
28
+ return elementInstance;
29
+ }
30
+ } else {
31
+ return 'error';
32
+ }
5
33
  }
6
34
  const cachedName = nameCache.get(element);
7
35
  if (cachedName) {
@@ -40,13 +40,9 @@ export default class VCObserverNew {
40
40
  if (config.ssrPlaceholderHandler) {
41
41
  this.ssrPlaceholderHandler = config.ssrPlaceholderHandler;
42
42
  } else {
43
- var _config$SSRConfig$ena, _config$SSRConfig, _config$SSRConfig$dis, _config$SSRConfig2;
43
+ var _config$SSRConfig$ena, _config$SSRConfig;
44
44
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
45
- enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false,
46
- disableSizeAndPositionCheck: (_config$SSRConfig$dis = (_config$SSRConfig2 = config.SSRConfig) === null || _config$SSRConfig2 === void 0 ? void 0 : _config$SSRConfig2.disableSizeAndPositionCheck) !== null && _config$SSRConfig$dis !== void 0 ? _config$SSRConfig$dis : {
47
- v: false,
48
- h: false
49
- }
45
+ enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false
50
46
  });
51
47
  }
52
48
  this.viewportObserver = new ViewportObserver({