Update content of files

This commit is contained in:
GitHub Action 2022-04-10 17:38:18 +00:00
parent 607b6268ed
commit 0d8c88ea93
11 changed files with 28330 additions and 0 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,272 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
//
// -- ogv-support.js
// https://github.com/brion/ogv.js
// Copyright (c) 2013-2016 Brion Vibber
//
(function() {
var OGVCompat = __webpack_require__(1),
OGVVersion = ("1.4.2-20170425024925-504d7197");
if (window) {
// 1.0-compat globals
window.OGVCompat = OGVCompat;
window.OGVVersion = OGVVersion;
}
module.exports = {
OGVCompat: OGVCompat,
OGVVersion: OGVVersion
};
})();
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var BogoSlow = __webpack_require__(2);
var OGVCompat = {
benchmark: new BogoSlow(),
hasTypedArrays: function() {
// emscripten-compiled code requires typed arrays
return !!window.Uint32Array;
},
hasWebAudio: function() {
return !!(window.AudioContext || window.webkitAudioContext);
},
hasFlash: function() {
if (navigator.userAgent.indexOf('Trident') !== -1) {
// We only do the ActiveX test because we only need Flash in
// Internet Explorer 10/11. Other browsers use Web Audio directly
// (Edge, Safari) or native playback, so there's no need to test
// other ways of loading Flash.
try {
var obj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
return true;
} catch(e) {
return false;
}
}
return false;
},
hasAudio: function() {
return this.hasWebAudio() || this.hasFlash();
},
isBlacklisted: function(userAgent) {
// JIT bugs in old Safari versions
var blacklist = [
/\(i.* OS [67]_.* like Mac OS X\).* Mobile\/.* Safari\//,
/\(Macintosh.* Version\/6\..* Safari\/\d/
];
var blacklisted = false;
blacklist.forEach(function(regex) {
if (userAgent.match(regex)) {
blacklisted = true;
}
});
return blacklisted;
},
isSlow: function() {
return this.benchmark.slow;
},
isTooSlow: function() {
return this.benchmark.tooSlow;
},
supported: function(component) {
if (component === 'OGVDecoder') {
return (this.hasTypedArrays() && !this.isBlacklisted(navigator.userAgent));
}
if (component === 'OGVPlayer') {
return (this.supported('OGVDecoder') && this.hasAudio() && !this.isTooSlow());
}
return false;
}
};
module.exports = OGVCompat;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
/**
* A quick CPU/JS engine benchmark to guesstimate whether we're
* fast enough to handle 360p video in JavaScript.
*/
function BogoSlow() {
var self = this;
var timer;
// FIXME: avoid to use window scope here
if (window.performance && window.performance.now) {
timer = function() {
return window.performance.now();
};
} else {
timer = function() {
return Date.now();
};
}
var savedSpeed = null;
function run() {
var ops = 0;
var fibonacci = function(n) {
ops++;
if (n < 2) {
return n;
} else {
return fibonacci(n - 2) + fibonacci(n - 1);
}
};
var start = timer();
fibonacci(30);
var delta = timer() - start;
savedSpeed = (ops / delta);
}
/**
* Return a scale value of operations/sec from the benchmark.
* If the benchmark has already been run, uses a memoized result.
*
* @property {number}
*/
Object.defineProperty(self, 'speed', {
get: function() {
if (savedSpeed === null) {
run();
}
return savedSpeed;
}
});
/**
* Return the defined cutoff speed value for 'slow' devices,
* based on results measured from some test devices.
*
* @property {number}
*/
Object.defineProperty(self, 'slowCutoff', {
get: function() {
// 2012 Retina MacBook Pro (Safari 7) ~150,000
// 2009 Dell T5500 (IE 11) ~100,000
// iPad Air (iOS 7) ~65,000
// 2010 MBP / OS X 10.9 (Safari 7) ~62,500
// 2010 MBP / Win7 VM (IE 11) ~50,000+-
// ^ these play 360p ok
// ----------- line of moderate doom ----------
return 50000;
// v these play 160p ok
// iPad Mini non-Retina (iOS 8 beta) ~25,000
// Dell Inspiron Duo (IE 11) ~25,000
// Surface RT (IE 11) ~18,000
// iPod Touch 5th-gen (iOS 8 beta) ~16,000
}
});
/**
* Return the defined cutoff speed value for 'too slow' devices,
* based on results measured from some test devices.
*
* No longer used.
*
* @property {number}
* @deprecated
*/
Object.defineProperty(self, 'tooSlowCutoff', {
get: function() {
return 0;
}
});
/**
* 'Slow' devices can play audio and should sorta play our
* extra-tiny Wikimedia 160p15 transcodes
*
* @property {boolean}
*/
Object.defineProperty(self, 'slow', {
get: function() {
return (self.speed < self.slowCutoff);
}
});
/**
* 'Too slow' devices aren't reliable at all
*
* @property {boolean}
*/
Object.defineProperty(self, 'tooSlow', {
get: function() {
return (self.speed < self.tooSlowCutoff);
}
});
}
module.exports = BogoSlow;
/***/ })
/******/ ]);

