oss-web-common 0.2.39 → 0.2.40-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/build/index.cjs.js +29766 -23682
  2. package/build/index.esm.js +905 -904
  3. package/build/index.js +48527 -41527
  4. package/package.json +146 -148
@@ -37909,931 +37909,931 @@ function stubFalse() {
37909
37909
  module.exports = isEqual;
37910
37910
  });
37911
37911
 
37912
- /**
37913
- * A collection of shims that provide minimal functionality of the ES6 collections.
37914
- *
37915
- * These implementations are not meant to be used outside of the ResizeObserver
37916
- * modules as they cover only a limited range of use cases.
37917
- */
37918
- /* eslint-disable require-jsdoc, valid-jsdoc */
37919
- var MapShim = (function () {
37920
- if (typeof Map !== 'undefined') {
37921
- return Map;
37922
- }
37923
- /**
37924
- * Returns index in provided array that matches the specified key.
37925
- *
37926
- * @param {Array<Array>} arr
37927
- * @param {*} key
37928
- * @returns {number}
37929
- */
37930
- function getIndex(arr, key) {
37931
- var result = -1;
37932
- arr.some(function (entry, index) {
37933
- if (entry[0] === key) {
37934
- result = index;
37935
- return true;
37936
- }
37937
- return false;
37938
- });
37939
- return result;
37940
- }
37941
- return /** @class */ (function () {
37942
- function class_1() {
37943
- this.__entries__ = [];
37944
- }
37945
- Object.defineProperty(class_1.prototype, "size", {
37946
- /**
37947
- * @returns {boolean}
37948
- */
37949
- get: function () {
37950
- return this.__entries__.length;
37951
- },
37952
- enumerable: true,
37953
- configurable: true
37954
- });
37955
- /**
37956
- * @param {*} key
37957
- * @returns {*}
37958
- */
37959
- class_1.prototype.get = function (key) {
37960
- var index = getIndex(this.__entries__, key);
37961
- var entry = this.__entries__[index];
37962
- return entry && entry[1];
37963
- };
37964
- /**
37965
- * @param {*} key
37966
- * @param {*} value
37967
- * @returns {void}
37968
- */
37969
- class_1.prototype.set = function (key, value) {
37970
- var index = getIndex(this.__entries__, key);
37971
- if (~index) {
37972
- this.__entries__[index][1] = value;
37973
- }
37974
- else {
37975
- this.__entries__.push([key, value]);
37976
- }
37977
- };
37978
- /**
37979
- * @param {*} key
37980
- * @returns {void}
37981
- */
37982
- class_1.prototype.delete = function (key) {
37983
- var entries = this.__entries__;
37984
- var index = getIndex(entries, key);
37985
- if (~index) {
37986
- entries.splice(index, 1);
37987
- }
37988
- };
37989
- /**
37990
- * @param {*} key
37991
- * @returns {void}
37992
- */
37993
- class_1.prototype.has = function (key) {
37994
- return !!~getIndex(this.__entries__, key);
37995
- };
37996
- /**
37997
- * @returns {void}
37998
- */
37999
- class_1.prototype.clear = function () {
38000
- this.__entries__.splice(0);
38001
- };
38002
- /**
38003
- * @param {Function} callback
38004
- * @param {*} [ctx=null]
38005
- * @returns {void}
38006
- */
38007
- class_1.prototype.forEach = function (callback, ctx) {
38008
- if (ctx === void 0) { ctx = null; }
38009
- for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
38010
- var entry = _a[_i];
38011
- callback.call(ctx, entry[1], entry[0]);
38012
- }
38013
- };
38014
- return class_1;
38015
- }());
37912
+ /**
37913
+ * A collection of shims that provide minimal functionality of the ES6 collections.
37914
+ *
37915
+ * These implementations are not meant to be used outside of the ResizeObserver
37916
+ * modules as they cover only a limited range of use cases.
37917
+ */
37918
+ /* eslint-disable require-jsdoc, valid-jsdoc */
37919
+ var MapShim = (function () {
37920
+ if (typeof Map !== 'undefined') {
37921
+ return Map;
37922
+ }
37923
+ /**
37924
+ * Returns index in provided array that matches the specified key.
37925
+ *
37926
+ * @param {Array<Array>} arr
37927
+ * @param {*} key
37928
+ * @returns {number}
37929
+ */
37930
+ function getIndex(arr, key) {
37931
+ var result = -1;
37932
+ arr.some(function (entry, index) {
37933
+ if (entry[0] === key) {
37934
+ result = index;
37935
+ return true;
37936
+ }
37937
+ return false;
37938
+ });
37939
+ return result;
37940
+ }
37941
+ return /** @class */ (function () {
37942
+ function class_1() {
37943
+ this.__entries__ = [];
37944
+ }
37945
+ Object.defineProperty(class_1.prototype, "size", {
37946
+ /**
37947
+ * @returns {boolean}
37948
+ */
37949
+ get: function () {
37950
+ return this.__entries__.length;
37951
+ },
37952
+ enumerable: true,
37953
+ configurable: true
37954
+ });
37955
+ /**
37956
+ * @param {*} key
37957
+ * @returns {*}
37958
+ */
37959
+ class_1.prototype.get = function (key) {
37960
+ var index = getIndex(this.__entries__, key);
37961
+ var entry = this.__entries__[index];
37962
+ return entry && entry[1];
37963
+ };
37964
+ /**
37965
+ * @param {*} key
37966
+ * @param {*} value
37967
+ * @returns {void}
37968
+ */
37969
+ class_1.prototype.set = function (key, value) {
37970
+ var index = getIndex(this.__entries__, key);
37971
+ if (~index) {
37972
+ this.__entries__[index][1] = value;
37973
+ }
37974
+ else {
37975
+ this.__entries__.push([key, value]);
37976
+ }
37977
+ };
37978
+ /**
37979
+ * @param {*} key
37980
+ * @returns {void}
37981
+ */
37982
+ class_1.prototype.delete = function (key) {
37983
+ var entries = this.__entries__;
37984
+ var index = getIndex(entries, key);
37985
+ if (~index) {
37986
+ entries.splice(index, 1);
37987
+ }
37988
+ };
37989
+ /**
37990
+ * @param {*} key
37991
+ * @returns {void}
37992
+ */
37993
+ class_1.prototype.has = function (key) {
37994
+ return !!~getIndex(this.__entries__, key);
37995
+ };
37996
+ /**
37997
+ * @returns {void}
37998
+ */
37999
+ class_1.prototype.clear = function () {
38000
+ this.__entries__.splice(0);
38001
+ };
38002
+ /**
38003
+ * @param {Function} callback
38004
+ * @param {*} [ctx=null]
38005
+ * @returns {void}
38006
+ */
38007
+ class_1.prototype.forEach = function (callback, ctx) {
38008
+ if (ctx === void 0) { ctx = null; }
38009
+ for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
38010
+ var entry = _a[_i];
38011
+ callback.call(ctx, entry[1], entry[0]);
38012
+ }
38013
+ };
38014
+ return class_1;
38015
+ }());
38016
38016
  })();
38017
38017
 
38018
- /**
38019
- * Detects whether window and document objects are available in current environment.
38020
- */
38018
+ /**
38019
+ * Detects whether window and document objects are available in current environment.
38020
+ */
38021
38021
  var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
38022
38022
 
