@atlaskit/react-ufo 4.1.12 → 4.2.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-payload/index.js +22 -4
  3. package/dist/cjs/create-payload/utils/add-performance-measures.js +62 -0
  4. package/dist/cjs/interaction-metrics/index.js +26 -2
  5. package/dist/cjs/interaction-metrics-init/index.js +1 -2
  6. package/dist/cjs/vc/index.js +7 -59
  7. package/dist/cjs/vc/vc-observer/index.js +1 -3
  8. package/dist/cjs/vc/vc-observer/observers/index.js +2 -3
  9. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  10. package/dist/cjs/vc/vc-observer-new/index.js +2 -6
  11. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +8 -14
  12. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +25 -0
  13. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +63 -0
  14. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +28 -0
  15. package/dist/es2019/create-payload/index.js +21 -3
  16. package/dist/es2019/create-payload/utils/add-performance-measures.js +54 -0
  17. package/dist/es2019/interaction-metrics/index.js +26 -2
  18. package/dist/es2019/interaction-metrics-init/index.js +1 -2
  19. package/dist/es2019/vc/index.js +4 -54
  20. package/dist/es2019/vc/vc-observer/index.js +1 -3
  21. package/dist/es2019/vc/vc-observer/observers/index.js +2 -3
  22. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +3 -12
  23. package/dist/es2019/vc/vc-observer-new/index.js +2 -6
  24. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +6 -15
  25. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  26. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  27. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  28. package/dist/esm/create-payload/index.js +22 -4
  29. package/dist/esm/create-payload/utils/add-performance-measures.js +56 -0
  30. package/dist/esm/interaction-metrics/index.js +26 -2
  31. package/dist/esm/interaction-metrics-init/index.js +1 -2
  32. package/dist/esm/vc/index.js +7 -59
  33. package/dist/esm/vc/vc-observer/index.js +1 -3
  34. package/dist/esm/vc/vc-observer/observers/index.js +2 -3
  35. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  36. package/dist/esm/vc/vc-observer-new/index.js +2 -6
  37. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +6 -14
  38. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  39. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  40. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  41. package/dist/types/config/index.d.ts +0 -4
  42. package/dist/types/create-payload/utils/add-performance-measures.d.ts +2 -0
  43. package/dist/types/ssr/index.d.ts +7 -1
  44. package/dist/types/vc/index.d.ts +0 -1
  45. package/dist/types/vc/types.d.ts +0 -4
  46. package/dist/types/vc/vc-observer/observers/index.d.ts +0 -4
  47. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  48. package/dist/types/vc/vc-observer-new/index.d.ts +0 -4
  49. package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  50. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  51. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  52. package/dist/types/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  53. package/dist/types-ts4.5/config/index.d.ts +0 -4
  54. package/dist/types-ts4.5/create-payload/utils/add-performance-measures.d.ts +2 -0
  55. package/dist/types-ts4.5/ssr/index.d.ts +7 -1
  56. package/dist/types-ts4.5/vc/index.d.ts +0 -1
  57. package/dist/types-ts4.5/vc/types.d.ts +0 -4
  58. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +0 -4
  59. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  60. package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +0 -4
  61. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  62. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  63. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  64. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  65. package/package.json +1 -1
  66. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -69
  67. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -60
  68. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -62
  69. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
  70. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
@@ -575,6 +575,7 @@ function finishInteraction(id, data) {
575
575
  data.end = endTime;
576
576
  try {
577
577
  // for Firefox 102 and older
578
+
578
579
  if (fg('ufo_chrome_devtools_uplift')) {
579
580
  performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
580
581
  start: data.start,
@@ -587,6 +588,14 @@ function finishInteraction(id, data) {
587
588
  }
588
589
  }
589
590
  });
