@atlaskit/react-ufo 4.2.2 → 4.2.4
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/common/utils/index.js +133 -18
- package/dist/cjs/create-payload/index.js +2 -9
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +11 -0
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +45 -30
- package/dist/es2019/create-payload/common/utils/index.js +113 -19
- package/dist/es2019/create-payload/index.js +2 -8
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +9 -0
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +28 -19
- package/dist/esm/create-payload/common/utils/index.js +131 -18
- package/dist/esm/create-payload/index.js +3 -10
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +11 -0
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +45 -30
- package/dist/types/config/index.d.ts +4 -0
- package/dist/types/create-payload/common/utils/index.d.ts +12 -1
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -0
- package/dist/types-ts4.5/config/index.d.ts +4 -0
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +12 -1
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -0
- package/package.json +7 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { isContainedWithinMediaWrapper } from '../../vc-observer/media-wrapper/vc-utils';
|
|
3
4
|
import isNonVisualStyleMutation from '../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation';
|
|
4
5
|
import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placeholders';
|
|
@@ -100,7 +101,7 @@ export default class ViewportObserver {
|
|
|
100
101
|
});
|
|
101
102
|
const targetNode = target.deref();
|
|
102
103
|
for (const addedNodeRef of addedNodes) {
|
|
103
|
-
var _this$
|
|
104
|
+
var _this$intersectionObs9;
|
|
104
105
|
const addedNode = addedNodeRef.deref();
|
|
105
106
|
if (!addedNode) {
|
|
106
107
|
continue;
|
|
@@ -140,19 +141,27 @@ export default class ViewportObserver {
|
|
|
140
141
|
const ssrPlaceholderHandler = this.getSSRPlaceholderHandler();
|
|
141
142
|
if (ssrPlaceholderHandler) {
|
|
142
143
|
if (ssrPlaceholderHandler.isPlaceholder(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode)) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
if (fg('platform_ufo_ssr_placeholder_resolution_ttvc_v3')) {
|
|
145
|
+
if (ssrPlaceholderHandler.checkIfExistedAndSizeMatchingV3(addedNode)) {
|
|
146
|
+
var _this$intersectionObs3;
|
|
147
|
+
(_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
const result = await ssrPlaceholderHandler.checkIfExistedAndSizeMatching(addedNode);
|
|
152
|
+
if (result !== false) {
|
|
153
|
+
var _this$intersectionObs4;
|
|
154
|
+
(_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
148
157
|
}
|
|
149
158
|
// If result is false, continue to normal mutation logic below
|
|
150
159
|
}
|
|
151
160
|
if (ssrPlaceholderHandler.isPlaceholderReplacement(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode)) {
|
|
152
161
|
const result = await ssrPlaceholderHandler.validateReactComponentMatchToPlaceholder(addedNode);
|
|
153
162
|
if (result !== false) {
|
|
154
|
-
var _this$
|
|
155
|
-
(_this$
|
|
163
|
+
var _this$intersectionObs5;
|
|
164
|
+
(_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 ? void 0 : _this$intersectionObs5.watchAndTag(addedNode, 'mutation:ssr-placeholder');
|
|
156
165
|
continue;
|
|
157
166
|
}
|
|
158
167
|
// If result is false, continue to normal mutation logic below
|
|
@@ -168,24 +177,24 @@ export default class ViewportObserver {
|
|
|
168
177
|
});
|
|
169
178
|
const isInIgnoreLsMarker = isInVCIgnoreIfNoLayoutShiftMarker(addedNode);
|
|
170
179
|
if (sameDeletedNode && isInIgnoreLsMarker) {
|
|
171
|
-
var _this$
|
|
172
|
-
(_this$
|
|
180
|
+
var _this$intersectionObs6;
|
|
181
|
+
(_this$intersectionObs6 = this.intersectionObserver) === null || _this$intersectionObs6 === void 0 ? void 0 : _this$intersectionObs6.watchAndTag(addedNode, 'mutation:remount');
|
|
173
182
|
continue;
|
|
174
183
|
}
|
|
175
184
|
if (isContainedWithinMediaWrapper(addedNode)) {
|
|
176
|
-
var _this$
|
|
177
|
-
(_this$
|
|
185
|
+
var _this$intersectionObs7;
|
|
186
|
+
(_this$intersectionObs7 = this.intersectionObserver) === null || _this$intersectionObs7 === void 0 ? void 0 : _this$intersectionObs7.watchAndTag(addedNode, 'mutation:media');
|
|
178
187
|
continue;
|
|
179
188
|
}
|
|
180
189
|
const {
|
|
181
190
|
isWithin: isWithinThirdPartySegment
|
|
182
191
|
} = checkWithinComponent(addedNode, 'UFOThirdPartySegment', this.mapIs3pResult);
|
|
183
192
|
if (isWithinThirdPartySegment) {
|
|
184
|
-
var _this$
|
|
185
|
-
(_this$
|
|
193
|
+
var _this$intersectionObs8;
|
|
194
|
+
(_this$intersectionObs8 = this.intersectionObserver) === null || _this$intersectionObs8 === void 0 ? void 0 : _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
|
|
186
195
|
continue;
|
|
187
196
|
}
|
|
188
|
-
(_this$
|
|
197
|
+
(_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
189
198
|
}
|
|
190
199
|
});
|
|
191
200
|
_defineProperty(this, "handleAttributeMutation", ({
|
|
@@ -194,8 +203,8 @@ export default class ViewportObserver {
|
|
|
194
203
|
oldValue,
|
|
195
204
|
newValue
|
|
196
205
|
}) => {
|
|
197
|
-
var _this$
|
|
198
|
-
(_this$
|
|
206
|
+
var _this$intersectionObs0;
|
|
207
|
+
(_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 ? void 0 : _this$intersectionObs0.watchAndTag(target, ({
|
|
199
208
|
target,
|
|
200
209
|
rect
|
|
201
210
|
}) => {
|
|
@@ -322,12 +331,12 @@ export default class ViewportObserver {
|
|
|
322
331
|
this.isStarted = true;
|
|
323
332
|
}
|
|
324
333
|
stop() {
|
|
325
|
-
var _this$mutationObserve2, _this$
|
|
334
|
+
var _this$mutationObserve2, _this$intersectionObs1, _this$performanceObse2;
|
|
326
335
|
if (!this.isStarted) {
|
|
327
336
|
return;
|
|
328
337
|
}
|
|
329
338
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 ? void 0 : _this$mutationObserve2.disconnect();
|
|
330
|
-
(_this$
|
|
339
|
+
(_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 ? void 0 : _this$intersectionObs1.disconnect();
|
|
331
340
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 ? void 0 : _this$performanceObse2.disconnect();
|
|
332
341
|
this.isStarted = false;
|
|
333
342
|
// Clean up caches when stopping
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
var _excluded = ["labelStack"],
|
|
4
|
+
_excluded2 = ["labelStack"];
|
|
2
5
|
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; }
|
|
3
6
|
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; }
|
|
7
|
+
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; } } }; }
|
|
8
|
+
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; } }
|
|
9
|
+
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; }
|
|
4
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { getConfig } from '../../../config';
|
|
12
|
+
import { getReactUFOPayloadVersion } from '../../utils/get-react-ufo-payload-version';
|
|
5
13
|
export function sanitizeUfoName(name) {
|
|
6
14
|
return name.replace(/_/g, '-');
|
|
7
15
|
}
|
|
@@ -13,26 +21,72 @@ export function buildSegmentTree(labelStacks) {
|
|
|
13
21
|
n: 'segment-tree-root',
|
|
14
22
|
c: {}
|
|
15
23
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
var config = getConfig();
|
|
25
|
+
var segmentThreshold = config === null || config === void 0 ? void 0 : config.segmentsThreshold;
|
|
26
|
+
var addSegmentsMap = new Map();
|
|
27
|
+
if (fg('platform_ufo_add_segments_count_threshold')) {
|
|
28
|
+
labelStacks.forEach(function (labelStack) {
|
|
29
|
+
var stringifiedLabelStack = stringifyLabelStackWithoutId(labelStack);
|
|
30
|
+
var currentNode = r;
|
|
31
|
+
var _iterator = _createForOfIteratorHelper(labelStack),
|
|
32
|
+
_step;
|
|
33
|
+
try {
|
|
34
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
35
|
+
var label = _step.value;
|
|
36
|
+
var isSegment = isSegmentLabel(label);
|
|
37
|
+
var name = label.name;
|
|
38
|
+
if (isSegment && segmentThreshold && segmentThreshold[name]) {
|
|
39
|
+
var threshold = segmentThreshold[name];
|
|
40
|
+
var count = addSegmentsMap.get(stringifiedLabelStack) || 0;
|
|
41
|
+
if (count < threshold) {
|
|
42
|
+
addSegmentsMap.set(stringifiedLabelStack, count + 1);
|
|
43
|
+
} else {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var id = isSegment ? label.segmentId : undefined;
|
|
48
|
+
var key = id !== undefined ? id : name;
|
|
49
|
+
var type = isSegment ? label.type : undefined;
|
|
50
|
+
if (!currentNode.c) {
|
|
51
|
+
currentNode.c = {};
|
|
52
|
+
}
|
|
53
|
+
if (!currentNode.c[key]) {
|
|
54
|
+
currentNode.c[key] = _objectSpread({
|
|
55
|
+
n: name
|
|
56
|
+
}, type && fg('platform_ufo_add_type_for_3p_segments') ? {
|
|
57
|
+
t: type
|
|
58
|
+
} : {});
|
|
59
|
+
}
|
|
60
|
+
currentNode = currentNode.c[key];
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
_iterator.e(err);
|
|
64
|
+
} finally {
|
|
65
|
+
_iterator.f();
|
|
25
66
|
}
|
|
26
|
-
if (!currentNode.c[key]) {
|
|
27
|
-
currentNode.c[key] = _objectSpread({
|
|
28
|
-
n: name
|
|
29
|
-
}, type && fg('platform_ufo_add_type_for_3p_segments') ? {
|
|
30
|
-
t: type
|
|
31
|
-
} : {});
|
|
32
|
-
}
|
|
33
|
-
currentNode = currentNode.c[key];
|
|
34
67
|
});
|
|
35
|
-
}
|
|
68
|
+
} else {
|
|
69
|
+
labelStacks.forEach(function (labelStack) {
|
|
70
|
+
var currentNode = r;
|
|
71
|
+
labelStack.forEach(function (label) {
|
|
72
|
+
var name = label.name;
|
|
73
|
+
var id = isSegmentLabel(label) ? label.segmentId : undefined;
|
|
74
|
+
var key = id !== undefined ? id : name;
|
|
75
|
+
var type = isSegmentLabel(label) ? label.type : undefined;
|
|
76
|
+
if (!currentNode.c) {
|
|
77
|
+
currentNode.c = {};
|
|
78
|
+
}
|
|
79
|
+
if (!currentNode.c[key]) {
|
|
80
|
+
currentNode.c[key] = _objectSpread({
|
|
81
|
+
n: name
|
|
82
|
+
}, type && fg('platform_ufo_add_type_for_3p_segments') ? {
|
|
83
|
+
t: type
|
|
84
|
+
} : {});
|
|
85
|
+
}
|
|
86
|
+
currentNode = currentNode.c[key];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
36
90
|
return {
|
|
37
91
|
r: r
|
|
38
92
|
};
|
|
@@ -45,6 +99,14 @@ export function stringifyLabelStackFully(labelStack) {
|
|
|
45
99
|
return l.name;
|
|
46
100
|
}).join('/');
|
|
47
101
|
}
|
|
102
|
+
export function stringifyLabelStackWithoutId(labelStack) {
|
|
103
|
+
return labelStack.map(function (l) {
|
|
104
|
+
if (isSegmentLabel(l)) {
|
|
105
|
+
return "".concat(l.name, ":segment");
|
|
106
|
+
}
|
|
107
|
+
return l.name;
|
|
108
|
+
}).join('/');
|
|
109
|
+
}
|
|
48
110
|
function getLabelStackReference(labelStack) {
|
|
49
111
|
return labelStack.map(function (l) {
|
|
50
112
|
return isSegmentLabel(l) ? l.segmentId : l.name;
|
|
@@ -63,4 +125,55 @@ export function optimizeLabelStack(labelStack, reactUFOVersion) {
|
|
|
63
125
|
t: ls.type
|
|
64
126
|
} : {});
|
|
65
127
|
});
|
|
128
|
+
}
|
|
129
|
+
export function getOldSegmentsLabelStack(segments, interactionType) {
|
|
130
|
+
if (fg('platform_ufo_add_segments_count_threshold')) {
|
|
131
|
+
var config = getConfig();
|
|
132
|
+
var addSegmentsMap = new Map();
|
|
133
|
+
var segmentThreshold = config === null || config === void 0 ? void 0 : config.segmentsThreshold;
|
|
134
|
+
return segments.map(function (_ref) {
|
|
135
|
+
var labelStack = _ref.labelStack,
|
|
136
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
|
137
|
+
var stringifiedLabelStack = stringifyLabelStackWithoutId(labelStack);
|
|
138
|
+
var segmentsInfo = [];
|
|
139
|
+
var _iterator2 = _createForOfIteratorHelper(labelStack),
|
|
140
|
+
_step2;
|
|
141
|
+
try {
|
|
142
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
143
|
+
var ls = _step2.value;
|
|
144
|
+
var isSegment = isSegmentLabel(ls);
|
|
145
|
+
if (isSegment && segmentThreshold && segmentThreshold[ls.name]) {
|
|
146
|
+
var threshold = segmentThreshold[ls.name];
|
|
147
|
+
var count = addSegmentsMap.get(stringifiedLabelStack) || 0;
|
|
148
|
+
if (count < threshold) {
|
|
149
|
+
addSegmentsMap.set(stringifiedLabelStack, count + 1);
|
|
150
|
+
} else {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
segmentsInfo.push(_objectSpread(_objectSpread({
|
|
155
|
+
n: ls.name
|
|
156
|
+
}, ls.segmentId ? {
|
|
157
|
+
s: ls.segmentId
|
|
158
|
+
} : {}), ls.type && fg('platform_ufo_add_type_for_3p_segments') ? {
|
|
159
|
+
t: ls.type
|
|
160
|
+
} : {}));
|
|
161
|
+
}
|
|
162
|
+
} catch (err) {
|
|
163
|
+
_iterator2.e(err);
|
|
164
|
+
} finally {
|
|
165
|
+
_iterator2.f();
|
|
166
|
+
}
|
|
167
|
+
return _objectSpread(_objectSpread({}, others), {}, {
|
|
168
|
+
labelStack: segmentsInfo
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return segments.map(function (_ref2) {
|
|
173
|
+
var labelStack = _ref2.labelStack,
|
|
174
|
+
others = _objectWithoutProperties(_ref2, _excluded2);
|
|
175
|
+
return _objectSpread(_objectSpread({}, others), {}, {
|
|
176
|
+
labelStack: optimizeLabelStack(labelStack, getReactUFOPayloadVersion(interactionType))
|
|
177
|
+
});
|
|
178
|
+
});
|
|
66
179
|
}
|
|
@@ -5,8 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
var _excluded = ["labelStack", "time"],
|
|
7
7
|
_excluded2 = ["stopTime", "labelStack"],
|
|
8
|
-
_excluded3 = ["labelStack"]
|
|
9
|
-
_excluded4 = ["labelStack"];
|
|
8
|
+
_excluded3 = ["labelStack"];
|
|
10
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
10
|
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; }
|
|
12
11
|
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; }
|
|
@@ -31,7 +30,7 @@ import * as resourceTiming from '../resource-timing';
|
|
|
31
30
|
import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
|
|
32
31
|
import { roundEpsilon } from '../round-number';
|
|
33
32
|
import * as ssr from '../ssr';
|
|
34
|
-
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
33
|
+
import { buildSegmentTree, getOldSegmentsLabelStack, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
35
34
|
import { createCriticalMetricsPayloads } from './critical-metrics-payload';
|
|
36
35
|
import { addPerformanceMeasures } from './utils/add-performance-measures';
|
|
37
36
|
import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
|
|
@@ -749,13 +748,7 @@ function _createInteractionMetricsPayload() {
|
|
|
749
748
|
apdex: optimizeApdex(interaction.apdex, getReactUFOPayloadVersion(interaction.type)),
|
|
750
749
|
end: Math.round(end),
|
|
751
750
|
start: Math.round(start),
|
|
752
|
-
segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : segments.
|
|
753
|
-
var labelStack = _ref7.labelStack,
|
|
754
|
-
others = _objectWithoutProperties(_ref7, _excluded4);
|
|
755
|
-
return _objectSpread(_objectSpread({}, others), {}, {
|
|
756
|
-
labelStack: optimizeLabelStack(labelStack, getReactUFOPayloadVersion(interaction.type))
|
|
757
|
-
});
|
|
758
|
-
}),
|
|
751
|
+
segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : getOldSegmentsLabelStack(segments, interaction.type),
|
|
759
752
|
marks: optimizeMarks(interaction.marks, getReactUFOPayloadVersion(interaction.type)),
|
|
760
753
|
customData: optimizeCustomData(interaction),
|
|
761
754
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, getReactUFOPayloadVersion(interaction.type))
|
|
@@ -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) {
|
|
@@ -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
|
|
@@ -24,6 +24,9 @@ type SelectorConfig = {
|
|
|
24
24
|
className: boolean;
|
|
25
25
|
dataVC?: boolean;
|
|
26
26
|
};
|
|
27
|
+
type SegmentThreshold = {
|
|
28
|
+
readonly [key: string]: number;
|
|
29
|
+
};
|
|
27
30
|
type Rates = {
|
|
28
31
|
readonly [key: string]: number;
|
|
29
32
|
};
|
|
@@ -68,6 +71,7 @@ export type Config = {
|
|
|
68
71
|
};
|
|
69
72
|
readonly assetsConfig?: AssetsConfig;
|
|
70
73
|
readonly enableBetterPageVisibilityApi?: boolean;
|
|
74
|
+
readonly segmentsThreshold?: SegmentThreshold;
|
|
71
75
|
readonly vc?: {
|
|
72
76
|
readonly enabled?: boolean;
|
|
73
77
|
readonly heatmapSize?: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { InteractionType, SegmentInfo } from '../../../common';
|
|
1
2
|
import type { LabelStack, SegmentLabel } from '../../../interaction-context';
|
|
2
3
|
import { type UFOSegmentType } from '../../../segment/segment';
|
|
3
|
-
import {
|
|
4
|
+
import { getReactUFOPayloadVersion } from '../../utils/get-react-ufo-payload-version';
|
|
4
5
|
export type SegmentItem = {
|
|
5
6
|
n: string;
|
|
6
7
|
c?: Record<string, SegmentItem>;
|
|
@@ -13,9 +14,19 @@ export declare function sanitizeUfoName(name: string): string;
|
|
|
13
14
|
export declare function isSegmentLabel(obj: any): obj is SegmentLabel;
|
|
14
15
|
export declare function buildSegmentTree(labelStacks: LabelStack[]): SegmentTree;
|
|
15
16
|
export declare function stringifyLabelStackFully(labelStack: LabelStack): string;
|
|
17
|
+
export declare function stringifyLabelStackWithoutId(labelStack: LabelStack): string;
|
|
16
18
|
export declare function labelStackStartWith(labelStack: LabelStack, startWith: LabelStack): boolean;
|
|
17
19
|
export declare function optimizeLabelStack(labelStack: LabelStack, reactUFOVersion: ReturnType<typeof getReactUFOPayloadVersion>): string | {
|
|
18
20
|
t?: UFOSegmentType | undefined;
|
|
19
21
|
s?: string | undefined;
|
|
20
22
|
n: string;
|
|
21
23
|
}[];
|
|
24
|
+
export declare function getOldSegmentsLabelStack(segments: SegmentInfo[], interactionType: InteractionType): {
|
|
25
|
+
labelStack: any[];
|
|
26
|
+
}[] | {
|
|
27
|
+
labelStack: string | {
|
|
28
|
+
t?: UFOSegmentType | undefined;
|
|
29
|
+
s?: string | undefined;
|
|
30
|
+
n: string;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
@@ -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;
|
|
@@ -24,6 +24,9 @@ type SelectorConfig = {
|
|
|
24
24
|
className: boolean;
|
|
25
25
|
dataVC?: boolean;
|
|
26
26
|
};
|
|
27
|
+
type SegmentThreshold = {
|
|
28
|
+
readonly [key: string]: number;
|
|
29
|
+
};
|
|
27
30
|
type Rates = {
|
|
28
31
|
readonly [key: string]: number;
|
|
29
32
|
};
|
|
@@ -68,6 +71,7 @@ export type Config = {
|
|
|
68
71
|
};
|
|
69
72
|
readonly assetsConfig?: AssetsConfig;
|
|
70
73
|
readonly enableBetterPageVisibilityApi?: boolean;
|
|
74
|
+
readonly segmentsThreshold?: SegmentThreshold;
|
|
71
75
|
readonly vc?: {
|
|
72
76
|
readonly enabled?: boolean;
|
|
73
77
|
readonly heatmapSize?: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { InteractionType, SegmentInfo } from '../../../common';
|
|
1
2
|
import type { LabelStack, SegmentLabel } from '../../../interaction-context';
|
|
2
3
|
import { type UFOSegmentType } from '../../../segment/segment';
|
|
3
|
-
import {
|
|
4
|
+
import { getReactUFOPayloadVersion } from '../../utils/get-react-ufo-payload-version';
|
|
4
5
|
export type SegmentItem = {
|
|
5
6
|
n: string;
|
|
6
7
|
c?: Record<string, SegmentItem>;
|
|
@@ -13,9 +14,19 @@ export declare function sanitizeUfoName(name: string): string;
|
|
|
13
14
|
export declare function isSegmentLabel(obj: any): obj is SegmentLabel;
|
|
14
15
|
export declare function buildSegmentTree(labelStacks: LabelStack[]): SegmentTree;
|
|
15
16
|
export declare function stringifyLabelStackFully(labelStack: LabelStack): string;
|
|
17
|
+
export declare function stringifyLabelStackWithoutId(labelStack: LabelStack): string;
|
|
16
18
|
export declare function labelStackStartWith(labelStack: LabelStack, startWith: LabelStack): boolean;
|
|
17
19
|
export declare function optimizeLabelStack(labelStack: LabelStack, reactUFOVersion: ReturnType<typeof getReactUFOPayloadVersion>): string | {
|
|
18
20
|
t?: UFOSegmentType | undefined;
|
|
19
21
|
s?: string | undefined;
|
|
20
22
|
n: string;
|
|
21
23
|
}[];
|
|
24
|
+
export declare function getOldSegmentsLabelStack(segments: SegmentInfo[], interactionType: InteractionType): {
|
|
25
|
+
labelStack: any[];
|
|
26
|
+
}[] | {
|
|
27
|
+
labelStack: string | {
|
|
28
|
+
t?: UFOSegmentType | undefined;
|
|
29
|
+
s?: string | undefined;
|
|
30
|
+
n: string;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.4",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -197,6 +197,12 @@
|
|
|
197
197
|
},
|
|
198
198
|
"platform_ufo_report_non_htmlelement_selectors": {
|
|
199
199
|
"type": "boolean"
|
|
200
|
+
},
|
|
201
|
+
"platform_ufo_add_segments_count_threshold": {
|
|
202
|
+
"type": "boolean"
|
|
203
|
+
},
|
|
204
|
+
"platform_ufo_ssr_placeholder_resolution_ttvc_v3": {
|
|
205
|
+
"type": "boolean"
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
}
|