@atlaskit/react-ufo 2.0.8 → 2.2.0
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 +30 -0
- package/dist/cjs/vc/vc-observer/index.js +30 -28
- package/dist/cjs/vc/vc-observer/media-wrapper/MediaWrapper.js +16 -0
- package/dist/cjs/vc/vc-observer/media-wrapper/index.js +22 -10
- package/dist/cjs/vc/vc-observer/observers/index.js +51 -7
- package/dist/es2019/vc/vc-observer/index.js +8 -8
- package/dist/es2019/vc/vc-observer/media-wrapper/MediaWrapper.js +10 -0
- package/dist/es2019/vc/vc-observer/media-wrapper/index.js +1 -9
- package/dist/es2019/vc/vc-observer/observers/index.js +31 -7
- package/dist/esm/vc/vc-observer/index.js +30 -28
- package/dist/esm/vc/vc-observer/media-wrapper/MediaWrapper.js +8 -0
- package/dist/esm/vc/vc-observer/media-wrapper/index.js +1 -7
- package/dist/esm/vc/vc-observer/observers/index.js +51 -7
- package/dist/types/vc/vc-observer/media-wrapper/MediaWrapper.d.ts +10 -0
- package/dist/types/vc/vc-observer/media-wrapper/index.d.ts +1 -7
- package/dist/types/vc/vc-observer/observers/index.d.ts +2 -1
- package/dist/types/vc/vc-observer/observers/types.d.ts +2 -1
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/MediaWrapper.d.ts +10 -0
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts +1 -7
- package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +2 -1
- package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +2 -1
- package/package.json +2 -2
- package/vc-media/package.json +15 -0
- package/vc/media/package.json +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#160594](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160594)
|
|
8
|
+
[`4a91df26ce837`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4a91df26ce837) -
|
|
9
|
+
Capture Style display changes
|
|
10
|
+
|
|
11
|
+
## 2.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#160884](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160884)
|
|
16
|
+
[`52e16a1e398bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52e16a1e398bf) -
|
|
17
|
+
Exposing VC Media Wrapper Props object
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#160884](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160884)
|
|
22
|
+
[`52e16a1e398bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52e16a1e398bf) -
|
|
23
|
+
Renamed entry point for VC Media export
|
|
24
|
+
|
|
25
|
+
## 2.0.9
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#154926](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154926)
|
|
30
|
+
[`33fd71f8d4196`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/33fd71f8d4196) -
|
|
31
|
+
Reporting VC with HTML attributes updates as separate field
|
|
32
|
+
|
|
3
33
|
## 2.0.8
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -94,7 +94,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
94
94
|
};
|
|
95
95
|
});
|
|
96
96
|
(0, _defineProperty2.default)(this, "getVCResult", function (_ref3) {
|
|
97
|
-
var _objectSpread2;
|
|
97
|
+
var _objectSpread2, _objectSpread3;
|
|
98
98
|
var start = _ref3.start,
|
|
99
99
|
stop = _ref3.stop,
|
|
100
100
|
tti = _ref3.tti,
|
|
@@ -116,7 +116,6 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
116
116
|
totalTime = rawData.totalTime,
|
|
117
117
|
componentsLog = rawData.componentsLog,
|
|
118
118
|
viewport = rawData.viewport,
|
|
119
|
-
oldDomUpdatesEnabled = rawData.oldDomUpdatesEnabled,
|
|
120
119
|
devToolsEnabled = rawData.devToolsEnabled,
|
|
121
120
|
ratios = rawData.ratios;
|
|
122
121
|
if (abortReasonInfo !== null && abortReason.blocking) {
|
|
@@ -161,7 +160,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
161
160
|
viewport: viewport
|
|
162
161
|
});
|
|
163
162
|
var outOfBoundary = outOfBoundaryInfo ? (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:oob"), outOfBoundaryInfo) : {};
|
|
164
|
-
|
|
163
|
+
//const oldDomUpdates = oldDomUpdatesEnabled ? { [`${fullPrefix}vc:old:dom`]: ssrVC.VCBox } : {};
|
|
164
|
+
|
|
165
165
|
var stopTime = performance.now();
|
|
166
166
|
|
|
167
167
|
// exposing data to devtools
|
|
@@ -196,18 +196,20 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
196
196
|
} catch (e) {
|
|
197
197
|
/* do nothing */
|
|
198
198
|
}
|
|
199
|
-
return _objectSpread(_objectSpread(
|
|
199
|
+
return _objectSpread(_objectSpread((_objectSpread2 = {
|
|
200
200
|
'metrics:vc': VC
|
|
201
|
-
}, (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:state"), true), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:dom"), VCBox), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:updates"), VCEntries.rel.slice(0, 50)), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:size"), viewport), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:total"), totalPainted), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:ratios"), ratios), _objectSpread2), outOfBoundary), {}, (0, _defineProperty2.default)(
|
|
201
|
+
}, (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:state"), true), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:dom"), VCBox), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:updates"), VCEntries.rel.slice(0, 50)), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:size"), viewport), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:total"), totalPainted), (0, _defineProperty2.default)(_objectSpread2, "".concat(fullPrefix, "vc:ratios"), ratios), _objectSpread2), outOfBoundary), {}, (_objectSpread3 = {}, (0, _defineProperty2.default)(_objectSpread3, "".concat(fullPrefix, "vc:attrs"), ssrVC.VC), (0, _defineProperty2.default)(_objectSpread3, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), _objectSpread3));
|
|
202
202
|
});
|
|
203
|
-
(0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, ignoreReason) {
|
|
203
|
+
(0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
|
|
204
204
|
_this.measureStart();
|
|
205
205
|
if (_this.abortReason.reason === null || _this.abortReason.blocking === false) {
|
|
206
206
|
var time = Math.round(rawTime - _this.startTime);
|
|
207
207
|
var mappedValues = _this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
|
|
208
208
|
_this.vcRatios[targetName] = _this.getElementRatio(mappedValues);
|
|
209
|
-
_this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
|
|
210
209
|
if (!ignoreReason) {
|
|
210
|
+
_this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
|
|
211
|
+
}
|
|
212
|
+
if (!ignoreReason && type !== 'attr') {
|
|
211
213
|
_this.applyChangesToHeatMap(mappedValues, time, _this.ssrInclusiveHeatmap);
|
|
212
214
|
}
|
|
213
215
|
if (!_this.componentsLog[time]) {
|
|
@@ -279,10 +281,10 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
279
281
|
var unbinds = (0, _attachAbortListeners.attachAbortListeners)(window, _this.viewport, _this.abortReasonCallback);
|
|
280
282
|
if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
|
|
281
283
|
var _window2;
|
|
282
|
-
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (
|
|
283
|
-
var
|
|
284
|
-
key =
|
|
285
|
-
time =
|
|
284
|
+
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref6) {
|
|
285
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
|
|
286
|
+
key = _ref7[0],
|
|
287
|
+
time = _ref7[1];
|
|
286
288
|
if (time) {
|
|
287
289
|
_this.abortReasonCallback(key, time);
|
|
288
290
|
}
|
|
@@ -310,8 +312,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
310
312
|
}
|
|
311
313
|
(0, _createClass2.default)(VCObserver, [{
|
|
312
314
|
key: "start",
|
|
313
|
-
value: function start(
|
|
314
|
-
var startTime =
|
|
315
|
+
value: function start(_ref8) {
|
|
316
|
+
var startTime = _ref8.startTime;
|
|
315
317
|
this.active = true;
|
|
316
318
|
if (this.observers.isBrowserSupported()) {
|
|
317
319
|
this.setViewportSize();
|
|
@@ -333,12 +335,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
333
335
|
}, {
|
|
334
336
|
key: "getIgnoredElements",
|
|
335
337
|
value: function getIgnoredElements(componentsLog) {
|
|
336
|
-
return Object.values(componentsLog).flat().filter(function (
|
|
337
|
-
var ignoreReason =
|
|
338
|
+
return Object.values(componentsLog).flat().filter(function (_ref9) {
|
|
339
|
+
var ignoreReason = _ref9.ignoreReason;
|
|
338
340
|
return Boolean(ignoreReason);
|
|
339
|
-
}).map(function (
|
|
340
|
-
var targetName =
|
|
341
|
-
ignoreReason =
|
|
341
|
+
}).map(function (_ref10) {
|
|
342
|
+
var targetName = _ref10.targetName,
|
|
343
|
+
ignoreReason = _ref10.ignoreReason;
|
|
342
344
|
return {
|
|
343
345
|
targetName: targetName,
|
|
344
346
|
ignoreReason: ignoreReason
|
|
@@ -453,12 +455,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
453
455
|
}
|
|
454
456
|
}], [{
|
|
455
457
|
key: "calculateVC",
|
|
456
|
-
value: function calculateVC(
|
|
457
|
-
var heatmap =
|
|
458
|
-
|
|
459
|
-
ssr =
|
|
460
|
-
componentsLog =
|
|
461
|
-
viewport =
|
|
458
|
+
value: function calculateVC(_ref11) {
|
|
459
|
+
var heatmap = _ref11.heatmap,
|
|
460
|
+
_ref11$ssr = _ref11.ssr,
|
|
461
|
+
ssr = _ref11$ssr === void 0 ? UNUSED_SECTOR : _ref11$ssr,
|
|
462
|
+
componentsLog = _ref11.componentsLog,
|
|
463
|
+
viewport = _ref11.viewport;
|
|
462
464
|
var lastUpdate = {};
|
|
463
465
|
var totalPainted = 0;
|
|
464
466
|
if (ssr !== UNUSED_SECTOR) {
|
|
@@ -518,11 +520,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
518
520
|
});
|
|
519
521
|
return VCRatio;
|
|
520
522
|
}, 0);
|
|
521
|
-
var VCEntries = entries.reduce(function (acc,
|
|
523
|
+
var VCEntries = entries.reduce(function (acc, _ref12, i) {
|
|
522
524
|
var _acc$abs, _componentsLog$timest;
|
|
523
|
-
var
|
|
524
|
-
timestamp =
|
|
525
|
-
entryPainted =
|
|
525
|
+
var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
|
|
526
|
+
timestamp = _ref13[0],
|
|
527
|
+
entryPainted = _ref13[1];
|
|
526
528
|
var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
|
|
527
529
|
var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
|
|
528
530
|
var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VcMediaWrapperProps = exports.MEDIA_WRAPPER_TAG = void 0;
|
|
8
|
+
exports.default = MediaWrapper;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var MEDIA_WRAPPER_TAG = exports.MEDIA_WRAPPER_TAG = 'data-media-vc-wrapper';
|
|
12
|
+
var VcMediaWrapperProps = exports.VcMediaWrapperProps = (0, _defineProperty2.default)({}, MEDIA_WRAPPER_TAG, true);
|
|
13
|
+
function MediaWrapper(_ref) {
|
|
14
|
+
var children = _ref.children;
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("div", VcMediaWrapperProps, children);
|
|
16
|
+
}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
Object.defineProperty(exports, "MEDIA_WRAPPER_TAG", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _MediaWrapper.MEDIA_WRAPPER_TAG;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "VcMediaWrapperProps", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _MediaWrapper.VcMediaWrapperProps;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "default", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _MediaWrapper.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var _MediaWrapper = _interopRequireWildcard(require("./MediaWrapper"));
|
|
26
|
+
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); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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; }
|
|
@@ -5,11 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.Observers = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
12
|
var _vcUtils = require("../media-wrapper/vc-utils");
|
|
12
13
|
var _ssrPlaceholders = require("./ssr-placeholders");
|
|
14
|
+
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; } } }; }
|
|
15
|
+
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; } }
|
|
16
|
+
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; }
|
|
13
17
|
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; }
|
|
14
18
|
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) { (0, _defineProperty2.default)(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; }
|
|
15
19
|
var state = {
|
|
@@ -42,12 +46,13 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
|
42
46
|
(0, _defineProperty2.default)(this, "subscribeResults", function (cb) {
|
|
43
47
|
_this.callbacks.add(cb);
|
|
44
48
|
});
|
|
45
|
-
(0, _defineProperty2.default)(this, "observeElement", function (node, mutation,
|
|
49
|
+
(0, _defineProperty2.default)(this, "observeElement", function (node, mutation, type, ignoreReason) {
|
|
46
50
|
var _this$intersectionObs;
|
|
47
51
|
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.observe(node);
|
|
48
52
|
_this.observedMutations.set(node, {
|
|
49
53
|
mutation: mutation,
|
|
50
|
-
ignoreReason: ignoreReason
|
|
54
|
+
ignoreReason: ignoreReason,
|
|
55
|
+
type: type
|
|
51
56
|
});
|
|
52
57
|
});
|
|
53
58
|
this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
|
|
@@ -177,16 +182,55 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
|
177
182
|
}
|
|
178
183
|
});
|
|
179
184
|
} else if (mutation.type === 'attributes') {
|
|
180
|
-
mutation.
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
if (mutation.target instanceof HTMLElement) {
|
|
186
|
+
// Commenting the following line temporarily.
|
|
187
|
+
// this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
188
|
+
|
|
189
|
+
// using the if below to collect data
|
|
190
|
+
// how would VC90 changes if only style display changes are accounted for
|
|
191
|
+
if (mutation.attributeName === 'style' && _this2.getStyleDisplay(mutation.target.getAttribute('style')) !== _this2.getStyleDisplay(mutation.oldValue)) {
|
|
192
|
+
_this2.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
183
193
|
}
|
|
184
|
-
}
|
|
194
|
+
}
|
|
185
195
|
}
|
|
186
196
|
});
|
|
187
197
|
_this2.measureStop();
|
|
188
198
|
}) : null;
|
|
189
199
|
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "getStyleDisplay",
|
|
202
|
+
value: function getStyleDisplay(styleAttributeValue) {
|
|
203
|
+
if (!styleAttributeValue) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Split the style string into individual declarations
|
|
208
|
+
var declarations = styleAttributeValue.split(';');
|
|
209
|
+
// Iterate over each declaration
|
|
210
|
+
var _iterator = _createForOfIteratorHelper(declarations),
|
|
211
|
+
_step;
|
|
212
|
+
try {
|
|
213
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
214
|
+
var declaration = _step.value;
|
|
215
|
+
// Trim whitespace and split into property and value
|
|
216
|
+
var _declaration$split$ma = declaration.split(':').map(function (part) {
|
|
217
|
+
return part.trim();
|
|
218
|
+
}),
|
|
219
|
+
_declaration$split$ma2 = (0, _slicedToArray2.default)(_declaration$split$ma, 2),
|
|
220
|
+
property = _declaration$split$ma2[0],
|
|
221
|
+
value = _declaration$split$ma2[1];
|
|
222
|
+
// Check if the property is 'display'
|
|
223
|
+
if (property && property.toLowerCase() === 'display') {
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (err) {
|
|
228
|
+
_iterator.e(err);
|
|
229
|
+
} finally {
|
|
230
|
+
_iterator.f();
|
|
231
|
+
}
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
190
234
|
}, {
|
|
191
235
|
key: "getElementName",
|
|
192
236
|
value: function getElementName(element) {
|
|
@@ -241,7 +285,7 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
|
241
285
|
} catch (e) {
|
|
242
286
|
elementName = 'error';
|
|
243
287
|
}
|
|
244
|
-
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.ignoreReason);
|
|
288
|
+
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.type, data.ignoreReason);
|
|
245
289
|
});
|
|
246
290
|
_this3.elementsInView.add(target);
|
|
247
291
|
} else {
|
|
@@ -104,7 +104,6 @@ export class VCObserver {
|
|
|
104
104
|
totalTime,
|
|
105
105
|
componentsLog,
|
|
106
106
|
viewport,
|
|
107
|
-
oldDomUpdatesEnabled,
|
|
108
107
|
devToolsEnabled,
|
|
109
108
|
ratios
|
|
110
109
|
} = rawData;
|
|
@@ -160,9 +159,8 @@ export class VCObserver {
|
|
|
160
159
|
const outOfBoundary = outOfBoundaryInfo ? {
|
|
161
160
|
[`${fullPrefix}vc:oob`]: outOfBoundaryInfo
|
|
162
161
|
} : {};
|
|
163
|
-
const oldDomUpdates = oldDomUpdatesEnabled ? {
|
|
164
|
-
|
|
165
|
-
} : {};
|
|
162
|
+
//const oldDomUpdates = oldDomUpdatesEnabled ? { [`${fullPrefix}vc:old:dom`]: ssrVC.VCBox } : {};
|
|
163
|
+
|
|
166
164
|
const stopTime = performance.now();
|
|
167
165
|
|
|
168
166
|
// exposing data to devtools
|
|
@@ -209,19 +207,21 @@ export class VCObserver {
|
|
|
209
207
|
[`${fullPrefix}vc:total`]: totalPainted,
|
|
210
208
|
[`${fullPrefix}vc:ratios`]: ratios,
|
|
211
209
|
...outOfBoundary,
|
|
212
|
-
[`${fullPrefix}vc:
|
|
213
|
-
|
|
210
|
+
[`${fullPrefix}vc:attrs`]: ssrVC.VC,
|
|
211
|
+
//...oldDomUpdates,
|
|
214
212
|
[`${fullPrefix}vc:ignored`]: this.getIgnoredElements(componentsLog)
|
|
215
213
|
};
|
|
216
214
|
});
|
|
217
|
-
_defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, ignoreReason) => {
|
|
215
|
+
_defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason) => {
|
|
218
216
|
this.measureStart();
|
|
219
217
|
if (this.abortReason.reason === null || this.abortReason.blocking === false) {
|
|
220
218
|
const time = Math.round(rawTime - this.startTime);
|
|
221
219
|
const mappedValues = this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
|
|
222
220
|
this.vcRatios[targetName] = this.getElementRatio(mappedValues);
|
|
223
|
-
this.applyChangesToHeatMap(mappedValues, time, this.heatmap);
|
|
224
221
|
if (!ignoreReason) {
|
|
222
|
+
this.applyChangesToHeatMap(mappedValues, time, this.heatmap);
|
|
223
|
+
}
|
|
224
|
+
if (!ignoreReason && type !== 'attr') {
|
|
225
225
|
this.applyChangesToHeatMap(mappedValues, time, this.ssrInclusiveHeatmap);
|
|
226
226
|
}
|
|
227
227
|
if (!this.componentsLog[time]) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const MEDIA_WRAPPER_TAG = 'data-media-vc-wrapper';
|
|
3
|
+
export const VcMediaWrapperProps = {
|
|
4
|
+
[MEDIA_WRAPPER_TAG]: true
|
|
5
|
+
};
|
|
6
|
+
export default function MediaWrapper({
|
|
7
|
+
children
|
|
8
|
+
}) {
|
|
9
|
+
return /*#__PURE__*/React.createElement("div", VcMediaWrapperProps, children);
|
|
10
|
+
}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const MEDIA_WRAPPER_TAG = 'data-media-vc-wrapper';
|
|
3
|
-
export default function MediaWrapper({
|
|
4
|
-
children
|
|
5
|
-
}) {
|
|
6
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
7
|
-
[MEDIA_WRAPPER_TAG]: true
|
|
8
|
-
}, children);
|
|
9
|
-
}
|
|
1
|
+
export { default, MEDIA_WRAPPER_TAG, VcMediaWrapperProps } from './MediaWrapper';
|
|
@@ -29,12 +29,13 @@ export class Observers {
|
|
|
29
29
|
_defineProperty(this, "subscribeResults", cb => {
|
|
30
30
|
this.callbacks.add(cb);
|
|
31
31
|
});
|
|
32
|
-
_defineProperty(this, "observeElement", (node, mutation,
|
|
32
|
+
_defineProperty(this, "observeElement", (node, mutation, type, ignoreReason) => {
|
|
33
33
|
var _this$intersectionObs;
|
|
34
34
|
(_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.observe(node);
|
|
35
35
|
this.observedMutations.set(node, {
|
|
36
36
|
mutation,
|
|
37
|
-
ignoreReason
|
|
37
|
+
ignoreReason,
|
|
38
|
+
type
|
|
38
39
|
});
|
|
39
40
|
});
|
|
40
41
|
this.selectorConfig = {
|
|
@@ -148,16 +149,39 @@ export class Observers {
|
|
|
148
149
|
}
|
|
149
150
|
});
|
|
150
151
|
} else if (mutation.type === 'attributes') {
|
|
151
|
-
mutation.
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
if (mutation.target instanceof HTMLElement) {
|
|
153
|
+
// Commenting the following line temporarily.
|
|
154
|
+
// this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
155
|
+
|
|
156
|
+
// using the if below to collect data
|
|
157
|
+
// how would VC90 changes if only style display changes are accounted for
|
|
158
|
+
if (mutation.attributeName === 'style' && this.getStyleDisplay(mutation.target.getAttribute('style')) !== this.getStyleDisplay(mutation.oldValue)) {
|
|
159
|
+
this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
154
160
|
}
|
|
155
|
-
}
|
|
161
|
+
}
|
|
156
162
|
}
|
|
157
163
|
});
|
|
158
164
|
this.measureStop();
|
|
159
165
|
}) : null;
|
|
160
166
|
}
|
|
167
|
+
getStyleDisplay(styleAttributeValue) {
|
|
168
|
+
if (!styleAttributeValue) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Split the style string into individual declarations
|
|
173
|
+
const declarations = styleAttributeValue.split(';');
|
|
174
|
+
// Iterate over each declaration
|
|
175
|
+
for (const declaration of declarations) {
|
|
176
|
+
// Trim whitespace and split into property and value
|
|
177
|
+
const [property, value] = declaration.split(':').map(part => part.trim());
|
|
178
|
+
// Check if the property is 'display'
|
|
179
|
+
if (property && property.toLowerCase() === 'display') {
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
161
185
|
getElementName(element) {
|
|
162
186
|
try {
|
|
163
187
|
const tagName = element.localName;
|
|
@@ -208,7 +232,7 @@ export class Observers {
|
|
|
208
232
|
} catch (e) {
|
|
209
233
|
elementName = 'error';
|
|
210
234
|
}
|
|
211
|
-
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.ignoreReason);
|
|
235
|
+
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.type, data.ignoreReason);
|
|
212
236
|
});
|
|
213
237
|
this.elementsInView.add(target);
|
|
214
238
|
} else {
|
|
@@ -87,7 +87,7 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
87
87
|
};
|
|
88
88
|
});
|
|
89
89
|
_defineProperty(this, "getVCResult", function (_ref3) {
|
|
90
|
-
var _objectSpread2;
|
|
90
|
+
var _objectSpread2, _objectSpread3;
|
|
91
91
|
var start = _ref3.start,
|
|
92
92
|
stop = _ref3.stop,
|
|
93
93
|
tti = _ref3.tti,
|
|
@@ -109,7 +109,6 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
109
109
|
totalTime = rawData.totalTime,
|
|
110
110
|
componentsLog = rawData.componentsLog,
|
|
111
111
|
viewport = rawData.viewport,
|
|
112
|
-
oldDomUpdatesEnabled = rawData.oldDomUpdatesEnabled,
|
|
113
112
|
devToolsEnabled = rawData.devToolsEnabled,
|
|
114
113
|
ratios = rawData.ratios;
|
|
115
114
|
if (abortReasonInfo !== null && abortReason.blocking) {
|
|
@@ -154,7 +153,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
154
153
|
viewport: viewport
|
|
155
154
|
});
|
|
156
155
|
var outOfBoundary = outOfBoundaryInfo ? _defineProperty({}, "".concat(fullPrefix, "vc:oob"), outOfBoundaryInfo) : {};
|
|
157
|
-
|
|
156
|
+
//const oldDomUpdates = oldDomUpdatesEnabled ? { [`${fullPrefix}vc:old:dom`]: ssrVC.VCBox } : {};
|
|
157
|
+
|
|
158
158
|
var stopTime = performance.now();
|
|
159
159
|
|
|
160
160
|
// exposing data to devtools
|
|
@@ -189,18 +189,20 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
189
189
|
} catch (e) {
|
|
190
190
|
/* do nothing */
|
|
191
191
|
}
|
|
192
|
-
return _objectSpread(_objectSpread(
|
|
192
|
+
return _objectSpread(_objectSpread((_objectSpread2 = {
|
|
193
193
|
'metrics:vc': VC
|
|
194
|
-
}, _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:state"), true), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:dom"), VCBox), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:updates"), VCEntries.rel.slice(0, 50)), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:size"), viewport), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:total"), totalPainted), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:ratios"), ratios), _objectSpread2), outOfBoundary), {},
|
|
194
|
+
}, _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:state"), true), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:dom"), VCBox), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:updates"), VCEntries.rel.slice(0, 50)), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:size"), viewport), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:total"), totalPainted), _defineProperty(_objectSpread2, "".concat(fullPrefix, "vc:ratios"), ratios), _objectSpread2), outOfBoundary), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, "".concat(fullPrefix, "vc:attrs"), ssrVC.VC), _defineProperty(_objectSpread3, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), _objectSpread3));
|
|
195
195
|
});
|
|
196
|
-
_defineProperty(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, ignoreReason) {
|
|
196
|
+
_defineProperty(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
|
|
197
197
|
_this.measureStart();
|
|
198
198
|
if (_this.abortReason.reason === null || _this.abortReason.blocking === false) {
|
|
199
199
|
var time = Math.round(rawTime - _this.startTime);
|
|
200
200
|
var mappedValues = _this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
|
|
201
201
|
_this.vcRatios[targetName] = _this.getElementRatio(mappedValues);
|
|
202
|
-
_this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
|
|
203
202
|
if (!ignoreReason) {
|
|
203
|
+
_this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
|
|
204
|
+
}
|
|
205
|
+
if (!ignoreReason && type !== 'attr') {
|
|
204
206
|
_this.applyChangesToHeatMap(mappedValues, time, _this.ssrInclusiveHeatmap);
|
|
205
207
|
}
|
|
206
208
|
if (!_this.componentsLog[time]) {
|
|
@@ -272,10 +274,10 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
272
274
|
var unbinds = attachAbortListeners(window, _this.viewport, _this.abortReasonCallback);
|
|
273
275
|
if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
|
|
274
276
|
var _window2;
|
|
275
|
-
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (
|
|
276
|
-
var
|
|
277
|
-
key =
|
|
278
|
-
time =
|
|
277
|
+
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref6) {
|
|
278
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
279
|
+
key = _ref7[0],
|
|
280
|
+
time = _ref7[1];
|
|
279
281
|
if (time) {
|
|
280
282
|
_this.abortReasonCallback(key, time);
|
|
281
283
|
}
|
|
@@ -303,8 +305,8 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
303
305
|
}
|
|
304
306
|
_createClass(VCObserver, [{
|
|
305
307
|
key: "start",
|
|
306
|
-
value: function start(
|
|
307
|
-
var startTime =
|
|
308
|
+
value: function start(_ref8) {
|
|
309
|
+
var startTime = _ref8.startTime;
|
|
308
310
|
this.active = true;
|
|
309
311
|
if (this.observers.isBrowserSupported()) {
|
|
310
312
|
this.setViewportSize();
|
|
@@ -326,12 +328,12 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
326
328
|
}, {
|
|
327
329
|
key: "getIgnoredElements",
|
|
328
330
|
value: function getIgnoredElements(componentsLog) {
|
|
329
|
-
return Object.values(componentsLog).flat().filter(function (
|
|
330
|
-
var ignoreReason =
|
|
331
|
+
return Object.values(componentsLog).flat().filter(function (_ref9) {
|
|
332
|
+
var ignoreReason = _ref9.ignoreReason;
|
|
331
333
|
return Boolean(ignoreReason);
|
|
332
|
-
}).map(function (
|
|
333
|
-
var targetName =
|
|
334
|
-
ignoreReason =
|
|
334
|
+
}).map(function (_ref10) {
|
|
335
|
+
var targetName = _ref10.targetName,
|
|
336
|
+
ignoreReason = _ref10.ignoreReason;
|
|
335
337
|
return {
|
|
336
338
|
targetName: targetName,
|
|
337
339
|
ignoreReason: ignoreReason
|
|
@@ -446,12 +448,12 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
446
448
|
}
|
|
447
449
|
}], [{
|
|
448
450
|
key: "calculateVC",
|
|
449
|
-
value: function calculateVC(
|
|
450
|
-
var heatmap =
|
|
451
|
-
|
|
452
|
-
ssr =
|
|
453
|
-
componentsLog =
|
|
454
|
-
viewport =
|
|
451
|
+
value: function calculateVC(_ref11) {
|
|
452
|
+
var heatmap = _ref11.heatmap,
|
|
453
|
+
_ref11$ssr = _ref11.ssr,
|
|
454
|
+
ssr = _ref11$ssr === void 0 ? UNUSED_SECTOR : _ref11$ssr,
|
|
455
|
+
componentsLog = _ref11.componentsLog,
|
|
456
|
+
viewport = _ref11.viewport;
|
|
455
457
|
var lastUpdate = {};
|
|
456
458
|
var totalPainted = 0;
|
|
457
459
|
if (ssr !== UNUSED_SECTOR) {
|
|
@@ -511,11 +513,11 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
511
513
|
});
|
|
512
514
|
return VCRatio;
|
|
513
515
|
}, 0);
|
|
514
|
-
var VCEntries = entries.reduce(function (acc,
|
|
516
|
+
var VCEntries = entries.reduce(function (acc, _ref12, i) {
|
|
515
517
|
var _acc$abs, _componentsLog$timest;
|
|
516
|
-
var
|
|
517
|
-
timestamp =
|
|
518
|
-
entryPainted =
|
|
518
|
+
var _ref13 = _slicedToArray(_ref12, 2),
|
|
519
|
+
timestamp = _ref13[0],
|
|
520
|
+
entryPainted = _ref13[1];
|
|
519
521
|
var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
|
|
520
522
|
var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
|
|
521
523
|
var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export var MEDIA_WRAPPER_TAG = 'data-media-vc-wrapper';
|
|
4
|
+
export var VcMediaWrapperProps = _defineProperty({}, MEDIA_WRAPPER_TAG, true);
|
|
5
|
+
export default function MediaWrapper(_ref) {
|
|
6
|
+
var children = _ref.children;
|
|
7
|
+
return /*#__PURE__*/React.createElement("div", VcMediaWrapperProps, children);
|
|
8
|
+
}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export var MEDIA_WRAPPER_TAG = 'data-media-vc-wrapper';
|
|
4
|
-
export default function MediaWrapper(_ref) {
|
|
5
|
-
var children = _ref.children;
|
|
6
|
-
return /*#__PURE__*/React.createElement("div", _defineProperty({}, MEDIA_WRAPPER_TAG, true), children);
|
|
7
|
-
}
|
|
1
|
+
export { default, MEDIA_WRAPPER_TAG, VcMediaWrapperProps } from './MediaWrapper';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
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; } } }; }
|
|
6
|
+
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; } }
|
|
7
|
+
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
8
|
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; }
|
|
5
9
|
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; }
|
|
6
10
|
import { isContainedWithinMediaWrapper } from '../media-wrapper/vc-utils';
|
|
@@ -35,12 +39,13 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
35
39
|
_defineProperty(this, "subscribeResults", function (cb) {
|
|
36
40
|
_this.callbacks.add(cb);
|
|
37
41
|
});
|
|
38
|
-
_defineProperty(this, "observeElement", function (node, mutation,
|
|
42
|
+
_defineProperty(this, "observeElement", function (node, mutation, type, ignoreReason) {
|
|
39
43
|
var _this$intersectionObs;
|
|
40
44
|
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.observe(node);
|
|
41
45
|
_this.observedMutations.set(node, {
|
|
42
46
|
mutation: mutation,
|
|
43
|
-
ignoreReason: ignoreReason
|
|
47
|
+
ignoreReason: ignoreReason,
|
|
48
|
+
type: type
|
|
44
49
|
});
|
|
45
50
|
});
|
|
46
51
|
this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
|
|
@@ -170,16 +175,55 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
170
175
|
}
|
|
171
176
|
});
|
|
172
177
|
} else if (mutation.type === 'attributes') {
|
|
173
|
-
mutation.
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
if (mutation.target instanceof HTMLElement) {
|
|
179
|
+
// Commenting the following line temporarily.
|
|
180
|
+
// this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
181
|
+
|
|
182
|
+
// using the if below to collect data
|
|
183
|
+
// how would VC90 changes if only style display changes are accounted for
|
|
184
|
+
if (mutation.attributeName === 'style' && _this2.getStyleDisplay(mutation.target.getAttribute('style')) !== _this2.getStyleDisplay(mutation.oldValue)) {
|
|
185
|
+
_this2.observeElement(mutation.target, mutation, 'attr', ignoreReason);
|
|
176
186
|
}
|
|
177
|
-
}
|
|
187
|
+
}
|
|
178
188
|
}
|
|
179
189
|
});
|
|
180
190
|
_this2.measureStop();
|
|
181
191
|
}) : null;
|
|
182
192
|
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getStyleDisplay",
|
|
195
|
+
value: function getStyleDisplay(styleAttributeValue) {
|
|
196
|
+
if (!styleAttributeValue) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Split the style string into individual declarations
|
|
201
|
+
var declarations = styleAttributeValue.split(';');
|
|
202
|
+
// Iterate over each declaration
|
|
203
|
+
var _iterator = _createForOfIteratorHelper(declarations),
|
|
204
|
+
_step;
|
|
205
|
+
try {
|
|
206
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
207
|
+
var declaration = _step.value;
|
|
208
|
+
// Trim whitespace and split into property and value
|
|
209
|
+
var _declaration$split$ma = declaration.split(':').map(function (part) {
|
|
210
|
+
return part.trim();
|
|
211
|
+
}),
|
|
212
|
+
_declaration$split$ma2 = _slicedToArray(_declaration$split$ma, 2),
|
|
213
|
+
property = _declaration$split$ma2[0],
|
|
214
|
+
value = _declaration$split$ma2[1];
|
|
215
|
+
// Check if the property is 'display'
|
|
216
|
+
if (property && property.toLowerCase() === 'display') {
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch (err) {
|
|
221
|
+
_iterator.e(err);
|
|
222
|
+
} finally {
|
|
223
|
+
_iterator.f();
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
183
227
|
}, {
|
|
184
228
|
key: "getElementName",
|
|
185
229
|
value: function getElementName(element) {
|
|
@@ -234,7 +278,7 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
234
278
|
} catch (e) {
|
|
235
279
|
elementName = 'error';
|
|
236
280
|
}
|
|
237
|
-
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.ignoreReason);
|
|
281
|
+
callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.type, data.ignoreReason);
|
|
238
282
|
});
|
|
239
283
|
_this3.elementsInView.add(target);
|
|
240
284
|
} else {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
export declare const MEDIA_WRAPPER_TAG = "data-media-vc-wrapper";
|
|
6
|
+
export declare const VcMediaWrapperProps: {
|
|
7
|
+
"data-media-vc-wrapper": boolean;
|
|
8
|
+
};
|
|
9
|
+
export default function MediaWrapper({ children }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type Props = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
};
|
|
5
|
-
export declare const MEDIA_WRAPPER_TAG = "data-media-vc-wrapper";
|
|
6
|
-
export default function MediaWrapper({ children }: Props): JSX.Element;
|
|
7
|
-
export {};
|
|
1
|
+
export { default, MEDIA_WRAPPER_TAG, VcMediaWrapperProps } from './MediaWrapper';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BrowserObservers, Callback } from './types';
|
|
2
|
+
export type { ObservedMutationType } from './types';
|
|
2
3
|
export type SelectorConfig = {
|
|
3
4
|
id: boolean;
|
|
4
5
|
testId: boolean;
|
|
@@ -31,9 +32,9 @@ export declare class Observers implements BrowserObservers {
|
|
|
31
32
|
setReactRootRenderStop(stopTime?: number): void;
|
|
32
33
|
private observeElement;
|
|
33
34
|
private getMutationObserver;
|
|
35
|
+
private getStyleDisplay;
|
|
34
36
|
private getElementName;
|
|
35
37
|
private getIntersectionObserver;
|
|
36
38
|
private measureStart;
|
|
37
39
|
private measureStop;
|
|
38
40
|
}
|
|
39
|
-
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type VCIgnoreReason } from '../../../common/vc/types';
|
|
2
|
-
export type
|
|
2
|
+
export type ObservedMutationType = 'html' | 'attr' | 'text';
|
|
3
|
+
export type Callback = (time: number, box: DOMRectReadOnly, targetName: string, node: HTMLElement, type: ObservedMutationType, ignoreReason?: VCIgnoreReason) => void;
|
|
3
4
|
export type MutationRecordWithTimestamp = MutationRecord & {
|
|
4
5
|
timestamp?: number;
|
|
5
6
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
export declare const MEDIA_WRAPPER_TAG = "data-media-vc-wrapper";
|
|
6
|
+
export declare const VcMediaWrapperProps: {
|
|
7
|
+
"data-media-vc-wrapper": boolean;
|
|
8
|
+
};
|
|
9
|
+
export default function MediaWrapper({ children }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type Props = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
};
|
|
5
|
-
export declare const MEDIA_WRAPPER_TAG = "data-media-vc-wrapper";
|
|
6
|
-
export default function MediaWrapper({ children }: Props): JSX.Element;
|
|
7
|
-
export {};
|
|
1
|
+
export { default, MEDIA_WRAPPER_TAG, VcMediaWrapperProps } from './MediaWrapper';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BrowserObservers, Callback } from './types';
|
|
2
|
+
export type { ObservedMutationType } from './types';
|
|
2
3
|
export type SelectorConfig = {
|
|
3
4
|
id: boolean;
|
|
4
5
|
testId: boolean;
|
|
@@ -31,9 +32,9 @@ export declare class Observers implements BrowserObservers {
|
|
|
31
32
|
setReactRootRenderStop(stopTime?: number): void;
|
|
32
33
|
private observeElement;
|
|
33
34
|
private getMutationObserver;
|
|
35
|
+
private getStyleDisplay;
|
|
34
36
|
private getElementName;
|
|
35
37
|
private getIntersectionObserver;
|
|
36
38
|
private measureStart;
|
|
37
39
|
private measureStop;
|
|
38
40
|
}
|
|
39
|
-
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type VCIgnoreReason } from '../../../common/vc/types';
|
|
2
|
-
export type
|
|
2
|
+
export type ObservedMutationType = 'html' | 'attr' | 'text';
|
|
3
|
+
export type Callback = (time: number, box: DOMRectReadOnly, targetName: string, node: HTMLElement, type: ObservedMutationType, ignoreReason?: VCIgnoreReason) => void;
|
|
3
4
|
export type MutationRecordWithTimestamp = MutationRecord & {
|
|
4
5
|
timestamp?: number;
|
|
5
6
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"./typing-performance-tracing": "./src/typing-performance-tracing/index.ts",
|
|
70
70
|
"./use-press-tracing": "./src/use-press-tracing/index.ts",
|
|
71
71
|
"./vc": "./src/vc/index.ts",
|
|
72
|
-
"./vc
|
|
72
|
+
"./vc-media": "./src/vc/vc-observer/media-wrapper/index.ts",
|
|
73
73
|
".": "./src/index.ts"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/react-ufo/vc-media",
|
|
3
|
+
"main": "../dist/cjs/vc/vc-observer/media-wrapper/index.js",
|
|
4
|
+
"module": "../dist/esm/vc/vc-observer/media-wrapper/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/vc/vc-observer/media-wrapper/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/vc/vc-observer/media-wrapper/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.4": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/vc/media/package.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/react-ufo/vc/media",
|
|
3
|
-
"main": "../../dist/cjs/vc/vc-observer/media-wrapper/index.js",
|
|
4
|
-
"module": "../../dist/esm/vc/vc-observer/media-wrapper/index.js",
|
|
5
|
-
"module:es2019": "../../dist/es2019/vc/vc-observer/media-wrapper/index.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../../dist/types/vc/vc-observer/media-wrapper/index.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../../dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|