591
+ performance.mark("TTAI", {
592
+ startTime: data.end,
593
+ detail: {
594
+ devtools: {
595
+ dataType: 'marker'
596
+ }
597
+ }
598
+ });
590
599
  } else {
591
600
  performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
592
601
  start: data.start,
@@ -879,8 +888,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
879
888
  oldDomUpdates: config.vc.oldDomUpdates,
880
889
  devToolsEnabled: config.vc.devToolsEnabled,
881
890
  selectorConfig: config.vc.selectorConfig,
882
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
883
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
891
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
884
892
  };
885
893
  vcObserver = newVCObserver(vcOptions);
886
894
  }
@@ -1028,6 +1036,14 @@ export function addApdexToAll(apdex) {
1028
1036
  }
1029
1037
  }
1030
1038
  });
1039
+ performance.mark("[bm3] TTI", {
1040
+ startTime: apdex.stopTime,
1041
+ detail: {
1042
+ devtools: {
1043
+ dataType: 'marker'
1044
+ }
1045
+ }
1046
+ });
1031
1047
  } else {
1032
1048
  var _apdex$startTime2;
1033
1049
  performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
@@ -1062,6 +1078,14 @@ export function addApdex(interactionId, apdexInfo) {
1062
1078
  }
1063
1079
  }
1064
1080
  });
