| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- /*!
- * @pixi/polyfill - v6.5.10
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
- *
- * @pixi/polyfill is licensed under the MIT License.
- * http://www.opensource.org/licenses/mit-license
- */
- (function () {
- 'use strict';
- "use strict";
- if (typeof globalThis === 'undefined') {
- if (typeof self !== 'undefined') {
- // covers browsers
- // @ts-expect-error not-writable ts(2540) error only on node
- self.globalThis = self;
- }
- else if (typeof global !== 'undefined') {
- // covers versions of Node < 12
- // @ts-expect-error not-writable ts(2540) error only on node
- global.globalThis = global;
- }
- }
- /**
- * @this {Promise}
- */
- function finallyConstructor(callback) {
- var constructor = this.constructor;
- return this.then(
- function(value) {
- // @ts-ignore
- return constructor.resolve(callback()).then(function() {
- return value;
- });
- },
- function(reason) {
- // @ts-ignore
- return constructor.resolve(callback()).then(function() {
- // @ts-ignore
- return constructor.reject(reason);
- });
- }
- );
- }
- function allSettled(arr) {
- var P = this;
- return new P(function(resolve, reject) {
- if (!(arr && typeof arr.length !== 'undefined')) {
- return reject(
- new TypeError(
- typeof arr +
- ' ' +
- arr +
- ' is not iterable(cannot read property Symbol(Symbol.iterator))'
- )
- );
- }
- var args = Array.prototype.slice.call(arr);
- if (args.length === 0) { return resolve([]); }
- var remaining = args.length;
- function res(i, val) {
- if (val && (typeof val === 'object' || typeof val === 'function')) {
- var then = val.then;
- if (typeof then === 'function') {
- then.call(
- val,
- function(val) {
- res(i, val);
- },
- function(e) {
- args[i] = { status: 'rejected', reason: e };
- if (--remaining === 0) {
- resolve(args);
- }
- }
- );
- return;
- }
- }
- args[i] = { status: 'fulfilled', value: val };
- if (--remaining === 0) {
- resolve(args);
- }
- }
- for (var i = 0; i < args.length; i++) {
- res(i, args[i]);
- }
- });
- }
- // Store setTimeout reference so promise-polyfill will be unaffected by
- // other code modifying setTimeout (like sinon.useFakeTimers())
- var setTimeoutFunc = setTimeout;
- function isArray(x) {
- return Boolean(x && typeof x.length !== 'undefined');
- }
- function noop() {}
- // Polyfill for Function.prototype.bind
- function bind(fn, thisArg) {
- return function() {
- fn.apply(thisArg, arguments);
- };
- }
- /**
- * @constructor
- * @param {Function} fn
- */
- function Promise$1(fn) {
- if (!(this instanceof Promise$1))
- { throw new TypeError('Promises must be constructed via new'); }
- if (typeof fn !== 'function') { throw new TypeError('not a function'); }
- /** @type {!number} */
- this._state = 0;
- /** @type {!boolean} */
- this._handled = false;
- /** @type {Promise|undefined} */
- this._value = undefined;
- /** @type {!Array<!Function>} */
- this._deferreds = [];
- doResolve(fn, this);
- }
- function handle(self, deferred) {
- while (self._state === 3) {
- self = self._value;
- }
- if (self._state === 0) {
- self._deferreds.push(deferred);
- return;
- }
- self._handled = true;
- Promise$1._immediateFn(function() {
- var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
- if (cb === null) {
- (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
- return;
- }
- var ret;
- try {
- ret = cb(self._value);
- } catch (e) {
- reject(deferred.promise, e);
- return;
- }
- resolve(deferred.promise, ret);
- });
- }
- function resolve(self, newValue) {
- try {
- // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
- if (newValue === self)
- { throw new TypeError('A promise cannot be resolved with itself.'); }
- if (
- newValue &&
- (typeof newValue === 'object' || typeof newValue === 'function')
- ) {
- var then = newValue.then;
- if (newValue instanceof Promise$1) {
- self._state = 3;
- self._value = newValue;
- finale(self);
- return;
- } else if (typeof then === 'function') {
- doResolve(bind(then, newValue), self);
- return;
- }
- }
- self._state = 1;
- self._value = newValue;
- finale(self);
- } catch (e) {
- reject(self, e);
- }
- }
- function reject(self, newValue) {
- self._state = 2;
- self._value = newValue;
- finale(self);
- }
- function finale(self) {
- if (self._state === 2 && self._deferreds.length === 0) {
- Promise$1._immediateFn(function() {
- if (!self._handled) {
- Promise$1._unhandledRejectionFn(self._value);
- }
- });
- }
- for (var i = 0, len = self._deferreds.length; i < len; i++) {
- handle(self, self._deferreds[i]);
- }
- self._deferreds = null;
- }
- /**
- * @constructor
- */
- function Handler(onFulfilled, onRejected, promise) {
- this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
- this.onRejected = typeof onRejected === 'function' ? onRejected : null;
- this.promise = promise;
- }
- /**
- * Take a potentially misbehaving resolver function and make sure
- * onFulfilled and onRejected are only called once.
- *
- * Makes no guarantees about asynchrony.
- */
- function doResolve(fn, self) {
- var done = false;
- try {
- fn(
- function(value) {
- if (done) { return; }
- done = true;
- resolve(self, value);
- },
- function(reason) {
- if (done) { return; }
- done = true;
- reject(self, reason);
- }
- );
- } catch (ex) {
- if (done) { return; }
- done = true;
- reject(self, ex);
- }
- }
- Promise$1.prototype['catch'] = function(onRejected) {
- return this.then(null, onRejected);
- };
- Promise$1.prototype.then = function(onFulfilled, onRejected) {
- // @ts-ignore
- var prom = new this.constructor(noop);
- handle(this, new Handler(onFulfilled, onRejected, prom));
- return prom;
- };
- Promise$1.prototype['finally'] = finallyConstructor;
- Promise$1.all = function(arr) {
- return new Promise$1(function(resolve, reject) {
- if (!isArray(arr)) {
- return reject(new TypeError('Promise.all accepts an array'));
- }
- var args = Array.prototype.slice.call(arr);
- if (args.length === 0) { return resolve([]); }
- var remaining = args.length;
- function res(i, val) {
- try {
- if (val && (typeof val === 'object' || typeof val === 'function')) {
- var then = val.then;
- if (typeof then === 'function') {
- then.call(
- val,
- function(val) {
- res(i, val);
- },
- reject
- );
- return;
- }
- }
- args[i] = val;
- if (--remaining === 0) {
- resolve(args);
- }
- } catch (ex) {
- reject(ex);
- }
- }
- for (var i = 0; i < args.length; i++) {
- res(i, args[i]);
- }
- });
- };
- Promise$1.allSettled = allSettled;
- Promise$1.resolve = function(value) {
- if (value && typeof value === 'object' && value.constructor === Promise$1) {
- return value;
- }
- return new Promise$1(function(resolve) {
- resolve(value);
- });
- };
- Promise$1.reject = function(value) {
- return new Promise$1(function(resolve, reject) {
- reject(value);
- });
- };
- Promise$1.race = function(arr) {
- return new Promise$1(function(resolve, reject) {
- if (!isArray(arr)) {
- return reject(new TypeError('Promise.race accepts an array'));
- }
- for (var i = 0, len = arr.length; i < len; i++) {
- Promise$1.resolve(arr[i]).then(resolve, reject);
- }
- });
- };
- // Use polyfill for setImmediate for performance gains
- Promise$1._immediateFn =
- // @ts-ignore
- (typeof setImmediate === 'function' &&
- function(fn) {
- // @ts-ignore
- setImmediate(fn);
- }) ||
- function(fn) {
- setTimeoutFunc(fn, 0);
- };
- Promise$1._unhandledRejectionFn = function _unhandledRejectionFn(err) {
- if (typeof console !== 'undefined' && console) {
- console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
- }
- };
- // Support for IE 9 - 11 which does not include Promises
- if (!globalThis.Promise) {
- globalThis.Promise = Promise$1;
- }
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- 'use strict';
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
- return Object(val);
- }
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
- // Detect buggy property enumeration order in older V8 versions.
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
- var arguments$1 = arguments;
- var from;
- var to = toObject(target);
- var symbols;
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments$1[s]);
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
- return to;
- };
- // References:
- if (!Object.assign) {
- Object.assign = objectAssign;
- }
- "use strict";
- // References:
- // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- // https://gist.github.com/1579671
- // http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
- // https://gist.github.com/timhall/4078614
- // https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame
- // Expected to be used with Browserfiy
- // Browserify automatically detects the use of `global` and passes the
- // correct reference of `global`, `globalThis`, and finally `window`
- var ONE_FRAME_TIME = 16;
- // Date.now
- if (!(Date.now && Date.prototype.getTime)) {
- Date.now = function now() {
- return new Date().getTime();
- };
- }
- // performance.now
- if (!(globalThis.performance && globalThis.performance.now)) {
- var startTime_1 = Date.now();
- if (!globalThis.performance) {
- globalThis.performance = {};
- }
- globalThis.performance.now = function () { return Date.now() - startTime_1; };
- }
- // requestAnimationFrame
- var lastTime = Date.now();
- var vendors = ['ms', 'moz', 'webkit', 'o'];
- for (var x = 0; x < vendors.length && !globalThis.requestAnimationFrame; ++x) {
- var p = vendors[x];
- globalThis.requestAnimationFrame = globalThis[p + "RequestAnimationFrame"];
- globalThis.cancelAnimationFrame = globalThis[p + "CancelAnimationFrame"]
- || globalThis[p + "CancelRequestAnimationFrame"];
- }
- if (!globalThis.requestAnimationFrame) {
- globalThis.requestAnimationFrame = function (callback) {
- if (typeof callback !== 'function') {
- throw new TypeError(callback + "is not a function");
- }
- var currentTime = Date.now();
- var delay = ONE_FRAME_TIME + lastTime - currentTime;
- if (delay < 0) {
- delay = 0;
- }
- lastTime = currentTime;
- return globalThis.self.setTimeout(function () {
- lastTime = Date.now();
- callback(performance.now());
- }, delay);
- };
- }
- if (!globalThis.cancelAnimationFrame) {
- globalThis.cancelAnimationFrame = function (id) { return clearTimeout(id); };
- }
- "use strict";
- // References:
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
- if (!Math.sign) {
- Math.sign = function mathSign(x) {
- x = Number(x);
- if (x === 0 || isNaN(x)) {
- return x;
- }
- return x > 0 ? 1 : -1;
- };
- }
- "use strict";
- // References:
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
- if (!Number.isInteger) {
- Number.isInteger = function numberIsInteger(value) {
- return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
- };
- }
- if (!globalThis.ArrayBuffer) {
- globalThis.ArrayBuffer = Array;
- }
- if (!globalThis.Float32Array) {
- globalThis.Float32Array = Array;
- }
- if (!globalThis.Uint32Array) {
- globalThis.Uint32Array = Array;
- }
- if (!globalThis.Uint16Array) {
- globalThis.Uint16Array = Array;
- }
- if (!globalThis.Uint8Array) {
- globalThis.Uint8Array = Array;
- }
- if (!globalThis.Int32Array) {
- globalThis.Int32Array = Array;
- }
- })();
- //# sourceMappingURL=polyfill.js.map
|