@atlaskit/react-ufo 2.0.1 → 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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 2.0.1
|
|
4
12
|
|
|
5
13
|
### Patch 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, {
|
|
@@ -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, {
|
|
@@ -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, {
|
|
@@ -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
|
*/
|
|
@@ -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
|
*/
|