1081
+ performance.mark("[bm3] TTI", {
1082
+ startTime: apdexInfo.stopTime,
1083
+ detail: {
1084
+ devtools: {
1085
+ dataType: 'marker'
1086
+ }
1087
+ }
1088
+ });
1065
1089
  } else {
1066
1090
  var _apdexInfo$startTime2;
1067
1091
  performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
@@ -86,8 +86,7 @@ export function init(analyticsWebClientAsync, config) {
86
86
  oldDomUpdates: config.vc.oldDomUpdates,
87
87
  devToolsEnabled: config.vc.devToolsEnabled,
88
88
  selectorConfig: config.vc.selectorConfig,
89
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
90
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
89
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
91
90
  };
92
91
  postInteractionLog.initializeVCObserver(vcOptions);
93
92
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
@@ -7,7 +7,6 @@ var _process;
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
10
  import { isVCRevisionEnabled } from '../config';
12
11
  import { VCObserverNOOP } from './no-op-vc-observer';
13
12
  import { VCObserver } from './vc-observer';
@@ -16,7 +15,7 @@ import { RLLPlaceholderHandlers } from './vc-observer/observers/rll-placeholders
16
15
  import { SSRPlaceholderHandlers } from './vc-observer/observers/ssr-placeholders';
17
16
  export var VCObserverWrapper = /*#__PURE__*/function () {
18
17
  function VCObserverWrapper() {
19
- var _opts$ssrEnablePageLa, _opts$disableSizeAndP;
18
+ var _opts$ssrEnablePageLa;
20
19
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
20
  _classCallCheck(this, VCObserverWrapper);
22
21
  this.newVCObserver = null;
@@ -24,23 +23,15 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
24
23
 
25
24
  // Initialize SSR placeholder handler once
26
25
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
27
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false,
28
- disableSizeAndPositionCheck: (_opts$disableSizeAndP = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP !== void 0 ? _opts$disableSizeAndP : {
29
- v: false,
30
- h: false
31
- }
26
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false
32
27
  });
33
28
  if (isVCRevisionEnabled('fy25.03')) {
34
- var _opts$ssrEnablePageLa2, _opts$disableSizeAndP2;
29
+ var _opts$ssrEnablePageLa2;
35
30
  this.newVCObserver = new VCObserverNew({
36
31
  selectorConfig: opts.selectorConfig,
37
32
  isPostInteraction: opts.isPostInteraction,
38
33
  SSRConfig: {
39
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false,
40
- disableSizeAndPositionCheck: (_opts$disableSizeAndP2 = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP2 !== void 0 ? _opts$disableSizeAndP2 : {
41
- v: false,
42
- h: false
43
- }
34
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false
44
35
  },
45
36
  ssrPlaceholderHandler: this.ssrPlaceholderHandler
46
37
  });
@@ -159,17 +150,16 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
159
150
  _context.t1 = [];
160
151
  case 16:
161
152
  v3Result = _context.t1;
162
- fg('ufo_chrome_devtools_uplift') && this.addPerformanceMeasures(param.start, [].concat(_toConsumableArray((v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) || []), _toConsumableArray(v3Result !== null && v3Result !== void 0 ? v3Result : [])));
163
153
  if (v3Result) {
164
- _context.next = 20;
154
+ _context.next = 19;
165
155
  break;
166
156
  }
167
157
  return _context.abrupt("return", v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {});
168
- case 20:
158
+ case 19:
169
159
  return _context.abrupt("return", _objectSpread(_objectSpread({}, v1v2Result), {}, {
170
160
  'ufo:vc:rev': [].concat(_toConsumableArray((_ref2 = v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) !== null && _ref2 !== void 0 ? _ref2 : []), _toConsumableArray(v3Result !== null && v3Result !== void 0 ? v3Result : []))
171
161
  }));
172
- case 21:
162
+ case 20:
173
163
  case "end":
174
164
  return _context.stop();
175
165
  }
@@ -206,48 +196,6 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
206
196
  value: function collectSSRPlaceholders() {
207
197
  this.ssrPlaceholderHandler.collectExistingPlaceholders();
208
198
  }
209
- }, {
210
- key: "addPerformanceMeasures",
211
- value: function addPerformanceMeasures(start, measures) {
212
- try {
213
- measures.forEach(function (entry) {
214
- var _entry$vcDetails;
215
- if (!entry || !entry.vcDetails) {
216
- return;
217
- }
218
- var VCParts = Object.keys(entry.vcDetails);
219
- performance.measure("VC90 (".concat(entry.revision, ")"), {
220
- start: start,
221
- duration: (_entry$vcDetails = entry.vcDetails) === null || _entry$vcDetails === void 0 || (_entry$vcDetails = _entry$vcDetails['90']) === null || _entry$vcDetails === void 0 ? void 0 : _entry$vcDetails.t,
222
- detail: {
223
- devtools: {
224
- track: "main metrics",
225
- trackGroup: '🛸 reactUFO metrics',
226
- color: 'tertiary'
227
- }
228
- }
229
- });
230
- VCParts.forEach(function (key) {
231
- var _entry$vcDetails2;
232
- var duration = (_entry$vcDetails2 = entry.vcDetails) === null || _entry$vcDetails2 === void 0 ? void 0 : _entry$vcDetails2[key].t;
233
- if (typeof duration !== 'number') {
234
- return;
235
- }
236
- performance.measure("VC".concat(key), {
237
- start: start,
238
- duration: duration,
239
- detail: {
240
- devtools: {
241
- track: "VC ".concat(entry.revision),
242
- trackGroup: '🛸 reactUFO metrics',
243
- color: key === '90' ? 'tertiary' : 'primary-light'
244
- }
245
- }
246
- });
247
- });
248
- });
249
- } catch (error) {}
250
- }
251
199
  }]);
252
200
  }();
253
201
 
@@ -454,7 +454,6 @@ export var VCObserver = /*#__PURE__*/function () {
454
454
  this.devToolsEnabled = options.devToolsEnabled || false;
455
455
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
456
456
  var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
457
- disableSizeAndPositionCheck = options.disableSizeAndPositionCheck,
458
457
  ssrPlaceholderHandler = options.ssrPlaceholderHandler;
459
458
  this.observers = new Observers({
460
459
  selectorConfig: options.selectorConfig || {
@@ -465,8 +464,7 @@ export var VCObserver = /*#__PURE__*/function () {
465
464
  dataVC: true
466
465
  },
467
466
  SSRConfig: {
468
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
469
- disableSizeAndPositionCheck: disableSizeAndPositionCheck
467
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
470
468
  },
471
469
  ssrPlaceholderHandler: ssrPlaceholderHandler
472
470
  });
@@ -70,10 +70,9 @@ export var Observers = /*#__PURE__*/function () {
70
70
  if (opts.ssrPlaceholderHandler) {
71
71
  this.ssrPlaceholderHandler = opts.ssrPlaceholderHandler;
72
72
  } else {
73
- var _opts$SSRConfig, _opts$SSRConfig2;
73
+ var _opts$SSRConfig;
74
74
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
75
- enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
76
- disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
75
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder
77
76
  });
78
77
  }
79
78
  }
