@atlaskit/react-ufo 3.4.4 → 3.4.6
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-payload/index.js +2 -2
- package/dist/cjs/interaction-metrics-init/index.js +4 -4
- package/dist/cjs/interaction-metrics-init/schedule-idle-callback.js +15 -0
- package/dist/cjs/vc/index.js +5 -3
- package/dist/cjs/vc/vc-observer-new/get-element-name.js +7 -1
- package/dist/cjs/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +1 -2
- package/dist/es2019/interaction-metrics-init/index.js +4 -4
- package/dist/es2019/interaction-metrics-init/schedule-idle-callback.js +9 -0
- package/dist/es2019/vc/index.js +8 -5
- package/dist/es2019/vc/vc-observer-new/get-element-name.js +7 -1
- package/dist/esm/create-payload/index.js +2 -2
- package/dist/esm/interaction-metrics-init/index.js +4 -4
- package/dist/esm/interaction-metrics-init/schedule-idle-callback.js +9 -0
- package/dist/esm/vc/index.js +5 -4
- package/dist/esm/vc/vc-observer-new/get-element-name.js +7 -1
- package/dist/esm/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +1 -2
- package/dist/types/interaction-metrics-init/schedule-idle-callback.d.ts +1 -0
- package/dist/types/vc/index.d.ts +1 -0
- package/dist/types-ts4.5/interaction-metrics-init/schedule-idle-callback.d.ts +1 -0
- package/dist/types-ts4.5/vc/index.d.ts +1 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#131564](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131564)
|
|
8
|
+
[`e4cc2be4d7e50`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e4cc2be4d7e50) -
|
|
9
|
+
Fix get element name to use data vc by default unless specifically disabled
|
|
10
|
+
|
|
11
|
+
## 3.4.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#130268](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130268)
|
|
16
|
+
[`597d9e0c5582d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/597d9e0c5582d) -
|
|
17
|
+
use requestIdleCallback for payload creation if its available
|
|
18
|
+
|
|
3
19
|
## 3.4.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -63,14 +63,14 @@ function getUfoNameOverride(interaction) {
|
|
|
63
63
|
function getEarliestLegacyStopTime(interaction, labelStack) {
|
|
64
64
|
var earliestLegacyStopTime = null;
|
|
65
65
|
interaction.apdex.forEach(function (a) {
|
|
66
|
-
var _a$labelStack
|
|
66
|
+
var _a$labelStack;
|
|
67
67
|
if (!(a !== null && a !== void 0 && a.stopTime)) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
if (!(0, _utils.labelStackStartWith)((_a$labelStack = a.labelStack) !== null && _a$labelStack !== void 0 ? _a$labelStack : [], labelStack)) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
if (a.stopTime > interaction.start && (
|
|
73
|
+
if (a.stopTime > interaction.start && (earliestLegacyStopTime !== null && earliestLegacyStopTime !== void 0 ? earliestLegacyStopTime : a.stopTime) >= a.stopTime) {
|
|
74
74
|
earliestLegacyStopTime = a.stopTime;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.init = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _scheduler = require("scheduler");
|
|
11
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _additionalPayload = require("../additional-payload");
|
|
13
12
|
var _config = require("../config");
|
|
@@ -15,12 +14,13 @@ var _createExperimentalInteractionMetricsPayload = require("../create-experiment
|
|
|
15
14
|
var _hiddenTiming = require("../hidden-timing");
|
|
16
15
|
var _interactionMetrics = require("../interaction-metrics");
|
|
17
16
|
var _vc = require("../vc");
|
|
17
|
+
var _scheduleIdleCallback = _interopRequireDefault(require("./schedule-idle-callback"));
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
20
|
var initialized = false;
|
|
21
21
|
function sinkInteraction(instance, payloadPackage) {
|
|
22
22
|
(0, _interactionMetrics.sinkInteractionHandler)(function (interactionId, interaction) {
|
|
23
|
-
(0,
|
|
23
|
+
(0, _scheduleIdleCallback.default)(function () {
|
|
24
24
|
payloadPackage.createPayloads(interactionId, interaction).then(function (payloads) {
|
|
25
25
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and Criterion
|
|
26
26
|
var devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
@@ -38,7 +38,7 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
38
38
|
}
|
|
39
39
|
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
40
40
|
(0, _createExperimentalInteractionMetricsPayload.sinkExperimentalHandler)(function (interactionId, interaction) {
|
|
41
|
-
(0,
|
|
41
|
+
(0, _scheduleIdleCallback.default)(function () {
|
|
42
42
|
var payloadPromise = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
43
43
|
payloadPromise.then(function (payload) {
|
|
44
44
|
if (payload) {
|
|
@@ -57,7 +57,7 @@ function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
|
57
57
|
}
|
|
58
58
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
59
59
|
(0, _interactionMetrics.sinkPostInteractionLogHandler)(function (logOutput) {
|
|
60
|
-
(0,
|
|
60
|
+
(0, _scheduleIdleCallback.default)(function () {
|
|
61
61
|
var payload = createPostInteractionLogPayload(logOutput);
|
|
62
62
|
if (payload) {
|
|
63
63
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and also by Criterion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = scheduleIdleCallback;
|
|
7
|
+
var _scheduler = require("scheduler");
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
|
+
function scheduleIdleCallback(work) {
|
|
10
|
+
if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function' && (0, _platformFeatureFlags.fg)('ufo_payload_use_idle_callback')) {
|
|
11
|
+
window.requestIdleCallback(work);
|
|
12
|
+
} else {
|
|
13
|
+
(0, _scheduler.unstable_scheduleCallback)(_scheduler.unstable_IdlePriority, work);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/cjs/vc/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getVCObserver = void 0;
|
|
8
|
+
exports.isEnvironmentSupported = isEnvironmentSupported;
|
|
8
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -114,12 +115,13 @@ var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
114
115
|
(_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 || _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
|
|
115
116
|
}
|
|
116
117
|
}]);
|
|
117
|
-
}();
|
|
118
|
+
}(); // Some products set this variable to indicate it is running in SSR
|
|
118
119
|
var isServer = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.__SERVER__);
|
|
119
|
-
|
|
120
|
+
// Other products set this other variable to indicate it is running in SSR
|
|
121
|
+
var isReactSSR = typeof process !== 'undefined' && Boolean(((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.REACT_SSR) || false);
|
|
120
122
|
function isEnvironmentSupported() {
|
|
121
123
|
// SSR environment aren't supported
|
|
122
|
-
if (isReactSSR) {
|
|
124
|
+
if (isReactSSR || isServer) {
|
|
123
125
|
return false;
|
|
124
126
|
}
|
|
125
127
|
|
|
@@ -16,6 +16,9 @@ function getElementName(selectorConfig, element) {
|
|
|
16
16
|
// Get the tag name of the element.
|
|
17
17
|
var tagName = element.localName;
|
|
18
18
|
var encodeValue = function encodeValue(s) {
|
|
19
|
+
if (typeof encodeURIComponent !== 'function') {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
19
22
|
try {
|
|
20
23
|
return encodeURIComponent(s);
|
|
21
24
|
} catch (e) {
|
|
@@ -26,6 +29,9 @@ function getElementName(selectorConfig, element) {
|
|
|
26
29
|
// Helper function to construct attribute selectors.
|
|
27
30
|
var getAttributeSelector = function getAttributeSelector(attributeName) {
|
|
28
31
|
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
32
|
+
if (element && typeof element.getAttribute !== 'function') {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
29
35
|
var attrValue = element.getAttribute(attributeName);
|
|
30
36
|
if (!attrValue) {
|
|
31
37
|
return '';
|
|
@@ -35,7 +41,7 @@ function getElementName(selectorConfig, element) {
|
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
// Construct the data-vc attribute selector if specified in the config.
|
|
38
|
-
var dataVC = selectorConfig.dataVC ? getAttributeSelector('data-vc') : '';
|
|
44
|
+
var dataVC = selectorConfig.dataVC !== false ? getAttributeSelector('data-vc') : '';
|
|
39
45
|
|
|
40
46
|
// Construct the ID selector if specified in the config and the element has an ID.
|
|
41
47
|
var id = selectorConfig.id && element.id ? "#".concat(encodeValue(element.id)) : '';
|
|
@@ -17,7 +17,6 @@ function createIntersectionObserver(args) {
|
|
|
17
17
|
var validEntries = [];
|
|
18
18
|
var startTime = performance.now();
|
|
19
19
|
entries.forEach(function (entry) {
|
|
20
|
-
var _mutationTag;
|
|
21
20
|
if (!(entry.target instanceof HTMLElement) || !isValidEntry(entry)) {
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
@@ -44,7 +43,7 @@ function createIntersectionObserver(args) {
|
|
|
44
43
|
target: entry.target,
|
|
45
44
|
rect: entry.intersectionRect,
|
|
46
45
|
time: entry.time,
|
|
47
|
-
type:
|
|
46
|
+
type: mutationTag !== null && mutationTag !== void 0 ? mutationTag : 'unknown',
|
|
48
47
|
mutationData: mutationData
|
|
49
48
|
});
|
|
50
49
|
validEntries.push(new WeakRef(entry.target));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { startLighthouseObserver } from '../additional-payload';
|
|
4
3
|
import { setUFOConfig } from '../config';
|
|
@@ -6,10 +5,11 @@ import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-
|
|
|
6
5
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
7
6
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
8
7
|
import { getVCObserver } from '../vc';
|
|
8
|
+
import scheduleIdleCallback from './schedule-idle-callback';
|
|
9
9
|
let initialized = false;
|
|
10
10
|
function sinkInteraction(instance, payloadPackage) {
|
|
11
11
|
sinkInteractionHandler((interactionId, interaction) => {
|
|
12
|
-
|
|
12
|
+
scheduleIdleCallback(() => {
|
|
13
13
|
payloadPackage.createPayloads(interactionId, interaction).then(payloads => {
|
|
14
14
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and Criterion
|
|
15
15
|
const devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
@@ -27,7 +27,7 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
27
27
|
}
|
|
28
28
|
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
29
29
|
sinkExperimentalHandler((interactionId, interaction) => {
|
|
30
|
-
|
|
30
|
+
scheduleIdleCallback(() => {
|
|
31
31
|
const payloadPromise = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
32
32
|
payloadPromise.then(payload => {
|
|
33
33
|
if (payload) {
|
|
@@ -46,7 +46,7 @@ function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
|
46
46
|
}
|
|
47
47
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
48
48
|
sinkPostInteractionLogHandler(logOutput => {
|
|
49
|
-
|
|
49
|
+
scheduleIdleCallback(() => {
|
|
50
50
|
const payload = createPostInteractionLogPayload(logOutput);
|
|
51
51
|
if (payload) {
|
|
52
52
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and also by Criterion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export default function scheduleIdleCallback(work) {
|
|
4
|
+
if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function' && fg('ufo_payload_use_idle_callback')) {
|
|
5
|
+
window.requestIdleCallback(work);
|
|
6
|
+
} else {
|
|
7
|
+
scheduleCallback(idlePriority, work);
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/es2019/vc/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _process;
|
|
1
|
+
var _process, _process$env;
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { getConfig } from '../config';
|
|
4
4
|
import { VCObserverNOOP } from './no-op-vc-observer';
|
|
@@ -60,11 +60,14 @@ class VCObserverWrapper {
|
|
|
60
60
|
(_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 ? void 0 : _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
|
|
64
|
+
// Some products set this variable to indicate it is running in SSR
|
|
65
|
+
let isServer = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.__SERVER__);
|
|
66
|
+
// Other products set this other variable to indicate it is running in SSR
|
|
67
|
+
let isReactSSR = typeof process !== 'undefined' && Boolean(((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.REACT_SSR) || false);
|
|
68
|
+
export function isEnvironmentSupported() {
|
|
66
69
|
// SSR environment aren't supported
|
|
67
|
-
if (isReactSSR) {
|
|
70
|
+
if (isReactSSR || isServer) {
|
|
68
71
|
return false;
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -10,6 +10,9 @@ export default function getElementName(selectorConfig, element) {
|
|
|
10
10
|
// Get the tag name of the element.
|
|
11
11
|
const tagName = element.localName;
|
|
12
12
|
const encodeValue = s => {
|
|
13
|
+
if (typeof encodeURIComponent !== 'function') {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
13
16
|
try {
|
|
14
17
|
return encodeURIComponent(s);
|
|
15
18
|
} catch (e) {
|
|
@@ -19,6 +22,9 @@ export default function getElementName(selectorConfig, element) {
|
|
|
19
22
|
|
|
20
23
|
// Helper function to construct attribute selectors.
|
|
21
24
|
const getAttributeSelector = (attributeName, prefix = '') => {
|
|
25
|
+
if (element && typeof element.getAttribute !== 'function') {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
22
28
|
const attrValue = element.getAttribute(attributeName);
|
|
23
29
|
if (!attrValue) {
|
|
24
30
|
return '';
|
|
@@ -28,7 +34,7 @@ export default function getElementName(selectorConfig, element) {
|
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
// Construct the data-vc attribute selector if specified in the config.
|
|
31
|
-
const dataVC = selectorConfig.dataVC ? getAttributeSelector('data-vc') : '';
|
|
37
|
+
const dataVC = selectorConfig.dataVC !== false ? getAttributeSelector('data-vc') : '';
|
|
32
38
|
|
|
33
39
|
// Construct the ID selector if specified in the config and the element has an ID.
|
|
34
40
|
const id = selectorConfig.id && element.id ? `#${encodeValue(element.id)}` : '';
|
|
@@ -52,14 +52,14 @@ function getUfoNameOverride(interaction) {
|
|
|
52
52
|
function getEarliestLegacyStopTime(interaction, labelStack) {
|
|
53
53
|
var earliestLegacyStopTime = null;
|
|
54
54
|
interaction.apdex.forEach(function (a) {
|
|
55
|
-
var _a$labelStack
|
|
55
|
+
var _a$labelStack;
|
|
56
56
|
if (!(a !== null && a !== void 0 && a.stopTime)) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
if (!labelStackStartWith((_a$labelStack = a.labelStack) !== null && _a$labelStack !== void 0 ? _a$labelStack : [], labelStack)) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
if (a.stopTime > interaction.start && (
|
|
62
|
+
if (a.stopTime > interaction.start && (earliestLegacyStopTime !== null && earliestLegacyStopTime !== void 0 ? earliestLegacyStopTime : a.stopTime) >= a.stopTime) {
|
|
63
63
|
earliestLegacyStopTime = a.stopTime;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { startLighthouseObserver } from '../additional-payload';
|
|
5
4
|
import { setUFOConfig } from '../config';
|
|
@@ -7,10 +6,11 @@ import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-
|
|
|
7
6
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
8
7
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
9
8
|
import { getVCObserver } from '../vc';
|
|
9
|
+
import scheduleIdleCallback from './schedule-idle-callback';
|
|
10
10
|
var initialized = false;
|
|
11
11
|
function sinkInteraction(instance, payloadPackage) {
|
|
12
12
|
sinkInteractionHandler(function (interactionId, interaction) {
|
|
13
|
-
|
|
13
|
+
scheduleIdleCallback(function () {
|
|
14
14
|
payloadPackage.createPayloads(interactionId, interaction).then(function (payloads) {
|
|
15
15
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and Criterion
|
|
16
16
|
var devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
@@ -28,7 +28,7 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
28
28
|
}
|
|
29
29
|
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
30
30
|
sinkExperimentalHandler(function (interactionId, interaction) {
|
|
31
|
-
|
|
31
|
+
scheduleIdleCallback(function () {
|
|
32
32
|
var payloadPromise = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
33
33
|
payloadPromise.then(function (payload) {
|
|
34
34
|
if (payload) {
|
|
@@ -47,7 +47,7 @@ function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
|
47
47
|
}
|
|
48
48
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
49
49
|
sinkPostInteractionLogHandler(function (logOutput) {
|
|
50
|
-
|
|
50
|
+
scheduleIdleCallback(function () {
|
|
51
51
|
var payload = createPostInteractionLogPayload(logOutput);
|
|
52
52
|
if (payload) {
|
|
53
53
|
// NOTE: This API is used by the UFO DevTool Chrome Extension and also by Criterion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export default function scheduleIdleCallback(work) {
|
|
4
|
+
if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function' && fg('ufo_payload_use_idle_callback')) {
|
|
5
|
+
window.requestIdleCallback(work);
|
|
6
|
+
} else {
|
|
7
|
+
scheduleCallback(idlePriority, work);
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/esm/vc/index.js
CHANGED
|
@@ -107,12 +107,13 @@ var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
107
107
|
(_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 || _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
|
|
108
108
|
}
|
|
109
109
|
}]);
|
|
110
|
-
}();
|
|
110
|
+
}(); // Some products set this variable to indicate it is running in SSR
|
|
111
111
|
var isServer = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.__SERVER__);
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
// Other products set this other variable to indicate it is running in SSR
|
|
113
|
+
var isReactSSR = typeof process !== 'undefined' && Boolean(((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.REACT_SSR) || false);
|
|
114
|
+
export function isEnvironmentSupported() {
|
|
114
115
|
// SSR environment aren't supported
|
|
115
|
-
if (isReactSSR) {
|
|
116
|
+
if (isReactSSR || isServer) {
|
|
116
117
|
return false;
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -10,6 +10,9 @@ export default function getElementName(selectorConfig, element) {
|
|
|
10
10
|
// Get the tag name of the element.
|
|
11
11
|
var tagName = element.localName;
|
|
12
12
|
var encodeValue = function encodeValue(s) {
|
|
13
|
+
if (typeof encodeURIComponent !== 'function') {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
13
16
|
try {
|
|
14
17
|
return encodeURIComponent(s);
|
|
15
18
|
} catch (e) {
|
|
@@ -20,6 +23,9 @@ export default function getElementName(selectorConfig, element) {
|
|
|
20
23
|
// Helper function to construct attribute selectors.
|
|
21
24
|
var getAttributeSelector = function getAttributeSelector(attributeName) {
|
|
22
25
|
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
26
|
+
if (element && typeof element.getAttribute !== 'function') {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
23
29
|
var attrValue = element.getAttribute(attributeName);
|
|
24
30
|
if (!attrValue) {
|
|
25
31
|
return '';
|
|
@@ -29,7 +35,7 @@ export default function getElementName(selectorConfig, element) {
|
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
// Construct the data-vc attribute selector if specified in the config.
|
|
32
|
-
var dataVC = selectorConfig.dataVC ? getAttributeSelector('data-vc') : '';
|
|
38
|
+
var dataVC = selectorConfig.dataVC !== false ? getAttributeSelector('data-vc') : '';
|
|
33
39
|
|
|
34
40
|
// Construct the ID selector if specified in the config and the element has an ID.
|
|
35
41
|
var id = selectorConfig.id && element.id ? "#".concat(encodeValue(element.id)) : '';
|
|
@@ -11,7 +11,6 @@ export function createIntersectionObserver(args) {
|
|
|
11
11
|
var validEntries = [];
|
|
12
12
|
var startTime = performance.now();
|
|
13
13
|
entries.forEach(function (entry) {
|
|
14
|
-
var _mutationTag;
|
|
15
14
|
if (!(entry.target instanceof HTMLElement) || !isValidEntry(entry)) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
@@ -38,7 +37,7 @@ export function createIntersectionObserver(args) {
|
|
|
38
37
|
target: entry.target,
|
|
39
38
|
rect: entry.intersectionRect,
|
|
40
39
|
time: entry.time,
|
|
41
|
-
type:
|
|
40
|
+
type: mutationTag !== null && mutationTag !== void 0 ? mutationTag : 'unknown',
|
|
42
41
|
mutationData: mutationData
|
|
43
42
|
});
|
|
44
43
|
validEntries.push(new WeakRef(entry.target));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function scheduleIdleCallback(work: () => void): void;
|
package/dist/types/vc/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import type { VCObserverInterface, VCObserverOptions } from './types';
|
|
|
2
2
|
declare global {
|
|
3
3
|
var __vcObserver: VCObserverInterface;
|
|
4
4
|
}
|
|
5
|
+
export declare function isEnvironmentSupported(): boolean;
|
|
5
6
|
export declare const getVCObserver: (opts?: VCObserverOptions) => VCObserverInterface;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function scheduleIdleCallback(work: () => void): void;
|
|
@@ -2,4 +2,5 @@ import type { VCObserverInterface, VCObserverOptions } from './types';
|
|
|
2
2
|
declare global {
|
|
3
3
|
var __vcObserver: VCObserverInterface;
|
|
4
4
|
}
|
|
5
|
+
export declare function isEnvironmentSupported(): boolean;
|
|
5
6
|
export declare const getVCObserver: (opts?: VCObserverOptions) => VCObserverInterface;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.6",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -183,6 +183,9 @@
|
|
|
183
183
|
},
|
|
184
184
|
"ufo_lcp": {
|
|
185
185
|
"type": "boolean"
|
|
186
|
+
},
|
|
187
|
+
"ufo_payload_use_idle_callback": {
|
|
188
|
+
"type": "boolean"
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
}
|