View file

@ -0,0 +1,701 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var OGVWorkerSupport = __webpack_require__(2);
var proxy = new OGVWorkerSupport([
'loadedMetadata',
'audioFormat',
'audioBuffer',
'cpuTime'
], {
init: function(args, callback) {
this.target.init(callback);
},
processHeader: function(args, callback) {
this.target.processHeader(args[0], function(ok) {
callback([ok]);
});
},
processAudio: function(args, callback) {
this.target.processAudio(args[0], function(ok) {
callback([ok]);
});
}
});
module.exports = proxy;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
var OGVLoader = __webpack_require__(3);
/**
* Web Worker wrapper for codec fun
*/
function OGVWorkerSupport(propList, handlers) {
var transferables = (function() {
var buffer = new ArrayBuffer(1024),
bytes = new Uint8Array(buffer);
try {
postMessage({
action: 'transferTest',
bytes: bytes
}, [buffer]);
if (buffer.byteLength) {
// No transferable support
return false;
} else {
return true;
}
} catch (e) {
return false;
}
})();
var self = this;
self.target = null;
var sentProps = {},
pendingEvents = [];
function copyObject(obj) {
var copy = {};
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
copy[prop] = obj[prop];
}
}
return copy;
}
function copyAudioBuffer(data) {
if (data == null) {
return null;
} else {
// Array of Float32Arrays
var copy = [];
for (var i = 0; i < data.length; i++) {
copy[i] = new Float32Array(data[i]);
}
return copy;
}
}
function handleEvent(data) {
handlers[data.action].call(self, data.args, function(args) {
args = args || [];
// Collect and send any changed properties...
var props = {},
transfers = [];
propList.forEach(function(propName) {
var propVal = self.target[propName];
if (sentProps[propName] !== propVal) {
// Save this value for later reference...
sentProps[propName] = propVal;
if (propName == 'duration' && isNaN(propVal) && isNaN(sentProps[propName])) {
// NaN is not === itself. Nice!
// no need to update it here.
} else if (propName == 'audioBuffer') {
// Don't send the entire emscripten heap!
propVal = copyAudioBuffer(propVal);
props[propName] = propVal;
if (propVal) {
for (var i = 0; i < propVal.length; i++) {
transfers.push(propVal[i].buffer);
}
}
} else if (propName == 'frameBuffer') {
// We already extract ahead of time now,
// so transfer the small buffers.
props[propName] = propVal;
if (propVal) {
transfers.push(propVal.y.bytes.buffer);
transfers.push(propVal.u.bytes.buffer);
transfers.push(propVal.v.bytes.buffer);
}
} else {
props[propName] = propVal;
}
}
});
var out = {
action: 'callback',
callbackId: data.callbackId,
args: args,
props: props
};
if (transferables) {
postMessage(out, transfers);
} else {
postMessage(out);
}
});
}
handlers.construct = function(args, callback) {
var className = args[0],
options = args[1];
OGVLoader.loadClass(className, function(classObj) {
self.target = new classObj(options);
callback();
while (pendingEvents.length) {
handleEvent(pendingEvents.shift());
}
});
};
addEventListener('message', function workerOnMessage(event) {
var data = event.data;
if (!data || typeof data !== 'object') {
// invalid
return;
} else if (data.action == 'transferTest') {
// ignore
} else if (typeof data.action !== 'string' || typeof data.callbackId !== 'string' || typeof data.args !== 'object') {
console.log('invalid message data', data);
} else if (!(data.action in handlers)) {
console.log('invalid message action', data.action);
} else if (data.action == 'construct') {
// always handle constructor
handleEvent(data);
} else if (!self.target) {
// queue until constructed
pendingEvents.push(data);
} else {
handleEvent(data);
}
});
}
module.exports = OGVWorkerSupport;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
var OGVVersion = ("1.4.2-20170425024925-504d7197");
(function() {
var global = this;
var scriptMap = {
OGVDemuxerOgg: 'ogv-demuxer-ogg.js',
OGVDemuxerOggW: 'ogv-demuxer-ogg-wasm.js',
OGVDemuxerWebM: 'ogv-demuxer-webm.js',
OGVDemuxerWebMW: 'ogv-demuxer-webm-wasm.js',
OGVDecoderAudioOpus: 'ogv-decoder-audio-opus.js',
OGVDecoderAudioOpusW: 'ogv-decoder-audio-opus-wasm.js',
OGVDecoderAudioVorbis: 'ogv-decoder-audio-vorbis.js',
OGVDecoderAudioVorbisW: 'ogv-decoder-audio-vorbis-wasm.js',
OGVDecoderVideoTheora: 'ogv-decoder-video-theora.js',
OGVDecoderVideoTheoraW: 'ogv-decoder-video-theora-wasm.js',
OGVDecoderVideoVP8: 'ogv-decoder-video-vp8.js',
OGVDecoderVideoVP8W: 'ogv-decoder-video-vp8-wasm.js',
OGVDecoderVideoVP8MT: 'ogv-decoder-video-vp8-mt.js',
OGVDecoderVideoVP9: 'ogv-decoder-video-vp9.js',
OGVDecoderVideoVP9W: 'ogv-decoder-video-vp9-wasm.js',
OGVDecoderVideoVP9MT: 'ogv-decoder-video-vp9-mt.js'
};
// @fixme make this less awful
var proxyTypes = {
OGVDecoderAudioOpus: 'audio',
OGVDecoderAudioOpusW: 'audio',
OGVDecoderAudioVorbis: 'audio',
OGVDecoderAudioVorbisW: 'audio',
OGVDecoderVideoTheora: 'video',
OGVDecoderVideoTheoraW: 'video',
OGVDecoderVideoVP8: 'video',
OGVDecoderVideoVP8W: 'video',
OGVDecoderVideoVP9: 'video',
OGVDecoderVideoVP9W: 'video'
};
var proxyInfo = {
audio: {
proxy: __webpack_require__(4),
worker: 'ogv-worker-audio.js',
},
video: {
proxy: __webpack_require__(6),
worker: 'ogv-worker-video.js'
}
}
function urlForClass(className) {
var scriptName = scriptMap[className];
if (scriptName) {
return urlForScript(scriptName);
} else {
throw new Error('asked for URL for unknown class ' + className);
}
};
function urlForScript(scriptName) {
if (scriptName) {
var base = OGVLoader.base;
if (base === undefined) {
base = '';
} else {
base += '/';
}
return base + scriptName + '?version=' + encodeURIComponent(OGVVersion);
} else {
throw new Error('asked for URL for unknown script ' + scriptName);
}
};
var scriptStatus = {},
scriptCallbacks = {};
function loadWebScript(src, callback) {
if (scriptStatus[src] == 'done') {
callback();
} else if (scriptStatus[src] == 'loading') {
scriptCallbacks[src].push(callback);
} else {
scriptStatus[src] = 'loading';
scriptCallbacks[src] = [callback];
var scriptNode = document.createElement('script');
function done(event) {
var callbacks = scriptCallbacks[src];
delete scriptCallbacks[src];
scriptStatus[src] = 'done';
callbacks.forEach(function(cb) {
cb();
});
}
scriptNode.addEventListener('load', done);
scriptNode.addEventListener('error', done);
scriptNode.src = src;
document.querySelector('head').appendChild(scriptNode);
}
}
function loadWebAssembly(src, callback) {
if (!src.match(/-wasm\.js/)) {
callback(null);
} else {
var wasmSrc = src.replace(/-wasm\.js/, '-wasm.wasm');
var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
callback(xhr.response);
};
xhr.onerror = function() {
callback(null);
};
xhr.open('GET', wasmSrc);
xhr.send();
}
}
function defaultBase() {
if (typeof global.window === 'object') {
// for browser, try to autodetect
var scriptNodes = document.querySelectorAll('script'),
regex = /^(?:|(.*)\/)ogv(?:-support)?\.js(?:\?|#|$)/,
path,
matches;
for (var i = 0; i < scriptNodes.length; i++) {
path = scriptNodes[i].getAttribute('src');
if (path) {
matches = path.match(regex);
if (matches) {
return matches[1];
}
}
}
return undefined; // current dir
} else {
// for workers, assume current directory
// if not a worker, too bad.
return undefined;
}
}
var OGVLoader = {
base: defaultBase(),
loadClass: function(className, callback, options) {
options = options || {};
if (options.worker) {
this.workerProxy(className, callback);
return;
}
var url = urlForClass(className);
loadWebAssembly(url, function(wasmBinary) {
function wasmClassWrapper(options) {
options = options || {};
if (wasmBinary !== null) {
options.wasmBinary = wasmBinary;
}
return new global[className](options);
}
if (typeof global[className] === 'function') {
// already loaded!
callback(wasmClassWrapper);
} else if (typeof global.window === 'object') {
loadWebScript(url, function() {
callback(wasmClassWrapper);
});
} else if (typeof global.importScripts === 'function') {
// worker has convenient sync importScripts
global.importScripts(url);
callback(wasmClassWrapper);
}
});
},
workerProxy: function(className, callback) {
var proxyType = proxyTypes[className],
info = proxyInfo[proxyType];
if (!info) {
throw new Error('Requested worker for class with no proxy: ' + className);
}
var proxyClass = info.proxy,
workerScript = info.worker,
codecUrl = urlForScript(scriptMap[className]),
workerUrl = urlForScript(workerScript),
worker;
var construct = function(options) {
return new proxyClass(worker, className, options);
};
if (workerUrl.match(/^https?:|\/\//i)) {
// Can't load workers natively cross-domain, but if CORS
// is set up we can fetch the worker stub and the desired
// class and load them from a blob.
var getCodec,
getWorker,
codecResponse,
workerResponse,
codecLoaded = false,
workerLoaded = false,
blob;
function completionCheck() {
if ((codecLoaded == true) && (workerLoaded == true)) {
try {
blob = new Blob([codecResponse + " " + workerResponse], {type: 'application/javascript'});
} catch (e) { // Backwards-compatibility
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new BlobBuilder();
blob.append(codecResponse + " " + workerResponse);
blob = blob.getBlob();
}
// Create the web worker
worker = new Worker(URL.createObjectURL(blob));
callback(construct);
}
}
// Load the codec
getCodec = new XMLHttpRequest();
getCodec.open("GET", codecUrl, true);
getCodec.onreadystatechange = function() {
if(getCodec.readyState == 4 && getCodec.status == 200) {
codecResponse = getCodec.responseText;
// Update the codec response loaded flag
codecLoaded = true;
completionCheck();
}
};
getCodec.send();
// Load the worker
getWorker = new XMLHttpRequest();
getWorker.open("GET", workerUrl, true);
getWorker.onreadystatechange = function() {
if(getWorker.readyState == 4 && getWorker.status == 200) {
workerResponse = getWorker.responseText;
// Update the worker response loaded flag
workerLoaded = true;
completionCheck();
}
};
getWorker.send();
} else {
// Local URL; load it directly for simplicity.
worker = new Worker(workerUrl);
callback(construct);
}
}
};
module.exports = OGVLoader;
})();
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var OGVProxyClass = __webpack_require__(5);
var OGVDecoderAudioProxy = OGVProxyClass({
loadedMetadata: false,
audioFormat: null,
audioBuffer: null,
cpuTime: 0
}, {
init: function(callback) {
this.proxy('init', [], callback);
},
processHeader: function(data, callback) {
this.proxy('processHeader', [data], callback, [data]);
},
processAudio: function(data, callback) {
this.proxy('processAudio', [data], callback, [data]);
},
close: function() {
this.terminate();
}
});
module.exports = OGVDecoderAudioProxy;
/***/ }),
/* 5 */
/***/ (function(module, exports) {
/**
* Proxy object for web worker interface for codec classes.
*
* Used by the high-level player interface.
*
* @author Brion Vibber <brion@pobox.com>
* @copyright 2015
* @license MIT-style
*/
function OGVProxyClass(initialProps, methods) {
return function(worker, className, options) {
options = options || {};
var self = this;
var transferables = (function() {
var buffer = new ArrayBuffer(1024),
bytes = new Uint8Array(buffer);
try {
worker.postMessage({
action: 'transferTest',
bytes: bytes
}, [buffer]);
if (buffer.byteLength) {
// No transferable support
return false;
} else {
return true;
}
} catch (e) {
return false;
}
})();
// Set up proxied property getters
var props = {};
for (var iPropName in initialProps) {
if (initialProps.hasOwnProperty(iPropName)) {
(function(propName) {
props[propName] = initialProps[propName];
Object.defineProperty(self, propName, {
get: function getProperty() {
return props[propName];
}
});
})(iPropName);
}
}
// Current player wants to avoid async confusion.
var processingQueue = 0;
Object.defineProperty(self, 'processing', {
get: function() {
return (processingQueue > 0);
}
});
// Set up proxied methods
for (var method in methods) {
if (methods.hasOwnProperty(method)) {
self[method] = methods[method];
}
}
// And some infrastructure!
var messageCount = 0,
pendingCallbacks = {};
this.proxy = function(action, args, callback, transfers) {
if (!worker) {
throw 'Tried to call "' + action + '" method on closed proxy object';
}
var callbackId = 'callback-' + (++messageCount) + '-' + action;
if (callback) {
pendingCallbacks[callbackId] = callback;
}
var out = {
'action': action,
'callbackId': callbackId,
'args': args || []
};
processingQueue++;
if (transferables) {
worker.postMessage(out, transfers || []);
} else {
worker.postMessage(out);
}
};
this.terminate = function() {
if (worker) {
worker.terminate();
worker = null;
processingQueue = 0;
pendingCallbacks = {};
}
};
worker.addEventListener('message', function proxyOnMessage(event) {
processingQueue--;
if (event.data.action !== 'callback') {
// ignore
return;
}
var data = event.data,
callbackId = data.callbackId,
args = data.args,
callback = pendingCallbacks[callbackId];
// Save any updated properties returned to us...
if (data.props) {
for (var propName in data.props) {
if (data.props.hasOwnProperty(propName)) {
props[propName] = data.props[propName];
}
}
}
if (callback) {
delete pendingCallbacks[callbackId];
callback.apply(this, args);
}
});
// Tell the proxy to load and initialize the appropriate class
self.proxy('construct', [className, options], function() {});
return self;
};
}
module.exports = OGVProxyClass;
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
var OGVProxyClass = __webpack_require__(5);
var OGVDecoderVideoProxy = OGVProxyClass({
loadedMetadata: false,
videoFormat: null,
frameBuffer: null,
cpuTime: 0
}, {
init: function(callback) {
this.proxy('init', [], callback);
},
processHeader: function(data, callback) {
this.proxy('processHeader', [data], callback, [data]);
},
processFrame: function(data, callback) {
this.proxy('processFrame', [data], callback, [data]);
},
close: function() {
this.terminate();
}
});
module.exports = OGVDecoderVideoProxy;
/***/ })
/******/ ]);

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,206 @@
importScripts('rlottie-wasm.js');
importScripts('pako-inflate.min.js');
function RLottieItem(reqId, jsString, width, height, fps) {
this.stringOnWasmHeap = null;
this.handle = null;
this.frameCount = 0;
this.reqId = reqId;
this.width = width;
this.height = height;
this.fps = Math.max(1, Math.min(60, fps || 60));
this.dead = false;
this.init(jsString, width, height);
reply('loaded', this.reqId, this.frameCount, this.fps);
}
RLottieItem.prototype.init = function(jsString) {
try {
this.handle = RLottieWorker.Api.init();
this.stringOnWasmHeap = allocate(intArrayFromString(jsString), 'i8', 0);
this.frameCount = RLottieWorker.Api.loadFromData(this.handle, this.stringOnWasmHeap);
RLottieWorker.Api.resize(this.handle, this.width, this.height);
} catch(e) {
console.error('init RLottieItem error:', e);
}
};
RLottieItem.prototype.render = function(frameNo, clamped) {
if(this.dead) return;
if(this.frameCount < frameNo || frameNo < 0) {
return;
}
try {
RLottieWorker.Api.render(this.handle, frameNo);
var bufferPointer = RLottieWorker.Api.buffer(this.handle);
var data = Module.HEAPU8.subarray(bufferPointer, bufferPointer + (this.width * this.height * 4));
if(!clamped) {
clamped = new Uint8ClampedArray(data);
} else {
clamped.set(data);
}
reply('frame', this.reqId, frameNo, clamped);
} catch(e) {
console.error('Render error:', e);
this.dead = true;
}
};
RLottieItem.prototype.destroy = function() {
this.dead = true;
RLottieWorker.Api.destroy(this.handle);
};
var RLottieWorker = (function() {
var worker = {};
worker.Api = {};
function initApi() {
worker.Api = {
init: Module.cwrap('lottie_init', '', []),
destroy: Module.cwrap('lottie_destroy', '', ['number']),
resize: Module.cwrap('lottie_resize', '', ['number', 'number', 'number']),
buffer: Module.cwrap('lottie_buffer', 'number', ['number']),
frameCount: Module.cwrap('lottie_frame_count', 'number', ['number']),
render: Module.cwrap('lottie_render', '', ['number', 'number']),
loadFromData: Module.cwrap('lottie_load_from_data', 'number', ['number', 'number']),
};
}
worker.init = function() {
initApi();
reply('ready');
};
return worker;
}());
Module.onRuntimeInitialized = function() {
RLottieWorker.init();
};
var items = {};
var queryableFunctions = {
loadFromData: function(reqId, url, width, height) {
getUrlContent(url, function(err, data) {
if (err) {
return console.warn('Can\'t fetch file ' + url, err);
}
try {
var json = pako.inflate(data, {to: 'string'});
var json_parsed = JSON.parse(json);
items[reqId] = new RLottieItem(reqId, json, width, height, json_parsed.fr);
} catch (e) {
return console.warn('Invalid file ' + url);
}
});
},
destroy: function(reqId) {
items[reqId].destroy();
delete items[reqId];
},
renderFrame: function(reqId, frameNo, clamped) {
items[reqId].render(frameNo, clamped);
}
};
function defaultReply(message) {
// your default PUBLIC function executed only when main page calls the queryableWorker.postMessage() method directly
// do something
}
/**
* Returns true when run in WebKit derived browsers.
* This is used as a workaround for a memory leak in Safari caused by using Transferable objects to
* transfer data between WebWorkers and the main thread.
* https://github.com/mapbox/mapbox-gl-js/issues/8771
*
* This should be removed once the underlying Safari issue is fixed.
*
* @private
* @param scope {WindowOrWorkerGlobalScope} Since this function is used both on the main thread and WebWorker context,
* let the calling scope pass in the global scope object.
* @returns {boolean}
*/
var _isSafari = null;
function isSafari(scope) {
if(_isSafari == null) {
var userAgent = scope.navigator ? scope.navigator.userAgent : null;
_isSafari = !!scope.safari ||
!!(userAgent && (/\b(iPad|iPhone|iPod)\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));
}
return _isSafari;
}
function reply() {
if(arguments.length < 1) {
throw new TypeError('reply - not enough arguments');
}
var args = Array.prototype.slice.call(arguments, 1);
if(isSafari(self)) {
postMessage({ 'queryMethodListener': arguments[0], 'queryMethodArguments': args });
} else {
var transfer = [];
for(var i = 0; i < args.length; i++) {
if(args[i] instanceof ArrayBuffer) {
transfer.push(args[i]);
}
if(args[i].buffer && args[i].buffer instanceof ArrayBuffer) {
transfer.push(args[i].buffer);
}
}
postMessage({ 'queryMethodListener': arguments[0], 'queryMethodArguments': args }, transfer);
}
}
onmessage = function(oEvent) {
if(oEvent.data instanceof Object && oEvent.data.hasOwnProperty('queryMethod') && oEvent.data.hasOwnProperty('queryMethodArguments')) {
queryableFunctions[oEvent.data.queryMethod].apply(self, oEvent.data.queryMethodArguments);
} else {
defaultReply(oEvent.data);
}
};
function getUrlContent(path, callback) {
try {
var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
if ('responseType' in xhr) {
xhr.responseType = 'arraybuffer';
}
if (xhr.overrideMimeType) {
xhr.overrideMimeType('text/plain; charset=x-user-defined');
}
xhr.onreadystatechange = function (event) {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
callback(null, xhr.response || xhr.responseText);
} else {
callback(new Error('Ajax error: ' + this.status + ' ' + this.statusText));
}
}
};
xhr.send();
} catch (e) {
callback(new Error(e));
}
};

File diff suppressed because it is too large Load diff