@@ -7,12 +7,7 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
7
7
  function SSRPlaceholderHandlers(_ref) {
8
8
  var _this = this;
9
9
  var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
10
- enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
11
- _ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
12
- disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
13
- v: false,
14
- h: false
15
- } : _ref$disableSizeAndPo;
10
+ enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout;
16
11
  _classCallCheck(this, SSRPlaceholderHandlers);
17
12
  _defineProperty(this, "staticPlaceholders", new Map());
18
13
  _defineProperty(this, "callbacks", new Map());
@@ -101,7 +96,6 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
101
96
  });
102
97
  }
103
98
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
104
- this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
105
99
  if (window.document) {
106
100
  try {
107
101
  // Collect initial placeholders using SSR dimensions
@@ -259,15 +253,11 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
259
253
  }, {
260
254
  key: "hasSameSizePosition",
261
255
  value: function hasSameSizePosition(rect, boundingClientRect) {
262
- var _this$disableSizeAndP, _this$disableSizeAndP2;
263
- 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) {
264
- return true;
265
- }
266
256
  if (!rect) {
267
257
  return false;
268
258
  }
269
- var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
270
- var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
259
+ var horizontalCheck = Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
260
+ var verticalCheck = Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
271
261
  return horizontalCheck && verticalCheck || false;
272
262
  }
273
263
  }, {
@@ -49,13 +49,9 @@ var VCObserverNew = /*#__PURE__*/function () {
49
49
  if (config.ssrPlaceholderHandler) {
50
50
  this.ssrPlaceholderHandler = config.ssrPlaceholderHandler;
51
51
  } else {
52
- var _config$SSRConfig$ena, _config$SSRConfig, _config$SSRConfig$dis, _config$SSRConfig2;
52
+ var _config$SSRConfig$ena, _config$SSRConfig;
53
53
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
54
- 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,
55
- 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 : {
56
- v: false,
57
- h: false
58
- }
54
+ 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
59
55
  });
60
56
  }
