planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
declare const isSVG: (target: Element) => boolean;
declare const isHidden: (target: Element) => boolean;
declare const isElement: (obj: unknown) => boolean;
declare const isReplacedElement: (target: Element) => boolean;
export { isSVG, isHidden, isElement, isReplacedElement };

View File

@@ -0,0 +1,35 @@
var isSVG = function (target) { return target instanceof SVGElement && 'getBBox' in target; };
var isHidden = function (target) {
if (isSVG(target)) {
var _a = target.getBBox(), width = _a.width, height = _a.height;
return !width && !height;
}
var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
return !(offsetWidth || offsetHeight || target.getClientRects().length);
};
var isElement = function (obj) {
var _a;
if (obj instanceof Element) {
return true;
}
var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
return !!(scope && obj instanceof scope.Element);
};
var isReplacedElement = function (target) {
switch (target.tagName) {
case 'INPUT':
if (target.type !== 'image') {
break;
}
case 'VIDEO':
case 'AUDIO':
case 'EMBED':
case 'OBJECT':
case 'CANVAS':
case 'IFRAME':
case 'IMG':
return true;
}
return false;
};
export { isSVG, isHidden, isElement, isReplacedElement };

View File

@@ -0,0 +1 @@
export declare const freeze: <T>(obj: T) => Readonly<T>;

View File

@@ -0,0 +1 @@
export var freeze = function (obj) { return Object.freeze(obj); };

View File

@@ -0,0 +1,10 @@
import { ResizeObserver } from '../ResizeObserver';
import { ResizeObserverEntry } from '../ResizeObserverEntry';
import { ResizeObserverSize } from '../ResizeObserverSize';
declare type IsomorphicWindow = Window & {
ResizeObserver?: typeof ResizeObserver;
ResizeObserverEntry?: typeof ResizeObserverEntry;
ResizeObserverSize?: typeof ResizeObserverSize;
};
export declare const global: IsomorphicWindow;
export {};

View File

@@ -0,0 +1 @@
export var global = typeof window !== 'undefined' ? window : {};

View File

@@ -0,0 +1,2 @@
declare const process: () => boolean;
export { process };

View File

@@ -0,0 +1,18 @@
import { hasActiveObservations } from '../algorithms/hasActiveObservations';
import { hasSkippedObservations } from '../algorithms/hasSkippedObservations';
import { deliverResizeLoopError } from '../algorithms/deliverResizeLoopError';
import { broadcastActiveObservations } from '../algorithms/broadcastActiveObservations';
import { gatherActiveObservationsAtDepth } from '../algorithms/gatherActiveObservationsAtDepth';
var process = function () {
var depth = 0;
gatherActiveObservationsAtDepth(depth);
while (hasActiveObservations()) {
depth = broadcastActiveObservations();
gatherActiveObservationsAtDepth(depth);
}
if (hasSkippedObservations()) {
deliverResizeLoopError();
}
return depth > 0;
};
export { process };

View File

@@ -0,0 +1,2 @@
declare const queueMicroTask: (callback: () => void) => void;
export { queueMicroTask };

View File

@@ -0,0 +1,15 @@
var trigger;
var callbacks = [];
var notify = function () { return callbacks.splice(0).forEach(function (cb) { return cb(); }); };
var queueMicroTask = function (callback) {
if (!trigger) {
var toggle_1 = 0;
var el_1 = document.createTextNode('');
var config = { characterData: true };
new MutationObserver(function () { return notify(); }).observe(el_1, config);
trigger = function () { el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++); };
}
callbacks.push(callback);
trigger();
};
export { queueMicroTask };

View File

@@ -0,0 +1,2 @@
declare const queueResizeObserver: (cb: () => void) => void;
export { queueResizeObserver };

View File

@@ -0,0 +1,7 @@
import { queueMicroTask } from './queueMicroTask';
var queueResizeObserver = function (cb) {
queueMicroTask(function ResizeObserver() {
requestAnimationFrame(cb);
});
};
export { queueResizeObserver };

View File

@@ -0,0 +1,3 @@
import { ResizeObserverDetail } from '../ResizeObserverDetail';
declare const resizeObservers: ResizeObserverDetail[];
export { resizeObservers };

View File

@@ -0,0 +1,2 @@
var resizeObservers = [];
export { resizeObservers };

View File

@@ -0,0 +1,14 @@
declare class Scheduler {
private observer;
private listener;
stopped: boolean;
constructor();
private run;
schedule(): void;
private observe;
start(): void;
stop(): void;
}
declare const scheduler: Scheduler;
declare const updateCount: (n: number) => void;
export { scheduler, updateCount };

View File

@@ -0,0 +1,100 @@
import { process } from './process';
import { global } from './global';
import { queueResizeObserver } from './queueResizeObserver';
var watching = 0;
var isWatching = function () { return !!watching; };
var CATCH_PERIOD = 250;
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
var events = [
'resize',
'load',
'transitionend',
'animationend',
'animationstart',
'animationiteration',
'keyup',
'keydown',
'mouseup',
'mousedown',
'mouseover',
'mouseout',
'blur',
'focus'
];
var time = function (timeout) {
if (timeout === void 0) { timeout = 0; }
return Date.now() + timeout;
};
var scheduled = false;
var Scheduler = (function () {
function Scheduler() {
var _this = this;
this.stopped = true;
this.listener = function () { return _this.schedule(); };
}
Scheduler.prototype.run = function (timeout) {
var _this = this;
if (timeout === void 0) { timeout = CATCH_PERIOD; }
if (scheduled) {
return;
}
scheduled = true;
var until = time(timeout);
queueResizeObserver(function () {
var elementsHaveResized = false;
try {
elementsHaveResized = process();
}
finally {
scheduled = false;
timeout = until - time();
if (!isWatching()) {
return;
}
if (elementsHaveResized) {
_this.run(1000);
}
else if (timeout > 0) {
_this.run(timeout);
}
else {
_this.start();
}
}
});
};
Scheduler.prototype.schedule = function () {
this.stop();
this.run();
};
Scheduler.prototype.observe = function () {
var _this = this;
var cb = function () { return _this.observer && _this.observer.observe(document.body, observerConfig); };
document.body ? cb() : global.addEventListener('DOMContentLoaded', cb);
};
Scheduler.prototype.start = function () {
var _this = this;
if (this.stopped) {
this.stopped = false;
this.observer = new MutationObserver(this.listener);
this.observe();
events.forEach(function (name) { return global.addEventListener(name, _this.listener, true); });
}
};
Scheduler.prototype.stop = function () {
var _this = this;
if (!this.stopped) {
this.observer && this.observer.disconnect();
events.forEach(function (name) { return global.removeEventListener(name, _this.listener, true); });
this.stopped = true;
}
};
return Scheduler;
}());
var scheduler = new Scheduler();
var updateCount = function (n) {
!watching && n > 0 && scheduler.start();
watching += n;
!watching && scheduler.stop();
};
export { scheduler, updateCount };