@atlaskit/react-ufo 3.14.6 → 3.14.8
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 +16 -0
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +14 -12
- package/dist/cjs/create-payload/utils/get-vc-metrics.js +17 -13
- package/dist/cjs/interaction-metrics/index.js +35 -15
- package/dist/cjs/interaction-metrics-init/index.js +5 -3
- package/dist/cjs/vc/index.js +46 -6
- package/dist/cjs/vc/vc-observer/index.js +10 -2
- package/dist/cjs/vc/vc-observer/observers/index.js +12 -7
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +76 -40
- package/dist/cjs/vc/vc-observer-new/index.js +84 -0
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +214 -71
- package/dist/cjs/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +97 -59
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +4 -2
- package/dist/es2019/create-payload/utils/get-vc-metrics.js +10 -4
- package/dist/es2019/interaction-metrics/index.js +36 -16
- package/dist/es2019/interaction-metrics-init/index.js +5 -3
- package/dist/es2019/vc/index.js +42 -5
- package/dist/es2019/vc/vc-observer/index.js +8 -2
- package/dist/es2019/vc/vc-observer/observers/index.js +11 -5
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +57 -26
- package/dist/es2019/vc/vc-observer-new/index.js +67 -1
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +87 -22
- package/dist/es2019/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +50 -34
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +14 -12
- package/dist/esm/create-payload/utils/get-vc-metrics.js +17 -13
- package/dist/esm/interaction-metrics/index.js +36 -16
- package/dist/esm/interaction-metrics-init/index.js +5 -3
- package/dist/esm/vc/index.js +45 -6
- package/dist/esm/vc/vc-observer/index.js +10 -2
- package/dist/esm/vc/vc-observer/observers/index.js +12 -7
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +76 -40
- package/dist/esm/vc/vc-observer-new/index.js +84 -0
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +214 -71
- package/dist/esm/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +97 -59
- package/dist/types/common/common/types.d.ts +4 -1
- package/dist/types/vc/index.d.ts +3 -0
- package/dist/types/vc/types.d.ts +2 -0
- package/dist/types/vc/vc-observer/index.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +6 -0
- package/dist/types/vc/vc-observer-new/index.d.ts +30 -0
- package/dist/types/vc/vc-observer-new/types.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +5 -1
- package/dist/types/vc/vc-observer-new/viewport-observer/mutation-observer/index.d.ts +2 -0
- package/dist/types-ts4.5/common/common/types.d.ts +4 -1
- package/dist/types-ts4.5/vc/index.d.ts +3 -0
- package/dist/types-ts4.5/vc/types.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +6 -0
- package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +30 -0
- package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +5 -1
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/mutation-observer/index.d.ts +2 -0
- package/package.json +11 -6
|
@@ -92,9 +92,11 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
92
92
|
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
93
93
|
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
96
|
+
getVCObserver(vcOptions).start({
|
|
97
|
+
startTime: 0
|
|
98
|
+
});
|
|
99
|
+
}
|
|
98
100
|
postInteractionLog.initializeVCObserver(vcOptions);
|
|
99
101
|
postInteractionLog.startVCObserver({
|
|
100
102
|
startTime: 0
|
package/dist/esm/vc/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
6
|
var _process;
|
|
@@ -12,19 +12,42 @@ import { VCObserverNOOP } from './no-op-vc-observer';
|
|
|
12
12
|
import { VCObserver } from './vc-observer';
|
|
13
13
|
import VCObserverNew from './vc-observer-new';
|
|
14
14
|
import { RLLPlaceholderHandlers } from './vc-observer/observers/rll-placeholders';
|
|
15
|
+
import { SSRPlaceholderHandlers } from './vc-observer/observers/ssr-placeholders';
|
|
15
16
|
export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
16
17
|
function VCObserverWrapper() {
|
|
18
|
+
var _opts$ssrEnablePageLa, _opts$disableSizeAndP;
|
|
17
19
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
20
|
_classCallCheck(this, VCObserverWrapper);
|
|
19
21
|
this.newVCObserver = null;
|
|
20
22
|
this.oldVCObserver = null;
|
|
23
|
+
|
|
24
|
+
// Initialize SSR placeholder handler once
|
|
25
|
+
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
|
|
26
|
+
enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false,
|
|
27
|
+
disableSizeAndPositionCheck: (_opts$disableSizeAndP = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP !== void 0 ? _opts$disableSizeAndP : {
|
|
28
|
+
v: false,
|
|
29
|
+
h: false
|
|
30
|
+
}
|
|
31
|
+
});
|
|
21
32
|
if (isVCRevisionEnabled('fy25.03')) {
|
|
33
|
+
var _opts$ssrEnablePageLa2, _opts$disableSizeAndP2;
|
|
22
34
|
this.newVCObserver = new VCObserverNew({
|
|
23
|
-
selectorConfig: opts.selectorConfig
|
|
35
|
+
selectorConfig: opts.selectorConfig,
|
|
36
|
+
isPostInteraction: opts.isPostInteraction,
|
|
37
|
+
SSRConfig: {
|
|
38
|
+
enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false,
|
|
39
|
+
disableSizeAndPositionCheck: (_opts$disableSizeAndP2 = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP2 !== void 0 ? _opts$disableSizeAndP2 : {
|
|
40
|
+
v: false,
|
|
41
|
+
h: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
ssrPlaceholderHandler: this.ssrPlaceholderHandler
|
|
24
45
|
});
|
|
25
46
|
}
|
|
26
47
|
if (isVCRevisionEnabled('fy25.01') || isVCRevisionEnabled('fy25.02')) {
|
|
27
|
-
this.oldVCObserver = new VCObserver(opts)
|
|
48
|
+
this.oldVCObserver = new VCObserver(_objectSpread(_objectSpread({}, opts), {}, {
|
|
49
|
+
ssrPlaceholderHandler: this.ssrPlaceholderHandler
|
|
50
|
+
}));
|
|
28
51
|
}
|
|
29
52
|
}
|
|
30
53
|
|
|
@@ -83,6 +106,8 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
83
106
|
(_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 || _this$newVCObserver2.stop();
|
|
84
107
|
}
|
|
85
108
|
RLLPlaceholderHandlers.getInstance().reset();
|
|
109
|
+
// Clear shared SSR placeholder handler
|
|
110
|
+
this.ssrPlaceholderHandler.clear();
|
|
86
111
|
}
|
|
87
112
|
}, {
|
|
88
113
|
key: "getVCRawData",
|
|
@@ -156,20 +181,28 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
156
181
|
}, {
|
|
157
182
|
key: "setSSRElement",
|
|
158
183
|
value: function setSSRElement(element) {
|
|
159
|
-
var _this$oldVCObserver5;
|
|
184
|
+
var _this$oldVCObserver5, _this$newVCObserver4;
|
|
160
185
|
(_this$oldVCObserver5 = this.oldVCObserver) === null || _this$oldVCObserver5 === void 0 || _this$oldVCObserver5.setSSRElement(element);
|
|
186
|
+
(_this$newVCObserver4 = this.newVCObserver) === null || _this$newVCObserver4 === void 0 || _this$newVCObserver4.setReactRootElement(element);
|
|
161
187
|
}
|
|
162
188
|
}, {
|
|
163
189
|
key: "setReactRootRenderStart",
|
|
164
190
|
value: function setReactRootRenderStart(startTime) {
|
|
165
|
-
var _this$oldVCObserver6;
|
|
191
|
+
var _this$oldVCObserver6, _this$newVCObserver5;
|
|
166
192
|
(_this$oldVCObserver6 = this.oldVCObserver) === null || _this$oldVCObserver6 === void 0 || _this$oldVCObserver6.setReactRootRenderStart(startTime || performance.now());
|
|
193
|
+
(_this$newVCObserver5 = this.newVCObserver) === null || _this$newVCObserver5 === void 0 || _this$newVCObserver5.setReactRootRenderStart(startTime || performance.now());
|
|
167
194
|
}
|
|
168
195
|
}, {
|
|
169
196
|
key: "setReactRootRenderStop",
|
|
170
197
|
value: function setReactRootRenderStop(stopTime) {
|
|
171
|
-
var _this$oldVCObserver7;
|
|
198
|
+
var _this$oldVCObserver7, _this$newVCObserver6;
|
|
172
199
|
(_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 || _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
|
|
200
|
+
(_this$newVCObserver6 = this.newVCObserver) === null || _this$newVCObserver6 === void 0 || _this$newVCObserver6.setReactRootRenderStop(stopTime || performance.now());
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "collectSSRPlaceholders",
|
|
204
|
+
value: function collectSSRPlaceholders() {
|
|
205
|
+
this.ssrPlaceholderHandler.collectExistingPlaceholders();
|
|
173
206
|
}
|
|
174
207
|
}]);
|
|
175
208
|
}();
|
|
@@ -201,4 +234,10 @@ export function getVCObserver() {
|
|
|
201
234
|
globalThis.__vcObserver = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
202
235
|
}
|
|
203
236
|
return globalThis.__vcObserver;
|
|
237
|
+
}
|
|
238
|
+
export function newVCObserver() {
|
|
239
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
240
|
+
var shouldMockVCObserver = !isEnvironmentSupported();
|
|
241
|
+
var observer = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
242
|
+
return observer;
|
|
204
243
|
}
|
|
@@ -448,7 +448,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
448
448
|
this.devToolsEnabled = options.devToolsEnabled || false;
|
|
449
449
|
this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
|
|
450
450
|
var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
|
|
451
|
-
disableSizeAndPositionCheck = options.disableSizeAndPositionCheck
|
|
451
|
+
disableSizeAndPositionCheck = options.disableSizeAndPositionCheck,
|
|
452
|
+
ssrPlaceholderHandler = options.ssrPlaceholderHandler;
|
|
452
453
|
this.observers = new Observers({
|
|
453
454
|
selectorConfig: options.selectorConfig || {
|
|
454
455
|
id: false,
|
|
@@ -460,7 +461,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
460
461
|
SSRConfig: {
|
|
461
462
|
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
|
|
462
463
|
disableSizeAndPositionCheck: disableSizeAndPositionCheck
|
|
463
|
-
}
|
|
464
|
+
},
|
|
465
|
+
ssrPlaceholderHandler: ssrPlaceholderHandler
|
|
464
466
|
});
|
|
465
467
|
this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
|
|
466
468
|
this.heatmapNext = this.getCleanHeatmap();
|
|
@@ -520,6 +522,12 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
520
522
|
var stopTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
|
|
521
523
|
this.observers.setReactRootRenderStop(stopTime);
|
|
522
524
|
}
|
|
525
|
+
}, {
|
|
526
|
+
key: "collectSSRPlaceholders",
|
|
527
|
+
value: function collectSSRPlaceholders() {
|
|
528
|
+
// This is handled by the shared SSRPlaceholderHandlers in VCObserverWrapper
|
|
529
|
+
// Individual observers don't need to implement this
|
|
530
|
+
}
|
|
523
531
|
}, {
|
|
524
532
|
key: "setAbortReason",
|
|
525
533
|
value: function setAbortReason(abort, timestamp) {
|
|
@@ -25,9 +25,7 @@ function isElementVisible(target) {
|
|
|
25
25
|
}
|
|
26
26
|
export var Observers = /*#__PURE__*/function () {
|
|
27
27
|
function Observers(opts) {
|
|
28
|
-
var _this = this
|
|
29
|
-
_opts$SSRConfig,
|
|
30
|
-
_opts$SSRConfig2;
|
|
28
|
+
var _this = this;
|
|
31
29
|
_classCallCheck(this, Observers);
|
|
32
30
|
_defineProperty(this, "observedMutations", new WeakMap());
|
|
33
31
|
_defineProperty(this, "elementsInView", new Set());
|
|
@@ -67,10 +65,17 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
67
65
|
this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
|
|
68
66
|
this.intersectionObserver = this.getIntersectionObserver();
|
|
69
67
|
this.mutationObserver = this.getMutationObserver();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
|
|
69
|
+
// Use shared SSR placeholder handler if provided, otherwise create new one
|
|
70
|
+
if (opts.ssrPlaceholderHandler) {
|
|
71
|
+
this.ssrPlaceholderHandler = opts.ssrPlaceholderHandler;
|
|
72
|
+
} else {
|
|
73
|
+
var _opts$SSRConfig, _opts$SSRConfig2;
|
|
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
|
|
77
|
+
});
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
return _createClass(Observers, [{
|
|
76
81
|
key: "isBrowserSupported",
|
|
@@ -104,32 +104,8 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
104
104
|
this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
|
|
105
105
|
if (window.document) {
|
|
106
106
|
try {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
existingElements.forEach(function (el) {
|
|
110
|
-
var placeholderId = el instanceof HTMLElement && _this.getPlaceholderId(el);
|
|
111
|
-
if (placeholderId) {
|
|
112
|
-
var _window$__SSR_PLACEHO, _this$intersectionObs2;
|
|
113
|
-
var width = -1;
|
|
114
|
-
var height = -1;
|
|
115
|
-
var x = -1;
|
|
116
|
-
var y = -1;
|
|
117
|
-
var boundingClientRect = (_window$__SSR_PLACEHO = window.__SSR_PLACEHOLDERS_DIMENSIONS__) === null || _window$__SSR_PLACEHO === void 0 ? void 0 : _window$__SSR_PLACEHO[placeholderId];
|
|
118
|
-
if (boundingClientRect) {
|
|
119
|
-
width = boundingClientRect.width;
|
|
120
|
-
height = boundingClientRect.height;
|
|
121
|
-
x = boundingClientRect.x;
|
|
122
|
-
y = boundingClientRect.y;
|
|
123
|
-
}
|
|
124
|
-
_this.staticPlaceholders.set(placeholderId, {
|
|
125
|
-
width: width,
|
|
126
|
-
height: height,
|
|
127
|
-
x: x,
|
|
128
|
-
y: y
|
|
129
|
-
});
|
|
130
|
-
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.observe(el);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
107
|
+
// Collect initial placeholders using SSR dimensions
|
|
108
|
+
this.collectPlaceholdersInternal();
|
|
133
109
|
} catch (e) {} finally {
|
|
134
110
|
delete window.__SSR_PLACEHOLDERS_DIMENSIONS__;
|
|
135
111
|
}
|
|
@@ -143,6 +119,66 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
143
119
|
this.getSizeCallbacks = new Map();
|
|
144
120
|
this.reactValidateCallbacks = new Map();
|
|
145
121
|
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "collectPlaceholdersInternal",
|
|
124
|
+
value: function collectPlaceholdersInternal() {
|
|
125
|
+
var _this2 = this;
|
|
126
|
+
var selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
|
|
127
|
+
var existingElements = document.querySelectorAll(selector);
|
|
128
|
+
existingElements.forEach(function (el) {
|
|
129
|
+
var placeholderId = el instanceof HTMLElement && _this2.getPlaceholderId(el);
|
|
130
|
+
if (placeholderId && !_this2.staticPlaceholders.has(placeholderId)) {
|
|
131
|
+
var _window$__SSR_PLACEHO, _this2$intersectionOb;
|
|
132
|
+
var width = -1;
|
|
133
|
+
var height = -1;
|
|
134
|
+
var x = -1;
|
|
135
|
+
var y = -1;
|
|
136
|
+
|
|
137
|
+
// Use SSR dimensions from window global if available
|
|
138
|
+
var boundingClientRect = (_window$__SSR_PLACEHO = window.__SSR_PLACEHOLDERS_DIMENSIONS__) === null || _window$__SSR_PLACEHO === void 0 ? void 0 : _window$__SSR_PLACEHO[placeholderId];
|
|
139
|
+
if (boundingClientRect) {
|
|
140
|
+
width = boundingClientRect.width;
|
|
141
|
+
height = boundingClientRect.height;
|
|
142
|
+
x = boundingClientRect.x;
|
|
143
|
+
y = boundingClientRect.y;
|
|
144
|
+
} else {
|
|
145
|
+
// Fallback to current bounding rect if SSR dimensions not available
|
|
146
|
+
var rect = el.getBoundingClientRect();
|
|
147
|
+
width = rect.width;
|
|
148
|
+
height = rect.height;
|
|
149
|
+
x = rect.x;
|
|
150
|
+
y = rect.y;
|
|
151
|
+
}
|
|
152
|
+
_this2.staticPlaceholders.set(placeholderId, {
|
|
153
|
+
width: width,
|
|
154
|
+
height: height,
|
|
155
|
+
x: x,
|
|
156
|
+
y: y
|
|
157
|
+
});
|
|
158
|
+
(_this2$intersectionOb = _this2.intersectionObserver) === null || _this2$intersectionOb === void 0 || _this2$intersectionOb.observe(el);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Added this method to be utilised for testing purposes.
|
|
165
|
+
* In production it collection placeholder should only happens on constructor
|
|
166
|
+
*/
|
|
167
|
+
}, {
|
|
168
|
+
key: "collectExistingPlaceholders",
|
|
169
|
+
value: function collectExistingPlaceholders() {
|
|
170
|
+
if (!window.document) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
// Collect placeholders using SSR dimensions or fallback to live dimensions
|
|
175
|
+
this.collectPlaceholdersInternal();
|
|
176
|
+
} catch (e) {
|
|
177
|
+
// Silently fail if there are any issues
|
|
178
|
+
} finally {
|
|
179
|
+
delete window.__SSR_PLACEHOLDERS_DIMENSIONS__;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
146
182
|
}, {
|
|
147
183
|
key: "isPlaceholder",
|
|
148
184
|
value: function isPlaceholder(element) {
|
|
@@ -179,44 +215,44 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
179
215
|
}, {
|
|
180
216
|
key: "checkIfExistedAndSizeMatching",
|
|
181
217
|
value: function checkIfExistedAndSizeMatching(el) {
|
|
182
|
-
var
|
|
218
|
+
var _this3 = this;
|
|
183
219
|
el = this.findNearestPlaceholderContainerIfIgnored(el);
|
|
184
220
|
var id = this.getPlaceholderId(el);
|
|
185
221
|
return new Promise(function (resolve) {
|
|
186
|
-
if (!
|
|
222
|
+
if (!_this3.staticPlaceholders.has(id)) {
|
|
187
223
|
resolve(false);
|
|
188
224
|
return;
|
|
189
225
|
} else {
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
(
|
|
226
|
+
var _this3$intersectionOb;
|
|
227
|
+
_this3.callbacks.set(id, resolve);
|
|
228
|
+
(_this3$intersectionOb = _this3.intersectionObserver) === null || _this3$intersectionOb === void 0 || _this3$intersectionOb.observe(el);
|
|
193
229
|
}
|
|
194
230
|
});
|
|
195
231
|
}
|
|
196
232
|
}, {
|
|
197
233
|
key: "getSize",
|
|
198
234
|
value: function getSize(el) {
|
|
199
|
-
var
|
|
235
|
+
var _this4 = this;
|
|
200
236
|
return new Promise(function (resolve) {
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
(
|
|
237
|
+
var _this4$intersectionOb;
|
|
238
|
+
_this4.getSizeCallbacks.set(_this4.getPlaceholderId(el), resolve);
|
|
239
|
+
(_this4$intersectionOb = _this4.intersectionObserver) === null || _this4$intersectionOb === void 0 || _this4$intersectionOb.observe(el);
|
|
204
240
|
});
|
|
205
241
|
}
|
|
206
242
|
}, {
|
|
207
243
|
key: "validateReactComponentMatchToPlaceholder",
|
|
208
244
|
value: function validateReactComponentMatchToPlaceholder(el) {
|
|
209
|
-
var
|
|
245
|
+
var _this5 = this;
|
|
210
246
|
el = this.findNearestPlaceholderContainerIfIgnored(el);
|
|
211
247
|
var id = this.getPlaceholderReplacementId(el);
|
|
212
248
|
return new Promise(function (resolve) {
|
|
213
|
-
if (!
|
|
249
|
+
if (!_this5.staticPlaceholders.has(id)) {
|
|
214
250
|
resolve(false);
|
|
215
251
|
return;
|
|
216
252
|
} else {
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
(
|
|
253
|
+
var _this5$intersectionOb;
|
|
254
|
+
_this5.reactValidateCallbacks.set(id, resolve);
|
|
255
|
+
(_this5$intersectionOb = _this5.intersectionObserver) === null || _this5$intersectionOb === void 0 || _this5$intersectionOb.observe(el);
|
|
220
256
|
}
|
|
221
257
|
});
|
|
222
258
|
}
|
|
@@ -6,6 +6,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { SSRPlaceholderHandlers } from '../vc-observer/observers/ssr-placeholders';
|
|
9
10
|
import EntriesTimeline from './entries-timeline';
|
|
10
11
|
import _getElementName from './get-element-name';
|
|
11
12
|
import VCCalculator_FY25_03 from './metric-calculator/fy25_03';
|
|
@@ -13,6 +14,11 @@ import getViewportHeight from './metric-calculator/utils/get-viewport-height';
|
|
|
13
14
|
import getViewportWidth from './metric-calculator/utils/get-viewport-width';
|
|
14
15
|
import ViewportObserver from './viewport-observer';
|
|
15
16
|
import WindowEventObserver from './window-event-observer';
|
|
17
|
+
var SSRState = {
|
|
18
|
+
normal: 1,
|
|
19
|
+
waitingForFirstRender: 2,
|
|
20
|
+
ignoring: 3
|
|
21
|
+
};
|
|
16
22
|
var DEFAULT_SELECTOR_CONFIG = {
|
|
17
23
|
id: false,
|
|
18
24
|
testId: true,
|
|
@@ -28,9 +34,31 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
28
34
|
_classCallCheck(this, VCObserverNew);
|
|
29
35
|
_defineProperty(this, "viewportObserver", null);
|
|
30
36
|
_defineProperty(this, "windowEventObserver", null);
|
|
37
|
+
// SSR related properties
|
|
38
|
+
_defineProperty(this, "ssrPlaceholderHandler", null);
|
|
39
|
+
_defineProperty(this, "ssr", {
|
|
40
|
+
state: SSRState.normal,
|
|
41
|
+
reactRootElement: null,
|
|
42
|
+
renderStart: -1,
|
|
43
|
+
renderStop: -1
|
|
44
|
+
});
|
|
31
45
|
this.entriesTimeline = new EntriesTimeline();
|
|
32
46
|
this.isPostInteraction = (_config$isPostInterac = config.isPostInteraction) !== null && _config$isPostInterac !== void 0 ? _config$isPostInterac : false;
|
|
33
47
|
this.selectorConfig = (_config$selectorConfi = config.selectorConfig) !== null && _config$selectorConfi !== void 0 ? _config$selectorConfi : DEFAULT_SELECTOR_CONFIG;
|
|
48
|
+
|
|
49
|
+
// Use shared SSR placeholder handler if provided, otherwise create new one if feature flag is enabled
|
|
50
|
+
if (config.ssrPlaceholderHandler) {
|
|
51
|
+
this.ssrPlaceholderHandler = config.ssrPlaceholderHandler;
|
|
52
|
+
} else {
|
|
53
|
+
var _config$SSRConfig$ena, _config$SSRConfig, _config$SSRConfig$dis, _config$SSRConfig2;
|
|
54
|
+
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
|
|
55
|
+
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,
|
|
56
|
+
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 : {
|
|
57
|
+
v: false,
|
|
58
|
+
h: false
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
34
62
|
this.viewportObserver = new ViewportObserver({
|
|
35
63
|
onChange: function onChange(onChangeArg) {
|
|
36
64
|
var time = onChangeArg.time,
|
|
@@ -58,6 +86,13 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
58
86
|
newValue: mutationData === null || mutationData === void 0 ? void 0 : mutationData.newValue
|
|
59
87
|
}
|
|
60
88
|
});
|
|
89
|
+
},
|
|
90
|
+
// Pass SSR context to ViewportObserver
|
|
91
|
+
getSSRState: function getSSRState() {
|
|
92
|
+
return _this.getSSRState();
|
|
93
|
+
},
|
|
94
|
+
getSSRPlaceholderHandler: function getSSRPlaceholderHandler() {
|
|
95
|
+
return _this.getSSRPlaceholderHandler();
|
|
61
96
|
}
|
|
62
97
|
});
|
|
63
98
|
this.windowEventObserver = new WindowEventObserver({
|
|
@@ -82,6 +117,14 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
82
117
|
_this2 = this,
|
|
83
118
|
_this$windowEventObse;
|
|
84
119
|
var startTime = _ref2.startTime;
|
|
120
|
+
// Reset SSR state on start (matches old VCObserver behavior)
|
|
121
|
+
this.ssr = {
|
|
122
|
+
state: SSRState.normal,
|
|
123
|
+
reactRootElement: null,
|
|
124
|
+
// Reset to null (matches old VCObserver)
|
|
125
|
+
renderStart: -1,
|
|
126
|
+
renderStop: -1
|
|
127
|
+
};
|
|
85
128
|
(_this$viewportObserve = this.viewportObserver) === null || _this$viewportObserve === void 0 || _this$viewportObserve.start();
|
|
86
129
|
if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__ && fg('platform_ufo_vc_observer_new_ssr_abort_listener')) {
|
|
87
130
|
var abortListeners = window.__SSR_ABORT_LISTENERS__;
|
|
@@ -112,6 +155,47 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
112
155
|
var _this$viewportObserve2, _this$windowEventObse2;
|
|
113
156
|
(_this$viewportObserve2 = this.viewportObserver) === null || _this$viewportObserve2 === void 0 || _this$viewportObserve2.stop();
|
|
114
157
|
(_this$windowEventObse2 = this.windowEventObserver) === null || _this$windowEventObse2 === void 0 || _this$windowEventObse2.stop();
|
|
158
|
+
|
|
159
|
+
// Clear SSR state on stop (matches old VCObserver behavior)
|
|
160
|
+
this.ssr.reactRootElement = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// SSR related methods
|
|
164
|
+
}, {
|
|
165
|
+
key: "setReactRootElement",
|
|
166
|
+
value: function setReactRootElement(element) {
|
|
167
|
+
this.ssr.reactRootElement = element;
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "setReactRootRenderStart",
|
|
171
|
+
value: function setReactRootRenderStart() {
|
|
172
|
+
var startTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
|
|
173
|
+
this.ssr.renderStart = startTime;
|
|
174
|
+
this.ssr.state = SSRState.waitingForFirstRender;
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "setReactRootRenderStop",
|
|
178
|
+
value: function setReactRootRenderStop() {
|
|
179
|
+
var stopTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
|
|
180
|
+
this.ssr.renderStop = stopTime;
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "collectSSRPlaceholders",
|
|
184
|
+
value: function collectSSRPlaceholders() {
|
|
185
|
+
// This is handled by the shared SSRPlaceholderHandlers in VCObserverWrapper
|
|
186
|
+
// Individual observers don't need to implement this
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Internal methods for ViewportObserver to access SSR state
|
|
190
|
+
}, {
|
|
191
|
+
key: "getSSRState",
|
|
192
|
+
value: function getSSRState() {
|
|
193
|
+
return this.ssr;
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
key: "getSSRPlaceholderHandler",
|
|
197
|
+
value: function getSSRPlaceholderHandler() {
|
|
198
|
+
return this.ssrPlaceholderHandler;
|
|
115
199
|
}
|
|
116
200
|
}, {
|
|
117
201
|
key: "addSSR",
|