mirrors*� (function(a,b){ "use strict"; var c=a.Array; var d=a.isNaN; var e=a.JSON.stringify; var f=a.Map.prototype.entries; var g=(new a.Map).entries().next; var h=(new a.Set).values().next; var i=a.Set.prototype.values; var j={ UNDEFINED_TYPE:'undefined', NULL_TYPE:'null', BOOLEAN_TYPE:'boolean', NUMBER_TYPE:'number', STRING_TYPE:'string', SYMBOL_TYPE:'symbol', OBJECT_TYPE:'object', FUNCTION_TYPE:'function', REGEXP_TYPE:'regexp', ERROR_TYPE:'error', PROPERTY_TYPE:'property', INTERNAL_PROPERTY_TYPE:'internalProperty', FRAME_TYPE:'frame', SCRIPT_TYPE:'script', CONTEXT_TYPE:'context', SCOPE_TYPE:'scope', PROMISE_TYPE:'promise', MAP_TYPE:'map', SET_TYPE:'set', ITERATOR_TYPE:'iterator', GENERATOR_TYPE:'generator', } function MakeMirror(k){ var l; if((k===(void 0))){ l=new UndefinedMirror(); }else if((k===null)){ l=new NullMirror(); }else if((typeof(k)==='boolean')){ l=new BooleanMirror(k); }else if((typeof(k)==='number')){ l=new NumberMirror(k); }else if((typeof(k)==='string')){ l=new StringMirror(k); }else if((typeof(k)==='symbol')){ l=new SymbolMirror(k); }else if((%_IsArray(k))){ l=new ArrayMirror(k); }else if((%IsDate(k))){ l=new DateMirror(k); }else if((%IsFunction(k))){ l=new FunctionMirror(k); }else if(%IsRegExp(k)){ l=new RegExpMirror(k); }else if((%_ClassOf(k)==='Error')){ l=new ErrorMirror(k); }else if((%_ClassOf(k)==='Script')){ l=new ScriptMirror(k); }else if((%_ClassOf(k)==='Map')||(%_ClassOf(k)==='WeakMap')){ l=new MapMirror(k); }else if((%_ClassOf(k)==='Set')||(%_ClassOf(k)==='WeakSet')){ l=new SetMirror(k); }else if((%_ClassOf(k)==='Map Iterator')||(%_ClassOf(k)==='Set Iterator')){ l=new IteratorMirror(k); }else if(%is_promise(k)){ l=new PromiseMirror(k); }else if((%_ClassOf(k)==='Generator')){ l=new GeneratorMirror(k); }else{ l=new ObjectMirror(k,j.OBJECT_TYPE); } return l; } function GetUndefinedMirror(){ return MakeMirror((void 0)); } function inherits(m,n){ var o=function(){}; o.prototype=n.prototype; m.super_=n.prototype; m.prototype=new o(); m.prototype.constructor=m; } var p=80; var q={}; q.Data=0; q.Accessor=1; var r={}; r.None=0; r.ReadOnly=1; r.DontEnum=2; r.DontDelete=4; var s={Global:0, Local:1, With:2, Closure:3, Catch:4, Block:5, Script:6, Eval:7, Module:8, }; function Mirror(t){ this.type_=t; } Mirror.prototype.type=function(){ return this.type_; }; Mirror.prototype.isValue=function(){ return this instanceof ValueMirror; }; Mirror.prototype.isUndefined=function(){ return this instanceof UndefinedMirror; }; Mirror.prototype.isNull=function(){ return this instanceof NullMirror; }; Mirror.prototype.isBoolean=function(){ return this instanceof BooleanMirror; }; Mirror.prototype.isNumber=function(){ return this instanceof NumberMirror; }; Mirror.prototype.isString=function(){ return this instanceof StringMirror; }; Mirror.prototype.isSymbol=function(){ return this instanceof SymbolMirror; }; Mirror.prototype.isObject=function(){ return this instanceof ObjectMirror; }; Mirror.prototype.isFunction=function(){ return this instanceof FunctionMirror; }; Mirror.prototype.isUnresolvedFunction=function(){ return this instanceof UnresolvedFunctionMirror; }; Mirror.prototype.isArray=function(){ return this instanceof ArrayMirror; }; Mirror.prototype.isDate=function(){ return this instanceof DateMirror; }; Mirror.prototype.isRegExp=function(){ return this instanceof RegExpMirror; }; Mirror.prototype.isError=function(){ return this instanceof ErrorMirror; }; Mirror.prototype.isPromise=function(){ return this instanceof PromiseMirror; }; Mirror.prototype.isGenerator=function(){ return this instanceof GeneratorMirror; }; Mirror.prototype.isProperty=function(){ return this instanceof PropertyMirror; }; Mirror.prototype.isInternalProperty=function(){ return this instanceof InternalPropertyMirror; }; Mirror.prototype.isFrame=function(){ return this instanceof FrameMirror; }; Mirror.prototype.isScript=function(){ return this instanceof ScriptMirror; }; Mirror.prototype.isContext=function(){ return this instanceof ContextMirror; }; Mirror.prototype.isScope=function(){ return this instanceof ScopeMirror; }; Mirror.prototype.isMap=function(){ return this instanceof MapMirror; }; Mirror.prototype.isSet=function(){ return this instanceof SetMirror; }; Mirror.prototype.isIterator=function(){ return this instanceof IteratorMirror; }; Mirror.prototype.toText=function(){ return"#<"+this.constructor.name+">"; }; function ValueMirror(t,k){ %_Call(Mirror,this,t); this.value_=k; } inherits(ValueMirror,Mirror); ValueMirror.prototype.isPrimitive=function(){ var t=this.type(); return t==='undefined'|| t==='null'|| t==='boolean'|| t==='number'|| t==='string'|| t==='symbol'; }; ValueMirror.prototype.value=function(){ return this.value_; }; function UndefinedMirror(){ %_Call(ValueMirror,this,j.UNDEFINED_TYPE,(void 0)); } inherits(UndefinedMirror,ValueMirror); UndefinedMirror.prototype.toText=function(){ return'undefined'; }; function NullMirror(){ %_Call(ValueMirror,this,j.NULL_TYPE,null); } inherits(NullMirror,ValueMirror); NullMirror.prototype.toText=function(){ return'null'; }; function BooleanMirror(k){ %_Call(ValueMirror,this,j.BOOLEAN_TYPE,k); } inherits(BooleanMirror,ValueMirror); BooleanMirror.prototype.toText=function(){ return this.value_?'true':'false'; }; function NumberMirror(k){ %_Call(ValueMirror,this,j.NUMBER_TYPE,k); } inherits(NumberMirror,ValueMirror); NumberMirror.prototype.toText=function(){ return %NumberToString(this.value_); }; function StringMirror(k){ %_Call(ValueMirror,this,j.STRING_TYPE,k); } inherits(StringMirror,ValueMirror); StringMirror.prototype.length=function(){ return this.value_.length; }; StringMirror.prototype.getTruncatedValue=function(u){ if(u!=-1&&this.length()>u){ return this.value_.substring(0,u)+ '... (length: '+this.length()+')'; } return this.value_; }; StringMirror.prototype.toText=function(){ return this.getTruncatedValue(p); }; function SymbolMirror(k){ %_Call(ValueMirror,this,j.SYMBOL_TYPE,k); } inherits(SymbolMirror,ValueMirror); SymbolMirror.prototype.description=function(){ return %SymbolDescription(%ValueOf(this.value_)); } SymbolMirror.prototype.toText=function(){ return %SymbolDescriptiveString(%ValueOf(this.value_)); } function ObjectMirror(k,t){ t=t||j.OBJECT_TYPE; %_Call(ValueMirror,this,t,k); } inherits(ObjectMirror,ValueMirror); ObjectMirror.prototype.className=function(){ return %_ClassOf(this.value_); }; ObjectMirror.prototype.constructorFunction=function(){ return MakeMirror(%DebugGetProperty(this.value_,'constructor')); }; ObjectMirror.prototype.prototypeObject=function(){ return MakeMirror(%DebugGetProperty(this.value_,'prototype')); }; ObjectMirror.prototype.protoObject=function(){ return MakeMirror(%DebugGetPrototype(this.value_)); }; ObjectMirror.prototype.hasNamedInterceptor=function(){ var v=%GetInterceptorInfo(this.value_); return(v&2)!=0; }; ObjectMirror.prototype.hasIndexedInterceptor=function(){ var v=%GetInterceptorInfo(this.value_); return(v&1)!=0; }; ObjectMirror.prototype.propertyNames=function(){ return %GetOwnPropertyKeys(this.value_,0); }; ObjectMirror.prototype.properties=function(){ var w=this.propertyNames(); var x=new c(w.length); for(var y=0;y<w.length;y++){ x[y]=this.property(w[y]); } return x; }; ObjectMirror.prototype.internalProperties=function(){ return ObjectMirror.GetInternalProperties(this.value_); } ObjectMirror.prototype.property=function(z){ var A=%DebugGetPropertyDetails(this.value_,z); if(A){ return new PropertyMirror(this,z,A); } return GetUndefinedMirror(); }; ObjectMirror.prototype.lookupProperty=function(k){ var x=this.properties(); for(var y=0;y<x.length;y++){ var B=x[y]; if(B.propertyType()==q.Data){ if(B.value_===k.value_){ return B; } } } return GetUndefinedMirror(); }; ObjectMirror.prototype.referencedBy=function(C){ var D=%DebugReferencedBy(this.value_, Mirror.prototype,C||0); for(var y=0;y<D.length;y++){ D[y]=MakeMirror(D[y]); } return D; }; ObjectMirror.prototype.toText=function(){ var z; var m=this.constructorFunction(); if(!m.isFunction()){ z=this.className(); }else{ z=m.name(); if(!z){ z=this.className(); } } return'#<'+z+'>'; }; ObjectMirror.GetInternalProperties=function(k){ var x=%DebugGetInternalProperties(k); var D=[]; for(var y=0;y<x.length;y+=2){ D.push(new InternalPropertyMirror(x[y],x[y+1])); } return D; } function FunctionMirror(k){ %_Call(ObjectMirror,this,k,j.FUNCTION_TYPE); this.resolved_=true; } inherits(FunctionMirror,ObjectMirror); FunctionMirror.prototype.resolved=function(){ return this.resolved_; }; FunctionMirror.prototype.name=function(){ return %FunctionGetName(this.value_); }; FunctionMirror.prototype.debugName=function(){ return %FunctionGetDebugName(this.value_); } FunctionMirror.prototype.inferredName=function(){ return %FunctionGetInferredName(this.value_); }; FunctionMirror.prototype.source=function(){ if(this.resolved()){ return %FunctionToString(this.value_); } }; FunctionMirror.prototype.script=function(){ if(this.resolved()){ if(this.script_){ return this.script_; } var E=%FunctionGetScript(this.value_); if(E){ return this.script_=MakeMirror(E); } } }; FunctionMirror.prototype.sourcePosition_=function(){ if(this.resolved()){ return %FunctionGetScriptSourcePosition(this.value_); } }; FunctionMirror.prototype.sourceLocation=function(){ if(this.resolved()){ var E=this.script(); if(E){ return E.locationFromPosition(this.sourcePosition_(),true); } } }; FunctionMirror.prototype.constructedBy=function(F){ if(this.resolved()){ var D=%DebugConstructedBy(this.value_,F||0); for(var y=0;y<D.length;y++){ D[y]=MakeMirror(D[y]); } return D; }else{ return[]; } }; FunctionMirror.prototype.scopeCount=function(){ if(this.resolved()){ if((this.scopeCount_===(void 0))){ this.scopeCount_=%GetFunctionScopeCount(this.value()); } return this.scopeCount_; }else{ return 0; } }; FunctionMirror.prototype.scope=function(G){ if(this.resolved()){ return new ScopeMirror((void 0),this,(void 0),G); } }; FunctionMirror.prototype.toText=function(){ return this.source(); }; FunctionMirror.prototype.context=function(){ if(this.resolved()){ if(!this._context) this._context=new ContextMirror(%FunctionGetContextData(this.value_)); return this._context; } }; function UnresolvedFunctionMirror(k){ %_Call(ValueMirror,this,j.FUNCTION_TYPE,k); this.propertyCount_=0; this.elementCount_=0; this.resolved_=false; } inherits(UnresolvedFunctionMirror,FunctionMirror); UnresolvedFunctionMirror.prototype.className=function(){ return'Function'; }; UnresolvedFunctionMirror.prototype.constructorFunction=function(){ return GetUndefinedMirror(); }; UnresolvedFunctionMirror.prototype.prototypeObject=function(){ return GetUndefinedMirror(); }; UnresolvedFunctionMirror.prototype.protoObject=function(){ return GetUndefinedMirror(); }; UnresolvedFunctionMirror.prototype.name=function(){ return this.value_; }; UnresolvedFunctionMirror.prototype.debugName=function(){ return this.value_; }; UnresolvedFunctionMirror.prototype.inferredName=function(){ return(void 0); }; UnresolvedFunctionMirror.prototype.propertyNames=function(H,I){ return[]; }; function ArrayMirror(k){ %_Call(ObjectMirror,this,k); } inherits(ArrayMirror,ObjectMirror); ArrayMirror.prototype.length=function(){ return this.value_.length; }; ArrayMirror.prototype.indexedPropertiesFromRange=function(opt_from_index, opt_to_index){ var J=opt_from_index||0; var K=opt_to_index||this.length()-1; if(J>K)return new c(); var L=new c(K-J+1); for(var y=J;y<=K;y++){ var A=%DebugGetPropertyDetails(this.value_,(%_ToString(y))); var k; if(A){ k=new PropertyMirror(this,y,A); }else{ k=GetUndefinedMirror(); } L[y-J]=k; } return L; }; function DateMirror(k){ %_Call(ObjectMirror,this,k); } inherits(DateMirror,ObjectMirror); DateMirror.prototype.toText=function(){ var M=e(this.value_); return M.substring(1,M.length-1); }; function RegExpMirror(k){ %_Call(ObjectMirror,this,k,j.REGEXP_TYPE); } inherits(RegExpMirror,ObjectMirror); RegExpMirror.prototype.source=function(){ return this.value_.source; }; RegExpMirror.prototype.global=function(){ return this.value_.global; }; RegExpMirror.prototype.ignoreCase=function(){ return this.value_.ignoreCase; }; RegExpMirror.prototype.multiline=function(){ return this.value_.multiline; }; RegExpMirror.prototype.sticky=function(){ return this.value_.sticky; }; RegExpMirror.prototype.unicode=function(){ return this.value_.unicode; }; RegExpMirror.prototype.toText=function(){ return"/"+this.source()+"/"; }; function ErrorMirror(k){ %_Call(ObjectMirror,this,k,j.ERROR_TYPE); } inherits(ErrorMirror,ObjectMirror); ErrorMirror.prototype.message=function(){ return this.value_.message; }; ErrorMirror.prototype.toText=function(){ var N; try{ N=%ErrorToString(this.value_); }catch(e){ N='#<Error>'; } return N; }; function PromiseMirror(k){ %_Call(ObjectMirror,this,k,j.PROMISE_TYPE); } inherits(PromiseMirror,ObjectMirror); function PromiseGetStatus_(k){ var O=%PromiseStatus(k); if(O==0)return"pending"; if(O==1)return"resolved"; return"rejected"; } function PromiseGetValue_(k){ return %PromiseResult(k); } PromiseMirror.prototype.status=function(){ return PromiseGetStatus_(this.value_); }; PromiseMirror.prototype.promiseValue=function(){ return MakeMirror(PromiseGetValue_(this.value_)); }; function MapMirror(k){ %_Call(ObjectMirror,this,k,j.MAP_TYPE); } inherits(MapMirror,ObjectMirror); MapMirror.prototype.entries=function(P){ var D=[]; if((%_ClassOf(this.value_)==='WeakMap')){ var Q=%GetWeakMapEntries(this.value_,P||0); for(var y=0;y<Q.length;y+=2){ D.push({ key:Q[y], value:Q[y+1] }); } return D; } var R=%_Call(f,this.value_); var S; while((!P||D.length<P)&& !(S=R.next()).done){ D.push({ key:S.value[0], value:S.value[1] }); } return D; }; function SetMirror(k){ %_Call(ObjectMirror,this,k,j.SET_TYPE); } inherits(SetMirror,ObjectMirror); function IteratorGetValues_(R,T,P){ var D=[]; var S; while((!P||D.length<P)&& !(S=%_Call(T,R)).done){ D.push(S.value); } return D; } SetMirror.prototype.values=function(P){ if((%_ClassOf(this.value_)==='WeakSet')){ return %GetWeakSetValues(this.value_,P||0); } var R=%_Call(i,this.value_); return IteratorGetValues_(R,h,P); }; function IteratorMirror(k){ %_Call(ObjectMirror,this,k,j.ITERATOR_TYPE); } inherits(IteratorMirror,ObjectMirror); IteratorMirror.prototype.preview=function(P){ if((%_ClassOf(this.value_)==='Map Iterator')){ return IteratorGetValues_(%MapIteratorClone(this.value_), g, P); }else if((%_ClassOf(this.value_)==='Set Iterator')){ return IteratorGetValues_(%SetIteratorClone(this.value_), h, P); } }; function GeneratorMirror(k){ %_Call(ObjectMirror,this,k,j.GENERATOR_TYPE); } inherits(GeneratorMirror,ObjectMirror); function GeneratorGetStatus_(k){ var U=%GeneratorGetContinuation(k); if(U<-1)return"running"; if(U==-1)return"closed"; return"suspended"; } GeneratorMirror.prototype.status=function(){ return GeneratorGetStatus_(this.value_); }; GeneratorMirror.prototype.sourcePosition_=function(){ return %GeneratorGetSourcePosition(this.value_); }; GeneratorMirror.prototype.sourceLocation=function(){ var V=this.sourcePosition_(); if(!(V===(void 0))){ var E=this.func().script(); if(E){ return E.locationFromPosition(V,true); } } }; GeneratorMirror.prototype.func=function(){ if(!this.func_){ this.func_=MakeMirror(%GeneratorGetFunction(this.value_)); } return this.func_; }; GeneratorMirror.prototype.receiver=function(){ if(!this.receiver_){ this.receiver_=MakeMirror(%GeneratorGetReceiver(this.value_)); } return this.receiver_; }; GeneratorMirror.prototype.scopeCount=function(){ return %GetGeneratorScopeCount(this.value()); }; GeneratorMirror.prototype.scope=function(G){ return new ScopeMirror((void 0),(void 0),this,G); }; GeneratorMirror.prototype.allScopes=function(){ var W=[]; for(let y=0;y<this.scopeCount();y++){ W.push(this.scope(y)); } return W; }; function PropertyMirror(l,z,A){ %_Call(Mirror,this,j.PROPERTY_TYPE); this.mirror_=l; this.name_=z; this.value_=A[0]; this.details_=A[1]; this.is_interceptor_=A[2]; if(A.length>3){ this.exception_=A[3]; this.getter_=A[4]; this.setter_=A[5]; } } inherits(PropertyMirror,Mirror); PropertyMirror.prototype.isReadOnly=function(){ return(this.attributes()&r.ReadOnly)!=0; }; PropertyMirror.prototype.isEnum=function(){ return(this.attributes()&r.DontEnum)==0; }; PropertyMirror.prototype.canDelete=function(){ return(this.attributes()&r.DontDelete)==0; }; PropertyMirror.prototype.name=function(){ return this.name_; }; PropertyMirror.prototype.toText=function(){ if((typeof(this.name_)==='symbol'))return %SymbolDescriptiveString(this.name_); return this.name_; }; PropertyMirror.prototype.isIndexed=function(){ for(var y=0;y<this.name_.length;y++){ if(this.name_[y]<'0'||'9'<this.name_[y]){ return false; } } return true; }; PropertyMirror.prototype.value=function(){ return MakeMirror(this.value_,false); }; PropertyMirror.prototype.isException=function(){ return this.exception_?true:false; }; PropertyMirror.prototype.attributes=function(){ return %DebugPropertyAttributesFromDetails(this.details_); }; PropertyMirror.prototype.propertyType=function(){ return %DebugPropertyKindFromDetails(this.details_); }; PropertyMirror.prototype.hasGetter=function(){ return this.getter_?true:false; }; PropertyMirror.prototype.hasSetter=function(){ return this.setter_?true:false; }; PropertyMirror.prototype.getter=function(){ if(this.hasGetter()){ return MakeMirror(this.getter_); }else{ return GetUndefinedMirror(); } }; PropertyMirror.prototype.setter=function(){ if(this.hasSetter()){ return MakeMirror(this.setter_); }else{ return GetUndefinedMirror(); } }; PropertyMirror.prototype.isNative=function(){ return this.is_interceptor_|| ((this.propertyType()==q.Accessor)&& !this.hasGetter()&&!this.hasSetter()); }; function InternalPropertyMirror(z,k){ %_Call(Mirror,this,j.INTERNAL_PROPERTY_TYPE); this.name_=z; this.value_=k; } inherits(InternalPropertyMirror,Mirror); InternalPropertyMirror.prototype.name=function(){ return this.name_; }; InternalPropertyMirror.prototype.value=function(){ return MakeMirror(this.value_,false); }; var X=0; var Y=1; var Z=2; var aa=3; var ab=4; var ac=5; var ad=6; var ae=7; var af=8; var ag=9; var ah=10; var ai=0; var aj=1; var ak=2; var al=1<<0; var am=1<<1; var an=7<<2; function FrameDetails(ao,G){ this.break_id_=ao; this.details_=%GetFrameDetails(ao,G); } FrameDetails.prototype.frameId=function(){ %CheckExecutionState(this.break_id_); return this.details_[X]; }; FrameDetails.prototype.receiver=function(){ %CheckExecutionState(this.break_id_); return this.details_[Y]; }; FrameDetails.prototype.func=function(){ %CheckExecutionState(this.break_id_); return this.details_[Z]; }; FrameDetails.prototype.script=function(){ %CheckExecutionState(this.break_id_); return this.details_[aa]; }; FrameDetails.prototype.isConstructCall=function(){ %CheckExecutionState(this.break_id_); return this.details_[ae]; }; FrameDetails.prototype.isAtReturn=function(){ %CheckExecutionState(this.break_id_); return this.details_[af]; }; FrameDetails.prototype.isDebuggerFrame=function(){ %CheckExecutionState(this.break_id_); var ap=al; return(this.details_[ag]&ap)==ap; }; FrameDetails.prototype.isOptimizedFrame=function(){ %CheckExecutionState(this.break_id_); var ap=am; return(this.details_[ag]&ap)==ap; }; FrameDetails.prototype.isInlinedFrame=function(){ return this.inlinedFrameIndex()>0; }; FrameDetails.prototype.inlinedFrameIndex=function(){ %CheckExecutionState(this.break_id_); var ap=an; return(this.details_[ag]&ap)>>2; }; FrameDetails.prototype.argumentCount=function(){ %CheckExecutionState(this.break_id_); return this.details_[ab]; }; FrameDetails.prototype.argumentName=function(G){ %CheckExecutionState(this.break_id_); if(G>=0&&G<this.argumentCount()){ return this.details_[ah+ G*ak+ ai]; } }; FrameDetails.prototype.argumentValue=function(G){ %CheckExecutionState(this.break_id_); if(G>=0&&G<this.argumentCount()){ return this.details_[ah+ G*ak+ aj]; } }; FrameDetails.prototype.localCount=function(){ %CheckExecutionState(this.break_id_); return this.details_[ac]; }; FrameDetails.prototype.sourcePosition=function(){ %CheckExecutionState(this.break_id_); return this.details_[ad]; }; FrameDetails.prototype.localName=function(G){ %CheckExecutionState(this.break_id_); if(G>=0&&G<this.localCount()){ var aq=ah+ this.argumentCount()*ak; return this.details_[aq+ G*ak+ ai]; } }; FrameDetails.prototype.localValue=function(G){ %CheckExecutionState(this.break_id_); if(G>=0&&G<this.localCount()){ var aq=ah+ this.argumentCount()*ak; return this.details_[aq+ G*ak+ aj]; } }; FrameDetails.prototype.returnValue=function(){ %CheckExecutionState(this.break_id_); var ar= ah+ (this.argumentCount()+this.localCount())*ak; if(this.details_[af]){ return this.details_[ar]; } }; FrameDetails.prototype.scopeCount=function(){ if((this.scopeCount_===(void 0))){ this.scopeCount_=%GetScopeCount(this.break_id_,this.frameId()); } return this.scopeCount_; }; function FrameMirror(ao,G){ %_Call(Mirror,this,j.FRAME_TYPE); this.break_id_=ao; this.index_=G; this.details_=new FrameDetails(ao,G); } inherits(FrameMirror,Mirror); FrameMirror.prototype.details=function(){ return this.details_; }; FrameMirror.prototype.index=function(){ return this.index_; }; FrameMirror.prototype.func=function(){ if(this.func_){ return this.func_; } var ap=this.details_.func(); if((%IsFunction(ap))){ return this.func_=MakeMirror(ap); }else{ return new UnresolvedFunctionMirror(ap); } }; FrameMirror.prototype.script=function(){ if(!this.script_){ this.script_=MakeMirror(this.details_.script()); } return this.script_; } FrameMirror.prototype.receiver=function(){ return MakeMirror(this.details_.receiver()); }; FrameMirror.prototype.isConstructCall=function(){ return this.details_.isConstructCall(); }; FrameMirror.prototype.isAtReturn=function(){ return this.details_.isAtReturn(); }; FrameMirror.prototype.isDebuggerFrame=function(){ return this.details_.isDebuggerFrame(); }; FrameMirror.prototype.isOptimizedFrame=function(){ return this.details_.isOptimizedFrame(); }; FrameMirror.prototype.isInlinedFrame=function(){ return this.details_.isInlinedFrame(); }; FrameMirror.prototype.inlinedFrameIndex=function(){ return this.details_.inlinedFrameIndex(); }; FrameMirror.prototype.argumentCount=function(){ return this.details_.argumentCount(); }; FrameMirror.prototype.argumentName=function(G){ return this.details_.argumentName(G); }; FrameMirror.prototype.argumentValue=function(G){ return MakeMirror(this.details_.argumentValue(G)); }; FrameMirror.prototype.localCount=function(){ return this.details_.localCount(); }; FrameMirror.prototype.localName=function(G){ return this.details_.localName(G); }; FrameMirror.prototype.localValue=function(G){ return MakeMirror(this.details_.localValue(G)); }; FrameMirror.prototype.returnValue=function(){ return MakeMirror(this.details_.returnValue()); }; FrameMirror.prototype.sourcePosition=function(){ return this.details_.sourcePosition(); }; FrameMirror.prototype.sourceLocation=function(){ var E=this.script(); if(E){ return E.locationFromPosition(this.sourcePosition(),true); } }; FrameMirror.prototype.sourceLine=function(){ var as=this.sourceLocation(); if(as){ return as.line; } }; FrameMirror.prototype.sourceColumn=function(){ var as=this.sourceLocation(); if(as){ return as.column; } }; FrameMirror.prototype.sourceLineText=function(){ var as=this.sourceLocation(); if(as){ return as.sourceText; } }; FrameMirror.prototype.scopeCount=function(){ return this.details_.scopeCount(); }; FrameMirror.prototype.scope=function(G){ return new ScopeMirror(this,(void 0),(void 0),G); }; FrameMirror.prototype.allScopes=function(at){ var au=%GetAllScopesDetails(this.break_id_, this.details_.frameId(), this.details_.inlinedFrameIndex(), !!at); var D=[]; for(var y=0;y<au.length;++y){ D.push(new ScopeMirror(this,(void 0),(void 0),y, au[y])); } return D; }; FrameMirror.prototype.evaluate=function(source,throw_on_side_effect=false){ return MakeMirror(%DebugEvaluate(this.break_id_, this.details_.frameId(), this.details_.inlinedFrameIndex(), source, throw_on_side_effect)); }; FrameMirror.prototype.invocationText=function(){ var D=''; var av=this.func(); var aw=this.receiver(); if(this.isConstructCall()){ D+='new '; D+=av.name()?av.name():'[anonymous]'; }else if(this.isDebuggerFrame()){ D+='[debugger]'; }else{ var ax= !aw.className||(aw.className()!='global'); if(ax){ D+=aw.toText(); } var B=GetUndefinedMirror(); if(aw.isObject()){ for(var ay=aw; !ay.isNull()&&B.isUndefined(); ay=ay.protoObject()){ B=ay.lookupProperty(av); } } if(!B.isUndefined()){ if(!B.isIndexed()){ if(ax){ D+='.'; } D+=B.toText(); }else{ D+='['; D+=B.toText(); D+=']'; } if(av.name()&&av.name()!=B.name()){ D+='(aka '+av.name()+')'; } }else{ if(ax){ D+='.'; } D+=av.name()?av.name():'[anonymous]'; } } if(!this.isDebuggerFrame()){ D+='('; for(var y=0;y<this.argumentCount();y++){ if(y!=0)D+=', '; if(this.argumentName(y)){ D+=this.argumentName(y); D+='='; } D+=this.argumentValue(y).toText(); } D+=')'; } if(this.isAtReturn()){ D+=' returning '; D+=this.returnValue().toText(); } return D; }; FrameMirror.prototype.sourceAndPositionText=function(){ var D=''; var av=this.func(); if(av.resolved()){ var E=av.script(); if(E){ if(E.name()){ D+=E.name(); }else{ D+='[unnamed]'; } if(!this.isDebuggerFrame()){ var as=this.sourceLocation(); D+=' line '; D+=!(as===(void 0))?(as.line+1):'?'; D+=' column '; D+=!(as===(void 0))?(as.column+1):'?'; if(!(this.sourcePosition()===(void 0))){ D+=' (position '+(this.sourcePosition()+1)+')'; } } }else{ D+='[no source]'; } }else{ D+='[unresolved]'; } return D; }; FrameMirror.prototype.localsText=function(){ var D=''; var az=this.localCount(); if(az>0){ for(var y=0;y<az;++y){ D+=' var '; D+=this.localName(y); D+=' = '; D+=this.localValue(y).toText(); if(y<az-1)D+='\n'; } } return D; }; FrameMirror.prototype.restart=function(){ var D=%LiveEditRestartFrame(this.break_id_,this.index_); if((D===(void 0))){ D="Failed to find requested frame"; } return D; }; FrameMirror.prototype.toText=function(aA){ var D=''; D+='#'+(this.index()<=9?'0':'')+this.index(); D+=' '; D+=this.invocationText(); D+=' '; D+=this.sourceAndPositionText(); if(aA){ D+='\n'; D+=this.localsText(); } return D; }; var aB=0; var aC=1; var aD=2; var aE=3; var aF=4; var aG=5; function ScopeDetails(aH,aI,aJ,G,aK){ if(aH){ this.break_id_=aH.break_id_; this.details_=aK|| %GetScopeDetails(aH.break_id_, aH.details_.frameId(), aH.details_.inlinedFrameIndex(), G); this.frame_id_=aH.details_.frameId(); this.inlined_frame_id_=aH.details_.inlinedFrameIndex(); }else if(aI){ this.details_=aK||%GetFunctionScopeDetails(aI.value(),G); this.fun_value_=aI.value(); this.break_id_=(void 0); }else{ this.details_= aK||%GetGeneratorScopeDetails(aJ.value(),G); this.gen_value_=aJ.value(); this.break_id_=(void 0); } this.index_=G; } ScopeDetails.prototype.type=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aB]; }; ScopeDetails.prototype.object=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aC]; }; ScopeDetails.prototype.name=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aD]; }; ScopeDetails.prototype.startPosition=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aE]; } ScopeDetails.prototype.endPosition=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aF]; } ScopeDetails.prototype.func=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[aG]; } ScopeDetails.prototype.setVariableValueImpl=function(z,aL){ var aM; if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); aM=%SetScopeVariableValue(this.break_id_,this.frame_id_, this.inlined_frame_id_,this.index_,z,aL); }else if(!(this.fun_value_===(void 0))){ aM=%SetScopeVariableValue(this.fun_value_,null,null,this.index_, z,aL); }else{ aM=%SetScopeVariableValue(this.gen_value_,null,null,this.index_, z,aL); } if(!aM)throw %make_error(2,"Failed to set variable value"); }; function ScopeMirror(aH,aI,aJ,G,aK){ %_Call(Mirror,this,j.SCOPE_TYPE); if(aH){ this.frame_index_=aH.index_; }else{ this.frame_index_=(void 0); } this.scope_index_=G; this.details_=new ScopeDetails(aH,aI,aJ,G,aK); } inherits(ScopeMirror,Mirror); ScopeMirror.prototype.details=function(){ return this.details_; }; ScopeMirror.prototype.frameIndex=function(){ return this.frame_index_; }; ScopeMirror.prototype.scopeIndex=function(){ return this.scope_index_; }; ScopeMirror.prototype.scopeType=function(){ return this.details_.type(); }; ScopeMirror.prototype.scopeObject=function(){ return MakeMirror(this.details_.object()); }; ScopeMirror.prototype.setVariableValue=function(z,aL){ this.details_.setVariableValueImpl(z,aL); }; function ScriptMirror(E){ %_Call(Mirror,this,j.SCRIPT_TYPE); this.script_=E; this.context_=new ContextMirror(E.context_data); } inherits(ScriptMirror,Mirror); ScriptMirror.prototype.value=function(){ return this.script_; }; ScriptMirror.prototype.name=function(){ return this.script_.name||this.script_.nameOrSourceURL(); }; ScriptMirror.prototype.id=function(){ return this.script_.id; }; ScriptMirror.prototype.source=function(){ return this.script_.source; }; ScriptMirror.prototype.setSource=function(aN){ if(!(typeof(aN)==='string'))throw %make_error(2,"Source is not a string"); %DebugSetScriptSource(this.script_,aN); }; ScriptMirror.prototype.lineOffset=function(){ return this.script_.line_offset; }; ScriptMirror.prototype.columnOffset=function(){ return this.script_.column_offset; }; ScriptMirror.prototype.data=function(){ return this.script_.data; }; ScriptMirror.prototype.scriptType=function(){ return this.script_.type; }; ScriptMirror.prototype.compilationType=function(){ return this.script_.compilation_type; }; ScriptMirror.prototype.lineCount=function(){ return %ScriptLineCount(this.script_); }; ScriptMirror.prototype.locationFromPosition=function( position,include_resource_offset){ return this.script_.locationFromPosition(position,include_resource_offset); }; ScriptMirror.prototype.context=function(){ return this.context_; }; ScriptMirror.prototype.evalFromScript=function(){ return MakeMirror(this.script_.eval_from_script); }; ScriptMirror.prototype.evalFromFunctionName=function(){ return MakeMirror(this.script_.eval_from_function_name); }; ScriptMirror.prototype.evalFromLocation=function(){ var aO=this.evalFromScript(); if(!aO.isUndefined()){ var aP=this.script_.eval_from_script_position; return aO.locationFromPosition(aP,true); } }; ScriptMirror.prototype.toText=function(){ var D=''; D+=this.name(); D+=' (lines: '; if(this.lineOffset()>0){ D+=this.lineOffset(); D+='-'; D+=this.lineOffset()+this.lineCount()-1; }else{ D+=this.lineCount(); } D+=')'; return D; }; function ContextMirror(aQ){ %_Call(Mirror,this,j.CONTEXT_TYPE); this.data_=aQ; } inherits(ContextMirror,Mirror); ContextMirror.prototype.data=function(){ return this.data_; }; b.InstallFunctions(a,2,[ "MakeMirror",MakeMirror, ]); b.InstallConstants(a,[ "ScopeType",s, "PropertyType",q, "PropertyAttribute",r, "Mirror",Mirror, "ValueMirror",ValueMirror, "UndefinedMirror",UndefinedMirror, "NullMirror",NullMirror, "BooleanMirror",BooleanMirror, "NumberMirror",NumberMirror, "StringMirror",StringMirror, "SymbolMirror",SymbolMirror, "ObjectMirror",ObjectMirror, "FunctionMirror",FunctionMirror, "UnresolvedFunctionMirror",UnresolvedFunctionMirror, "ArrayMirror",ArrayMirror, "DateMirror",DateMirror, "RegExpMirror",RegExpMirror, "ErrorMirror",ErrorMirror, "PromiseMirror",PromiseMirror, "MapMirror",MapMirror, "SetMirror",SetMirror, "IteratorMirror",IteratorMirror, "GeneratorMirror",GeneratorMirror, "PropertyMirror",PropertyMirror, "InternalPropertyMirror",InternalPropertyMirror, "FrameMirror",FrameMirror, "ScriptMirror",ScriptMirror, "ScopeMirror",ScopeMirror, "FrameDetails",FrameDetails, ]); }) debugQ� (function(a,b){ "use strict"; var c=a.FrameMirror; var d=a.Array; var e=a.RegExp; var f=a.isNaN; var g=a.MakeMirror; var h=a.Math.min; var i=a.Mirror; var j=a.ValueMirror; var k=10; var l={}; var m=/^(?:\s*(?:\/\*.*?\*\/)*)*/; l.DebugEvent={Break:1, Exception:2, AfterCompile:3, CompileError:4, AsyncTaskEvent:5}; l.ExceptionBreak={Caught:0, Uncaught:1}; l.StepAction={StepOut:0, StepNext:1, StepIn:2}; l.ScriptType={Native:0, Extension:1, Normal:2, Wasm:3}; l.ScriptCompilationType={Host:0, Eval:1, JSON:2}; l.ScriptBreakPointType={ScriptId:0, ScriptName:1, ScriptRegExp:2}; l.BreakPositionAlignment={ Statement:0, BreakPosition:1 }; function ScriptTypeFlag(n){ return(1<<n); } var o=0; var p=1; var q=[]; var r=[]; var s={ breakPointsActive:{ value:true, getValue:function(){return this.value;}, setValue:function(t){ this.value=!!t; %SetBreakPointsActive(this.value); } }, breakOnCaughtException:{ getValue:function(){return l.isBreakOnException();}, setValue:function(t){ if(t){ l.setBreakOnException(); }else{ l.clearBreakOnException(); } } }, breakOnUncaughtException:{ getValue:function(){return l.isBreakOnUncaughtException();}, setValue:function(t){ if(t){ l.setBreakOnUncaughtException(); }else{ l.clearBreakOnUncaughtException(); } } }, }; function MakeBreakPoint(u,v){ var w=new BreakPoint(u,v); q.push(w); return w; } function BreakPoint(u,v){ this.source_position_=u; if(v){ this.script_break_point_=v; }else{ this.number_=p++; } this.active_=true; this.condition_=null; } BreakPoint.prototype.number=function(){ return this.number_; }; BreakPoint.prototype.func=function(){ return this.func_; }; BreakPoint.prototype.source_position=function(){ return this.source_position_; }; BreakPoint.prototype.active=function(){ if(this.script_break_point()){ return this.script_break_point().active(); } return this.active_; }; BreakPoint.prototype.condition=function(){ if(this.script_break_point()&&this.script_break_point().condition()){ return this.script_break_point().condition(); } return this.condition_; }; BreakPoint.prototype.script_break_point=function(){ return this.script_break_point_; }; BreakPoint.prototype.enable=function(){ this.active_=true; }; BreakPoint.prototype.disable=function(){ this.active_=false; }; BreakPoint.prototype.setCondition=function(x){ this.condition_=x; }; BreakPoint.prototype.isTriggered=function(y){ if(!this.active())return false; if(this.condition()){ try{ var z=y.frame(0).evaluate(this.condition()); if(!(z instanceof j)||!z.value_){ return false; } }catch(e){ return false; } } return true; }; function IsBreakPointTriggered(A,w){ return w.isTriggered(MakeExecutionState(A)); } function ScriptBreakPoint(n,script_id_or_name,opt_line,opt_column, opt_groupId,opt_position_alignment){ this.type_=n; if(n==l.ScriptBreakPointType.ScriptId){ this.script_id_=script_id_or_name; }else if(n==l.ScriptBreakPointType.ScriptName){ this.script_name_=script_id_or_name; }else if(n==l.ScriptBreakPointType.ScriptRegExp){ this.script_regexp_object_=new e(script_id_or_name); }else{ throw %make_error(2,"Unexpected breakpoint type "+n); } this.line_=opt_line||0; this.column_=opt_column; this.groupId_=opt_groupId; this.position_alignment_=(opt_position_alignment===(void 0)) ?l.BreakPositionAlignment.Statement:opt_position_alignment; this.active_=true; this.condition_=null; this.break_points_=[]; } ScriptBreakPoint.prototype.number=function(){ return this.number_; }; ScriptBreakPoint.prototype.groupId=function(){ return this.groupId_; }; ScriptBreakPoint.prototype.type=function(){ return this.type_; }; ScriptBreakPoint.prototype.script_id=function(){ return this.script_id_; }; ScriptBreakPoint.prototype.script_name=function(){ return this.script_name_; }; ScriptBreakPoint.prototype.script_regexp_object=function(){ return this.script_regexp_object_; }; ScriptBreakPoint.prototype.line=function(){ return this.line_; }; ScriptBreakPoint.prototype.column=function(){ return this.column_; }; ScriptBreakPoint.prototype.actual_locations=function(){ var B=[]; for(var C=0;C<this.break_points_.length;C++){ B.push(this.break_points_[C].actual_location); } return B; }; ScriptBreakPoint.prototype.update_positions=function(D,E){ this.line_=D; this.column_=E; }; ScriptBreakPoint.prototype.active=function(){ return this.active_; }; ScriptBreakPoint.prototype.condition=function(){ return this.condition_; }; ScriptBreakPoint.prototype.enable=function(){ this.active_=true; }; ScriptBreakPoint.prototype.disable=function(){ this.active_=false; }; ScriptBreakPoint.prototype.setCondition=function(x){ this.condition_=x; }; ScriptBreakPoint.prototype.matchesScript=function(F){ if(this.type_==l.ScriptBreakPointType.ScriptId){ return this.script_id_==F.id; }else{ if(!(F.line_offset<=this.line_&& this.line_<F.line_offset+%ScriptLineCount(F))){ return false; } if(this.type_==l.ScriptBreakPointType.ScriptName){ return this.script_name_==F.nameOrSourceURL(); }else if(this.type_==l.ScriptBreakPointType.ScriptRegExp){ return this.script_regexp_object_.test(F.nameOrSourceURL()); }else{ throw %make_error(2,"Unexpected breakpoint type "+this.type_); } } }; ScriptBreakPoint.prototype.set=function(F){ var E=this.column(); var D=this.line(); if((E===(void 0))){ var G=%ScriptSourceLine(F,D||F.line_offset); if(!F.sourceColumnStart_){ F.sourceColumnStart_=new d(%ScriptLineCount(F)); } if((F.sourceColumnStart_[D]===(void 0))){ F.sourceColumnStart_[D]= G.match(m)[0].length; } E=F.sourceColumnStart_[D]; } var H=l.findScriptSourcePosition(F,this.line(),E); if((H===null))return; var w=MakeBreakPoint(H,this); var I=%SetScriptBreakPoint(F,H, this.position_alignment_, w); if((I===(void 0))){ I=H; } var J=F.locationFromPosition(I,true); w.actual_location={line:J.line, column:J.column, script_id:F.id}; this.break_points_.push(w); return w; }; ScriptBreakPoint.prototype.clear=function(){ var K=[]; for(var C=0;C<q.length;C++){ if(q[C].script_break_point()&& q[C].script_break_point()===this){ %ClearBreakPoint(q[C]); }else{ K.push(q[C]); } } q=K; this.break_points_=[]; }; l.setListener=function(L,M){ if(!(%IsFunction(L))&&!(L===(void 0))&&!(L===null)){ throw %make_type_error(36); } %SetDebugEventListener(L,M); }; l.findScript=function(N){ if((%IsFunction(N))){ return %FunctionGetScript(N); }else if(%IsRegExp(N)){ var O=this.scripts(); var P=null; var Q=0; for(var C in O){ var F=O[C]; if(N.test(F.name)){ P=F; Q++; } } if(Q==1){ return P; }else{ return(void 0); } }else{ return %GetScript(N); } }; l.scriptSource=function(N){ return this.findScript(N).source; }; l.source=function(R){ if(!(%IsFunction(R)))throw %make_type_error(36); return %FunctionGetSourceCode(R); }; l.sourcePosition=function(R){ if(!(%IsFunction(R)))throw %make_type_error(36); return %FunctionGetScriptSourcePosition(R); }; l.findFunctionSourceLocation=function(S,T,U){ var F=%FunctionGetScript(S); var V=%FunctionGetScriptSourcePosition(S); return %ScriptLocationFromLine(F,T,U,V); }; l.findScriptSourcePosition=function(F,T,U){ var W=%ScriptLocationFromLine(F,T,U,0); return W?W.position:null; }; l.findBreakPoint=function(X,Y){ var w; for(var C=0;C<q.length;C++){ if(q[C].number()==X){ w=q[C]; if(Y){ q.splice(C,1); } break; } } if(w){ return w; }else{ return this.findScriptBreakPoint(X,Y); } }; l.findBreakPointActualLocations=function(X){ for(var C=0;C<r.length;C++){ if(r[C].number()==X){ return r[C].actual_locations(); } } for(var C=0;C<q.length;C++){ if(q[C].number()==X){ return[q[C].actual_location]; } } return[]; }; l.setBreakPoint=function(S,T,U,Z){ if(!(%IsFunction(S)))throw %make_type_error(36); if(%FunctionIsAPIFunction(S)){ throw %make_error(2,'Cannot set break point in native code.'); } var u= this.findFunctionSourceLocation(S,T,U).position; var F=%FunctionGetScript(S); if(F.type==l.ScriptType.Native){ throw %make_error(2,'Cannot set break point in native code.'); } if(F&&F.id){ var W=F.locationFromPosition(u,false); return this.setScriptBreakPointById(F.id, W.line,W.column, Z); }else{ var w=MakeBreakPoint(u); var I= %SetFunctionBreakPoint(S,u,w); var J=F.locationFromPosition(I,true); w.actual_location={line:J.line, column:J.column, script_id:F.id}; w.setCondition(Z); return w.number(); } }; l.setBreakPointByScriptIdAndPosition=function(script_id,H, x,enabled, opt_position_alignment) { var w=MakeBreakPoint(H); w.setCondition(x); if(!enabled){ w.disable(); } var F=scriptById(script_id); if(F){ var aa=(opt_position_alignment===(void 0)) ?l.BreakPositionAlignment.Statement:opt_position_alignment; w.actual_position=%SetScriptBreakPoint(F,H, aa,w); } return w; }; l.enableBreakPoint=function(X){ var w=this.findBreakPoint(X,false); if(w){ w.enable(); } }; l.disableBreakPoint=function(X){ var w=this.findBreakPoint(X,false); if(w){ w.disable(); } }; l.changeBreakPointCondition=function(X,x){ var w=this.findBreakPoint(X,false); w.setCondition(x); }; l.clearBreakPoint=function(X){ var w=this.findBreakPoint(X,true); if(w){ return %ClearBreakPoint(w); }else{ w=this.findScriptBreakPoint(X,true); if(!w)throw %make_error(2,'Invalid breakpoint'); } }; l.clearAllBreakPoints=function(){ for(var C=0;C<q.length;C++){ var w=q[C]; %ClearBreakPoint(w); } q=[]; }; l.disableAllBreakPoints=function(){ for(var C=1;C<p;C++){ l.disableBreakPoint(C); } %ChangeBreakOnException(l.ExceptionBreak.Caught,false); %ChangeBreakOnException(l.ExceptionBreak.Uncaught,false); }; l.findScriptBreakPoint=function(X,Y){ var ab; for(var C=0;C<r.length;C++){ if(r[C].number()==X){ ab=r[C]; if(Y){ ab.clear(); r.splice(C,1); } break; } } return ab; }; l.setScriptBreakPoint=function(n,script_id_or_name, T,U,Z, opt_groupId,opt_position_alignment){ var ab= new ScriptBreakPoint(n,script_id_or_name,T,U, opt_groupId,opt_position_alignment); ab.number_=p++; ab.setCondition(Z); r.push(ab); var O=this.scripts(); for(var C=0;C<O.length;C++){ if(ab.matchesScript(O[C])){ ab.set(O[C]); } } return ab.number(); }; l.setScriptBreakPointById=function(script_id, T,U, Z,opt_groupId, opt_position_alignment){ return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptId, script_id,T,U, Z,opt_groupId, opt_position_alignment); }; l.setScriptBreakPointByName=function(script_name, T,U, Z,opt_groupId){ return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptName, script_name,T,U, Z,opt_groupId); }; l.setScriptBreakPointByRegExp=function(script_regexp, T,U, Z,opt_groupId){ return this.setScriptBreakPoint(l.ScriptBreakPointType.ScriptRegExp, script_regexp,T,U, Z,opt_groupId); }; l.enableScriptBreakPoint=function(X){ var ab=this.findScriptBreakPoint(X,false); ab.enable(); }; l.disableScriptBreakPoint=function(X){ var ab=this.findScriptBreakPoint(X,false); ab.disable(); }; l.changeScriptBreakPointCondition=function( X,x){ var ab=this.findScriptBreakPoint(X,false); ab.setCondition(x); }; l.scriptBreakPoints=function(){ return r; }; l.clearStepping=function(){ %ClearStepping(); }; l.setBreakOnException=function(){ return %ChangeBreakOnException(l.ExceptionBreak.Caught,true); }; l.clearBreakOnException=function(){ return %ChangeBreakOnException(l.ExceptionBreak.Caught,false); }; l.isBreakOnException=function(){ return!!%IsBreakOnException(l.ExceptionBreak.Caught); }; l.setBreakOnUncaughtException=function(){ return %ChangeBreakOnException(l.ExceptionBreak.Uncaught,true); }; l.clearBreakOnUncaughtException=function(){ return %ChangeBreakOnException(l.ExceptionBreak.Uncaught,false); }; l.isBreakOnUncaughtException=function(){ return!!%IsBreakOnException(l.ExceptionBreak.Uncaught); }; l.showBreakPoints=function(R,ac,ad){ if(!(%IsFunction(R)))throw %make_error(36); var ae=ac?this.scriptSource(R):this.source(R); var af=ac?0:this.sourcePosition(R); var aa=(ad===(void 0)) ?l.BreakPositionAlignment.Statement:ad; var B=%GetBreakLocations(R,aa); if(!B)return ae; B.sort(function(ag,ah){return ag-ah;}); var ai=""; var aj=0; var ak; for(var C=0;C<B.length;C++){ ak=B[C]-af; ai+=ae.slice(aj,ak); ai+="[B"+C+"]"; aj=ak; } ak=ae.length; ai+=ae.substring(aj,ak); return ai; }; l.scripts=function(){ return %DebugGetLoadedScripts(); }; function scriptById(al){ var O=l.scripts(); for(var F of O){ if(F.id==al)return F; } return(void 0); }; l.debuggerFlags=function(){ return s; }; l.MakeMirror=g; function MakeExecutionState(A){ return new ExecutionState(A); } function ExecutionState(A){ this.break_id=A; this.selected_frame=0; } ExecutionState.prototype.prepareStep=function(am){ if(am===l.StepAction.StepIn|| am===l.StepAction.StepOut|| am===l.StepAction.StepNext){ return %PrepareStep(this.break_id,am); } throw %make_type_error(36); }; ExecutionState.prototype.evaluateGlobal=function(ae){ return g(%DebugEvaluateGlobal(this.break_id,ae)); }; ExecutionState.prototype.frameCount=function(){ return %GetFrameCount(this.break_id); }; ExecutionState.prototype.frame=function(an){ if(an==null)an=this.selected_frame; if(an<0||an>=this.frameCount()){ throw %make_type_error(35); } return new c(this.break_id,an); }; ExecutionState.prototype.setSelectedFrame=function(ao){ var C=(%_ToNumber(ao)); if(C<0||C>=this.frameCount()){ throw %make_type_error(35); } this.selected_frame=C; }; ExecutionState.prototype.selectedFrame=function(){ return this.selected_frame; }; function MakeBreakEvent(A,ap){ return new BreakEvent(A,ap); } function BreakEvent(A,ap){ this.frame_=new c(A,0); this.break_points_hit_=ap; } BreakEvent.prototype.eventType=function(){ return l.DebugEvent.Break; }; BreakEvent.prototype.func=function(){ return this.frame_.func(); }; BreakEvent.prototype.sourceLine=function(){ return this.frame_.sourceLine(); }; BreakEvent.prototype.sourceColumn=function(){ return this.frame_.sourceColumn(); }; BreakEvent.prototype.sourceLineText=function(){ return this.frame_.sourceLineText(); }; BreakEvent.prototype.breakPointsHit=function(){ return this.break_points_hit_; }; function MakeExceptionEvent(A,aq,ar,as){ return new ExceptionEvent(A,aq,ar,as); } function ExceptionEvent(A,aq,ar,as){ this.exec_state_=new ExecutionState(A); this.exception_=aq; this.uncaught_=ar; this.promise_=as; } ExceptionEvent.prototype.eventType=function(){ return l.DebugEvent.Exception; }; ExceptionEvent.prototype.exception=function(){ return this.exception_; }; ExceptionEvent.prototype.uncaught=function(){ return this.uncaught_; }; ExceptionEvent.prototype.promise=function(){ return this.promise_; }; ExceptionEvent.prototype.func=function(){ return this.exec_state_.frame(0).func(); }; ExceptionEvent.prototype.sourceLine=function(){ return this.exec_state_.frame(0).sourceLine(); }; ExceptionEvent.prototype.sourceColumn=function(){ return this.exec_state_.frame(0).sourceColumn(); }; ExceptionEvent.prototype.sourceLineText=function(){ return this.exec_state_.frame(0).sourceLineText(); }; function MakeCompileEvent(F,n){ return new CompileEvent(F,n); } function CompileEvent(F,n){ this.script_=g(F); this.type_=n; } CompileEvent.prototype.eventType=function(){ return this.type_; }; CompileEvent.prototype.script=function(){ return this.script_; }; function MakeScriptObject_(F,at){ var au={id:F.id(), name:F.name(), lineOffset:F.lineOffset(), columnOffset:F.columnOffset(), lineCount:F.lineCount(), }; if(!(F.data()===(void 0))){ au.data=F.data(); } if(at){ au.source=F.source(); } return au; } function MakeAsyncTaskEvent(n,av){ return new AsyncTaskEvent(n,av); } function AsyncTaskEvent(n,av){ this.type_=n; this.id_=av; } AsyncTaskEvent.prototype.type=function(){ return this.type_; } AsyncTaskEvent.prototype.id=function(){ return this.id_; } b.InstallConstants(a,[ "Debug",l, "BreakEvent",BreakEvent, "CompileEvent",CompileEvent, "BreakPoint",BreakPoint, ]); b.InstallFunctions(b,2,[ "MakeExecutionState",MakeExecutionState, "MakeExceptionEvent",MakeExceptionEvent, "MakeBreakEvent",MakeBreakEvent, "MakeCompileEvent",MakeCompileEvent, "MakeAsyncTaskEvent",MakeAsyncTaskEvent, "IsBreakPointTriggered",IsBreakPointTriggered, ]); }) liveedit}� (function(a,b){ "use strict"; var c=a.Debug.findScriptSourcePosition; var d=a.Array; var e=a.Math.floor; var f=a.Math.max; var g=a.SyntaxError; var h; function ApplyPatchMultiChunk(script,diff_array,new_source,preview_only, change_log){ var i=script.source; var j=GatherCompileInfo(i,script); var k=BuildCodeInfoTree(j); var l=new PosTranslator(diff_array); MarkChangedFunctions(k,l.GetChunks()); FindLiveSharedInfos(k,script); var m; try{ m=GatherCompileInfo(new_source,script); }catch(e){ var n= new Failure("Failed to compile new version of script: "+e); if(e instanceof g){ var o={ type:"liveedit_compile_error", syntaxErrorMessage:e.message }; CopyErrorPositionToDetails(e,o); n.details=o; } throw n; } var p=m.reduce( (max,info)=>f(max,info.function_literal_id),0); var q=BuildCodeInfoTree(m); FindCorrespondingFunctions(k,q); var r=new d(); var s=new d(); var t=new d(); var u=new d(); function HarvestTodo(v){ function CollectDamaged(w){ s.push(w); for(var x=0;x<w.children.length;x++){ CollectDamaged(w.children[x]); } } function CollectNew(y){ for(var x=0;x<y.length;x++){ t.push(y[x]); CollectNew(y[x].children); } } if(v.status==h.DAMAGED){ CollectDamaged(v); return; } if(v.status==h.UNCHANGED){ u.push(v); }else if(v.status==h.SOURCE_CHANGED){ u.push(v); }else if(v.status==h.CHANGED){ r.push(v); CollectNew(v.unmatched_new_nodes); } for(var x=0;x<v.children.length;x++){ HarvestTodo(v.children[x]); } } var z={ change_tree:DescribeChangeTree(k), textual_diff:{ old_len:i.length, new_len:new_source.length, chunks:diff_array }, updated:false }; if(preview_only){ return z; } HarvestTodo(k); var A=new d(); var B=new d(); for(var x=0;x<r.length;x++){ var C=r[x].live_shared_function_infos; var D= r[x].corresponding_node.info.shared_function_info; if(C){ for(var E=0;E<C.length;E++){ A.push(C[E]); B.push(D); } } } var F= CheckStackActivations(A, B, change_log); z.stack_modified=F!=0; var G; if(s.length==0){ %LiveEditReplaceScript(script,new_source,null); G=(void 0); }else{ var H=CreateNameForOldScript(script); G=%LiveEditReplaceScript(script,new_source,H); var I=new d(); change_log.push({linked_to_old_script:I}); for(var x=0;x<s.length;x++){ LinkToOldScript(s[x],G, I); } z.created_script_name=H; } for(var x=0;x<r.length;x++){ PatchFunctionCode(r[x],change_log); } var J=new d(); change_log.push({position_patched:J}); for(var x=0;x<u.length;x++){ PatchPositions(u[x],diff_array, J); if(u[x].live_shared_function_infos){ var K= u[x] .corresponding_node.info.function_literal_id; u[x].live_shared_function_infos.forEach(function( info){ %LiveEditFunctionSourceUpdated( info.raw_array,K); }); } } %LiveEditFixupScript(script,p); for(var x=0;x<t.length;x++){ %LiveEditFunctionSetScript( t[x].info.shared_function_info,script); } z.updated=true; return z; } function GatherCompileInfo(L,M){ var N=%LiveEditGatherCompileInfo(M,L); var O=new d(); var P=new d(); for(var x=0;x<N.length;x++){ var Q=new FunctionCompileInfo(N[x]); %LiveEditFunctionSetScript(Q.shared_function_info,(void 0)); O.push(Q); P.push(x); } for(var x=0;x<O.length;x++){ var R=x; for(var E=x+1;E<O.length;E++){ if(O[R].start_position>O[E].start_position){ R=E; } } if(R!=x){ var S=O[R]; var T=P[R]; O[R]=O[x]; P[R]=P[x]; O[x]=S; P[x]=T; } } var U=0; function ResetIndexes(V,W){ var X=-1; while(U<O.length&& O[U].outer_index==W){ var Y=U; O[Y].outer_index=V; if(X!=-1){ O[X].next_sibling_index=Y; } X=Y; U++; ResetIndexes(Y,P[Y]); } if(X!=-1){ O[X].next_sibling_index=-1; } } ResetIndexes(-1,-1); Assert(U==O.length); return O; } function PatchFunctionCode(v,Z){ var D=v.corresponding_node.info; if(v.live_shared_function_infos){ v.live_shared_function_infos.forEach(function(aa){ %LiveEditReplaceFunctionCode(D.raw_array, aa.raw_array); for(var x=0;x<v.children.length;x++){ if(v.children[x].corresponding_node){ var ab= v.children[x].corresponding_node.info. shared_function_info; if(v.children[x].live_shared_function_infos){ v.children[x].live_shared_function_infos. forEach(function(ac){ %LiveEditReplaceRefToNestedFunction( aa.info, ab, ac.info); }); } } } }); Z.push({function_patched:D.function_name}); }else{ Z.push({function_patched:D.function_name, function_info_not_found:true}); } } function LinkToOldScript(ad,G,ae){ if(ad.live_shared_function_infos){ ad.live_shared_function_infos. forEach(function(Q){ %LiveEditFunctionSetScript(Q.info,G); }); ae.push({name:ad.info.function_name}); }else{ ae.push( {name:ad.info.function_name,not_found:true}); } } function Assert(af,ag){ if(!af){ if(ag){ throw"Assert "+ag; }else{ throw"Assert"; } } } function DiffChunk(ah,ai,aj,ak){ this.pos1=ah; this.pos2=ai; this.len1=aj; this.len2=ak; } function PosTranslator(al){ var am=new d(); var an=0; for(var x=0;x<al.length;x+=3){ var ao=al[x]; var ap=ao+an; var aq=al[x+1]; var ar=al[x+2]; am.push(new DiffChunk(ao,ap,aq-ao, ar-ap)); an=ar-aq; } this.chunks=am; } PosTranslator.prototype.GetChunks=function(){ return this.chunks; }; PosTranslator.prototype.Translate=function(as,at){ var au=this.chunks; if(au.length==0||as<au[0].pos1){ return as; } var av=0; var aw=au.length-1; while(av<aw){ var ax=e((av+aw)/2); if(as<au[ax+1].pos1){ aw=ax; }else{ av=ax+1; } } var ay=au[av]; if(as>=ay.pos1+ay.len1){ return as+ay.pos2+ay.len2-ay.pos1-ay.len1; } if(!at){ at=PosTranslator.DefaultInsideChunkHandler; } return at(as,ay); }; PosTranslator.DefaultInsideChunkHandler=function(as,az){ Assert(false,"Cannot translate position in changed area"); }; PosTranslator.ShiftWithTopInsideChunkHandler= function(as,az){ return as-az.pos1+az.pos2; }; var h={ UNCHANGED:"unchanged", SOURCE_CHANGED:"source changed", CHANGED:"changed", DAMAGED:"damaged" }; function CodeInfoTreeNode(aA,aB,aC){ this.info=aA; this.children=aB; this.array_index=aC; this.parent=(void 0); this.status=h.UNCHANGED; this.status_explanation=(void 0); this.new_start_pos=(void 0); this.new_end_pos=(void 0); this.corresponding_node=(void 0); this.unmatched_new_nodes=(void 0); this.textual_corresponding_node=(void 0); this.textually_unmatched_new_nodes=(void 0); this.live_shared_function_infos=(void 0); } function BuildCodeInfoTree(aD){ var aE=0; function BuildNode(){ var aF=aE; aE++; var aG=new d(); while(aE<aD.length&& aD[aE].outer_index==aF){ aG.push(BuildNode()); } var w=new CodeInfoTreeNode(aD[aF],aG, aF); for(var x=0;x<aG.length;x++){ aG[x].parent=w; } return w; } var aH=BuildNode(); Assert(aE==aD.length); return aH; } function MarkChangedFunctions(aI,am){ var aJ=new function(){ var aK=0; var aL=0; this.current=function(){return am[aK];}; this.next=function(){ var ay=am[aK]; aL=ay.pos2+ay.len2-(ay.pos1+ay.len1); aK++; }; this.done=function(){return aK>=am.length;}; this.TranslatePos=function(as){return as+aL;}; }; function ProcessInternals(aM){ aM.new_start_pos=aJ.TranslatePos( aM.info.start_position); var aN=0; var aO=false; var aP=false; while(!aJ.done()&& aJ.current().pos1<aM.info.end_position){ if(aN<aM.children.length){ var aQ=aM.children[aN]; if(aQ.info.end_position<=aJ.current().pos1){ ProcessUnchangedChild(aQ); aN++; continue; }else if(aQ.info.start_position>= aJ.current().pos1+aJ.current().len1){ aO=true; aJ.next(); continue; }else if(aQ.info.start_position<=aJ.current().pos1&& aQ.info.end_position>=aJ.current().pos1+ aJ.current().len1){ ProcessInternals(aQ); aP=aP|| (aQ.status!=h.UNCHANGED); aO=aO|| (aQ.status==h.DAMAGED); aN++; continue; }else{ aO=true; aQ.status=h.DAMAGED; aQ.status_explanation= "Text diff overlaps with function boundary"; aN++; continue; } }else{ if(aJ.current().pos1+aJ.current().len1<= aM.info.end_position){ aM.status=h.CHANGED; aJ.next(); continue; }else{ aM.status=h.DAMAGED; aM.status_explanation= "Text diff overlaps with function boundary"; return; } } Assert("Unreachable",false); } while(aN<aM.children.length){ var aQ=aM.children[aN]; ProcessUnchangedChild(aQ); aN++; } if(aO){ aM.status=h.CHANGED; }else if(aP){ aM.status=h.SOURCE_CHANGED; } aM.new_end_pos= aJ.TranslatePos(aM.info.end_position); } function ProcessUnchangedChild(w){ w.new_start_pos=aJ.TranslatePos(w.info.start_position); w.new_end_pos=aJ.TranslatePos(w.info.end_position); } ProcessInternals(aI); } function FindCorrespondingFunctions(aR,aS){ function ProcessNode(v,aT){ var aU= IsFunctionContextLocalsChanged(v.info,aT.info); if(aU){ v.status=h.CHANGED; } var aV=v.children; var aW=aT.children; var aX=[]; var aY=[]; var aZ=0; var ba=0; while(aZ<aV.length){ if(aV[aZ].status==h.DAMAGED){ aZ++; }else if(ba<aW.length){ if(aW[ba].info.start_position< aV[aZ].new_start_pos){ aX.push(aW[ba]); aY.push(aW[ba]); ba++; }else if(aW[ba].info.start_position== aV[aZ].new_start_pos){ if(aW[ba].info.end_position== aV[aZ].new_end_pos){ aV[aZ].corresponding_node= aW[ba]; aV[aZ].textual_corresponding_node= aW[ba]; if(aU){ aV[aZ].status=h.DAMAGED; aV[aZ].status_explanation= "Enclosing function is now incompatible. "+ aU; aV[aZ].corresponding_node=(void 0); }else if(aV[aZ].status!= h.UNCHANGED){ ProcessNode(aV[aZ], aW[ba]); if(aV[aZ].status==h.DAMAGED){ aX.push( aV[aZ].corresponding_node); aV[aZ].corresponding_node=(void 0); v.status=h.CHANGED; } }else{ ProcessNode(aV[aZ],aW[ba]); } }else{ aV[aZ].status=h.DAMAGED; aV[aZ].status_explanation= "No corresponding function in new script found"; v.status=h.CHANGED; aX.push(aW[ba]); aY.push(aW[ba]); } ba++; aZ++; }else{ aV[aZ].status=h.DAMAGED; aV[aZ].status_explanation= "No corresponding function in new script found"; v.status=h.CHANGED; aZ++; } }else{ aV[aZ].status=h.DAMAGED; aV[aZ].status_explanation= "No corresponding function in new script found"; v.status=h.CHANGED; aZ++; } } while(ba<aW.length){ aX.push(aW[ba]); aY.push(aW[ba]); ba++; } if(v.status==h.CHANGED){ if(v.info.param_num!=aT.info.param_num){ v.status=h.DAMAGED; v.status_explanation="Changed parameter number: "+ v.info.param_num+" and "+aT.info.param_num; } } v.unmatched_new_nodes=aX; v.textually_unmatched_new_nodes= aY; } ProcessNode(aR,aS); aR.corresponding_node=aS; aR.textual_corresponding_node=aS; Assert(aR.status!=h.DAMAGED, "Script became damaged"); } function FindLiveSharedInfos(aR,M){ var bb=%LiveEditFindSharedFunctionInfosForScript(M); var bc=new d(); for(var x=0;x<bb.length;x++){ bc.push(new SharedInfoWrapper(bb[x])); } function FindFunctionInfos(O){ var bd=[]; for(var x=0;x<bc.length;x++){ var be=bc[x]; if(be.start_position==O.start_position&& be.end_position==O.end_position){ bd.push(be); } } if(bd.length>0){ return bd; } } function TraverseTree(w){ w.live_shared_function_infos=FindFunctionInfos(w.info); for(var x=0;x<w.children.length;x++){ TraverseTree(w.children[x]); } } TraverseTree(aR); } function FunctionCompileInfo(bf){ this.function_name=bf[0]; this.start_position=bf[1]; this.end_position=bf[2]; this.param_num=bf[3]; this.scope_info=bf[4]; this.outer_index=bf[5]; this.shared_function_info=bf[6]; this.function_literal_id=bf[7]; this.next_sibling_index=null; this.raw_array=bf; } function SharedInfoWrapper(bf){ this.function_name=bf[0]; this.start_position=bf[1]; this.end_position=bf[2]; this.info=bf[3]; this.raw_array=bf; } function PatchPositions(ad,al,ae){ if(ad.live_shared_function_infos){ ad.live_shared_function_infos.forEach(function(Q){ %LiveEditPatchFunctionPositions(Q.raw_array, al); }); ae.push({name:ad.info.function_name}); }else{ ae.push( {name:ad.info.function_name,info_not_found:true}); } } function CreateNameForOldScript(M){ return M.name+" (old)"; } function IsFunctionContextLocalsChanged(bg,bh){ var bi=bg.scope_info; var bj=bh.scope_info; var bk; var bl; if(bi){ bk=bi.toString(); }else{ bk=""; } if(bj){ bl=bj.toString(); }else{ bl=""; } if(bk!=bl){ return"Variable map changed: ["+bk+ "] => ["+bl+"]"; } return; } var bm; function CheckStackActivations(old_shared_wrapper_list, new_shared_list, Z){ var bn=new d(); for(var x=0;x<old_shared_wrapper_list.length;x++){ bn[x]=old_shared_wrapper_list[x].info; } var bo=%LiveEditCheckAndDropActivations( bn,new_shared_list,true); if(bo[old_shared_wrapper_list.length]){ throw new Failure(bo[old_shared_wrapper_list.length]); } var bp=new d(); var bq=new d(); for(var x=0;x<bn.length;x++){ var br=old_shared_wrapper_list[x]; if(bo[x]==bm.REPLACED_ON_ACTIVE_STACK){ bq.push({name:br.function_name}); }else if(bo[x]!=bm.AVAILABLE_FOR_PATCH){ var bs={ name:br.function_name, start_pos:br.start_position, end_pos:br.end_position, replace_problem: bm.SymbolName(bo[x]) }; bp.push(bs); } } if(bq.length>0){ Z.push({dropped_from_stack:bq}); } if(bp.length>0){ Z.push({functions_on_stack:bp}); throw new Failure("Blocked by functions on stack"); } return bq.length; } var bm={ AVAILABLE_FOR_PATCH:1, BLOCKED_ON_ACTIVE_STACK:2, BLOCKED_ON_OTHER_STACK:3, BLOCKED_UNDER_NATIVE_CODE:4, REPLACED_ON_ACTIVE_STACK:5, BLOCKED_UNDER_GENERATOR:6, BLOCKED_ACTIVE_GENERATOR:7, BLOCKED_NO_NEW_TARGET_ON_RESTART:8 }; bm.SymbolName=function(bt){ var bu=bm; for(var bv in bu){ if(bu[bv]==bt){ return bv; } } }; function Failure(ag){ this.message=ag; } Failure.prototype.toString=function(){ return"LiveEdit Failure: "+this.message; }; function CopyErrorPositionToDetails(bw,o){ function createPositionStruct(M,bx){ if(bx==-1)return; var by=M.locationFromPosition(bx,true); if(by==null)return; return{ line:by.line+1, column:by.column+1, position:bx }; } if(!("scriptObject"in bw)||!("startPosition"in bw)){ return; } var M=bw.scriptObject; var bz={ start:createPositionStruct(M,bw.startPosition), end:createPositionStruct(M,bw.endPosition) }; o.position=bz; } function SetScriptSource(M,bA,bB,Z){ var i=M.source; var bC=CompareStrings(i,bA); return ApplyPatchMultiChunk(M,bC,bA,bB, Z); } function CompareStrings(bD,bE){ return %LiveEditCompareStrings(bD,bE); } function ApplySingleChunkPatch(M,change_pos,change_len,new_str, Z){ var i=M.source; var bA=i.substring(0,change_pos)+ new_str+i.substring(change_pos+change_len); return ApplyPatchMultiChunk(M, [change_pos,change_pos+change_len,change_pos+new_str.length], bA,false,Z); } function DescribeChangeTree(aR){ function ProcessOldNode(w){ var bF=[]; for(var x=0;x<w.children.length;x++){ var aQ=w.children[x]; if(aQ.status!=h.UNCHANGED){ bF.push(ProcessOldNode(aQ)); } } var bG=[]; if(w.textually_unmatched_new_nodes){ for(var x=0;x<w.textually_unmatched_new_nodes.length;x++){ var aQ=w.textually_unmatched_new_nodes[x]; bG.push(ProcessNewNode(aQ)); } } var bH={ name:w.info.function_name, positions:DescribePositions(w), status:w.status, children:bF, new_children:bG }; if(w.status_explanation){ bH.status_explanation=w.status_explanation; } if(w.textual_corresponding_node){ bH.new_positions=DescribePositions(w.textual_corresponding_node); } return bH; } function ProcessNewNode(w){ var bF=[]; if(false){ for(var x=0;x<w.children.length;x++){ bF.push(ProcessNewNode(w.children[x])); } } var bH={ name:w.info.function_name, positions:DescribePositions(w), children:bF, }; return bH; } function DescribePositions(w){ return{ start_position:w.info.start_position, end_position:w.info.end_position }; } return ProcessOldNode(aR); } var bI={}; bI.SetScriptSource=SetScriptSource; bI.ApplyPatchMultiChunk=ApplyPatchMultiChunk; bI.Failure=Failure; bI.TestApi={ PosTranslator:PosTranslator, CompareStrings:CompareStrings, ApplySingleChunkPatch:ApplySingleChunkPatch }; a.Debug.LiveEdit=bI; }) @ prologue�3 (function(a,b,c){ "use strict"; %CheckIsBootstrapping(); var d=(void 0); var e=%ExportFromRuntime({}); function Export(f){ f(e); } function Import(f){ f.next=d; d=f; } function ImportNow(g){ return e[g]; } function SetFunctionName(f,g,h){ if((typeof(g)==='symbol')){ g="["+%SymbolDescription(g)+"]"; } if((h===(void 0))){ %FunctionSetName(f,g); }else{ %FunctionSetName(f,h+" "+g); } } function InstallConstants(i,j){ %CheckIsBootstrapping(); %OptimizeObjectForAddingMultipleProperties(i,j.length>>1); var k=2|4|1; for(var l=0;l<j.length;l+=2){ var g=j[l]; var m=j[l+1]; %AddNamedProperty(i,g,m,k); } %ToFastProperties(i); } function InstallFunctions(i,k,n){ %CheckIsBootstrapping(); %OptimizeObjectForAddingMultipleProperties(i,n.length>>1); for(var l=0;l<n.length;l+=2){ var o=n[l]; var f=n[l+1]; SetFunctionName(f,o); %FunctionRemovePrototype(f); %AddNamedProperty(i,o,f,k); %SetNativeFlag(f); } %ToFastProperties(i); } function InstallGetter(i,g,p,k,h){ %CheckIsBootstrapping(); if((k===(void 0)))k=2; SetFunctionName(p,g,(h===(void 0))?"get":h); %FunctionRemovePrototype(p); %DefineGetterPropertyUnchecked(i,g,p,k); %SetNativeFlag(p); } function OverrideFunction(i,g,f,q){ %CheckIsBootstrapping(); %object_define_property(i,g,{value:f, writeable:true, configurable:true, enumerable:false}); SetFunctionName(f,g); if(!q)%FunctionRemovePrototype(f); %SetNativeFlag(f); } function SetUpLockedPrototype( constructor,fields,methods){ %CheckIsBootstrapping(); var r=constructor.prototype; var s=(methods.length>>1)+(fields?fields.length:0); if(s>=4){ %OptimizeObjectForAddingMultipleProperties(r,s); } if(fields){ for(var l=0;l<fields.length;l++){ %AddNamedProperty(r,fields[l], (void 0),2|4); } } for(var l=0;l<methods.length;l+=2){ var o=methods[l]; var f=methods[l+1]; %AddNamedProperty(r,o,f,2|4|1); %SetNativeFlag(f); } %InternalSetPrototype(r,null); %ToFastProperties(r); } function PostNatives(b){ %CheckIsBootstrapping(); for(;!(d===(void 0));d=d.next){ d(e); } e=(void 0); b.Export=(void 0); b.Import=(void 0); b.ImportNow=(void 0); b.PostNatives=(void 0); } %OptimizeObjectForAddingMultipleProperties(b,14); b.Import=Import; b.ImportNow=ImportNow; b.Export=Export; b.SetFunctionName=SetFunctionName; b.InstallConstants=InstallConstants; b.InstallFunctions=InstallFunctions; b.InstallGetter=InstallGetter; b.OverrideFunction=OverrideFunction; b.SetUpLockedPrototype=SetUpLockedPrototype; b.PostNatives=PostNatives; %ToFastProperties(b); %OptimizeObjectForAddingMultipleProperties(c,11); c.logStackTrace=function logStackTrace(){ %DebugTrace(); }; c.log=function log(){ let message=''; for(const arg of arguments){ message+=arg; } %GlobalPrint(message); }; c.createPrivateSymbol=function createPrivateSymbol(g){ return %CreatePrivateSymbol(g); }; c.simpleBind=function simpleBind(t,u){ return function(...args){ return %reflect_apply(t,u,args); }; }; c.uncurryThis=function uncurryThis(t){ return function(u,...args){ return %reflect_apply(t,u,args); }; }; c.rejectPromise=function rejectPromise(v,w){ %promise_internal_reject(v,w,true); } c.markPromiseAsHandled=function markPromiseAsHandled(v){ %PromiseMarkAsHandled(v); }; c.promiseState=function promiseState(v){ return %PromiseStatus(v); }; c.kPROMISE_PENDING=0; c.kPROMISE_FULFILLED=1; c.kPROMISE_REJECTED=2; %ToFastProperties(c); }) runtime5 (function(a,b){ %CheckIsBootstrapping(); var c=a.Array; var d=a.Boolean; var e=a.String; var f; b.Import(function(g){ f=g.species_symbol; }); function ToPositiveInteger(h,i){ var j=(%_ToInteger(h))+0; if(j<0)throw %make_range_error(i); return j; } function ToIndex(h,i){ var j=(%_ToInteger(h))+0; if(j<0||j>9007199254740991)throw %make_range_error(i); return j; } function MaxSimple(k,l){ return k>l?k:l; } function MinSimple(k,l){ return k>l?l:k; } %SetForceInlineFlag(MaxSimple); %SetForceInlineFlag(MinSimple); function SpeciesConstructor(m,n){ var o=m.constructor; if((o===(void 0))){ return n; } if(!(%_IsJSReceiver(o))){ throw %make_type_error(30); } var p=o[f]; if((p==null)){ return n; } if(%IsConstructor(p)){ return p; } throw %make_type_error(242); } %FunctionSetPrototype(c,new c(0)); b.Export(function(q){ q.MaxSimple=MaxSimple; q.MinSimple=MinSimple; q.ToPositiveInteger=ToPositiveInteger; q.ToIndex=ToIndex; q.SpeciesConstructor=SpeciesConstructor; }); }) $v8natives� (function(a,b){ %CheckIsBootstrapping(); var c=a.Object; var d=b.ImportNow("iterator_symbol"); var e=b.ImportNow("object_to_string"); var f=2|4|1; function ObjectToLocaleString(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Object.prototype.toLocaleString"); return this.toString(); } function ObjectIsPrototypeOf(g){ if(!(%_IsJSReceiver(g)))return false; var h=(%_ToObject(this)); return %HasInPrototypeChain(g,h); } function GetMethod(i,j){ var k=i[j]; if((k==null))return(void 0); if((typeof(k)==='function'))return k; throw %make_type_error(15,typeof k); } function ObjectConstructor(l){ if(c!=new.target&&!(new.target===(void 0))){ return this; } if((l===null)||(l===(void 0)))return{}; return(%_ToObject(l)); } %SetNativeFlag(c); %SetCode(c,ObjectConstructor); %AddNamedProperty(c.prototype,"constructor",c, 2); b.InstallFunctions(c.prototype,2,[ "toString",e, "toLocaleString",ObjectToLocaleString, "isPrototypeOf",ObjectIsPrototypeOf, ]); function GetIterator(i,m){ if((m===(void 0))){ m=i[d]; } if(!(typeof(m)==='function')){ throw %make_type_error(73,i); } var n=%_Call(m,i); if(!(%_IsJSReceiver(n))){ throw %make_type_error(67,n); } return n; } b.Export(function(o){ o.GetIterator=GetIterator; o.GetMethod=GetMethod; o.ObjectHasOwnProperty=c.prototype.hasOwnProperty; }); }) array9 (function(a,b,c){ "use strict"; %CheckIsBootstrapping(); var d; var e; var f=a.Array; var g=b.InternalArray; var h=b.InternalPackedArray; var i; var j; var k; var l=b.ImportNow("object_to_string"); var m=b.ImportNow("iterator_symbol"); var n=b.ImportNow("unscopables_symbol"); b.Import(function(o){ d=o.GetIterator; e=o.GetMethod; i=o.MaxSimple; j=o.MinSimple; k=o.ObjectHasOwnProperty; }); function ArraySpeciesCreate(p,q){ q=((q)+0); var r=%ArraySpeciesConstructor(p); return new r(q); } function KeySortCompare(s,t){ return s-t; } function GetSortedArrayKeys(p,u){ if((typeof(u)==='number')){ var v=u; var w=new g(); for(var x=0;x<v;++x){ var y=p[x]; if(!(y===(void 0))||x in p){ w.push(x); } } return w; } return InnerArraySort(u,u.length,KeySortCompare); } function SparseJoinWithSeparatorJS(p,w,q,z,A){ var B=w.length; var C=new g(B*2); for(var x=0;x<B;x++){ var D=w[x]; C[x*2]=D; C[x*2+1]=ConvertToString(z,p[D]); } return %SparseJoinWithSeparator(C,q,A); } function SparseJoin(p,w,z){ var B=w.length; var C=new g(B); for(var x=0;x<B;x++){ C[x]=ConvertToString(z,p[w[x]]); } return %StringBuilderConcat(C,B,''); } function UseSparseVariant(p,q,E,F){ if(!E||q<1000||%HasComplexElements(p)){ return false; } if(!%_IsSmi(q)){ return true; } var G=q>>2; var H=%EstimateNumberOfElements(p); return(H<G)&& (F>H*4); } function Stack(){ this.length=0; this.values=new g(); } Stack.prototype.length=null; Stack.prototype.values=null; function StackPush(I,J){ I.values[I.length++]=J; } function StackPop(I){ I.values[--I.length]=null } function StackHas(I,K){ var q=I.length; var L=I.values; for(var x=0;x<q;x++){ if(L[x]===K)return true; } return false; } var M=new Stack(); function DoJoin(p,q,E,A,z){ if(UseSparseVariant(p,q,E,q)){ %NormalizeElements(p); var w=GetSortedArrayKeys(p,%GetArrayKeys(p,q)); if(A===''){ if(w.length===0)return''; return SparseJoin(p,w,z); }else{ return SparseJoinWithSeparatorJS( p,w,q,z,A); } } if(q===1){ return ConvertToString(z,p[0]); } var C=new g(q); for(var x=0;x<q;x++){ C[x]=ConvertToString(z,p[x]); } if(A===''){ return %StringBuilderConcat(C,q,''); }else{ return %StringBuilderJoin(C,q,A); } } function Join(p,q,A,z){ if(q===0)return''; var E=(%_IsArray(p)); if(E){ if(StackHas(M,p))return''; StackPush(M,p); } try{ return DoJoin(p,q,E,A,z); }finally{ if(E)StackPop(M); } } function ConvertToString(z,N){ if((N==null))return''; return(%_ToString(z?N.toLocaleString():N)); } function SparseSlice(p,O,P,Q,R){ var u=%GetArrayKeys(p,O+P); if((typeof(u)==='number')){ var v=u; for(var x=O;x<v;++x){ var S=p[x]; if(!(S===(void 0))||x in p){ %CreateDataProperty(R,x-O,S); } } }else{ var q=u.length; for(var T=0;T<q;++T){ var D=u[T]; if(D>=O){ var S=p[D]; if(!(S===(void 0))||D in p){ %CreateDataProperty(R,D-O,S); } } } } } function SparseMove(p,O,P,Q,U){ if(U===P)return; var V=new g( j(Q-P+U,0xffffffff)); var W; var u=%GetArrayKeys(p,Q); if((typeof(u)==='number')){ var v=u; for(var x=0;x<O&&x<v;++x){ var S=p[x]; if(!(S===(void 0))||x in p){ V[x]=S; } } for(var x=O+P;x<v;++x){ var S=p[x]; if(!(S===(void 0))||x in p){ V[x-P+U]=S; } } }else{ var q=u.length; for(var T=0;T<q;++T){ var D=u[T]; if(D<O){ var S=p[D]; if(!(S===(void 0))||D in p){ V[D]=S; } }else if(D>=O+P){ var S=p[D]; if(!(S===(void 0))||D in p){ var X=D-P+U; V[X]=S; if(X>0xfffffffe){ W=W||new g(); W.push(X); } } } } } %MoveArrayContents(V,p); if(!(W===(void 0))){ var q=W.length; for(var x=0;x<q;++x){ var D=W[x]; p[D]=V[D]; } } } function SimpleSlice(p,O,P,Q,R){ for(var x=0;x<P;x++){ var Y=O+x; if(Y in p){ var S=p[Y]; %CreateDataProperty(R,x,S); } } } function SimpleMove(p,O,P,Q,U){ if(U!==P){ if(U>P){ for(var x=Q-P;x>O;x--){ var Z=x+P-1; var aa=x+U-1; if(Z in p){ p[aa]=p[Z]; }else{ delete p[aa]; } } }else{ for(var x=O;x<Q-P;x++){ var Z=x+P; var aa=x+U; if(Z in p){ p[aa]=p[Z]; }else{ delete p[aa]; } } for(var x=Q;x>Q-P+U;x--){ delete p[x-1]; } } } } function ArrayToString(){ var p; var ab; if((%_IsArray(this))){ ab=this.join; if(ab===ArrayJoin){ return Join(this,this.length,',',false); } p=this; }else{ p=(%_ToObject(this)); ab=p.join; } if(!(typeof(ab)==='function')){ return %_Call(l,p); } return %_Call(ab,p); } function InnerArrayToLocaleString(p,q){ return Join(p,(%_ToLength(q)),',',true); } function ArrayToLocaleString(){ var p=(%_ToObject(this)); var ac=p.length; return InnerArrayToLocaleString(p,ac); } function InnerArrayJoin(A,p,q){ if((A===(void 0))){ A=','; }else{ A=(%_ToString(A)); } if(q===1){ var y=p[0]; if((y==null))return''; return(%_ToString(y)); } return Join(p,q,A,false); } function ArrayJoin(A){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.join"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); return InnerArrayJoin(A,p,q); } function ArrayPop(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.pop"); var p=(%_ToObject(this)); var ad=(%_ToLength(p.length)); if(ad==0){ p.length=ad; return; } ad--; var J=p[ad]; %DeleteProperty_Strict(p,ad); p.length=ad; return J; } function ArrayPush(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.push"); var p=(%_ToObject(this)); var ad=(%_ToLength(p.length)); var ae=arguments.length; if(ae>9007199254740991-ad)throw %make_type_error(231,ae,ad); for(var x=0;x<ae;x++){ p[x+ad]=arguments[x]; } var af=ad+ae; p.length=af; return af; } function SparseReverse(p,Q){ var w=GetSortedArrayKeys(p,%GetArrayKeys(p,Q)); var ag=w.length-1; var ah=0; while(ah<=ag){ var x=w[ah]; var ai=w[ag]; var aj=Q-ai-1; var ak,al; if(aj<=x){ al=ai; while(w[--ag]==ai){} ak=aj; } if(aj>=x){ ak=x; while(w[++ah]==x){} al=Q-x-1; } var am=p[ak]; if(!(am===(void 0))||ak in p){ var an=p[al]; if(!(an===(void 0))||al in p){ p[ak]=an; p[al]=am; }else{ p[al]=am; delete p[ak]; } }else{ var an=p[al]; if(!(an===(void 0))||al in p){ p[ak]=an; delete p[al]; } } } } function PackedArrayReverse(p,Q){ var ai=Q-1; for(var x=0;x<ai;x++,ai--){ var am=p[x]; var an=p[ai]; p[x]=an; p[ai]=am; } return p; } function GenericArrayReverse(p,Q){ var ai=Q-1; for(var x=0;x<ai;x++,ai--){ if(x in p){ var am=p[x]; if(ai in p){ var an=p[ai]; p[x]=an; p[ai]=am; }else{ p[ai]=am; delete p[x]; } }else{ if(ai in p){ var an=p[ai]; p[x]=an; delete p[ai]; } } } return p; } function ArrayReverse(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.reverse"); var p=(%_ToObject(this)); var Q=(%_ToLength(p.length)); var ao=(%_IsArray(p)); if(UseSparseVariant(p,Q,ao,Q)){ %NormalizeElements(p); SparseReverse(p,Q); return p; }else if(ao&&%_HasFastPackedElements(p)){ return PackedArrayReverse(p,Q); }else{ return GenericArrayReverse(p,Q); } } function ArrayShift(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.shift"); var p=(%_ToObject(this)); var Q=(%_ToLength(p.length)); if(Q===0){ p.length=0; return; } if(%object_is_sealed(p))throw %make_type_error(13); var ap=p[0]; if(UseSparseVariant(p,Q,(%_IsArray(p)),Q)){ SparseMove(p,0,1,Q,0); }else{ SimpleMove(p,0,1,Q,0); } p.length=Q-1; return ap; } function ArrayUnshift(aq){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.unshift"); var p=(%_ToObject(this)); var Q=(%_ToLength(p.length)); var ar=arguments.length; if(Q>0&&UseSparseVariant(p,Q,(%_IsArray(p)),Q)&& !%object_is_sealed(p)){ SparseMove(p,0,0,Q,ar); }else{ SimpleMove(p,0,0,Q,ar); } for(var x=0;x<ar;x++){ p[x]=arguments[x]; } var af=Q+ar; p.length=af; return af; } function ArraySlice(as,at){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.slice"); var p=(%_ToObject(this)); var Q=(%_ToLength(p.length)); var O=(%_ToInteger(as)); var au=Q; if(!(at===(void 0)))au=(%_ToInteger(at)); if(O<0){ O+=Q; if(O<0)O=0; }else{ if(O>Q)O=Q; } if(au<0){ au+=Q; if(au<0)au=0; }else{ if(au>Q)au=Q; } var av=ArraySpeciesCreate(p,i(au-O,0)); if(au<O)return av; if(UseSparseVariant(p,Q,(%_IsArray(p)),au-O)){ %NormalizeElements(p); if((%_IsArray(av)))%NormalizeElements(av); SparseSlice(p,O,au-O,Q,av); }else{ SimpleSlice(p,O,au-O,Q,av); } av.length=au-O; return av; } function ComputeSpliceStartIndex(O,Q){ if(O<0){ O+=Q; return O<0?0:O; } return O>Q?Q:O; } function ComputeSpliceDeleteCount(aw,ar,Q,O){ var P=0; if(ar==1) return Q-O; P=(%_ToInteger(aw)); if(P<0) return 0; if(P>Q-O) return Q-O; return P; } function ArraySplice(as,aw){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.splice"); var ar=arguments.length; var p=(%_ToObject(this)); var Q=(%_ToLength(p.length)); var O=ComputeSpliceStartIndex((%_ToInteger(as)),Q); var P=ComputeSpliceDeleteCount(aw,ar,Q, O); var R=ArraySpeciesCreate(p,P); R.length=P; var ax=ar>2?ar-2:0; if(P!=ax&&%object_is_sealed(p)){ throw %make_type_error(13); }else if(P>0&&%object_is_frozen(p)){ throw %make_type_error(12); } var ay=P; if(ax!=P){ ay+=Q-O-P; } if(UseSparseVariant(p,Q,(%_IsArray(p)),ay)){ %NormalizeElements(p); if((%_IsArray(R)))%NormalizeElements(R); SparseSlice(p,O,P,Q,R); SparseMove(p,O,P,Q,ax); }else{ SimpleSlice(p,O,P,Q,R); SimpleMove(p,O,P,Q,ax); } var x=O; var az=2; var aA=arguments.length; while(az<aA){ p[x++]=arguments[az++]; } p.length=Q-P+ax; return R; } function InnerArraySort(p,q,aB){ if(!(typeof(aB)==='function')){ aB=function(N,aC){ if(N===aC)return 0; if(%_IsSmi(N)&&%_IsSmi(aC)){ return %SmiLexicographicCompare(N,aC); } N=(%_ToString(N)); aC=(%_ToString(aC)); if(N==aC)return 0; else return N<aC?-1:1; }; } function InsertionSort(s,o,aD){ for(var x=o+1;x<aD;x++){ var aE=s[x]; for(var ai=x-1;ai>=o;ai--){ var aF=s[ai]; var aG=aB(aF,aE); if(aG>0){ s[ai+1]=aF; }else{ break; } } s[ai+1]=aE; } }; function GetThirdIndex(s,o,aD){ var aH=new g(); var aI=200+((aD-o)&15); var ai=0; o+=1; aD-=1; for(var x=o;x<aD;x+=aI){ aH[ai]=[x,s[x]]; ai++; } aH.sort(function(s,t){ return aB(s[1],t[1]); }); var aJ=aH[aH.length>>1][0]; return aJ; } function QuickSort(s,o,aD){ var aJ=0; while(true){ if(aD-o<=10){ InsertionSort(s,o,aD); return; } if(aD-o>1000){ aJ=GetThirdIndex(s,o,aD); }else{ aJ=o+((aD-o)>>1); } var aK=s[o]; var aL=s[aD-1]; var aM=s[aJ]; var aN=aB(aK,aL); if(aN>0){ var aF=aK; aK=aL; aL=aF; } var aO=aB(aK,aM); if(aO>=0){ var aF=aK; aK=aM; aM=aL; aL=aF; }else{ var aP=aB(aL,aM); if(aP>0){ var aF=aL; aL=aM; aM=aF; } } s[o]=aK; s[aD-1]=aM; var aQ=aL; var aR=o+1; var aS=aD-1; s[aJ]=s[aR]; s[aR]=aQ; partition:for(var x=aR+1;x<aS;x++){ var aE=s[x]; var aG=aB(aE,aQ); if(aG<0){ s[x]=s[aR]; s[aR]=aE; aR++; }else if(aG>0){ do{ aS--; if(aS==x)break partition; var aT=s[aS]; aG=aB(aT,aQ); }while(aG>0); s[x]=s[aS]; s[aS]=aE; if(aG<0){ aE=s[x]; s[x]=s[aR]; s[aR]=aE; aR++; } } } if(aD-aS<aR-o){ QuickSort(s,aS,aD); aD=aR; }else{ QuickSort(s,o,aR); o=aS; } } }; function CopyFromPrototype(aU,q){ var aV=0; for(var aW=%object_get_prototype_of(aU);aW; aW=%object_get_prototype_of(aW)){ var u=(%_IsJSProxy(aW))?q:%GetArrayKeys(aW,q); if((typeof(u)==='number')){ var aX=u; for(var x=0;x<aX;x++){ if(!(%_Call(k,aU,x))&&(%_Call(k,aW,x))){ aU[x]=aW[x]; if(x>=aV){aV=x+1;} } } }else{ for(var x=0;x<u.length;x++){ var Y=u[x]; if(!(%_Call(k,aU,Y))&&(%_Call(k,aW,Y))){ aU[Y]=aW[Y]; if(Y>=aV){aV=Y+1;} } } } } return aV; }; function ShadowPrototypeElements(aU,o,aD){ for(var aW=%object_get_prototype_of(aU);aW; aW=%object_get_prototype_of(aW)){ var u=(%_IsJSProxy(aW))?aD:%GetArrayKeys(aW,aD); if((typeof(u)==='number')){ var aX=u; for(var x=o;x<aX;x++){ if((%_Call(k,aW,x))){ aU[x]=(void 0); } } }else{ for(var x=0;x<u.length;x++){ var Y=u[x]; if(o<=Y&&(%_Call(k,aW,Y))){ aU[Y]=(void 0); } } } } }; function SafeRemoveArrayHoles(aU){ var aY=0; var aZ=q-1; var ba=0; while(aY<aZ){ while(aY<aZ&& !(aU[aY]===(void 0))){ aY++; } if(!(%_Call(k,aU,aY))){ ba++; } while(aY<aZ&& (aU[aZ]===(void 0))){ if(!(%_Call(k,aU,aZ))){ ba++; } aZ--; } if(aY<aZ){ aU[aY]=aU[aZ]; aU[aZ]=(void 0); } } if(!(aU[aY]===(void 0)))aY++; var x; for(x=aY;x<q-ba;x++){ aU[x]=(void 0); } for(x=q-ba;x<q;x++){ if(x in %object_get_prototype_of(aU)){ aU[x]=(void 0); }else{ delete aU[x]; } } return aY; }; if(q<2)return p; var E=(%_IsArray(p)); var bb; if(!E){ bb=CopyFromPrototype(p,q); } var bc=%RemoveArrayHoles(p,q); if(bc==-1){ bc=SafeRemoveArrayHoles(p); } QuickSort(p,0,bc); if(!E&&(bc+1<bb)){ ShadowPrototypeElements(p,bc,bb); } return p; } function ArraySort(aB){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.sort"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); return InnerArraySort(p,q,aB); } function InnerArrayFilter(bd,be,p,q,av){ var bf=0; for(var x=0;x<q;x++){ if(x in p){ var aE=p[x]; if(%_Call(bd,be,aE,x,p)){ %CreateDataProperty(av,bf,aE); bf++; } } } return av; } function ArrayFilter(bd,be){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.filter"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); if(!(typeof(bd)==='function'))throw %make_type_error(15,bd); var av=ArraySpeciesCreate(p,0); return InnerArrayFilter(bd,be,p,q,av); } function ArrayMap(bd,be){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.map"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); if(!(typeof(bd)==='function'))throw %make_type_error(15,bd); var av=ArraySpeciesCreate(p,q); for(var x=0;x<q;x++){ if(x in p){ var aE=p[x]; %CreateDataProperty(av,x,%_Call(bd,be,aE,x,p)); } } return av; } function ArrayLastIndexOf(aE,Y){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.lastIndexOf"); var p=this; var q=(%_ToLength(this.length)); if(q==0)return-1; if(arguments.length<2){ Y=q-1; }else{ Y=(((%_ToInteger(Y)))+0); if(Y<0)Y+=q; if(Y<0)return-1; else if(Y>=q)Y=q-1; } var bg=0; var aV=Y; if(UseSparseVariant(p,q,(%_IsArray(p)),Y)){ %NormalizeElements(p); var u=%GetArrayKeys(p,Y+1); if((typeof(u)==='number')){ aV=u; }else{ if(u.length==0)return-1; var bh=GetSortedArrayKeys(p,u); var x=bh.length-1; while(x>=0){ var D=bh[x]; if(p[D]===aE)return D; x--; } return-1; } } if(!(aE===(void 0))){ for(var x=aV;x>=bg;x--){ if(p[x]===aE)return x; } return-1; } for(var x=aV;x>=bg;x--){ if((p[x]===(void 0))&&x in p){ return x; } } return-1; } function ArrayCopyWithin(bi,as,at){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.copyWithin"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); bi=(%_ToInteger(bi)); var aD; if(bi<0){ aD=i(q+bi,0); }else{ aD=j(bi,q); } as=(%_ToInteger(as)); var o; if(as<0){ o=i(q+as,0); }else{ o=j(as,q); } at=(at===(void 0))?q:(%_ToInteger(at)); var bj; if(at<0){ bj=i(q+at,0); }else{ bj=j(at,q); } var bk=j(bj-o,q-aD); var bl=1; if(o<aD&&aD<(o+bk)){ bl=-1; o=o+bk-1; aD=aD+bk-1; } while(bk>0){ if(o in p){ p[aD]=p[o]; }else{ delete p[aD]; } o=o+bl; aD=aD+bl; bk--; } return p; } function InnerArrayFind(bm,bn,p,q){ if(!(typeof(bm)==='function')){ throw %make_type_error(15,bm); } for(var x=0;x<q;x++){ var aE=p[x]; if(%_Call(bm,bn,aE,x,p)){ return aE; } } return; } function ArrayFind(bm,bn){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.find"); var p=(%_ToObject(this)); var q=(%_ToInteger(p.length)); return InnerArrayFind(bm,bn,p,q); } function InnerArrayFindIndex(bm,bn,p,q){ if(!(typeof(bm)==='function')){ throw %make_type_error(15,bm); } for(var x=0;x<q;x++){ var aE=p[x]; if(%_Call(bm,bn,aE,x,p)){ return x; } } return-1; } function ArrayFindIndex(bm,bn){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.findIndex"); var p=(%_ToObject(this)); var q=(%_ToInteger(p.length)); return InnerArrayFindIndex(bm,bn,p,q); } function ArrayFill(J,as,at){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Array.prototype.fill"); var p=(%_ToObject(this)); var q=(%_ToLength(p.length)); var x=(as===(void 0))?0:(%_ToInteger(as)); var at=(at===(void 0))?q:(%_ToInteger(at)); if(x<0){ x+=q; if(x<0)x=0; }else{ if(x>q)x=q; } if(at<0){ at+=q; if(at<0)at=0; }else{ if(at>q)at=q; } if((at-x)>0&&%object_is_frozen(p)){ throw %make_type_error(12); } for(;x<at;x++) p[x]=J; return p; } function ArrayFrom(bo,bp,be){ var bq=(%_ToObject(bo)); var br=!(bp===(void 0)); if(br){ if(!(typeof(bp)==='function')){ throw %make_type_error(15,bp); } } var bs=e(bq,m); var T; var av; var bt; var bu; if(!(bs===(void 0))){ av=%IsConstructor(this)?new this():[]; T=0; for(bu of {[m](){return d(bq,bs)}}){ if(br){ bt=%_Call(bp,be,bu,T); }else{ bt=bu; } %CreateDataProperty(av,T,bt); T++; } av.length=T; return av; }else{ var Q=(%_ToLength(bq.length)); av=%IsConstructor(this)?new this(Q):new f(Q); for(T=0;T<Q;++T){ bu=bq[T]; if(br){ bt=%_Call(bp,be,bu,T); }else{ bt=bu; } %CreateDataProperty(av,T,bt); } av.length=T; return av; } } function ArrayOf(...args){ var q=args.length; var r=this; var p=%IsConstructor(r)?new r(q):[]; for(var x=0;x<q;x++){ %CreateDataProperty(p,x,args[x]); } p.length=q; return p; } %AddNamedProperty(f.prototype,"constructor",f, 2); var bv={ __proto__:null, copyWithin:true, entries:true, fill:true, find:true, findIndex:true, includes:true, keys:true, }; %AddNamedProperty(f.prototype,n,bv, 2|1); %FunctionSetLength(ArrayFrom,1); b.InstallFunctions(f,2,[ "from",ArrayFrom, "of",ArrayOf ]); var bw=%SpecialArrayFunctions(); function getFunction(bx,by,Q){ var bd=by; if(bw.hasOwnProperty(bx)){ bd=bw[bx]; } if(!(Q===(void 0))){ %FunctionSetLength(bd,Q); } return bd; }; var bz={ "entries":getFunction("entries",null,0), "keys":getFunction("keys",null,0), "values":getFunction("values",null,0) } b.InstallFunctions(f.prototype,2,[ "toString",getFunction("toString",ArrayToString), "toLocaleString",getFunction("toLocaleString",ArrayToLocaleString), "join",getFunction("join",ArrayJoin), "pop",getFunction("pop",ArrayPop), "push",getFunction("push",ArrayPush,1), "reverse",getFunction("reverse",ArrayReverse), "shift",getFunction("shift",ArrayShift), "unshift",getFunction("unshift",ArrayUnshift,1), "slice",getFunction("slice",ArraySlice,2), "splice",getFunction("splice",ArraySplice,2), "sort",getFunction("sort",ArraySort), "filter",getFunction("filter",ArrayFilter,1), "map",getFunction("map",ArrayMap,1), "indexOf",getFunction("indexOf",null,1), "lastIndexOf",getFunction("lastIndexOf",ArrayLastIndexOf,1), "copyWithin",getFunction("copyWithin",ArrayCopyWithin,2), "find",getFunction("find",ArrayFind,1), "findIndex",getFunction("findIndex",ArrayFindIndex,1), "fill",getFunction("fill",ArrayFill,1), "includes",getFunction("includes",null,1), "entries",bz.entries, "keys",bz.keys, m,bz.values ]); %FunctionSetName(bz.entries,"entries"); %FunctionSetName(bz.keys,"keys"); %FunctionSetName(bz.values,"values"); b.SetUpLockedPrototype(g,f(),[ "indexOf",getFunction("indexOf",null), "join",getFunction("join",ArrayJoin), "pop",getFunction("pop",ArrayPop), "push",getFunction("push",ArrayPush), "shift",getFunction("shift",ArrayShift), "sort",getFunction("sort",ArraySort), "splice",getFunction("splice",ArraySplice) ]); b.SetUpLockedPrototype(h,f(),[ "join",getFunction("join",ArrayJoin), "pop",getFunction("pop",ArrayPop), "push",getFunction("push",ArrayPush), "shift",getFunction("shift",ArrayShift) ]); b.SetUpLockedPrototype(c.InternalPackedArray,f(),[ "push",getFunction("push",ArrayPush), "pop",getFunction("pop",ArrayPop), "shift",getFunction("shift",ArrayShift), "unshift",getFunction("unshift",ArrayUnshift), "splice",getFunction("splice",ArraySplice), "slice",getFunction("slice",ArraySlice) ]); b.Export(function(aD){ aD.ArrayFrom=ArrayFrom; aD.ArrayJoin=ArrayJoin; aD.ArrayPush=ArrayPush; aD.ArrayToString=ArrayToString; aD.ArrayValues=bz.values, aD.InnerArrayFilter=InnerArrayFilter; aD.InnerArrayFind=InnerArrayFind; aD.InnerArrayFindIndex=InnerArrayFindIndex; aD.InnerArrayJoin=InnerArrayJoin; aD.InnerArraySort=InnerArraySort; aD.InnerArrayToLocaleString=InnerArrayToLocaleString; }); %InstallToContext([ "array_entries_iterator",bz.entries, "array_keys_iterator",bz.keys, "array_pop",ArrayPop, "array_push",ArrayPush, "array_shift",ArrayShift, "array_splice",ArraySplice, "array_slice",ArraySlice, "array_unshift",ArrayUnshift, "array_values_iterator",bz.values, ]); }); string�N (function(a,b){ %CheckIsBootstrapping(); var c=a.String; var d=b.ImportNow("match_symbol"); var e=b.ImportNow("search_symbol"); function StringMatchJS(f){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.match"); if(!(f==null)){ var g=f[d]; if(!(g===(void 0))){ return %_Call(g,f,this); } } var h=(%_ToString(this)); var i=%RegExpCreate(f); return i[d](h); } function StringSearch(f){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.search"); if(!(f==null)){ var j=f[e]; if(!(j===(void 0))){ return %_Call(j,f,this); } } var h=(%_ToString(this)); var i=%RegExpCreate(f); return %_Call(i[e],i,h); } function StringSlice(k,l){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.slice"); var m=(%_ToString(this)); var n=m.length; var o=(%_ToInteger(k)); var p=n; if(!(l===(void 0))){ p=(%_ToInteger(l)); } if(o<0){ o+=n; if(o<0){ o=0; } }else{ if(o>n){ return''; } } if(p<0){ p+=n; if(p<0){ return''; } }else{ if(p>n){ p=n; } } if(p<=o){ return''; } return %_SubString(m,o,p); } function HtmlEscape(q){ return %RegExpInternalReplace(/"/g,(%_ToString(q)),"""); } function StringAnchor(r){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.anchor"); return"<a name=\""+HtmlEscape(r)+"\">"+(%_ToString(this))+ "</a>"; } function StringBig(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.big"); return"<big>"+(%_ToString(this))+"</big>"; } function StringBlink(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.blink"); return"<blink>"+(%_ToString(this))+"</blink>"; } function StringBold(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.bold"); return"<b>"+(%_ToString(this))+"</b>"; } function StringFixed(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.fixed"); return"<tt>"+(%_ToString(this))+"</tt>"; } function StringFontcolor(s){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.fontcolor"); return"<font color=\""+HtmlEscape(s)+"\">"+(%_ToString(this))+ "</font>"; } function StringFontsize(t){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.fontsize"); return"<font size=\""+HtmlEscape(t)+"\">"+(%_ToString(this))+ "</font>"; } function StringItalics(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.italics"); return"<i>"+(%_ToString(this))+"</i>"; } function StringLink(m){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.link"); return"<a href=\""+HtmlEscape(m)+"\">"+(%_ToString(this))+"</a>"; } function StringSmall(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.small"); return"<small>"+(%_ToString(this))+"</small>"; } function StringStrike(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.strike"); return"<strike>"+(%_ToString(this))+"</strike>"; } function StringSub(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.sub"); return"<sub>"+(%_ToString(this))+"</sub>"; } function StringSup(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.sup"); return"<sup>"+(%_ToString(this))+"</sup>"; } function StringRepeat(u){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.repeat"); var m=(%_ToString(this)); var v=(%_ToInteger(u)); if(v<0||v===(1/0))throw %make_range_error(162); if(m.length===0)return""; if(v>%_MaxSmi())throw %make_range_error(171); var w=""; while(true){ if(v&1)w+=m; v>>=1; if(v===0)return w; m+=m; } } function StringCodePointAt(x){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.codePointAt"); var y=(%_ToString(this)); var t=y.length; x=(%_ToInteger(x)); if(x<0||x>=t){ return(void 0); } var z=%_StringCharCodeAt(y,x); if(z<0xD800||z>0xDBFF||x+1==t){ return z; } var A=%_StringCharCodeAt(y,x+1); if(A<0xDC00||A>0xDFFF){ return z; } return(z-0xD800)*0x400+A+0x2400; } function StringRaw(B){ "use strict"; var C=arguments.length; var D=(%_ToObject(B)); var E=(%_ToObject(D.raw)); var F=(%_ToLength(E.length)); if(F<=0)return""; var G=(%_ToString(E[0])); for(var H=1;H<F;++H){ if(H<C){ G+=(%_ToString(arguments[H])); } G+=(%_ToString(E[H])); } return G; } b.InstallFunctions(c,2,[ "raw",StringRaw ]); b.InstallFunctions(c.prototype,2,[ "codePointAt",StringCodePointAt, "match",StringMatchJS, "repeat",StringRepeat, "search",StringSearch, "slice",StringSlice, "link",StringLink, "anchor",StringAnchor, "fontcolor",StringFontcolor, "fontsize",StringFontsize, "big",StringBig, "blink",StringBlink, "bold",StringBold, "fixed",StringFixed, "italics",StringItalics, "small",StringSmall, "strike",StringStrike, "sub",StringSub, "sup",StringSup ]); }) (typedarrayƷ (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c=b.ImportNow("ArrayToString"); var d; var e; var f; var g=a.Array; var h=a.ArrayBuffer; var i=h.prototype; var j=a.Object; var k; var l; var m; var n; var o; var p; var q=b.InternalArray; var r; var s; var t; var u; var v; var w=b.ImportNow("iterator_symbol"); var x=b.ImportNow("to_string_tag_symbol"); var y=a.Uint8Array; var z=a.Int8Array; var A=a.Uint16Array; var B=a.Int16Array; var C=a.Uint32Array; var D=a.Int32Array; var E=a.Float32Array; var F=a.Float64Array; var G=a.Uint8ClampedArray; var H=%object_get_prototype_of(y); b.Import(function(I){ d=I.ArrayValues; e=I.GetIterator; f=I.GetMethod; k=I.InnerArrayFilter; l=I.InnerArrayFind; m=I.InnerArrayFindIndex; n=I.InnerArrayJoin; o=I.InnerArraySort; p=I.InnerArrayToLocaleString; r=I.MaxSimple; s=I.MinSimple; t=I.SpeciesConstructor; u=I.ToPositiveInteger; v=I.ToIndex; }); function TypedArrayDefaultConstructor(J){ switch(%_ClassOf(J)){ case"Uint8Array": return y; case"Int8Array": return z; case"Uint16Array": return A; case"Int16Array": return B; case"Uint32Array": return C; case"Int32Array": return D; case"Float32Array": return E; case"Float64Array": return F; case"Uint8ClampedArray": return G; } throw %make_type_error(48, "TypedArrayDefaultConstructor",this); } function TypedArrayCreate(K,L,M,N){ if((M===(void 0))){ var O=new K(L); }else{ var O=new K(L,M,N); } if(!(%_IsTypedArray(O)))throw %make_type_error(75); if((typeof(L)==='number')&&%_TypedArrayGetLength(O)<L){ throw %make_type_error(258); } return O; } function TypedArraySpeciesCreate(P,L,M,N,Q){ var R=TypedArrayDefaultConstructor(P); var K=t(P,R, Q); return TypedArrayCreate(K,L,M,N); } function Uint8ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,1); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,1); } } function Uint8ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*1; %typed_array_construct_by_array_like(S,J,aa,1); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Uint8ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,1); }else if((%_IsTypedArray(M))){ Uint8ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,1); }else{ Uint8ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,1); } }else{ throw %make_type_error(29,"Uint8Array") } } function Uint8ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*1; return new y(%TypedArrayGetBuffer(this),am,al); } function Int8ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,1); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,1); } } function Int8ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*1; %typed_array_construct_by_array_like(S,J,aa,1); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Int8ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,1); }else if((%_IsTypedArray(M))){ Int8ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,1); }else{ Int8ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,1); } }else{ throw %make_type_error(29,"Int8Array") } } function Int8ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*1; return new z(%TypedArrayGetBuffer(this),am,al); } function Uint16ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,2); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,2); } } function Uint16ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*2; %typed_array_construct_by_array_like(S,J,aa,2); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Uint16ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,2); }else if((%_IsTypedArray(M))){ Uint16ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,2); }else{ Uint16ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,2); } }else{ throw %make_type_error(29,"Uint16Array") } } function Uint16ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*2; return new A(%TypedArrayGetBuffer(this),am,al); } function Int16ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,2); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,2); } } function Int16ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*2; %typed_array_construct_by_array_like(S,J,aa,2); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Int16ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,2); }else if((%_IsTypedArray(M))){ Int16ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,2); }else{ Int16ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,2); } }else{ throw %make_type_error(29,"Int16Array") } } function Int16ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*2; return new B(%TypedArrayGetBuffer(this),am,al); } function Uint32ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,4); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,4); } } function Uint32ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*4; %typed_array_construct_by_array_like(S,J,aa,4); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Uint32ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,4); }else if((%_IsTypedArray(M))){ Uint32ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,4); }else{ Uint32ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,4); } }else{ throw %make_type_error(29,"Uint32Array") } } function Uint32ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*4; return new C(%TypedArrayGetBuffer(this),am,al); } function Int32ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,4); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,4); } } function Int32ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*4; %typed_array_construct_by_array_like(S,J,aa,4); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Int32ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,4); }else if((%_IsTypedArray(M))){ Int32ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,4); }else{ Int32ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,4); } }else{ throw %make_type_error(29,"Int32Array") } } function Int32ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*4; return new D(%TypedArrayGetBuffer(this),am,al); } function Float32ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,4); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,4); } } function Float32ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*4; %typed_array_construct_by_array_like(S,J,aa,4); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Float32ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,4); }else if((%_IsTypedArray(M))){ Float32ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,4); }else{ Float32ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,4); } }else{ throw %make_type_error(29,"Float32Array") } } function Float32ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*4; return new E(%TypedArrayGetBuffer(this),am,al); } function Float64ArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,8); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,8); } } function Float64ArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*8; %typed_array_construct_by_array_like(S,J,aa,8); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Float64ArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,8); }else if((%_IsTypedArray(M))){ Float64ArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,8); }else{ Float64ArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,8); } }else{ throw %make_type_error(29,"Float64Array") } } function Float64ArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*8; return new F(%TypedArrayGetBuffer(this),am,al); } function Uint8ClampedArrayConstructByIterable(S,T,U){ if(%IterableToListCanBeElided(T)){ %typed_array_construct_by_array_like( S,T,T.length,1); }else{ var V=new q(); var W=%_Call(U,T); var X={ __proto__:null }; X[w]=function(){return W;} for(var Y of X){ V.push(Y); } %typed_array_construct_by_array_like(S,V,V.length,1); } } function Uint8ClampedArrayConstructByTypedArray(S,J){ var Z=%TypedArrayGetBuffer(J); var aa=%_TypedArrayGetLength(J); var ab=%_ArrayBufferViewGetByteLength(J); var ac=aa*1; %typed_array_construct_by_array_like(S,J,aa,1); var ad=(%_ClassOf(Z)==='SharedArrayBuffer') ?h :t(Z,h); var ae=ad.prototype; if((%_IsJSReceiver(ae))&&ae!==i){ %InternalSetPrototype(%TypedArrayGetBuffer(S),ae); } } function Uint8ClampedArrayConstructor(M,N,af){ if(!(new.target===(void 0))){ if((%_ClassOf(M)==='ArrayBuffer')||(%_ClassOf(M)==='SharedArrayBuffer')){ %typed_array_construct_by_array_buffer( this,M,N,af,1); }else if((%_IsTypedArray(M))){ Uint8ClampedArrayConstructByTypedArray(this,M); }else if((%_IsJSReceiver(M))){ var U=M[w]; if((U===(void 0))){ %typed_array_construct_by_array_like( this,M,M.length,1); }else{ Uint8ClampedArrayConstructByIterable(this,M,U); } }else{ %typed_array_construct_by_length(this,M,1); } }else{ throw %make_type_error(29,"Uint8ClampedArray") } } function Uint8ClampedArraySubArray(ag,ah){ var ai=(%_ToInteger(ag)); if(!(ah===(void 0))){ var aj=(%_ToInteger(ah)); var ak=%_TypedArrayGetLength(this); }else{ var ak=%_TypedArrayGetLength(this); var aj=ak; } if(ai<0){ ai=r(0,ak+ai); }else{ ai=s(ai,ak); } if(aj<0){ aj=r(0,ak+aj); }else{ aj=s(aj,ak); } if(aj<ai){ aj=ai; } var al=aj-ai; var am= %_ArrayBufferViewGetByteOffset(this)+ai*1; return new G(%TypedArrayGetBuffer(this),am,al); } function TypedArraySubArray(ag,ah){ switch(%_ClassOf(this)){ case"Uint8Array": return %_Call(Uint8ArraySubArray,this,ag,ah); case"Int8Array": return %_Call(Int8ArraySubArray,this,ag,ah); case"Uint16Array": return %_Call(Uint16ArraySubArray,this,ag,ah); case"Int16Array": return %_Call(Int16ArraySubArray,this,ag,ah); case"Uint32Array": return %_Call(Uint32ArraySubArray,this,ag,ah); case"Int32Array": return %_Call(Int32ArraySubArray,this,ag,ah); case"Float32Array": return %_Call(Float32ArraySubArray,this,ag,ah); case"Float64Array": return %_Call(Float64ArraySubArray,this,ag,ah); case"Uint8ClampedArray": return %_Call(Uint8ClampedArraySubArray,this,ag,ah); } throw %make_type_error(48, "get TypedArray.prototype.subarray",this); } %SetForceInlineFlag(TypedArraySubArray); function TypedArraySetFromArrayLike(an,ao,ap,aq){ if(aq>0){ for(var ar=0;ar<ap;ar++){ an[aq+ar]=ao[ar]; } } else{ for(var ar=0;ar<ap;ar++){ an[ar]=ao[ar]; } } } %InstallToContext([ 'typed_array_set_from_array_like',TypedArraySetFromArrayLike]); function TypedArraySetFromOverlappingTypedArray(an,ao,aq){ var as=ao.BYTES_PER_ELEMENT; var at=an.BYTES_PER_ELEMENT; var ap=%_TypedArrayGetLength(ao); function CopyLeftPart(){ var au=%_ArrayBufferViewGetByteOffset(an)+ (aq+1)*at; var av=%_ArrayBufferViewGetByteOffset(ao); for(var aw=0; aw<ap&&au<=av; aw++){ an[aq+aw]=ao[aw]; au+=at; av+=as; } return aw; } var aw=CopyLeftPart(); function CopyRightPart(){ var au=%_ArrayBufferViewGetByteOffset(an)+ (aq+ap-1)*at; var av=%_ArrayBufferViewGetByteOffset(ao)+ ap*as; for(var ax=ap-1; ax>=aw&&au>=av; ax--){ an[aq+ax]=ao[ax]; au-=at; av-=as; } return ax; } var ax=CopyRightPart(); var ay=new g(ax+1-aw); for(var ar=aw;ar<=ax;ar++){ ay[ar-aw]=ao[ar]; } for(ar=aw;ar<=ax;ar++){ an[aq+ar]=ay[ar-aw]; } } function TypedArraySet(S,aq){ var az=(aq===(void 0))?0:(%_ToInteger(aq)); if(az<0)throw %make_type_error(184); if(az>%_MaxSmi()){ throw %make_range_error(185); } switch(%TypedArraySetFastCases(this,S,az)){ case 0: return; case 1: TypedArraySetFromOverlappingTypedArray(this,S,az); return; case 2: TypedArraySetFromArrayLike(this, S,%_TypedArrayGetLength(S),az); return; case 3: var aA=S.length; if((aA===(void 0))){ if((typeof(S)==='number')){ throw %make_type_error(50); } return; } aA=(%_ToLength(aA)); if(az+aA>%_TypedArrayGetLength(this)){ throw %make_range_error(185); } TypedArraySetFromArrayLike(this,S,aA,az); return; } } %FunctionSetLength(TypedArraySet,1); function TypedArrayGetToStringTag(){ if(!(%_IsTypedArray(this)))return; var aB=%_ClassOf(this); if((aB===(void 0)))return; return aB; } function InnerTypedArrayEvery(aC,aD,aE,aa){ if(!(typeof(aC)==='function'))throw %make_type_error(15,aC); for(var ar=0;ar<aa;ar++){ if(ar in aE){ var aF=aE[ar]; if(!%_Call(aC,aD,aF,ar,aE))return false; } } return true; } function TypedArrayEvery(aC,aD){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return InnerTypedArrayEvery(aC,aD,this,aa); } %FunctionSetLength(TypedArrayEvery,1); function InnerTypedArrayForEach(aC,aD,aE,aa){ if(!(typeof(aC)==='function'))throw %make_type_error(15,aC); if((aD===(void 0))){ for(var ar=0;ar<aa;ar++){ if(ar in aE){ var aF=aE[ar]; aC(aF,ar,aE); } } }else{ for(var ar=0;ar<aa;ar++){ if(ar in aE){ var aF=aE[ar]; %_Call(aC,aD,aF,ar,aE); } } } } function TypedArrayForEach(aC,aD){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); InnerTypedArrayForEach(aC,aD,this,aa); } %FunctionSetLength(TypedArrayForEach,1); function TypedArrayFilter(aC,aG){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); if(!(typeof(aC)==='function'))throw %make_type_error(15,aC); var aH=new q(); k(aC,aG,this,aa,aH); var aI=aH.length; var aJ=TypedArraySpeciesCreate(this,aI); for(var ar=0;ar<aI;ar++){ aJ[ar]=aH[ar]; } return aJ; } %FunctionSetLength(TypedArrayFilter,1); function TypedArrayFind(aK,aG){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return l(aK,aG,this,aa); } %FunctionSetLength(TypedArrayFind,1); function TypedArrayFindIndex(aK,aG){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return m(aK,aG,this,aa); } %FunctionSetLength(TypedArrayFindIndex,1); function TypedArraySort(aL){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); if((aL===(void 0))){ return %TypedArraySortFast(this); } return o(this,aa,aL); } function TypedArrayMap(aC,aG){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); var aH=TypedArraySpeciesCreate(this,aa); if(!(typeof(aC)==='function'))throw %make_type_error(15,aC); for(var ar=0;ar<aa;ar++){ var aF=this[ar]; aH[ar]=%_Call(aC,aG,aF,ar,this); } return aH; } %FunctionSetLength(TypedArrayMap,1); function InnerTypedArraySome(aC,aD,aE,aa){ if(!(typeof(aC)==='function'))throw %make_type_error(15,aC); for(var ar=0;ar<aa;ar++){ if(ar in aE){ var aF=aE[ar]; if(%_Call(aC,aD,aF,ar,aE))return true; } } return false; } function TypedArraySome(aC,aD){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return InnerTypedArraySome(aC,aD,this,aa); } %FunctionSetLength(TypedArraySome,1); function TypedArrayToLocaleString(){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return p(this,aa); } function TypedArrayJoin(aM){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return n(aM,this,aa); } function InnerTypedArrayReduce( callback,current,aE,aa,argumentsLength){ if(!(typeof(callback)==='function')){ throw %make_type_error(15,callback); } var ar=0; find_initial:if(argumentsLength<2){ for(;ar<aa;ar++){ if(ar in aE){ current=aE[ar++]; break find_initial; } } throw %make_type_error(124); } for(;ar<aa;ar++){ if(ar in aE){ var aF=aE[ar]; current=callback(current,aF,ar,aE); } } return current; } function TypedArrayReduce(aN,aO){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return InnerTypedArrayReduce( aN,aO,this,aa,arguments.length); } %FunctionSetLength(TypedArrayReduce,1); function InnerArrayReduceRight(aN,aO,aE,aa, argumentsLength){ if(!(typeof(aN)==='function')){ throw %make_type_error(15,aN); } var ar=aa-1; find_initial:if(argumentsLength<2){ for(;ar>=0;ar--){ if(ar in aE){ aO=aE[ar--]; break find_initial; } } throw %make_type_error(124); } for(;ar>=0;ar--){ if(ar in aE){ var aF=aE[ar]; aO=aN(aO,aF,ar,aE); } } return aO; } function TypedArrayReduceRight(aN,aO){ if(!(%_IsTypedArray(this)))throw %make_type_error(75); var aa=%_TypedArrayGetLength(this); return InnerArrayReduceRight(aN,aO,this,aa, arguments.length); } %FunctionSetLength(TypedArrayReduceRight,1); function TypedArrayOf(){ var aa=arguments.length; var aE=TypedArrayCreate(this,aa); for(var ar=0;ar<aa;ar++){ aE[ar]=arguments[ar]; } return aE; } function IterableToArrayLike(aP){ var T=f(aP,w); if(!(T===(void 0))){ var aQ=new q(); var ar=0; for(var Y of {[w](){return e(aP,T)}}){ aQ[ar]=Y; ar++; } var aE=[]; %MoveArrayContents(aQ,aE); return aE; } return(%_ToObject(aP)); } function TypedArrayFrom(ao,aR,aG){ if(!%IsConstructor(this))throw %make_type_error(69,this); var aS; if(!(aR===(void 0))){ if(!(typeof(aR)==='function'))throw %make_type_error(15,this); aS=true; }else{ aS=false; } var aT=IterableToArrayLike(ao); var aa=(%_ToLength(aT.length)); var aU=TypedArrayCreate(this,aa); var Y,aV; for(var ar=0;ar<aa;ar++){ Y=aT[ar]; if(aS){ aV=%_Call(aR,aG,Y,ar); }else{ aV=Y; } aU[ar]=aV; } return aU; } %FunctionSetLength(TypedArrayFrom,1); function TypedArrayConstructor(){ throw %make_type_error(26,"TypedArray"); } %SetCode(H,TypedArrayConstructor); b.InstallFunctions(H,2,[ "from",TypedArrayFrom, "of",TypedArrayOf ]); b.InstallGetter(H.prototype,x, TypedArrayGetToStringTag); b.InstallFunctions(H.prototype,2,[ "subarray",TypedArraySubArray, "set",TypedArraySet, "every",TypedArrayEvery, "filter",TypedArrayFilter, "find",TypedArrayFind, "findIndex",TypedArrayFindIndex, "join",TypedArrayJoin, "forEach",TypedArrayForEach, "map",TypedArrayMap, "reduce",TypedArrayReduce, "reduceRight",TypedArrayReduceRight, "some",TypedArraySome, "sort",TypedArraySort, "toLocaleString",TypedArrayToLocaleString ]); %AddNamedProperty(H.prototype,"toString",c, 2); %SetCode(y,Uint8ArrayConstructor); %FunctionSetPrototype(y,new j()); %InternalSetPrototype(y,H); %InternalSetPrototype(y.prototype,H.prototype); %AddNamedProperty(y,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(y.prototype, "constructor",a.Uint8Array,2); %AddNamedProperty(y.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); %SetCode(z,Int8ArrayConstructor); %FunctionSetPrototype(z,new j()); %InternalSetPrototype(z,H); %InternalSetPrototype(z.prototype,H.prototype); %AddNamedProperty(z,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(z.prototype, "constructor",a.Int8Array,2); %AddNamedProperty(z.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); %SetCode(A,Uint16ArrayConstructor); %FunctionSetPrototype(A,new j()); %InternalSetPrototype(A,H); %InternalSetPrototype(A.prototype,H.prototype); %AddNamedProperty(A,"BYTES_PER_ELEMENT",2, 1|2|4); %AddNamedProperty(A.prototype, "constructor",a.Uint16Array,2); %AddNamedProperty(A.prototype, "BYTES_PER_ELEMENT",2, 1|2|4); %SetCode(B,Int16ArrayConstructor); %FunctionSetPrototype(B,new j()); %InternalSetPrototype(B,H); %InternalSetPrototype(B.prototype,H.prototype); %AddNamedProperty(B,"BYTES_PER_ELEMENT",2, 1|2|4); %AddNamedProperty(B.prototype, "constructor",a.Int16Array,2); %AddNamedProperty(B.prototype, "BYTES_PER_ELEMENT",2, 1|2|4); %SetCode(C,Uint32ArrayConstructor); %FunctionSetPrototype(C,new j()); %InternalSetPrototype(C,H); %InternalSetPrototype(C.prototype,H.prototype); %AddNamedProperty(C,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(C.prototype, "constructor",a.Uint32Array,2); %AddNamedProperty(C.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); %SetCode(D,Int32ArrayConstructor); %FunctionSetPrototype(D,new j()); %InternalSetPrototype(D,H); %InternalSetPrototype(D.prototype,H.prototype); %AddNamedProperty(D,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(D.prototype, "constructor",a.Int32Array,2); %AddNamedProperty(D.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); %SetCode(E,Float32ArrayConstructor); %FunctionSetPrototype(E,new j()); %InternalSetPrototype(E,H); %InternalSetPrototype(E.prototype,H.prototype); %AddNamedProperty(E,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(E.prototype, "constructor",a.Float32Array,2); %AddNamedProperty(E.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); %SetCode(F,Float64ArrayConstructor); %FunctionSetPrototype(F,new j()); %InternalSetPrototype(F,H); %InternalSetPrototype(F.prototype,H.prototype); %AddNamedProperty(F,"BYTES_PER_ELEMENT",8, 1|2|4); %AddNamedProperty(F.prototype, "constructor",a.Float64Array,2); %AddNamedProperty(F.prototype, "BYTES_PER_ELEMENT",8, 1|2|4); %SetCode(G,Uint8ClampedArrayConstructor); %FunctionSetPrototype(G,new j()); %InternalSetPrototype(G,H); %InternalSetPrototype(G.prototype,H.prototype); %AddNamedProperty(G,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(G.prototype, "constructor",a.Uint8ClampedArray,2); %AddNamedProperty(G.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); }) (collection� (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c=a.Map; var d=a.Object; var e=a.Set; var f=b.ImportNow("hash_code_symbol"); var g=a.Math.random; var h; var i; var j=b.ImportNow("to_string_tag_symbol"); b.Import(function(k){ h=k.MapIterator; i=k.SetIterator; }); function HashToEntry(l,m,n){ var o=(m&((n)-1)); return((%_FixedArrayGet(l,(3+(o))|0))); } %SetForceInlineFlag(HashToEntry); function SetFindEntry(l,n,p,m){ var q=HashToEntry(l,m,n); if(q===-1)return q; var r=((%_FixedArrayGet(l,((3+(n)+((q)<<1)))|0))); if(p===r)return q; var s=(%IS_VAR(p)!==p); while(true){ if(s&&(%IS_VAR(r)!==r)){ return q; } q=((%_FixedArrayGet(l,((3+(n)+((q)<<1))+1)|0))); if(q===-1)return q; r=((%_FixedArrayGet(l,((3+(n)+((q)<<1)))|0))); if(p===r)return q; } return-1; } %SetForceInlineFlag(SetFindEntry); function MapFindEntry(l,n,p,m){ var q=HashToEntry(l,m,n); if(q===-1)return q; var r=((%_FixedArrayGet(l,((3+(n)+((q)*3)))|0))); if(p===r)return q; var s=(%IS_VAR(p)!==p); while(true){ if(s&&(%IS_VAR(r)!==r)){ return q; } q=((%_FixedArrayGet(l,((3+(n)+((q)*3))+2)|0))); if(q===-1)return q; r=((%_FixedArrayGet(l,((3+(n)+((q)*3)))|0))); if(p===r)return q; } return-1; } %SetForceInlineFlag(MapFindEntry); function ComputeIntegerHash(p,t){ var m=p; m=m^t; m=~m+(m<<15); m=m^(m>>>12); m=m+(m<<2); m=m^(m>>>4); m=(m*2057)|0; m=m^(m>>>16); return m&0x3fffffff; } %SetForceInlineFlag(ComputeIntegerHash); function GetExistingHash(p){ if(%_IsSmi(p)){ return ComputeIntegerHash(p,0); } if((typeof(p)==='string')){ var u=%_StringGetRawHashField(p); if((u&1)===0){ return u>>>2; } }else if((%_IsJSReceiver(p))&&!(%_IsJSProxy(p))&&!(%_ClassOf(p)==='global')){ var m=(p[f]); return m; } return %GenericHash(p); } %SetForceInlineFlag(GetExistingHash); function GetHash(p){ var m=GetExistingHash(p); if((m===(void 0))){ m=(g()*0x40000000)|0; if(m===0)m=1; (p[f]=m); } return m; } %SetForceInlineFlag(GetHash); function SetConstructor(v){ if((new.target===(void 0))){ throw %make_type_error(29,"Set"); } %_SetInitialize(this); if(!(v==null)){ var w=this.add; if(!(typeof(w)==='function')){ throw %make_type_error(90,w,'add',this); } for(var x of v){ %_Call(w,this,x); } } } function SetAdd(p){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48,'Set.prototype.add',this); } if(p===0){ p=0; } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetHash(p); if(SetFindEntry(l,n,p,m)!==-1)return this; var y=((%_FixedArrayGet(l,(0)|0))); var z=((%_FixedArrayGet(l,(1)|0))); var A=n<<1; if((y+z)>=A){ %SetGrow(this); l=%_JSCollectionGetTable(this); n=((%_FixedArrayGet(l,(2)|0))); y=((%_FixedArrayGet(l,(0)|0))); z=((%_FixedArrayGet(l,(1)|0))); } var q=y+z; var B=(3+(n)+((q)<<1)); var o=(m&((n)-1)); var C=((%_FixedArrayGet(l,(3+(o))|0))); ((%_FixedArraySet(l,(3+(o))|0,q))); (((%_FixedArraySet(l,(0)|0,(y+1)|0)))); (%_FixedArraySet(l,(B)|0,p)); ((%_FixedArraySet(l,(B+1)|0,(C)|0))); return this; } function SetHas(p){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48,'Set.prototype.has',this); } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetExistingHash(p); if((m===(void 0)))return false; return SetFindEntry(l,n,p,m)!==-1; } function SetDelete(p){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.delete',this); } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetExistingHash(p); if((m===(void 0)))return false; var q=SetFindEntry(l,n,p,m); if(q===-1)return false; var y=((%_FixedArrayGet(l,(0)|0)))-1; var z=((%_FixedArrayGet(l,(1)|0)))+1; var B=(3+(n)+((q)<<1)); (%_FixedArraySet(l,(B)|0,%_TheHole())); (((%_FixedArraySet(l,(0)|0,(y)|0)))); (((%_FixedArraySet(l,(1)|0,(z)|0)))); if(y<(n>>>1))%SetShrink(this); return true; } function SetGetSize(){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.size',this); } var l=%_JSCollectionGetTable(this); return((%_FixedArrayGet(l,(0)|0))); } function SetClearJS(){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.clear',this); } %_SetClear(this); } function SetForEach(D,E){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.forEach',this); } if(!(typeof(D)==='function'))throw %make_type_error(15,D); var F=new i(this,2); var p; var G=[(void 0)]; while(%SetIteratorNext(F,G)){ p=G[0]; %_Call(D,E,p,p,this); } } %SetCode(e,SetConstructor); %FunctionSetLength(e,0); %FunctionSetPrototype(e,new d()); %AddNamedProperty(e.prototype,"constructor",e,2); %AddNamedProperty(e.prototype,j,"Set", 2|1); %FunctionSetLength(SetForEach,1); b.InstallGetter(e.prototype,"size",SetGetSize); b.InstallFunctions(e.prototype,2,[ "add",SetAdd, "has",SetHas, "delete",SetDelete, "clear",SetClearJS, "forEach",SetForEach ]); function MapConstructor(v){ if((new.target===(void 0))){ throw %make_type_error(29,"Map"); } %_MapInitialize(this); if(!(v==null)){ var w=this.set; if(!(typeof(w)==='function')){ throw %make_type_error(90,w,'set',this); } for(var H of v){ if(!(%_IsJSReceiver(H))){ throw %make_type_error(54,H); } %_Call(w,this,H[0],H[1]); } } } function MapGet(p){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.get',this); } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetExistingHash(p); if((m===(void 0)))return(void 0); var q=MapFindEntry(l,n,p,m); if(q===-1)return(void 0); return((%_FixedArrayGet(l,((3+(n)+((q)*3))+1)|0))); } function MapSet(p,x){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.set',this); } if(p===0){ p=0; } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetHash(p); var q=MapFindEntry(l,n,p,m); if(q!==-1){ var I=(3+(n)+((q)*3)); (%_FixedArraySet(l,(I+1)|0,x)); return this; } var y=((%_FixedArrayGet(l,(0)|0))); var z=((%_FixedArrayGet(l,(1)|0))); var A=n<<1; if((y+z)>=A){ %MapGrow(this); l=%_JSCollectionGetTable(this); n=((%_FixedArrayGet(l,(2)|0))); y=((%_FixedArrayGet(l,(0)|0))); z=((%_FixedArrayGet(l,(1)|0))); } q=y+z; var B=(3+(n)+((q)*3)); var o=(m&((n)-1)); var C=((%_FixedArrayGet(l,(3+(o))|0))); ((%_FixedArraySet(l,(3+(o))|0,q))); (((%_FixedArraySet(l,(0)|0,(y+1)|0)))); (%_FixedArraySet(l,(B)|0,p)); (%_FixedArraySet(l,(B+1)|0,x)); (%_FixedArraySet(l,(B+2)|0,C)); return this; } function MapHas(p){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.has',this); } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetHash(p); return MapFindEntry(l,n,p,m)!==-1; } function MapDelete(p){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.delete',this); } var l=%_JSCollectionGetTable(this); var n=((%_FixedArrayGet(l,(2)|0))); var m=GetHash(p); var q=MapFindEntry(l,n,p,m); if(q===-1)return false; var y=((%_FixedArrayGet(l,(0)|0)))-1; var z=((%_FixedArrayGet(l,(1)|0)))+1; var B=(3+(n)+((q)*3)); (%_FixedArraySet(l,(B)|0,%_TheHole())); (%_FixedArraySet(l,(B+1)|0,%_TheHole())); (((%_FixedArraySet(l,(0)|0,(y)|0)))); (((%_FixedArraySet(l,(1)|0,(z)|0)))); if(y<(n>>>1))%MapShrink(this); return true; } function MapGetSize(){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.size',this); } var l=%_JSCollectionGetTable(this); return((%_FixedArrayGet(l,(0)|0))); } function MapClearJS(){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.clear',this); } %_MapClear(this); } function MapForEach(D,E){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.forEach',this); } if(!(typeof(D)==='function'))throw %make_type_error(15,D); var F=new h(this,3); var G=[(void 0),(void 0)]; while(%MapIteratorNext(F,G)){ %_Call(D,E,G[1],G[0],this); } } %SetCode(c,MapConstructor); %FunctionSetLength(c,0); %FunctionSetPrototype(c,new d()); %AddNamedProperty(c.prototype,"constructor",c,2); %AddNamedProperty( c.prototype,j,"Map",2|1); %FunctionSetLength(MapForEach,1); b.InstallGetter(c.prototype,"size",MapGetSize); b.InstallFunctions(c.prototype,2,[ "get",MapGet, "set",MapSet, "has",MapHas, "delete",MapDelete, "clear",MapClearJS, "forEach",MapForEach ]); %InstallToContext([ "map_get",MapGet, "map_set",MapSet, "map_has",MapHas, "map_delete",MapDelete, "set_add",SetAdd, "set_has",SetHas, "set_delete",SetDelete, ]); b.Export(function(J){ J.GetExistingHash=GetExistingHash; J.GetHash=GetHash; }); }) <weak-collection�0 (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c; var d; var e=a.Object; var f=a.WeakMap; var g=a.WeakSet; var h=b.ImportNow("to_string_tag_symbol"); b.Import(function(i){ c=i.GetExistingHash; d=i.GetHash; }); function WeakMapConstructor(j){ if((new.target===(void 0))){ throw %make_type_error(29,"WeakMap"); } %WeakCollectionInitialize(this); if(!(j==null)){ var k=this.set; if(!(typeof(k)==='function')){ throw %make_type_error(90,k,'set',this); } for(var l of j){ if(!(%_IsJSReceiver(l))){ throw %make_type_error(54,l); } %_Call(k,this,l[0],l[1]); } } } function WeakMapGet(m){ if(!(%_ClassOf(this)==='WeakMap')){ throw %make_type_error(48, 'WeakMap.prototype.get',this); } if(!(%_IsJSReceiver(m)))return(void 0); var n=c(m); if((n===(void 0)))return(void 0); return %WeakCollectionGet(this,m,n); } function WeakMapSet(m,o){ if(!(%_ClassOf(this)==='WeakMap')){ throw %make_type_error(48, 'WeakMap.prototype.set',this); } if(!(%_IsJSReceiver(m)))throw %make_type_error(169); return %WeakCollectionSet(this,m,o,d(m)); } function WeakMapHas(m){ if(!(%_ClassOf(this)==='WeakMap')){ throw %make_type_error(48, 'WeakMap.prototype.has',this); } if(!(%_IsJSReceiver(m)))return false; var n=c(m); if((n===(void 0)))return false; return %WeakCollectionHas(this,m,n); } function WeakMapDelete(m){ if(!(%_ClassOf(this)==='WeakMap')){ throw %make_type_error(48, 'WeakMap.prototype.delete',this); } if(!(%_IsJSReceiver(m)))return false; var n=c(m); if((n===(void 0)))return false; return %WeakCollectionDelete(this,m,n); } %SetCode(f,WeakMapConstructor); %FunctionSetLength(f,0); %FunctionSetPrototype(f,new e()); %AddNamedProperty(f.prototype,"constructor",f, 2); %AddNamedProperty(f.prototype,h,"WeakMap", 2|1); b.InstallFunctions(f.prototype,2,[ "get",WeakMapGet, "set",WeakMapSet, "has",WeakMapHas, "delete",WeakMapDelete ]); function WeakSetConstructor(j){ if((new.target===(void 0))){ throw %make_type_error(29,"WeakSet"); } %WeakCollectionInitialize(this); if(!(j==null)){ var k=this.add; if(!(typeof(k)==='function')){ throw %make_type_error(90,k,'add',this); } for(var o of j){ %_Call(k,this,o); } } } function WeakSetAdd(o){ if(!(%_ClassOf(this)==='WeakSet')){ throw %make_type_error(48, 'WeakSet.prototype.add',this); } if(!(%_IsJSReceiver(o)))throw %make_type_error(170); return %WeakCollectionSet(this,o,true,d(o)); } function WeakSetHas(o){ if(!(%_ClassOf(this)==='WeakSet')){ throw %make_type_error(48, 'WeakSet.prototype.has',this); } if(!(%_IsJSReceiver(o)))return false; var n=c(o); if((n===(void 0)))return false; return %WeakCollectionHas(this,o,n); } function WeakSetDelete(o){ if(!(%_ClassOf(this)==='WeakSet')){ throw %make_type_error(48, 'WeakSet.prototype.delete',this); } if(!(%_IsJSReceiver(o)))return false; var n=c(o); if((n===(void 0)))return false; return %WeakCollectionDelete(this,o,n); } %SetCode(g,WeakSetConstructor); %FunctionSetLength(g,0); %FunctionSetPrototype(g,new e()); %AddNamedProperty(g.prototype,"constructor",g, 2); %AddNamedProperty(g.prototype,h,"WeakSet", 2|1); b.InstallFunctions(g.prototype,2,[ "add",WeakSetAdd, "has",WeakSetHas, "delete",WeakSetDelete ]); }) Lcollection-iterator�( (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c=a.Map; var d=a.Set; var e=b.ImportNow("iterator_symbol"); var f=b.ImportNow("MapIterator"); var g=b.ImportNow("to_string_tag_symbol"); var h=b.ImportNow("SetIterator"); function SetIteratorConstructor(i,j){ %SetIteratorInitialize(this,i,j); } function SetIteratorNextJS(){ if(!(%_ClassOf(this)==='Set Iterator')){ throw %make_type_error(48, 'Set Iterator.prototype.next',this); } var k=[(void 0),(void 0)]; var l=%_CreateIterResultObject(k,false); switch(%SetIteratorNext(this,k)){ case 0: l.value=(void 0); l.done=true; break; case 2: l.value=k[0]; break; case 3: k[1]=k[0]; break; } return l; } function SetEntries(){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.entries',this); } return new h(this,3); } function SetValues(){ if(!(%_ClassOf(this)==='Set')){ throw %make_type_error(48, 'Set.prototype.values',this); } return new h(this,2); } %SetCode(h,SetIteratorConstructor); %FunctionSetInstanceClassName(h,'Set Iterator'); b.InstallFunctions(h.prototype,2,[ 'next',SetIteratorNextJS ]); %AddNamedProperty(h.prototype,g, "Set Iterator",1|2); b.InstallFunctions(d.prototype,2,[ 'entries',SetEntries, 'keys',SetValues, 'values',SetValues ]); %AddNamedProperty(d.prototype,e,SetValues,2); function MapIteratorConstructor(m,j){ %MapIteratorInitialize(this,m,j); } function MapIteratorNextJS(){ if(!(%_ClassOf(this)==='Map Iterator')){ throw %make_type_error(48, 'Map Iterator.prototype.next',this); } var k=[(void 0),(void 0)]; var l=%_CreateIterResultObject(k,false); switch(%MapIteratorNext(this,k)){ case 0: l.value=(void 0); l.done=true; break; case 1: l.value=k[0]; break; case 2: l.value=k[1]; break; } return l; } function MapEntries(){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.entries',this); } return new f(this,3); } function MapKeys(){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.keys',this); } return new f(this,1); } function MapValues(){ if(!(%_ClassOf(this)==='Map')){ throw %make_type_error(48, 'Map.prototype.values',this); } return new f(this,2); } %SetCode(f,MapIteratorConstructor); %FunctionSetInstanceClassName(f,'Map Iterator'); b.InstallFunctions(f.prototype,2,[ 'next',MapIteratorNextJS ]); %AddNamedProperty(f.prototype,g, "Map Iterator",1|2); b.InstallFunctions(c.prototype,2,[ 'entries',MapEntries, 'keys',MapKeys, 'values',MapValues ]); %AddNamedProperty(c.prototype,e,MapEntries,2); b.Export(function(n){ n.MapEntries=MapEntries; n.MapIteratorNext=MapIteratorNextJS; n.SetIteratorNext=SetIteratorNextJS; n.SetValues=SetValues; }); }) promise� (function(a,b,c){ "use strict"; %CheckIsBootstrapping(); var d=b.InternalArray; var e= b.ImportNow("promise_handled_by_symbol"); var f= b.ImportNow("promise_forwarding_handler_symbol"); var g=a.Promise; function PromiseAll(h){ if(!(%_IsJSReceiver(this))){ throw %make_type_error(16,"Promise.all"); } var i=%new_promise_capability(this,false); var j=new d(); var k; var l=(%_DebugIsActive()!=0); if(l){ (i.reject[f]=true); } function CreateResolveElementFunction(m,n,o){ var p=false; return(x)=>{ if(p===true)return; p=true; n[m]=x; if(--k===0){ var q=[]; %MoveArrayContents(n,q); %_Call(o.resolve,(void 0),q); } }; } try{ var r=0; k=1; for(var s of h){ var t=this.resolve(s); ++k; var u=t.then( CreateResolveElementFunction(r,j,i), i.reject); if(l&&%is_promise(u)){ (u[e]=i.promise); } ++r; } if(--k===0){ var q=[]; %MoveArrayContents(j,q); %_Call(i.resolve,(void 0),q); } }catch(e){ %_Call(i.reject,(void 0),e); } return i.promise; } function PromiseRace(h){ if(!(%_IsJSReceiver(this))){ throw %make_type_error(16,PromiseRace); } var i=%new_promise_capability(this,false); var l=(%_DebugIsActive()!=0); if(l){ (i.reject[f]=true); } try{ for(var s of h){ var u=this.resolve(s).then(i.resolve, i.reject); if(l&&%is_promise(u)){ (u[e]=i.promise); } } }catch(e){ %_Call(i.reject,(void 0),e); } return i.promise; } b.InstallFunctions(g,2,[ "all",PromiseAll, "race",PromiseRace, ]); }) messages� (function(a,b){ %CheckIsBootstrapping(); var c=b.ImportNow("Script"); %FunctionSetInstanceClassName(c,'Script'); %AddNamedProperty(c.prototype,'constructor',c, 2|4|1); function ScriptLocationFromPosition(position, include_resource_offset){ return %ScriptPositionInfo(this,position,!!include_resource_offset); } function ScriptNameOrSourceURL(){ if(this.source_url)return this.source_url; return this.name; } b.SetUpLockedPrototype(c,[ "source", "name", "source_url", "source_mapping_url", "line_offset", "column_offset" ],[ "locationFromPosition",ScriptLocationFromPosition, "nameOrSourceURL",ScriptNameOrSourceURL, ] ); }); $templates (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c=a.Map; var d=b.InternalArray; var e=new c; var f=c.prototype.get; var g=c.prototype.set; function SameCallSiteElements(h,i){ var j=h.length; var i=i.raw; if(j!==i.length)return false; for(var k=0;k<j;++k){ if(h[k]!==i[k])return false; } return true; } function GetCachedCallSite(l,m){ var n=%_Call(f,e,m); if((n===(void 0)))return; var j=n.length; for(var k=0;k<j;++k){ if(SameCallSiteElements(l,n[k]))return n[k]; } } function SetCachedCallSite(l,m){ var n=%_Call(f,e,m); var o; if((n===(void 0))){ o=new d(1); o[0]=l; %_Call(g,e,m,o); }else{ n.push(l); } return l; } function GetTemplateCallSite(l,h,m){ var p=GetCachedCallSite(h,m); if(!(p===(void 0)))return p; %AddNamedProperty(l,"raw",%object_freeze(h), 1|2|4); return SetCachedCallSite(%object_freeze(l),m); } %InstallToContext(["get_template_call_site",GetTemplateCallSite]); }) spread5 (function(a,b){ 'use strict'; var c=b.InternalArray; function SpreadArguments(){ var d=arguments.length; var e=new c(); for(var f=0;f<d;++f){ var g=arguments[f]; var h=g.length; for(var i=0;i<h;++i){ e.push(g[i]); } } return e; } function SpreadIterable(j){ if((j==null)){ throw %make_type_error(73,j); } var e=new c(); for(var k of j){ e.push(k); } return e; } %InstallToContext([ "spread_arguments",SpreadArguments, "spread_iterable",SpreadIterable, ]); }) proxy� (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c=a.Proxy; function ProxyCreateRevocable(d,e){ var f=new c(d,e); return{proxy:f,revoke:()=>%JSProxyRevoke(f)}; } b.InstallFunctions(c,2,[ "revocable",ProxyCreateRevocable ]); }) Xharmony-string-paddingY (function(a,b){ %CheckIsBootstrapping(); var c=a.String; function StringPad(d,e,f){ e=(%_ToLength(e)); var g=d.length; if(e<=g)return""; if((f===(void 0))){ f=" "; }else{ f=(%_ToString(f)); if(f===""){ return""; } } var h=e-g; var i=(h/f.length)|0; var j=(h-f.length*i)|0; var k=""; while(true){ if(i&1)k+=f; i>>=1; if(i===0)break; f+=f; } if(j){ k+=%_SubString(f,0,j); } return k; } function StringPadStart(e,f){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.padStart") var d=(%_ToString(this)); return StringPad(d,e,f)+d; } %FunctionSetLength(StringPadStart,1); function StringPadEnd(e,f){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.padEnd") var d=(%_ToString(this)); return d+StringPad(d,e,f); } %FunctionSetLength(StringPadEnd,1); b.InstallFunctions(c.prototype,2,[ "padStart",StringPadStart, "padEnd",StringPadEnd ]); }); i18n.� (function(a,b){ "use strict"; %CheckIsBootstrapping(); var c; var d; var e=a.Date; var f=a.Intl; var g=f.DateTimeFormat; var h=f.NumberFormat; var i=f.Collator; var j=f.v8BreakIterator; var k=a.Number; var l=a.RegExp; var m=a.String; var n=b.ImportNow("intl_fallback_symbol"); var o=b.InstallFunctions; var p=b.InstallGetter; var q=b.InternalArray; var r; var s=b.ImportNow("ObjectHasOwnProperty"); var t=b.OverrideFunction; var u=b.ImportNow("intl_pattern_symbol"); var v=b.ImportNow("intl_resolved_symbol"); var w=b.SetFunctionName; var x=m.prototype.substr; var y=m.prototype.substring; b.Import(function(z){ c=z.ArrayJoin; d=z.ArrayPush; r=z.MaxSimple; }); function InstallFunction(A,B,C){ o(A,2,[B,C]); } function AddBoundMethod(obj,methodName,implementation,length,typename, compat){ %CheckIsBootstrapping(); var D=%CreatePrivateSymbol(methodName); var E=(0,(function(){ var F=Unwrap(this,typename,obj,methodName,compat); if((F[D]===(void 0))){ var G; if((length===(void 0))||length===2){ G= (0,((fst,snd)=>implementation(F,fst,snd))); }else if(length===1){ G=(0,(fst=>implementation(F,fst))); }else{ G=(0,((...args)=>{ if(args.length>0){ return implementation(F,args[0]); }else{ return implementation(F); } })); } %SetNativeFlag(G); F[D]=G; } return F[D]; })); %FunctionRemovePrototype(E); %DefineGetterPropertyUnchecked(obj.prototype,methodName,E,2); %SetNativeFlag(E); } function IntlConstruct(F,constructor,create,newTarget,args, compat){ var H=args[0]; var I=args[1]; var J=create(H,I); if(compat&&(newTarget===(void 0))&&F instanceof constructor){ %object_define_property(F,n,{value:J}); return F; } return J; } function Unwrap(F,K,L,M,N){ if(!%IsInitializedIntlObjectOfType(F,K)){ if(N&&F instanceof L){ let fallback=F[n]; if(%IsInitializedIntlObjectOfType(fallback,K)){ return fallback; } } throw %make_type_error(48,M,F); } return F; } var O={ 'collator':(void 0), 'numberformat':(void 0), 'dateformat':(void 0), 'breakiterator':(void 0) }; var P=(void 0); function GetDefaultICULocaleJS(){ if((P===(void 0))){ P=%GetDefaultICULocale(); } return P; } var Q=(void 0); function GetUnicodeExtensionRE(){ if(((void 0)===(void 0))){ Q=new l('-u(-[a-z0-9]{2,8})+','g'); } return Q; } var R=(void 0); function GetAnyExtensionRE(){ if((R===(void 0))){ R=new l('-[a-z0-9]{1}-.*','g'); } return R; } var S=(void 0); function GetQuotedStringRE(){ if((S===(void 0))){ S=new l("'[^']+'",'g'); } return S; } var T=(void 0); function GetServiceRE(){ if((T===(void 0))){ T= new l('^(collator|numberformat|dateformat|breakiterator)$'); } return T; } var U=(void 0); function GetLanguageTagRE(){ if((U===(void 0))){ BuildLanguageTagREs(); } return U; } var V=(void 0); function GetLanguageVariantRE(){ if((V===(void 0))){ BuildLanguageTagREs(); } return V; } var W=(void 0); function GetLanguageSingletonRE(){ if((W===(void 0))){ BuildLanguageTagREs(); } return W; } var X=(void 0); function GetTimezoneNameCheckRE(){ if((X===(void 0))){ X=new l( '^([A-Za-z]+)/([A-Za-z_-]+)((?:\/[A-Za-z_-]+)+)*$'); } return X; } var Y=(void 0); function GetTimezoneNameLocationPartRE(){ if((Y===(void 0))){ Y= new l('^([A-Za-z]+)((?:[_-][A-Za-z]+)+)*$'); } return Y; } function supportedLocalesOf(Z,H,I){ if((%regexp_internal_match(GetServiceRE(),Z)===null)){ throw %make_error(7,Z); } if((I===(void 0))){ I={}; }else{ I=(%_ToObject(I)); } var aa=I.localeMatcher; if(!(aa===(void 0))){ aa=(%_ToString(aa)); if(aa!=='lookup'&&aa!=='best fit'){ throw %make_range_error(177,aa); } }else{ aa='best fit'; } var ab=initializeLocaleList(H); if((O[Z]===(void 0))){ O[Z]=getAvailableLocalesOf(Z); } if(aa==='best fit'){ return initializeLocaleList(bestFitSupportedLocalesOf( ab,O[Z])); } return initializeLocaleList(lookupSupportedLocalesOf( ab,O[Z])); } function lookupSupportedLocalesOf(ab,ac){ var ad=new q(); for(var ae=0;ae<ab.length;++ae){ var af=%RegExpInternalReplace( GetUnicodeExtensionRE(),ab[ae],''); do{ if(!(ac[af]===(void 0))){ %_Call(d,ad,ab[ae]); break; } var ag=%StringLastIndexOf(af,'-'); if(ag===-1){ break; } af=%_Call(y,af,0,ag); }while(true); } return ad; } function bestFitSupportedLocalesOf(ab,ac){ return lookupSupportedLocalesOf(ab,ac); } function getGetOption(I,ah){ if((I===(void 0)))throw %make_error(4,ah); var ai=function getOption(aj,ak,al,am){ if(!(I[aj]===(void 0))){ var an=I[aj]; switch(ak){ case'boolean': an=(!!(an)); break; case'string': an=(%_ToString(an)); break; case'number': an=(%_ToNumber(an)); break; default: throw %make_error(8); } if(!(al===(void 0))&&%ArrayIndexOf(al,an,0)===-1){ throw %make_range_error(187,an,ah,aj); } return an; } return am; } return ai; } function resolveLocale(Z,ab,I){ ab=initializeLocaleList(ab); var ai=getGetOption(I,Z); var aa=ai('localeMatcher','string', ['lookup','best fit'],'best fit'); var ao; if(aa==='lookup'){ ao=lookupMatcher(Z,ab); }else{ ao=bestFitMatcher(Z,ab); } return ao; } function lookupMatcher(Z,ab){ if((%regexp_internal_match(GetServiceRE(),Z)===null)){ throw %make_error(7,Z); } if((O[Z]===(void 0))){ O[Z]=getAvailableLocalesOf(Z); } for(var ae=0;ae<ab.length;++ae){ var af=%RegExpInternalReplace( GetAnyExtensionRE(),ab[ae],''); do{ if(!(O[Z][af]===(void 0))){ var ap=%regexp_internal_match( GetUnicodeExtensionRE(),ab[ae]); var aq=(ap===null)?'':ap[0]; return{'locale':af,'extension':aq,'position':ae}; } var ag=%StringLastIndexOf(af,'-'); if(ag===-1){ break; } af=%_Call(y,af,0,ag); }while(true); } return{'locale':GetDefaultICULocaleJS(),'extension':'','position':-1}; } function bestFitMatcher(Z,ab){ return lookupMatcher(Z,ab); } function parseExtension(aq){ var ar=%StringSplit(aq,'-',4294967295); if(ar.length<=2|| (ar[0]!==''&&ar[1]!=='u')){ return{}; } var as={}; var at=(void 0); var an=(void 0); for(var ae=2;ae<ar.length;++ae){ var au=ar[ae].length; var av=ar[ae]; if(au===2){ if(!(at===(void 0))){ if(!(at in as)){ as[at]=an; } an=(void 0); } at=av; }else if(au>=3&&au<=8&&!(at===(void 0))){ if((an===(void 0))){ an=av; }else{ an=an+"-"+av; } }else{ return{}; } } if(!(at===(void 0))&&!(at in as)){ as[at]=an; } return as; } function setOptions(aw,as,ax,ai,ay){ var aq=''; var az=function updateExtension(at,an){ return'-'+at+'-'+(%_ToString(an)); } var aA=function updateProperty(aj,ak,an){ if(ak==='boolean'&&(typeof an==='string')){ an=(an==='true')?true:false; } if(!(aj===(void 0))){ defineWEProperty(ay,aj,an); } } for(var at in ax){ if((%_Call(s,ax,at))){ var an=(void 0); var aB=ax[at]; if(!(aB.property===(void 0))){ an=ai(aB.property,aB.type,aB.values); } if(!(an===(void 0))){ aA(aB.property,aB.type,an); aq+=az(at,an); continue; } if((%_Call(s,as,at))){ an=as[at]; if(!(an===(void 0))){ aA(aB.property,aB.type,an); aq+=az(at,an); }else if(aB.type==='boolean'){ aA(aB.property,aB.type,true); aq+=az(at,true); } } } } return aq===''?'':'-u'+aq; } function freezeArray(aC){ var aD=[]; var aE=aC.length; for(var ae=0;ae<aE;ae++){ if(ae in aC){ %object_define_property(aD,ae,{value:aC[ae], configurable:false, writable:false, enumerable:true}); } } %object_define_property(aD,'length',{value:aE,writable:false}); return aD; } function makeArray(aC){ var aD=[]; %MoveArrayContents(aC,aD); return aD; } function getOptimalLanguageTag(aF,ao){ if(aF===ao){ return aF; } var H=%GetLanguageTagVariants([aF,ao]); if(H[0].maximized!==H[1].maximized){ return ao; } var aG=new l('^'+H[1].base,'g'); return %RegExpInternalReplace(aG,ao,H[0].base); } function getAvailableLocalesOf(Z){ var aH=%AvailableLocalesOf(Z); for(var ae in aH){ if((%_Call(s,aH,ae))){ var aI=%regexp_internal_match( /^([a-z]{2,3})-([A-Z][a-z]{3})-([A-Z]{2})$/,ae); if(!(aI===null)){ aH[aI[1]+'-'+aI[3]]=null; } } } return aH; } function defineWEProperty(A,aj,an){ %object_define_property(A,aj, {value:an,writable:true,enumerable:true}); } function addWEPropertyIfDefined(A,aj,an){ if(!(an===(void 0))){ defineWEProperty(A,aj,an); } } function defineWECProperty(A,aj,an){ %object_define_property(A,aj,{value:an, writable:true, enumerable:true, configurable:true}); } function addWECPropertyIfDefined(A,aj,an){ if(!(an===(void 0))){ defineWECProperty(A,aj,an); } } function toTitleCaseWord(aJ){ return %StringToUpperCaseI18N(%_Call(x,aJ,0,1))+ %StringToLowerCaseI18N(%_Call(x,aJ,1)); } function toTitleCaseTimezoneLocation(aK){ var aL=%regexp_internal_match(GetTimezoneNameLocationPartRE(),aK) if((aL===null))throw %make_range_error(156,aK); var aM=toTitleCaseWord(aL[1]); if(!(aL[2]===(void 0))&&2<aL.length){ var aN=%_Call(y,aL[2],0,1); var aI=%StringSplit(aL[2],aN,4294967295); for(var ae=1;ae<aI.length;ae++){ var aO=aI[ae] var aP=%StringToLowerCaseI18N(aO); aM=aM+aN+ ((aP!=='es'&& aP!=='of'&&aP!=='au')? toTitleCaseWord(aO):aP); } } return aM; } function canonicalizeLanguageTag(aQ){ if((!(typeof(aQ)==='string')&&!(%_IsJSReceiver(aQ)))|| (aQ===null)){ throw %make_type_error(55); } if((typeof(aQ)==='string')&& !(%regexp_internal_match(/^[a-z]{2,3}$/,aQ)===null)){ return aQ; } var aR=(%_ToString(aQ)); if(isStructuallyValidLanguageTag(aR)===false){ throw %make_range_error(168,aR); } var aS=%CanonicalizeLanguageTag(aR); if(aS==='invalid-tag'){ throw %make_range_error(168,aR); } return aS; } function canonicalizeLocaleList(H){ var aT=new q(); if(!(H===(void 0))){ if(typeof H==='string'){ %_Call(d,aT,canonicalizeLanguageTag(H)); return aT; } var aU=(%_ToObject(H)); var aV=(%_ToLength(aU.length)); for(var aW=0;aW<aV;aW++){ if(aW in aU){ var an=aU[aW]; var aS=canonicalizeLanguageTag(an); if(%ArrayIndexOf(aT,aS,0)===-1){ %_Call(d,aT,aS); } } } } return aT; } function initializeLocaleList(H){ return freezeArray(canonicalizeLocaleList(H)); } function isStructuallyValidLanguageTag(af){ if((%regexp_internal_match(GetLanguageTagRE(),af)===null)){ return false; } af=%StringToLowerCaseI18N(af); if(%StringIndexOf(af,'x-',0)===0){ return true; } af=%StringSplit(af,'-x-',4294967295)[0]; var aX=new q(); var aY=new q(); var aI=%StringSplit(af,'-',4294967295); for(var ae=1;ae<aI.length;ae++){ var an=aI[ae]; if(!(%regexp_internal_match(GetLanguageVariantRE(),an)===null)&& aY.length===0){ if(%ArrayIndexOf(aX,an,0)===-1){ %_Call(d,aX,an); }else{ return false; } } if(!(%regexp_internal_match(GetLanguageSingletonRE(),an)===null)){ if(%ArrayIndexOf(aY,an,0)===-1){ %_Call(d,aY,an); }else{ return false; } } } return true; } function BuildLanguageTagREs(){ var aZ='[a-zA-Z]'; var ba='[0-9]'; var bb='('+aZ+'|'+ba+')'; var bc='(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|'+ 'zh-min|zh-min-nan|zh-xiang)'; var bd='(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|'+ 'i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|'+ 'i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)'; var be='('+bd+'|'+bc+')'; var bf='(x(-'+bb+'{1,8})+)'; var bg='('+ba+'|[A-WY-Za-wy-z])'; W=new l('^'+bg+'$','i'); var aq='('+bg+'(-'+bb+'{2,8})+)'; var bh='('+bb+'{5,8}|('+ba+bb+'{3}))'; V=new l('^'+bh+'$','i'); var bi='('+aZ+'{2}|'+ba+'{3})'; var bj='('+aZ+'{4})'; var bk='('+aZ+'{3}(-'+aZ+'{3}){0,2})'; var bl='('+aZ+'{2,3}(-'+bk+')?|'+aZ+'{4}|'+ aZ+'{5,8})'; var bm=bl+'(-'+bj+')?(-'+bi+')?(-'+ bh+')*(-'+aq+')*(-'+bf+')?'; var bn= '^('+bm+'|'+bf+'|'+be+')$'; U=new l(bn,'i'); } InstallFunction(f,'getCanonicalLocales',function(H){ return makeArray(canonicalizeLocaleList(H)); } ); function CreateCollator(H,I){ if((I===(void 0))){ I={}; } var ai=getGetOption(I,'collator'); var bo={}; defineWEProperty(bo,'usage',ai( 'usage','string',['sort','search'],'sort')); var bp=ai('sensitivity','string', ['base','accent','case','variant']); if((bp===(void 0))&&bo.usage==='sort'){ bp='variant'; } defineWEProperty(bo,'sensitivity',bp); defineWEProperty(bo,'ignorePunctuation',ai( 'ignorePunctuation','boolean',(void 0),false)); var af=resolveLocale('collator',H,I); var as=parseExtension(af.extension); var bq={ 'kn':{'property':'numeric','type':'boolean'}, 'kf':{'property':'caseFirst','type':'string', 'values':['false','lower','upper']} }; setOptions( I,as,bq,ai,bo); var br='default'; var aq=''; if((%_Call(s,as,'co'))&&bo.usage==='sort'){ var bs=[ 'big5han','dict','direct','ducet','gb2312','phonebk','phonetic', 'pinyin','reformed','searchjl','stroke','trad','unihan','zhuyin' ]; if(%ArrayIndexOf(bs,as.co,0)!==-1){ aq='-u-co-'+as.co; br=as.co; } }else if(bo.usage==='search'){ aq='-u-co-search'; } defineWEProperty(bo,'collation',br); var bt=af.locale+aq; var ao=%object_define_properties({},{ caseFirst:{writable:true}, collation:{value:bo.collation,writable:true}, ignorePunctuation:{writable:true}, locale:{writable:true}, numeric:{writable:true}, requestedLocale:{value:bt,writable:true}, sensitivity:{writable:true}, strength:{writable:true}, usage:{value:bo.usage,writable:true} }); var bu=%CreateCollator(bt,bo,ao); %MarkAsInitializedIntlObjectOfType(bu,'collator'); bu[v]=ao; return bu; } function CollatorConstructor(){ return IntlConstruct(this,i,CreateCollator,new.target, arguments); } %SetCode(i,CollatorConstructor); InstallFunction(i.prototype,'resolvedOptions',function(){ var bv=Unwrap(this,'collator',i,'resolvedOptions', false); var af=getOptimalLanguageTag(bv[v].requestedLocale, bv[v].locale); return{ locale:af, usage:bv[v].usage, sensitivity:bv[v].sensitivity, ignorePunctuation:bv[v].ignorePunctuation, numeric:bv[v].numeric, caseFirst:bv[v].caseFirst, collation:bv[v].collation }; } ); InstallFunction(i,'supportedLocalesOf',function(H){ return supportedLocalesOf('collator',H,arguments[1]); } ); function compare(bu,bw,bx){ return %InternalCompare(bu,(%_ToString(bw)),(%_ToString(bx))); }; AddBoundMethod(i,'compare',compare,2,'collator',false); function isWellFormedCurrencyCode(by){ return typeof by==="string"&&by.length===3&& (%regexp_internal_match(/[^A-Za-z]/,by)===null); } function defaultNumberOption(an,bz,bA,bB,aj){ if(!(an===(void 0))){ an=(%_ToNumber(an)); if((%IS_VAR(an)!==an)||an<bz||an>bA){ throw %make_range_error(180,aj); } return %math_floor(an); } return bB; } function getNumberOption(I,aj,bz,bA,bB){ var an=I[aj]; return defaultNumberOption(an,bz,bA,bB,aj); } function SetNumberFormatDigitOptions(bo,I, mnfdDefault,mxfdDefault){ var bC=getNumberOption(I,'minimumIntegerDigits',1,21,1); defineWEProperty(bo,'minimumIntegerDigits',bC); var bD=getNumberOption(I,'minimumFractionDigits',0,20, mnfdDefault); defineWEProperty(bo,'minimumFractionDigits',bD); var bE=r(bD,mxfdDefault); var bF=getNumberOption(I,'maximumFractionDigits',bD,20, bE); defineWEProperty(bo,'maximumFractionDigits',bF); var bG=I['minimumSignificantDigits']; var bH=I['maximumSignificantDigits']; if(!(bG===(void 0))||!(bH===(void 0))){ bG=defaultNumberOption(bG,1,21,1,'minimumSignificantDigits'); defineWEProperty(bo,'minimumSignificantDigits',bG); bH=defaultNumberOption(bH,bG,21,21,'maximumSignificantDigits'); defineWEProperty(bo,'maximumSignificantDigits',bH); } } function CreateNumberFormat(H,I){ if((I===(void 0))){ I={}; } var ai=getGetOption(I,'numberformat'); var af=resolveLocale('numberformat',H,I); var bo={}; defineWEProperty(bo,'style',ai( 'style','string',['decimal','percent','currency'],'decimal')); var by=ai('currency','string'); if(!(by===(void 0))&&!isWellFormedCurrencyCode(by)){ throw %make_range_error(163,by); } if(bo.style==='currency'&&(by===(void 0))){ throw %make_type_error(31); } var bI,bJ; var bK=ai( 'currencyDisplay','string',['code','symbol','name'],'symbol'); if(bo.style==='currency'){ defineWEProperty(bo,'currency',%StringToUpperCaseI18N(by)); defineWEProperty(bo,'currencyDisplay',bK); bI=bJ=%CurrencyDigits(bo.currency); }else{ bI=0; bJ=bo.style==='percent'?0:3; } SetNumberFormatDigitOptions(bo,I,bI, bJ); defineWEProperty(bo,'useGrouping',ai( 'useGrouping','boolean',(void 0),true)); var as=parseExtension(af.extension); var bL={ 'nu':{'property':(void 0),'type':'string'} }; var aq=setOptions(I,as,bL, ai,bo); var bt=af.locale+aq; var ao=%object_define_properties({},{ currency:{writable:true}, currencyDisplay:{writable:true}, locale:{writable:true}, maximumFractionDigits:{writable:true}, minimumFractionDigits:{writable:true}, minimumIntegerDigits:{writable:true}, numberingSystem:{writable:true}, requestedLocale:{value:bt,writable:true}, style:{value:bo.style,writable:true}, useGrouping:{writable:true} }); if((%_Call(s,bo,'minimumSignificantDigits'))){ defineWEProperty(ao,'minimumSignificantDigits',(void 0)); } if((%_Call(s,bo,'maximumSignificantDigits'))){ defineWEProperty(ao,'maximumSignificantDigits',(void 0)); } var bM=%CreateNumberFormat(bt,bo, ao); if(bo.style==='currency'){ %object_define_property(ao,'currencyDisplay', {value:bK,writable:true}); } %MarkAsInitializedIntlObjectOfType(bM,'numberformat'); bM[v]=ao; return bM; } function NumberFormatConstructor(){ return IntlConstruct(this,h,CreateNumberFormat, new.target,arguments,true); } %SetCode(h,NumberFormatConstructor); InstallFunction(h.prototype,'resolvedOptions', function(){ var bN=Unwrap(this,'numberformat',h, 'resolvedOptions',true); var af=getOptimalLanguageTag(bN[v].requestedLocale, bN[v].locale); var aM={ locale:af, numberingSystem:bN[v].numberingSystem, style:bN[v].style, useGrouping:bN[v].useGrouping, minimumIntegerDigits:bN[v].minimumIntegerDigits, minimumFractionDigits:bN[v].minimumFractionDigits, maximumFractionDigits:bN[v].maximumFractionDigits, }; if(aM.style==='currency'){ defineWECProperty(aM,'currency',bN[v].currency); defineWECProperty(aM,'currencyDisplay', bN[v].currencyDisplay); } if((%_Call(s,bN[v],'minimumSignificantDigits'))){ defineWECProperty(aM,'minimumSignificantDigits', bN[v].minimumSignificantDigits); } if((%_Call(s,bN[v],'maximumSignificantDigits'))){ defineWECProperty(aM,'maximumSignificantDigits', bN[v].maximumSignificantDigits); } return aM; } ); InstallFunction(h,'supportedLocalesOf', function(H){ return supportedLocalesOf('numberformat',H,arguments[1]); } ); function formatNumber(bO,an){ var bP=(%_ToNumber(an))+0; return %InternalNumberFormat(bO,bP); } AddBoundMethod(h,'format',formatNumber,1, 'numberformat',true); function toLDMLString(I){ var ai=getGetOption(I,'dateformat'); var bQ=''; var bR=ai('weekday','string',['narrow','short','long']); bQ+=appendToLDMLString( bR,{narrow:'EEEEE',short:'EEE',long:'EEEE'}); bR=ai('era','string',['narrow','short','long']); bQ+=appendToLDMLString( bR,{narrow:'GGGGG',short:'GGG',long:'GGGG'}); bR=ai('year','string',['2-digit','numeric']); bQ+=appendToLDMLString(bR,{'2-digit':'yy','numeric':'y'}); bR=ai('month','string', ['2-digit','numeric','narrow','short','long']); bQ+=appendToLDMLString(bR,{'2-digit':'MM','numeric':'M', 'narrow':'MMMMM','short':'MMM','long':'MMMM'}); bR=ai('day','string',['2-digit','numeric']); bQ+=appendToLDMLString( bR,{'2-digit':'dd','numeric':'d'}); var bS=ai('hour12','boolean'); bR=ai('hour','string',['2-digit','numeric']); if((bS===(void 0))){ bQ+=appendToLDMLString(bR,{'2-digit':'jj','numeric':'j'}); }else if(bS===true){ bQ+=appendToLDMLString(bR,{'2-digit':'hh','numeric':'h'}); }else{ bQ+=appendToLDMLString(bR,{'2-digit':'HH','numeric':'H'}); } bR=ai('minute','string',['2-digit','numeric']); bQ+=appendToLDMLString(bR,{'2-digit':'mm','numeric':'m'}); bR=ai('second','string',['2-digit','numeric']); bQ+=appendToLDMLString(bR,{'2-digit':'ss','numeric':'s'}); bR=ai('timeZoneName','string',['short','long']); bQ+=appendToLDMLString(bR,{short:'z',long:'zzzz'}); return bQ; } function appendToLDMLString(bR,bT){ if(!(bR===(void 0))){ return bT[bR]; }else{ return''; } } function fromLDMLString(bQ){ bQ=%RegExpInternalReplace(GetQuotedStringRE(),bQ,''); var I={}; var aL=%regexp_internal_match(/E{3,5}/,bQ); I=appendToDateTimeObject( I,'weekday',aL,{EEEEE:'narrow',EEE:'short',EEEE:'long'}); aL=%regexp_internal_match(/G{3,5}/,bQ); I=appendToDateTimeObject( I,'era',aL,{GGGGG:'narrow',GGG:'short',GGGG:'long'}); aL=%regexp_internal_match(/y{1,2}/,bQ); I=appendToDateTimeObject( I,'year',aL,{y:'numeric',yy:'2-digit'}); aL=%regexp_internal_match(/M{1,5}/,bQ); I=appendToDateTimeObject(I,'month',aL,{MM:'2-digit', M:'numeric',MMMMM:'narrow',MMM:'short',MMMM:'long'}); aL=%regexp_internal_match(/L{1,5}/,bQ); I=appendToDateTimeObject(I,'month',aL,{LL:'2-digit', L:'numeric',LLLLL:'narrow',LLL:'short',LLLL:'long'}); aL=%regexp_internal_match(/d{1,2}/,bQ); I=appendToDateTimeObject( I,'day',aL,{d:'numeric',dd:'2-digit'}); aL=%regexp_internal_match(/h{1,2}/,bQ); if(aL!==null){ I['hour12']=true; } I=appendToDateTimeObject( I,'hour',aL,{h:'numeric',hh:'2-digit'}); aL=%regexp_internal_match(/H{1,2}/,bQ); if(aL!==null){ I['hour12']=false; } I=appendToDateTimeObject( I,'hour',aL,{H:'numeric',HH:'2-digit'}); aL=%regexp_internal_match(/m{1,2}/,bQ); I=appendToDateTimeObject( I,'minute',aL,{m:'numeric',mm:'2-digit'}); aL=%regexp_internal_match(/s{1,2}/,bQ); I=appendToDateTimeObject( I,'second',aL,{s:'numeric',ss:'2-digit'}); aL=%regexp_internal_match(/z|zzzz/,bQ); I=appendToDateTimeObject( I,'timeZoneName',aL,{z:'short',zzzz:'long'}); return I; } function appendToDateTimeObject(I,bR,aL,bT){ if((aL===null)){ if(!(%_Call(s,I,bR))){ defineWEProperty(I,bR,(void 0)); } return I; } var aj=aL[0]; defineWEProperty(I,bR,bT[aj]); return I; } function toDateTimeOptions(I,bU,bV){ if((I===(void 0))){ I={}; }else{ I=(%_ToObject(I)); } I=%object_create(I); var bW=true; if((bU==='date'||bU==='any')&& (!(I.weekday===(void 0))||!(I.year===(void 0))|| !(I.month===(void 0))||!(I.day===(void 0)))){ bW=false; } if((bU==='time'||bU==='any')&& (!(I.hour===(void 0))||!(I.minute===(void 0))|| !(I.second===(void 0)))){ bW=false; } if(bW&&(bV==='date'||bV==='all')){ %object_define_property(I,'year',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(I,'month',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(I,'day',{value:'numeric', writable:true, enumerable:true, configurable:true}); } if(bW&&(bV==='time'||bV==='all')){ %object_define_property(I,'hour',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(I,'minute',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(I,'second',{value:'numeric', writable:true, enumerable:true, configurable:true}); } return I; } function CreateDateTimeFormat(H,I){ if((I===(void 0))){ I={}; } var af=resolveLocale('dateformat',H,I); I=toDateTimeOptions(I,'any','date'); var ai=getGetOption(I,'dateformat'); var aa=ai('formatMatcher','string', ['basic','best fit'],'best fit'); var bQ=toLDMLString(I); var bX=canonicalizeTimeZoneID(I.timeZone); var bo={}; var as=parseExtension(af.extension); var bY={ 'ca':{'property':(void 0),'type':'string'}, 'nu':{'property':(void 0),'type':'string'} }; var aq=setOptions(I,as,bY, ai,bo); var bt=af.locale+aq; var ao=%object_define_properties({},{ calendar:{writable:true}, day:{writable:true}, era:{writable:true}, hour12:{writable:true}, hour:{writable:true}, locale:{writable:true}, minute:{writable:true}, month:{writable:true}, numberingSystem:{writable:true}, [u]:{writable:true}, requestedLocale:{value:bt,writable:true}, second:{writable:true}, timeZone:{writable:true}, timeZoneName:{writable:true}, tz:{value:bX,writable:true}, weekday:{writable:true}, year:{writable:true} }); var bZ=%CreateDateTimeFormat( bt,{skeleton:bQ,timeZone:bX},ao); if(ao.timeZone==="Etc/Unknown"){ throw %make_range_error(186,bX); } %MarkAsInitializedIntlObjectOfType(bZ,'dateformat'); bZ[v]=ao; return bZ; } function DateTimeFormatConstructor(){ return IntlConstruct(this,g,CreateDateTimeFormat, new.target,arguments,true); } %SetCode(g,DateTimeFormatConstructor); InstallFunction(g.prototype,'resolvedOptions', function(){ var bN=Unwrap(this,'dateformat',g, 'resolvedOptions',true); var ca={ 'gregorian':'gregory', 'ethiopic-amete-alem':'ethioaa' }; var cb=fromLDMLString(bN[v][u]); var cc=ca[bN[v].calendar]; if((cc===(void 0))){ cc=bN[v].calendar; } var af=getOptimalLanguageTag(bN[v].requestedLocale, bN[v].locale); var aM={ locale:af, numberingSystem:bN[v].numberingSystem, calendar:cc, timeZone:bN[v].timeZone }; addWECPropertyIfDefined(aM,'timeZoneName',cb.timeZoneName); addWECPropertyIfDefined(aM,'era',cb.era); addWECPropertyIfDefined(aM,'year',cb.year); addWECPropertyIfDefined(aM,'month',cb.month); addWECPropertyIfDefined(aM,'day',cb.day); addWECPropertyIfDefined(aM,'weekday',cb.weekday); addWECPropertyIfDefined(aM,'hour12',cb.hour12); addWECPropertyIfDefined(aM,'hour',cb.hour); addWECPropertyIfDefined(aM,'minute',cb.minute); addWECPropertyIfDefined(aM,'second',cb.second); return aM; } ); InstallFunction(g,'supportedLocalesOf', function(H){ return supportedLocalesOf('dateformat',H,arguments[1]); } ); function formatDate(bO,cd){ var ce; if((cd===(void 0))){ ce=%DateCurrentTime(); }else{ ce=(%_ToNumber(cd)); } if(!(%_IsSmi(%IS_VAR(ce))||((ce==ce)&&(ce!=1/0)&&(ce!=-1/0))))throw %make_range_error(154); return %InternalDateFormat(bO,new e(ce)); } function FormatDateToParts(cd){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"Intl.DateTimeFormat.prototype.formatToParts"); if(!(typeof(this)==='object')){ throw %make_type_error(16,this); } if(!%IsInitializedIntlObjectOfType(this,'dateformat')){ throw %make_type_error(48, 'Intl.DateTimeFormat.prototype.formatToParts', this); } var ce; if((cd===(void 0))){ ce=%DateCurrentTime(); }else{ ce=(%_ToNumber(cd)); } if(!(%_IsSmi(%IS_VAR(ce))||((ce==ce)&&(ce!=1/0)&&(ce!=-1/0))))throw %make_range_error(154); return %InternalDateFormatToParts(this,new e(ce)); } AddBoundMethod(g,'format',formatDate,1,'dateformat', true); function canonicalizeTimeZoneID(cf){ if((cf===(void 0))){ return cf; } cf=(%_ToString(cf)); var cg=%StringToUpperCaseI18N(cf); if(cg==='UTC'||cg==='GMT'|| cg==='ETC/UTC'||cg==='ETC/GMT'){ return'UTC'; } var aL=%regexp_internal_match(GetTimezoneNameCheckRE(),cf); if((aL===null))throw %make_range_error(155,cf); var aM=toTitleCaseTimezoneLocation(aL[1])+'/'+ toTitleCaseTimezoneLocation(aL[2]); if(!(aL[3]===(void 0))&&3<aL.length){ var ch=%StringSplit(aL[3],'/',4294967295); for(var ae=1;ae<ch.length;ae++){ aM=aM+'/'+toTitleCaseTimezoneLocation(ch[ae]); } } return aM; } function CreateBreakIterator(H,I){ if((I===(void 0))){ I={}; } var ai=getGetOption(I,'breakiterator'); var bo={}; defineWEProperty(bo,'type',ai( 'type','string',['character','word','sentence','line'],'word')); var af=resolveLocale('breakiterator',H,I); var ao=%object_define_properties({},{ requestedLocale:{value:af.locale,writable:true}, type:{value:bo.type,writable:true}, locale:{writable:true} }); var ci=%CreateBreakIterator(af.locale,bo,ao); %MarkAsInitializedIntlObjectOfType(ci,'breakiterator'); ci[v]=ao; return ci; } function v8BreakIteratorConstructor(){ return IntlConstruct(this,j,CreateBreakIterator, new.target,arguments); } %SetCode(j,v8BreakIteratorConstructor); InstallFunction(j.prototype,'resolvedOptions', function(){ if(!(new.target===(void 0))){ throw %make_type_error(85); } var cj=Unwrap(this,'breakiterator',j, 'resolvedOptions',false); var af= getOptimalLanguageTag(cj[v].requestedLocale, cj[v].locale); return{ locale:af, type:cj[v].type }; } ); InstallFunction(j,'supportedLocalesOf', function(H){ if(!(new.target===(void 0))){ throw %make_type_error(85); } return supportedLocalesOf('breakiterator',H,arguments[1]); } ); function adoptText(ci,ck){ %BreakIteratorAdoptText(ci,(%_ToString(ck))); } function first(ci){ return %BreakIteratorFirst(ci); } function next(ci){ return %BreakIteratorNext(ci); } function current(ci){ return %BreakIteratorCurrent(ci); } function breakType(ci){ return %BreakIteratorBreakType(ci); } AddBoundMethod(j,'adoptText',adoptText,1, 'breakiterator'); AddBoundMethod(j,'first',first,0,'breakiterator'); AddBoundMethod(j,'next',next,0,'breakiterator'); AddBoundMethod(j,'current',current,0, 'breakiterator'); AddBoundMethod(j,'breakType',breakType,0, 'breakiterator'); var cl={ 'collator':i, 'numberformat':h, 'dateformatall':g, 'dateformatdate':g, 'dateformattime':g }; var cm={ 'collator':(void 0), 'numberformat':(void 0), 'dateformatall':(void 0), 'dateformatdate':(void 0), 'dateformattime':(void 0), }; function clearDefaultObjects(){ cm['dateformatall']=(void 0); cm['dateformatdate']=(void 0); cm['dateformattime']=(void 0); } var cn=0; function checkDateCacheCurrent(){ var co=%DateCacheVersion(); if(co==cn){ return; } cn=co; clearDefaultObjects(); } function cachedOrNewService(Z,H,I,bV){ var cp=((bV===(void 0)))?I:bV; if((H===(void 0))&&(I===(void 0))){ checkDateCacheCurrent(); if((cm[Z]===(void 0))){ cm[Z]=new cl[Z](H,cp); } return cm[Z]; } return new cl[Z](H,cp); } function LocaleConvertCase(cq,H,cr){ var bl; if((H===(void 0))){ bl=GetDefaultICULocaleJS(); }else if((typeof(H)==='string')){ bl=canonicalizeLanguageTag(H); }else{ var H=initializeLocaleList(H); bl=H.length>0?H[0]:GetDefaultICULocaleJS(); } var ag=%StringIndexOf(bl,'-',0); if(ag!==-1){ bl=%_Call(y,bl,0,ag); } return %StringLocaleConvertCase(cq,cr,bl); } t(m.prototype,'localeCompare',function(cs){ if((this==null)){ throw %make_type_error(57); } var H=arguments[1]; var I=arguments[2]; var bu=cachedOrNewService('collator',H,I); return compare(bu,this,cs); } ); function ToLowerCaseI18N(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.toLowerCase"); return %StringToLowerCaseI18N((%_ToString(this))); } function ToUpperCaseI18N(){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.toUpperCase"); return %StringToUpperCaseI18N((%_ToString(this))); } function ToLocaleLowerCaseI18N(H){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.toLocaleLowerCase"); return LocaleConvertCase((%_ToString(this)),H,false); } %FunctionSetLength(ToLocaleLowerCaseI18N,0); function ToLocaleUpperCaseI18N(H){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(17,"String.prototype.toLocaleUpperCase"); return LocaleConvertCase((%_ToString(this)),H,true); } %FunctionSetLength(ToLocaleUpperCaseI18N,0); t(k.prototype,'toLocaleString',function(){ if(!(this instanceof k)&&typeof(this)!=='number'){ throw %make_type_error(58,"Number"); } var H=arguments[0]; var I=arguments[1]; var bM=cachedOrNewService('numberformat',H,I); return formatNumber(bM,this); } ); function toLocaleDateTime(ct,H,I,bU,bV,Z){ if(!(ct instanceof e)){ throw %make_type_error(58,"Date"); } var cd=(%_ToNumber(ct)); if((%IS_VAR(cd)!==cd))return'Invalid Date'; var bo=toDateTimeOptions(I,bU,bV); var bZ= cachedOrNewService(Z,H,I,bo); return formatDate(bZ,ct); } t(e.prototype,'toLocaleString',function(){ var H=arguments[0]; var I=arguments[1]; return toLocaleDateTime( this,H,I,'any','all','dateformatall'); } ); t(e.prototype,'toLocaleDateString',function(){ var H=arguments[0]; var I=arguments[1]; return toLocaleDateTime( this,H,I,'date','date','dateformatdate'); } ); t(e.prototype,'toLocaleTimeString',function(){ var H=arguments[0]; var I=arguments[1]; return toLocaleDateTime( this,H,I,'time','time','dateformattime'); } ); %FunctionRemovePrototype(FormatDateToParts); %FunctionRemovePrototype(ToLowerCaseI18N); %FunctionRemovePrototype(ToUpperCaseI18N); %FunctionRemovePrototype(ToLocaleLowerCaseI18N); %FunctionRemovePrototype(ToLocaleUpperCaseI18N); b.SetFunctionName(FormatDateToParts,"formatToParts"); b.SetFunctionName(ToLowerCaseI18N,"toLowerCase"); b.SetFunctionName(ToUpperCaseI18N,"toUpperCase"); b.SetFunctionName(ToLocaleLowerCaseI18N,"toLocaleLowerCase"); b.SetFunctionName(ToLocaleUpperCaseI18N,"toLocaleUpperCase"); b.Export(function(cu){ cu.FormatDateToParts=FormatDateToParts; cu.ToLowerCaseI18N=ToLowerCaseI18N; cu.ToUpperCaseI18N=ToUpperCaseI18N; cu.ToLocaleLowerCaseI18N=ToLocaleLowerCaseI18N; cu.ToLocaleUpperCaseI18N=ToLocaleUpperCaseI18N; }); }) �4CommonStringsI (function(global, binding, v8) { 'use strict'; binding.streamErrors = { illegalInvocation: 'Illegal invocation', illegalConstructor: 'Illegal constructor', invalidType: 'Invalid type is specified', invalidSize: 'The return value of a queuing strategy\'s size function must be a finite, non-NaN, non-negative number', sizeNotAFunction: 'A queuing strategy\'s size property must be a function', invalidHWM: 'A queueing strategy\'s highWaterMark property must be a nonnegative, non-NaN number', }; }); ,SimpleQueue (function(global, binding, v8) { 'use strict'; const QUEUE_MAX_ARRAY_SIZE = 16384; class SimpleQueue { constructor() { this.front = { elements: new v8.InternalPackedArray(), next: undefined, }; this.back = this.front; this.cursor = 0; this.size = 0; } get length() { return this.size; } push(element) { ++this.size; if (this.back.elements.length === QUEUE_MAX_ARRAY_SIZE) { const oldBack = this.back; this.back = { elements: new v8.InternalPackedArray(), next: undefined, }; oldBack.next = this.back; } this.back.elements.push(element); } shift() { --this.size; if (this.front.elements.length === this.cursor) { this.front = this.front.next; this.cursor = 0; } const element = this.front.elements[this.cursor]; this.front.elements[this.cursor] = undefined; ++this.cursor; return element; } forEach(callback) { let i = this.cursor; let node = this.front; let elements = node.elements; while (i !== elements.length || node.next !== undefined) { if (i === elements.length) { node = node.next; elements = node.elements; i = 0; } callback(elements[i]); ++i; } } peek() { if (this.front.elements.length === this.cursor) { return this.front.next.elements[0]; } return this.front.elements[this.cursor]; } } binding.SimpleQueue = SimpleQueue; }); dByteLengthQueuingStrategy� (function(global, binding, v8) { 'use strict'; const defineProperty = global.Object.defineProperty; class ByteLengthQueuingStrategy { constructor(options) { defineProperty(this, 'highWaterMark', { value: options.highWaterMark, enumerable: true, configurable: true, writable: true }); } size(chunk) { return chunk.byteLength; } } defineProperty(global, 'ByteLengthQueuingStrategy', { value: ByteLengthQueuingStrategy, enumerable: false, configurable: true, writable: true }); }); PCountQueuingStrategy� (function(global, binding, v8) { 'use strict'; const defineProperty = global.Object.defineProperty; class CountQueuingStrategy { constructor(options) { defineProperty(this, 'highWaterMark', { value: options.highWaterMark, enumerable: true, configurable: true, writable: true }); } size(chunk) { return 1; } } defineProperty(global, 'CountQueuingStrategy', { value: CountQueuingStrategy, enumerable: false, configurable: true, writable: true }); class BuiltInCountQueuingStrategy { constructor(highWaterMark) { defineProperty(this, 'highWaterMark', {value: highWaterMark}); } size(chunk) { return 1; } } binding.createBuiltInCountQueuingStrategy = highWaterMark => new BuiltInCountQueuingStrategy(highWaterMark); }); 8ReadableStream� (function(global, binding, v8) { 'use strict'; const _reader = v8.createPrivateSymbol('[[reader]]'); const _storedError = v8.createPrivateSymbol('[[storedError]]'); const _controller = v8.createPrivateSymbol('[[controller]]'); const _closedPromise = v8.createPrivateSymbol('[[closedPromise]]'); const _ownerReadableStream = v8.createPrivateSymbol('[[ownerReadableStream]]'); const _readRequests = v8.createPrivateSymbol('[[readRequests]]'); const createWithExternalControllerSentinel = v8.createPrivateSymbol('flag for UA-created ReadableStream to pass'); const _readableStreamBits = v8.createPrivateSymbol('bit field for [[state]] and [[disturbed]]'); const DISTURBED = 0b1; const STATE_MASK = 0b110; const STATE_BITS_OFFSET = 1; const STATE_READABLE = 0; const STATE_CLOSED = 1; const STATE_ERRORED = 2; const _underlyingSource = v8.createPrivateSymbol('[[underlyingSource]]'); const _controlledReadableStream = v8.createPrivateSymbol('[[controlledReadableStream]]'); const _queue = v8.createPrivateSymbol('[[queue]]'); const _totalQueuedSize = v8.createPrivateSymbol('[[totalQueuedSize]]'); const _strategySize = v8.createPrivateSymbol('[[strategySize]]'); const _strategyHWM = v8.createPrivateSymbol('[[strategyHWM]]'); const _readableStreamDefaultControllerBits = v8.createPrivateSymbol( 'bit field for [[started]], [[closeRequested]], [[pulling]], [[pullAgain]]'); const STARTED = 0b1; const CLOSE_REQUESTED = 0b10; const PULLING = 0b100; const PULL_AGAIN = 0b1000; const EXTERNALLY_CONTROLLED = 0b10000; const undefined = global.undefined; const Infinity = global.Infinity; const defineProperty = global.Object.defineProperty; const hasOwnProperty = v8.uncurryThis(global.Object.hasOwnProperty); const callFunction = v8.uncurryThis(global.Function.prototype.call); const applyFunction = v8.uncurryThis(global.Function.prototype.apply); const TypeError = global.TypeError; const RangeError = global.RangeError; const Number = global.Number; const Number_isNaN = Number.isNaN; const Number_isFinite = Number.isFinite; const Promise = global.Promise; const thenPromise = v8.uncurryThis(Promise.prototype.then); const Promise_resolve = v8.simpleBind(Promise.resolve, Promise); const Promise_reject = v8.simpleBind(Promise.reject, Promise); const streamErrors = binding.streamErrors; const errCancelLockedStream = 'Cannot cancel a readable stream that is locked to a reader'; const errEnqueueCloseRequestedStream = 'Cannot enqueue a chunk into a readable stream that is closed or has been requested to be closed'; const errCancelReleasedReader = 'This readable stream reader has been released and cannot be used to cancel its previous owner stream'; const errReadReleasedReader = 'This readable stream reader has been released and cannot be used to read from its previous owner stream'; const errCloseCloseRequestedStream = 'Cannot close a readable stream that has already been requested to be closed'; const errEnqueueClosedStream = 'Cannot enqueue a chunk into a closed readable stream'; const errEnqueueErroredStream = 'Cannot enqueue a chunk into an errored readable stream'; const errCloseClosedStream = 'Cannot close a closed readable stream'; const errCloseErroredStream = 'Cannot close an errored readable stream'; const errErrorClosedStream = 'Cannot error a close readable stream'; const errErrorErroredStream = 'Cannot error a readable stream that is already errored'; const errGetReaderNotByteStream = 'This readable stream does not support BYOB readers'; const errGetReaderBadMode = 'Invalid reader mode given: expected undefined or "byob"'; const errReaderConstructorBadArgument = 'ReadableStreamReader constructor argument is not a readable stream'; const errReaderConstructorStreamAlreadyLocked = 'ReadableStreamReader constructor can only accept readable streams that are not yet locked to a reader'; const errReleaseReaderWithPendingRead = 'Cannot release a readable stream reader when it still has outstanding read() calls that have not yet settled'; const errReleasedReaderClosedPromise = 'This readable stream reader has been released and cannot be used to monitor the stream\'s state'; const errTmplMustBeFunctionOrUndefined = name => `${name} must be a function or undefined`; const errCannotPipeLockedStream = 'Cannot pipe a locked stream'; const errCannotPipeToALockedStream = 'Cannot pipe to a locked stream'; const errDestinationStreamClosed = 'Destination stream closed'; class ReadableStream { constructor() { const underlyingSource = arguments[0] === undefined ? {} : arguments[0]; const strategy = arguments[1] === undefined ? {} : arguments[1]; const size = strategy.size; let highWaterMark = strategy.highWaterMark; if (highWaterMark === undefined) { highWaterMark = 1; } this[_readableStreamBits] = 0b0; ReadableStreamSetState(this, STATE_READABLE); this[_reader] = undefined; this[_storedError] = undefined; this[_controller] = undefined; const type = underlyingSource.type; const typeString = String(type); if (typeString === 'bytes') { throw new RangeError('bytes type is not yet implemented'); } else if (type !== undefined) { throw new RangeError(streamErrors.invalidType); } this[_controller] = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark, arguments[2] === createWithExternalControllerSentinel); } get locked() { if (IsReadableStream(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } return IsReadableStreamLocked(this); } cancel(reason) { if (IsReadableStream(this) === false) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (IsReadableStreamLocked(this) === true) { return Promise_reject(new TypeError(errCancelLockedStream)); } return ReadableStreamCancel(this, reason); } getReader({ mode } = {}) { if (IsReadableStream(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } if (mode === 'byob') { throw new TypeError(errGetReaderNotByteStream); } if (mode === undefined) { return AcquireReadableStreamDefaultReader(this); } throw new RangeError(errGetReaderBadMode); } pipeThrough({writable, readable}, options) { const promise = this.pipeTo(writable, options); if (v8.isPromise(promise)) { v8.markPromiseAsHandled(promise); } return readable; } pipeTo(dest, {preventClose, preventAbort, preventCancel} = {}) { if (!IsReadableStream(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (!binding.IsWritableStream(dest)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } preventClose = Boolean(preventClose); preventAbort = Boolean(preventAbort); preventCancel = Boolean(preventCancel); if (IsReadableStreamLocked(this)) { return Promise_reject(new TypeError(errCannotPipeLockedStream)); } if (binding.IsWritableStreamLocked(dest)) { return Promise_reject(new TypeError(errCannotPipeToALockedStream)); } return ReadableStreamPipeTo(this, dest, preventClose, preventAbort, preventCancel); } tee() { if (IsReadableStream(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } return ReadableStreamTee(this); } } function ReadableStreamPipeTo(readable, dest, preventClose, preventAbort, preventCancel) { const reader = AcquireReadableStreamDefaultReader(readable); const writer = binding.AcquireWritableStreamDefaultWriter(dest); let shuttingDown = false; const promise = v8.createPromise(); let reading = false; if (checkInitialState()) { thenPromise(reader[_closedPromise], onReaderClosed, readableError); thenPromise( binding.getWritableStreamDefaultWriterClosedPromise(writer), undefined, writableError); pump(); } function checkInitialState() { const state = ReadableStreamGetState(readable); if (state === STATE_ERRORED) { readableError(readable[_storedError]); return false; } if (binding.isWritableStreamErrored(dest)) { writableError(binding.getWritableStreamStoredError(dest)); return false; } if (state === STATE_CLOSED) { readableClosed(); return false; } if (binding.isWritableStreamClosingOrClosed(dest)) { writableStartedClosed(); return false; } return true; } function pump() { if (shuttingDown) { return; } const desiredSize = binding.WritableStreamDefaultWriterGetDesiredSize(writer); if (desiredSize === null) { return; } if (desiredSize <= 0) { thenPromise( binding.getWritableStreamDefaultWriterReadyPromise(writer), pump, writableError); return; } reading = true; thenPromise( ReadableStreamDefaultReaderRead(reader), readFulfilled, readRejected); } function readFulfilled({value, done}) { reading = false; if (shuttingDown) { return; } if (done) { readableClosed(); return; } const write = binding.WritableStreamDefaultWriterWrite(writer, value); thenPromise(write, undefined, writableError); pump(); } function readRejected() { reading = false; readableError(readable[_storedError]); } function onReaderClosed() { if (!reading) { readableClosed(); } } function readableError(error) { if (!preventAbort) { shutdownWithAction( binding.WritableStreamAbort, [dest, error], error, true); } else { shutdown(error, true); } } function writableError(error) { if (!preventCancel) { shutdownWithAction( ReadableStreamCancel, [readable, error], error, true); } else { shutdown(error, true); } } function readableClosed() { if (!preventClose) { shutdownWithAction( binding.WritableStreamDefaultWriterCloseWithErrorPropagation, [writer]); } else { shutdown(); } } function writableStartedClosed() { const destClosed = new TypeError(errDestinationStreamClosed); if (!preventCancel) { shutdownWithAction( ReadableStreamCancel, [readable, destClosed], destClosed, true); } else { shutdown(destClosed, true); } } function shutdownWithAction( action, args, originalError = undefined, errorGiven = false) { if (shuttingDown) { return; } shuttingDown = true; const p = applyFunction(action, undefined, args); thenPromise( p, () => finalize(originalError, errorGiven), newError => finalize(newError, true)); } function shutdown(error = undefined, errorGiven = false) { if (shuttingDown) { return; } shuttingDown = true; finalize(error, errorGiven); } function finalize(error, errorGiven) { binding.WritableStreamDefaultWriterRelease(writer); ReadableStreamReaderGenericRelease(reader); if (errorGiven) { v8.rejectPromise(promise, error); } else { v8.resolvePromise(promise, undefined); } } return promise; } class ReadableStreamDefaultController { constructor(stream, underlyingSource, size, highWaterMark, isExternallyControlled) { if (IsReadableStream(stream) === false) { throw new TypeError(streamErrors.illegalConstructor); } if (stream[_controller] !== undefined) { throw new TypeError(streamErrors.illegalConstructor); } this[_controlledReadableStream] = stream; this[_underlyingSource] = underlyingSource; this[_queue] = new binding.SimpleQueue(); this[_totalQueuedSize] = 0; this[_readableStreamDefaultControllerBits] = 0b0; if (isExternallyControlled === true) { this[_readableStreamDefaultControllerBits] |= EXTERNALLY_CONTROLLED; } const normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark); this[_strategySize] = normalizedStrategy.size; this[_strategyHWM] = normalizedStrategy.highWaterMark; const controller = this; const startResult = CallOrNoop( underlyingSource, 'start', this, 'underlyingSource.start'); thenPromise(Promise_resolve(startResult), () => { controller[_readableStreamDefaultControllerBits] |= STARTED; ReadableStreamDefaultControllerCallPullIfNeeded(controller); }, r => { if (ReadableStreamGetState(stream) === STATE_READABLE) { ReadableStreamDefaultControllerError(controller, r); } }); } get desiredSize() { if (IsReadableStreamDefaultController(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } return ReadableStreamDefaultControllerGetDesiredSize(this); } close() { if (IsReadableStreamDefaultController(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } const stream = this[_controlledReadableStream]; if (this[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) { throw new TypeError(errCloseCloseRequestedStream); } const state = ReadableStreamGetState(stream); if (state === STATE_ERRORED) { throw new TypeError(errCloseErroredStream); } if (state === STATE_CLOSED) { throw new TypeError(errCloseClosedStream); } return ReadableStreamDefaultControllerClose(this); } enqueue(chunk) { if (IsReadableStreamDefaultController(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } const stream = this[_controlledReadableStream]; if (this[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) { throw new TypeError(errEnqueueCloseRequestedStream); } const state = ReadableStreamGetState(stream); if (state === STATE_ERRORED) { throw new TypeError(errEnqueueErroredStream); } if (state === STATE_CLOSED) { throw new TypeError(errEnqueueClosedStream); } return ReadableStreamDefaultControllerEnqueue(this, chunk); } error(e) { if (IsReadableStreamDefaultController(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } const stream = this[_controlledReadableStream]; const state = ReadableStreamGetState(stream); if (state === STATE_ERRORED) { throw new TypeError(errErrorErroredStream); } if (state === STATE_CLOSED) { throw new TypeError(errErrorClosedStream); } return ReadableStreamDefaultControllerError(this, e); } } function ReadableStreamDefaultControllerCancel(controller, reason) { controller[_queue] = new binding.SimpleQueue(); const underlyingSource = controller[_underlyingSource]; return PromiseCallOrNoop(underlyingSource, 'cancel', reason, 'underlyingSource.cancel'); } function ReadableStreamDefaultControllerPull(controller) { const stream = controller[_controlledReadableStream]; if (controller[_queue].length > 0) { const chunk = DequeueValue(controller); if ((controller[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) && controller[_queue].length === 0) { ReadableStreamClose(stream); } else { ReadableStreamDefaultControllerCallPullIfNeeded(controller); } return Promise_resolve(CreateIterResultObject(chunk, false)); } const pendingPromise = ReadableStreamAddReadRequest(stream); ReadableStreamDefaultControllerCallPullIfNeeded(controller); return pendingPromise; } function ReadableStreamAddReadRequest(stream) { const promise = v8.createPromise(); stream[_reader][_readRequests].push(promise); return promise; } class ReadableStreamDefaultReader { constructor(stream) { if (IsReadableStream(stream) === false) { throw new TypeError(errReaderConstructorBadArgument); } if (IsReadableStreamLocked(stream) === true) { throw new TypeError(errReaderConstructorStreamAlreadyLocked); } ReadableStreamReaderGenericInitialize(this, stream); this[_readRequests] = new binding.SimpleQueue(); } get closed() { if (IsReadableStreamDefaultReader(this) === false) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } return this[_closedPromise]; } cancel(reason) { if (IsReadableStreamDefaultReader(this) === false) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } const stream = this[_ownerReadableStream]; if (stream === undefined) { return Promise_reject(new TypeError(errCancelReleasedReader)); } return ReadableStreamReaderGenericCancel(this, reason); } read() { if (IsReadableStreamDefaultReader(this) === false) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (this[_ownerReadableStream] === undefined) { return Promise_reject(new TypeError(errReadReleasedReader)); } return ReadableStreamDefaultReaderRead(this); } releaseLock() { if (IsReadableStreamDefaultReader(this) === false) { throw new TypeError(streamErrors.illegalInvocation); } const stream = this[_ownerReadableStream]; if (stream === undefined) { return undefined; } if (this[_readRequests].length > 0) { throw new TypeError(errReleaseReaderWithPendingRead); } ReadableStreamReaderGenericRelease(this); } } function ReadableStreamReaderGenericCancel(reader, reason) { return ReadableStreamCancel(reader[_ownerReadableStream], reason); } function AcquireReadableStreamDefaultReader(stream) { return new ReadableStreamDefaultReader(stream); } function ReadableStreamCancel(stream, reason) { stream[_readableStreamBits] |= DISTURBED; const state = ReadableStreamGetState(stream); if (state === STATE_CLOSED) { return Promise_resolve(undefined); } if (state === STATE_ERRORED) { return Promise_reject(stream[_storedError]); } ReadableStreamClose(stream); const sourceCancelPromise = ReadableStreamDefaultControllerCancel(stream[_controller], reason); return thenPromise(sourceCancelPromise, () => undefined); } function ReadableStreamDefaultControllerClose(controller) { const stream = controller[_controlledReadableStream]; controller[_readableStreamDefaultControllerBits] |= CLOSE_REQUESTED; if (controller[_queue].length === 0) { ReadableStreamClose(stream); } } function ReadableStreamFulfillReadRequest(stream, chunk, done) { const reader = stream[_reader]; const readRequest = stream[_reader][_readRequests].shift(); v8.resolvePromise(readRequest, CreateIterResultObject(chunk, done)); } function ReadableStreamDefaultControllerEnqueue(controller, chunk) { const stream = controller[_controlledReadableStream]; if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) { ReadableStreamFulfillReadRequest(stream, chunk, false); } else { let chunkSize = 1; const strategySize = controller[_strategySize]; if (strategySize !== undefined) { try { chunkSize = strategySize(chunk); } catch (chunkSizeE) { if (ReadableStreamGetState(stream) === STATE_READABLE) { ReadableStreamDefaultControllerError(controller, chunkSizeE); } throw chunkSizeE; } } try { EnqueueValueWithSize(controller, chunk, chunkSize); } catch (enqueueE) { if (ReadableStreamGetState(stream) === STATE_READABLE) { ReadableStreamDefaultControllerError(controller, enqueueE); } throw enqueueE; } } ReadableStreamDefaultControllerCallPullIfNeeded(controller); } function ReadableStreamGetState(stream) { return (stream[_readableStreamBits] & STATE_MASK) >> STATE_BITS_OFFSET; } function ReadableStreamSetState(stream, state) { stream[_readableStreamBits] = (stream[_readableStreamBits] & ~STATE_MASK) | (state << STATE_BITS_OFFSET); } function ReadableStreamDefaultControllerError(controller, e) { controller[_queue] = new binding.SimpleQueue(); const stream = controller[_controlledReadableStream]; ReadableStreamError(stream, e); } function ReadableStreamError(stream, e) { stream[_storedError] = e; ReadableStreamSetState(stream, STATE_ERRORED); const reader = stream[_reader]; if (reader === undefined) { return undefined; } if (IsReadableStreamDefaultReader(reader) === true) { reader[_readRequests].forEach(request => v8.rejectPromise(request, e)); reader[_readRequests] = new binding.SimpleQueue(); } v8.rejectPromise(reader[_closedPromise], e); v8.markPromiseAsHandled(reader[_closedPromise]); } function ReadableStreamClose(stream) { ReadableStreamSetState(stream, STATE_CLOSED); const reader = stream[_reader]; if (reader === undefined) { return undefined; } if (IsReadableStreamDefaultReader(reader) === true) { reader[_readRequests].forEach(request => v8.resolvePromise(request, CreateIterResultObject(undefined, true))); reader[_readRequests] = new binding.SimpleQueue(); } v8.resolvePromise(reader[_closedPromise], undefined); } function ReadableStreamDefaultControllerGetDesiredSize(controller) { const queueSize = GetTotalQueueSize(controller); return controller[_strategyHWM] - queueSize; } function IsReadableStream(x) { return hasOwnProperty(x, _controller); } function IsReadableStreamDisturbed(stream) { return stream[_readableStreamBits] & DISTURBED; } function IsReadableStreamLocked(stream) { return stream[_reader] !== undefined; } function IsReadableStreamDefaultController(x) { return hasOwnProperty(x, _controlledReadableStream); } function IsReadableStreamDefaultReader(x) { return hasOwnProperty(x, _readRequests); } function IsReadableStreamReadable(stream) { return ReadableStreamGetState(stream) === STATE_READABLE; } function IsReadableStreamClosed(stream) { return ReadableStreamGetState(stream) === STATE_CLOSED; } function IsReadableStreamErrored(stream) { return ReadableStreamGetState(stream) === STATE_ERRORED; } function ReadableStreamReaderGenericInitialize(reader, stream) { const controller = stream[_controller]; if (controller[_readableStreamDefaultControllerBits] & EXTERNALLY_CONTROLLED) { const underlyingSource = controller[_underlyingSource]; callFunction(underlyingSource.notifyLockAcquired, underlyingSource); } reader[_ownerReadableStream] = stream; stream[_reader] = reader; switch (ReadableStreamGetState(stream)) { case STATE_READABLE: reader[_closedPromise] = v8.createPromise(); break; case STATE_CLOSED: reader[_closedPromise] = Promise_resolve(undefined); break; case STATE_ERRORED: reader[_closedPromise] = Promise_reject(stream[_storedError]); v8.markPromiseAsHandled(reader[_closedPromise]); break; } } function ReadableStreamReaderGenericRelease(reader) { const controller = reader[_ownerReadableStream][_controller]; if (controller[_readableStreamDefaultControllerBits] & EXTERNALLY_CONTROLLED) { const underlyingSource = controller[_underlyingSource]; callFunction(underlyingSource.notifyLockReleased, underlyingSource); } if (ReadableStreamGetState(reader[_ownerReadableStream]) === STATE_READABLE) { v8.rejectPromise(reader[_closedPromise], new TypeError(errReleasedReaderClosedPromise)); } else { reader[_closedPromise] = Promise_reject(new TypeError(errReleasedReaderClosedPromise)); } v8.markPromiseAsHandled(reader[_closedPromise]); reader[_ownerReadableStream][_reader] = undefined; reader[_ownerReadableStream] = undefined; } function ReadableStreamDefaultReaderRead(reader) { const stream = reader[_ownerReadableStream]; stream[_readableStreamBits] |= DISTURBED; if (ReadableStreamGetState(stream) === STATE_CLOSED) { return Promise_resolve(CreateIterResultObject(undefined, true)); } if (ReadableStreamGetState(stream) === STATE_ERRORED) { return Promise_reject(stream[_storedError]); } return ReadableStreamDefaultControllerPull(stream[_controller]); } function ReadableStreamDefaultControllerCallPullIfNeeded(controller) { const shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller); if (shouldPull === false) { return undefined; } if (controller[_readableStreamDefaultControllerBits] & PULLING) { controller[_readableStreamDefaultControllerBits] |= PULL_AGAIN; return undefined; } controller[_readableStreamDefaultControllerBits] |= PULLING; const underlyingSource = controller[_underlyingSource]; const pullPromise = PromiseCallOrNoop( underlyingSource, 'pull', controller, 'underlyingSource.pull'); thenPromise(pullPromise, () => { controller[_readableStreamDefaultControllerBits] &= ~PULLING; if (controller[_readableStreamDefaultControllerBits] & PULL_AGAIN) { controller[_readableStreamDefaultControllerBits] &= ~PULL_AGAIN; ReadableStreamDefaultControllerCallPullIfNeeded(controller); } }, e => { if (ReadableStreamGetState(controller[_controlledReadableStream]) === STATE_READABLE) { ReadableStreamDefaultControllerError(controller, e); } }); } function ReadableStreamDefaultControllerShouldCallPull(controller) { const stream = controller[_controlledReadableStream]; const state = ReadableStreamGetState(stream); if (state === STATE_CLOSED || state === STATE_ERRORED) { return false; } if (controller[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) { return false; } if (!(controller[_readableStreamDefaultControllerBits] & STARTED)) { return false; } if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) { return true; } const desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller); if (desiredSize > 0) { return true; } return false; } function ReadableStreamGetNumReadRequests(stream) { const reader = stream[_reader]; const readRequests = reader[_readRequests]; return readRequests.length; } function ReadableStreamTee(stream) { const reader = AcquireReadableStreamDefaultReader(stream); let closedOrErrored = false; let canceled1 = false; let canceled2 = false; let reason1; let reason2; let promise = v8.createPromise(); const branch1Stream = new ReadableStream({pull, cancel: cancel1}); const branch2Stream = new ReadableStream({pull, cancel: cancel2}); const branch1 = branch1Stream[_controller]; const branch2 = branch2Stream[_controller]; thenPromise( reader[_closedPromise], undefined, function(r) { if (closedOrErrored === true) { return; } ReadableStreamDefaultControllerError(branch1, r); ReadableStreamDefaultControllerError(branch2, r); closedOrErrored = true; }); return [branch1Stream, branch2Stream]; function pull() { return thenPromise( ReadableStreamDefaultReaderRead(reader), function(result) { const value = result.value; const done = result.done; if (done === true && closedOrErrored === false) { if (canceled1 === false) { ReadableStreamDefaultControllerClose(branch1); } if (canceled2 === false) { ReadableStreamDefaultControllerClose(branch2); } closedOrErrored = true; } if (closedOrErrored === true) { return; } if (canceled1 === false) { ReadableStreamDefaultControllerEnqueue(branch1, value); } if (canceled2 === false) { ReadableStreamDefaultControllerEnqueue(branch2, value); } }); } function cancel1(reason) { canceled1 = true; reason1 = reason; if (canceled2 === true) { const compositeReason = [reason1, reason2]; const cancelResult = ReadableStreamCancel(stream, compositeReason); v8.resolvePromise(promise, cancelResult); } return promise; } function cancel2(reason) { canceled2 = true; reason2 = reason; if (canceled1 === true) { const compositeReason = [reason1, reason2]; const cancelResult = ReadableStreamCancel(stream, compositeReason); v8.resolvePromise(promise, cancelResult); } return promise; } } function DequeueValue(controller) { const result = controller[_queue].shift(); controller[_totalQueuedSize] -= result.size; return result.value; } function EnqueueValueWithSize(controller, value, size) { size = Number(size); if (Number_isNaN(size) || size === +Infinity || size < 0) { throw new RangeError(streamErrors.invalidSize); } controller[_totalQueuedSize] += size; controller[_queue].push({value, size}); } function GetTotalQueueSize(controller) { return controller[_totalQueuedSize]; } function ValidateAndNormalizeQueuingStrategy(size, highWaterMark) { if (size !== undefined && typeof size !== 'function') { throw new TypeError(streamErrors.sizeNotAFunction); } highWaterMark = Number(highWaterMark); if (Number_isNaN(highWaterMark)) { throw new RangeError(streamErrors.errInvalidHWM); } if (highWaterMark < 0) { throw new RangeError(streamErrors.invalidHWM); } return {size, highWaterMark}; } function CallOrNoop(O, P, arg, nameForError) { const method = O[P]; if (method === undefined) { return undefined; } if (typeof method !== 'function') { throw new TypeError(errTmplMustBeFunctionOrUndefined(nameForError)); } return callFunction(method, O, arg); } function PromiseCallOrNoop(O, P, arg, nameForError) { let method; try { method = O[P]; } catch (methodE) { return Promise_reject(methodE); } if (method === undefined) { return Promise_resolve(undefined); } if (typeof method !== 'function') { return Promise_reject(new TypeError(errTmplMustBeFunctionOrUndefined(nameForError))); } try { return Promise_resolve(callFunction(method, O, arg)); } catch (e) { return Promise_reject(e); } } function CreateIterResultObject(value, done) { return {value, done}; } defineProperty(global, 'ReadableStream', { value: ReadableStream, enumerable: false, configurable: true, writable: true }); binding.AcquireReadableStreamDefaultReader = AcquireReadableStreamDefaultReader; binding.IsReadableStream = IsReadableStream; binding.IsReadableStreamDisturbed = IsReadableStreamDisturbed; binding.IsReadableStreamLocked = IsReadableStreamLocked; binding.IsReadableStreamReadable = IsReadableStreamReadable; binding.IsReadableStreamClosed = IsReadableStreamClosed; binding.IsReadableStreamErrored = IsReadableStreamErrored; binding.IsReadableStreamDefaultReader = IsReadableStreamDefaultReader; binding.ReadableStreamDefaultReaderRead = ReadableStreamDefaultReaderRead; binding.ReadableStreamTee = ReadableStreamTee; binding.ReadableStreamDefaultControllerClose = ReadableStreamDefaultControllerClose; binding.ReadableStreamDefaultControllerGetDesiredSize = ReadableStreamDefaultControllerGetDesiredSize; binding.ReadableStreamDefaultControllerEnqueue = ReadableStreamDefaultControllerEnqueue; binding.ReadableStreamDefaultControllerError = ReadableStreamDefaultControllerError; binding.createReadableStreamWithExternalController = (underlyingSource, strategy) => { return new ReadableStream( underlyingSource, strategy, createWithExternalControllerSentinel); }; }); 8WritableStream�� (function(global, binding, v8) { 'use strict'; const _closeRequest = v8.createPrivateSymbol('[[closeRequest]]'); const _inFlightWriteRequest = v8.createPrivateSymbol('[[inFlightWriteRequest]]'); const _inFlightCloseRequest = v8.createPrivateSymbol('[[inFlightCloseRequest]]'); const _pendingAbortRequest = v8.createPrivateSymbol('[[pendingAbortRequest]]'); const _stateAndFlags = v8.createPrivateSymbol('[[state]] and flags'); const _storedError = v8.createPrivateSymbol('[[storedError]]'); const _writableStreamController = v8.createPrivateSymbol('[[writableStreamController]]'); const _writer = v8.createPrivateSymbol('[[writer]]'); const _writeRequests = v8.createPrivateSymbol('[[writeRequests]]'); const _closedPromise = v8.createPrivateSymbol('[[closedPromise]]'); const _ownerWritableStream = v8.createPrivateSymbol('[[ownerWritableStream]]'); const _readyPromise = v8.createPrivateSymbol('[[readyPromise]]'); const _controlledWritableStream = v8.createPrivateSymbol('[[controlledWritableStream]]'); const _queue = v8.createPrivateSymbol('[[queue]]'); const _queueTotalSize = v8.createPrivateSymbol('[[queueTotalSize]]'); const _started = v8.createPrivateSymbol('[[started]]'); const _strategyHWM = v8.createPrivateSymbol('[[strategyHWM]]'); const _strategySize = v8.createPrivateSymbol('[[strategySize]]'); const _underlyingSink = v8.createPrivateSymbol('[[underlyingSink]]'); const WRITABLE = 0; const CLOSED = 1; const ERRORING = 2; const ERRORED = 3; const STATE_MASK = 0xF; const BACKPRESSURE_FLAG = 0x10; const undefined = global.undefined; const defineProperty = global.Object.defineProperty; const hasOwnProperty = v8.uncurryThis(global.Object.hasOwnProperty); const Function_apply = v8.uncurryThis(global.Function.prototype.apply); const Function_call = v8.uncurryThis(global.Function.prototype.call); const TypeError = global.TypeError; const RangeError = global.RangeError; const Boolean = global.Boolean; const Number = global.Number; const Number_isNaN = Number.isNaN; const Number_isFinite = Number.isFinite; const Promise = global.Promise; const thenPromise = v8.uncurryThis(Promise.prototype.then); const Promise_resolve = v8.simpleBind(Promise.resolve, Promise); const Promise_reject = v8.simpleBind(Promise.reject, Promise); const streamErrors = binding.streamErrors; const errAbortLockedStream = 'Cannot abort a writable stream that is locked to a writer'; const errStreamAborted = 'The stream has been aborted'; const errStreamAborting = 'The stream is in the process of being aborted'; const errWriterLockReleasedPrefix = 'This writable stream writer has been released and cannot be '; const errCloseCloseRequestedStream = 'Cannot close a writable stream that has already been requested to be closed'; const errWriteCloseRequestedStream = 'Cannot write to a writable stream that is due to be closed'; const templateErrorCannotActionOnStateStream = (action, state) => `Cannot ${action} a ${state} writable stream`; const errReleasedWriterClosedPromise = 'This writable stream writer has been released and cannot be used to monitor the stream\'s state'; const templateErrorIsNotAFunction = f => `${f} is not a function`; const verbUsedToGetTheDesiredSize = 'used to get the desiredSize'; const verbAborted = 'aborted'; const verbClosed = 'closed'; const verbWrittenTo = 'written to'; function createWriterLockReleasedError(verb) { return new TypeError(errWriterLockReleasedPrefix + verb); } const stateNames = {[CLOSED]: 'closed', [ERRORED]: 'errored'}; function createCannotActionOnStateStreamError(action, state) { return new TypeError( templateErrorCannotActionOnStateStream(action, stateNames[state])); } function rejectPromises(queue, e) { queue.forEach(promise => v8.rejectPromise(promise, e)); } class WritableStream { constructor(underlyingSink = {}, { size, highWaterMark = 1 } = {}) { this[_stateAndFlags] = WRITABLE; this[_storedError] = undefined; this[_writer] = undefined; this[_writableStreamController] = undefined; this[_inFlightWriteRequest] = undefined; this[_closeRequest] = undefined; this[_inFlightCloseRequest] = undefined; this[_pendingAbortRequest] = undefined; this[_writeRequests] = new binding.SimpleQueue(); const type = underlyingSink.type; if (type !== undefined) { throw new RangeError(streamErrors.invalidType); } this[_writableStreamController] = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark); WritableStreamDefaultControllerStartSteps(this[_writableStreamController]); } get locked() { if (!IsWritableStream(this)) { throw new TypeError(streamErrors.illegalInvocation); } return IsWritableStreamLocked(this); } abort(reason) { if (!IsWritableStream(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (IsWritableStreamLocked(this)) { return Promise_reject(new TypeError(errAbortLockedStream)); } return WritableStreamAbort(this, reason); } getWriter() { if (!IsWritableStream(this)) { throw new TypeError(streamErrors.illegalInvocation); } return AcquireWritableStreamDefaultWriter(this); } } function AcquireWritableStreamDefaultWriter(stream) { return new WritableStreamDefaultWriter(stream); } function IsWritableStream(x) { return hasOwnProperty(x, _writableStreamController); } function IsWritableStreamLocked(stream) { return stream[_writer] !== undefined; } function WritableStreamAbort(stream, reason) { const state = stream[_stateAndFlags] & STATE_MASK; if (state === CLOSED) { return Promise_resolve(undefined); } if (state === ERRORED) { return Promise_reject(stream[_storedError]); } const error = new TypeError(errStreamAborting); if (stream[_pendingAbortRequest] !== undefined) { return Promise_reject(error); } const wasAlreadyErroring = state === ERRORING; if (wasAlreadyErroring) { reason = undefined; } const promise = v8.createPromise(); stream[_pendingAbortRequest] = {promise, reason, wasAlreadyErroring}; if (!wasAlreadyErroring) { WritableStreamStartErroring(stream, error); } return promise; } function WritableStreamAddWriteRequest(stream) { const promise = v8.createPromise(); stream[_writeRequests].push(promise); return promise; } function WritableStreamDealWithRejection(stream, error) { const state = stream[_stateAndFlags] & STATE_MASK; if (state === WRITABLE) { WritableStreamStartErroring(stream, error); return; } WritableStreamFinishErroring(stream); } function WritableStreamStartErroring(stream, reason) { const controller = stream[_writableStreamController]; stream[_stateAndFlags] = (stream[_stateAndFlags] & ~STATE_MASK) | ERRORING; stream[_storedError] = reason; const writer = stream[_writer]; if (writer !== undefined) { WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason); } if (!WritableStreamHasOperationMarkedInFlight(stream) && controller[_started]) { WritableStreamFinishErroring(stream); } } function WritableStreamFinishErroring(stream) { stream[_stateAndFlags] = (stream[_stateAndFlags] & ~STATE_MASK) | ERRORED; WritableStreamDefaultControllerErrorSteps( stream[_writableStreamController]); const storedError = stream[_storedError]; rejectPromises(stream[_writeRequests], storedError); stream[_writeRequests] = new binding.SimpleQueue(); if (stream[_pendingAbortRequest] === undefined) { WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); return; } const abortRequest = stream[_pendingAbortRequest]; stream[_pendingAbortRequest] = undefined; if (abortRequest.wasAlreadyErroring === true) { v8.rejectPromise(abortRequest.promise, storedError); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); return; } const promise = WritableStreamDefaultControllerAbortSteps( stream[_writableStreamController], abortRequest.reason); thenPromise( promise, () => { v8.resolvePromise(abortRequest.promise, undefined); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }, reason => { v8.rejectPromise(abortRequest.promise, reason); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }); } function WritableStreamFinishInFlightWrite(stream) { v8.resolvePromise(stream[_inFlightWriteRequest], undefined); stream[_inFlightWriteRequest] = undefined; } function WritableStreamFinishInFlightWriteWithError(stream, error) { v8.rejectPromise(stream[_inFlightWriteRequest], error); stream[_inFlightWriteRequest] = undefined; let state = stream[_stateAndFlags] & STATE_MASK; WritableStreamDealWithRejection(stream, error); } function WritableStreamFinishInFlightClose(stream) { v8.resolvePromise(stream[_inFlightCloseRequest], undefined); stream[_inFlightCloseRequest] = undefined; const state = stream[_stateAndFlags] & STATE_MASK; if (state === ERRORING) { stream[_storedError] = undefined; if (stream[_pendingAbortRequest] !== undefined) { v8.resolvePromise(stream[_pendingAbortRequest].promise, undefined); stream[_pendingAbortRequest] = undefined; } } stream[_stateAndFlags] = (stream[_stateAndFlags] & ~STATE_MASK) | CLOSED; const writer = stream[_writer]; if (writer !== undefined) { v8.resolvePromise(writer[_closedPromise], undefined); } } function WritableStreamFinishInFlightCloseWithError(stream, error) { v8.rejectPromise(stream[_inFlightCloseRequest], error); stream[_inFlightCloseRequest] = undefined; const state = stream[_stateAndFlags] & STATE_MASK; if (stream[_pendingAbortRequest] !== undefined) { v8.rejectPromise(stream[_pendingAbortRequest].promise, error); stream[_pendingAbortRequest] = undefined; } WritableStreamDealWithRejection(stream, error); } function WritableStreamCloseQueuedOrInFlight(stream) { return stream[_closeRequest] !== undefined || stream[_inFlightCloseRequest] !== undefined; } function WritableStreamHasOperationMarkedInFlight(stream) { return stream[_inFlightWriteRequest] !== undefined || stream[_inFlightCloseRequest] !== undefined; } function WritableStreamMarkCloseRequestInFlight(stream) { stream[_inFlightCloseRequest] = stream[_closeRequest]; stream[_closeRequest] = undefined; } function WritableStreamMarkFirstWriteRequestInFlight(stream) { const writeRequest = stream[_writeRequests].shift(); stream[_inFlightWriteRequest] = writeRequest; } function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) { if (stream[_closeRequest] !== undefined) { v8.rejectPromise(stream[_closeRequest], stream[_storedError]); stream[_closeRequest] = undefined; } const writer = stream[_writer]; if (writer !== undefined) { v8.rejectPromise(writer[_closedPromise], stream[_storedError]); v8.markPromiseAsHandled(writer[_closedPromise]); } } function WritableStreamUpdateBackpressure(stream, backpressure) { const writer = stream[_writer]; if (writer !== undefined && backpressure !== Boolean(stream[_stateAndFlags] & BACKPRESSURE_FLAG)) { if (backpressure) { writer[_readyPromise] = v8.createPromise(); } else { v8.resolvePromise(writer[_readyPromise], undefined); } } if (backpressure) { stream[_stateAndFlags] |= BACKPRESSURE_FLAG; } else { stream[_stateAndFlags] &= ~BACKPRESSURE_FLAG; } } function isWritableStreamErrored(stream) { return (stream[_stateAndFlags] & STATE_MASK) === ERRORED; } function isWritableStreamClosingOrClosed(stream) { return WritableStreamCloseQueuedOrInFlight(stream) || (stream[_stateAndFlags] & STATE_MASK) === CLOSED; } function getWritableStreamStoredError(stream) { return stream[_storedError]; } class WritableStreamDefaultWriter { constructor(stream) { if (!IsWritableStream(stream)) { throw new TypeError(streamErrors.illegalConstructor); } if (IsWritableStreamLocked(stream)) { throw new TypeError(streamErrors.illegalConstructor); } this[_ownerWritableStream] = stream; stream[_writer] = this; const state = stream[_stateAndFlags] & STATE_MASK; switch (state) { case WRITABLE: { if (!WritableStreamCloseQueuedOrInFlight(stream) && stream[_stateAndFlags] & BACKPRESSURE_FLAG) { this[_readyPromise] = v8.createPromise(); } else { this[_readyPromise] = Promise_resolve(undefined); } this[_closedPromise] = v8.createPromise(); break; } case ERRORING: { this[_readyPromise] = Promise_reject(stream[_storedError]); v8.markPromiseAsHandled(this[_readyPromise]); this[_closedPromise] = v8.createPromise(); break; } case CLOSED: { this[_readyPromise] = Promise_resolve(undefined); this[_closedPromise] = Promise_resolve(undefined); break; } default: { const storedError = stream[_storedError]; this[_readyPromise] = Promise_reject(storedError); v8.markPromiseAsHandled(this[_readyPromise]); this[_closedPromise] = Promise_reject(storedError); v8.markPromiseAsHandled(this[_closedPromise]); break; } } } get closed() { if (!IsWritableStreamDefaultWriter(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } return this[_closedPromise]; } get desiredSize() { if (!IsWritableStreamDefaultWriter(this)) { throw new TypeError(streamErrors.illegalInvocation); } if (this[_ownerWritableStream] === undefined) { throw createWriterLockReleasedError(verbUsedToGetTheDesiredSize); } return WritableStreamDefaultWriterGetDesiredSize(this); } get ready() { if (!IsWritableStreamDefaultWriter(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } return this[_readyPromise]; } abort(reason) { if (!IsWritableStreamDefaultWriter(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (this[_ownerWritableStream] === undefined) { return Promise_reject(createWriterLockReleasedError(verbAborted)); } return WritableStreamDefaultWriterAbort(this, reason); } close() { if (!IsWritableStreamDefaultWriter(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } const stream = this[_ownerWritableStream]; if (stream === undefined) { return Promise_reject(createWriterLockReleasedError(verbClosed)); } if (WritableStreamCloseQueuedOrInFlight(stream)) { return Promise_reject(new TypeError(errCloseCloseRequestedStream)); } return WritableStreamDefaultWriterClose(this); } releaseLock() { if (!IsWritableStreamDefaultWriter(this)) { throw new TypeError(streamErrors.illegalInvocation); } const stream = this[_ownerWritableStream]; if (stream === undefined) { return; } WritableStreamDefaultWriterRelease(this); } write(chunk) { if (!IsWritableStreamDefaultWriter(this)) { return Promise_reject(new TypeError(streamErrors.illegalInvocation)); } if (this[_ownerWritableStream] === undefined) { return Promise_reject(createWriterLockReleasedError(verbWrittenTo)); } return WritableStreamDefaultWriterWrite(this, chunk); } } function IsWritableStreamDefaultWriter(x) { return hasOwnProperty(x, _ownerWritableStream); } function WritableStreamDefaultWriterAbort(writer, reason) { const stream = writer[_ownerWritableStream]; return WritableStreamAbort(stream, reason); } function WritableStreamDefaultWriterClose(writer) { const stream = writer[_ownerWritableStream]; const state = stream[_stateAndFlags] & STATE_MASK; if (state === CLOSED || state === ERRORED) { return Promise_reject( createCannotActionOnStateStreamError('close', state)); } const promise = v8.createPromise(); stream[_closeRequest] = promise; if ((stream[_stateAndFlags] & BACKPRESSURE_FLAG) && state === WRITABLE) { v8.resolvePromise(writer[_readyPromise], undefined); } WritableStreamDefaultControllerClose(stream[_writableStreamController]); return promise; } function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) { const stream = writer[_ownerWritableStream]; const state = stream[_stateAndFlags] & STATE_MASK; if (WritableStreamCloseQueuedOrInFlight(stream) || state === CLOSED) { return Promise_resolve(undefined); } if (state === ERRORED) { return Promise_reject(stream[_storedError]); } return WritableStreamDefaultWriterClose(writer); } function WritableStreamDefaultWriterEnsureClosedPromiseRejected( writer, error) { if (v8.promiseState(writer[_closedPromise]) === v8.kPROMISE_PENDING) { v8.rejectPromise(writer[_closedPromise], error); } else { writer[_closedPromise] = Promise_reject(error); } v8.markPromiseAsHandled(writer[_closedPromise]); } function WritableStreamDefaultWriterEnsureReadyPromiseRejected( writer, error) { if (v8.promiseState(writer[_readyPromise]) === v8.kPROMISE_PENDING) { v8.rejectPromise(writer[_readyPromise], error); } else { writer[_readyPromise] = Promise_reject(error); } v8.markPromiseAsHandled(writer[_readyPromise]); } function WritableStreamDefaultWriterGetDesiredSize(writer) { const stream = writer[_ownerWritableStream]; const state = stream[_stateAndFlags] & STATE_MASK; if (state === ERRORED || state === ERRORING) { return null; } if (state === CLOSED) { return 0; } return WritableStreamDefaultControllerGetDesiredSize( stream[_writableStreamController]); } function WritableStreamDefaultWriterRelease(writer) { const stream = writer[_ownerWritableStream]; const releasedError = new TypeError(errReleasedWriterClosedPromise); WritableStreamDefaultWriterEnsureReadyPromiseRejected( writer, releasedError); WritableStreamDefaultWriterEnsureClosedPromiseRejected( writer, releasedError); stream[_writer] = undefined; writer[_ownerWritableStream] = undefined; } function WritableStreamDefaultWriterWrite(writer, chunk) { const stream = writer[_ownerWritableStream]; const controller = stream[_writableStreamController]; const chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk); if (stream !== writer[_ownerWritableStream]) { return Promise_reject(createWriterLockReleasedError(verbWrittenTo)); } const state = stream[_stateAndFlags] & STATE_MASK; if (state === ERRORED) { return Promise_reject(stream[_storedError]); } if (WritableStreamCloseQueuedOrInFlight(stream)) { return Promise_reject(new TypeError( templateErrorCannotActionOnStateStream('write to', 'closing'))); } if (state === CLOSED) { return Promise_reject( createCannotActionOnStateStreamError('write to', CLOSED)); } if (state === ERRORING) { return Promise_reject(stream[_storedError]); } const promise = WritableStreamAddWriteRequest(stream); WritableStreamDefaultControllerWrite(controller, chunk, chunkSize); return promise; } function getWritableStreamDefaultWriterClosedPromise(writer) { return writer[_closedPromise]; } function getWritableStreamDefaultWriterReadyPromise(writer) { return writer[_readyPromise]; } class WritableStreamDefaultController { constructor(stream, underlyingSink, size, highWaterMark) { if (!IsWritableStream(stream)) { throw new TypeError(streamErrors.illegalConstructor); } if (stream[_writableStreamController] !== undefined) { throw new TypeError(streamErrors.illegalConstructor); } this[_controlledWritableStream] = stream; this[_underlyingSink] = underlyingSink; this[_queue] = undefined; this[_queueTotalSize] = undefined; ResetQueue(this); this[_started] = false; const normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark); this[_strategySize] = normalizedStrategy.size; this[_strategyHWM] = normalizedStrategy.highWaterMark; const backpressure = WritableStreamDefaultControllerGetBackpressure(this); WritableStreamUpdateBackpressure(stream, backpressure); } error(e) { if (!IsWritableStreamDefaultController(this)) { throw new TypeError(streamErrors.illegalInvocation); } const state = this[_controlledWritableStream][_stateAndFlags] & STATE_MASK; if (state !== WRITABLE) { return; } WritableStreamDefaultControllerError(this, e); } } function WritableStreamDefaultControllerAbortSteps(controller, reason) { return PromiseInvokeOrNoop(controller[_underlyingSink], 'abort', [reason]); } function WritableStreamDefaultControllerErrorSteps(controller) { ResetQueue(controller); } function WritableStreamDefaultControllerStartSteps(controller) { const startResult = InvokeOrNoop(controller[_underlyingSink], 'start', [controller]); const stream = controller[_controlledWritableStream]; const startPromise = Promise_resolve(startResult); thenPromise( startPromise, () => { const state = stream[_stateAndFlags] & STATE_MASK; controller[_started] = true; WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); }, r => { const state = stream[_stateAndFlags] & STATE_MASK; controller[_started] = true; WritableStreamDealWithRejection(stream, r); }); } function IsWritableStreamDefaultController(x) { return hasOwnProperty(x, _underlyingSink); } function WritableStreamDefaultControllerClose(controller) { EnqueueValueWithSize(controller, 'close', 0); WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); } function WritableStreamDefaultControllerGetChunkSize(controller, chunk) { const strategySize = controller[_strategySize]; if (strategySize === undefined) { return 1; } let value; try { value = Function_call(strategySize, undefined, chunk); } catch (e) { WritableStreamDefaultControllerErrorIfNeeded(controller, e); return 1; } return value; } function WritableStreamDefaultControllerGetDesiredSize(controller) { return controller[_strategyHWM] - controller[_queueTotalSize]; } function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) { const writeRecord = {chunk}; try { EnqueueValueWithSize(controller, writeRecord, chunkSize); } catch (e) { WritableStreamDefaultControllerErrorIfNeeded(controller, e); return; } const stream = controller[_controlledWritableStream]; if (!WritableStreamCloseQueuedOrInFlight(stream) && (stream[_stateAndFlags] & STATE_MASK) === WRITABLE) { const backpressure = WritableStreamDefaultControllerGetBackpressure(controller); WritableStreamUpdateBackpressure(stream, backpressure); } WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); } function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) { const stream = controller[_controlledWritableStream]; if (!controller[_started]) { return; } if (stream[_inFlightWriteRequest] !== undefined) { return; } const state = stream[_stateAndFlags] & STATE_MASK; if (state === CLOSED || state === ERRORED) { return; } if (state === ERRORING) { WritableStreamFinishErroring(stream); return; } if (controller[_queue].length === 0) { return; } const writeRecord = PeekQueueValue(controller); if (writeRecord === 'close') { WritableStreamDefaultControllerProcessClose(controller); } else { WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk); } } function WritableStreamDefaultControllerErrorIfNeeded(controller, error) { const state = controller[_controlledWritableStream][_stateAndFlags] & STATE_MASK; if (state === WRITABLE) { WritableStreamDefaultControllerError(controller, error); } } function WritableStreamDefaultControllerProcessClose(controller) { const stream = controller[_controlledWritableStream]; WritableStreamMarkCloseRequestInFlight(stream); DequeueValue(controller); const sinkClosePromise = PromiseInvokeOrNoop( controller[_underlyingSink], 'close', []); thenPromise( sinkClosePromise, () => WritableStreamFinishInFlightClose(stream), reason => WritableStreamFinishInFlightCloseWithError(stream, reason) ); } function WritableStreamDefaultControllerProcessWrite(controller, chunk) { const stream = controller[_controlledWritableStream]; WritableStreamMarkFirstWriteRequestInFlight(stream); const sinkWritePromise = PromiseInvokeOrNoop(controller[_underlyingSink], 'write', [chunk, controller]); thenPromise( sinkWritePromise, () => { WritableStreamFinishInFlightWrite(stream); const state = stream[_stateAndFlags] & STATE_MASK; DequeueValue(controller); if (!WritableStreamCloseQueuedOrInFlight(stream) && state === WRITABLE) { const backpressure = WritableStreamDefaultControllerGetBackpressure(controller); WritableStreamUpdateBackpressure(stream, backpressure); } WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); }, reason => { WritableStreamFinishInFlightWriteWithError(stream, reason); }); } function WritableStreamDefaultControllerGetBackpressure(controller) { const desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller); return desiredSize <= 0; } function WritableStreamDefaultControllerError(controller, error) { const stream = controller[_controlledWritableStream]; WritableStreamStartErroring(stream, error); } function DequeueValue(container) { const pair = container[_queue].shift(); container[_queueTotalSize] -= pair.size; if (container[_queueTotalSize] < 0) { container[_queueTotalSize] = 0; } return pair.value; } function EnqueueValueWithSize(container, value, size) { size = Number(size); if (!IsFiniteNonNegativeNumber(size)) { throw new RangeError(streamErrors.invalidSize); } container[_queue].push({value, size}); container[_queueTotalSize] += size; } function PeekQueueValue(container) { const pair = container[_queue].peek(); return pair.value; } function ResetQueue(container) { container[_queue] = new binding.SimpleQueue(); container[_queueTotalSize] = 0; } function InvokeOrNoop(O, P, args) { if (args === undefined) { args = []; } const method = O[P]; if (method === undefined) { return undefined; } if (typeof method !== 'function') { throw new TypeError(templateErrorIsNotAFunction(P)); } return Function_apply(method, O, args); } function IsFiniteNonNegativeNumber(v) { return Number_isFinite(v) && v >= 0; } function PromiseInvokeOrNoop(O, P, args) { try { return Promise_resolve(InvokeOrNoop(O, P, args)); } catch (e) { return Promise_reject(e); } } function ValidateAndNormalizeQueuingStrategy(size, highWaterMark) { if (size !== undefined && typeof size !== 'function') { throw new TypeError(streamErrors.sizeNotAFunction); } highWaterMark = Number(highWaterMark); if (Number_isNaN(highWaterMark)) { throw new RangeError(streamErrors.errInvalidHWM); } if (highWaterMark < 0) { throw new RangeError(streamErrors.invalidHWM); } return {size, highWaterMark}; } defineProperty(global, 'WritableStream', { value: WritableStream, enumerable: false, configurable: true, writable: true }); binding.AcquireWritableStreamDefaultWriter = AcquireWritableStreamDefaultWriter; binding.IsWritableStream = IsWritableStream; binding.isWritableStreamClosingOrClosed = isWritableStreamClosingOrClosed; binding.isWritableStreamErrored = isWritableStreamErrored; binding.IsWritableStreamLocked = IsWritableStreamLocked; binding.WritableStreamAbort = WritableStreamAbort; binding.WritableStreamDefaultWriterCloseWithErrorPropagation = WritableStreamDefaultWriterCloseWithErrorPropagation; binding.getWritableStreamDefaultWriterClosedPromise = getWritableStreamDefaultWriterClosedPromise; binding.WritableStreamDefaultWriterGetDesiredSize = WritableStreamDefaultWriterGetDesiredSize; binding.getWritableStreamDefaultWriterReadyPromise = getWritableStreamDefaultWriterReadyPromise; binding.WritableStreamDefaultWriterRelease = WritableStreamDefaultWriterRelease; binding.WritableStreamDefaultWriterWrite = WritableStreamDefaultWriterWrite; binding.getWritableStreamStoredError = getWritableStreamStoredError; }); �dummy<(function() {})