@atlaskit/react-ufo 4.2.3 → 4.2.5
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/ignore-holds/index.js +1 -2
- package/dist/cjs/interaction-metrics-init/index.js +7 -9
- package/dist/cjs/resource-timing/main.js +1 -1
- package/dist/cjs/vc/no-op-vc-observer.js +5 -5
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +11 -0
- package/dist/cjs/vc/vc-observer-new/index.js +5 -6
- package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +1 -1
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +45 -30
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +1 -0
- package/dist/es2019/ignore-holds/index.js +1 -2
- package/dist/es2019/interaction-metrics-init/index.js +7 -9
- package/dist/es2019/resource-timing/main.js +1 -1
- package/dist/es2019/vc/no-op-vc-observer.js +5 -5
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +9 -0
- package/dist/es2019/vc/vc-observer-new/index.js +1 -3
- package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +1 -1
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +28 -19
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +1 -0
- package/dist/esm/ignore-holds/index.js +1 -2
- package/dist/esm/interaction-metrics-init/index.js +7 -9
- package/dist/esm/resource-timing/main.js +1 -1
- package/dist/esm/vc/no-op-vc-observer.js +5 -5
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +11 -0
- package/dist/esm/vc/vc-observer-new/index.js +5 -6
- package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +1 -1
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +45 -30
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +1 -0
- package/dist/types/ignore-holds/index.d.ts +1 -1
- package/dist/types/vc/no-op-vc-observer.d.ts +5 -5
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/index.d.ts +1 -3
- package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +1 -1
- package/dist/types-ts4.5/ignore-holds/index.d.ts +1 -1
- package/dist/types-ts4.5/vc/no-op-vc-observer.d.ts +5 -5
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +1 -3
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +1 -1
- package/package.json +4 -4
- package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/test-with-debug-info.js +0 -108
- package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/test-with-debug-info.js +0 -75
- package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/test-with-debug-info.js +0 -106
- package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/test-with-debug-info.d.ts +0 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/test-with-debug-info.d.ts +0 -1
|
@@ -8,7 +8,7 @@ export var VCObserverNOOP = /*#__PURE__*/function () {
|
|
|
8
8
|
}
|
|
9
9
|
return _createClass(VCObserverNOOP, [{
|
|
10
10
|
key: "start",
|
|
11
|
-
value: function start(
|
|
11
|
+
value: function start(_) {}
|
|
12
12
|
}, {
|
|
13
13
|
key: "stop",
|
|
14
14
|
value: function stop() {}
|
|
@@ -19,19 +19,19 @@ export var VCObserverNOOP = /*#__PURE__*/function () {
|
|
|
19
19
|
}
|
|
20
20
|
}, {
|
|
21
21
|
key: "getVCResult",
|
|
22
|
-
value: function getVCResult(
|
|
22
|
+
value: function getVCResult(_) {
|
|
23
23
|
return Promise.resolve({
|
|
24
24
|
'ufo:vc:noop': true
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
}, {
|
|
28
28
|
key: "setSSRElement",
|
|
29
|
-
value: function setSSRElement(
|
|
29
|
+
value: function setSSRElement(_) {}
|
|
30
30
|
}, {
|
|
31
31
|
key: "setReactRootRenderStart",
|
|
32
|
-
value: function setReactRootRenderStart(
|
|
32
|
+
value: function setReactRootRenderStart(_) {}
|
|
33
33
|
}, {
|
|
34
34
|
key: "setReactRootRenderStop",
|
|
35
|
-
value: function setReactRootRenderStop(
|
|
35
|
+
value: function setReactRootRenderStop(_) {}
|
|
36
36
|
}]);
|
|
37
37
|
}();
|
|
@@ -206,6 +206,8 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
206
206
|
}
|
|
207
207
|
return element;
|
|
208
208
|
}
|
|
209
|
+
|
|
210
|
+
// NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is disabled
|
|
209
211
|
}, {
|
|
210
212
|
key: "checkIfExistedAndSizeMatching",
|
|
211
213
|
value: function checkIfExistedAndSizeMatching(el) {
|
|
@@ -223,6 +225,15 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
223
225
|
}
|
|
224
226
|
});
|
|
225
227
|
}
|
|
228
|
+
|
|
229
|
+
// NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is enabled
|
|
230
|
+
}, {
|
|
231
|
+
key: "checkIfExistedAndSizeMatchingV3",
|
|
232
|
+
value: function checkIfExistedAndSizeMatchingV3(el) {
|
|
233
|
+
el = this.findNearestPlaceholderContainerIfIgnored(el);
|
|
234
|
+
var id = this.getPlaceholderId(el);
|
|
235
|
+
return this.staticPlaceholders.has(id);
|
|
236
|
+
}
|
|
226
237
|
}, {
|
|
227
238
|
key: "getSize",
|
|
228
239
|
value: function getSize(el) {
|
|
@@ -106,12 +106,11 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
106
106
|
}
|
|
107
107
|
return _createClass(VCObserverNew, [{
|
|
108
108
|
key: "start",
|
|
109
|
-
value: function start(
|
|
109
|
+
value: function start(_) {
|
|
110
110
|
var _this$viewportObserve,
|
|
111
111
|
_window,
|
|
112
112
|
_this2 = this,
|
|
113
113
|
_this$windowEventObse;
|
|
114
|
-
var startTime = _ref2.startTime;
|
|
115
114
|
// Reset SSR state on start (matches old VCObserver behavior)
|
|
116
115
|
this.ssr = {
|
|
117
116
|
state: SSRState.normal,
|
|
@@ -125,10 +124,10 @@ var VCObserverNew = /*#__PURE__*/function () {
|
|
|
125
124
|
var abortListeners = window.__SSR_ABORT_LISTENERS__;
|
|
126
125
|
var aborts = abortListeners.aborts;
|
|
127
126
|
if (aborts && _typeof(aborts) === 'object') {
|
|
128
|
-
Object.entries(aborts).forEach(function (
|
|
129
|
-
var
|
|
130
|
-
key =
|
|
131
|
-
time =
|
|
127
|
+
Object.entries(aborts).forEach(function (_ref2) {
|
|
128
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
129
|
+
key = _ref3[0],
|
|
130
|
+
time = _ref3[1];
|
|
132
131
|
if (typeof time === 'number') {
|
|
133
132
|
_this2.entriesTimeline.push({
|
|
134
133
|
time: time,
|
package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js
CHANGED
|
@@ -238,7 +238,7 @@ export function calculateDrawnPixelsRaw(_x, _x2, _x3) {
|
|
|
238
238
|
return _calculateDrawnPixelsRaw.apply(this, arguments);
|
|
239
239
|
}
|
|
240
240
|
function _calculateDrawnPixelsRaw() {
|
|
241
|
-
_calculateDrawnPixelsRaw = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(imageData,
|
|
241
|
+
_calculateDrawnPixelsRaw = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(imageData, _, arraySize) {
|
|
242
242
|
var data, arr, i, color, colorIndex;
|
|
243
243
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
244
244
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -6,6 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
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; } } }; }
|
|
7
7
|
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; } }
|
|
8
8
|
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; }
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { isContainedWithinMediaWrapper } from '../../vc-observer/media-wrapper/vc-utils';
|
|
10
11
|
import isNonVisualStyleMutation from '../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation';
|
|
11
12
|
import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placeholders';
|
|
@@ -113,8 +114,8 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
113
114
|
_iterator = _createForOfIteratorHelper(addedNodes);
|
|
114
115
|
_context2.prev = 4;
|
|
115
116
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
116
|
-
var _this$
|
|
117
|
-
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, result, _this$
|
|
117
|
+
var _this$intersectionObs9;
|
|
118
|
+
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8;
|
|
118
119
|
return _regeneratorRuntime.wrap(function _loop$(_context) {
|
|
119
120
|
while (1) switch (_context.prev = _context.next) {
|
|
120
121
|
case 0:
|
|
@@ -162,44 +163,58 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
162
163
|
ssrState.state = SSRStateEnum.normal;
|
|
163
164
|
case 19:
|
|
164
165
|
if (!_this.getSSRPlaceholderHandler) {
|
|
165
|
-
_context.next =
|
|
166
|
+
_context.next = 42;
|
|
166
167
|
break;
|
|
167
168
|
}
|
|
168
169
|
ssrPlaceholderHandler = _this.getSSRPlaceholderHandler();
|
|
169
170
|
if (!ssrPlaceholderHandler) {
|
|
170
|
-
_context.next =
|
|
171
|
+
_context.next = 42;
|
|
171
172
|
break;
|
|
172
173
|
}
|
|
173
174
|
if (!(ssrPlaceholderHandler.isPlaceholder(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode))) {
|
|
175
|
+
_context.next = 35;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (!fg('platform_ufo_ssr_placeholder_resolution_ttvc_v3')) {
|
|
174
179
|
_context.next = 29;
|
|
175
180
|
break;
|
|
176
181
|
}
|
|
177
|
-
|
|
182
|
+
if (!ssrPlaceholderHandler.checkIfExistedAndSizeMatchingV3(addedNode)) {
|
|
183
|
+
_context.next = 27;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
(_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
187
|
+
return _context.abrupt("return", 0);
|
|
188
|
+
case 27:
|
|
189
|
+
_context.next = 35;
|
|
190
|
+
break;
|
|
191
|
+
case 29:
|
|
192
|
+
_context.next = 31;
|
|
178
193
|
return ssrPlaceholderHandler.checkIfExistedAndSizeMatching(addedNode);
|
|
179
|
-
case
|
|
194
|
+
case 31:
|
|
180
195
|
result = _context.sent;
|
|
181
196
|
if (!(result !== false)) {
|
|
182
|
-
_context.next =
|
|
197
|
+
_context.next = 35;
|
|
183
198
|
break;
|
|
184
199
|
}
|
|
185
|
-
(_this$
|
|
200
|
+
(_this$intersectionObs4 = _this.intersectionObserver) === null || _this$intersectionObs4 === void 0 || _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
186
201
|
return _context.abrupt("return", 0);
|
|
187
|
-
case
|
|
202
|
+
case 35:
|
|
188
203
|
if (!(ssrPlaceholderHandler.isPlaceholderReplacement(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode))) {
|
|
189
|
-
_context.next =
|
|
204
|
+
_context.next = 42;
|
|
190
205
|
break;
|
|
191
206
|
}
|
|
192
|
-
_context.next =
|
|
207
|
+
_context.next = 38;
|
|
193
208
|
return ssrPlaceholderHandler.validateReactComponentMatchToPlaceholder(addedNode);
|
|
194
|
-
case
|
|
209
|
+
case 38:
|
|
195
210
|
_result = _context.sent;
|
|
196
211
|
if (!(_result !== false)) {
|
|
197
|
-
_context.next =
|
|
212
|
+
_context.next = 42;
|
|
198
213
|
break;
|
|
199
214
|
}
|
|
200
|
-
(_this$
|
|
215
|
+
(_this$intersectionObs5 = _this.intersectionObserver) === null || _this$intersectionObs5 === void 0 || _this$intersectionObs5.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
201
216
|
return _context.abrupt("return", 0);
|
|
202
|
-
case
|
|
217
|
+
case 42:
|
|
203
218
|
sameDeletedNode = removedNodes.find(function (ref) {
|
|
204
219
|
var n = ref.deref();
|
|
205
220
|
if (!n || !addedNode) {
|
|
@@ -209,29 +224,29 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
209
224
|
});
|
|
210
225
|
isInIgnoreLsMarker = isInVCIgnoreIfNoLayoutShiftMarker(addedNode);
|
|
211
226
|
if (!(sameDeletedNode && isInIgnoreLsMarker)) {
|
|
212
|
-
_context.next =
|
|
227
|
+
_context.next = 47;
|
|
213
228
|
break;
|
|
214
229
|
}
|
|
215
|
-
(_this$
|
|
230
|
+
(_this$intersectionObs6 = _this.intersectionObserver) === null || _this$intersectionObs6 === void 0 || _this$intersectionObs6.watchAndTag(addedNode, 'mutation:remount');
|
|
216
231
|
return _context.abrupt("return", 0);
|
|
217
|
-
case
|
|
232
|
+
case 47:
|
|
218
233
|
if (!isContainedWithinMediaWrapper(addedNode)) {
|
|
219
|
-
_context.next =
|
|
234
|
+
_context.next = 50;
|
|
220
235
|
break;
|
|
221
236
|
}
|
|
222
|
-
(_this$
|
|
237
|
+
(_this$intersectionObs7 = _this.intersectionObserver) === null || _this$intersectionObs7 === void 0 || _this$intersectionObs7.watchAndTag(addedNode, 'mutation:media');
|
|
223
238
|
return _context.abrupt("return", 0);
|
|
224
|
-
case
|
|
239
|
+
case 50:
|
|
225
240
|
_checkWithinComponent = checkWithinComponent(addedNode, 'UFOThirdPartySegment', _this.mapIs3pResult), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
|
|
226
241
|
if (!isWithinThirdPartySegment) {
|
|
227
|
-
_context.next =
|
|
242
|
+
_context.next = 54;
|
|
228
243
|
break;
|
|
229
244
|
}
|
|
230
|
-
(_this$
|
|
245
|
+
(_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
|
|
231
246
|
return _context.abrupt("return", 0);
|
|
232
|
-
case
|
|
233
|
-
(_this$
|
|
234
|
-
case
|
|
247
|
+
case 54:
|
|
248
|
+
(_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
249
|
+
case 55:
|
|
235
250
|
case "end":
|
|
236
251
|
return _context.stop();
|
|
237
252
|
}
|
|
@@ -276,12 +291,12 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
276
291
|
};
|
|
277
292
|
}());
|
|
278
293
|
_defineProperty(this, "handleAttributeMutation", function (_ref6) {
|
|
279
|
-
var _this$
|
|
294
|
+
var _this$intersectionObs0;
|
|
280
295
|
var target = _ref6.target,
|
|
281
296
|
attributeName = _ref6.attributeName,
|
|
282
297
|
oldValue = _ref6.oldValue,
|
|
283
298
|
newValue = _ref6.newValue;
|
|
284
|
-
(_this$
|
|
299
|
+
(_this$intersectionObs0 = _this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.watchAndTag(target, function (_ref7) {
|
|
285
300
|
var target = _ref7.target,
|
|
286
301
|
rect = _ref7.rect;
|
|
287
302
|
if (isContainedWithinMediaWrapper(target)) {
|
|
@@ -421,12 +436,12 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
421
436
|
}, {
|
|
422
437
|
key: "stop",
|
|
423
438
|
value: function stop() {
|
|
424
|
-
var _this$mutationObserve2, _this$
|
|
439
|
+
var _this$mutationObserve2, _this$intersectionObs1, _this$performanceObse2;
|
|
425
440
|
if (!this.isStarted) {
|
|
426
441
|
return;
|
|
427
442
|
}
|
|
428
443
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
429
|
-
(_this$
|
|
444
|
+
(_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 || _this$intersectionObs1.disconnect();
|
|
430
445
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
|
|
431
446
|
this.isStarted = false;
|
|
432
447
|
// Clean up caches when stopping
|
|
@@ -17,6 +17,7 @@ function maybeCleanup(resultCache) {
|
|
|
17
17
|
export function cleanupCaches(resultCache) {
|
|
18
18
|
resultCache = new WeakMap();
|
|
19
19
|
callCount = 0;
|
|
20
|
+
return resultCache;
|
|
20
21
|
}
|
|
21
22
|
export default function checkWithinComponent(node, targetComponentName, resultCache) {
|
|
22
23
|
maybeCleanup(resultCache);
|
|
@@ -24,7 +24,7 @@ export type UFOIgnoreHoldsProps = {
|
|
|
24
24
|
* Has an `ignore` prop, to allow you to use it conditionally
|
|
25
25
|
* Has a `reason` prop, to specify why the hold is being ignored
|
|
26
26
|
*/
|
|
27
|
-
declare function UFOIgnoreHolds({ children, ignore
|
|
27
|
+
declare function UFOIgnoreHolds({ children, ignore }: UFOIgnoreHoldsProps): React.JSX.Element;
|
|
28
28
|
declare namespace UFOIgnoreHolds {
|
|
29
29
|
var displayName: string;
|
|
30
30
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { VCResult } from '../common/vc/types';
|
|
2
2
|
import type { GetVCResultType, VCObserverInterface } from './types';
|
|
3
3
|
export declare class VCObserverNOOP implements VCObserverInterface {
|
|
4
|
-
start(
|
|
4
|
+
start(_: {
|
|
5
5
|
startTime: number;
|
|
6
6
|
}): void;
|
|
7
7
|
stop(): void;
|
|
8
8
|
getVCRawData(): null;
|
|
9
|
-
getVCResult(
|
|
10
|
-
setSSRElement(
|
|
11
|
-
setReactRootRenderStart(
|
|
12
|
-
setReactRootRenderStop(
|
|
9
|
+
getVCResult(_: GetVCResultType): Promise<VCResult>;
|
|
10
|
+
setSSRElement(_: HTMLElement): void;
|
|
11
|
+
setReactRootRenderStart(_: number): void;
|
|
12
|
+
setReactRootRenderStop(_: number): void;
|
|
13
13
|
}
|
|
@@ -30,6 +30,7 @@ export declare class SSRPlaceholderHandlers {
|
|
|
30
30
|
isPlaceholderIgnored(element: HTMLElement): boolean;
|
|
31
31
|
findNearestPlaceholderContainerIfIgnored(element: HTMLElement): HTMLElement;
|
|
32
32
|
checkIfExistedAndSizeMatching(el: HTMLElement): Promise<unknown>;
|
|
33
|
+
checkIfExistedAndSizeMatchingV3(el: HTMLElement): boolean;
|
|
33
34
|
getSize(el: HTMLElement): Promise<Rect>;
|
|
34
35
|
validateReactComponentMatchToPlaceholder(el: HTMLElement): Promise<unknown>;
|
|
35
36
|
hasSameSizePosition(rect: Rect | undefined, boundingClientRect: DOMRectReadOnly): boolean;
|
|
@@ -31,9 +31,7 @@ export default class VCObserverNew {
|
|
|
31
31
|
private ssrPlaceholderHandler;
|
|
32
32
|
private ssr;
|
|
33
33
|
constructor(config: VCObserverNewConfig);
|
|
34
|
-
start(
|
|
35
|
-
startTime: DOMHighResTimeStamp;
|
|
36
|
-
}): void;
|
|
34
|
+
start(_: any): void;
|
|
37
35
|
stop(): void;
|
|
38
36
|
setReactRootElement(element: HTMLElement): void;
|
|
39
37
|
setReactRootRenderStart(startTime?: number): void;
|
|
@@ -91,5 +91,5 @@ export declare function getRGBComponents(n: number): RGBColor;
|
|
|
91
91
|
* @param arraySize - The amount of timestamps that were drawn in the viewport
|
|
92
92
|
* @returns A Map containing color to pixel count mappings.
|
|
93
93
|
*/
|
|
94
|
-
export declare function calculateDrawnPixelsRaw(imageData: ImageData,
|
|
94
|
+
export declare function calculateDrawnPixelsRaw(imageData: ImageData, _: number, arraySize: number): Promise<Uint32Array>;
|
|
95
95
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function cleanupCaches(resultCache: WeakMap<HTMLElement, boolean>):
|
|
1
|
+
export declare function cleanupCaches(resultCache: WeakMap<HTMLElement, boolean>): WeakMap<HTMLElement, boolean>;
|
|
2
2
|
export default function checkWithinComponent(node: HTMLElement, targetComponentName: string, resultCache: WeakMap<HTMLElement, boolean>): {
|
|
3
3
|
isWithin: boolean;
|
|
4
4
|
};
|
|
@@ -24,7 +24,7 @@ export type UFOIgnoreHoldsProps = {
|
|
|
24
24
|
* Has an `ignore` prop, to allow you to use it conditionally
|
|
25
25
|
* Has a `reason` prop, to specify why the hold is being ignored
|
|
26
26
|
*/
|
|
27
|
-
declare function UFOIgnoreHolds({ children, ignore
|
|
27
|
+
declare function UFOIgnoreHolds({ children, ignore }: UFOIgnoreHoldsProps): React.JSX.Element;
|
|
28
28
|
declare namespace UFOIgnoreHolds {
|
|
29
29
|
var displayName: string;
|
|
30
30
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { VCResult } from '../common/vc/types';
|
|
2
2
|
import type { GetVCResultType, VCObserverInterface } from './types';
|
|
3
3
|
export declare class VCObserverNOOP implements VCObserverInterface {
|
|
4
|
-
start(
|
|
4
|
+
start(_: {
|
|
5
5
|
startTime: number;
|
|
6
6
|
}): void;
|
|
7
7
|
stop(): void;
|
|
8
8
|
getVCRawData(): null;
|
|
9
|
-
getVCResult(
|
|
10
|
-
setSSRElement(
|
|
11
|
-
setReactRootRenderStart(
|
|
12
|
-
setReactRootRenderStop(
|
|
9
|
+
getVCResult(_: GetVCResultType): Promise<VCResult>;
|
|
10
|
+
setSSRElement(_: HTMLElement): void;
|
|
11
|
+
setReactRootRenderStart(_: number): void;
|
|
12
|
+
setReactRootRenderStop(_: number): void;
|
|
13
13
|
}
|
|
@@ -30,6 +30,7 @@ export declare class SSRPlaceholderHandlers {
|
|
|
30
30
|
isPlaceholderIgnored(element: HTMLElement): boolean;
|
|
31
31
|
findNearestPlaceholderContainerIfIgnored(element: HTMLElement): HTMLElement;
|
|
32
32
|
checkIfExistedAndSizeMatching(el: HTMLElement): Promise<unknown>;
|
|
33
|
+
checkIfExistedAndSizeMatchingV3(el: HTMLElement): boolean;
|
|
33
34
|
getSize(el: HTMLElement): Promise<Rect>;
|
|
34
35
|
validateReactComponentMatchToPlaceholder(el: HTMLElement): Promise<unknown>;
|
|
35
36
|
hasSameSizePosition(rect: Rect | undefined, boundingClientRect: DOMRectReadOnly): boolean;
|
|
@@ -31,9 +31,7 @@ export default class VCObserverNew {
|
|
|
31
31
|
private ssrPlaceholderHandler;
|
|
32
32
|
private ssr;
|
|
33
33
|
constructor(config: VCObserverNewConfig);
|
|
34
|
-
start(
|
|
35
|
-
startTime: DOMHighResTimeStamp;
|
|
36
|
-
}): void;
|
|
34
|
+
start(_: any): void;
|
|
37
35
|
stop(): void;
|
|
38
36
|
setReactRootElement(element: HTMLElement): void;
|
|
39
37
|
setReactRootRenderStart(startTime?: number): void;
|
|
@@ -91,5 +91,5 @@ export declare function getRGBComponents(n: number): RGBColor;
|
|
|
91
91
|
* @param arraySize - The amount of timestamps that were drawn in the viewport
|
|
92
92
|
* @returns A Map containing color to pixel count mappings.
|
|
93
93
|
*/
|
|
94
|
-
export declare function calculateDrawnPixelsRaw(imageData: ImageData,
|
|
94
|
+
export declare function calculateDrawnPixelsRaw(imageData: ImageData, _: number, arraySize: number): Promise<Uint32Array>;
|
|
95
95
|
export {};
|
package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function cleanupCaches(resultCache: WeakMap<HTMLElement, boolean>):
|
|
1
|
+
export declare function cleanupCaches(resultCache: WeakMap<HTMLElement, boolean>): WeakMap<HTMLElement, boolean>;
|
|
2
2
|
export default function checkWithinComponent(node: HTMLElement, targetComponentName: string, resultCache: WeakMap<HTMLElement, boolean>): {
|
|
3
3
|
isWithin: boolean;
|
|
4
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -153,9 +153,6 @@
|
|
|
153
153
|
"platform_ufo_assets_check_for_nan": {
|
|
154
154
|
"type": "boolean"
|
|
155
155
|
},
|
|
156
|
-
"platform_ufo_enable_events_observer": {
|
|
157
|
-
"type": "boolean"
|
|
158
|
-
},
|
|
159
156
|
"platform_ufo_ssr_size_field": {
|
|
160
157
|
"type": "boolean"
|
|
161
158
|
},
|
|
@@ -200,6 +197,9 @@
|
|
|
200
197
|
},
|
|
201
198
|
"platform_ufo_add_segments_count_threshold": {
|
|
202
199
|
"type": "boolean"
|
|
200
|
+
},
|
|
201
|
+
"platform_ufo_ssr_placeholder_resolution_ttvc_v3": {
|
|
202
|
+
"type": "boolean"
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
5
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
6
|
-
var _index = require("./index");
|
|
7
|
-
// Test utilities
|
|
8
|
-
var createMockRect = function createMockRect() {
|
|
9
|
-
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
10
|
-
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
11
|
-
var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
|
|
12
|
-
var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 100;
|
|
13
|
-
return new MockDOMRect(x, y, width, height);
|
|
14
|
-
};
|
|
15
|
-
var createViewportEntry = function createViewportEntry(elementName) {
|
|
16
|
-
var rect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createMockRect();
|
|
17
|
-
var visible = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
18
|
-
var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'mutation:element';
|
|
19
|
-
return {
|
|
20
|
-
elementName: elementName,
|
|
21
|
-
rect: rect,
|
|
22
|
-
visible: visible,
|
|
23
|
-
type: type
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
var createTimePixelCounts = function createTimePixelCounts(counts) {
|
|
27
|
-
return new Map(counts);
|
|
28
|
-
};
|
|
29
|
-
var createElementMap = function createElementMap(entries) {
|
|
30
|
-
return new Map(entries);
|
|
31
|
-
};
|
|
32
|
-
var createExpectedResult = function createExpectedResult(time, viewportPercentage, entries) {
|
|
33
|
-
return {
|
|
34
|
-
time: time,
|
|
35
|
-
viewportPercentage: viewportPercentage,
|
|
36
|
-
entries: entries
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
var MockDOMRect = /*#__PURE__*/function () {
|
|
40
|
-
function MockDOMRect(x, y, width, height) {
|
|
41
|
-
(0, _classCallCheck2.default)(this, MockDOMRect);
|
|
42
|
-
this.x = x;
|
|
43
|
-
this.y = y;
|
|
44
|
-
this.width = width;
|
|
45
|
-
this.height = height;
|
|
46
|
-
}
|
|
47
|
-
return (0, _createClass2.default)(MockDOMRect, [{
|
|
48
|
-
key: "bottom",
|
|
49
|
-
get: function get() {
|
|
50
|
-
return this.y + this.height;
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "left",
|
|
54
|
-
get: function get() {
|
|
55
|
-
return this.x;
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "right",
|
|
59
|
-
get: function get() {
|
|
60
|
-
return this.x + this.width;
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "top",
|
|
64
|
-
get: function get() {
|
|
65
|
-
return this.y;
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "toJSON",
|
|
69
|
-
value: function toJSON() {
|
|
70
|
-
return {
|
|
71
|
-
x: this.x,
|
|
72
|
-
y: this.y,
|
|
73
|
-
width: this.width,
|
|
74
|
-
height: this.height
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}]);
|
|
78
|
-
}();
|
|
79
|
-
describe('calculatePercentilesWithDebugInfo', function () {
|
|
80
|
-
it('should correctly calculate percentiles with accumulated elements from timestamps', function () {
|
|
81
|
-
var timePixelCounts = createTimePixelCounts([[100, 10], [200, 20], [300, 10], [400, 10]]);
|
|
82
|
-
var elementMap = createElementMap([[100, [createViewportEntry('div'), createViewportEntry('span')]], [200, [createViewportEntry('img')]], [300, [createViewportEntry('p'), createViewportEntry('a')]], [400, [createViewportEntry('img')]]]);
|
|
83
|
-
var expected = [createExpectedResult(100, 20, [createViewportEntry('div'), createViewportEntry('span')]), createExpectedResult(200, 60, [createViewportEntry('img')]), createExpectedResult(300, 80, [createViewportEntry('p'), createViewportEntry('a')]), createExpectedResult(400, 100, [createViewportEntry('img')])];
|
|
84
|
-
var result = (0, _index.calculatePercentilesWithDebugInfo)(timePixelCounts, elementMap, 50, 0);
|
|
85
|
-
expect(result).toEqual(expected);
|
|
86
|
-
});
|
|
87
|
-
it('should handle empty entries gracefully', function () {
|
|
88
|
-
var timePixelCounts = new Map();
|
|
89
|
-
var elementMap = new Map();
|
|
90
|
-
var expected = [];
|
|
91
|
-
var result = (0, _index.calculatePercentilesWithDebugInfo)(timePixelCounts, elementMap, 100, 0);
|
|
92
|
-
expect(result).toEqual(expected);
|
|
93
|
-
});
|
|
94
|
-
it('should handle non-sequential timestamps', function () {
|
|
95
|
-
var timePixelCounts = createTimePixelCounts([[300, 70], [100, 30]]);
|
|
96
|
-
var elementMap = createElementMap([[300, [createViewportEntry('p'), createViewportEntry('a')]], [100, [createViewportEntry('div')]]]);
|
|
97
|
-
var expected = [createExpectedResult(100, 30, [createViewportEntry('div')]), createExpectedResult(300, 100, [createViewportEntry('p'), createViewportEntry('a')])];
|
|
98
|
-
var result = (0, _index.calculatePercentilesWithDebugInfo)(timePixelCounts, elementMap, 100, 0);
|
|
99
|
-
expect(result).toEqual(expected);
|
|
100
|
-
});
|
|
101
|
-
it('should correctly calculate percentiles with startTime offset', function () {
|
|
102
|
-
var timePixelCounts = createTimePixelCounts([[100, 10], [200, 20], [300, 10], [400, 10]]);
|
|
103
|
-
var elementMap = createElementMap([[100, [createViewportEntry('div'), createViewportEntry('span')]], [200, [createViewportEntry('img')]], [300, [createViewportEntry('p'), createViewportEntry('a')]], [400, [createViewportEntry('img')]]]);
|
|
104
|
-
var expected = [createExpectedResult(50, 20, [createViewportEntry('div'), createViewportEntry('span')]), createExpectedResult(150, 60, [createViewportEntry('img')]), createExpectedResult(250, 80, [createViewportEntry('p'), createViewportEntry('a')]), createExpectedResult(350, 100, [createViewportEntry('img')])];
|
|
105
|
-
var result = (0, _index.calculatePercentilesWithDebugInfo)(timePixelCounts, elementMap, 50, 50);
|
|
106
|
-
expect(result).toEqual(expected);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { calculatePercentilesWithDebugInfo } from './index';
|
|
2
|
-
|
|
3
|
-
// Test utilities
|
|
4
|
-
const createMockRect = (x = 0, y = 0, width = 100, height = 100) => new MockDOMRect(x, y, width, height);
|
|
5
|
-
const createViewportEntry = (elementName, rect = createMockRect(), visible = true, type = 'mutation:element') => ({
|
|
6
|
-
elementName,
|
|
7
|
-
rect,
|
|
8
|
-
visible,
|
|
9
|
-
type
|
|
10
|
-
});
|
|
11
|
-
const createTimePixelCounts = counts => new Map(counts);
|
|
12
|
-
const createElementMap = entries => new Map(entries);
|
|
13
|
-
const createExpectedResult = (time, viewportPercentage, entries) => ({
|
|
14
|
-
time,
|
|
15
|
-
viewportPercentage,
|
|
16
|
-
entries
|
|
17
|
-
});
|
|
18
|
-
class MockDOMRect {
|
|
19
|
-
constructor(x, y, width, height) {
|
|
20
|
-
this.x = x;
|
|
21
|
-
this.y = y;
|
|
22
|
-
this.width = width;
|
|
23
|
-
this.height = height;
|
|
24
|
-
}
|
|
25
|
-
get bottom() {
|
|
26
|
-
return this.y + this.height;
|
|
27
|
-
}
|
|
28
|
-
get left() {
|
|
29
|
-
return this.x;
|
|
30
|
-
}
|
|
31
|
-
get right() {
|
|
32
|
-
return this.x + this.width;
|
|
33
|
-
}
|
|
34
|
-
get top() {
|
|
35
|
-
return this.y;
|
|
36
|
-
}
|
|
37
|
-
toJSON() {
|
|
38
|
-
return {
|
|
39
|
-
x: this.x,
|
|
40
|
-
y: this.y,
|
|
41
|
-
width: this.width,
|
|
42
|
-
height: this.height
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
describe('calculatePercentilesWithDebugInfo', () => {
|
|
47
|
-
it('should correctly calculate percentiles with accumulated elements from timestamps', () => {
|
|
48
|
-
const timePixelCounts = createTimePixelCounts([[100, 10], [200, 20], [300, 10], [400, 10]]);
|
|
49
|
-
const elementMap = createElementMap([[100, [createViewportEntry('div'), createViewportEntry('span')]], [200, [createViewportEntry('img')]], [300, [createViewportEntry('p'), createViewportEntry('a')]], [400, [createViewportEntry('img')]]]);
|
|
50
|
-
const expected = [createExpectedResult(100, 20, [createViewportEntry('div'), createViewportEntry('span')]), createExpectedResult(200, 60, [createViewportEntry('img')]), createExpectedResult(300, 80, [createViewportEntry('p'), createViewportEntry('a')]), createExpectedResult(400, 100, [createViewportEntry('img')])];
|
|
51
|
-
const result = calculatePercentilesWithDebugInfo(timePixelCounts, elementMap, 50, 0);
|
|
52
|
-
expect(result).toEqual(expected);
|
|
53
|
-
});
|
|
54
|
-
it('should handle empty entries gracefully', () => {
|
|
55
|
-
const timePixelCounts = new Map();
|
|
56
|
-
const elementMap = new Map();
|
|
57
|
-
const expected = [];
|
|
58
|
-
const result = calculatePercentilesWithDebugInfo(timePixelCounts, elementMap, 100, 0);
|
|
59
|
-
expect(result).toEqual(expected);
|
|
60
|
-
});
|
|
61
|
-
it('should handle non-sequential timestamps', () => {
|
|
62
|
-
const timePixelCounts = createTimePixelCounts([[300, 70], [100, 30]]);
|
|
63
|
-
const elementMap = createElementMap([[300, [createViewportEntry('p'), createViewportEntry('a')]], [100, [createViewportEntry('div')]]]);
|
|
64
|
-
const expected = [createExpectedResult(100, 30, [createViewportEntry('div')]), createExpectedResult(300, 100, [createViewportEntry('p'), createViewportEntry('a')])];
|
|
65
|
-
const result = calculatePercentilesWithDebugInfo(timePixelCounts, elementMap, 100, 0);
|
|
66
|
-
expect(result).toEqual(expected);
|
|
67
|
-
});
|
|
68
|
-
it('should correctly calculate percentiles with startTime offset', () => {
|
|
69
|
-
const timePixelCounts = createTimePixelCounts([[100, 10], [200, 20], [300, 10], [400, 10]]);
|
|
70
|
-
const elementMap = createElementMap([[100, [createViewportEntry('div'), createViewportEntry('span')]], [200, [createViewportEntry('img')]], [300, [createViewportEntry('p'), createViewportEntry('a')]], [400, [createViewportEntry('img')]]]);
|
|
71
|
-
const expected = [createExpectedResult(50, 20, [createViewportEntry('div'), createViewportEntry('span')]), createExpectedResult(150, 60, [createViewportEntry('img')]), createExpectedResult(250, 80, [createViewportEntry('p'), createViewportEntry('a')]), createExpectedResult(350, 100, [createViewportEntry('img')])];
|
|
72
|
-
const result = calculatePercentilesWithDebugInfo(timePixelCounts, elementMap, 50, 50);
|
|
73
|
-
expect(result).toEqual(expected);
|
|
74
|
-
});
|
|
75
|
-
});
|