38023
- // Returns global object of a current environment.
38024
- var global$1 = (function () {
38025
- if (typeof global !== 'undefined' && global.Math === Math) {
38026
- return global;
38027
- }
38028
- if (typeof self !== 'undefined' && self.Math === Math) {
38029
- return self;
38030
- }
38031
- if (typeof window !== 'undefined' && window.Math === Math) {
38032
- return window;
38033
- }
38034
- // eslint-disable-next-line no-new-func
38035
- return Function('return this')();
38023
+ // Returns global object of a current environment.
38024
+ var global$1 = (function () {
38025
+ if (typeof global !== 'undefined' && global.Math === Math) {
38026
+ return global;
38027
+ }
38028
+ if (typeof self !== 'undefined' && self.Math === Math) {
38029
+ return self;
38030
+ }
38031
+ if (typeof window !== 'undefined' && window.Math === Math) {
38032
+ return window;
38033
+ }
38034
+ // eslint-disable-next-line no-new-func
38035
+ return Function('return this')();
38036
38036
  })();
38037
38037
 
38038
- /**
38039
- * A shim for the requestAnimationFrame which falls back to the setTimeout if
38040
- * first one is not supported.
38041
- *
38042
- * @returns {number} Requests' identifier.
38043
- */
38044
- var requestAnimationFrame$1 = (function () {
38045
- if (typeof requestAnimationFrame === 'function') {
38046
- // It's required to use a bounded function because IE sometimes throws
38047
- // an "Invalid calling object" error if rAF is invoked without the global
38048
- // object on the left hand side.
38049
- return requestAnimationFrame.bind(global$1);
38050
- }
38051
- return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
38038
+ /**
38039
+ * A shim for the requestAnimationFrame which falls back to the setTimeout if
38040
+ * first one is not supported.
38041
+ *
38042
+ * @returns {number} Requests' identifier.
38043
+ */
38044
+ var requestAnimationFrame$1 = (function () {
38045
+ if (typeof requestAnimationFrame === 'function') {
38046
+ // It's required to use a bounded function because IE sometimes throws
38047
+ // an "Invalid calling object" error if rAF is invoked without the global
38048
+ // object on the left hand side.
38049
+ return requestAnimationFrame.bind(global$1);
38050
+ }
38051
+ return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
38052
38052
  })();
38053
38053
 
38054
- // Defines minimum timeout before adding a trailing call.
38055
- var trailingTimeout = 2;
38056
- /**
38057
- * Creates a wrapper function which ensures that provided callback will be
38058
- * invoked only once during the specified delay period.
38059
- *
38060
- * @param {Function} callback - Function to be invoked after the delay period.
38061
- * @param {number} delay - Delay after which to invoke callback.
38062
- * @returns {Function}
38063
- */
38064
- function throttle (callback, delay) {
38065
- var leadingCall = false, trailingCall = false, lastCallTime = 0;
38066
- /**
38067
- * Invokes the original callback function and schedules new invocation if
38068
- * the "proxy" was called during current request.
38069
- *
38070
- * @returns {void}
38071
- */
38072
- function resolvePending() {
38073
- if (leadingCall) {
38074
- leadingCall = false;
38075
- callback();
38076
- }
38077
- if (trailingCall) {
38078
- proxy();
38079
- }
38080
- }
38081
- /**
38082
- * Callback invoked after the specified delay. It will further postpone
38083
- * invocation of the original function delegating it to the
38084
- * requestAnimationFrame.
38085
- *
38086
- * @returns {void}
38087
- */
38088
- function timeoutCallback() {
38089
- requestAnimationFrame$1(resolvePending);
38090
- }
38091
- /**
38092
- * Schedules invocation of the original function.
38093
- *
38094
- * @returns {void}
38095
- */
38096
- function proxy() {
38097
- var timeStamp = Date.now();
38098
- if (leadingCall) {
38099
- // Reject immediately following calls.
38100
- if (timeStamp - lastCallTime < trailingTimeout) {
38101
- return;
38102
- }
38103
- // Schedule new call to be in invoked when the pending one is resolved.
38104
- // This is important for "transitions" which never actually start
38105
- // immediately so there is a chance that we might miss one if change
38106
- // happens amids the pending invocation.
38107
- trailingCall = true;
38108
- }
38109
- else {
38110
- leadingCall = true;
38111
- trailingCall = false;
38112
- setTimeout(timeoutCallback, delay);
38113
- }
38114
- lastCallTime = timeStamp;
38115
- }
38116
- return proxy;
38117
- }
38118
-
38119
- // Minimum delay before invoking the update of observers.
38120
- var REFRESH_DELAY = 20;
38121
- // A list of substrings of CSS properties used to find transition events that
38122
- // might affect dimensions of observed elements.
38123
- var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
38124
- // Check if MutationObserver is available.
38125
- var mutationObserverSupported = typeof MutationObserver !== 'undefined';
38126
- /**
38127
- * Singleton controller class which handles updates of ResizeObserver instances.
38128
- */
38129
- var ResizeObserverController = /** @class */ (function () {
38130
- /**
38131
- * Creates a new instance of ResizeObserverController.
38132
- *
38133
- * @private
38134
- */
38135
- function ResizeObserverController() {
38136
- /**
38137
- * Indicates whether DOM listeners have been added.
38138
- *
38139
- * @private {boolean}
38140
- */
38141
- this.connected_ = false;
38142
- /**
38143
- * Tells that controller has subscribed for Mutation Events.
38144
- *
38145
- * @private {boolean}
38146
- */
38147
- this.mutationEventsAdded_ = false;
38148
- /**
38149
- * Keeps reference to the instance of MutationObserver.
38150
- *
38151
- * @private {MutationObserver}
38152
- */
38153
- this.mutationsObserver_ = null;
38154
- /**
38155
- * A list of connected observers.
38156
- *
38157
- * @private {Array<ResizeObserverSPI>}
38158
- */
38159
- this.observers_ = [];
38160
- this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
38161
- this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
38162
- }
38163
- /**
38164
- * Adds observer to observers list.
38165
- *
38166
- * @param {ResizeObserverSPI} observer - Observer to be added.
38167
- * @returns {void}
38168
- */
38169
- ResizeObserverController.prototype.addObserver = function (observer) {
38170
- if (!~this.observers_.indexOf(observer)) {
38171
- this.observers_.push(observer);
38172
- }
38173
- // Add listeners if they haven't been added yet.
38174
- if (!this.connected_) {
38175
- this.connect_();
38176
- }
38177
- };
38178
- /**
38179
- * Removes observer from observers list.
38180
- *
38181
- * @param {ResizeObserverSPI} observer - Observer to be removed.
38182
- * @returns {void}
38183
- */
38184
- ResizeObserverController.prototype.removeObserver = function (observer) {
38185
- var observers = this.observers_;
38186
- var index = observers.indexOf(observer);
38187
- // Remove observer if it's present in registry.
38188
- if (~index) {
38189
- observers.splice(index, 1);
38190
- }
38191
- // Remove listeners if controller has no connected observers.
38192
- if (!observers.length && this.connected_) {
38193
- this.disconnect_();
38194
- }
38195
- };
38196
- /**
38197
- * Invokes the update of observers. It will continue running updates insofar
38198
- * it detects changes.
38199
- *
38200
- * @returns {void}
38201
- */
38202
- ResizeObserverController.prototype.refresh = function () {
38203
- var changesDetected = this.updateObservers_();
38204
- // Continue running updates if changes have been detected as there might
38205
- // be future ones caused by CSS transitions.
38206
- if (changesDetected) {
38207
- this.refresh();
38208
- }
38209
- };
38210
- /**
38211
- * Updates every observer from observers list and notifies them of queued
38212
- * entries.
38213
- *
38214
- * @private
38215
- * @returns {boolean} Returns "true" if any observer has detected changes in
38216
- * dimensions of it's elements.
38217
- */
38218
- ResizeObserverController.prototype.updateObservers_ = function () {
38219
- // Collect observers that have active observations.
38220
- var activeObservers = this.observers_.filter(function (observer) {
38221
- return observer.gatherActive(), observer.hasActive();
38222
- });
38223
- // Deliver notifications in a separate cycle in order to avoid any
38224
- // collisions between observers, e.g. when multiple instances of
38225
- // ResizeObserver are tracking the same element and the callback of one
38226
- // of them changes content dimensions of the observed target. Sometimes
38227
- // this may result in notifications being blocked for the rest of observers.
38228
- activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
38229
- return activeObservers.length > 0;
38230
- };
38231
- /**
38232
- * Initializes DOM listeners.
38233
- *
38234
- * @private
38235
- * @returns {void}
38236
- */
38237
- ResizeObserverController.prototype.connect_ = function () {
38238
- // Do nothing if running in a non-browser environment or if listeners
38239
- // have been already added.
38240
- if (!isBrowser || this.connected_) {
38241
- return;
38242
- }
38243
- // Subscription to the "Transitionend" event is used as a workaround for
38244
- // delayed transitions. This way it's possible to capture at least the
38245
- // final state of an element.
38246
- document.addEventListener('transitionend', this.onTransitionEnd_);
38247
- window.addEventListener('resize', this.refresh);
38248
- if (mutationObserverSupported) {
38249
- this.mutationsObserver_ = new MutationObserver(this.refresh);
38250
- this.mutationsObserver_.observe(document, {
38251
- attributes: true,
38252
- childList: true,
38253
- characterData: true,
38254
- subtree: true
38255
- });
38256
- }
38257
- else {
38258
- document.addEventListener('DOMSubtreeModified', this.refresh);
38259
- this.mutationEventsAdded_ = true;
38260
- }
38261
- this.connected_ = true;
38262
- };
38263
- /**
38264
- * Removes DOM listeners.
38265
- *
38266
- * @private
38267
- * @returns {void}
38268
- */
38269
- ResizeObserverController.prototype.disconnect_ = function () {
38270
- // Do nothing if running in a non-browser environment or if listeners
38271
- // have been already removed.
38272
- if (!isBrowser || !this.connected_) {
38273
- return;
38274
- }
38275
- document.removeEventListener('transitionend', this.onTransitionEnd_);
38276
- window.removeEventListener('resize', this.refresh);
38277
- if (this.mutationsObserver_) {
38278
- this.mutationsObserver_.disconnect();
38279
- }
38280
- if (this.mutationEventsAdded_) {
38281
- document.removeEventListener('DOMSubtreeModified', this.refresh);
38282
- }
38283
- this.mutationsObserver_ = null;
38284
- this.mutationEventsAdded_ = false;
38285
- this.connected_ = false;
38286
- };
38287
- /**
38288
- * "Transitionend" event handler.
38289
- *
38290
- * @private
38291
- * @param {TransitionEvent} event
38292
- * @returns {void}
38293
- */
38294
- ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
38295
- var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
38296
- // Detect whether transition may affect dimensions of an element.
38297
- var isReflowProperty = transitionKeys.some(function (key) {
38298
- return !!~propertyName.indexOf(key);
38299
- });
38300
- if (isReflowProperty) {
38301
- this.refresh();
38302
- }
38303
- };
38304
- /**
38305
- * Returns instance of the ResizeObserverController.
38306
- *
38307
- * @returns {ResizeObserverController}
38308
- */
38309
- ResizeObserverController.getInstance = function () {
38310
- if (!this.instance_) {
38311
- this.instance_ = new ResizeObserverController();
38312
- }
38313
- return this.instance_;
38314
- };
38315
- /**
38316
- * Holds reference to the controller's instance.
38317
- *
38318
- * @private {ResizeObserverController}
38319
- */
38320
- ResizeObserverController.instance_ = null;
38321
- return ResizeObserverController;
38054
+ // Defines minimum timeout before adding a trailing call.
38055
+ var trailingTimeout = 2;
38056
+ /**
38057
+ * Creates a wrapper function which ensures that provided callback will be
38058
+ * invoked only once during the specified delay period.
38059
+ *
38060
+ * @param {Function} callback - Function to be invoked after the delay period.
38061
+ * @param {number} delay - Delay after which to invoke callback.
38062
+ * @returns {Function}
38063
+ */
38064
+ function throttle (callback, delay) {
38065
+ var leadingCall = false, trailingCall = false, lastCallTime = 0;
38066
+ /**
38067
+ * Invokes the original callback function and schedules new invocation if
38068
+ * the "proxy" was called during current request.
38069
+ *
38070
+ * @returns {void}
38071
+ */
38072
+ function resolvePending() {
38073
+ if (leadingCall) {
38074
+ leadingCall = false;
38075
+ callback();
38076
+ }
38077
+ if (trailingCall) {
38078
+ proxy();
38079
+ }
38080
+ }
38081
+ /**
38082
+ * Callback invoked after the specified delay. It will further postpone
38083
+ * invocation of the original function delegating it to the
38084
+ * requestAnimationFrame.
38085
+ *
38086
+ * @returns {void}
38087
+ */
38088
+ function timeoutCallback() {
38089
+ requestAnimationFrame$1(resolvePending);
38090
+ }
38091
+ /**
38092
+ * Schedules invocation of the original function.
38093
+ *
38094
+ * @returns {void}
38095
+ */
38096
+ function proxy() {
38097
+ var timeStamp = Date.now();
38098
+ if (leadingCall) {
38099
+ // Reject immediately following calls.
38100
+ if (timeStamp - lastCallTime < trailingTimeout) {
38101
+ return;
38102
+ }
38103
+ // Schedule new call to be in invoked when the pending one is resolved.
38104
+ // This is important for "transitions" which never actually start
38105
+ // immediately so there is a chance that we might miss one if change
38106
+ // happens amids the pending invocation.
38107
+ trailingCall = true;
38108
+ }
38109
+ else {
38110
+ leadingCall = true;
38111
+ trailingCall = false;
38112
+ setTimeout(timeoutCallback, delay);
38113
+ }
38114
+ lastCallTime = timeStamp;
38115
+ }
38116
+ return proxy;
38117
+ }
38118
+
38119
+ // Minimum delay before invoking the update of observers.
38120
+ var REFRESH_DELAY = 20;
38121
+ // A list of substrings of CSS properties used to find transition events that
38122
+ // might affect dimensions of observed elements.
38123
+ var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
38124
+ // Check if MutationObserver is available.
38125
+ var mutationObserverSupported = typeof MutationObserver !== 'undefined';
38126
+ /**
38127
+ * Singleton controller class which handles updates of ResizeObserver instances.
38128
+ */
38129
+ var ResizeObserverController = /** @class */ (function () {
38130
+ /**
38131
+ * Creates a new instance of ResizeObserverController.
38132
+ *
38133
+ * @private
38134
+ */
38135
+ function ResizeObserverController() {
38136
+ /**
38137
+ * Indicates whether DOM listeners have been added.
38138
+ *
38139
+ * @private {boolean}
38140
+ */
38141
+ this.connected_ = false;
38142
+ /**
38143
+ * Tells that controller has subscribed for Mutation Events.
38144
+ *
38145
+ * @private {boolean}
38146
+ */
38147
+ this.mutationEventsAdded_ = false;
38148
+ /**
38149
+ * Keeps reference to the instance of MutationObserver.
38150
+ *
38151
+ * @private {MutationObserver}
38152
+ */
38153
+ this.mutationsObserver_ = null;
38154
+ /**
38155
+ * A list of connected observers.
38156
+ *
38157
+ * @private {Array<ResizeObserverSPI>}
38158
+ */
38159
+ this.observers_ = [];
38160
+ this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
38161
+ this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
38162
+ }
38163
+ /**
38164
+ * Adds observer to observers list.
38165
+ *
38166
+ * @param {ResizeObserverSPI} observer - Observer to be added.
38167
+ * @returns {void}
38168
+ */
38169
+ ResizeObserverController.prototype.addObserver = function (observer) {
38170
+ if (!~this.observers_.indexOf(observer)) {
38171
+ this.observers_.push(observer);
38172
+ }
38173
+ // Add listeners if they haven't been added yet.
38174
+ if (!this.connected_) {
38175
+ this.connect_();
38176
+ }
38177
+ };
38178
+ /**
38179
+ * Removes observer from observers list.
38180
+ *
38181
+ * @param {ResizeObserverSPI} observer - Observer to be removed.
38182
+ * @returns {void}
38183
+ */
38184
+ ResizeObserverController.prototype.removeObserver = function (observer) {
38185
+ var observers = this.observers_;
38186
+ var index = observers.indexOf(observer);
38187
+ // Remove observer if it's present in registry.
38188
+ if (~index) {
38189
+ observers.splice(index, 1);
38190
+ }
38191
+ // Remove listeners if controller has no connected observers.
38192
+ if (!observers.length && this.connected_) {
38193
+ this.disconnect_();
38194
+ }
38195
+ };
38196
+ /**
38197
+ * Invokes the update of observers. It will continue running updates insofar
38198
+ * it detects changes.
38199
+ *
38200
+ * @returns {void}
38201
+ */
38202
+ ResizeObserverController.prototype.refresh = function () {
38203
+ var changesDetected = this.updateObservers_();
38204
+ // Continue running updates if changes have been detected as there might
38205
+ // be future ones caused by CSS transitions.
38206
+ if (changesDetected) {
38207
+ this.refresh();
38208
+ }
38209
+ };
38210
+ /**
38211
+ * Updates every observer from observers list and notifies them of queued
38212
+ * entries.
38213
+ *
38214
+ * @private
38215
+ * @returns {boolean} Returns "true" if any observer has detected changes in
38216
+ * dimensions of it's elements.
38217
+ */
38218
+ ResizeObserverController.prototype.updateObservers_ = function () {
38219
+ // Collect observers that have active observations.
38220
+ var activeObservers = this.observers_.filter(function (observer) {
38221
+ return observer.gatherActive(), observer.hasActive();
38222
+ });
38223
+ // Deliver notifications in a separate cycle in order to avoid any
38224
+ // collisions between observers, e.g. when multiple instances of
38225
+ // ResizeObserver are tracking the same element and the callback of one
38226
+ // of them changes content dimensions of the observed target. Sometimes
38227
+ // this may result in notifications being blocked for the rest of observers.
38228
+ activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
38229
+ return activeObservers.length > 0;
38230
+ };
38231
+ /**
38232
+ * Initializes DOM listeners.
38233
+ *
38234
+ * @private
38235
+ * @returns {void}
38236
+ */
38237
+ ResizeObserverController.prototype.connect_ = function () {
38238
+ // Do nothing if running in a non-browser environment or if listeners
38239
+ // have been already added.
38240
+ if (!isBrowser || this.connected_) {
38241
+ return;
38242
+ }
38243
+ // Subscription to the "Transitionend" event is used as a workaround for
38244
+ // delayed transitions. This way it's possible to capture at least the
38245
+ // final state of an element.
38246
+ document.addEventListener('transitionend', this.onTransitionEnd_);
38247
+ window.addEventListener('resize', this.refresh);
38248
+ if (mutationObserverSupported) {
38249
+ this.mutationsObserver_ = new MutationObserver(this.refresh);
38250
+ this.mutationsObserver_.observe(document, {
38251
+ attributes: true,
38252
+ childList: true,
38253
+ characterData: true,
38254
+ subtree: true
38255
+ });
38256
+ }
38257
+ else {
38258
+ document.addEventListener('DOMSubtreeModified', this.refresh);
38259
+ this.mutationEventsAdded_ = true;
38260
+ }
38261
+ this.connected_ = true;
38262
+ };
38263
+ /**
38264
+ * Removes DOM listeners.
38265
+ *
38266
+ * @private
38267
+ * @returns {void}
38268
+ */
38269
+ ResizeObserverController.prototype.disconnect_ = function () {
38270
+ // Do nothing if running in a non-browser environment or if listeners
38271
+ // have been already removed.
38272
+ if (!isBrowser || !this.connected_) {
38273
+ return;
38274
+ }
38275
+ document.removeEventListener('transitionend', this.onTransitionEnd_);
38276
+ window.removeEventListener('resize', this.refresh);
38277
+ if (this.mutationsObserver_) {
38278
+ this.mutationsObserver_.disconnect();
38279
+ }
38280
+ if (this.mutationEventsAdded_) {
38281
+ document.removeEventListener('DOMSubtreeModified', this.refresh);
38282
+ }
38283
+ this.mutationsObserver_ = null;
38284
+ this.mutationEventsAdded_ = false;
38285
+ this.connected_ = false;
38286
+ };
38287
+ /**
38288
+ * "Transitionend" event handler.
38289
+ *
38290
+ * @private
38291
+ * @param {TransitionEvent} event
38292
+ * @returns {void}
38293
+ */
38294
+ ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
38295
+ var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
38296
+ // Detect whether transition may affect dimensions of an element.
38297
+ var isReflowProperty = transitionKeys.some(function (key) {
38298
+ return !!~propertyName.indexOf(key);
38299
+ });
38300
+ if (isReflowProperty) {
38301
+ this.refresh();
38302
+ }
38303
+ };
38304
+ /**
38305
+ * Returns instance of the ResizeObserverController.
38306
+ *
38307
+ * @returns {ResizeObserverController}
38308
+ */
38309
+ ResizeObserverController.getInstance = function () {
38310
+ if (!this.instance_) {
38311
+ this.instance_ = new ResizeObserverController();
38312
+ }
38313
+ return this.instance_;
38314
+ };
38315
+ /**
38316
+ * Holds reference to the controller's instance.
38317
+ *
38318
+ * @private {ResizeObserverController}
38319
+ */
38320
+ ResizeObserverController.instance_ = null;
38321
+ return ResizeObserverController;
38322
38322
  }());
38323
38323
 
38324
- /**
38325
- * Defines non-writable/enumerable properties of the provided target object.
38326
- *
38327
- * @param {Object} target - Object for which to define properties.
38328
- * @param {Object} props - Properties to be defined.
38329
- * @returns {Object} Target object.
38330
- */
38331
- var defineConfigurable = (function (target, props) {
38332
- for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
38333
- var key = _a[_i];
38334
- Object.defineProperty(target, key, {
38335
- value: props[key],
38336
- enumerable: false,
38337
- writable: false,
38338
- configurable: true
38339
- });
38340
- }
38341
- return target;
38324
+ /**
38325
+ * Defines non-writable/enumerable properties of the provided target object.
38326
+ *
38327
+ * @param {Object} target - Object for which to define properties.
38328
+ * @param {Object} props - Properties to be defined.
38329
+ * @returns {Object} Target object.
38330
+ */
38331
+ var defineConfigurable = (function (target, props) {
38332
+ for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
38333
+ var key = _a[_i];
38334
+ Object.defineProperty(target, key, {
38335
+ value: props[key],
38336
+ enumerable: false,
38337
+ writable: false,
38338
+ configurable: true
38339
+ });
38340
+ }
38341
+ return target;
38342
38342
  });
38343
38343
 
38344
- /**
38345
- * Returns the global object associated with provided element.
38346
- *
38347
- * @param {Object} target
38348
- * @returns {Object}
38349
- */
38350
- var getWindowOf = (function (target) {
38351
- // Assume that the element is an instance of Node, which means that it
38352
- // has the "ownerDocument" property from which we can retrieve a
38353
- // corresponding global object.
38354
- var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
38355
- // Return the local global object if it's not possible extract one from
38356
- // provided element.
38357
- return ownerGlobal || global$1;
38344
+ /**
38345
+ * Returns the global object associated with provided element.
38346
+ *
38347
+ * @param {Object} target
38348
+ * @returns {Object}
38349
+ */
38350
+ var getWindowOf = (function (target) {
38351
+ // Assume that the element is an instance of Node, which means that it
38352
+ // has the "ownerDocument" property from which we can retrieve a
38353
+ // corresponding global object.
38354
+ var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
38355
+ // Return the local global object if it's not possible extract one from
38356
+ // provided element.
38357
+ return ownerGlobal || global$1;
38358
38358
  });
38359
38359
 
38360
- // Placeholder of an empty content rectangle.
38361
- var emptyRect = createRectInit(0, 0, 0, 0);
38362
- /**
38363
- * Converts provided string to a number.
38364
- *
38365
- * @param {number|string} value
38366
- * @returns {number}
38367
- */
38368
- function toFloat(value) {
38369
- return parseFloat(value) || 0;
38370
- }
38371
- /**
38372
- * Extracts borders size from provided styles.
38373
- *
38374
- * @param {CSSStyleDeclaration} styles
38375
- * @param {...string} positions - Borders positions (top, right, ...)
38376
- * @returns {number}
38377
- */
38378
- function getBordersSize(styles) {
38379
- var positions = [];
38380
- for (var _i = 1; _i < arguments.length; _i++) {
38381
- positions[_i - 1] = arguments[_i];
38382
- }
38383
- return positions.reduce(function (size, position) {
38384
- var value = styles['border-' + position + '-width'];
38385
- return size + toFloat(value);
38386
- }, 0);
38387
- }
38388
- /**
38389
- * Extracts paddings sizes from provided styles.
38390
- *
38391
- * @param {CSSStyleDeclaration} styles
38392
- * @returns {Object} Paddings box.
38393
- */
38394
- function getPaddings(styles) {
38395
- var positions = ['top', 'right', 'bottom', 'left'];
38396
- var paddings = {};
38397
- for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
38398
- var position = positions_1[_i];
38399
- var value = styles['padding-' + position];
38400
- paddings[position] = toFloat(value);
38401
- }
38402
- return paddings;
38403
- }
38404
- /**
38405
- * Calculates content rectangle of provided SVG element.
38406
- *
38407
- * @param {SVGGraphicsElement} target - Element content rectangle of which needs
38408
- * to be calculated.
38409
- * @returns {DOMRectInit}
38410
- */
38411
- function getSVGContentRect(target) {
38412
- var bbox = target.getBBox();
38413
- return createRectInit(0, 0, bbox.width, bbox.height);
38414
- }
38415
- /**
38416
- * Calculates content rectangle of provided HTMLElement.
38417
- *
38418
- * @param {HTMLElement} target - Element for which to calculate the content rectangle.
38419
- * @returns {DOMRectInit}
38420
- */
38421
- function getHTMLElementContentRect(target) {
38422
- // Client width & height properties can't be
38423
- // used exclusively as they provide rounded values.
38424
- var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
38425
- // By this condition we can catch all non-replaced inline, hidden and
38426
- // detached elements. Though elements with width & height properties less
38427
- // than 0.5 will be discarded as well.
38428
- //
38429
- // Without it we would need to implement separate methods for each of
38430
- // those cases and it's not possible to perform a precise and performance
38431
- // effective test for hidden elements. E.g. even jQuery's ':visible' filter
38432
- // gives wrong results for elements with width & height less than 0.5.
38433
- if (!clientWidth && !clientHeight) {
38434
- return emptyRect;
38435
- }
38436
- var styles = getWindowOf(target).getComputedStyle(target);
38437
- var paddings = getPaddings(styles);
38438
- var horizPad = paddings.left + paddings.right;
38439
- var vertPad = paddings.top + paddings.bottom;
38440
- // Computed styles of width & height are being used because they are the
38441
- // only dimensions available to JS that contain non-rounded values. It could
38442
- // be possible to utilize the getBoundingClientRect if only it's data wasn't
38443
- // affected by CSS transformations let alone paddings, borders and scroll bars.
38444
- var width = toFloat(styles.width), height = toFloat(styles.height);
38445
- // Width & height include paddings and borders when the 'border-box' box
38446
- // model is applied (except for IE).
38447
- if (styles.boxSizing === 'border-box') {
38448
- // Following conditions are required to handle Internet Explorer which
38449
- // doesn't include paddings and borders to computed CSS dimensions.
38450
- //
38451
- // We can say that if CSS dimensions + paddings are equal to the "client"
38452
- // properties then it's either IE, and thus we don't need to subtract
38453
- // anything, or an element merely doesn't have paddings/borders styles.
38454
- if (Math.round(width + horizPad) !== clientWidth) {
38455
- width -= getBordersSize(styles, 'left', 'right') + horizPad;
38456
- }
38457
- if (Math.round(height + vertPad) !== clientHeight) {
38458
- height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
38459
- }
38460
- }
38461
- // Following steps can't be applied to the document's root element as its
38462
- // client[Width/Height] properties represent viewport area of the window.
38463
- // Besides, it's as well not necessary as the <html> itself neither has
38464
- // rendered scroll bars nor it can be clipped.
38465
- if (!isDocumentElement(target)) {
38466
- // In some browsers (only in Firefox, actually) CSS width & height
38467
- // include scroll bars size which can be removed at this step as scroll
38468
- // bars are the only difference between rounded dimensions + paddings
38469
- // and "client" properties, though that is not always true in Chrome.
38470
- var vertScrollbar = Math.round(width + horizPad) - clientWidth;
38471
- var horizScrollbar = Math.round(height + vertPad) - clientHeight;
38472
- // Chrome has a rather weird rounding of "client" properties.
38473
- // E.g. for an element with content width of 314.2px it sometimes gives
38474
- // the client width of 315px and for the width of 314.7px it may give
38475
- // 314px. And it doesn't happen all the time. So just ignore this delta
38476
- // as a non-relevant.
38477
- if (Math.abs(vertScrollbar) !== 1) {
38478
- width -= vertScrollbar;
38479
- }
38480
- if (Math.abs(horizScrollbar) !== 1) {
38481
- height -= horizScrollbar;
38482
- }
38483
- }
38484
- return createRectInit(paddings.left, paddings.top, width, height);
38485
- }
38486
- /**
38487
- * Checks whether provided element is an instance of the SVGGraphicsElement.
38488
- *
38489
- * @param {Element} target - Element to be checked.
38490
- * @returns {boolean}
38491
- */
38492
- var isSVGGraphicsElement = (function () {
38493
- // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
38494
- // interface.
38495
- if (typeof SVGGraphicsElement !== 'undefined') {
38496
- return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
38497
- }
38498
- // If it's so, then check that element is at least an instance of the
38499
- // SVGElement and that it has the "getBBox" method.
38500
- // eslint-disable-next-line no-extra-parens
38501
- return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
38502
- typeof target.getBBox === 'function'); };
38503
- })();
38504
- /**
38505
- * Checks whether provided element is a document element (<html>).
38506
- *
38507
- * @param {Element} target - Element to be checked.
38508
- * @returns {boolean}
38509
- */
38510
- function isDocumentElement(target) {
38511
- return target === getWindowOf(target).document.documentElement;
38512
- }
38513
- /**
38514
- * Calculates an appropriate content rectangle for provided html or svg element.
38515
- *
38516
- * @param {Element} target - Element content rectangle of which needs to be calculated.
38517
- * @returns {DOMRectInit}
38518
- */
38519
- function getContentRect(target) {
38520
- if (!isBrowser) {
38521
- return emptyRect;
38522
- }
38523
- if (isSVGGraphicsElement(target)) {
38524
- return getSVGContentRect(target);
38525
- }
38526
- return getHTMLElementContentRect(target);
38527
- }
38528
- /**
38529
- * Creates rectangle with an interface of the DOMRectReadOnly.
38530
- * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
38531
- *
38532
- * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
38533
- * @returns {DOMRectReadOnly}
38534
- */
38535
- function createReadOnlyRect(_a) {
38536
- var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
38537
- // If DOMRectReadOnly is available use it as a prototype for the rectangle.
38538
- var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
38539
- var rect = Object.create(Constr.prototype);
38540
- // Rectangle's properties are not writable and non-enumerable.
38541
- defineConfigurable(rect, {
38542
- x: x, y: y, width: width, height: height,
38543
- top: y,
38544
- right: x + width,
38545
- bottom: height + y,
38546
- left: x
38547
- });
38548
- return rect;
38549
- }
38550
- /**
38551
- * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
38552
- * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
38553
- *
38554
- * @param {number} x - X coordinate.
38555
- * @param {number} y - Y coordinate.
38556
- * @param {number} width - Rectangle's width.
38557
- * @param {number} height - Rectangle's height.
38558
- * @returns {DOMRectInit}
38559
- */
38560
- function createRectInit(x, y, width, height) {
38561
- return { x: x, y: y, width: width, height: height };
38562
- }
38563
-
38564
- /**
38565
- * Class that is responsible for computations of the content rectangle of
38566
- * provided DOM element and for keeping track of it's changes.
38567
- */
38568
- var ResizeObservation = /** @class */ (function () {
38569
- /**
38570
- * Creates an instance of ResizeObservation.
38571
- *
38572
- * @param {Element} target - Element to be observed.
38573
- */
38574
- function ResizeObservation(target) {
38575
- /**
38576
- * Broadcasted width of content rectangle.
38577
- *
38578
- * @type {number}
38579
- */
38580
- this.broadcastWidth = 0;
38581
- /**
38582
- * Broadcasted height of content rectangle.
38583
- *
38584
- * @type {number}
38585
- */
38586
- this.broadcastHeight = 0;
38587
- /**
38588
- * Reference to the last observed content rectangle.
38589
- *
38590
- * @private {DOMRectInit}
38591
- */
38592
- this.contentRect_ = createRectInit(0, 0, 0, 0);
38593
- this.target = target;
38594
- }
38595
- /**
38596
- * Updates content rectangle and tells whether it's width or height properties
38597
- * have changed since the last broadcast.
38598
- *
38599
- * @returns {boolean}
38600
- */
38601
- ResizeObservation.prototype.isActive = function () {
38602
- var rect = getContentRect(this.target);
38603
- this.contentRect_ = rect;
38604
- return (rect.width !== this.broadcastWidth ||
38605
- rect.height !== this.broadcastHeight);
38606
- };
38607
- /**
38608
- * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
38609
- * from the corresponding properties of the last observed content rectangle.
38610
- *
38611
- * @returns {DOMRectInit} Last observed content rectangle.
38612
- */
38613
- ResizeObservation.prototype.broadcastRect = function () {
38614
- var rect = this.contentRect_;
38615
- this.broadcastWidth = rect.width;
38616
- this.broadcastHeight = rect.height;
38617
- return rect;
38618
- };
38619
- return ResizeObservation;
38360
+ // Placeholder of an empty content rectangle.
38361
+ var emptyRect = createRectInit(0, 0, 0, 0);
38362
+ /**
38363
+ * Converts provided string to a number.
38364
+ *
38365
+ * @param {number|string} value
38366
+ * @returns {number}
38367
+ */
38368
+ function toFloat(value) {
38369
+ return parseFloat(value) || 0;
38370
+ }
38371
+ /**
38372
+ * Extracts borders size from provided styles.
38373
+ *
38374
+ * @param {CSSStyleDeclaration} styles
38375
+ * @param {...string} positions - Borders positions (top, right, ...)
38376
+ * @returns {number}
38377
+ */
38378
+ function getBordersSize(styles) {
38379
+ var positions = [];
38380
+ for (var _i = 1; _i < arguments.length; _i++) {
38381
+ positions[_i - 1] = arguments[_i];
38382
+ }
38383
+ return positions.reduce(function (size, position) {
38384
+ var value = styles['border-' + position + '-width'];
38385
+ return size + toFloat(value);
38386
+ }, 0);
38387
+ }
38388
+ /**
38389
+ * Extracts paddings sizes from provided styles.
38390
+ *
38391
+ * @param {CSSStyleDeclaration} styles
38392
+ * @returns {Object} Paddings box.
38393
+ */
38394
+ function getPaddings(styles) {
38395
+ var positions = ['top', 'right', 'bottom', 'left'];
38396
+ var paddings = {};
38397
+ for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
38398
+ var position = positions_1[_i];
38399
+ var value = styles['padding-' + position];
38400
+ paddings[position] = toFloat(value);
38401
+ }
38402
+ return paddings;
38403
+ }
38404
+ /**
38405
+ * Calculates content rectangle of provided SVG element.
38406
+ *
38407
+ * @param {SVGGraphicsElement} target - Element content rectangle of which needs
38408
+ * to be calculated.
38409
+ * @returns {DOMRectInit}
38410
+ */
38411
+ function getSVGContentRect(target) {
38412
+ var bbox = target.getBBox();
38413
+ return createRectInit(0, 0, bbox.width, bbox.height);
38414
+ }
38415
+ /**
38416
+ * Calculates content rectangle of provided HTMLElement.
38417
+ *
38418
+ * @param {HTMLElement} target - Element for which to calculate the content rectangle.
38419
+ * @returns {DOMRectInit}
38420
+ */
38421
+ function getHTMLElementContentRect(target) {
38422
+ // Client width & height properties can't be
38423
+ // used exclusively as they provide rounded values.
38424
+ var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
38425
+ // By this condition we can catch all non-replaced inline, hidden and
38426
+ // detached elements. Though elements with width & height properties less
38427
+ // than 0.5 will be discarded as well.
38428
+ //
38429
+ // Without it we would need to implement separate methods for each of
38430
+ // those cases and it's not possible to perform a precise and performance
38431
+ // effective test for hidden elements. E.g. even jQuery's ':visible' filter
38432
+ // gives wrong results for elements with width & height less than 0.5.
38433
+ if (!clientWidth && !clientHeight) {
38434
+ return emptyRect;
38435
+ }
38436
+ var styles = getWindowOf(target).getComputedStyle(target);
38437
+ var paddings = getPaddings(styles);
38438
+ var horizPad = paddings.left + paddings.right;
38439
+ var vertPad = paddings.top + paddings.bottom;
38440
+ // Computed styles of width & height are being used because they are the
38441
+ // only dimensions available to JS that contain non-rounded values. It could
38442
+ // be possible to utilize the getBoundingClientRect if only it's data wasn't
38443
+ // affected by CSS transformations let alone paddings, borders and scroll bars.
38444
+ var width = toFloat(styles.width), height = toFloat(styles.height);
38445
+ // Width & height include paddings and borders when the 'border-box' box
38446
+ // model is applied (except for IE).
38447
+ if (styles.boxSizing === 'border-box') {
38448
+ // Following conditions are required to handle Internet Explorer which
38449
+ // doesn't include paddings and borders to computed CSS dimensions.
38450
+ //
38451
+ // We can say that if CSS dimensions + paddings are equal to the "client"
38452
+ // properties then it's either IE, and thus we don't need to subtract
38453
+ // anything, or an element merely doesn't have paddings/borders styles.
38454
+ if (Math.round(width + horizPad) !== clientWidth) {
38455
+ width -= getBordersSize(styles, 'left', 'right') + horizPad;
38456
+ }
38457
+ if (Math.round(height + vertPad) !== clientHeight) {
38458
+ height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
38459
+ }
38460
+ }
38461
+ // Following steps can't be applied to the document's root element as its
38462
+ // client[Width/Height] properties represent viewport area of the window.
38463
+ // Besides, it's as well not necessary as the <html> itself neither has
38464
+ // rendered scroll bars nor it can be clipped.
38465
+ if (!isDocumentElement(target)) {
38466
+ // In some browsers (only in Firefox, actually) CSS width & height
38467
+ // include scroll bars size which can be removed at this step as scroll
38468
+ // bars are the only difference between rounded dimensions + paddings
38469
+ // and "client" properties, though that is not always true in Chrome.
38470
+ var vertScrollbar = Math.round(width + horizPad) - clientWidth;
38471
+ var horizScrollbar = Math.round(height + vertPad) - clientHeight;
38472
+ // Chrome has a rather weird rounding of "client" properties.
38473
+ // E.g. for an element with content width of 314.2px it sometimes gives
38474
+ // the client width of 315px and for the width of 314.7px it may give
38475
+ // 314px. And it doesn't happen all the time. So just ignore this delta
38476
+ // as a non-relevant.
38477
+ if (Math.abs(vertScrollbar) !== 1) {
38478
+ width -= vertScrollbar;
38479
+ }
38480
+ if (Math.abs(horizScrollbar) !== 1) {
38481
+ height -= horizScrollbar;
38482
+ }
38483
+ }
38484
+ return createRectInit(paddings.left, paddings.top, width, height);
38485
+ }
38486
+ /**
38487
+ * Checks whether provided element is an instance of the SVGGraphicsElement.
38488
+ *
38489
+ * @param {Element} target - Element to be checked.
38490
+ * @returns {boolean}
38491
+ */
38492
+ var isSVGGraphicsElement = (function () {
38493
+ // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
38494
+ // interface.
38495
+ if (typeof SVGGraphicsElement !== 'undefined') {
38496
+ return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
38497
+ }
38498
+ // If it's so, then check that element is at least an instance of the
38499
+ // SVGElement and that it has the "getBBox" method.
38500
+ // eslint-disable-next-line no-extra-parens
38501
+ return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
38502
+ typeof target.getBBox === 'function'); };
38503
+ })();
38504
+ /**
38505
+ * Checks whether provided element is a document element (<html>).
38506
+ *
38507
+ * @param {Element} target - Element to be checked.
38508
+ * @returns {boolean}
38509
+ */
38510
+ function isDocumentElement(target) {
38511
+ return target === getWindowOf(target).document.documentElement;
38512
+ }
38513
+ /**
38514
+ * Calculates an appropriate content rectangle for provided html or svg element.
38515
+ *
38516
+ * @param {Element} target - Element content rectangle of which needs to be calculated.
38517
+ * @returns {DOMRectInit}
38518
+ */
38519
+ function getContentRect(target) {
38520
+ if (!isBrowser) {
38521
+ return emptyRect;
38522
+ }
38523
+ if (isSVGGraphicsElement(target)) {
38524
+ return getSVGContentRect(target);
38525
+ }
38526
+ return getHTMLElementContentRect(target);
38527
+ }
38528
+ /**
38529
+ * Creates rectangle with an interface of the DOMRectReadOnly.
38530
+ * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
38531
+ *
38532
+ * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
38533
+ * @returns {DOMRectReadOnly}
38534
+ */
38535
+ function createReadOnlyRect(_a) {
38536
+ var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
38537
+ // If DOMRectReadOnly is available use it as a prototype for the rectangle.
38538
+ var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
38539
+ var rect = Object.create(Constr.prototype);
38540
+ // Rectangle's properties are not writable and non-enumerable.
38541
+ defineConfigurable(rect, {
38542
+ x: x, y: y, width: width, height: height,
38543
+ top: y,
38544
+ right: x + width,
38545
+ bottom: height + y,
38546
+ left: x
38547
+ });
38548
+ return rect;
38549
+ }
38550
+ /**
38551
+ * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
38552
+ * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
38553
+ *
38554
+ * @param {number} x - X coordinate.
38555
+ * @param {number} y - Y coordinate.
38556
+ * @param {number} width - Rectangle's width.
38557
+ * @param {number} height - Rectangle's height.
38558
+ * @returns {DOMRectInit}
38559
+ */
38560
+ function createRectInit(x, y, width, height) {
38561
+ return { x: x, y: y, width: width, height: height };
38562
+ }
38563
+
38564
+ /**
38565
+ * Class that is responsible for computations of the content rectangle of
38566
+ * provided DOM element and for keeping track of it's changes.
38567
+ */
38568
+ var ResizeObservation = /** @class */ (function () {
38569
+ /**
38570
+ * Creates an instance of ResizeObservation.
38571
+ *
38572
+ * @param {Element} target - Element to be observed.
38573
+ */
38574
+ function ResizeObservation(target) {
38575
+ /**
38576
+ * Broadcasted width of content rectangle.
38577
+ *
38578
+ * @type {number}
38579
+ */
38580
+ this.broadcastWidth = 0;
38581
+ /**
38582
+ * Broadcasted height of content rectangle.
38583
+ *
38584
+ * @type {number}
38585
+ */
38586
+ this.broadcastHeight = 0;
38587
+ /**
38588
+ * Reference to the last observed content rectangle.
38589
+ *
38590
+ * @private {DOMRectInit}
38591
+ */
38592
+ this.contentRect_ = createRectInit(0, 0, 0, 0);
38593
+ this.target = target;
38594
+ }
38595
+ /**
38596
+ * Updates content rectangle and tells whether it's width or height properties
38597
+ * have changed since the last broadcast.
38598
+ *
38599
+ * @returns {boolean}
38600
+ */
38601
+ ResizeObservation.prototype.isActive = function () {
38602
+ var rect = getContentRect(this.target);
38603
+ this.contentRect_ = rect;
38604
+ return (rect.width !== this.broadcastWidth ||
38605
+ rect.height !== this.broadcastHeight);
38606
+ };
38607
+ /**
38608
+ * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
38609
+ * from the corresponding properties of the last observed content rectangle.
38610
+ *
38611
+ * @returns {DOMRectInit} Last observed content rectangle.
38612
+ */
38613
+ ResizeObservation.prototype.broadcastRect = function () {
38614
+ var rect = this.contentRect_;
38615
+ this.broadcastWidth = rect.width;
38616
+ this.broadcastHeight = rect.height;
38617
+ return rect;
38618
+ };
38619
+ return ResizeObservation;
38620
38620
  }());
38621
38621
 
38622
- var ResizeObserverEntry = /** @class */ (function () {
38623
- /**
38624
- * Creates an instance of ResizeObserverEntry.
38625
- *
38626
- * @param {Element} target - Element that is being observed.
38627
- * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
38628
- */
38629
- function ResizeObserverEntry(target, rectInit) {
38630
- var contentRect = createReadOnlyRect(rectInit);
38631
- // According to the specification following properties are not writable
38632
- // and are also not enumerable in the native implementation.
38633
- //
38634
- // Property accessors are not being used as they'd require to define a
38635
- // private WeakMap storage which may cause memory leaks in browsers that
38636
- // don't support this type of collections.
38637
- defineConfigurable(this, { target: target, contentRect: contentRect });
38638
- }
38639
- return ResizeObserverEntry;
38622
+ var ResizeObserverEntry = /** @class */ (function () {
38623
+ /**
38624
+ * Creates an instance of ResizeObserverEntry.
38625
+ *
38626
+ * @param {Element} target - Element that is being observed.
38627
+ * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
38628
+ */
38629
+ function ResizeObserverEntry(target, rectInit) {
38630
+ var contentRect = createReadOnlyRect(rectInit);
38631
+ // According to the specification following properties are not writable
38632
+ // and are also not enumerable in the native implementation.
38633
+ //
38634
+ // Property accessors are not being used as they'd require to define a
38635
+ // private WeakMap storage which may cause memory leaks in browsers that
38636
+ // don't support this type of collections.
38637
+ defineConfigurable(this, { target: target, contentRect: contentRect });
38638
+ }
38639
+ return ResizeObserverEntry;
38640
38640
  }());
38641
38641
 
38642
- var ResizeObserverSPI = /** @class */ (function () {
38643
- /**
38644
- * Creates a new instance of ResizeObserver.
38645
- *
38646
- * @param {ResizeObserverCallback} callback - Callback function that is invoked
38647
- * when one of the observed elements changes it's content dimensions.
38648
- * @param {ResizeObserverController} controller - Controller instance which
38649
- * is responsible for the updates of observer.
38650
- * @param {ResizeObserver} callbackCtx - Reference to the public
38651
- * ResizeObserver instance which will be passed to callback function.
38652
- */
38653
- function ResizeObserverSPI(callback, controller, callbackCtx) {
38654
- /**
38655
- * Collection of resize observations that have detected changes in dimensions
38656
- * of elements.
38657
- *
38658
- * @private {Array<ResizeObservation>}
38659
- */
38660
- this.activeObservations_ = [];
38661
- /**
38662
- * Registry of the ResizeObservation instances.
38663
- *
38664
- * @private {Map<Element, ResizeObservation>}
38665
- */
38666
- this.observations_ = new MapShim();
38667
- if (typeof callback !== 'function') {
38668
- throw new TypeError('The callback provided as parameter 1 is not a function.');
38669
- }
38670
- this.callback_ = callback;
38671
- this.controller_ = controller;
38672
- this.callbackCtx_ = callbackCtx;
38673
- }
38674
- /**
38675
- * Starts observing provided element.
38676
- *
38677
- * @param {Element} target - Element to be observed.
38678
- * @returns {void}
38679
- */
38680
- ResizeObserverSPI.prototype.observe = function (target) {
38681
- if (!arguments.length) {
38682
- throw new TypeError('1 argument required, but only 0 present.');
38683
- }
38684
- // Do nothing if current environment doesn't have the Element interface.
38685
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
38686
- return;
38687
- }
38688
- if (!(target instanceof getWindowOf(target).Element)) {
38689
- throw new TypeError('parameter 1 is not of type "Element".');
38690
- }
38691
- var observations = this.observations_;
38692
- // Do nothing if element is already being observed.
38693
- if (observations.has(target)) {
38694
- return;
38695
- }
38696
- observations.set(target, new ResizeObservation(target));
38697
- this.controller_.addObserver(this);
38698
- // Force the update of observations.
38699
- this.controller_.refresh();
38700
- };
38701
- /**
38702
- * Stops observing provided element.
38703
- *
38704
- * @param {Element} target - Element to stop observing.
38705
- * @returns {void}
38706
- */
38707
- ResizeObserverSPI.prototype.unobserve = function (target) {
38708
- if (!arguments.length) {
38709
- throw new TypeError('1 argument required, but only 0 present.');
38710
- }
38711
- // Do nothing if current environment doesn't have the Element interface.
38712
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
38713
- return;
38714
- }
38715
- if (!(target instanceof getWindowOf(target).Element)) {
38716
- throw new TypeError('parameter 1 is not of type "Element".');
38717
- }
38718
- var observations = this.observations_;
38719
- // Do nothing if element is not being observed.
38720
- if (!observations.has(target)) {
38721
- return;
38722
- }
38723
- observations.delete(target);
38724
- if (!observations.size) {
38725
- this.controller_.removeObserver(this);
38726
- }
38727
- };
38728
- /**
38729
- * Stops observing all elements.
38730
- *
38731
- * @returns {void}
38732
- */
38733
- ResizeObserverSPI.prototype.disconnect = function () {
38734
- this.clearActive();
38735
- this.observations_.clear();
38736
- this.controller_.removeObserver(this);
38737
- };
38738
- /**
38739
- * Collects observation instances the associated element of which has changed
38740
- * it's content rectangle.
38741
- *
38742
- * @returns {void}
38743
- */
38744
- ResizeObserverSPI.prototype.gatherActive = function () {
38745
- var _this = this;
38746
- this.clearActive();
38747
- this.observations_.forEach(function (observation) {
38748
- if (observation.isActive()) {
38749
- _this.activeObservations_.push(observation);
38750
- }
38751
- });
38752
- };
38753
- /**
38754
- * Invokes initial callback function with a list of ResizeObserverEntry
38755
- * instances collected from active resize observations.
38756
- *
38757
- * @returns {void}
38758
- */
38759
- ResizeObserverSPI.prototype.broadcastActive = function () {
38760
- // Do nothing if observer doesn't have active observations.
38761
- if (!this.hasActive()) {
38762
- return;
38763
- }
38764
- var ctx = this.callbackCtx_;
38765
- // Create ResizeObserverEntry instance for every active observation.
38766
- var entries = this.activeObservations_.map(function (observation) {
38767
- return new ResizeObserverEntry(observation.target, observation.broadcastRect());
38768
- });
38769
- this.callback_.call(ctx, entries, ctx);
38770
- this.clearActive();
38771
- };
38772
- /**
38773
- * Clears the collection of active observations.
38774
- *
38775
- * @returns {void}
38776
- */
38777
- ResizeObserverSPI.prototype.clearActive = function () {
38778
- this.activeObservations_.splice(0);
38779
- };
38780
- /**
38781
- * Tells whether observer has active observations.
38782
- *
38783
- * @returns {boolean}
38784
- */
38785
- ResizeObserverSPI.prototype.hasActive = function () {
38786
- return this.activeObservations_.length > 0;
38787
- };
38788
- return ResizeObserverSPI;
38642
+ var ResizeObserverSPI = /** @class */ (function () {
38643
+ /**
38644
+ * Creates a new instance of ResizeObserver.
38645
+ *
38646
+ * @param {ResizeObserverCallback} callback - Callback function that is invoked
38647
+ * when one of the observed elements changes it's content dimensions.
38648
+ * @param {ResizeObserverController} controller - Controller instance which
38649
+ * is responsible for the updates of observer.
38650
+ * @param {ResizeObserver} callbackCtx - Reference to the public
38651
+ * ResizeObserver instance which will be passed to callback function.
38652
+ */
38653
+ function ResizeObserverSPI(callback, controller, callbackCtx) {
38654
+ /**
38655
+ * Collection of resize observations that have detected changes in dimensions
38656
+ * of elements.
38657
+ *
38658
+ * @private {Array<ResizeObservation>}
38659
+ */
38660
+ this.activeObservations_ = [];
38661
+ /**
38662
+ * Registry of the ResizeObservation instances.
38663
+ *
38664
+ * @private {Map<Element, ResizeObservation>}
38665
+ */
38666
+ this.observations_ = new MapShim();
38667
+ if (typeof callback !== 'function') {
38668
+ throw new TypeError('The callback provided as parameter 1 is not a function.');
38669
+ }
38670
+ this.callback_ = callback;
38671
+ this.controller_ = controller;
38672
+ this.callbackCtx_ = callbackCtx;
38673
+ }
38674
+ /**
38675
+ * Starts observing provided element.
38676
+ *
38677
+ * @param {Element} target - Element to be observed.
38678
+ * @returns {void}
38679
+ */
38680
+ ResizeObserverSPI.prototype.observe = function (target) {
38681
+ if (!arguments.length) {
38682
+ throw new TypeError('1 argument required, but only 0 present.');
38683
+ }
38684
+ // Do nothing if current environment doesn't have the Element interface.
38685
+ if (typeof Element === 'undefined' || !(Element instanceof Object)) {
38686
+ return;
38687
+ }
38688
+ if (!(target instanceof getWindowOf(target).Element)) {
38689
+ throw new TypeError('parameter 1 is not of type "Element".');
38690
+ }
38691
+ var observations = this.observations_;
38692
+ // Do nothing if element is already being observed.
38693
+ if (observations.has(target)) {
38694
+ return;
38695
+ }
38696
+ observations.set(target, new ResizeObservation(target));
38697
+ this.controller_.addObserver(this);
38698
+ // Force the update of observations.
38699
+ this.controller_.refresh();
38700
+ };
38701
+ /**
38702
+ * Stops observing provided element.
38703
+ *
38704
+ * @param {Element} target - Element to stop observing.
38705
+ * @returns {void}
38706
+ */
38707
+ ResizeObserverSPI.prototype.unobserve = function (target) {
38708
+ if (!arguments.length) {
38709
+ throw new TypeError('1 argument required, but only 0 present.');
38710
+ }
38711
+ // Do nothing if current environment doesn't have the Element interface.
38712
+ if (typeof Element === 'undefined' || !(Element instanceof Object)) {
38713
+ return;
38714
+ }
38715
+ if (!(target instanceof getWindowOf(target).Element)) {
38716
+ throw new TypeError('parameter 1 is not of type "Element".');
38717
+ }
38718
+ var observations = this.observations_;
38719
+ // Do nothing if element is not being observed.
38720
+ if (!observations.has(target)) {
38721
+ return;
38722
+ }
38723
+ observations.delete(target);
38724
+ if (!observations.size) {
38725
+ this.controller_.removeObserver(this);
38726
+ }
38727
+ };
38728
+ /**
38729
+ * Stops observing all elements.
38730
+ *
38731
+ * @returns {void}
38732
+ */
38733
+ ResizeObserverSPI.prototype.disconnect = function () {
38734
+ this.clearActive();
38735
+ this.observations_.clear();
38736
+ this.controller_.removeObserver(this);
38737
+ };
38738
+ /**
38739
+ * Collects observation instances the associated element of which has changed
38740
+ * it's content rectangle.
38741
+ *
38742
+ * @returns {void}
38743
+ */
38744
+ ResizeObserverSPI.prototype.gatherActive = function () {
38745
+ var _this = this;
38746
+ this.clearActive();
38747
+ this.observations_.forEach(function (observation) {
38748
+ if (observation.isActive()) {
38749
+ _this.activeObservations_.push(observation);
38750
+ }
38751
+ });
38752
+ };
38753
+ /**
38754
+ * Invokes initial callback function with a list of ResizeObserverEntry
38755
+ * instances collected from active resize observations.
38756
+ *
38757
+ * @returns {void}
38758
+ */
38759
+ ResizeObserverSPI.prototype.broadcastActive = function () {
38760
+ // Do nothing if observer doesn't have active observations.
38761
+ if (!this.hasActive()) {
38762
+ return;
38763
+ }
38764
+ var ctx = this.callbackCtx_;
38765
+ // Create ResizeObserverEntry instance for every active observation.
38766
+ var entries = this.activeObservations_.map(function (observation) {
38767
+ return new ResizeObserverEntry(observation.target, observation.broadcastRect());
38768
+ });
38769
+ this.callback_.call(ctx, entries, ctx);
38770
+ this.clearActive();
38771
+ };
38772
+ /**
38773
+ * Clears the collection of active observations.
38774
+ *
38775
+ * @returns {void}
38776
+ */
38777
+ ResizeObserverSPI.prototype.clearActive = function () {
38778
+ this.activeObservations_.splice(0);
38779
+ };
38780
+ /**
38781
+ * Tells whether observer has active observations.
38782
+ *
38783
+ * @returns {boolean}
38784
+ */
38785
+ ResizeObserverSPI.prototype.hasActive = function () {
38786
+ return this.activeObservations_.length > 0;
38787
+ };
38788
+ return ResizeObserverSPI;
38789
38789
  }());
38790
38790
 
38791
- // Registry of internal observers. If WeakMap is not available use current shim
38792
- // for the Map collection as it has all required methods and because WeakMap
38793
- // can't be fully polyfilled anyway.
38794
- var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
38795
- /**
38796
- * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
38797
- * exposing only those methods and properties that are defined in the spec.
38798
- */
38799
- var ResizeObserver = /** @class */ (function () {
38800
- /**
38801
- * Creates a new instance of ResizeObserver.
38802
- *
38803
- * @param {ResizeObserverCallback} callback - Callback that is invoked when
38804
- * dimensions of the observed elements change.
38805
- */
38806
- function ResizeObserver(callback) {
38807
- if (!(this instanceof ResizeObserver)) {
38808
- throw new TypeError('Cannot call a class as a function.');
38809
- }
38810
- if (!arguments.length) {
38811
- throw new TypeError('1 argument required, but only 0 present.');
38812
- }
38813
- var controller = ResizeObserverController.getInstance();
38814
- var observer = new ResizeObserverSPI(callback, controller, this);
38815
- observers.set(this, observer);
38816
- }
38817
- return ResizeObserver;
38818
- }());
38819
- // Expose public methods of ResizeObserver.
38820
- [
38821
- 'observe',
38822
- 'unobserve',
38823
- 'disconnect'
38824
- ].forEach(function (method) {
38825
- ResizeObserver.prototype[method] = function () {
38826
- var _a;
38827
- return (_a = observers.get(this))[method].apply(_a, arguments);
38828
- };
38791
+ // Registry of internal observers. If WeakMap is not available use current shim
38792
+ // for the Map collection as it has all required methods and because WeakMap
38793
+ // can't be fully polyfilled anyway.
38794
+ var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
38795
+ /**
38796
+ * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
38797
+ * exposing only those methods and properties that are defined in the spec.
38798
+ */
38799
+ var ResizeObserver = /** @class */ (function () {
38800
+ /**
38801
+ * Creates a new instance of ResizeObserver.
38802
+ *
38803
+ * @param {ResizeObserverCallback} callback - Callback that is invoked when
38804
+ * dimensions of the observed elements change.
38805
+ */
38806
+ function ResizeObserver(callback) {
38807
+ if (!(this instanceof ResizeObserver)) {
38808
+ throw new TypeError('Cannot call a class as a function.');
38809
+ }
38810
+ if (!arguments.length) {
38811
+ throw new TypeError('1 argument required, but only 0 present.');
38812
+ }
38813
+ var controller = ResizeObserverController.getInstance();
38814
+ var observer = new ResizeObserverSPI(callback, controller, this);
38815
+ observers.set(this, observer);
38816
+ }
38817
+ return ResizeObserver;
38818
+ }());
38819
+ // Expose public methods of ResizeObserver.
38820
+ [
38821
+ 'observe',
38822
+ 'unobserve',
38823
+ 'disconnect'
38824
+ ].forEach(function (method) {
38825
+ ResizeObserver.prototype[method] = function () {
38826
+ var _a;
38827
+ return (_a = observers.get(this))[method].apply(_a, arguments);
38828
+ };
38829
38829
  });
38830
38830
 
38831
- ((function () {
38832
- // Export existing implementation if available.
38833
- if (typeof global$1.ResizeObserver !== 'undefined') {
38834
- return global$1.ResizeObserver;
38835
- }
38836
- return ResizeObserver;
38831
+ ((function () {
38832
+ // Export existing implementation if available.
38833
+ if (typeof global$1.ResizeObserver !== 'undefined') {
38834
+ return global$1.ResizeObserver;
38835
+ }
38836
+ return ResizeObserver;
38837
38837
  }))();
38838
38838
 
38839
38839
  var screenfull = createCommonjsModule$1(function (module) {
@@ -39796,6 +39796,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
39796
39796
  var useEnvironment = function useEnvironment(_ref) {
39797
39797
  var configPath = _ref.configPath,
39798
39798
  _ref$headers = _ref.headers,
39799
+ transformData = _ref.transformData,
39799
39800
  headers = _ref$headers === void 0 ? {} : _ref$headers;
39800
39801
 
39801
39802
  var _useState = useState({}),
@@ -39816,7 +39817,7 @@ var useEnvironment = function useEnvironment(_ref) {
39816
39817
 
39817
39818
  var reload = function reload() {
39818
39819
  retry(loadEnvironment, 5, 500).then(function (res) {
39819
- setEnvironment(res);
39820
+ setEnvironment(transformData ? transformData(res) : res);
39820
39821
  setEnvironmentLoaded(true);
39821
39822
  });
39822
39823
  };