@atlaskit/react-ufo 2.0.0 → 2.0.2
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/segment/segment.js +11 -3
- package/dist/cjs/vc/vc-observer/index.js +2 -2
- package/dist/es2019/segment/segment.js +12 -4
- package/dist/es2019/vc/vc-observer/index.js +2 -2
- package/dist/esm/segment/segment.js +12 -4
- package/dist/esm/vc/vc-observer/index.js +2 -2
- package/dist/types/common/vc/types.d.ts +1 -1
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types-ts4.5/common/vc/types.d.ts +1 -1
- package/dist/types-ts4.5/config/index.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#157063](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157063)
|
|
8
|
+
[`e710d292f8921`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e710d292f8921) -
|
|
9
|
+
manually track mount phase in UFO segments
|
|
10
|
+
|
|
11
|
+
## 2.0.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#156904](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/156904)
|
|
16
|
+
[`285da5f8a4b0b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/285da5f8a4b0b) -
|
|
17
|
+
use weakref for VC observer debug elements
|
|
18
|
+
|
|
3
19
|
## 2.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
|
@@ -36,7 +36,7 @@ var AsyncSegmentHighlight = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
|
36
36
|
|
|
37
37
|
/** A portion of the page we apply measurement to */
|
|
38
38
|
function UFOSegment(_ref) {
|
|
39
|
-
var
|
|
39
|
+
var _getConfig2;
|
|
40
40
|
var segmentName = _ref.name,
|
|
41
41
|
children = _ref.children;
|
|
42
42
|
var parentContext = (0, _react.useContext)(_interactionContext.default);
|
|
@@ -220,8 +220,16 @@ function UFOSegment(_ref) {
|
|
|
220
220
|
complete: complete
|
|
221
221
|
};
|
|
222
222
|
}, [parentContext, labelStack, interactionId]);
|
|
223
|
+
var hasMounted = (0, _react.useRef)(false);
|
|
223
224
|
var onRender = (0, _react.useCallback)(function (_id, phase, actualDuration, baseDuration, startTime, commitTime) {
|
|
224
|
-
|
|
225
|
+
var _getConfig;
|
|
226
|
+
// Manually keep track of mount-phase, and ensure that every segment is always mounted at least once
|
|
227
|
+
if ((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && _getConfig.manuallyTrackReactProfilerMounts && !hasMounted.current) {
|
|
228
|
+
interactionContext.onRender('mount', actualDuration, baseDuration, startTime, commitTime);
|
|
229
|
+
hasMounted.current = true;
|
|
230
|
+
} else {
|
|
231
|
+
interactionContext.onRender(phase, actualDuration, baseDuration, startTime, commitTime);
|
|
232
|
+
}
|
|
225
233
|
}, [interactionContext]);
|
|
226
234
|
(0, _react.useEffect)(function () {
|
|
227
235
|
return function () {
|
|
@@ -233,7 +241,7 @@ function UFOSegment(_ref) {
|
|
|
233
241
|
return l.name;
|
|
234
242
|
}).join('/');
|
|
235
243
|
}, [labelStack]);
|
|
236
|
-
var enableSegmentHighlighting = (
|
|
244
|
+
var enableSegmentHighlighting = (_getConfig2 = (0, _config.getConfig)()) === null || _getConfig2 === void 0 ? void 0 : _getConfig2.enableSegmentHighlighting;
|
|
237
245
|
return /*#__PURE__*/_react.default.createElement(_interactionContext.default.Provider, {
|
|
238
246
|
value: interactionContext
|
|
239
247
|
}, /*#__PURE__*/_react.default.createElement(_react.Profiler, {
|
|
@@ -214,7 +214,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
214
214
|
_this.componentsLog[time] = [];
|
|
215
215
|
}
|
|
216
216
|
_this.componentsLog[time].push({
|
|
217
|
-
__debug__element: _this.devToolsEnabled ? element : null,
|
|
217
|
+
__debug__element: _this.devToolsEnabled ? new WeakRef(element) : null,
|
|
218
218
|
intersectionRect: intersectionRect,
|
|
219
219
|
targetName: targetName,
|
|
220
220
|
ignoreReason: ignoreReason
|
|
@@ -464,7 +464,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
464
464
|
if (ssr !== UNUSED_SECTOR) {
|
|
465
465
|
var _window$document;
|
|
466
466
|
var element = {
|
|
467
|
-
__debug__element: (_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body,
|
|
467
|
+
__debug__element: new WeakRef((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body),
|
|
468
468
|
intersectionRect: {
|
|
469
469
|
top: 0,
|
|
470
470
|
left: 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { lazy, Profiler, Suspense, useCallback, useContext, useEffect, useMemo } from 'react';
|
|
1
|
+
import React, { lazy, Profiler, Suspense, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { unstable_NormalPriority as NormalPriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
3
|
import { v4 as createUUID } from 'uuid';
|
|
4
4
|
import coinflip from '../coinflip';
|
|
@@ -19,7 +19,7 @@ export default function UFOSegment({
|
|
|
19
19
|
name: segmentName,
|
|
20
20
|
children
|
|
21
21
|
}) {
|
|
22
|
-
var
|
|
22
|
+
var _getConfig2;
|
|
23
23
|
const parentContext = useContext(UFOInteractionContext);
|
|
24
24
|
const segmentId = useMemo(() => generateId(), []);
|
|
25
25
|
const labelStack = useMemo(() => parentContext !== null && parentContext !== void 0 && parentContext.labelStack ? [...parentContext.labelStack, {
|
|
@@ -197,14 +197,22 @@ export default function UFOSegment({
|
|
|
197
197
|
complete
|
|
198
198
|
};
|
|
199
199
|
}, [parentContext, labelStack, interactionId]);
|
|
200
|
+
const hasMounted = useRef(false);
|
|
200
201
|
const onRender = useCallback((_id, phase, actualDuration, baseDuration, startTime, commitTime) => {
|
|
201
|
-
|
|
202
|
+
var _getConfig;
|
|
203
|
+
// Manually keep track of mount-phase, and ensure that every segment is always mounted at least once
|
|
204
|
+
if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && _getConfig.manuallyTrackReactProfilerMounts && !hasMounted.current) {
|
|
205
|
+
interactionContext.onRender('mount', actualDuration, baseDuration, startTime, commitTime);
|
|
206
|
+
hasMounted.current = true;
|
|
207
|
+
} else {
|
|
208
|
+
interactionContext.onRender(phase, actualDuration, baseDuration, startTime, commitTime);
|
|
209
|
+
}
|
|
202
210
|
}, [interactionContext]);
|
|
203
211
|
useEffect(() => () => {
|
|
204
212
|
removeSegment(labelStack);
|
|
205
213
|
}, [interactionId, parentContext, interactionContext, labelStack]);
|
|
206
214
|
const reactProfilerId = useMemo(() => labelStack.map(l => l.name).join('/'), [labelStack]);
|
|
207
|
-
const enableSegmentHighlighting = (
|
|
215
|
+
const enableSegmentHighlighting = (_getConfig2 = getConfig()) === null || _getConfig2 === void 0 ? void 0 : _getConfig2.enableSegmentHighlighting;
|
|
208
216
|
return /*#__PURE__*/React.createElement(UFOInteractionContext.Provider, {
|
|
209
217
|
value: interactionContext
|
|
210
218
|
}, /*#__PURE__*/React.createElement(Profiler, {
|
|
@@ -228,7 +228,7 @@ export class VCObserver {
|
|
|
228
228
|
this.componentsLog[time] = [];
|
|
229
229
|
}
|
|
230
230
|
this.componentsLog[time].push({
|
|
231
|
-
__debug__element: this.devToolsEnabled ? element : null,
|
|
231
|
+
__debug__element: this.devToolsEnabled ? new WeakRef(element) : null,
|
|
232
232
|
intersectionRect,
|
|
233
233
|
targetName,
|
|
234
234
|
ignoreReason
|
|
@@ -363,7 +363,7 @@ export class VCObserver {
|
|
|
363
363
|
if (ssr !== UNUSED_SECTOR) {
|
|
364
364
|
var _window$document;
|
|
365
365
|
const element = {
|
|
366
|
-
__debug__element: (_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body,
|
|
366
|
+
__debug__element: new WeakRef((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body),
|
|
367
367
|
intersectionRect: {
|
|
368
368
|
top: 0,
|
|
369
369
|
left: 0,
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
|
-
import React, { lazy, Profiler, Suspense, useCallback, useContext, useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { lazy, Profiler, Suspense, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
6
6
|
import { unstable_NormalPriority as NormalPriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
7
7
|
import { v4 as createUUID } from 'uuid';
|
|
8
8
|
import coinflip from '../coinflip';
|
|
@@ -24,7 +24,7 @@ var AsyncSegmentHighlight = /*#__PURE__*/lazy(function () {
|
|
|
24
24
|
|
|
25
25
|
/** A portion of the page we apply measurement to */
|
|
26
26
|
export default function UFOSegment(_ref) {
|
|
27
|
-
var
|
|
27
|
+
var _getConfig2;
|
|
28
28
|
var segmentName = _ref.name,
|
|
29
29
|
children = _ref.children;
|
|
30
30
|
var parentContext = useContext(UFOInteractionContext);
|
|
@@ -208,8 +208,16 @@ export default function UFOSegment(_ref) {
|
|
|
208
208
|
complete: complete
|
|
209
209
|
};
|
|
210
210
|
}, [parentContext, labelStack, interactionId]);
|
|
211
|
+
var hasMounted = useRef(false);
|
|
211
212
|
var onRender = useCallback(function (_id, phase, actualDuration, baseDuration, startTime, commitTime) {
|
|
212
|
-
|
|
213
|
+
var _getConfig;
|
|
214
|
+
// Manually keep track of mount-phase, and ensure that every segment is always mounted at least once
|
|
215
|
+
if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && _getConfig.manuallyTrackReactProfilerMounts && !hasMounted.current) {
|
|
216
|
+
interactionContext.onRender('mount', actualDuration, baseDuration, startTime, commitTime);
|
|
217
|
+
hasMounted.current = true;
|
|
218
|
+
} else {
|
|
219
|
+
interactionContext.onRender(phase, actualDuration, baseDuration, startTime, commitTime);
|
|
220
|
+
}
|
|
213
221
|
}, [interactionContext]);
|
|
214
222
|
useEffect(function () {
|
|
215
223
|
return function () {
|
|
@@ -221,7 +229,7 @@ export default function UFOSegment(_ref) {
|
|
|
221
229
|
return l.name;
|
|
222
230
|
}).join('/');
|
|
223
231
|
}, [labelStack]);
|
|
224
|
-
var enableSegmentHighlighting = (
|
|
232
|
+
var enableSegmentHighlighting = (_getConfig2 = getConfig()) === null || _getConfig2 === void 0 ? void 0 : _getConfig2.enableSegmentHighlighting;
|
|
225
233
|
return /*#__PURE__*/React.createElement(UFOInteractionContext.Provider, {
|
|
226
234
|
value: interactionContext
|
|
227
235
|
}, /*#__PURE__*/React.createElement(Profiler, {
|
|
@@ -207,7 +207,7 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
207
207
|
_this.componentsLog[time] = [];
|
|
208
208
|
}
|
|
209
209
|
_this.componentsLog[time].push({
|
|
210
|
-
__debug__element: _this.devToolsEnabled ? element : null,
|
|
210
|
+
__debug__element: _this.devToolsEnabled ? new WeakRef(element) : null,
|
|
211
211
|
intersectionRect: intersectionRect,
|
|
212
212
|
targetName: targetName,
|
|
213
213
|
ignoreReason: ignoreReason
|
|
@@ -457,7 +457,7 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
457
457
|
if (ssr !== UNUSED_SECTOR) {
|
|
458
458
|
var _window$document;
|
|
459
459
|
var element = {
|
|
460
|
-
__debug__element: (_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body,
|
|
460
|
+
__debug__element: new WeakRef((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body),
|
|
461
461
|
intersectionRect: {
|
|
462
462
|
top: 0,
|
|
463
463
|
left: 0,
|
|
@@ -38,7 +38,7 @@ export type VCEntryType = {
|
|
|
38
38
|
export type VCIgnoreReason = 'image' | 'ssr-hydration' | '';
|
|
39
39
|
export type ComponentsLogEntry = {
|
|
40
40
|
targetName: string;
|
|
41
|
-
__debug__element: Element | null;
|
|
41
|
+
__debug__element: WeakRef<Element> | null;
|
|
42
42
|
intersectionRect: DOMRectReadOnly;
|
|
43
43
|
ignoreReason?: VCIgnoreReason;
|
|
44
44
|
};
|
|
@@ -70,6 +70,7 @@ export type Config = {
|
|
|
70
70
|
readonly enableSegmentHighlighting?: boolean;
|
|
71
71
|
readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
|
|
72
72
|
readonly timeWindowForLateMutationsInMilliseconds?: number;
|
|
73
|
+
readonly manuallyTrackReactProfilerMounts?: boolean;
|
|
73
74
|
/**
|
|
74
75
|
* @deprecated setting this will do nothing now
|
|
75
76
|
*/
|
|
@@ -38,7 +38,7 @@ export type VCEntryType = {
|
|
|
38
38
|
export type VCIgnoreReason = 'image' | 'ssr-hydration' | '';
|
|
39
39
|
export type ComponentsLogEntry = {
|
|
40
40
|
targetName: string;
|
|
41
|
-
__debug__element: Element | null;
|
|
41
|
+
__debug__element: WeakRef<Element> | null;
|
|
42
42
|
intersectionRect: DOMRectReadOnly;
|
|
43
43
|
ignoreReason?: VCIgnoreReason;
|
|
44
44
|
};
|
|
@@ -70,6 +70,7 @@ export type Config = {
|
|
|
70
70
|
readonly enableSegmentHighlighting?: boolean;
|
|
71
71
|
readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
|
|
72
72
|
readonly timeWindowForLateMutationsInMilliseconds?: number;
|
|
73
|
+
readonly manuallyTrackReactProfilerMounts?: boolean;
|
|
73
74
|
/**
|
|
74
75
|
* @deprecated setting this will do nothing now
|
|
75
76
|
*/
|