Hawk/src/polyfill.js

86 lines
104 KiB
JavaScript
Raw Normal View History

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var process=module.exports={};var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=setTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){currentQueue[queueIndex].run()}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;clearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){setTimeout(drainQueue,0)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],2:[function(require,module,exports){(function(global){"use strict";require("core-js/shim");require("regenerator/runtime");if(global._babelPolyfill){throw new Error("only one instance of babel/polyfill is allowed")}global._babelPolyfill=true}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"core-js/shim":182,"regenerator/runtime":183}],3:[function(require,module,exports){module.exports=function(it){if(typeof it!="function")throw TypeError(it+" is not a function!");return it}},{}],4:[function(require,module,exports){var isObject=require("./$.is-object");module.exports=function(it){if(!isObject(it))throw TypeError(it+" is not an object!");return it}},{"./$.is-object":34}],5:[function(require,module,exports){var toIObject=require("./$.to-iobject"),toLength=require("./$.to-length"),toIndex=require("./$.to-index");module.exports=function(IS_INCLUDES){return function($this,el,fromIndex){var O=toIObject($this),length=toLength(O.length),index=toIndex(fromIndex,length),value;if(IS_INCLUDES&&el!=el)while(length>index){value=O[index++];if(value!=value)return true}else for(;length>index;index++)if(IS_INCLUDES||index in O){if(O[index]===el)return IS_INCLUDES||index}return!IS_INCLUDES&&-1}}},{"./$.to-index":70,"./$.to-iobject":72,"./$.to-length":73}],6:[function(require,module,exports){var ctx=require("./$.ctx"),IObject=require("./$.iobject"),toObject=require("./$.to-object"),toLength=require("./$.to-length");module.exports=function(TYPE){var IS_MAP=TYPE==1,IS_FILTER=TYPE==2,IS_SOME=TYPE==3,IS_EVERY=TYPE==4,IS_FIND_INDEX=TYPE==6,NO_HOLES=TYPE==5||IS_FIND_INDEX;return function($this,callbackfn,that){var O=toObject($this),self=IObject(O),f=ctx(callbackfn,that,3),length=toLength(self.length),index=0,result=IS_MAP?Array(length):IS_FILTER?[]:undefined,val,res;for(;length>index;index++)if(NO_HOLES||index in self){val=self[index];res=f(val,index,O);if(TYPE){if(IS_MAP)result[index]=res;else if(res)switch(TYPE){case 3:return true;case 5:return val;case 6:return index;case 2:result.push(val)}else if(IS_EVERY)return false}}return IS_FIND_INDEX?-1:IS_SOME||IS_EVERY?IS_EVERY:result}}},{"./$.ctx":15,"./$.iobje
var args=[],i=1;while(arguments.length>i)args.push(arguments[i++]);queue[++counter]=function(){invoke(typeof fn=="function"?fn:Function(fn),args)};defer(counter);return counter};clearTask=function clearImmediate(id){delete queue[id]};if(require("./$.cof")(process)=="process"){defer=function(id){process.nextTick(ctx(run,id,1))}}else if(MessageChannel){channel=new MessageChannel;port=channel.port2;channel.port1.onmessage=listner;defer=ctx(port.postMessage,port,1)}else if(global.addEventListener&&typeof postMessage=="function"&&!global.importScript){defer=function(id){global.postMessage(id+"","*")};global.addEventListener("message",listner,false)}else if(ONREADYSTATECHANGE in cel("script")){defer=function(id){html.appendChild(cel("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this);run.call(id)}}}else{defer=function(id){setTimeout(ctx(run,id,1),0)}}}module.exports={set:setTask,clear:clearTask}},{"./$.cof":9,"./$.ctx":15,"./$.dom-create":18,"./$.global":26,"./$.html":29,"./$.invoke":30}],70:[function(require,module,exports){var toInteger=require("./$.to-integer"),max=Math.max,min=Math.min;module.exports=function(index,length){index=toInteger(index);return index<0?max(index+length,0):min(index,length)}},{"./$.to-integer":71}],71:[function(require,module,exports){var ceil=Math.ceil,floor=Math.floor;module.exports=function(it){return isNaN(it=+it)?0:(it>0?floor:ceil)(it)}},{}],72:[function(require,module,exports){var IObject=require("./$.iobject"),defined=require("./$.defined");module.exports=function(it){return IObject(defined(it))}},{"./$.defined":17,"./$.iobject":31}],73:[function(require,module,exports){var toInteger=require("./$.to-integer"),min=Math.min;module.exports=function(it){return it>0?min(toInteger(it),9007199254740991):0}},{"./$.to-integer":71}],74:[function(require,module,exports){var defined=require("./$.defined");module.exports=function(it){return Object(defined(it))}},{"./$.defined":17}],75:[function(require,module,exports){var id=0,px=Math.random();module.exports=function(key){return"Symbol(".concat(key===undefined?"":key,")_",(++id+px).toString(36))}},{}],76:[function(require,module,exports){var UNSCOPABLES=require("./$.wks")("unscopables");if(!(UNSCOPABLES in[]))require("./$.hide")(Array.prototype,UNSCOPABLES,{});module.exports=function(key){[][UNSCOPABLES][key]=true}},{"./$.hide":28,"./$.wks":77}],77:[function(require,module,exports){var store=require("./$.shared")("wks"),Symbol=require("./$.global").Symbol;module.exports=function(name){return store[name]||(store[name]=Symbol&&Symbol[name]||(Symbol||require("./$.uid"))("Symbol."+name))}},{"./$.global":26,"./$.shared":58,"./$.uid":75}],78:[function(require,module,exports){var classof=require("./$.classof"),ITERATOR=require("./$.wks")("iterator"),Iterators=require("./$.iterators");module.exports=require("./$.core").getIteratorMethod=function(it){if(it!=undefined)return it[ITERATOR]||it["@@iterator"]||Iterators[classof(it)]}},{"./$.classof":8,"./$.core":14,"./$.iterators":41,"./$.wks":77}],79:[function(require,module,exports){"use strict";var $=require("./$"),SUPPORT_DESC=require("./$.support-desc"),createDesc=require("./$.property-desc"),html=require("./$.html"),cel=require("./$.dom-create"),has=require("./$.has"),cof=require("./$.cof"),$def=require("./$.def"),invoke=require("./$.invoke"),arrayMethod=require("./$.array-methods"),IE_PROTO=require("./$.uid")("__proto__"),isObject=require("./$.is-object"),anObject=require("./$.an-object"),aFunction=require("./$.a-function"),toObject=require("./$.to-object"),toIObject=require("./$.to-iobject"),toInteger=require("./$.to-integer"),toIndex=require("./$.to-index"),toLength=require("./$.to-length"),IObject=require("./$.iobject"),fails=require("./$.fails"),ObjectProto=Object.prototype,A=[],_slice=A.slice,_join=A.join,defineProperty=$.setDesc,getOwnDescriptor=$.getDesc,defineProperties=$.setDescs,$indexOf=require("./$.array-includes")(false),factories={},IE8_DOM_DEFINE;if(!SUPPORT_DESC){IE8_DOM_DEFINE=!fails(function(){return defineProperty(cel("div"),"a",{get:function(){return 7}}).a!=7});$.setDesc=funct
$def($def.S,"Reflect",{construct:function construct(Target,args){aFunction(Target);if(arguments.length<3){if(args!=undefined)switch(anObject(args).length){case 0:return new Target;case 1:return new Target(args[0]);case 2:return new Target(args[0],args[1]);case 3:return new Target(args[0],args[1],args[2]);case 4:return new Target(args[0],args[1],args[2],args[3])}var $args=[null];$args.push.apply($args,args);return new(bind.apply(Target,$args))}var proto=aFunction(arguments[2]).prototype,instance=$.create(isObject(proto)?proto:Object.prototype),result=Function.apply.call(Target,instance,args);return isObject(result)?result:instance}})},{"./$":42,"./$.a-function":3,"./$.an-object":4,"./$.core":14,"./$.def":16,"./$.is-object":34}],135:[function(require,module,exports){var $=require("./$"),$def=require("./$.def"),anObject=require("./$.an-object");$def($def.S+$def.F*require("./$.fails")(function(){Reflect.defineProperty($.setDesc({},1,{value:1}),1,{value:2})}),"Reflect",{defineProperty:function defineProperty(target,propertyKey,attributes){anObject(target);try{$.setDesc(target,propertyKey,attributes);return true}catch(e){return false}}})},{"./$":42,"./$.an-object":4,"./$.def":16,"./$.fails":21}],136:[function(require,module,exports){var $def=require("./$.def"),getDesc=require("./$").getDesc,anObject=require("./$.an-object");$def($def.S,"Reflect",{deleteProperty:function deleteProperty(target,propertyKey){var desc=getDesc(anObject(target),propertyKey);return desc&&!desc.configurable?false:delete target[propertyKey]}})},{"./$":42,"./$.an-object":4,"./$.def":16}],137:[function(require,module,exports){"use strict";var $def=require("./$.def"),anObject=require("./$.an-object");var Enumerate=function(iterated){this._t=anObject(iterated);this._i=0;var keys=this._k=[],key;for(key in iterated)keys.push(key)};require("./$.iter-create")(Enumerate,"Object",function(){var that=this,keys=that._k,key;do{if(that._i>=keys.length)return{value:undefined,done:true}}while(!((key=keys[that._i++])in that._t));return{value:key,done:false}});$def($def.S,"Reflect",{enumerate:function enumerate(target){return new Enumerate(target)}})},{"./$.an-object":4,"./$.def":16,"./$.iter-create":37}],138:[function(require,module,exports){var $=require("./$"),$def=require("./$.def"),anObject=require("./$.an-object");$def($def.S,"Reflect",{getOwnPropertyDescriptor:function getOwnPropertyDescriptor(target,propertyKey){return $.getDesc(anObject(target),propertyKey)}})},{"./$":42,"./$.an-object":4,"./$.def":16}],139:[function(require,module,exports){var $def=require("./$.def"),getProto=require("./$").getProto,anObject=require("./$.an-object");$def($def.S,"Reflect",{getPrototypeOf:function getPrototypeOf(target){return getProto(anObject(target))}})},{"./$":42,"./$.an-object":4,"./$.def":16}],140:[function(require,module,exports){var $=require("./$"),has=require("./$.has"),$def=require("./$.def"),isObject=require("./$.is-object"),anObject=require("./$.an-object");function get(target,propertyKey){var receiver=arguments.length<3?target:arguments[2],desc,proto;if(anObject(target)===receiver)return target[propertyKey];if(desc=$.getDesc(target,propertyKey))return has(desc,"value")?desc.value:desc.get!==undefined?desc.get.call(receiver):undefined;if(isObject(proto=$.getProto(target)))return get(proto,propertyKey,receiver)}$def($def.S,"Reflect",{get:get})},{"./$":42,"./$.an-object":4,"./$.def":16,"./$.has":27,"./$.is-object":34}],141:[function(require,module,exports){var $def=require("./$.def");$def($def.S,"Reflect",{has:function has(target,propertyKey){return propertyKey in target}})},{"./$.def":16}],142:[function(require,module,exports){var $def=require("./$.def"),anObject=require("./$.an-object"),$isExtensible=Object.isExtensible;$def($def.S,"Reflect",{isExtensible:function isExtensible(target){anObject(target);return $isExtensible?$isExtensible(target):true}})},{"./$.an-object":4,"./$.def":16}],143:[function(require,module,exports){var $def=require("./$.def");$def($def.S,"Reflect",{ownKeys:require("./$.own-keys")})},{"./$.def":16,"./$.own-keys":50}],144:[function(require,mod
function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype;GeneratorFunction.prototype=Gp.constructor=GeneratorFunctionPrototype;GeneratorFunctionPrototype.constructor=GeneratorFunction;GeneratorFunction.displayName="GeneratorFunction";function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){prototype[method]=function(arg){return this._invoke(method,arg)}})}runtime.isGeneratorFunction=function(genFun){var ctor=typeof genFun==="function"&&genFun.constructor;return ctor?ctor===GeneratorFunction||(ctor.displayName||ctor.name)==="GeneratorFunction":false};runtime.mark=function(genFun){genFun.__proto__=GeneratorFunctionPrototype;genFun.prototype=Object.create(Gp);return genFun};runtime.awrap=function(arg){return new AwaitArgument(arg)};function AwaitArgument(arg){this.arg=arg}function AsyncIterator(generator){function invoke(method,arg){var result=generator[method](arg);var value=result.value;return value instanceof AwaitArgument?Promise.resolve(value.arg).then(invokeNext,invokeThrow):Promise.resolve(value).then(function(unwrapped){result.value=unwrapped;return result})}if(typeof process==="object"&&process.domain){invoke=process.domain.bind(invoke)}var invokeNext=invoke.bind(generator,"next");var invokeThrow=invoke.bind(generator,"throw");var invokeReturn=invoke.bind(generator,"return");var previousPromise;function enqueue(method,arg){var enqueueResult=previousPromise?previousPromise.then(function(){return invoke(method,arg)}):new Promise(function(resolve){resolve(invoke(method,arg))});previousPromise=enqueueResult["catch"](function(ignored){});return enqueueResult}this._invoke=enqueue}defineIteratorMethods(AsyncIterator.prototype);runtime.async=function(innerFn,outerFn,self,tryLocsList){var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList));return runtime.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next()})};function makeInvokeMethod(innerFn,self,context){var state=GenStateSuspendedStart;return function invoke(method,arg){if(state===GenStateExecuting){throw new Error("Generator is already running")}if(state===GenStateCompleted){if(method==="throw"){throw arg}return doneResult()}while(true){var delegate=context.delegate;if(delegate){if(method==="return"||method==="throw"&&delegate.iterator[method]===undefined){context.delegate=null;var returnMethod=delegate.iterator["return"];if(returnMethod){var record=tryCatch(returnMethod,delegate.iterator,arg);if(record.type==="throw"){method="throw";arg=record.arg;continue}}if(method==="return"){continue}}var record=tryCatch(delegate.iterator[method],delegate.iterator,arg);if(record.type==="throw"){context.delegate=null;method="throw";arg=record.arg;continue}method="next";arg=undefined;var info=record.arg;if(info.done){context[delegate.resultName]=info.value;context.next=delegate.nextLoc}else{state=GenStateSuspendedYield;return info}context.delegate=null}if(method==="next"){if(state===GenStateSuspendedYield){context.sent=arg}else{context.sent=undefined}}else if(method==="throw"){if(state===GenStateSuspendedStart){state=GenStateCompleted;throw arg}if(context.dispatchException(arg)){method="next";arg=undefined}}else if(method==="return"){context.abrupt("return",arg)}state=GenStateExecuting;var record=tryCatch(innerFn,self,context);if(record.type==="normal"){state=context.done?GenStateCompleted:GenStateSuspendedYield;var info={value:record.arg,done:context.done};if(record.arg===ContinueSentinel){if(context.delegate&&method==="next"){arg=undefined}}else{return info}}else if(record.type==="throw"){state=GenStateCompleted;method="throw";arg=record.arg}}}}defineIteratorMethods(Gp);Gp[iteratorSymbol]=function(){return this};Gp.toString=function(){return"[object Generator]"};function pushTryEntry(locs){var entry={tryLoc:locs[0]};if(1 in locs){entry.catchLoc=locs[1]}if(2 in locs){entry.finallyLoc=locs[2];entry.afterLoc=locs[3]}this.tryEntries.push(entry)}function resetTryEntry(entry){var record
(function (ELEMENT) {
ELEMENT.matches = ELEMENT.matches || ELEMENT.mozMatchesSelector || ELEMENT.msMatchesSelector || ELEMENT.oMatchesSelector || ELEMENT.webkitMatchesSelector;
ELEMENT.closest = ELEMENT.closest || function closest(selector) {
var element = this;
while (element) {
if (element.matches(selector)) {
break;
}
element = element.parentElement;
}
return element;
};
}(Element.prototype));
window.needsShim = false;
function shimDirectory(directory) {
if (!directory.getFilesAndDirectories) {
window.needsShim = true;
directory.toString = function() { return '[object Directory]' };
directory.getFilesAndDirectories = function getFilesAndDirectories() {
var current = (this.path || '') + this.name;
var children = [];
return new Promise(function(resolve, reject) {
var request = sdcard.enumerate(current);
request.onsuccess = function() {
if (!this.result) {
if (this.done) resolve(children);
else this.continue();
return;
}
var normalized = this.result.name.replace('/sdcard/', '');
var parts = normalized.split('/');
// immediate children files
if (parts.slice(0, -1).join('/') === current) {
var file = new File([this.result], parts[parts.length - 1], {
type: this.result.type
});
Object.defineProperty(file, 'path', {
value: parts.slice(0, -1).join('/') + '/',
configurable: true,
enumerable: true
});
children.push(file);
// Directories
} else if (normalized.indexOf(current) === 0) {
var name = normalized.slice(current.length).replace(/^\//, '').split('/')[0];
var exists = children.some(function(child) {
return child.name === name
});
if (!exists) {
var dir = Object.assign({}, directory);
dir.name = name;
dir.path = current + '/';
children.push(dir);
}
}
if (this.done) return resolve(children);
else this.continue();
}
request.onerror = reject;
});
}
}
return directory;
}