61
57
  this.viewportObserver = new ViewportObserver({
@@ -12,7 +12,7 @@ import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placehol
12
12
  import { createIntersectionObserver } from './intersection-observer';
13
13
  import createMutationObserver from './mutation-observer';
14
14
  import createPerformanceObserver from './performance-observer';
15
- import checkWithinComponentAndExtractChildProps from './utils/check-within-component-and-extract-child-props';
15
+ import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
16
16
  import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
17
17
  function isElementVisible(element) {
18
18
  if (!(element instanceof HTMLElement)) {
@@ -222,7 +222,7 @@ var ViewportObserver = /*#__PURE__*/function () {
222
222
  (_this$intersectionObs6 = _this.intersectionObserver) === null || _this$intersectionObs6 === void 0 || _this$intersectionObs6.watchAndTag(addedNode, 'mutation:media');
223
223
  return _context.abrupt("return", 0);
224
224
  case 44:
225
- _checkWithinComponent = checkWithinComponentAndExtractChildProps(addedNode, 'UFOThirdPartySegment'), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
225
+ _checkWithinComponent = checkWithinComponent(addedNode, 'UFOThirdPartySegment', _this.mapIs3pResult), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
226
226
  if (!isWithinThirdPartySegment) {
227
227
  _context.next = 48;
228
228
  break;
@@ -319,18 +319,6 @@ var ViewportObserver = /*#__PURE__*/function () {
319
319
  }
320
320
  };
321
321
  }
322
- var _checkWithinComponent2 = checkWithinComponentAndExtractChildProps(target, 'UFOThirdPartySegment'),
323
- isWithinThirdPartySegment = _checkWithinComponent2.isWithin;
324
- if (isWithinThirdPartySegment) {
325
- return {
326
- type: 'mutation:third-party-element',
327
- mutationData: {
328
- attributeName: attributeName,
329
- oldValue: oldValue,
330
- newValue: newValue
331
- }
332
- };
333
- }
334
322
  var lastElementRect = _this.mapVisibleNodeRects.get(target);
335
323
  if (lastElementRect && sameRectSize(rect, lastElementRect)) {
336
324
  return {
@@ -351,6 +339,7 @@ var ViewportObserver = /*#__PURE__*/function () {
351
339
  }
352
340
  };
353
341
  });
342
+ // }
354
343
  });
355
344
  _defineProperty(this, "handleLayoutShift", function (_ref8) {
356
345
  var time = _ref8.time,
@@ -379,6 +368,7 @@ var ViewportObserver = /*#__PURE__*/function () {
379
368
  }
380
369
  });
381
370
  this.mapVisibleNodeRects = new WeakMap();
371
+ this.mapIs3pResult = new WeakMap();
382
372
  this.onChange = onChange;
383
373
  this.isStarted = false;
384
374
  this.intersectionObserver = null;
@@ -439,6 +429,8 @@ var ViewportObserver = /*#__PURE__*/function () {
439
429
  (_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.disconnect();
440
430
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
441
431
  this.isStarted = false;
432
+ // Clean up caches when stopping
433
+ cleanupCaches(this.mapIs3pResult);
442
434
  }
443
435
  }]);
444
436
  }();
