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((%IsJSError(k)) ){ l=new ErrorMirror(k); }else if((%IsScriptWrapper(k)) ){ l=new ScriptMirror(k); }else if((%_IsJSMap(k)) ||(%_IsJSWeakMap(k))){ l=new MapMirror(k); }else if((%_IsJSSet(k)) ||(%_IsJSWeakSet(k))){ l=new SetMirror(k); }else if((%IsJSMapIterator(k)) ||(%IsJSSetIterator(k)) ){ l=new IteratorMirror(k); }else if(%is_promise(k)){ l=new PromiseMirror(k); }else if((%IsJSGeneratorObject(k)) ){ 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''+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'; }; ObjectMirror.GetInternalProperties=function(k){ var x=%DebugGetInternalProperties(k); var D=[]; for(var y=0;yK)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='#'; } 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((%_IsJSWeakMap(this.value_))){ var Q=%GetWeakMapEntries(this.value_,P||0); for(var y=0;y3){ 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;y0; }; 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=0&&G=0&&G=0&&G0){ for(var y=0;y0){ 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.InstallConstants(a,[ "MakeMirror",MakeMirror, "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, ]); }) debug¹U (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={}; k.DebugEvent={Break:1, Exception:2, AfterCompile:3, CompileError:4, AsyncTaskEvent:5}; k.ExceptionBreak={Caught:0, Uncaught:1}; k.StepAction={StepOut:0, StepNext:1, StepIn:2}; k.ScriptType={Native:0, Extension:1, Normal:2, Wasm:3}; k.ScriptCompilationType={Host:0, Eval:1, JSON:2}; function ScriptTypeFlag(l){ return(1<=this.frameCount()){ throw %make_type_error(46); } return new c(this.break_id,E); }; ExecutionState.prototype.setSelectedFrame=function(F){ var s=(%_ToNumber(F)); if(s<0||s>=this.frameCount()){ throw %make_type_error(46); } this.selected_frame=s; }; ExecutionState.prototype.selectedFrame=function(){ return this.selected_frame; }; function MakeExceptionEvent(B,G,H,I){ return new ExceptionEvent(B,G,H,I); } function ExceptionEvent(B,G,H,I){ this.exec_state_=new ExecutionState(B); this.exception_=G; this.uncaught_=H; this.promise_=I; } ExceptionEvent.prototype.eventType=function(){ return k.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(t,l){ return new CompileEvent(t,l); } function CompileEvent(t,l){ this.script_=g(t); this.type_=l; } CompileEvent.prototype.eventType=function(){ return this.type_; }; CompileEvent.prototype.script=function(){ return this.script_; }; function MakeScriptObject_(t,J){ var K={id:t.id(), name:t.name(), lineOffset:t.lineOffset(), columnOffset:t.columnOffset(), lineCount:t.lineCount(), }; if(!(t.data()===(void 0))){ K.data=t.data(); } if(J){ K.source=t.source(); } return K; } function MakeAsyncTaskEvent(l,L){ return new AsyncTaskEvent(l,L); } function AsyncTaskEvent(l,L){ this.type_=l; this.id_=L; } AsyncTaskEvent.prototype.type=function(){ return this.type_; } AsyncTaskEvent.prototype.id=function(){ return this.id_; } b.InstallConstants(a,[ "Debug",k, "CompileEvent",CompileEvent, ]); b.InstallConstants(b,[ "MakeExecutionState",MakeExecutionState, "MakeExceptionEvent",MakeExceptionEvent, "MakeCompileEvent",MakeCompileEvent, "MakeAsyncTaskEvent",MakeAsyncTaskEvent, ]); }) 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;xO[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=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=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= 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(aN0){ return bd; } } function TraverseTree(w){ w.live_shared_function_infos=FindFunctionInfos(w.info); for(var x=0;x ["+bl+"]"; } return; } var bm; function CheckStackActivations(old_shared_wrapper_list, new_shared_list, Z){ var bn=new d(); for(var x=0;x0){ 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>1); var j=2|4|1; for(var k=0;k>1)+(fields?fields.length:0); if(n>=4){ %OptimizeObjectForAddingMultipleProperties(m,n); } if(fields){ for(var k=0;k>2; var G=%EstimateNumberOfElements(o); return(GG*4); } function Stack(){ this.length=0; this.values=new g(); } Stack.prototype.length=null; Stack.prototype.values=null; function StackPush(H,I){ H.values[H.length++]=I; } function StackPop(H){ H.values[--H.length]=null } function StackHas(H,J){ var p=H.length; var K=H.values; for(var w=0;w=N){ var R=o[C]; if(!(R===(void 0))||C in o){ %CreateDataProperty(Q,C-N,R); } } } } } function SparseMove(o,N,O,P,T){ if(T===O)return; var U=new g( i(P-O+T,0xffffffff)); var V; var t=%GetArrayKeys(o,P); if((typeof(t)==='number')){ var u=t; for(var w=0;w=N+O){ var R=o[C]; if(!(R===(void 0))||C in o){ var W=C-O+T; U[W]=R; if(W>0xfffffffe){ V=V||new g(); V.push(W); } } } } } %MoveArrayContents(U,o); if(!(V===(void 0))){ var p=V.length; for(var w=0;wO){ for(var w=P-O;w>N;w--){ var Y=w+O-1; var Z=w+T-1; if(Y in o){ o[Z]=o[Y]; }else{ delete o[Z]; } } }else{ for(var w=N;wP-O+T;w--){ delete o[w-1]; } } } } var aa; %DefineMethodsInternal(f.prototype,class{toString(){ var o; var ab; if((%_IsArray(this))){ ab=this.join; if(ab===aa){ return Join(this,this.length,',',false); } o=this; }else{ o=(%_ToObject(this)); ab=o.join; } if(!(typeof(ab)==='function')){ return %_Call(k,o); } return %_Call(ab,o); }},-1); function InnerArrayToLocaleString(o,p){ return Join(o,(%_ToLength(p)),',',true); } %DefineMethodsInternal(f.prototype,class{toLocaleString(){ var o=(%_ToObject(this)); var ac=o.length; return InnerArrayToLocaleString(o,ac); }},-1); function InnerArrayJoin(z,o,p){ if((z===(void 0))){ z=','; }else{ z=(%_ToString(z)); } if(p===1){ var x=o[0]; if((x==null))return''; return(%_ToString(x)); } return Join(o,p,z,false); } %DefineMethodsInternal(f.prototype,class{join(z){ var o=(%_ToObject(this)); var p=(%_ToLength(o.length)); return InnerArrayJoin(z,o,p); }},-1); function ArrayPopFallback(){ var o=(%_ToObject(this)); var ad=(%_ToLength(o.length)); if(ad==0){ o.length=ad; return; } ad--; var I=o[ad]; delete o[ad]; o.length=ad; return I; } function ArrayPushFallback(){ var o=(%_ToObject(this)); var ad=(%_ToLength(o.length)); var ae=arguments.length; if(ae>9007199254740991-ad)throw %make_type_error(256,ae,ad); for(var w=0;w=w){ ak=w; while(v[++ah]==w){} al=P-w-1; } var am=o[ak]; if(!(am===(void 0))||ak in o){ var an=o[al]; if(!(an===(void 0))||al in o){ o[ak]=an; o[al]=am; }else{ o[al]=am; delete o[ak]; } }else{ var an=o[al]; if(!(an===(void 0))||al in o){ o[ak]=an; delete o[al]; } } } } function PackedArrayReverse(o,P){ var ai=P-1; for(var w=0;w0&&UseSparseVariant(o,P,(%_IsArray(o)),P)&& !%object_is_sealed(o)){ SparseMove(o,0,0,P,ar); }else{ SimpleMove(o,0,0,P,ar); } for(var w=0;wP?P:N; } function ComputeSpliceDeleteCount(au,ar,P,N){ var O=0; if(ar==1) return P-N; O=(%_ToInteger(au)); if(O<0) return 0; if(O>P-N) return P-N; return O; } function ArraySpliceFallback(as,au){ var ar=arguments.length; var o=(%_ToObject(this)); var P=(%_ToLength(o.length)); var N=ComputeSpliceStartIndex((%_ToInteger(as)),P); var O=ComputeSpliceDeleteCount(au,ar,P, N); var Q=ArraySpeciesCreate(o,O); Q.length=O; var av=ar>2?ar-2:0; if(O!=av&&%object_is_sealed(o)){ throw %make_type_error(15); }else if(O>0&&%object_is_frozen(o)){ throw %make_type_error(14); } var aw=O; if(av!=O){ aw+=P-N-O; } if(UseSparseVariant(o,P,(%_IsArray(o)),aw)){ %NormalizeElements(o); if((%_IsArray(Q)))%NormalizeElements(Q); SparseSlice(o,N,O,P,Q); SparseMove(o,N,O,P,av); }else{ SimpleSlice(o,N,O,P,Q); SimpleMove(o,N,O,P,av); } var w=N; var ax=2; var ay=arguments.length; while(ax=n;ai--){ var aD=r[ai]; var aE=az(aD,aC); if(aE>0){ r[ai+1]=aD; }else{ break; } } r[ai+1]=aC; } }; function GetThirdIndex(r,n,aB){ var aF=new g(); var aG=200+((aB-n)&15); var ai=0; n+=1; aB-=1; for(var w=n;w>1][0]; return aH; } function QuickSort(r,n,aB){ var aH=0; while(true){ if(aB-n<=10){ InsertionSort(r,n,aB); return; } if(aB-n>1000){ aH=GetThirdIndex(r,n,aB); }else{ aH=n+((aB-n)>>1); } var aI=r[n]; var aJ=r[aB-1]; var aK=r[aH]; var aL=az(aI,aJ); if(aL>0){ var aD=aI; aI=aJ; aJ=aD; } var aM=az(aI,aK); if(aM>=0){ var aD=aI; aI=aK; aK=aJ; aJ=aD; }else{ var aN=az(aJ,aK); if(aN>0){ var aD=aJ; aJ=aK; aK=aD; } } r[n]=aI; r[aB-1]=aK; var aO=aJ; var aP=n+1; var aQ=aB-1; r[aH]=r[aP]; r[aP]=aO; partition:for(var w=aP+1;w0){ do{ aQ--; if(aQ==w)break partition; var aR=r[aQ]; aE=az(aR,aO); }while(aE>0); r[w]=r[aQ]; r[aQ]=aC; if(aE<0){ aC=r[w]; r[w]=r[aP]; r[aP]=aC; aP++; } } } if(aB-aQ=aT){aT=w+1;} } } }else{ for(var w=0;w=aT){aT=X+1;} } } } } return aT; }; function ShadowPrototypeElements(aS,n,aB){ for(var aU=%object_get_prototype_of(aS);aU; aU=%object_get_prototype_of(aU)){ var t=(%_IsJSProxy(aU)) ?aB:%GetArrayKeys(aU,aB); if((typeof(t)==='number')){ var aV=t; for(var w=n;w=p)X=p-1; } var bb=0; var aT=X; if(UseSparseVariant(o,p,(%_IsArray(o)),X)){ %NormalizeElements(o); var t=%GetArrayKeys(o,X+1); if((typeof(t)==='number')){ aT=t; }else{ if(t.length==0)return-1; var bc=GetSortedArrayKeys(o,t); var w=bc.length-1; while(w>=0){ var C=bc[w]; if(o[C]===aC)return C; w--; } return-1; } } if(!(aC===(void 0))){ for(var w=aT;w>=bb;w--){ if(o[w]===aC)return w; } return-1; } for(var w=aT;w>=bb;w--){ if((o[w]===(void 0))&&w in o){ return w; } } return-1; }},1); %DefineMethodsInternal(f.prototype,class{copyWithin(target,as,at){ var o=(%_ToObject(this)); var p=(%_ToLength(o.length)); target=(%_ToInteger(target)); var aB; if(target<0){ aB=h(p+target,0); }else{ aB=i(target,p); } as=(%_ToInteger(as)); var n; if(as<0){ n=h(p+as,0); }else{ n=i(as,p); } at=(at===(void 0))?p:(%_ToInteger(at)); var bd; if(at<0){ bd=h(p+at,0); }else{ bd=i(at,p); } var be=i(bd-n,p-aB); var bf=1; if(n0){ if(n in o){ o[aB]=o[n]; }else{ delete o[aB]; } n=n+bf; aB=aB+bf; be--; } return o; }},2); %DefineMethodsInternal(f.prototype,class{fill(I,as,at){ var o=(%_ToObject(this)); var p=(%_ToLength(o.length)); var w=(as===(void 0))?0:(%_ToInteger(as)); var at=(at===(void 0))?p:(%_ToInteger(at)); if(w<0){ w+=p; if(w<0)w=0; }else{ if(w>p)w=p; } if(at<0){ at+=p; if(at<0)at=0; }else{ if(at>p)at=p; } if((at-w)>0&&%object_is_frozen(o)){ throw %make_type_error(14); } for(;wimplementation(z,fst,snd))) ; }else if(length===1){ A=(0,(fst=>implementation(z,fst))) ; }else{ A=(0,((...args)=>{ if(args.length>0){ return implementation(z,args[0]); }else{ return implementation(z); } })) ; } %SetNativeFlag(A); z[y]=A; } return z[y]; }},-1); } function IntlConstruct(z,constructor,create,newTarget,args, compat){ var B=args[0]; var C=args[1]; var D=create(B,C); if(compat&&(newTarget===(void 0))&&z instanceof constructor){ %object_define_property(z,o,{value:D}); return z; } return D; } function Unwrap(z,E,F,G,H){ if(!%IsInitializedIntlObjectOfType(z,E)){ if(H&&z instanceof F){ let fallback=z[o]; if(%IsInitializedIntlObjectOfType(fallback,E)){ return fallback; } } throw %make_type_error(61,G,z); } return z; } var I={ 'collator':(void 0), 'numberformat':(void 0), 'dateformat':(void 0), 'breakiterator':(void 0), 'pluralrules':(void 0), }; var J=(void 0); function GetDefaultICULocaleJS(K){ if((J===(void 0))){ J=%GetDefaultICULocale(); } return((K===(void 0))|| (%_Call(r,getAvailableLocalesOf(K),J))) ?J:"und"; } var L=(void 0); function GetUnicodeExtensionRE(){ if(((void 0)===(void 0))){ L=new m('-u(-[a-z0-9]{2,8})+','g'); } return L; } var M=(void 0); function GetAnyExtensionRE(){ if((M===(void 0))){ M=new m('-[a-z0-9]{1}-.*','g'); } return M; } var N=(void 0); function GetQuotedStringRE(){ if((N===(void 0))){ N=new m("'[^']+'",'g'); } return N; } var O=(void 0); function GetServiceRE(){ if((O===(void 0))){ O= new m('^('+%_Call(c,s(I),'|')+')$'); } return O; } var P=(void 0); function GetLanguageTagRE(){ if((P===(void 0))){ BuildLanguageTagREs(); } return P; } var Q=(void 0); function GetLanguageVariantRE(){ if((Q===(void 0))){ BuildLanguageTagREs(); } return Q; } var R=(void 0); function GetLanguageSingletonRE(){ if((R===(void 0))){ BuildLanguageTagREs(); } return R; } var S=(void 0); function GetTimezoneNameCheckRE(){ if((S===(void 0))){ S=new m( '^([A-Za-z]+)/([A-Za-z_-]+)((?:\/[A-Za-z_-]+)+)*$'); } return S; } var T=(void 0); function GetTimezoneNameLocationPartRE(){ if((T===(void 0))){ T= new m('^([A-Za-z]+)((?:[_-][A-Za-z]+)+)*$'); } return T; } function supportedLocalesOf(K,B,C){ if((%regexp_internal_match(GetServiceRE(),K)===null)){ throw %make_error(8,K); } if((C===(void 0))){ C={__proto__:null}; }else{ C=(%_ToObject(C)); } var U=C.localeMatcher; if(!(U===(void 0))){ U=(%_ToString(U)); if(U!=='lookup'&&U!=='best fit'){ throw %make_range_error(194,U); } }else{ U='best fit'; } var V=initializeLocaleList(B); var W=getAvailableLocalesOf(K); if(U==='best fit'){ return initializeLocaleList(bestFitSupportedLocalesOf( V,W)); } return initializeLocaleList(lookupSupportedLocalesOf( V,W)); } function lookupSupportedLocalesOf(V,W){ var X=new p(); for(var Y=0;Y=3&&ao<=8&&!(an===(void 0))){ if((ah===(void 0))){ ah=ap; }else{ ah=ah+"-"+ap; } }else{ return{__proto__:null}; } } if(!(an===(void 0))&&!(an in am)){ am[an]=ah; } return am; } function setOptions(aq,am,ar,ac,as){ var ak=''; var at=function updateExtension(an,ah){ return'-'+an+'-'+(%_ToString(ah)); } var au=function updateProperty(ad,ae,ah){ if(ae==='boolean'&&(typeof ah==='string')){ ah=(ah==='true')?true:false; } if(!(ad===(void 0))){ defineWEProperty(as,ad,ah); } } for(var an in ar){ if((%_Call(r,ar,an))){ var ah=(void 0); var av=ar[an]; if(!(av.property===(void 0))){ ah=ac(av.property,av.type,av.values); } if(!(ah===(void 0))){ au(av.property,av.type,ah); ak+=at(an,ah); continue; } if((%_Call(r,am,an))){ ah=am[an]; if(!(ah===(void 0))){ au(av.property,av.type,ah); ak+=at(an,ah); }else if(av.type==='boolean'){ au(av.property,av.type,true); ak+=at(an,true); } } } } return ak===''?'':'-u'+ak; } function freezeArray(aw){ var ax=[]; var ay=aw.length; for(var Y=0;Ybu){ throw %make_range_error(197,ad); } return %math_floor(ah); } return bv; } function getNumberOption(C,ad,bt,bu,bv){ var ah=C[ad]; return defaultNumberOption(ah,bt,bu,bv,ad); } function SetNumberFormatDigitOptions(bh,C, mnfdDefault,mxfdDefault){ var bw=getNumberOption(C,'minimumIntegerDigits',1,21,1); defineWEProperty(bh,'minimumIntegerDigits',bw); var bx=getNumberOption(C,'minimumFractionDigits',0,20, mnfdDefault); defineWEProperty(bh,'minimumFractionDigits',bx); var by=q(bx,mxfdDefault); var bz=getNumberOption(C,'maximumFractionDigits',bx,20, by); defineWEProperty(bh,'maximumFractionDigits',bz); var bA=C['minimumSignificantDigits']; var bB=C['maximumSignificantDigits']; if(!(bA===(void 0))||!(bB===(void 0))){ bA=defaultNumberOption(bA,1,21,1,'minimumSignificantDigits'); defineWEProperty(bh,'minimumSignificantDigits',bA); bB=defaultNumberOption(bB,bA,21,21,'maximumSignificantDigits'); defineWEProperty(bh,'maximumSignificantDigits',bB); } } function CreateNumberFormat(B,C){ if((C===(void 0))){ C={__proto__:null}; } var ac=getGetOption(C,'numberformat'); var Z=resolveLocale('numberformat',B,C); var bh={__proto__:null}; defineWEProperty(bh,'style',ac( 'style','string',['decimal','percent','currency'],'decimal')); var bs=ac('currency','string'); if(!(bs===(void 0))&&!isWellFormedCurrencyCode(bs)){ throw %make_range_error(179,bs); } if(bh.style==='currency'&&(bs===(void 0))){ throw %make_type_error(42); } var bC,bD; var bE=ac( 'currencyDisplay','string',['code','symbol','name'],'symbol'); if(bh.style==='currency'){ defineWEProperty(bh,'currency',%StringToUpperCaseIntl(bs)); defineWEProperty(bh,'currencyDisplay',bE); bC=bD=%CurrencyDigits(bh.currency); }else{ bC=0; bD=bh.style==='percent'?0:3; } SetNumberFormatDigitOptions(bh,C,bC, bD); defineWEProperty(bh,'useGrouping',ac( 'useGrouping','boolean',(void 0),true)); var am=parseExtension(Z.extension); var bF={ 'nu':{'property':(void 0),'type':'string'} }; var ak=setOptions(C,am,bF, ac,bh); var bm=Z.locale+ak; var ai=%object_define_properties({__proto__:null},{ currency:{writable:true}, currencyDisplay:{writable:true}, locale:{writable:true}, maximumFractionDigits:{writable:true}, minimumFractionDigits:{writable:true}, minimumIntegerDigits:{writable:true}, numberingSystem:{writable:true}, requestedLocale:{value:bm,writable:true}, style:{value:bh.style,writable:true}, useGrouping:{writable:true} }); if((%_Call(r,bh,'minimumSignificantDigits'))){ defineWEProperty(ai,'minimumSignificantDigits',(void 0)); } if((%_Call(r,bh,'maximumSignificantDigits'))){ defineWEProperty(ai,'maximumSignificantDigits',(void 0)); } var bG=%CreateNumberFormat(bm,bh, ai); if(bh.style==='currency'){ %object_define_property(ai,'currencyDisplay', {value:bE,writable:true}); } %MarkAsInitializedIntlObjectOfType(bG,'numberformat'); bG[u]=ai; return bG; } function NumberFormatConstructor(){ return IntlConstruct(this,h,CreateNumberFormat, new.target,arguments,true); } %SetCode(h,NumberFormatConstructor); %DefineMethodsInternal(h.prototype,class{resolvedOptions(){ var bH=Unwrap(this,'numberformat',h, 'resolvedOptions',true); var aF={ locale:bH[u].locale, numberingSystem:bH[u].numberingSystem, style:bH[u].style, useGrouping:bH[u].useGrouping, minimumIntegerDigits:bH[u].minimumIntegerDigits, minimumFractionDigits:bH[u].minimumFractionDigits, maximumFractionDigits:bH[u].maximumFractionDigits, }; if(aF.style==='currency'){ defineWECProperty(aF,'currency',bH[u].currency); defineWECProperty(aF,'currencyDisplay', bH[u].currencyDisplay); } if((%_Call(r,bH[u],'minimumSignificantDigits'))){ defineWECProperty(aF,'minimumSignificantDigits', bH[u].minimumSignificantDigits); } if((%_Call(r,bH[u],'maximumSignificantDigits'))){ defineWECProperty(aF,'maximumSignificantDigits', bH[u].maximumSignificantDigits); } return aF; }},-1); %DefineMethodsInternal(h,class{supportedLocalesOf(B){ return supportedLocalesOf('numberformat',B,arguments[1]); }},-1); function formatNumber(bI,ah){ var bJ=(%_ToNumber(ah))+0; return %InternalNumberFormat(bI,bJ); } AddBoundMethod(h,'format',formatNumber,1, 'numberformat',true); function toLDMLString(C){ var ac=getGetOption(C,'dateformat'); var bK=''; var bL=ac('weekday','string',['narrow','short','long']); bK+=appendToLDMLString( bL,{narrow:'EEEEE',short:'EEE',long:'EEEE'}); bL=ac('era','string',['narrow','short','long']); bK+=appendToLDMLString( bL,{narrow:'GGGGG',short:'GGG',long:'GGGG'}); bL=ac('year','string',['2-digit','numeric']); bK+=appendToLDMLString(bL,{'2-digit':'yy','numeric':'y'}); bL=ac('month','string', ['2-digit','numeric','narrow','short','long']); bK+=appendToLDMLString(bL,{'2-digit':'MM','numeric':'M', 'narrow':'MMMMM','short':'MMM','long':'MMMM'}); bL=ac('day','string',['2-digit','numeric']); bK+=appendToLDMLString( bL,{'2-digit':'dd','numeric':'d'}); var bM=ac('hour12','boolean'); bL=ac('hour','string',['2-digit','numeric']); if((bM===(void 0))){ bK+=appendToLDMLString(bL,{'2-digit':'jj','numeric':'j'}); }else if(bM===true){ bK+=appendToLDMLString(bL,{'2-digit':'hh','numeric':'h'}); }else{ bK+=appendToLDMLString(bL,{'2-digit':'HH','numeric':'H'}); } bL=ac('minute','string',['2-digit','numeric']); bK+=appendToLDMLString(bL,{'2-digit':'mm','numeric':'m'}); bL=ac('second','string',['2-digit','numeric']); bK+=appendToLDMLString(bL,{'2-digit':'ss','numeric':'s'}); bL=ac('timeZoneName','string',['short','long']); bK+=appendToLDMLString(bL,{short:'z',long:'zzzz'}); return bK; } function appendToLDMLString(bL,bN){ if(!(bL===(void 0))){ return bN[bL]; }else{ return''; } } function fromLDMLString(bK){ bK=%RegExpInternalReplace(GetQuotedStringRE(),bK,''); var C={__proto__:null}; var aE=%regexp_internal_match(/E{3,5}/,bK); C=appendToDateTimeObject( C,'weekday',aE,{EEEEE:'narrow',EEE:'short',EEEE:'long'}); aE=%regexp_internal_match(/G{3,5}/,bK); C=appendToDateTimeObject( C,'era',aE,{GGGGG:'narrow',GGG:'short',GGGG:'long'}); aE=%regexp_internal_match(/y{1,2}/,bK); C=appendToDateTimeObject( C,'year',aE,{y:'numeric',yy:'2-digit'}); aE=%regexp_internal_match(/M{1,5}/,bK); C=appendToDateTimeObject(C,'month',aE,{MM:'2-digit', M:'numeric',MMMMM:'narrow',MMM:'short',MMMM:'long'}); aE=%regexp_internal_match(/L{1,5}/,bK); C=appendToDateTimeObject(C,'month',aE,{LL:'2-digit', L:'numeric',LLLLL:'narrow',LLL:'short',LLLL:'long'}); aE=%regexp_internal_match(/d{1,2}/,bK); C=appendToDateTimeObject( C,'day',aE,{d:'numeric',dd:'2-digit'}); aE=%regexp_internal_match(/h{1,2}/,bK); if(aE!==null){ C['hour12']=true; } C=appendToDateTimeObject( C,'hour',aE,{h:'numeric',hh:'2-digit'}); aE=%regexp_internal_match(/H{1,2}/,bK); if(aE!==null){ C['hour12']=false; } C=appendToDateTimeObject( C,'hour',aE,{H:'numeric',HH:'2-digit'}); aE=%regexp_internal_match(/m{1,2}/,bK); C=appendToDateTimeObject( C,'minute',aE,{m:'numeric',mm:'2-digit'}); aE=%regexp_internal_match(/s{1,2}/,bK); C=appendToDateTimeObject( C,'second',aE,{s:'numeric',ss:'2-digit'}); aE=%regexp_internal_match(/z|zzzz/,bK); C=appendToDateTimeObject( C,'timeZoneName',aE,{z:'short',zzzz:'long'}); return C; } function appendToDateTimeObject(C,bL,aE,bN){ if((aE===null)){ if(!(%_Call(r,C,bL))){ defineWEProperty(C,bL,(void 0)); } return C; } var ad=aE[0]; defineWEProperty(C,bL,bN[ad]); return C; } function toDateTimeOptions(C,bO,bP){ if((C===(void 0))){ C={__proto__:null}; }else{ C=(%_ToObject(C)); } C=%object_create(C); var bQ=true; if((bO==='date'||bO==='any')&& (!(C.weekday===(void 0))||!(C.year===(void 0))|| !(C.month===(void 0))||!(C.day===(void 0)))){ bQ=false; } if((bO==='time'||bO==='any')&& (!(C.hour===(void 0))||!(C.minute===(void 0))|| !(C.second===(void 0)))){ bQ=false; } if(bQ&&(bP==='date'||bP==='all')){ %object_define_property(C,'year',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(C,'month',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(C,'day',{value:'numeric', writable:true, enumerable:true, configurable:true}); } if(bQ&&(bP==='time'||bP==='all')){ %object_define_property(C,'hour',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(C,'minute',{value:'numeric', writable:true, enumerable:true, configurable:true}); %object_define_property(C,'second',{value:'numeric', writable:true, enumerable:true, configurable:true}); } return C; } function CreateDateTimeFormat(B,C){ if((C===(void 0))){ C={__proto__:null}; } var Z=resolveLocale('dateformat',B,C); C=toDateTimeOptions(C,'any','date'); var ac=getGetOption(C,'dateformat'); var U=ac('formatMatcher','string', ['basic','best fit'],'best fit'); var bK=toLDMLString(C); var bR=canonicalizeTimeZoneID(C.timeZone); var bh={__proto__:null}; var am=parseExtension(Z.extension); var bS={ 'ca':{'property':(void 0),'type':'string'}, 'nu':{'property':(void 0),'type':'string'} }; var ak=setOptions(C,am,bS, ac,bh); var bm=Z.locale+ak; var ai=%object_define_properties({__proto__:null},{ 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}, [t]:{writable:true}, requestedLocale:{value:bm,writable:true}, second:{writable:true}, timeZone:{writable:true}, timeZoneName:{writable:true}, tz:{value:bR,writable:true}, weekday:{writable:true}, year:{writable:true} }); var bT=%CreateDateTimeFormat( bm,{skeleton:bK,timeZone:bR},ai); if(ai.timeZone==="Etc/Unknown"){ throw %make_range_error(203,bR); } %MarkAsInitializedIntlObjectOfType(bT,'dateformat'); bT[u]=ai; return bT; } function DateTimeFormatConstructor(){ return IntlConstruct(this,g,CreateDateTimeFormat, new.target,arguments,true); } %SetCode(g,DateTimeFormatConstructor); %DefineMethodsInternal(g.prototype,class{resolvedOptions(){ var bH=Unwrap(this,'dateformat',g, 'resolvedOptions',true); var bU={ 'gregorian':'gregory', 'ethiopic-amete-alem':'ethioaa' }; var bV=fromLDMLString(bH[u][t]); var bW=bU[bH[u].calendar]; if((bW===(void 0))){ bW=bH[u].calendar; } var aF={ locale:bH[u].locale, numberingSystem:bH[u].numberingSystem, calendar:bW, timeZone:bH[u].timeZone }; addWECPropertyIfDefined(aF,'timeZoneName',bV.timeZoneName); addWECPropertyIfDefined(aF,'era',bV.era); addWECPropertyIfDefined(aF,'year',bV.year); addWECPropertyIfDefined(aF,'month',bV.month); addWECPropertyIfDefined(aF,'day',bV.day); addWECPropertyIfDefined(aF,'weekday',bV.weekday); addWECPropertyIfDefined(aF,'hour12',bV.hour12); addWECPropertyIfDefined(aF,'hour',bV.hour); addWECPropertyIfDefined(aF,'minute',bV.minute); addWECPropertyIfDefined(aF,'second',bV.second); return aF; }},-1); %DefineMethodsInternal(g,class{supportedLocalesOf(B){ return supportedLocalesOf('dateformat',B,arguments[1]); }},-1); function formatDate(bI,bX){ var bY; if((bX===(void 0))){ bY=%DateCurrentTime(); }else{ bY=(%_ToNumber(bX)); } return %InternalDateFormat(bI,bY); } %DefineMethodsInternal(g.prototype,class{formatToParts(bX){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(27,"Intl.DateTimeFormat.prototype.formatToParts"); if(!(typeof(this)==='object') ){ throw %make_type_error(26,this); } if(!%IsInitializedIntlObjectOfType(this,'dateformat')){ throw %make_type_error(61, 'Intl.DateTimeFormat.prototype.formatToParts', this); } var bY; if((bX===(void 0))){ bY=%DateCurrentTime(); }else{ bY=(%_ToNumber(bX)); } return %InternalDateFormatToParts(this,bY); }},-1); AddBoundMethod(g,'format',formatDate,1,'dateformat', true); function canonicalizeTimeZoneID(bZ){ if((bZ===(void 0))){ return bZ; } bZ=(%_ToString(bZ)); var ca=%StringToUpperCaseIntl(bZ); if(ca==='UTC'||ca==='GMT'|| ca==='ETC/UTC'||ca==='ETC/GMT'){ return'UTC'; } var aE=%regexp_internal_match(GetTimezoneNameCheckRE(),bZ); if((aE===null))throw %make_range_error(171,bZ); var aF=toTitleCaseTimezoneLocation(aE[1])+'/'+ toTitleCaseTimezoneLocation(aE[2]); if(!(aE[3]===(void 0))&&30?B[0]:GetDefaultICULocaleJS(); } var aa=%StringIndexOf(be,'-',0); if(aa!==-1){ be=%_Call(w,be,0,aa); } return %StringLocaleConvertCase(ck,cl,be); } %DefineMethodsInternal(n.prototype,class{localeCompare(that){ if((this==null)){ throw %make_type_error(71); } var B=arguments[1]; var C=arguments[2]; var bn=cachedOrNewService('collator',B,C); return compare(bn,this,that); }},-1); %DefineMethodsInternal(n.prototype,class{ toLocaleLowerCase(B){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(27,"String.prototype.toLocaleLowerCase"); return LocaleConvertCase((%_ToString(this)),B,false); } toLocaleUpperCase(B){ if((%IS_VAR(this)===null)||(this===(void 0)))throw %make_type_error(27,"String.prototype.toLocaleUpperCase"); return LocaleConvertCase((%_ToString(this)),B,true); } },0); %DefineMethodsInternal(l.prototype,class{toLocaleString(){ if(!(this instanceof l)&&typeof(this)!=='number'){ throw %make_type_error(72,"Number"); } var B=arguments[0]; var C=arguments[1]; var bG=cachedOrNewService('numberformat',B,C); return formatNumber(bG,this); }},-1); function toLocaleDateTime(cm,B,C,bO,bP,K){ if(!(cm instanceof e)){ throw %make_type_error(72,"Date"); } var bX=(%_ToNumber(cm)); if((%IS_VAR(bX)!==bX) )return'Invalid Date'; var bh=toDateTimeOptions(C,bO,bP); var bT= cachedOrNewService(K,B,C,bh); return formatDate(bT,cm); } %DefineMethodsInternal(e.prototype,class{toLocaleString(){ var B=arguments[0]; var C=arguments[1]; return toLocaleDateTime( this,B,C,'any','all','dateformatall'); }},-1); %DefineMethodsInternal(e.prototype,class{toLocaleDateString(){ var B=arguments[0]; var C=arguments[1]; return toLocaleDateTime( this,B,C,'date','date','dateformatdate'); }},-1); %DefineMethodsInternal(e.prototype,class{toLocaleTimeString(){ var B=arguments[0]; var C=arguments[1]; return toLocaleDateTime( this,B,C,'time','time','dateformattime'); }},-1); }) @CommonOperations> (function(global, binding, v8) { 'use strict'; const _queue = v8.createPrivateSymbol('[[queue]]'); const _queueTotalSize = v8.createPrivateSymbol('[[queueTotalSize]]'); const Boolean = global.Boolean; const Number = global.Number; const Number_isFinite = Number.isFinite; const Number_isNaN = Number.isNaN; const RangeError = global.RangeError; const TypeError = global.TypeError; const hasOwnProperty = v8.uncurryThis(global.Object.hasOwnProperty); function hasOwnPropertyNoThrow(x, property) { return Boolean(x) && hasOwnProperty(x, property); } function streamInternalError() { throw new RangeError('Stream API Internal Error'); } function rejectPromise(p, reason) { if (!v8.isPromise(p)) { streamInternalError(); } v8.rejectPromise(p, reason); } function resolvePromise(p, value) { if (!v8.isPromise(p)) { streamInternalError(); } v8.resolvePromise(p, value); } function markPromiseAsHandled(p) { if (!v8.isPromise(p)) { streamInternalError(); } v8.markPromiseAsHandled(p); } function promiseState(p) { if (!v8.isPromise(p)) { streamInternalError(); } return v8.promiseState(p); } 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(binding.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 IsFiniteNonNegativeNumber(v) { return Number_isFinite(v) && v >= 0; } function ValidateAndNormalizeQueuingStrategy(size, highWaterMark) { if (size !== undefined && typeof size !== 'function') { throw new TypeError(binding.streamErrors.sizeNotAFunction); } highWaterMark = Number(highWaterMark); if (Number_isNaN(highWaterMark)) { throw new RangeError(binding.streamErrors.invalidHWM); } if (highWaterMark < 0) { throw new RangeError(binding.streamErrors.invalidHWM); } return {size, highWaterMark}; } const callFunction = v8.uncurryThis(global.Function.prototype.call); const errTmplMustBeFunctionOrUndefined = name => `${name} must be a function or undefined`; const Promise_resolve = Promise.resolve.bind(Promise); const Promise_reject = Promise.reject.bind(Promise); function resolveMethod(O, P, nameForError) { const method = O[P]; if (typeof method !== 'function' && typeof method !== 'undefined') { throw new TypeError(errTmplMustBeFunctionOrUndefined(nameForError)); } return method; } function CallOrNoop1(O, P, arg0, nameForError) { const method = resolveMethod(O, P, nameForError); if (method === undefined) { return undefined; } return callFunction(method, O, arg0); } function PromiseCallOrNoop0(O, P, nameForError) { try { const method = resolveMethod(O, P, nameForError); if (method === undefined) { return Promise_resolve(); } return Promise_resolve(callFunction(method, O)); } catch (e) { return Promise_reject(e); } } function PromiseCallOrNoop1(O, P, arg0, nameForError) { try { return Promise_resolve(CallOrNoop1(O, P, arg0, nameForError)); } catch (e) { return Promise_reject(e); } } function PromiseCallOrNoop2(O, P, arg0, arg1, nameForError) { try { const method = resolveMethod(O, P, nameForError); if (method === undefined) { return Promise_resolve(); } return Promise_resolve(callFunction(method, O, arg0, arg1)); } catch (e) { return Promise_reject(e); } } binding.streamOperations = { _queue, _queueTotalSize, hasOwnPropertyNoThrow, rejectPromise, resolvePromise, markPromiseAsHandled, promiseState, DequeueValue, EnqueueValueWithSize, PeekQueueValue, ResetQueue, ValidateAndNormalizeQueuingStrategy, CallOrNoop1, PromiseCallOrNoop0, PromiseCallOrNoop1, PromiseCallOrNoop2 }; }); 4CommonStringsù (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 _front = v8.createPrivateSymbol('front'); const _back = v8.createPrivateSymbol('back'); const _cursor = v8.createPrivateSymbol('cursor'); const _size = v8.createPrivateSymbol('size'); const _elements = v8.createPrivateSymbol('elements'); const _next = v8.createPrivateSymbol('next'); const RangeError = global.RangeError; function requireNonEmptyQueue(queue, functionName) { if (queue[_size] === 0) { throw new RangeError( `${functionName}() must not be called on an empty queue`); } } 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) { const oldBack = this[_back]; let newBack = oldBack; if (oldBack[_elements].length === QUEUE_MAX_ARRAY_SIZE - 1) { newBack = { [_elements]: new v8.InternalPackedArray(), [_next]: undefined, }; } oldBack[_elements].push(element); if (newBack !== oldBack) { this[_back] = newBack; oldBack[_next] = newBack; } ++this[_size]; } shift() { requireNonEmptyQueue(this, 'shift'); const oldFront = this[_front]; let newFront = oldFront; const oldCursor = this[_cursor]; let newCursor = oldCursor + 1; const elements = oldFront[_elements]; const element = elements[oldCursor]; if (newCursor === QUEUE_MAX_ARRAY_SIZE) { newFront = oldFront[_next]; newCursor = 0; } --this[_size]; this[_cursor] = newCursor; if (oldFront !== newFront) { this[_front] = newFront; } elements[oldCursor] = undefined; 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; if (elements.length === 0) { break; } } callback(elements[i]); ++i; } } peek() { requireNonEmptyQueue(this, 'peek'); const front = this[_front]; const cursor = this[_cursor]; return front[_elements][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() { return 1; } } defineProperty(global, 'CountQueuingStrategy', { value: CountQueuingStrategy, enumerable: false, configurable: true, writable: true }); class BuiltInCountQueuingStrategy { constructor(highWaterMark) { defineProperty(this, 'highWaterMark', {value: highWaterMark}); } size() { return 1; } } binding.createBuiltInCountQueuingStrategy = highWaterMark => new BuiltInCountQueuingStrategy(highWaterMark); }); 8ReadableStreamZº (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 _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 defineProperty = global.Object.defineProperty; 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 Boolean = global.Boolean; const String = global.String; const Promise = global.Promise; const thenPromise = v8.uncurryThis(Promise.prototype.then); const Promise_resolve = Promise.resolve.bind(Promise); const Promise_reject = Promise.reject.bind(Promise); const { _queue, _queueTotalSize, hasOwnPropertyNoThrow, rejectPromise, resolvePromise, markPromiseAsHandled, DequeueValue, EnqueueValueWithSize, ValidateAndNormalizeQueuingStrategy, CallOrNoop1, PromiseCallOrNoop1 } = binding.streamOperations; 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 errCannotPipeLockedStream = 'Cannot pipe a locked stream'; const errCannotPipeToALockedStream = 'Cannot pipe to a locked stream'; const errDestinationStreamClosed = 'Destination stream closed'; const errPipeThroughUndefinedWritable = 'Failed to execute \'pipeThrough\' on \'ReadableStream\': parameter ' + '1\'s \'writable\' property is undefined.'; const errPipeThroughUndefinedReadable = 'Failed to execute \'pipeThrough\' on \'ReadableStream\': parameter ' + '1\'s \'readable\' property is undefined.'; class ReadableStream { constructor(underlyingSource = {}, { size, highWaterMark = 1 } = {}, internalArgument = undefined) { 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, internalArgument === 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) { if (writable === undefined) { throw new TypeError(errPipeThroughUndefinedWritable); } if (readable === undefined) { throw new TypeError(errPipeThroughUndefinedReadable); } const promise = this.pipeTo(writable, options); if (v8.isPromise(promise)) { 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) { rejectPromise(promise, error); } else { resolvePromise(promise, undefined); } } return promise; } function AcquireReadableStreamDefaultReader(stream) { return new ReadableStreamDefaultReader(stream); } function IsReadableStream(x) { return hasOwnPropertyNoThrow(x, _controller); } function IsReadableStreamDisturbed(stream) { return stream[_readableStreamBits] & DISTURBED; } function IsReadableStreamLocked(stream) { return stream[_reader] !== undefined; } function ReadableStreamTee(stream) { const reader = AcquireReadableStreamDefaultReader(stream); let closedOrErrored = false; let canceled1 = false; let canceled2 = false; let reason1; let reason2; const 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); resolvePromise(promise, cancelResult); } return promise; } function cancel2(reason) { canceled2 = true; reason2 = reason; if (canceled1 === true) { const compositeReason = [reason1, reason2]; const cancelResult = ReadableStreamCancel(stream, compositeReason); resolvePromise(promise, cancelResult); } return promise; } } function ReadableStreamAddReadRequest(stream) { const promise = v8.createPromise(); stream[_reader][_readRequests].push(promise); return promise; } 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 ReadableStreamClose(stream) { ReadableStreamSetState(stream, STATE_CLOSED); const reader = stream[_reader]; if (reader === undefined) { return undefined; } if (IsReadableStreamDefaultReader(reader) === true) { reader[_readRequests].forEach( request => resolvePromise(request, CreateIterResultObject(undefined, true))); reader[_readRequests] = new binding.SimpleQueue(); } resolvePromise(reader[_closedPromise], undefined); } 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 => rejectPromise(request, e)); reader[_readRequests] = new binding.SimpleQueue(); } rejectPromise(reader[_closedPromise], e); markPromiseAsHandled(reader[_closedPromise]); } function ReadableStreamFulfillReadRequest(stream, chunk, done) { const readRequest = stream[_reader][_readRequests].shift(); resolvePromise(readRequest, CreateIterResultObject(chunk, done)); } function ReadableStreamGetNumReadRequests(stream) { const reader = stream[_reader]; const readRequests = reader[_readRequests]; return readRequests.length; } 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 IsReadableStreamDefaultReader(x) { return hasOwnPropertyNoThrow(x, _readRequests); } function ReadableStreamReaderGenericCancel(reader, reason) { return ReadableStreamCancel(reader[_ownerReadableStream], reason); } 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]); 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) { rejectPromise( reader[_closedPromise], new TypeError(errReleasedReaderClosedPromise)); } else { reader[_closedPromise] = Promise_reject(new TypeError(errReleasedReaderClosedPromise)); } 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]); } 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[_queueTotalSize] = 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 = CallOrNoop1( 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); } if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) { const stream = this[_controlledReadableStream]; throw getReadableStreamEnqueueError(stream, this); } 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 PromiseCallOrNoop1( 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 IsReadableStreamDefaultController(x) { return hasOwnPropertyNoThrow(x, _controlledReadableStream); } 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 = PromiseCallOrNoop1( 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 ReadableStreamDefaultControllerClose(controller) { const stream = controller[_controlledReadableStream]; controller[_readableStreamDefaultControllerBits] |= CLOSE_REQUESTED; if (controller[_queue].length === 0) { ReadableStreamClose(stream); } } 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 ReadableStreamDefaultControllerError(controller, e) { controller[_queue] = new binding.SimpleQueue(); const stream = controller[_controlledReadableStream]; ReadableStreamError(stream, e); } function ReadableStreamDefaultControllerGetDesiredSize(controller) { return controller[_strategyHWM] - controller[_queueTotalSize]; } function ReadableStreamDefaultControllerHasBackpressure(controller) { return !ReadableStreamDefaultControllerShouldCallPull(controller); } function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) { if (controller[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) { return false; } const state = ReadableStreamGetState(controller[_controlledReadableStream]); return state === STATE_READABLE; } 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 IsReadableStreamReadable(stream) { return ReadableStreamGetState(stream) === STATE_READABLE; } function IsReadableStreamClosed(stream) { return ReadableStreamGetState(stream) === STATE_CLOSED; } function IsReadableStreamErrored(stream) { return ReadableStreamGetState(stream) === STATE_ERRORED; } function getReadableStreamEnqueueError(stream, controller) { if (controller[_readableStreamDefaultControllerBits] & CLOSE_REQUESTED) { return new TypeError(errEnqueueCloseRequestedStream); } const state = ReadableStreamGetState(stream); if (state === STATE_ERRORED) { return new TypeError(errEnqueueErroredStream); } return new TypeError(errEnqueueClosedStream); } function CreateIterResultObject(value, done) { return {value, done}; } function getReadableStreamController(stream) { return stream[_controller]; } function getReadableStreamStoredError(stream) { return stream[_storedError]; } 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); }; binding.ReadableStream = ReadableStream; binding.ReadableStreamDefaultControllerCanCloseOrEnqueue = ReadableStreamDefaultControllerCanCloseOrEnqueue; binding.ReadableStreamDefaultControllerHasBackpressure = ReadableStreamDefaultControllerHasBackpressure; binding.getReadableStreamEnqueueError = getReadableStreamEnqueueError; binding.getReadableStreamController = getReadableStreamController; binding.getReadableStreamStoredError = getReadableStreamStoredError; }); 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 _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 defineProperty = global.Object.defineProperty; const Function_call = v8.uncurryThis(global.Function.prototype.call); const TypeError = global.TypeError; const RangeError = global.RangeError; const Boolean = global.Boolean; const Promise = global.Promise; const thenPromise = v8.uncurryThis(Promise.prototype.then); const Promise_resolve = Promise.resolve.bind(Promise); const Promise_reject = Promise.reject.bind(Promise); const { _queue, _queueTotalSize, hasOwnPropertyNoThrow, rejectPromise, resolvePromise, markPromiseAsHandled, promiseState, DequeueValue, EnqueueValueWithSize, PeekQueueValue, ResetQueue, ValidateAndNormalizeQueuingStrategy, CallOrNoop1, PromiseCallOrNoop0, PromiseCallOrNoop1, PromiseCallOrNoop2 } = binding.streamOperations; const streamErrors = binding.streamErrors; const errAbortLockedStream = 'Cannot abort a writable stream that is locked to a writer'; 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 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 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 => 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 hasOwnPropertyNoThrow(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) { rejectPromise(abortRequest.promise, storedError); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); return; } const promise = WritableStreamDefaultControllerAbortSteps( stream[_writableStreamController], abortRequest.reason); thenPromise( promise, () => { resolvePromise(abortRequest.promise, undefined); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }, reason => { rejectPromise(abortRequest.promise, reason); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }); } function WritableStreamFinishInFlightWrite(stream) { resolvePromise(stream[_inFlightWriteRequest], undefined); stream[_inFlightWriteRequest] = undefined; } function WritableStreamFinishInFlightWriteWithError(stream, error) { rejectPromise(stream[_inFlightWriteRequest], error); stream[_inFlightWriteRequest] = undefined; WritableStreamDealWithRejection(stream, error); } function WritableStreamFinishInFlightClose(stream) { resolvePromise(stream[_inFlightCloseRequest], undefined); stream[_inFlightCloseRequest] = undefined; const state = stream[_stateAndFlags] & STATE_MASK; if (state === ERRORING) { stream[_storedError] = undefined; if (stream[_pendingAbortRequest] !== undefined) { resolvePromise(stream[_pendingAbortRequest].promise, undefined); stream[_pendingAbortRequest] = undefined; } } stream[_stateAndFlags] = (stream[_stateAndFlags] & ~STATE_MASK) | CLOSED; const writer = stream[_writer]; if (writer !== undefined) { resolvePromise(writer[_closedPromise], undefined); } } function WritableStreamFinishInFlightCloseWithError(stream, error) { rejectPromise(stream[_inFlightCloseRequest], error); stream[_inFlightCloseRequest] = undefined; if (stream[_pendingAbortRequest] !== undefined) { 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) { rejectPromise(stream[_closeRequest], stream[_storedError]); stream[_closeRequest] = undefined; } const writer = stream[_writer]; if (writer !== undefined) { rejectPromise(writer[_closedPromise], stream[_storedError]); 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 { 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]; } function isWritableStreamWritable(stream) { return (stream[_stateAndFlags] & STATE_MASK) === WRITABLE; } function isWritableStreamErroring(stream) { return (stream[_stateAndFlags] & STATE_MASK) === ERRORING; } function getWritableStreamController(stream) { return stream[_writableStreamController]; } 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]); 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); markPromiseAsHandled(this[_readyPromise]); this[_closedPromise] = Promise_reject(storedError); 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 hasOwnPropertyNoThrow(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) { 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 (promiseState(writer[_closedPromise]) === v8.kPROMISE_PENDING) { rejectPromise(writer[_closedPromise], error); } else { writer[_closedPromise] = Promise_reject(error); } markPromiseAsHandled(writer[_closedPromise]); } function WritableStreamDefaultWriterEnsureReadyPromiseRejected( writer, error) { if (promiseState(writer[_readyPromise]) === v8.kPROMISE_PENDING) { rejectPromise(writer[_readyPromise], error); } else { writer[_readyPromise] = Promise_reject(error); } 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 PromiseCallOrNoop1(controller[_underlyingSink], 'abort', reason, 'underlyingSink.abort'); } function WritableStreamDefaultControllerErrorSteps(controller) { ResetQueue(controller); } function WritableStreamDefaultControllerStartSteps(controller) { const startResult = CallOrNoop1(controller[_underlyingSink], 'start', controller, 'underlyingSink.start'); const stream = controller[_controlledWritableStream]; const startPromise = Promise_resolve(startResult); thenPromise( startPromise, () => { controller[_started] = true; WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); }, r => { controller[_started] = true; WritableStreamDealWithRejection(stream, r); }); } function IsWritableStreamDefaultController(x) { return hasOwnPropertyNoThrow(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 = PromiseCallOrNoop0(controller[_underlyingSink], 'close', 'underlyingSink.close'); thenPromise( sinkClosePromise, () => WritableStreamFinishInFlightClose(stream), reason => WritableStreamFinishInFlightCloseWithError(stream, reason)); } function WritableStreamDefaultControllerProcessWrite(controller, chunk) { const stream = controller[_controlledWritableStream]; WritableStreamMarkFirstWriteRequestInFlight(stream); const sinkWritePromise = PromiseCallOrNoop2( controller[_underlyingSink], 'write', chunk, controller, 'underlyingSink.write'); 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); } 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; binding.WritableStream = WritableStream; binding.WritableStreamDefaultControllerErrorIfNeeded = WritableStreamDefaultControllerErrorIfNeeded; binding.isWritableStreamWritable = isWritableStreamWritable; binding.isWritableStreamErroring = isWritableStreamErroring; binding.getWritableStreamController = getWritableStreamController; });  `${f} is not a function`; class TransformStream { constructor( transformer = {}, writableStrategy = undefined, {size, highWaterMark = 0} = {}) { this[_transformer] = transformer; const readableType = transformer.readableType; if (readableType !== undefined) { throw new RangeError(streamErrors.invalidType); } const writableType = transformer.writableType; if (writableType !== undefined) { throw new RangeError(streamErrors.invalidType); } this[_transformStreamController] = undefined; const controller = new TransformStreamDefaultController(this); this[_transformStreamController] = controller; const startPromise = v8.createPromise(); const source = new TransformStreamDefaultSource(this, startPromise); const readableStrategy = {size, highWaterMark}; this[_readable] = new binding.ReadableStream(source, readableStrategy); const sink = new TransformStreamDefaultSink(this, startPromise); this[_writable] = new binding.WritableStream(sink, writableStrategy); TransformStreamSetBackpressure(this, true); const startResult = CallOrNoop1(transformer, 'start', controller, 'transformer.start'); resolvePromise(startPromise, startResult); } get readable() { if (!IsTransformStream(this)) { throw new TypeError(streamErrors.illegalInvocation); } return this[_readable]; } get writable() { if (!IsTransformStream(this)) { throw new TypeError(streamErrors.illegalInvocation); } return this[_writable]; } } function IsTransformStream(x) { return hasOwnPropertyNoThrow(x, _transformStreamController); } function TransformStreamError(stream, e) { const readable = stream[_readable]; if (binding.IsReadableStreamReadable(readable)) { binding.ReadableStreamDefaultControllerError( binding.getReadableStreamController(readable), e); } TransformStreamErrorWritableAndUnblockWrite(stream, e); } function TransformStreamErrorWritableAndUnblockWrite(stream, e) { binding.WritableStreamDefaultControllerErrorIfNeeded( binding.getWritableStreamController(stream[_writable]), e); if (stream[_backpressure]) { TransformStreamSetBackpressure(stream, false); } } function TransformStreamSetBackpressure(stream, backpressure) { if (stream[_backpressureChangePromise] !== undefined) { resolvePromise(stream[_backpressureChangePromise], undefined); } stream[_backpressureChangePromise] = v8.createPromise(); stream[_backpressure] = backpressure; } class TransformStreamDefaultController { constructor(stream) { if (!IsTransformStream(stream)) { throw new TypeError(streamErrors.illegalConstructor); } if (stream[_transformStreamController] !== undefined) { throw new TypeError(streamErrors.illegalConstructor); } this[_controlledTransformStream] = stream; } get desiredSize() { if (!IsTransformStreamDefaultController(this)) { throw new TypeError(streamErrors.illegalInvocation); } const readableController = binding.getReadableStreamController( this[_controlledTransformStream][_readable]); return binding.ReadableStreamDefaultControllerGetDesiredSize( readableController); } enqueue(chunk) { if (!IsTransformStreamDefaultController(this)) { throw new TypeError(streamErrors.illegalInvocation); } TransformStreamDefaultControllerEnqueue(this, chunk); } error(reason) { if (!IsTransformStreamDefaultController(this)) { throw new TypeError(streamErrors.illegalInvocation); } TransformStreamDefaultControllerError(this, reason); } terminate() { if (!IsTransformStreamDefaultController(this)) { throw new TypeError(streamErrors.illegalInvocation); } TransformStreamDefaultControllerTerminate(this); } } function IsTransformStreamDefaultController(x) { return hasOwnPropertyNoThrow(x, _controlledTransformStream); } function TransformStreamDefaultControllerEnqueue(controller, chunk) { const stream = controller[_controlledTransformStream]; const readableController = binding.getReadableStreamController(stream[_readable]); if (!binding.ReadableStreamDefaultControllerCanCloseOrEnqueue( readableController)) { throw binding.getReadableStreamEnqueueError(stream[_readable]); } try { binding.ReadableStreamDefaultControllerEnqueue(readableController, chunk); } catch (e) { TransformStreamErrorWritableAndUnblockWrite(stream, e); throw binding.getReadableStreamStoredError(stream[_readable]); } const backpressure = binding.ReadableStreamDefaultControllerHasBackpressure( readableController); if (backpressure !== stream[_backpressure]) { TransformStreamSetBackpressure(stream, true); } } function TransformStreamDefaultControllerError(controller, e) { TransformStreamError(controller[_controlledTransformStream], e); } function TransformStreamDefaultControllerTerminate(controller) { const stream = controller[_controlledTransformStream]; const readableController = binding.getReadableStreamController(stream[_readable]); if (binding.ReadableStreamDefaultControllerCanCloseOrEnqueue( readableController)) { binding.ReadableStreamDefaultControllerClose(readableController); } const error = new TypeError(errStreamTerminated); TransformStreamErrorWritableAndUnblockWrite(stream, error); } class TransformStreamDefaultSink { constructor(stream, startPromise) { this[_ownerTransformStream] = stream; this[_startPromise] = startPromise; } start() { const startPromise = this[_startPromise]; this[_startPromise] = undefined; return startPromise; } write(chunk) { const stream = this[_ownerTransformStream]; if (stream[_backpressure]) { const backpressureChangePromise = stream[_backpressureChangePromise]; return thenPromise(backpressureChangePromise, () => { const writable = stream[_writable]; if (binding.isWritableStreamErroring(writable)) { throw binding.getWritableStreamStoredError(writable); } return TransformStreamDefaultSinkTransform(this, chunk); }); } return TransformStreamDefaultSinkTransform(this, chunk); } abort() { const e = new TypeError(errWritableStreamAborted); TransformStreamError(this[_ownerTransformStream], e); } close() { const stream = this[_ownerTransformStream]; const readable = stream[_readable]; const flushPromise = PromiseCallOrNoop1( stream[_transformer], 'flush', stream[_transformStreamController], 'transformer.flush'); return thenPromise( flushPromise, () => { if (binding.IsReadableStreamErrored(readable)) { throw binding.getReadableStreamStoredError(readable); } const readableController = binding.getReadableStreamController(readable); if (binding.ReadableStreamDefaultControllerCanCloseOrEnqueue( readableController)) { binding.ReadableStreamDefaultControllerClose(readableController); } }, r => { TransformStreamError(stream, r); throw binding.getReadableStreamStoredError(readable); }); } } function TransformStreamDefaultSinkInvokeTransform(stream, chunk) { const controller = stream[_transformStreamController]; const transformer = stream[_transformer]; const method = transformer.transform; if (method === undefined) { TransformStreamDefaultControllerEnqueue(controller, chunk); return undefined; } if (typeof method !== 'function') { throw new TypeError(templateErrorIsNotAFunction('transform')); } return Function_call(method, transformer, chunk, controller); } function TransformStreamDefaultSinkTransform(sink, chunk) { const stream = sink[_ownerTransformStream]; let transformPromise; try { transformPromise = Promise_resolve( TransformStreamDefaultSinkInvokeTransform(stream, chunk)); } catch (e) { transformPromise = Promise_reject(e); } return thenPromise(transformPromise, undefined, e => { TransformStreamError(stream, e); throw e; }); } class TransformStreamDefaultSource { constructor(stream, startPromise) { this[_ownerTransformStream] = stream; this[_startPromise] = startPromise; } start() { const startPromise = this[_startPromise]; this[_startPromise] = undefined; return startPromise; } pull() { const stream = this[_ownerTransformStream]; TransformStreamSetBackpressure(stream, false); return stream[_backpressureChangePromise]; } cancel(reason) { TransformStreamErrorWritableAndUnblockWrite( this[_ownerTransformStream], reason); } } defineProperty(global, 'TransformStream', { value: TransformStream, enumerable: false, configurable: true, writable: true }); });