@atlaskit/react-ufo 3.13.21 → 3.13.22
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 +8 -0
- package/dist/cjs/interaction-metrics-init/index.js +2 -1
- package/dist/cjs/vc/vc-observer/index.js +4 -2
- package/dist/cjs/vc/vc-observer/observers/index.js +6 -2
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +22 -6
- package/dist/es2019/interaction-metrics-init/index.js +2 -1
- package/dist/es2019/vc/vc-observer/index.js +4 -2
- package/dist/es2019/vc/vc-observer/observers/index.js +5 -2
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +18 -2
- package/dist/esm/interaction-metrics-init/index.js +2 -1
- package/dist/esm/vc/vc-observer/index.js +4 -2
- package/dist/esm/vc/vc-observer/observers/index.js +6 -2
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +22 -6
- package/dist/types/config/index.d.ts +4 -0
- package/dist/types/vc/types.d.ts +4 -0
- package/dist/types/vc/vc-observer/observers/index.d.ts +4 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +10 -1
- package/dist/types-ts4.5/config/index.d.ts +4 -0
- package/dist/types-ts4.5/vc/types.d.ts +4 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +4 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +10 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.13.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#169345](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169345)
|
|
8
|
+
[`6fab3e0da9d68`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6fab3e0da9d68) -
|
|
9
|
+
Added API to disable checks for size and position of SSR placeholders
|
|
10
|
+
|
|
3
11
|
## 3.13.21
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -95,7 +95,8 @@ function init(analyticsWebClientAsync, config) {
|
|
|
95
95
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
96
96
|
devToolsEnabled: config.vc.devToolsEnabled,
|
|
97
97
|
selectorConfig: config.vc.selectorConfig,
|
|
98
|
-
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
|
|
98
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
99
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
99
100
|
};
|
|
100
101
|
(0, _vc.getVCObserver)(vcOptions).start({
|
|
101
102
|
startTime: 0
|
|
@@ -454,7 +454,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
454
454
|
this.arraySize = options.heatmapSize || 200;
|
|
455
455
|
this.devToolsEnabled = options.devToolsEnabled || false;
|
|
456
456
|
this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
|
|
457
|
-
var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder
|
|
457
|
+
var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
|
|
458
|
+
disableSizeAndPositionCheck = options.disableSizeAndPositionCheck;
|
|
458
459
|
this.observers = new _observers.Observers({
|
|
459
460
|
selectorConfig: options.selectorConfig || {
|
|
460
461
|
id: false,
|
|
@@ -464,7 +465,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
464
465
|
dataVC: true
|
|
465
466
|
},
|
|
466
467
|
SSRConfig: {
|
|
467
|
-
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
|
|
468
|
+
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
|
|
469
|
+
disableSizeAndPositionCheck: disableSizeAndPositionCheck
|
|
468
470
|
}
|
|
469
471
|
});
|
|
470
472
|
this.heatmap = !(0, _config.isVCRevisionEnabled)('fy25.01') ? [] : this.getCleanHeatmap();
|
|
@@ -33,7 +33,8 @@ function isElementVisible(target) {
|
|
|
33
33
|
var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
34
34
|
function Observers(opts) {
|
|
35
35
|
var _this = this,
|
|
36
|
-
_opts$SSRConfig
|
|
36
|
+
_opts$SSRConfig,
|
|
37
|
+
_opts$SSRConfig2;
|
|
37
38
|
(0, _classCallCheck2.default)(this, Observers);
|
|
38
39
|
(0, _defineProperty2.default)(this, "observedMutations", new WeakMap());
|
|
39
40
|
(0, _defineProperty2.default)(this, "elementsInView", new Set());
|
|
@@ -73,7 +74,10 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
|
73
74
|
this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
|
|
74
75
|
this.intersectionObserver = this.getIntersectionObserver();
|
|
75
76
|
this.mutationObserver = this.getMutationObserver();
|
|
76
|
-
this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers(
|
|
77
|
+
this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers({
|
|
78
|
+
enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
|
|
79
|
+
disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
|
|
80
|
+
});
|
|
77
81
|
}
|
|
78
82
|
return (0, _createClass2.default)(Observers, [{
|
|
79
83
|
key: "isBrowserSupported",
|
|
@@ -11,9 +11,15 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var ANCESTOR_LOOKUP_LIMIT = 10;
|
|
12
12
|
var PAGE_LAYOUT_ID = 'page-layout.root';
|
|
13
13
|
var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
14
|
-
function SSRPlaceholderHandlers() {
|
|
14
|
+
function SSRPlaceholderHandlers(_ref) {
|
|
15
15
|
var _this = this;
|
|
16
|
-
var
|
|
16
|
+
var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
|
|
17
|
+
enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
|
|
18
|
+
_ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
|
|
19
|
+
disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
|
|
20
|
+
v: false,
|
|
21
|
+
h: false
|
|
22
|
+
} : _ref$disableSizeAndPo;
|
|
17
23
|
(0, _classCallCheck2.default)(this, SSRPlaceholderHandlers);
|
|
18
24
|
(0, _defineProperty2.default)(this, "staticPlaceholders", new Map());
|
|
19
25
|
(0, _defineProperty2.default)(this, "callbacks", new Map());
|
|
@@ -42,10 +48,10 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
42
48
|
}
|
|
43
49
|
return '';
|
|
44
50
|
});
|
|
45
|
-
(0, _defineProperty2.default)(this, "intersectionObserverCallback", function (
|
|
51
|
+
(0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref2) {
|
|
46
52
|
var _this$intersectionObs;
|
|
47
|
-
var target =
|
|
48
|
-
boundingClientRect =
|
|
53
|
+
var target = _ref2.target,
|
|
54
|
+
boundingClientRect = _ref2.boundingClientRect;
|
|
49
55
|
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.unobserve(target);
|
|
50
56
|
if (!(target instanceof HTMLElement)) {
|
|
51
57
|
// impossible case - keep typescript healthy
|
|
@@ -102,6 +108,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
102
108
|
});
|
|
103
109
|
}
|
|
104
110
|
this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
|
|
111
|
+
this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
|
|
105
112
|
if (window.document) {
|
|
106
113
|
try {
|
|
107
114
|
var selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
|
|
@@ -223,7 +230,16 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
223
230
|
}, {
|
|
224
231
|
key: "hasSameSizePosition",
|
|
225
232
|
value: function hasSameSizePosition(rect, boundingClientRect) {
|
|
226
|
-
|
|
233
|
+
var _this$disableSizeAndP, _this$disableSizeAndP2;
|
|
234
|
+
if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
if (!rect) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
|
|
241
|
+
var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
|
|
242
|
+
return horizontalCheck && verticalCheck || false;
|
|
227
243
|
}
|
|
228
244
|
}, {
|
|
229
245
|
key: "isDummyRect",
|
|
@@ -85,7 +85,8 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
85
85
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
86
86
|
devToolsEnabled: config.vc.devToolsEnabled,
|
|
87
87
|
selectorConfig: config.vc.selectorConfig,
|
|
88
|
-
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
|
|
88
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
89
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
89
90
|
};
|
|
90
91
|
getVCObserver(vcOptions).start({
|
|
91
92
|
startTime: 0
|
|
@@ -494,7 +494,8 @@ export class VCObserver {
|
|
|
494
494
|
this.devToolsEnabled = options.devToolsEnabled || false;
|
|
495
495
|
this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
|
|
496
496
|
const {
|
|
497
|
-
ssrEnablePageLayoutPlaceholder
|
|
497
|
+
ssrEnablePageLayoutPlaceholder,
|
|
498
|
+
disableSizeAndPositionCheck
|
|
498
499
|
} = options;
|
|
499
500
|
this.observers = new Observers({
|
|
500
501
|
selectorConfig: options.selectorConfig || {
|
|
@@ -505,7 +506,8 @@ export class VCObserver {
|
|
|
505
506
|
dataVC: true
|
|
506
507
|
},
|
|
507
508
|
SSRConfig: {
|
|
508
|
-
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
|
|
509
|
+
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
|
|
510
|
+
disableSizeAndPositionCheck: disableSizeAndPositionCheck
|
|
509
511
|
}
|
|
510
512
|
});
|
|
511
513
|
this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
|
|
@@ -21,7 +21,7 @@ function isElementVisible(target) {
|
|
|
21
21
|
}
|
|
22
22
|
export class Observers {
|
|
23
23
|
constructor(opts) {
|
|
24
|
-
var _opts$SSRConfig;
|
|
24
|
+
var _opts$SSRConfig, _opts$SSRConfig2;
|
|
25
25
|
_defineProperty(this, "observedMutations", new WeakMap());
|
|
26
26
|
_defineProperty(this, "elementsInView", new Set());
|
|
27
27
|
_defineProperty(this, "callbacks", new Set());
|
|
@@ -61,7 +61,10 @@ export class Observers {
|
|
|
61
61
|
};
|
|
62
62
|
this.intersectionObserver = this.getIntersectionObserver();
|
|
63
63
|
this.mutationObserver = this.getMutationObserver();
|
|
64
|
-
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers(
|
|
64
|
+
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
|
|
65
|
+
enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
|
|
66
|
+
disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
|
|
67
|
+
});
|
|
65
68
|
}
|
|
66
69
|
isBrowserSupported() {
|
|
67
70
|
return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
|
|
@@ -2,7 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
const ANCESTOR_LOOKUP_LIMIT = 10;
|
|
3
3
|
const PAGE_LAYOUT_ID = 'page-layout.root';
|
|
4
4
|
export class SSRPlaceholderHandlers {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor({
|
|
6
|
+
enablePageLayoutPlaceholder = false,
|
|
7
|
+
disableSizeAndPositionCheck = {
|
|
8
|
+
v: false,
|
|
9
|
+
h: false
|
|
10
|
+
}
|
|
11
|
+
}) {
|
|
6
12
|
_defineProperty(this, "staticPlaceholders", new Map());
|
|
7
13
|
_defineProperty(this, "callbacks", new Map());
|
|
8
14
|
_defineProperty(this, "getSizeCallbacks", new Map());
|
|
@@ -87,6 +93,7 @@ export class SSRPlaceholderHandlers {
|
|
|
87
93
|
this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
|
|
88
94
|
}
|
|
89
95
|
this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
|
|
96
|
+
this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
|
|
90
97
|
if (window.document) {
|
|
91
98
|
try {
|
|
92
99
|
const selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
|
|
@@ -187,7 +194,16 @@ export class SSRPlaceholderHandlers {
|
|
|
187
194
|
});
|
|
188
195
|
}
|
|
189
196
|
hasSameSizePosition(rect, boundingClientRect) {
|
|
190
|
-
|
|
197
|
+
var _this$disableSizeAndP, _this$disableSizeAndP2;
|
|
198
|
+
if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
if (!rect) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
|
|
205
|
+
const verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
|
|
206
|
+
return horizontalCheck && verticalCheck || false;
|
|
191
207
|
}
|
|
192
208
|
isDummyRect(rect) {
|
|
193
209
|
return rect && rect.width < 0 && rect.height < 0 || false;
|
|
@@ -86,7 +86,8 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
86
86
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
87
87
|
devToolsEnabled: config.vc.devToolsEnabled,
|
|
88
88
|
selectorConfig: config.vc.selectorConfig,
|
|
89
|
-
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
|
|
89
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
90
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
90
91
|
};
|
|
91
92
|
getVCObserver(vcOptions).start({
|
|
92
93
|
startTime: 0
|
|
@@ -447,7 +447,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
447
447
|
this.arraySize = options.heatmapSize || 200;
|
|
448
448
|
this.devToolsEnabled = options.devToolsEnabled || false;
|
|
449
449
|
this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
|
|
450
|
-
var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder
|
|
450
|
+
var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
|
|
451
|
+
disableSizeAndPositionCheck = options.disableSizeAndPositionCheck;
|
|
451
452
|
this.observers = new Observers({
|
|
452
453
|
selectorConfig: options.selectorConfig || {
|
|
453
454
|
id: false,
|
|
@@ -457,7 +458,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
457
458
|
dataVC: true
|
|
458
459
|
},
|
|
459
460
|
SSRConfig: {
|
|
460
|
-
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
|
|
461
|
+
enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
|
|
462
|
+
disableSizeAndPositionCheck: disableSizeAndPositionCheck
|
|
461
463
|
}
|
|
462
464
|
});
|
|
463
465
|
this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
|
|
@@ -26,7 +26,8 @@ function isElementVisible(target) {
|
|
|
26
26
|
export var Observers = /*#__PURE__*/function () {
|
|
27
27
|
function Observers(opts) {
|
|
28
28
|
var _this = this,
|
|
29
|
-
_opts$SSRConfig
|
|
29
|
+
_opts$SSRConfig,
|
|
30
|
+
_opts$SSRConfig2;
|
|
30
31
|
_classCallCheck(this, Observers);
|
|
31
32
|
_defineProperty(this, "observedMutations", new WeakMap());
|
|
32
33
|
_defineProperty(this, "elementsInView", new Set());
|
|
@@ -66,7 +67,10 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
66
67
|
this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
|
|
67
68
|
this.intersectionObserver = this.getIntersectionObserver();
|
|
68
69
|
this.mutationObserver = this.getMutationObserver();
|
|
69
|
-
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers(
|
|
70
|
+
this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
|
|
71
|
+
enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
|
|
72
|
+
disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
|
|
73
|
+
});
|
|
70
74
|
}
|
|
71
75
|
return _createClass(Observers, [{
|
|
72
76
|
key: "isBrowserSupported",
|
|
@@ -4,9 +4,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
var ANCESTOR_LOOKUP_LIMIT = 10;
|
|
5
5
|
var PAGE_LAYOUT_ID = 'page-layout.root';
|
|
6
6
|
export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
7
|
-
function SSRPlaceholderHandlers() {
|
|
7
|
+
function SSRPlaceholderHandlers(_ref) {
|
|
8
8
|
var _this = this;
|
|
9
|
-
var
|
|
9
|
+
var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
|
|
10
|
+
enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
|
|
11
|
+
_ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
|
|
12
|
+
disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
|
|
13
|
+
v: false,
|
|
14
|
+
h: false
|
|
15
|
+
} : _ref$disableSizeAndPo;
|
|
10
16
|
_classCallCheck(this, SSRPlaceholderHandlers);
|
|
11
17
|
_defineProperty(this, "staticPlaceholders", new Map());
|
|
12
18
|
_defineProperty(this, "callbacks", new Map());
|
|
@@ -35,10 +41,10 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
35
41
|
}
|
|
36
42
|
return '';
|
|
37
43
|
});
|
|
38
|
-
_defineProperty(this, "intersectionObserverCallback", function (
|
|
44
|
+
_defineProperty(this, "intersectionObserverCallback", function (_ref2) {
|
|
39
45
|
var _this$intersectionObs;
|
|
40
|
-
var target =
|
|
41
|
-
boundingClientRect =
|
|
46
|
+
var target = _ref2.target,
|
|
47
|
+
boundingClientRect = _ref2.boundingClientRect;
|
|
42
48
|
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.unobserve(target);
|
|
43
49
|
if (!(target instanceof HTMLElement)) {
|
|
44
50
|
// impossible case - keep typescript healthy
|
|
@@ -95,6 +101,7 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
95
101
|
});
|
|
96
102
|
}
|
|
97
103
|
this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
|
|
104
|
+
this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
|
|
98
105
|
if (window.document) {
|
|
99
106
|
try {
|
|
100
107
|
var selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
|
|
@@ -216,7 +223,16 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
216
223
|
}, {
|
|
217
224
|
key: "hasSameSizePosition",
|
|
218
225
|
value: function hasSameSizePosition(rect, boundingClientRect) {
|
|
219
|
-
|
|
226
|
+
var _this$disableSizeAndP, _this$disableSizeAndP2;
|
|
227
|
+
if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
if (!rect) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
|
|
234
|
+
var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
|
|
235
|
+
return horizontalCheck && verticalCheck || false;
|
|
220
236
|
}
|
|
221
237
|
}, {
|
|
222
238
|
key: "isDummyRect",
|
|
@@ -74,6 +74,10 @@ export type Config = {
|
|
|
74
74
|
readonly ssr?: boolean;
|
|
75
75
|
readonly ssrWhitelist?: string[];
|
|
76
76
|
readonly ssrEnablePageLayoutPlaceholder?: boolean;
|
|
77
|
+
readonly disableSizeAndPositionCheck?: {
|
|
78
|
+
v: boolean;
|
|
79
|
+
h: boolean;
|
|
80
|
+
};
|
|
77
81
|
readonly includeSSRInV3?: boolean;
|
|
78
82
|
readonly stopVCAtInteractionFinish?: boolean;
|
|
79
83
|
readonly includeSSRRatio?: boolean;
|
package/dist/types/vc/types.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export type VCObserverOptions = {
|
|
|
26
26
|
selectorConfig?: SelectorConfig | undefined;
|
|
27
27
|
isPostInteraction?: boolean;
|
|
28
28
|
ssrEnablePageLayoutPlaceholder?: boolean;
|
|
29
|
+
disableSizeAndPositionCheck?: {
|
|
30
|
+
v: boolean;
|
|
31
|
+
h: boolean;
|
|
32
|
+
};
|
|
29
33
|
};
|
|
30
34
|
export interface VCObserverInterface {
|
|
31
35
|
start(startArg: {
|
|
@@ -11,6 +11,10 @@ type ConstructorOptions = {
|
|
|
11
11
|
selectorConfig: SelectorConfig;
|
|
12
12
|
SSRConfig?: {
|
|
13
13
|
enablePageLayoutPlaceholder: boolean;
|
|
14
|
+
disableSizeAndPositionCheck?: {
|
|
15
|
+
v: boolean;
|
|
16
|
+
h: boolean;
|
|
17
|
+
};
|
|
14
18
|
};
|
|
15
19
|
};
|
|
16
20
|
export declare class Observers implements BrowserObservers {
|
|
@@ -4,6 +4,14 @@ type Rect = {
|
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
};
|
|
7
|
+
type DisableSizeAndPositionCheckType = {
|
|
8
|
+
v: boolean;
|
|
9
|
+
h: boolean;
|
|
10
|
+
};
|
|
11
|
+
type SSRPlaceholderHandlersConfig = {
|
|
12
|
+
enablePageLayoutPlaceholder?: boolean;
|
|
13
|
+
disableSizeAndPositionCheck?: DisableSizeAndPositionCheckType;
|
|
14
|
+
};
|
|
7
15
|
export declare class SSRPlaceholderHandlers {
|
|
8
16
|
private staticPlaceholders;
|
|
9
17
|
private callbacks;
|
|
@@ -12,7 +20,8 @@ export declare class SSRPlaceholderHandlers {
|
|
|
12
20
|
private intersectionObserver;
|
|
13
21
|
private EQUALITY_THRESHOLD;
|
|
14
22
|
private enablePageLayoutPlaceholder;
|
|
15
|
-
|
|
23
|
+
private disableSizeAndPositionCheck;
|
|
24
|
+
constructor({ enablePageLayoutPlaceholder, disableSizeAndPositionCheck }: SSRPlaceholderHandlersConfig);
|
|
16
25
|
private getPlaceholderId;
|
|
17
26
|
private getPlaceholderReplacementId;
|
|
18
27
|
clear(): void;
|
|
@@ -74,6 +74,10 @@ export type Config = {
|
|
|
74
74
|
readonly ssr?: boolean;
|
|
75
75
|
readonly ssrWhitelist?: string[];
|
|
76
76
|
readonly ssrEnablePageLayoutPlaceholder?: boolean;
|
|
77
|
+
readonly disableSizeAndPositionCheck?: {
|
|
78
|
+
v: boolean;
|
|
79
|
+
h: boolean;
|
|
80
|
+
};
|
|
77
81
|
readonly includeSSRInV3?: boolean;
|
|
78
82
|
readonly stopVCAtInteractionFinish?: boolean;
|
|
79
83
|
readonly includeSSRRatio?: boolean;
|
|
@@ -26,6 +26,10 @@ export type VCObserverOptions = {
|
|
|
26
26
|
selectorConfig?: SelectorConfig | undefined;
|
|
27
27
|
isPostInteraction?: boolean;
|
|
28
28
|
ssrEnablePageLayoutPlaceholder?: boolean;
|
|
29
|
+
disableSizeAndPositionCheck?: {
|
|
30
|
+
v: boolean;
|
|
31
|
+
h: boolean;
|
|
32
|
+
};
|
|
29
33
|
};
|
|
30
34
|
export interface VCObserverInterface {
|
|
31
35
|
start(startArg: {
|
|
@@ -11,6 +11,10 @@ type ConstructorOptions = {
|
|
|
11
11
|
selectorConfig: SelectorConfig;
|
|
12
12
|
SSRConfig?: {
|
|
13
13
|
enablePageLayoutPlaceholder: boolean;
|
|
14
|
+
disableSizeAndPositionCheck?: {
|
|
15
|
+
v: boolean;
|
|
16
|
+
h: boolean;
|
|
17
|
+
};
|
|
14
18
|
};
|
|
15
19
|
};
|
|
16
20
|
export declare class Observers implements BrowserObservers {
|
|
@@ -4,6 +4,14 @@ type Rect = {
|
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
};
|
|
7
|
+
type DisableSizeAndPositionCheckType = {
|
|
8
|
+
v: boolean;
|
|
9
|
+
h: boolean;
|
|
10
|
+
};
|
|
11
|
+
type SSRPlaceholderHandlersConfig = {
|
|
12
|
+
enablePageLayoutPlaceholder?: boolean;
|
|
13
|
+
disableSizeAndPositionCheck?: DisableSizeAndPositionCheckType;
|
|
14
|
+
};
|
|
7
15
|
export declare class SSRPlaceholderHandlers {
|
|
8
16
|
private staticPlaceholders;
|
|
9
17
|
private callbacks;
|
|
@@ -12,7 +20,8 @@ export declare class SSRPlaceholderHandlers {
|
|
|
12
20
|
private intersectionObserver;
|
|
13
21
|
private EQUALITY_THRESHOLD;
|
|
14
22
|
private enablePageLayoutPlaceholder;
|
|
15
|
-
|
|
23
|
+
private disableSizeAndPositionCheck;
|
|
24
|
+
constructor({ enablePageLayoutPlaceholder, disableSizeAndPositionCheck }: SSRPlaceholderHandlersConfig);
|
|
16
25
|
private getPlaceholderId;
|
|
17
26
|
private getPlaceholderReplacementId;
|
|
18
27
|
clear(): void;
|