@@ -0,0 +1,19 @@
1
+ import getComponentName from './get-component-name';
2
+
3
+ // Helper to check fiber within component
4
+ export default function checkFiberWithinComponent(fiber, targetComponentName, maxLevel) {
5
+ // Stop when no more levels to traverse
6
+ if (maxLevel <= 0) {
7
+ return false;
8
+ }
9
+ if (!fiber) {
10
+ return false;
11
+ }
12
+ var componentName = getComponentName(fiber);
13
+ if (componentName === targetComponentName) {
14
+ return true;
15
+ }
16
+
17
+ // Recursively traverse up the fiber tree
18
+ return checkFiberWithinComponent(fiber.return, targetComponentName, maxLevel - 1);
19
+ }
@@ -0,0 +1,55 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import coinflip from '../../../../coinflip';
3
+ import checkFiberWithinComponent from './check-fiber-within-component';
4
+ import findFiberWithCache from './find-fiber-with-cache';
5
+ import findReactFiber from './find-react-fiber';
6
+ var DEFAULT_MAX_LEVEL = 20;
7
+
8
+ // Cache cleanup
9
+ var callCount = 0;
10
+ var CLEANUP_THRESHOLD = 50;
11
+ function maybeCleanup(resultCache) {
12
+ callCount++;
13
+ if (callCount >= CLEANUP_THRESHOLD && coinflip(0.3)) {
14
+ cleanupCaches(resultCache);
15
+ }
16
+ }
17
+ export function cleanupCaches(resultCache) {
18
+ resultCache = new WeakMap();
19
+ callCount = 0;
20
+ }
21
+ export default function checkWithinComponent(node, targetComponentName, resultCache) {
22
+ maybeCleanup(resultCache);
23
+ if (resultCache.has(node)) {
24
+ var _resultCache$get;
25
+ return {
26
+ isWithin: (_resultCache$get = resultCache.get(node)) !== null && _resultCache$get !== void 0 ? _resultCache$get : false
27
+ };
28
+ }
29
+ var fiber = null;
30
+ var checkedNodes = [];
31
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
32
+ fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
33
+ } else {
34
+ fiber = findReactFiber(node);
35
+ }
36
+ if (!fiber) {
37
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
38
+ checkedNodes.forEach(function (checkedNode) {
39
+ resultCache.set(checkedNode, false);
40
+ });
41
+ }
42
+ return {
43
+ isWithin: false
44
+ };
45
+ }
46
+ var isWithin = checkFiberWithinComponent(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
47
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
48
+ checkedNodes.forEach(function (checkedNode) {
49
+ resultCache.set(checkedNode, isWithin);
50
+ });
51
+ }
52
+ return {
53
+ isWithin: isWithin
54
+ };
55
+ }
@@ -0,0 +1,21 @@
1
+ import findReactFiber from './find-react-fiber';
2
+ export default function findFiberWithCache(element, maxLevel, checkedNodes) {
3
+ // Stop when no more levels to traverse
4
+ if (maxLevel <= 0) {
5
+ return null;
6
+ }
7
+ checkedNodes.push(element);
8
+ var fiber = findReactFiber(element);
9
+ if (fiber) {
10
+ return fiber;
11
+ }
12
+
13
+ // Walk up the DOM tree to find the fiber
14
+ var parent = element.parentElement;
15
+ if (!parent) {
16
+ return null;
17
+ }
18
+
19
+ // Recursively check parent
20
+ return findFiberWithCache(parent, maxLevel - 1, checkedNodes);
21
+ }
@@ -77,10 +77,6 @@ export type Config = {
77
77
  readonly ssr?: boolean;
78
78
  readonly ssrWhitelist?: string[];
79
79
  readonly ssrEnablePageLayoutPlaceholder?: boolean;
80
- readonly disableSizeAndPositionCheck?: {
81
- v: boolean;
82
- h: boolean;
83
- };
84
80
  readonly includeSSRInV3?: boolean;
85
81
  readonly stopVCAtInteractionFinish?: boolean;
86
82
  readonly includeSSRRatio?: boolean;
@@ -0,0 +1,2 @@
1
+ import type { RevisionPayload } from '../../common/vc/types';
2
+ export declare const addPerformanceMeasures: (start: number, measures: RevisionPayload) => void;
@@ -12,7 +12,8 @@ export type SSRFeatureFlags = {
12
12
  };
13
13
  export type SSRConfig = {
14
14
  /**
15
- * Used to represent whether SSR as a whole was considered successful. You can consider this the success of the "render" phase success
15
+ * Used to represent whether SSR as a whole was considered successful. You can consider this the success of the "render" phase success.
16
+ * Also may be used as the FMP mark
16
17
  */
17
18
  getDoneMark: () => number | null;
18
19
  /**
@@ -31,6 +32,10 @@ export type SSRConfig = {
31
32
  * This is generally expected to be earlier than / independant of the prefetch data and may even be non-visual (eg: <link rel="preload" href="..."> tags).
32
33
  */
33
34
  earlyFlush?: boolean;
35
+ /**
36
+ * "done" if present can override the presence / absence of the done mark in the overral SSR success status ('ssr:success').
37
+ */
38
+ done?: boolean;
34
39
  };
35
40
  getFeatureFlags: () => SSRFeatureFlags | null;
36
41
  getTimings?: () => ReportedTimings | null;
@@ -41,6 +46,7 @@ export declare function getSSRSuccess(): boolean;
41
46
  export declare function getSSRPhaseSuccess(): {
42
47
  prefetch?: boolean;
43
48
  earlyFlush?: boolean;
49
+ done?: boolean;
44
50
  } | undefined;
45
51
  export declare function getSSRDoneTime(): number | undefined;
46
52
  export declare function getSSRFeatureFlags(): SSRFeatureFlags | undefined;
@@ -21,7 +21,6 @@ export declare class VCObserverWrapper implements VCObserverInterface {
21
21
  setReactRootRenderStart(startTime: number): void;
22
22
  setReactRootRenderStop(stopTime: number): void;
23
23
  collectSSRPlaceholders(): void;
24
- private addPerformanceMeasures;
25
24
  }
26
25
  export declare function isEnvironmentSupported(): boolean;
27
26
  export declare function getVCObserver(opts?: VCObserverOptions): VCObserverInterface;
@@ -26,10 +26,6 @@ export type VCObserverOptions = {
26
26
  selectorConfig?: SelectorConfig | undefined;
27
27
  isPostInteraction?: boolean;
28
28
  ssrEnablePageLayoutPlaceholder?: boolean;
29
- disableSizeAndPositionCheck?: {
30
- v: boolean;
31
- h: boolean;
32
- };
33
29
  ssrPlaceholderHandler?: any;
34
30
  };
35
31
  export interface VCObserverInterface {
@@ -12,10 +12,6 @@ type ConstructorOptions = {
12
12
  selectorConfig: SelectorConfig;
13
13
  SSRConfig?: {
14
14
  enablePageLayoutPlaceholder: boolean;
15
- disableSizeAndPositionCheck?: {
16
- v: boolean;
17
- h: boolean;
18
- };
19
15
  };
20
16
  ssrPlaceholderHandler?: SSRPlaceholderHandlers | null;
21
17
  };
@@ -4,13 +4,8 @@ type Rect = {
4
4
  width: number;
5
5
  height: number;
6
6
  };
7
- type DisableSizeAndPositionCheckType = {
8
- v: boolean;
9
- h: boolean;
10
- };
11
7
  type SSRPlaceholderHandlersConfig = {
12
8
  enablePageLayoutPlaceholder?: boolean;
13
- disableSizeAndPositionCheck?: DisableSizeAndPositionCheckType;
14
9
  };
15
10
  export declare class SSRPlaceholderHandlers {
16
11
  private staticPlaceholders;
@@ -20,8 +15,7 @@ export declare class SSRPlaceholderHandlers {
20
15
  private intersectionObserver;
21
16
  private EQUALITY_THRESHOLD;
22
17
  private enablePageLayoutPlaceholder;
23
- private disableSizeAndPositionCheck;
24
- constructor({ enablePageLayoutPlaceholder, disableSizeAndPositionCheck, }: SSRPlaceholderHandlersConfig);
18
+ constructor({ enablePageLayoutPlaceholder, }: SSRPlaceholderHandlersConfig);
25
19
  private getPlaceholderId;
26
20
  private getPlaceholderReplacementId;
27
21
  clear(): void;
@@ -7,10 +7,6 @@ export type VCObserverNewConfig = {
7
7
  isPostInteraction?: boolean;
8
8
  SSRConfig?: {
9
9
  enablePageLayoutPlaceholder?: boolean;
10
- disableSizeAndPositionCheck?: {
11
- v: boolean;
12
- h: boolean;
13
- };
14
10
  };
15
11
  ssrPlaceholderHandler?: SSRPlaceholderHandlers | null;
16
12
  };
@@ -18,6 +18,7 @@ export default class ViewportObserver {
18
18
  private mutationObserver;
19
19
  private performanceObserver;
20
20
  private mapVisibleNodeRects;
21
+ private mapIs3pResult;
21
22
  private onChange;
22
23
  private isStarted;
23
24
  private getSSRState?;
@@ -0,0 +1 @@
1
+ export default function checkFiberWithinComponent(fiber: any, targetComponentName: string, maxLevel: number): boolean;
@@ -0,0 +1,4 @@
1
+ export declare function cleanupCaches(resultCache: WeakMap<HTMLElement, boolean>): void;
2
+ export default function checkWithinComponent(node: HTMLElement, targetComponentName: string, resultCache: WeakMap<HTMLElement, boolean>): {
3
+ isWithin: boolean;
4
+ };
@@ -0,0 +1 @@
1
+ export default function findFiberWithCache(element: HTMLElement, maxLevel: number, checkedNodes: HTMLElement[]): any | null;
@@ -77,10 +77,6 @@ export type Config = {
77
77
  readonly ssr?: boolean;
78
78
  readonly ssrWhitelist?: string[];
79
79
  readonly ssrEnablePageLayoutPlaceholder?: boolean;
80
- readonly disableSizeAndPositionCheck?: {
81
- v: boolean;
82
- h: boolean;
83
- };
84
80
  readonly includeSSRInV3?: boolean;
85
81
  readonly stopVCAtInteractionFinish?: boolean;
86
82
  readonly includeSSRRatio?: boolean;
@@ -0,0 +1,2 @@
1
+ import type { RevisionPayload } from '../../common/vc/types';
2
+ export declare const addPerformanceMeasures: (start: number, measures: RevisionPayload) => void;
@@ -12,7 +12,8 @@ export type SSRFeatureFlags = {
12
12
  };
13
13
  export type SSRConfig = {
14
14
  /**
15
- * Used to represent whether SSR as a whole was considered successful. You can consider this the success of the "render" phase success
15
+ * Used to represent whether SSR as a whole was considered successful. You can consider this the success of the "render" phase success.
16
+ * Also may be used as the FMP mark
16
17
  */
17
18
  getDoneMark: () => number | null;
18
19
  /**
@@ -31,6 +32,10 @@ export type SSRConfig = {
31
32
  * This is generally expected to be earlier than / independant of the prefetch data and may even be non-visual (eg: <link rel="preload" href="..."> tags).
32
33
  */
33
34
  earlyFlush?: boolean;
35
+ /**
36
+ * "done" if present can override the presence / absence of the done mark in the overral SSR success status ('ssr:success').
37
+ */
38
+ done?: boolean;
34
39
  };
35
40
  getFeatureFlags: () => SSRFeatureFlags | null;
36
41
  getTimings?: () => ReportedTimings | null;
@@ -41,6 +46,7 @@ export declare function getSSRSuccess(): boolean;
41
46
  export declare function getSSRPhaseSuccess(): {
42
47
  prefetch?: boolean;
43
48
  earlyFlush?: boolean;
49
+ done?: boolean;
44
50
  } | undefined;
45
51
  export declare function getSSRDoneTime(): number | undefined;
46
52
  export declare function getSSRFeatureFlags(): SSRFeatureFlags | undefined;
@@ -21,7 +21,6 @@ export declare class VCObserverWrapper implements VCObserverInterface {
21
21
  setReactRootRenderStart(startTime: number): void;
22
22
  setReactRootRenderStop(stopTime: number): void;
23
23
  collectSSRPlaceholders(): void;
24
- private addPerformanceMeasures;
25
24
  }
26
25
  export declare function isEnvironmentSupported(): boolean;
27
26
  export declare function getVCObserver(opts?: VCObserverOptions): VCObserverInterface;
@@ -26,10 +26,6 @@ export type VCObserverOptions = {
26
26
  selectorConfig?: SelectorConfig | undefined;
27
27
  isPostInteraction?: boolean;
28
28
  ssrEnablePageLayoutPlaceholder?: boolean;
29
- disableSizeAndPositionCheck?: {
30
- v: boolean;
31
- h: boolean;
32
- };
33
29
  ssrPlaceholderHandler?: any;
34
30
  };
35
31
  export interface VCObserverInterface {
@@ -12,10 +12,6 @@ type ConstructorOptions = {
12
12
  selectorConfig: SelectorConfig;
13
13
  SSRConfig?: {
14
14
  enablePageLayoutPlaceholder: boolean;
15
- disableSizeAndPositionCheck?: {
16
- v: boolean;
17
- h: boolean;
18
- };
19
15
  };
20
16
  ssrPlaceholderHandler?: SSRPlaceholderHandlers | null;
21
17
  };