jsb-builtin.js 318 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (global){
  3. "use strict";
  4. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5. /* Blob.js
  6. * A Blob implementation.
  7. * 2017-11-15
  8. *
  9. * By Eli Grey, http://eligrey.com
  10. * By Devin Samarin, https://github.com/dsamarin
  11. * License: MIT
  12. * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md
  13. */
  14. /*global self, unescape */
  15. /*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
  16. plusplus: true */
  17. /*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
  18. (function (global) {
  19. (function (factory) {
  20. if (typeof define === "function" && define.amd) {
  21. // AMD. Register as an anonymous module.
  22. define(["exports"], factory);
  23. } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof exports.nodeName !== "string") {
  24. // CommonJS
  25. factory(exports);
  26. } else {
  27. // Browser globals
  28. factory(global);
  29. }
  30. })(function (exports) {
  31. "use strict";
  32. exports.URL = global.URL || global.webkitURL;
  33. if (global.Blob && global.URL) {
  34. try {
  35. new Blob();
  36. return;
  37. } catch (e) {}
  38. } // Internally we use a BlobBuilder implementation to base Blob off of
  39. // in order to support older browsers that only have BlobBuilder
  40. var BlobBuilder = global.BlobBuilder || global.WebKitBlobBuilder || global.MozBlobBuilder || function () {
  41. var get_class = function get_class(object) {
  42. return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
  43. },
  44. FakeBlobBuilder = function BlobBuilder() {
  45. this.data = [];
  46. },
  47. FakeBlob = function Blob(data, type, encoding) {
  48. this.data = data;
  49. this.size = data.length;
  50. this.type = type;
  51. this.encoding = encoding;
  52. },
  53. FBB_proto = FakeBlobBuilder.prototype,
  54. FB_proto = FakeBlob.prototype,
  55. FileReaderSync = global.FileReaderSync,
  56. FileException = function FileException(type) {
  57. this.code = this[this.name = type];
  58. },
  59. file_ex_codes = ("NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR " + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR").split(" "),
  60. file_ex_code = file_ex_codes.length,
  61. real_URL = global.URL || global.webkitURL || exports,
  62. real_create_object_URL = real_URL.createObjectURL,
  63. real_revoke_object_URL = real_URL.revokeObjectURL,
  64. URL = real_URL,
  65. btoa = global.btoa,
  66. atob = global.atob,
  67. ArrayBuffer = global.ArrayBuffer,
  68. Uint8Array = global.Uint8Array,
  69. origin = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;
  70. FakeBlob.fake = FB_proto.fake = true;
  71. while (file_ex_code--) {
  72. FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
  73. } // Polyfill URL
  74. if (!real_URL.createObjectURL) {
  75. URL = exports.URL = function (uri) {
  76. var uri_info = document.createElementNS("http://www.w3.org/1999/xhtml", "a"),
  77. uri_origin;
  78. uri_info.href = uri;
  79. if (!("origin" in uri_info)) {
  80. if (uri_info.protocol.toLowerCase() === "data:") {
  81. uri_info.origin = null;
  82. } else {
  83. uri_origin = uri.match(origin);
  84. uri_info.origin = uri_origin && uri_origin[1];
  85. }
  86. }
  87. return uri_info;
  88. };
  89. }
  90. URL.createObjectURL = function (blob) {
  91. var type = blob.type,
  92. data_URI_header;
  93. if (type === null) {
  94. type = "application/octet-stream";
  95. }
  96. if (blob instanceof FakeBlob) {
  97. data_URI_header = "data:" + type;
  98. if (blob.encoding === "base64") {
  99. return data_URI_header + ";base64," + blob.data;
  100. } else if (blob.encoding === "URI") {
  101. return data_URI_header + "," + decodeURIComponent(blob.data);
  102. }
  103. if (btoa) {
  104. return data_URI_header + ";base64," + btoa(blob.data);
  105. } else {
  106. return data_URI_header + "," + encodeURIComponent(blob.data);
  107. }
  108. } else if (real_create_object_URL) {
  109. return real_create_object_URL.call(real_URL, blob);
  110. }
  111. };
  112. URL.revokeObjectURL = function (object_URL) {
  113. if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
  114. real_revoke_object_URL.call(real_URL, object_URL);
  115. }
  116. };
  117. FBB_proto.append = function (data
  118. /*, endings*/
  119. ) {
  120. var bb = this.data; // decode data to a binary string
  121. if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
  122. var str = "",
  123. buf = new Uint8Array(data),
  124. i = 0,
  125. buf_len = buf.length;
  126. for (; i < buf_len; i++) {
  127. str += String.fromCharCode(buf[i]);
  128. }
  129. bb.push(str);
  130. } else if (get_class(data) === "Blob" || get_class(data) === "File") {
  131. if (FileReaderSync) {
  132. var fr = new FileReaderSync();
  133. bb.push(fr.readAsBinaryString(data));
  134. } else {
  135. // async FileReader won't work as BlobBuilder is sync
  136. throw new FileException("NOT_READABLE_ERR");
  137. }
  138. } else if (data instanceof FakeBlob) {
  139. if (data.encoding === "base64" && atob) {
  140. bb.push(atob(data.data));
  141. } else if (data.encoding === "URI") {
  142. bb.push(decodeURIComponent(data.data));
  143. } else if (data.encoding === "raw") {
  144. bb.push(data.data);
  145. }
  146. } else {
  147. if (typeof data !== "string") {
  148. data += ""; // convert unsupported types to strings
  149. } // decode UTF-16 to binary string
  150. bb.push(unescape(encodeURIComponent(data)));
  151. }
  152. };
  153. FBB_proto.getBlob = function (type) {
  154. if (!arguments.length) {
  155. type = null;
  156. }
  157. return new FakeBlob(this.data.join(""), type, "raw");
  158. };
  159. FBB_proto.toString = function () {
  160. return "[object BlobBuilder]";
  161. };
  162. FB_proto.slice = function (start, end, type) {
  163. var args = arguments.length;
  164. if (args < 3) {
  165. type = null;
  166. }
  167. return new FakeBlob(this.data.slice(start, args > 1 ? end : this.data.length), type, this.encoding);
  168. };
  169. FB_proto.toString = function () {
  170. return "[object Blob]";
  171. };
  172. FB_proto.close = function () {
  173. this.size = 0;
  174. delete this.data;
  175. };
  176. return FakeBlobBuilder;
  177. }();
  178. exports.Blob = function (blobParts, options) {
  179. var type = options ? options.type || "" : "";
  180. var builder = new BlobBuilder();
  181. if (blobParts) {
  182. for (var i = 0, len = blobParts.length; i < len; i++) {
  183. if (Uint8Array && blobParts[i] instanceof Uint8Array) {
  184. builder.append(blobParts[i].buffer);
  185. } else {
  186. builder.append(blobParts[i]);
  187. }
  188. }
  189. }
  190. var blob = builder.getBlob(type);
  191. if (!blob.slice && blob.webkitSlice) {
  192. blob.slice = blob.webkitSlice;
  193. }
  194. return blob;
  195. };
  196. var getPrototypeOf = Object.getPrototypeOf || function (object) {
  197. return object.__proto__;
  198. };
  199. exports.Blob.prototype = getPrototypeOf(new exports.Blob());
  200. });
  201. })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || typeof global !== "undefined" && global || (void 0).content || void 0);
  202. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  203. },{}],2:[function(require,module,exports){
  204. "use strict";
  205. !function () {
  206. function e(e) {
  207. this.message = e;
  208. }
  209. var t = "undefined" != typeof exports ? exports : "undefined" != typeof self ? self : $.global,
  210. r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  211. e.prototype = new Error(), e.prototype.name = "InvalidCharacterError", t.btoa || (t.btoa = function (t) {
  212. for (var o, n, a = String(t), i = 0, f = r, c = ""; a.charAt(0 | i) || (f = "=", i % 1); c += f.charAt(63 & o >> 8 - i % 1 * 8)) {
  213. if (n = a.charCodeAt(i += .75), n > 255) throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
  214. o = o << 8 | n;
  215. }
  216. return c;
  217. }), t.atob || (t.atob = function (t) {
  218. var o = String(t).replace(/[=]+$/, "");
  219. if (o.length % 4 == 1) throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
  220. for (var n, a, i = 0, f = 0, c = ""; a = o.charAt(f++); ~a && (n = i % 4 ? 64 * n + a : a, i++ % 4) ? c += String.fromCharCode(255 & n >> (-2 * i & 6)) : 0) {
  221. a = r.indexOf(a);
  222. }
  223. return c;
  224. });
  225. }();
  226. },{}],3:[function(require,module,exports){
  227. "use strict";
  228. var GL_COMMAND_ACTIVE_TEXTURE = 0;
  229. var GL_COMMAND_ATTACH_SHADER = 1;
  230. var GL_COMMAND_BIND_ATTRIB_LOCATION = 2;
  231. var GL_COMMAND_BIND_BUFFER = 3;
  232. var GL_COMMAND_BIND_FRAME_BUFFER = 4;
  233. var GL_COMMAND_BIND_RENDER_BUFFER = 5;
  234. var GL_COMMAND_BIND_TEXTURE = 6;
  235. var GL_COMMAND_BLEND_COLOR = 7;
  236. var GL_COMMAND_BLEND_EQUATION = 8;
  237. var GL_COMMAND_BLEND_EQUATION_SEPARATE = 9;
  238. var GL_COMMAND_BLEND_FUNC = 10;
  239. var GL_COMMAND_BLEND_FUNC_SEPARATE = 11;
  240. var GL_COMMAND_BUFFER_DATA = 12;
  241. var GL_COMMAND_BUFFER_SUB_DATA = 13;
  242. var GL_COMMAND_CLEAR = 14;
  243. var GL_COMMAND_CLEAR_COLOR = 15;
  244. var GL_COMMAND_CLEAR_DEPTH = 16;
  245. var GL_COMMAND_CLEAR_STENCIL = 17;
  246. var GL_COMMAND_COLOR_MASK = 18;
  247. var GL_COMMAND_COMMIT = 19;
  248. var GL_COMMAND_COMPILE_SHADER = 20;
  249. var GL_COMMAND_COMPRESSED_TEX_IMAGE_2D = 21;
  250. var GL_COMMAND_COMPRESSED_TEX_SUB_IMAGE_2D = 22;
  251. var GL_COMMAND_COPY_TEX_IMAGE_2D = 23;
  252. var GL_COMMAND_COPY_TEX_SUB_IMAGE_2D = 24;
  253. var GL_COMMAND_CULL_FACE = 25;
  254. var GL_COMMAND_DELETE_BUFFER = 26;
  255. var GL_COMMAND_DELETE_FRAME_BUFFER = 27;
  256. var GL_COMMAND_DELETE_PROGRAM = 28;
  257. var GL_COMMAND_DELETE_RENDER_BUFFER = 29;
  258. var GL_COMMAND_DELETE_SHADER = 30;
  259. var GL_COMMAND_DELETE_TEXTURE = 31;
  260. var GL_COMMAND_DEPTH_FUNC = 32;
  261. var GL_COMMAND_DEPTH_MASK = 33;
  262. var GL_COMMAND_DEPTH_RANGE = 34;
  263. var GL_COMMAND_DETACH_SHADER = 35;
  264. var GL_COMMAND_DISABLE = 36;
  265. var GL_COMMAND_DISABLE_VERTEX_ATTRIB_ARRAY = 37;
  266. var GL_COMMAND_DRAW_ARRAYS = 38;
  267. var GL_COMMAND_DRAW_ELEMENTS = 39;
  268. var GL_COMMAND_ENABLE = 40;
  269. var GL_COMMAND_ENABLE_VERTEX_ATTRIB_ARRAY = 41;
  270. var GL_COMMAND_FINISH = 42;
  271. var GL_COMMAND_FLUSH = 43;
  272. var GL_COMMAND_FRAME_BUFFER_RENDER_BUFFER = 44;
  273. var GL_COMMAND_FRAME_BUFFER_TEXTURE_2D = 45;
  274. var GL_COMMAND_FRONT_FACE = 46;
  275. var GL_COMMAND_GENERATE_MIPMAP = 47;
  276. var GL_COMMAND_HINT = 48;
  277. var GL_COMMAND_LINE_WIDTH = 49;
  278. var GL_COMMAND_LINK_PROGRAM = 50;
  279. var GL_COMMAND_PIXEL_STOREI = 51;
  280. var GL_COMMAND_POLYGON_OFFSET = 52;
  281. var GL_COMMAND_RENDER_BUFFER_STORAGE = 53;
  282. var GL_COMMAND_SAMPLE_COVERAGE = 54;
  283. var GL_COMMAND_SCISSOR = 55;
  284. var GL_COMMAND_SHADER_SOURCE = 56;
  285. var GL_COMMAND_STENCIL_FUNC = 57;
  286. var GL_COMMAND_STENCIL_FUNC_SEPARATE = 58;
  287. var GL_COMMAND_STENCIL_MASK = 59;
  288. var GL_COMMAND_STENCIL_MASK_SEPARATE = 60;
  289. var GL_COMMAND_STENCIL_OP = 61;
  290. var GL_COMMAND_STENCIL_OP_SEPARATE = 62;
  291. var GL_COMMAND_TEX_IMAGE_2D = 63;
  292. var GL_COMMAND_TEX_PARAMETER_F = 64;
  293. var GL_COMMAND_TEX_PARAMETER_I = 65;
  294. var GL_COMMAND_TEX_SUB_IMAGE_2D = 66;
  295. var GL_COMMAND_UNIFORM_1F = 67;
  296. var GL_COMMAND_UNIFORM_1FV = 68;
  297. var GL_COMMAND_UNIFORM_1I = 69;
  298. var GL_COMMAND_UNIFORM_1IV = 70;
  299. var GL_COMMAND_UNIFORM_2F = 71;
  300. var GL_COMMAND_UNIFORM_2FV = 72;
  301. var GL_COMMAND_UNIFORM_2I = 73;
  302. var GL_COMMAND_UNIFORM_2IV = 74;
  303. var GL_COMMAND_UNIFORM_3F = 75;
  304. var GL_COMMAND_UNIFORM_3FV = 76;
  305. var GL_COMMAND_UNIFORM_3I = 77;
  306. var GL_COMMAND_UNIFORM_3IV = 78;
  307. var GL_COMMAND_UNIFORM_4F = 79;
  308. var GL_COMMAND_UNIFORM_4FV = 80;
  309. var GL_COMMAND_UNIFORM_4I = 81;
  310. var GL_COMMAND_UNIFORM_4IV = 82;
  311. var GL_COMMAND_UNIFORM_MATRIX_2FV = 83;
  312. var GL_COMMAND_UNIFORM_MATRIX_3FV = 84;
  313. var GL_COMMAND_UNIFORM_MATRIX_4FV = 85;
  314. var GL_COMMAND_USE_PROGRAM = 86;
  315. var GL_COMMAND_VALIDATE_PROGRAM = 87;
  316. var GL_COMMAND_VERTEX_ATTRIB_1F = 88;
  317. var GL_COMMAND_VERTEX_ATTRIB_2F = 89;
  318. var GL_COMMAND_VERTEX_ATTRIB_3F = 90;
  319. var GL_COMMAND_VERTEX_ATTRIB_4F = 91;
  320. var GL_COMMAND_VERTEX_ATTRIB_1FV = 92;
  321. var GL_COMMAND_VERTEX_ATTRIB_2FV = 93;
  322. var GL_COMMAND_VERTEX_ATTRIB_3FV = 94;
  323. var GL_COMMAND_VERTEX_ATTRIB_4FV = 95;
  324. var GL_COMMAND_VERTEX_ATTRIB_POINTER = 96;
  325. var GL_COMMAND_VIEW_PORT = 97;
  326. var gl = __gl; // _gl save the orignal gl functions.
  327. var _gl = {};
  328. for (var k in gl) {
  329. _gl[k] = gl[k];
  330. }
  331. var total_size = 100000;
  332. var next_index = 0;
  333. var buffer_data;
  334. var commandCount = 0; // Batch GL commands is enabled by default.
  335. function batchGLCommandsToNative() {
  336. if (gl._flushCommands) {
  337. if (isSupportTypeArray()) {
  338. console.log('Enable batch GL commands optimization!');
  339. attachMethodOpt();
  340. buffer_data = new Float32Array(total_size);
  341. } else {
  342. console.log("Disable batch GL commands, TypedArray Native API isn't supported!");
  343. }
  344. } else {
  345. console.log("Disable batch GL commands, _flushCommands isn't binded!");
  346. }
  347. }
  348. function disableBatchGLCommandsToNative() {
  349. // Reset __gl variable to the default one.
  350. flushCommands();
  351. for (var k in _gl) {
  352. __gl[k] = _gl[k];
  353. }
  354. console.log('Disable batch GL commands optimization!');
  355. jsb.disableBatchGLCommandsToNative();
  356. }
  357. function flushCommands() {
  358. if (next_index > 0) {
  359. gl._flushCommands(next_index, buffer_data, commandCount);
  360. next_index = 0;
  361. commandCount = 0;
  362. }
  363. }
  364. function activeTextureOpt(texture) {
  365. // console.log('GLOpt: activeTexture');
  366. if (next_index + 2 > total_size) {
  367. flushCommands();
  368. }
  369. buffer_data[next_index] = GL_COMMAND_ACTIVE_TEXTURE;
  370. buffer_data[next_index + 1] = texture;
  371. next_index += 2;
  372. ++commandCount;
  373. }
  374. function attachShaderOpt(program, shader) {
  375. // console.log('GLOpt: attachShader');
  376. if (next_index + 3 > total_size) {
  377. flushCommands();
  378. }
  379. buffer_data[next_index] = GL_COMMAND_ATTACH_SHADER;
  380. buffer_data[next_index + 1] = program ? program._id : 0;
  381. buffer_data[next_index + 2] = shader ? shader._id : 0;
  382. next_index += 3;
  383. ++commandCount;
  384. }
  385. function bindAttribLocationOpt(program, index, name) {
  386. // console.log('GLOpt: bindAttribLocation');
  387. flushCommands();
  388. _gl.bindAttribLocation(program, index, name);
  389. }
  390. function bindBufferOpt(target, buffer) {
  391. // console.log('GLOpt: bindBuffer: ' + (buffer? buffer._id : null));
  392. if (next_index + 3 > total_size) {
  393. flushCommands();
  394. }
  395. buffer_data[next_index] = GL_COMMAND_BIND_BUFFER;
  396. buffer_data[next_index + 1] = target;
  397. buffer_data[next_index + 2] = buffer ? buffer._id : 0;
  398. next_index += 3;
  399. ++commandCount;
  400. }
  401. function bindFramebufferOpt(target, framebuffer) {
  402. // console.log('GLOpt: bindFramebuffer');
  403. if (next_index + 3 > total_size) {
  404. flushCommands();
  405. }
  406. buffer_data[next_index] = GL_COMMAND_BIND_FRAME_BUFFER;
  407. buffer_data[next_index + 1] = target;
  408. buffer_data[next_index + 2] = framebuffer ? framebuffer._id : 0;
  409. next_index += 3;
  410. ++commandCount;
  411. }
  412. function bindRenderbufferOpt(target, renderbuffer) {
  413. // console.log('GLOpt: bindRenderbuffer');
  414. if (next_index + 3 > total_size) {
  415. flushCommands();
  416. }
  417. buffer_data[next_index] = GL_COMMAND_BIND_RENDER_BUFFER;
  418. buffer_data[next_index + 1] = target;
  419. buffer_data[next_index + 2] = renderbuffer ? renderbuffer._id : 0;
  420. next_index += 3;
  421. ++commandCount;
  422. }
  423. function bindTextureOpt(target, texture) {
  424. // console.log('GLOpt: bindTexture');
  425. if (next_index + 3 > total_size) {
  426. flushCommands();
  427. }
  428. buffer_data[next_index] = GL_COMMAND_BIND_TEXTURE;
  429. buffer_data[next_index + 1] = target;
  430. buffer_data[next_index + 2] = texture ? texture._id : 0;
  431. next_index += 3;
  432. ++commandCount;
  433. }
  434. function blendColorOpt(red, green, blue, alpha) {
  435. // console.log('GLOpt: blendColor');
  436. if (next_index + 5 > total_size) {
  437. flushCommands();
  438. }
  439. buffer_data[next_index] = GL_COMMAND_BLEND_COLOR;
  440. buffer_data[next_index + 1] = red;
  441. buffer_data[next_index + 2] = green;
  442. buffer_data[next_index + 3] = blue;
  443. buffer_data[next_index + 4] = alpha;
  444. next_index += 5;
  445. ++commandCount;
  446. }
  447. function blendEquationOpt(mode) {
  448. // console.log('GLOpt: blendEquation');
  449. if (next_index + 2 > total_size) {
  450. flushCommands();
  451. }
  452. buffer_data[next_index] = GL_COMMAND_BLEND_EQUATION;
  453. buffer_data[next_index + 1] = mode;
  454. next_index += 2;
  455. ++commandCount;
  456. }
  457. function blendEquationSeparateOpt(modeRGB, modeAlpha) {
  458. // console.log('GLOpt: blendEquationSeparate');
  459. if (next_index + 3 > total_size) {
  460. flushCommands();
  461. }
  462. buffer_data[next_index] = GL_COMMAND_BLEND_EQUATION_SEPARATE;
  463. buffer_data[next_index + 1] = modeRGB;
  464. buffer_data[next_index + 2] = modeAlpha;
  465. next_index += 3;
  466. ++commandCount;
  467. }
  468. function blendFuncOpt(sfactor, dfactor) {
  469. // console.log('GLOpt: blendFunc');
  470. if (next_index + 3 > total_size) {
  471. flushCommands();
  472. }
  473. buffer_data[next_index] = GL_COMMAND_BLEND_FUNC;
  474. buffer_data[next_index + 1] = sfactor;
  475. buffer_data[next_index + 2] = dfactor;
  476. next_index += 3;
  477. ++commandCount;
  478. }
  479. function blendFuncSeparateOpt(srcRGB, dstRGB, srcAlpha, dstAlpha) {
  480. // console.log('GLOpt: blendFuncSeparate');
  481. if (next_index + 5 > total_size) {
  482. flushCommands();
  483. }
  484. buffer_data[next_index] = GL_COMMAND_BLEND_FUNC_SEPARATE;
  485. buffer_data[next_index + 1] = srcRGB;
  486. buffer_data[next_index + 2] = dstRGB;
  487. buffer_data[next_index + 3] = srcAlpha;
  488. buffer_data[next_index + 4] = dstAlpha;
  489. next_index += 5;
  490. ++commandCount;
  491. }
  492. function bufferDataOpt(target, data, usage) {
  493. flushCommands(); // console.log('GLOpt: bufferData');
  494. _gl.bufferData(target, data, usage);
  495. }
  496. function bufferSubDataOpt(target, offset, data) {
  497. flushCommands(); // console.log('GLOpt: bufferSubData');
  498. _gl.bufferSubData(target, offset, data);
  499. }
  500. function checkFramebufferStatusOpt(target) {
  501. flushCommands(); // console.log('GLOpt: checkFramebufferStatus');
  502. return _gl.checkFramebufferStatus(target);
  503. }
  504. function clearOpt(mask) {
  505. // console.log('GLOpt: clear');
  506. if (next_index + 2 > total_size) {
  507. flushCommands();
  508. }
  509. buffer_data[next_index] = GL_COMMAND_CLEAR;
  510. buffer_data[next_index + 1] = mask;
  511. next_index += 2;
  512. ++commandCount;
  513. }
  514. function clearColorOpt(red, green, blue, alpha) {
  515. // console.log('GLOpt: clearColor');
  516. if (next_index + 5 > total_size) {
  517. flushCommands();
  518. }
  519. buffer_data[next_index] = GL_COMMAND_CLEAR_COLOR;
  520. buffer_data[next_index + 1] = red;
  521. buffer_data[next_index + 2] = green;
  522. buffer_data[next_index + 3] = blue;
  523. buffer_data[next_index + 4] = alpha;
  524. next_index += 5;
  525. ++commandCount;
  526. }
  527. function clearDepthOpt(depth) {
  528. // console.log('GLOpt: clearDepth');
  529. if (next_index + 2 > total_size) {
  530. flushCommands();
  531. }
  532. buffer_data[next_index] = GL_COMMAND_CLEAR_DEPTH;
  533. buffer_data[next_index + 1] = depth;
  534. next_index += 2;
  535. ++commandCount;
  536. }
  537. function clearStencilOpt(s) {
  538. // console.log('GLOpt: clearStencil');
  539. if (next_index + 2 > total_size) {
  540. flushCommands();
  541. }
  542. buffer_data[next_index] = GL_COMMAND_CLEAR_STENCIL;
  543. buffer_data[next_index + 1] = s;
  544. next_index += 2;
  545. ++commandCount;
  546. }
  547. function colorMaskOpt(red, green, blue, alpha) {
  548. // console.log('GLOpt: colorMask');
  549. if (next_index + 5 > total_size) {
  550. flushCommands();
  551. }
  552. buffer_data[next_index] = GL_COMMAND_COLOR_MASK;
  553. buffer_data[next_index + 1] = red ? 1 : 0;
  554. buffer_data[next_index + 2] = green ? 1 : 0;
  555. buffer_data[next_index + 3] = blue ? 1 : 0;
  556. buffer_data[next_index + 4] = alpha ? 1 : 0;
  557. next_index += 5;
  558. ++commandCount;
  559. }
  560. function compileShaderOpt(shader) {
  561. // console.log('GLOpt: compileShader');
  562. if (next_index + 2 > total_size) {
  563. flushCommands();
  564. }
  565. buffer_data[next_index] = GL_COMMAND_COMPILE_SHADER;
  566. buffer_data[next_index + 1] = shader ? shader._id : 0;
  567. next_index += 2;
  568. ++commandCount;
  569. }
  570. function compressedTexImage2DOpt(target, level, internalformat, width, height, border, data) {
  571. // console.log('GLOpt: compressedTexImage2D');
  572. flushCommands();
  573. _gl.compressedTexImage2D(target, level, internalformat, width, height, border, data);
  574. }
  575. function compressedTexSubImage2DOpt(target, level, xoffset, yoffset, width, height, format, data) {
  576. // console.log('GLOpt: compressedTexSubImage2D');
  577. flushCommands();
  578. _gl.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, data);
  579. }
  580. function copyTexImage2DOpt(target, level, internalformat, x, y, width, height, border) {
  581. // console.log('GLOpt: copyTexImage2D');
  582. if (next_index + 9 > total_size) {
  583. flushCommands();
  584. }
  585. buffer_data[next_index] = GL_COMMAND_COPY_TEX_IMAGE_2D;
  586. buffer_data[next_index + 1] = target;
  587. buffer_data[next_index + 2] = level;
  588. buffer_data[next_index + 3] = internalformat;
  589. buffer_data[next_index + 4] = x;
  590. buffer_data[next_index + 5] = y;
  591. buffer_data[next_index + 6] = width;
  592. buffer_data[next_index + 7] = height;
  593. buffer_data[next_index + 8] = border;
  594. next_index += 9;
  595. ++commandCount;
  596. }
  597. function copyTexSubImage2DOpt(target, level, xoffset, yoffset, x, y, width, height) {
  598. // console.log('GLOpt: copyTexSubImage2D');
  599. if (next_index + 9 > total_size) {
  600. flushCommands();
  601. }
  602. buffer_data[next_index] = GL_COMMAND_COPY_TEX_SUB_IMAGE_2D;
  603. buffer_data[next_index + 1] = target;
  604. buffer_data[next_index + 2] = level;
  605. buffer_data[next_index + 3] = xoffset;
  606. buffer_data[next_index + 4] = yoffset;
  607. buffer_data[next_index + 5] = x;
  608. buffer_data[next_index + 6] = y;
  609. buffer_data[next_index + 7] = width;
  610. buffer_data[next_index + 8] = height;
  611. next_index += 9;
  612. ++commandCount;
  613. }
  614. function createBufferOpt() {
  615. flushCommands();
  616. var ret = _gl.createBuffer(); // console.log('GLOpt: createBuffer: ' + ret._id);
  617. return ret;
  618. }
  619. function createFramebufferOpt() {
  620. flushCommands(); // console.log('GLOpt: createFramebuffer');
  621. return _gl.createFramebuffer();
  622. }
  623. function createProgramOpt() {
  624. flushCommands(); // console.log('GLOpt: createProgram');
  625. return _gl.createProgram();
  626. }
  627. function createRenderbufferOpt() {
  628. flushCommands(); // console.log('GLOpt: createRenderbuffer');
  629. return _gl.createRenderbuffer();
  630. }
  631. function createShaderOpt(type) {
  632. // console.log('GLOpt: createShader');
  633. flushCommands();
  634. return _gl.createShader(type);
  635. }
  636. function createTextureOpt() {
  637. flushCommands(); // console.log('GLOpt: createTexture');
  638. return _gl.createTexture();
  639. }
  640. function cullFaceOpt(mode) {
  641. // console.log('GLOpt: cullFace');
  642. if (next_index + 2 >= total_size) {
  643. flushCommands();
  644. }
  645. buffer_data[next_index] = GL_COMMAND_CULL_FACE;
  646. buffer_data[next_index + 1] = mode;
  647. next_index += 2;
  648. ++commandCount;
  649. }
  650. function deleteBufferOpt(buffer) {
  651. // console.log('GLOpt: deleteBuffer');
  652. if (next_index + 2 >= total_size) {
  653. flushCommands();
  654. }
  655. buffer_data[next_index] = GL_COMMAND_DELETE_BUFFER;
  656. buffer_data[next_index + 1] = buffer ? buffer._id : 0;
  657. next_index += 2;
  658. ++commandCount;
  659. }
  660. function deleteFramebufferOpt(framebuffer) {
  661. // console.log('GLOpt: deleteFramebuffer');
  662. if (next_index + 2 >= total_size) {
  663. flushCommands();
  664. }
  665. buffer_data[next_index] = GL_COMMAND_DELETE_FRAME_BUFFER;
  666. buffer_data[next_index + 1] = framebuffer ? framebuffer._id : 0;
  667. next_index += 2;
  668. ++commandCount;
  669. }
  670. function deleteProgramOpt(program) {
  671. // console.log('GLOpt: deleteProgram');
  672. if (next_index + 2 >= total_size) {
  673. flushCommands();
  674. }
  675. buffer_data[next_index] = GL_COMMAND_DELETE_PROGRAM;
  676. buffer_data[next_index + 1] = program ? program._id : 0;
  677. next_index += 2;
  678. ++commandCount;
  679. }
  680. function deleteRenderbufferOpt(renderbuffer) {
  681. // console.log('GLOpt: deleteRenderbuffer');
  682. if (next_index + 2 >= total_size) {
  683. flushCommands();
  684. }
  685. buffer_data[next_index] = GL_COMMAND_DELETE_RENDER_BUFFER;
  686. buffer_data[next_index + 1] = renderbuffer ? renderbuffer._id : 0;
  687. next_index += 2;
  688. ++commandCount;
  689. }
  690. function deleteShaderOpt(shader) {
  691. // console.log('GLOpt: deleteShader');
  692. if (next_index + 2 >= total_size) {
  693. flushCommands();
  694. }
  695. buffer_data[next_index] = GL_COMMAND_DELETE_SHADER;
  696. buffer_data[next_index + 1] = shader ? shader._id : 0;
  697. next_index += 2;
  698. ++commandCount;
  699. }
  700. function deleteTextureOpt(texture) {
  701. // console.log('GLOpt: deleteTexture');
  702. if (next_index + 2 >= total_size) {
  703. flushCommands();
  704. }
  705. buffer_data[next_index] = GL_COMMAND_DELETE_TEXTURE;
  706. buffer_data[next_index + 1] = texture ? texture._id : 0;
  707. next_index += 2;
  708. ++commandCount;
  709. }
  710. function depthFuncOpt(func) {
  711. // console.log('GLOpt: depthFunc');
  712. if (next_index + 2 >= total_size) {
  713. flushCommands();
  714. }
  715. buffer_data[next_index] = GL_COMMAND_DEPTH_FUNC;
  716. buffer_data[next_index + 1] = func;
  717. next_index += 2;
  718. ++commandCount;
  719. }
  720. function depthMaskOpt(flag) {
  721. // console.log('GLOpt: depthMask');
  722. if (next_index + 2 >= total_size) {
  723. flushCommands();
  724. }
  725. buffer_data[next_index] = GL_COMMAND_DEPTH_MASK;
  726. buffer_data[next_index + 1] = flag ? 1 : 0;
  727. next_index += 2;
  728. ++commandCount;
  729. }
  730. function depthRangeOpt(zNear, zFar) {
  731. // console.log('GLOpt: depthRange');
  732. if (next_index + 3 >= total_size) {
  733. flushCommands();
  734. }
  735. buffer_data[next_index] = GL_COMMAND_DEPTH_RANGE;
  736. buffer_data[next_index + 1] = zNear;
  737. buffer_data[next_index + 2] = zFar;
  738. next_index += 3;
  739. ++commandCount;
  740. }
  741. function detachShaderOpt(program, shader) {
  742. // console.log('GLOpt: detachShader');
  743. if (next_index + 3 >= total_size) {
  744. flushCommands();
  745. }
  746. buffer_data[next_index] = GL_COMMAND_DETACH_SHADER;
  747. buffer_data[next_index + 1] = program ? program._id : 0;
  748. buffer_data[next_index + 2] = shader ? shader._id : 0;
  749. next_index += 3;
  750. ++commandCount;
  751. }
  752. function disableOpt(cap) {
  753. // console.log('GLOpt: disable');
  754. if (next_index + 2 >= total_size) {
  755. flushCommands();
  756. }
  757. buffer_data[next_index] = GL_COMMAND_DISABLE;
  758. buffer_data[next_index + 1] = cap;
  759. next_index += 2;
  760. ++commandCount;
  761. }
  762. function disableVertexAttribArrayOpt(index) {
  763. // console.log('GLOpt: disableVertexAttribArray');
  764. if (next_index + 2 >= total_size) {
  765. flushCommands();
  766. }
  767. buffer_data[next_index] = GL_COMMAND_DISABLE_VERTEX_ATTRIB_ARRAY;
  768. buffer_data[next_index + 1] = index;
  769. next_index += 2;
  770. ++commandCount;
  771. }
  772. function drawArraysOpt(mode, first, count) {
  773. // console.log('GLOpt: drawArrays');
  774. if (next_index + 4 >= total_size) {
  775. flushCommands();
  776. }
  777. buffer_data[next_index] = GL_COMMAND_DRAW_ARRAYS;
  778. buffer_data[next_index + 1] = mode;
  779. buffer_data[next_index + 2] = first;
  780. buffer_data[next_index + 3] = count;
  781. next_index += 4;
  782. ++commandCount;
  783. }
  784. function drawElementsOpt(mode, count, type, offset) {
  785. // console.log('GLOpt: drawElements');
  786. if (next_index + 5 >= total_size) {
  787. flushCommands();
  788. }
  789. buffer_data[next_index] = GL_COMMAND_DRAW_ELEMENTS;
  790. buffer_data[next_index + 1] = mode;
  791. buffer_data[next_index + 2] = count;
  792. buffer_data[next_index + 3] = type;
  793. buffer_data[next_index + 4] = offset ? offset : 0;
  794. next_index += 5;
  795. ++commandCount;
  796. }
  797. function enableOpt(cap) {
  798. // console.log('GLOpt: enable');
  799. if (next_index + 2 >= total_size) {
  800. flushCommands();
  801. }
  802. buffer_data[next_index] = GL_COMMAND_ENABLE;
  803. buffer_data[next_index + 1] = cap;
  804. next_index += 2;
  805. ++commandCount;
  806. }
  807. function enableVertexAttribArrayOpt(index) {
  808. // console.log('GLOpt: enableVertexAttribArray');
  809. if (next_index + 2 >= total_size) {
  810. flushCommands();
  811. }
  812. buffer_data[next_index] = GL_COMMAND_ENABLE_VERTEX_ATTRIB_ARRAY;
  813. buffer_data[next_index + 1] = index;
  814. next_index += 2;
  815. ++commandCount;
  816. }
  817. function finishOpt() {
  818. // console.log('GLOpt: finish');
  819. if (next_index + 1 >= total_size) {
  820. flushCommands();
  821. }
  822. buffer_data[next_index] = GL_COMMAND_FINISH;
  823. next_index += 1;
  824. ++commandCount;
  825. }
  826. function flushOpt() {
  827. // console.log('GLOpt: flush');
  828. if (next_index + 1 >= total_size) {
  829. flushCommands();
  830. }
  831. buffer_data[next_index] = GL_COMMAND_FLUSH;
  832. next_index += 1;
  833. ++commandCount;
  834. }
  835. function framebufferRenderbufferOpt(target, attachment, renderbuffertarget, renderbuffer) {
  836. // console.log('GLOpt: framebufferRenderbuffer');
  837. if (next_index + 5 >= total_size) {
  838. flushCommands();
  839. }
  840. buffer_data[next_index] = GL_COMMAND_FRAME_BUFFER_RENDER_BUFFER;
  841. buffer_data[next_index + 1] = target;
  842. buffer_data[next_index + 2] = attachment;
  843. buffer_data[next_index + 3] = renderbuffertarget;
  844. buffer_data[next_index + 4] = renderbuffer ? renderbuffer._id : 0;
  845. next_index += 5;
  846. ++commandCount;
  847. }
  848. function framebufferTexture2DOpt(target, attachment, textarget, texture, level) {
  849. // console.log('GLOpt: framebufferTexture2D');
  850. if (next_index + 6 >= total_size) {
  851. flushCommands();
  852. }
  853. buffer_data[next_index] = GL_COMMAND_FRAME_BUFFER_TEXTURE_2D;
  854. buffer_data[next_index + 1] = target;
  855. buffer_data[next_index + 2] = attachment;
  856. buffer_data[next_index + 3] = textarget;
  857. buffer_data[next_index + 4] = texture ? texture._id : 0;
  858. buffer_data[next_index + 5] = level;
  859. next_index += 6;
  860. ++commandCount;
  861. }
  862. function frontFaceOpt(mode) {
  863. // console.log('GLOpt: frontFace');
  864. if (next_index + 2 >= total_size) {
  865. flushCommands();
  866. }
  867. buffer_data[next_index] = GL_COMMAND_FRONT_FACE;
  868. buffer_data[next_index + 1] = mode;
  869. next_index += 2;
  870. ++commandCount;
  871. }
  872. function generateMipmapOpt(target) {
  873. // console.log('GLOpt: generateMipmap');
  874. if (next_index + 2 >= total_size) {
  875. flushCommands();
  876. }
  877. buffer_data[next_index] = GL_COMMAND_GENERATE_MIPMAP;
  878. buffer_data[next_index + 1] = target;
  879. next_index += 2;
  880. ++commandCount;
  881. }
  882. function getActiveAttribOpt(program, index) {
  883. // console.log('GLOpt: getActiveAttrib');
  884. flushCommands();
  885. return _gl.getActiveAttrib(program, index);
  886. }
  887. function getActiveUniformOpt(program, index) {
  888. // console.log('GLOpt: getActiveUniform');
  889. flushCommands();
  890. return _gl.getActiveUniform(program, index);
  891. }
  892. function getAttachedShadersOpt(program) {
  893. // console.log('GLOpt: getAttachedShaders');
  894. flushCommands();
  895. return _gl.getAttachedShaders(program);
  896. }
  897. function getAttribLocationOpt(program, name) {
  898. // console.log('GLOpt: getAttribLocation');
  899. flushCommands();
  900. return _gl.getAttribLocation(program, name);
  901. }
  902. function getBufferParameterOpt(target, pname) {
  903. // console.log('GLOpt: getBufferParameter');
  904. flushCommands();
  905. return _gl.getBufferParameter(target, pname);
  906. }
  907. function getParameterOpt(pname) {
  908. // console.log('GLOpt: getParameter');
  909. flushCommands();
  910. return _gl.getParameter(pname);
  911. }
  912. function getErrorOpt() {
  913. // console.log('GLOpt: getError');
  914. flushCommands();
  915. return _gl.getError();
  916. }
  917. function getFramebufferAttachmentParameterOpt(target, attachment, pname) {
  918. // console.log('GLOpt: getFramebufferAttachmentParameter');
  919. flushCommands();
  920. return _gl.getFramebufferAttachmentParameter(target, attachment, pname);
  921. }
  922. function getProgramParameterOpt(program, pname) {
  923. // console.log('GLOpt: getProgramParameter');
  924. flushCommands();
  925. return _gl.getProgramParameter(program, pname);
  926. }
  927. function getProgramInfoLogOpt(program) {
  928. // console.log('GLOpt: getProgramInfoLog');
  929. flushCommands();
  930. return _gl.getProgramInfoLog(program);
  931. }
  932. function getRenderbufferParameterOpt(target, pname) {
  933. // console.log('GLOpt: getRenderbufferParameter');
  934. flushCommands();
  935. return _gl.getRenderbufferParameter(target, pname);
  936. }
  937. function getShaderParameterOpt(shader, pname) {
  938. // console.log('GLOpt: getShaderParameter');
  939. flushCommands();
  940. return _gl.getShaderParameter(shader, pname);
  941. }
  942. function getShaderPrecisionFormatOpt(shadertype, precisiontype) {
  943. // console.log('GLOpt: getShaderPrecisionFormat');
  944. flushCommands();
  945. return _gl.getShaderPrecisionFormat(shadertype, precisiontype);
  946. }
  947. function getShaderInfoLogOpt(shader) {
  948. // console.log('GLOpt: getShaderInfoLog');
  949. flushCommands();
  950. return _gl.getShaderInfoLog(shader);
  951. }
  952. function getShaderSourceOpt(shader) {
  953. // console.log('GLOpt: getShaderSource');
  954. flushCommands();
  955. return _gl.getShaderSource(shader);
  956. }
  957. function getTexParameterOpt(target, pname) {
  958. // console.log('GLOpt: getTexParameter');
  959. flushCommands();
  960. return _gl.getTexParameter(target, pname);
  961. }
  962. function getUniformOpt(program, location) {
  963. // console.log('GLOpt: getUniform');
  964. flushCommands();
  965. return _gl.getUniform(program, location);
  966. }
  967. function getUniformLocationOpt(program, name) {
  968. // console.log('GLOpt: getUniformLocation');
  969. flushCommands();
  970. return _gl.getUniformLocation(program, name);
  971. }
  972. function getVertexAttribOpt(index, pname) {
  973. // console.log('GLOpt: getVertexAttrib');
  974. flushCommands();
  975. return _gl.getVertexAttrib(index, pname);
  976. }
  977. function getVertexAttribOffsetOpt(index, pname) {
  978. // console.log('GLOpt: getVertexAttribOffset');
  979. flushCommands();
  980. return _gl.getVertexAttribOffset(index, pname);
  981. }
  982. function hintOpt(target, mode) {
  983. // console.log('GLOpt: hint');
  984. if (next_index + 3 >= total_size) {
  985. flushCommands();
  986. }
  987. buffer_data[next_index] = GL_COMMAND_HINT;
  988. buffer_data[next_index + 1] = target;
  989. buffer_data[next_index + 2] = mode;
  990. next_index += 3;
  991. ++commandCount;
  992. }
  993. function isBufferOpt(buffer) {
  994. // console.log('GLOpt: isBuffer');
  995. flushCommands();
  996. return _gl.isBuffer(buffer);
  997. }
  998. function isEnabledOpt(cap) {
  999. // console.log('GLOpt: isEnabled');
  1000. flushCommands();
  1001. return _gl.isEnabled(cap);
  1002. }
  1003. function isFramebufferOpt(framebuffer) {
  1004. // console.log('GLOpt: isFramebuffer');
  1005. flushCommands();
  1006. return _gl.isFramebuffer(framebuffer);
  1007. }
  1008. function isProgramOpt(program) {
  1009. // console.log('GLOpt: isProgram');
  1010. flushCommands();
  1011. return _gl.isProgram(program);
  1012. }
  1013. function isRenderbufferOpt(renderbuffer) {
  1014. // console.log('GLOpt: isRenderbuffer');
  1015. flushCommands();
  1016. return _gl.isRenderbuffer(renderbuffer);
  1017. }
  1018. function isShaderOpt(shader) {
  1019. // console.log('GLOpt: isShader');
  1020. flushCommands();
  1021. return _gl.isShader(shader);
  1022. }
  1023. function isTextureOpt(texture) {
  1024. // console.log('GLOpt: isTexture');
  1025. flushCommands();
  1026. return _gl.isTexture(texture);
  1027. }
  1028. function lineWidthOpt(width) {
  1029. // console.log('GLOpt: lineWidth');
  1030. if (next_index + 2 >= total_size) {
  1031. flushCommands();
  1032. }
  1033. buffer_data[next_index] = GL_COMMAND_LINE_WIDTH;
  1034. buffer_data[next_index + 1] = width;
  1035. next_index += 2;
  1036. ++commandCount;
  1037. }
  1038. function linkProgramOpt(program) {
  1039. // console.log('GLOpt: linkProgram');
  1040. if (next_index + 2 >= total_size) {
  1041. flushCommands();
  1042. }
  1043. buffer_data[next_index] = GL_COMMAND_LINK_PROGRAM;
  1044. buffer_data[next_index + 1] = program ? program._id : 0;
  1045. next_index += 2;
  1046. ++commandCount;
  1047. }
  1048. function pixelStoreiOpt(pname, param) {
  1049. // console.log('GLOpt: pixelStorei');
  1050. if (next_index + 3 >= total_size) {
  1051. flushCommands();
  1052. }
  1053. buffer_data[next_index] = GL_COMMAND_PIXEL_STOREI;
  1054. buffer_data[next_index + 1] = pname;
  1055. buffer_data[next_index + 2] = param;
  1056. next_index += 3;
  1057. ++commandCount;
  1058. }
  1059. function polygonOffsetOpt(factor, units) {
  1060. // console.log('GLOpt: polygonOffset');
  1061. if (next_index + 3 >= total_size) {
  1062. flushCommands();
  1063. }
  1064. buffer_data[next_index] = GL_COMMAND_POLYGON_OFFSET;
  1065. buffer_data[next_index + 1] = factor;
  1066. buffer_data[next_index + 2] = units;
  1067. next_index += 3;
  1068. ++commandCount;
  1069. }
  1070. function readPixelsOpt(x, y, width, height, format, type, pixels) {
  1071. // console.log('GLOpt: readPixels');
  1072. flushCommands();
  1073. _gl.readPixels(x, y, width, height, format, type, pixels);
  1074. }
  1075. function renderbufferStorageOpt(target, internalFormat, width, height) {
  1076. // console.log('GLOpt: renderbufferStorage');
  1077. if (next_index + 5 >= total_size) {
  1078. flushCommands();
  1079. }
  1080. buffer_data[next_index] = GL_COMMAND_RENDER_BUFFER_STORAGE;
  1081. buffer_data[next_index + 1] = target;
  1082. buffer_data[next_index + 2] = internalFormat;
  1083. buffer_data[next_index + 3] = width;
  1084. buffer_data[next_index + 4] = height;
  1085. next_index += 5;
  1086. ++commandCount;
  1087. }
  1088. function sampleCoverageOpt(value, invert) {
  1089. // console.log('GLOpt: sampleCoverage');
  1090. if (next_index + 3 >= total_size) {
  1091. flushCommands();
  1092. }
  1093. buffer_data[next_index] = GL_COMMAND_SAMPLE_COVERAGE;
  1094. buffer_data[next_index + 1] = value;
  1095. buffer_data[next_index + 2] = invert ? 1 : 0;
  1096. next_index += 3;
  1097. ++commandCount;
  1098. }
  1099. function scissorOpt(x, y, width, height) {
  1100. // console.log('GLOpt: scissor');
  1101. if (next_index + 5 >= total_size) {
  1102. flushCommands();
  1103. }
  1104. buffer_data[next_index] = GL_COMMAND_SCISSOR;
  1105. buffer_data[next_index + 1] = x;
  1106. buffer_data[next_index + 2] = y;
  1107. buffer_data[next_index + 3] = width;
  1108. buffer_data[next_index + 4] = height;
  1109. next_index += 5;
  1110. ++commandCount;
  1111. }
  1112. function shaderSourceOpt(shader, source) {
  1113. // console.log('GLOpt: shaderSource');
  1114. flushCommands();
  1115. _gl.shaderSource(shader, source);
  1116. }
  1117. function stencilFuncOpt(func, ref, mask) {
  1118. // console.log('GLOpt: stencilFunc');
  1119. if (next_index + 4 >= total_size) {
  1120. flushCommands();
  1121. }
  1122. buffer_data[next_index] = GL_COMMAND_STENCIL_FUNC;
  1123. buffer_data[next_index + 1] = func;
  1124. buffer_data[next_index + 2] = ref;
  1125. buffer_data[next_index + 3] = mask;
  1126. next_index += 4;
  1127. ++commandCount;
  1128. }
  1129. function stencilFuncSeparateOpt(face, func, ref, mask) {
  1130. // console.log('GLOpt: stencilFuncSeparate');
  1131. if (next_index + 5 >= total_size) {
  1132. flushCommands();
  1133. }
  1134. buffer_data[next_index] = GL_COMMAND_STENCIL_FUNC_SEPARATE;
  1135. buffer_data[next_index + 1] = face;
  1136. buffer_data[next_index + 2] = func;
  1137. buffer_data[next_index + 3] = ref;
  1138. buffer_data[next_index + 4] = mask;
  1139. next_index += 5;
  1140. ++commandCount;
  1141. }
  1142. function stencilMaskOpt(mask) {
  1143. // console.log('GLOpt: stencilMask');
  1144. if (next_index + 2 >= total_size) {
  1145. flushCommands();
  1146. }
  1147. buffer_data[next_index] = GL_COMMAND_STENCIL_MASK;
  1148. buffer_data[next_index + 1] = mask;
  1149. next_index += 2;
  1150. ++commandCount;
  1151. }
  1152. function stencilMaskSeparateOpt(face, mask) {
  1153. // console.log('GLOpt: stencilMaskSeparate');
  1154. if (next_index + 3 >= total_size) {
  1155. flushCommands();
  1156. }
  1157. buffer_data[next_index] = GL_COMMAND_STENCIL_MASK_SEPARATE;
  1158. buffer_data[next_index + 1] = face;
  1159. buffer_data[next_index + 2] = mask;
  1160. next_index += 3;
  1161. ++commandCount;
  1162. }
  1163. function stencilOpOpt(fail, zfail, zpass) {
  1164. // console.log('GLOpt: stencilOp');
  1165. if (next_index + 4 >= total_size) {
  1166. flushCommands();
  1167. }
  1168. buffer_data[next_index] = GL_COMMAND_STENCIL_OP;
  1169. buffer_data[next_index + 1] = fail;
  1170. buffer_data[next_index + 2] = zfail;
  1171. buffer_data[next_index + 3] = zpass;
  1172. next_index += 4;
  1173. ++commandCount;
  1174. }
  1175. function stencilOpSeparateOpt(face, fail, zfail, zpass) {
  1176. // console.log('GLOpt: stencilOpSeparate');
  1177. if (next_index + 5 >= total_size) {
  1178. flushCommands();
  1179. }
  1180. buffer_data[next_index] = GL_COMMAND_STENCIL_OP_SEPARATE;
  1181. buffer_data[next_index + 1] = face;
  1182. buffer_data[next_index + 2] = fail;
  1183. buffer_data[next_index + 3] = zfail;
  1184. buffer_data[next_index + 4] = zpass;
  1185. next_index += 5;
  1186. ++commandCount;
  1187. }
  1188. function texImage2DOpt() {
  1189. flushCommands(); // console.log('GLOpt: texImage2D');
  1190. var argCount = arguments.length;
  1191. if (argCount === 6) {
  1192. _gl.texImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
  1193. } else if (argCount === 9) {
  1194. _gl.texImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
  1195. } else {
  1196. console.log("texImage2DOpt: Wrong number of arguments, expected 6 or 9 but got ".concat(argCount));
  1197. }
  1198. }
  1199. function texParameterfOpt(target, pname, param) {
  1200. // console.log('GLOpt: texParameterf');
  1201. if (next_index + 4 >= total_size) {
  1202. flushCommands();
  1203. }
  1204. buffer_data[next_index] = GL_COMMAND_TEX_PARAMETER_F;
  1205. buffer_data[next_index + 1] = target;
  1206. buffer_data[next_index + 2] = pname;
  1207. buffer_data[next_index + 3] = param;
  1208. next_index += 4;
  1209. ++commandCount;
  1210. }
  1211. function texParameteriOpt(target, pname, param) {
  1212. // console.log('GLOpt: texParameteri');
  1213. if (next_index + 4 >= total_size) {
  1214. flushCommands();
  1215. }
  1216. buffer_data[next_index] = GL_COMMAND_TEX_PARAMETER_I;
  1217. buffer_data[next_index + 1] = target;
  1218. buffer_data[next_index + 2] = pname;
  1219. buffer_data[next_index + 3] = param;
  1220. next_index += 4;
  1221. ++commandCount;
  1222. }
  1223. function texSubImage2DOpt(target, level, xoffset, yoffset, width, height, format, type, pixels) {
  1224. flushCommands(); // console.log('GLOpt: texSubImage2D');
  1225. var argCount = arguments.length;
  1226. if (argCount === 7) {
  1227. _gl.texSubImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
  1228. } else if (argCount === 9) {
  1229. _gl.texSubImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
  1230. } else {
  1231. console.log("texSubImage2DOpt: Wrong number of arguments, expected 7 or 9 but got ".concat(argCount));
  1232. }
  1233. }
  1234. function uniform1fOpt(location, x) {
  1235. // console.log('GLOpt: uniform1f');
  1236. if (next_index + 3 >= total_size) {
  1237. flushCommands();
  1238. }
  1239. buffer_data[next_index] = GL_COMMAND_UNIFORM_1F;
  1240. buffer_data[next_index + 1] = location;
  1241. buffer_data[next_index + 2] = x;
  1242. next_index += 3;
  1243. ++commandCount;
  1244. }
  1245. function uniform2fOpt(location, x, y) {
  1246. // console.log('GLOpt: uniform2f');
  1247. if (next_index + 4 >= total_size) {
  1248. flushCommands();
  1249. }
  1250. buffer_data[next_index] = GL_COMMAND_UNIFORM_2F;
  1251. buffer_data[next_index + 1] = location;
  1252. buffer_data[next_index + 2] = x;
  1253. buffer_data[next_index + 3] = y;
  1254. next_index += 4;
  1255. ++commandCount;
  1256. }
  1257. function uniform3fOpt(location, x, y, z) {
  1258. // console.log('GLOpt: uniform3f');
  1259. if (next_index + 5 >= total_size) {
  1260. flushCommands();
  1261. }
  1262. buffer_data[next_index] = GL_COMMAND_UNIFORM_3F;
  1263. buffer_data[next_index + 1] = location;
  1264. buffer_data[next_index + 2] = x;
  1265. buffer_data[next_index + 3] = y;
  1266. buffer_data[next_index + 4] = z;
  1267. next_index += 5;
  1268. ++commandCount;
  1269. }
  1270. function uniform4fOpt(location, x, y, z, w) {
  1271. // console.log('GLOpt: uniform4f');
  1272. if (next_index + 6 >= total_size) {
  1273. flushCommands();
  1274. }
  1275. buffer_data[next_index] = GL_COMMAND_UNIFORM_4F;
  1276. buffer_data[next_index + 1] = location;
  1277. buffer_data[next_index + 2] = x;
  1278. buffer_data[next_index + 3] = y;
  1279. buffer_data[next_index + 4] = z;
  1280. buffer_data[next_index + 5] = w;
  1281. next_index += 6;
  1282. ++commandCount;
  1283. }
  1284. function uniform1iOpt(location, x) {
  1285. // console.log('GLOpt: uniform1i');
  1286. if (next_index + 3 >= total_size) {
  1287. flushCommands();
  1288. }
  1289. buffer_data[next_index] = GL_COMMAND_UNIFORM_1I;
  1290. buffer_data[next_index + 1] = location;
  1291. buffer_data[next_index + 2] = x;
  1292. next_index += 3;
  1293. ++commandCount;
  1294. }
  1295. function uniform2iOpt(location, x, y) {
  1296. // console.log('GLOpt: uniform2i');
  1297. if (next_index + 4 >= total_size) {
  1298. flushCommands();
  1299. }
  1300. buffer_data[next_index] = GL_COMMAND_UNIFORM_2I;
  1301. buffer_data[next_index + 1] = location;
  1302. buffer_data[next_index + 2] = x;
  1303. buffer_data[next_index + 3] = y;
  1304. next_index += 4;
  1305. ++commandCount;
  1306. }
  1307. function uniform3iOpt(location, x, y, z) {
  1308. // console.log('GLOpt: uniform3i');
  1309. if (next_index + 5 >= total_size) {
  1310. flushCommands();
  1311. }
  1312. buffer_data[next_index] = GL_COMMAND_UNIFORM_3I;
  1313. buffer_data[next_index + 1] = location;
  1314. buffer_data[next_index + 2] = x;
  1315. buffer_data[next_index + 3] = y;
  1316. buffer_data[next_index + 4] = z;
  1317. next_index += 5;
  1318. ++commandCount;
  1319. }
  1320. function uniform4iOpt(location, x, y, z, w) {
  1321. // console.log('GLOpt: uniform4i');
  1322. if (next_index + 6 >= total_size) {
  1323. flushCommands();
  1324. }
  1325. buffer_data[next_index] = GL_COMMAND_UNIFORM_4I;
  1326. buffer_data[next_index + 1] = location;
  1327. buffer_data[next_index + 2] = x;
  1328. buffer_data[next_index + 3] = y;
  1329. buffer_data[next_index + 4] = z;
  1330. buffer_data[next_index + 5] = w;
  1331. next_index += 6;
  1332. ++commandCount;
  1333. }
  1334. function uniform1fvOpt(location, value) {
  1335. // console.log('GLOpt: uniform1fv');
  1336. if (next_index + 3 + value.length >= total_size) {
  1337. flushCommands();
  1338. }
  1339. buffer_data[next_index] = GL_COMMAND_UNIFORM_1FV;
  1340. buffer_data[next_index + 1] = location;
  1341. buffer_data[next_index + 2] = value.length;
  1342. buffer_data.set(value, next_index + 3);
  1343. next_index += 3 + value.length;
  1344. ++commandCount;
  1345. }
  1346. function uniform2fvOpt(location, value) {
  1347. // console.log('GLOpt: uniform2fv');
  1348. if (next_index + 3 + value.length >= total_size) {
  1349. flushCommands();
  1350. }
  1351. buffer_data[next_index] = GL_COMMAND_UNIFORM_2FV;
  1352. buffer_data[next_index + 1] = location;
  1353. buffer_data[next_index + 2] = value.length;
  1354. buffer_data.set(value, next_index + 3);
  1355. next_index += 3 + value.length;
  1356. ++commandCount;
  1357. }
  1358. function uniform3fvOpt(location, value) {
  1359. // console.log('GLOpt: uniform3fv');
  1360. if (next_index + 3 + value.length >= total_size) {
  1361. flushCommands();
  1362. }
  1363. buffer_data[next_index] = GL_COMMAND_UNIFORM_3FV;
  1364. buffer_data[next_index + 1] = location;
  1365. buffer_data[next_index + 2] = value.length;
  1366. buffer_data.set(value, next_index + 3);
  1367. next_index += 3 + value.length;
  1368. ++commandCount;
  1369. }
  1370. function uniform4fvOpt(location, value) {
  1371. // console.log('GLOpt: uniform4fv');
  1372. if (next_index + 3 + value.length >= total_size) {
  1373. flushCommands();
  1374. }
  1375. buffer_data[next_index] = GL_COMMAND_UNIFORM_4FV;
  1376. buffer_data[next_index + 1] = location;
  1377. buffer_data[next_index + 2] = value.length;
  1378. buffer_data.set(value, next_index + 3);
  1379. next_index += 3 + value.length;
  1380. ++commandCount;
  1381. }
  1382. function uniform1ivOpt(location, value) {
  1383. // console.log('GLOpt: uniform1iv');
  1384. if (next_index + 3 + value.length >= total_size) {
  1385. flushCommands();
  1386. }
  1387. buffer_data[next_index] = GL_COMMAND_UNIFORM_1IV;
  1388. buffer_data[next_index + 1] = location;
  1389. buffer_data[next_index + 2] = value.length;
  1390. buffer_data.set(value, next_index + 3);
  1391. next_index += 3 + value.length;
  1392. ++commandCount;
  1393. }
  1394. function uniform2ivOpt(location, value) {
  1395. // console.log('GLOpt: uniform2iv');
  1396. if (next_index + 3 + value.length >= total_size) {
  1397. flushCommands();
  1398. }
  1399. buffer_data[next_index] = GL_COMMAND_UNIFORM_2IV;
  1400. buffer_data[next_index + 1] = location;
  1401. buffer_data[next_index + 2] = value.length;
  1402. buffer_data.set(value, next_index + 3);
  1403. next_index += 3 + value.length;
  1404. ++commandCount;
  1405. }
  1406. function uniform3ivOpt(location, value) {
  1407. // console.log('GLOpt: uniform3iv');
  1408. if (next_index + 3 + value.length >= total_size) {
  1409. flushCommands();
  1410. }
  1411. buffer_data[next_index] = GL_COMMAND_UNIFORM_3IV;
  1412. buffer_data[next_index + 1] = location;
  1413. buffer_data[next_index + 2] = value.length;
  1414. buffer_data.set(value, next_index + 3);
  1415. next_index += 3 + value.length;
  1416. ++commandCount;
  1417. }
  1418. function uniform4ivOpt(location, value) {
  1419. // console.log('GLOpt: uniform4iv');
  1420. if (next_index + 3 + value.length >= total_size) {
  1421. flushCommands();
  1422. }
  1423. buffer_data[next_index] = GL_COMMAND_UNIFORM_4IV;
  1424. buffer_data[next_index + 1] = location;
  1425. buffer_data[next_index + 2] = value.length;
  1426. buffer_data.set(value, next_index + 3);
  1427. next_index += 3 + value.length;
  1428. ++commandCount;
  1429. }
  1430. function uniformMatrix2fvOpt(location, transpose, value) {
  1431. // console.log('GLOpt: uniformMatrix2fv');
  1432. if (next_index + 4 + value.length >= total_size) {
  1433. flushCommands();
  1434. }
  1435. buffer_data[next_index] = GL_COMMAND_UNIFORM_MATRIX_2FV;
  1436. buffer_data[next_index + 1] = location;
  1437. buffer_data[next_index + 2] = transpose;
  1438. buffer_data[next_index + 3] = value.length;
  1439. buffer_data.set(value, next_index + 4);
  1440. next_index += 4 + value.length;
  1441. ++commandCount;
  1442. }
  1443. function uniformMatrix3fvOpt(location, transpose, value) {
  1444. // console.log('GLOpt: uniformMatrix3fv');
  1445. if (next_index + 4 + value.length >= total_size) {
  1446. flushCommands();
  1447. }
  1448. buffer_data[next_index] = GL_COMMAND_UNIFORM_MATRIX_3FV;
  1449. buffer_data[next_index + 1] = location;
  1450. buffer_data[next_index + 2] = transpose;
  1451. buffer_data[next_index + 3] = value.length;
  1452. buffer_data.set(value, next_index + 4);
  1453. next_index += 4 + value.length;
  1454. ++commandCount;
  1455. }
  1456. function uniformMatrix4fvOpt(location, transpose, value) {
  1457. // console.log('GLOpt: uniformMatrix4fv');
  1458. if (next_index + 4 + value.length >= total_size) {
  1459. flushCommands();
  1460. }
  1461. buffer_data[next_index] = GL_COMMAND_UNIFORM_MATRIX_4FV;
  1462. buffer_data[next_index + 1] = location;
  1463. buffer_data[next_index + 2] = transpose;
  1464. buffer_data[next_index + 3] = value.length;
  1465. buffer_data.set(value, next_index + 4);
  1466. next_index += 4 + value.length;
  1467. ++commandCount;
  1468. }
  1469. function useProgramOpt(program) {
  1470. // console.log('GLOpt: useProgram');
  1471. if (next_index + 2 >= total_size) {
  1472. flushCommands();
  1473. }
  1474. buffer_data[next_index] = GL_COMMAND_USE_PROGRAM;
  1475. buffer_data[next_index + 1] = program ? program._id : 0;
  1476. next_index += 2;
  1477. ++commandCount;
  1478. }
  1479. function validateProgramOpt(program) {
  1480. // console.log('GLOpt: validateProgram');
  1481. if (next_index + 2 >= total_size) {
  1482. flushCommands();
  1483. }
  1484. buffer_data[next_index] = GL_COMMAND_VALIDATE_PROGRAM;
  1485. buffer_data[next_index + 1] = program ? program._id : 0;
  1486. next_index += 2;
  1487. ++commandCount;
  1488. }
  1489. function vertexAttrib1fOpt(index, x) {
  1490. // console.log('GLOpt: vertexAttrib1f');
  1491. if (next_index + 3 >= total_size) {
  1492. flushCommands();
  1493. }
  1494. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_1F;
  1495. buffer_data[next_index + 1] = index;
  1496. buffer_data[next_index + 2] = x;
  1497. next_index += 3;
  1498. ++commandCount;
  1499. }
  1500. function vertexAttrib2fOpt(index, x, y) {
  1501. // console.log('GLOpt: vertexAttrib2f');
  1502. if (next_index + 4 >= total_size) {
  1503. flushCommands();
  1504. }
  1505. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_2F;
  1506. buffer_data[next_index + 1] = index;
  1507. buffer_data[next_index + 2] = x;
  1508. buffer_data[next_index + 3] = y;
  1509. next_index += 4;
  1510. ++commandCount;
  1511. }
  1512. function vertexAttrib3fOpt(index, x, y, z) {
  1513. // console.log('GLOpt: vertexAttrib3f');
  1514. if (next_index + 5 >= total_size) {
  1515. flushCommands();
  1516. }
  1517. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_3F;
  1518. buffer_data[next_index + 1] = index;
  1519. buffer_data[next_index + 2] = x;
  1520. buffer_data[next_index + 3] = y;
  1521. buffer_data[next_index + 4] = z;
  1522. next_index += 5;
  1523. ++commandCount;
  1524. }
  1525. function vertexAttrib4fOpt(index, x, y, z, w) {
  1526. // console.log('GLOpt: vertexAttrib4f');
  1527. if (next_index + 6 >= total_size) {
  1528. flushCommands();
  1529. }
  1530. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_4F;
  1531. buffer_data[next_index + 1] = index;
  1532. buffer_data[next_index + 2] = x;
  1533. buffer_data[next_index + 3] = y;
  1534. buffer_data[next_index + 4] = z;
  1535. buffer_data[next_index + 5] = w;
  1536. next_index += 6;
  1537. ++commandCount;
  1538. }
  1539. function vertexAttrib1fvOpt(index, value) {
  1540. // console.log('GLOpt: vertexAttrib1fv');
  1541. if (next_index + 3 + value.length >= total_size) {
  1542. flushCommands();
  1543. }
  1544. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_1FV;
  1545. buffer_data[next_index + 1] = index;
  1546. buffer_data[next_index + 2] = value.length;
  1547. buffer_data.set(value, next_index + 3);
  1548. next_index += 3 + value.length;
  1549. ++commandCount;
  1550. }
  1551. function vertexAttrib2fvOpt(index, value) {
  1552. // console.log('GLOpt: vertexAttrib2fv');
  1553. if (next_index + 3 + value.length >= total_size) {
  1554. flushCommands();
  1555. }
  1556. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_2FV;
  1557. buffer_data[next_index + 1] = index;
  1558. buffer_data[next_index + 2] = value.length;
  1559. buffer_data.set(value, next_index + 3);
  1560. next_index += 3 + value.length;
  1561. ++commandCount;
  1562. }
  1563. function vertexAttrib3fvOpt(index, value) {
  1564. // console.log('GLOpt: vertexAttrib3fv');
  1565. if (next_index + 3 + value.length >= total_size) {
  1566. flushCommands();
  1567. }
  1568. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_3FV;
  1569. buffer_data[next_index + 1] = index;
  1570. buffer_data[next_index + 2] = value.length;
  1571. buffer_data.set(value, next_index + 3);
  1572. next_index += 3 + value.length;
  1573. ++commandCount;
  1574. }
  1575. function vertexAttrib4fvOpt(index, value) {
  1576. // console.log('GLOpt: vertexAttrib4fv');
  1577. if (next_index + 3 + value.length >= total_size) {
  1578. flushCommands();
  1579. }
  1580. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_4FV;
  1581. buffer_data[next_index + 1] = index;
  1582. buffer_data[next_index + 2] = value.length;
  1583. buffer_data.set(value, next_index + 3);
  1584. next_index += 3 + value.length;
  1585. ++commandCount;
  1586. }
  1587. function vertexAttribPointerOpt(index, size, type, normalized, stride, offset) {
  1588. // console.log('GLOpt: vertexAttribPointer');
  1589. if (next_index + 7 >= total_size) {
  1590. flushCommands();
  1591. }
  1592. buffer_data[next_index] = GL_COMMAND_VERTEX_ATTRIB_POINTER;
  1593. buffer_data[next_index + 1] = index;
  1594. buffer_data[next_index + 2] = size;
  1595. buffer_data[next_index + 3] = type;
  1596. buffer_data[next_index + 4] = normalized ? 1 : 0;
  1597. buffer_data[next_index + 5] = stride;
  1598. buffer_data[next_index + 6] = offset;
  1599. next_index += 7;
  1600. ++commandCount;
  1601. }
  1602. function viewportOpt(x, y, width, height) {
  1603. // console.log('GLOpt: viewport');
  1604. if (next_index + 5 >= total_size) {
  1605. flushCommands();
  1606. }
  1607. buffer_data[next_index] = GL_COMMAND_VIEW_PORT;
  1608. buffer_data[next_index + 1] = x;
  1609. buffer_data[next_index + 2] = y;
  1610. buffer_data[next_index + 3] = width;
  1611. buffer_data[next_index + 4] = height;
  1612. next_index += 5;
  1613. ++commandCount;
  1614. }
  1615. function isSupportTypeArray() {
  1616. //FIXME:
  1617. // if (GameStatusInfo.platform == 'android') {
  1618. return true; // }
  1619. // var info = BK.Director.queryDeviceInfo();
  1620. // var vers = info.version.split('.');
  1621. // if (info.platform == 'ios' && Number(vers[0]) >= 10) {
  1622. // return true;
  1623. // }
  1624. // return false;
  1625. }
  1626. function attachMethodOpt() {
  1627. gl.activeTexture = activeTextureOpt;
  1628. gl.attachShader = attachShaderOpt;
  1629. gl.bindAttribLocation = bindAttribLocationOpt;
  1630. gl.bindBuffer = bindBufferOpt;
  1631. gl.bindFramebuffer = bindFramebufferOpt;
  1632. gl.bindRenderbuffer = bindRenderbufferOpt;
  1633. gl.bindTexture = bindTextureOpt;
  1634. gl.blendColor = blendColorOpt;
  1635. gl.blendEquation = blendEquationOpt;
  1636. gl.blendEquationSeparate = blendEquationSeparateOpt;
  1637. gl.blendFunc = blendFuncOpt;
  1638. gl.blendFuncSeparate = blendFuncSeparateOpt;
  1639. gl.bufferData = bufferDataOpt;
  1640. gl.bufferSubData = bufferSubDataOpt;
  1641. gl.checkFramebufferStatus = checkFramebufferStatusOpt;
  1642. gl.clear = clearOpt;
  1643. gl.clearColor = clearColorOpt;
  1644. gl.clearDepth = clearDepthOpt;
  1645. gl.clearStencil = clearStencilOpt;
  1646. gl.colorMask = colorMaskOpt;
  1647. gl.compileShader = compileShaderOpt;
  1648. gl.compressedTexImage2D = compressedTexImage2DOpt;
  1649. gl.compressedTexSubImage2D = compressedTexSubImage2DOpt;
  1650. gl.copyTexImage2D = copyTexImage2DOpt;
  1651. gl.copyTexSubImage2D = copyTexSubImage2DOpt;
  1652. gl.createBuffer = createBufferOpt;
  1653. gl.createFramebuffer = createFramebufferOpt;
  1654. gl.createProgram = createProgramOpt;
  1655. gl.createRenderbuffer = createRenderbufferOpt;
  1656. gl.createShader = createShaderOpt;
  1657. gl.createTexture = createTextureOpt;
  1658. gl.cullFace = cullFaceOpt;
  1659. gl.deleteBuffer = deleteBufferOpt;
  1660. gl.deleteFramebuffer = deleteFramebufferOpt;
  1661. gl.deleteProgram = deleteProgramOpt;
  1662. gl.deleteRenderbuffer = deleteRenderbufferOpt;
  1663. gl.deleteShader = deleteShaderOpt;
  1664. gl.deleteTexture = deleteTextureOpt;
  1665. gl.depthFunc = depthFuncOpt;
  1666. gl.depthMask = depthMaskOpt;
  1667. gl.depthRange = depthRangeOpt;
  1668. gl.detachShader = detachShaderOpt;
  1669. gl.disable = disableOpt;
  1670. gl.disableVertexAttribArray = disableVertexAttribArrayOpt;
  1671. gl.drawArrays = drawArraysOpt;
  1672. gl.drawElements = drawElementsOpt;
  1673. gl.enable = enableOpt;
  1674. gl.enableVertexAttribArray = enableVertexAttribArrayOpt;
  1675. gl.finish = finishOpt;
  1676. gl.flush = flushOpt;
  1677. gl.framebufferRenderbuffer = framebufferRenderbufferOpt;
  1678. gl.framebufferTexture2D = framebufferTexture2DOpt;
  1679. gl.frontFace = frontFaceOpt;
  1680. gl.generateMipmap = generateMipmapOpt;
  1681. gl.getActiveAttrib = getActiveAttribOpt;
  1682. gl.getActiveUniform = getActiveUniformOpt;
  1683. gl.getAttachedShaders = getAttachedShadersOpt;
  1684. gl.getAttribLocation = getAttribLocationOpt;
  1685. gl.getBufferParameter = getBufferParameterOpt;
  1686. gl.getParameter = getParameterOpt;
  1687. gl.getError = getErrorOpt;
  1688. gl.getFramebufferAttachmentParameter = getFramebufferAttachmentParameterOpt;
  1689. gl.getProgramParameter = getProgramParameterOpt;
  1690. gl.getProgramInfoLog = getProgramInfoLogOpt;
  1691. gl.getRenderbufferParameter = getRenderbufferParameterOpt;
  1692. gl.getShaderParameter = getShaderParameterOpt;
  1693. gl.getShaderPrecisionFormat = getShaderPrecisionFormatOpt;
  1694. gl.getShaderInfoLog = getShaderInfoLogOpt;
  1695. gl.getShaderSource = getShaderSourceOpt;
  1696. gl.getTexParameter = getTexParameterOpt;
  1697. gl.getUniform = getUniformOpt;
  1698. gl.getUniformLocation = getUniformLocationOpt;
  1699. gl.getVertexAttrib = getVertexAttribOpt;
  1700. gl.getVertexAttribOffset = getVertexAttribOffsetOpt;
  1701. gl.hint = hintOpt;
  1702. gl.isBuffer = isBufferOpt;
  1703. gl.isEnabled = isEnabledOpt;
  1704. gl.isFramebuffer = isFramebufferOpt;
  1705. gl.isProgram = isProgramOpt;
  1706. gl.isRenderbuffer = isRenderbufferOpt;
  1707. gl.isShader = isShaderOpt;
  1708. gl.isTexture = isTextureOpt;
  1709. gl.lineWidth = lineWidthOpt;
  1710. gl.linkProgram = linkProgramOpt;
  1711. gl.pixelStorei = pixelStoreiOpt;
  1712. gl.polygonOffset = polygonOffsetOpt;
  1713. gl.readPixels = readPixelsOpt;
  1714. gl.renderbufferStorage = renderbufferStorageOpt;
  1715. gl.sampleCoverage = sampleCoverageOpt;
  1716. gl.scissor = scissorOpt;
  1717. gl.shaderSource = shaderSourceOpt;
  1718. gl.stencilFunc = stencilFuncOpt;
  1719. gl.stencilFuncSeparate = stencilFuncSeparateOpt;
  1720. gl.stencilMask = stencilMaskOpt;
  1721. gl.stencilMaskSeparate = stencilMaskSeparateOpt;
  1722. gl.stencilOp = stencilOpOpt;
  1723. gl.stencilOpSeparate = stencilOpSeparateOpt;
  1724. gl.texImage2D = texImage2DOpt;
  1725. gl.texParameterf = texParameterfOpt;
  1726. gl.texParameteri = texParameteriOpt;
  1727. gl.texSubImage2D = texSubImage2DOpt;
  1728. gl.uniform1f = uniform1fOpt;
  1729. gl.uniform2f = uniform2fOpt;
  1730. gl.uniform3f = uniform3fOpt;
  1731. gl.uniform4f = uniform4fOpt;
  1732. gl.uniform1i = uniform1iOpt;
  1733. gl.uniform2i = uniform2iOpt;
  1734. gl.uniform3i = uniform3iOpt;
  1735. gl.uniform4i = uniform4iOpt;
  1736. gl.uniform1fv = uniform1fvOpt;
  1737. gl.uniform2fv = uniform2fvOpt;
  1738. gl.uniform3fv = uniform3fvOpt;
  1739. gl.uniform4fv = uniform4fvOpt;
  1740. gl.uniform1iv = uniform1ivOpt;
  1741. gl.uniform2iv = uniform2ivOpt;
  1742. gl.uniform3iv = uniform3ivOpt;
  1743. gl.uniform4iv = uniform4ivOpt;
  1744. gl.uniformMatrix2fv = uniformMatrix2fvOpt;
  1745. gl.uniformMatrix3fv = uniformMatrix3fvOpt;
  1746. gl.uniformMatrix4fv = uniformMatrix4fvOpt;
  1747. gl.useProgram = useProgramOpt;
  1748. gl.validateProgram = validateProgramOpt;
  1749. gl.vertexAttrib1f = vertexAttrib1fOpt;
  1750. gl.vertexAttrib2f = vertexAttrib2fOpt;
  1751. gl.vertexAttrib3f = vertexAttrib3fOpt;
  1752. gl.vertexAttrib4f = vertexAttrib4fOpt;
  1753. gl.vertexAttrib1fv = vertexAttrib1fvOpt;
  1754. gl.vertexAttrib2fv = vertexAttrib2fvOpt;
  1755. gl.vertexAttrib3fv = vertexAttrib3fvOpt;
  1756. gl.vertexAttrib4fv = vertexAttrib4fvOpt;
  1757. gl.vertexAttribPointer = vertexAttribPointerOpt;
  1758. gl.viewport = viewportOpt;
  1759. }
  1760. batchGLCommandsToNative();
  1761. module.exports = {
  1762. disableBatchGLCommandsToNative: disableBatchGLCommandsToNative,
  1763. flushCommands: flushCommands
  1764. };
  1765. },{}],4:[function(require,module,exports){
  1766. "use strict";
  1767. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1768. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1769. window.CanvasRenderingContext2D = jsb.CanvasRenderingContext2D;
  1770. delete jsb.CanvasRenderingContext2D;
  1771. jsb.device = jsb.Device; // cc namespace will be reset to {} in creator, use jsb namespace instead.
  1772. var _require = require('./base64/base64.min'),
  1773. btoa = _require.btoa,
  1774. atob = _require.atob;
  1775. window.btoa = btoa;
  1776. window.atob = atob;
  1777. var _require2 = require('./Blob'),
  1778. Blob = _require2.Blob,
  1779. URL = _require2.URL;
  1780. window.Blob = Blob;
  1781. window.URL = URL;
  1782. window.DOMParser = require('./xmldom/dom-parser').DOMParser;
  1783. require('./jsb_prepare');
  1784. require('./jsb_opengl');
  1785. require('./jsb-adapter');
  1786. require('./jsb_audioengine');
  1787. require('./jsb_input'); // external interface of native renderer
  1788. require('./renderer/enums');
  1789. require('./renderer/jsb-vertex-format');
  1790. require('./renderer/jsb-gfx');
  1791. require('./renderer/jsb-renderer');
  1792. var _oldRequestFrameCallback = null;
  1793. var _requestAnimationFrameID = 0;
  1794. var _requestAnimationFrameCallbacks = {};
  1795. var _firstTick = true;
  1796. window.requestAnimationFrame = function (cb) {
  1797. var id = ++_requestAnimationFrameID;
  1798. _requestAnimationFrameCallbacks[id] = cb;
  1799. return id;
  1800. };
  1801. window.cancelAnimationFrame = function (id) {
  1802. delete _requestAnimationFrameCallbacks[id];
  1803. };
  1804. var _require3 = require('./glOptMode'),
  1805. disableBatchGLCommandsToNative = _require3.disableBatchGLCommandsToNative,
  1806. flushCommands = _require3.flushCommands;
  1807. window.optConfig = {
  1808. disableBatchGLCommandsToNative: disableBatchGLCommandsToNative
  1809. };
  1810. function tick(nowMilliSeconds) {
  1811. if (_firstTick) {
  1812. _firstTick = false;
  1813. if (window.onload) {
  1814. var event = new Event('load');
  1815. event._target = window;
  1816. window.onload(event);
  1817. }
  1818. }
  1819. fireTimeout(nowMilliSeconds);
  1820. for (var id in _requestAnimationFrameCallbacks) {
  1821. _oldRequestFrameCallback = _requestAnimationFrameCallbacks[id];
  1822. if (_oldRequestFrameCallback) {
  1823. delete _requestAnimationFrameCallbacks[id];
  1824. _oldRequestFrameCallback(nowMilliSeconds);
  1825. }
  1826. }
  1827. flushCommands();
  1828. }
  1829. var _timeoutIDIndex = 0;
  1830. var TimeoutInfo = function TimeoutInfo(cb, delay, isRepeat, target, args) {
  1831. _classCallCheck(this, TimeoutInfo);
  1832. this.cb = cb;
  1833. this.id = ++_timeoutIDIndex;
  1834. this.start = performance.now();
  1835. this.delay = delay;
  1836. this.isRepeat = isRepeat;
  1837. this.target = target;
  1838. this.args = args;
  1839. };
  1840. var _timeoutInfos = {};
  1841. function fireTimeout(nowMilliSeconds) {
  1842. var info;
  1843. for (var id in _timeoutInfos) {
  1844. info = _timeoutInfos[id];
  1845. if (info && info.cb) {
  1846. if (nowMilliSeconds - info.start >= info.delay) {
  1847. // console.log(`fireTimeout: id ${id}, start: ${info.start}, delay: ${info.delay}, now: ${nowMilliSeconds}`);
  1848. if (typeof info.cb === 'string') {
  1849. Function(info.cb)();
  1850. } else if (typeof info.cb === 'function') {
  1851. info.cb.apply(info.target, info.args);
  1852. }
  1853. if (info.isRepeat) {
  1854. info.start = nowMilliSeconds;
  1855. } else {
  1856. delete _timeoutInfos[id];
  1857. }
  1858. }
  1859. }
  1860. }
  1861. }
  1862. function createTimeoutInfo(prevFuncArgs, isRepeat) {
  1863. var cb = prevFuncArgs[0];
  1864. if (!cb) {
  1865. console.error("createTimeoutInfo doesn't pass a callback ...");
  1866. return 0;
  1867. }
  1868. var delay = prevFuncArgs.length > 1 ? prevFuncArgs[1] : 0;
  1869. var args;
  1870. if (prevFuncArgs.length > 2) {
  1871. args = Array.prototype.slice.call(prevFuncArgs, 2);
  1872. }
  1873. var info = new TimeoutInfo(cb, delay, isRepeat, this, args);
  1874. _timeoutInfos[info.id] = info;
  1875. return info.id;
  1876. }
  1877. window.setTimeout = function (cb) {
  1878. return createTimeoutInfo(arguments, false);
  1879. };
  1880. window.clearTimeout = function (id) {
  1881. delete _timeoutInfos[id];
  1882. };
  1883. window.setInterval = function (cb) {
  1884. return createTimeoutInfo(arguments, true);
  1885. };
  1886. window.clearInterval = window.clearTimeout;
  1887. window.alert = console.error.bind(console);
  1888. var __motionCallbackID = 0;
  1889. var __motionEnabled = false;
  1890. var __motionInterval = 16.6; // milliseconds
  1891. jsb.device.setMotionInterval = function (milliseconds) {
  1892. __motionInterval = milliseconds; // convert to seconds
  1893. jsb.device.setAccelerometerInterval(__motionInterval / 1000);
  1894. if (__motionEnabled) {
  1895. jsb.device.setMotionEnabled(false);
  1896. jsb.device.setMotionEnabled(true);
  1897. }
  1898. };
  1899. jsb.device.setMotionEnabled = function (enabled) {
  1900. if (__motionEnabled === enabled) return;
  1901. jsb.device.setAccelerometerEnabled(enabled);
  1902. if (enabled) {
  1903. var motionValue;
  1904. var event = new DeviceMotionEvent();
  1905. __motionCallbackID = window.setInterval(function () {
  1906. motionValue = jsb.device.getDeviceMotionValue();
  1907. event._acceleration.x = motionValue[0];
  1908. event._acceleration.y = motionValue[1];
  1909. event._acceleration.z = motionValue[2];
  1910. event._accelerationIncludingGravity.x = motionValue[3];
  1911. event._accelerationIncludingGravity.y = motionValue[4];
  1912. event._accelerationIncludingGravity.z = motionValue[5];
  1913. event._rotationRate.alpha = motionValue[6];
  1914. event._rotationRate.beta = motionValue[7];
  1915. event._rotationRate.gamma = motionValue[8];
  1916. event._interval = __motionInterval;
  1917. jsb.device.dispatchDeviceMotionEvent(event);
  1918. }, __motionInterval);
  1919. } else {
  1920. window.clearInterval(__motionCallbackID);
  1921. __motionCallbackID = 0;
  1922. }
  1923. __motionEnabled = enabled;
  1924. }; // File utils (Temporary, won't be accessible)
  1925. if (typeof jsb.FileUtils !== 'undefined') {
  1926. jsb.fileUtils = jsb.FileUtils.getInstance();
  1927. delete jsb.FileUtils;
  1928. }
  1929. XMLHttpRequest.prototype.addEventListener = function (eventName, listener, options) {
  1930. this['on' + eventName] = listener;
  1931. };
  1932. XMLHttpRequest.prototype.removeEventListener = function (eventName, listener, options) {
  1933. this['on' + eventName] = null;
  1934. }; // SocketIO
  1935. if (window.SocketIO) {
  1936. window.io = window.SocketIO;
  1937. SocketIO.prototype._Emit = SocketIO.prototype.emit;
  1938. SocketIO.prototype.emit = function (uri, delegate) {
  1939. if (_typeof(delegate) === 'object') {
  1940. delegate = JSON.stringify(delegate);
  1941. }
  1942. this._Emit(uri, delegate);
  1943. };
  1944. }
  1945. window.gameTick = tick; // generate get set function
  1946. jsb.generateGetSet = function (moduleObj) {
  1947. for (var classKey in moduleObj) {
  1948. var classProto = moduleObj[classKey] && moduleObj[classKey].prototype;
  1949. if (!classProto) continue;
  1950. var _loop = function _loop(getName) {
  1951. var getPos = getName.search(/^get/);
  1952. if (getPos == -1) return "continue";
  1953. var propName = getName.replace(/^get/, '');
  1954. var nameArr = propName.split('');
  1955. var lowerFirst = nameArr[0].toLowerCase();
  1956. var upperFirst = nameArr[0].toUpperCase();
  1957. nameArr.splice(0, 1);
  1958. var left = nameArr.join('');
  1959. propName = lowerFirst + left;
  1960. var setName = 'set' + upperFirst + left;
  1961. if (classProto.hasOwnProperty(propName)) return "continue";
  1962. var setFunc = classProto[setName];
  1963. var hasSetFunc = typeof setFunc === 'function';
  1964. if (hasSetFunc) {
  1965. Object.defineProperty(classProto, propName, {
  1966. get: function get() {
  1967. return this[getName]();
  1968. },
  1969. set: function set(val) {
  1970. this[setName](val);
  1971. },
  1972. configurable: true
  1973. });
  1974. } else {
  1975. Object.defineProperty(classProto, propName, {
  1976. get: function get() {
  1977. return this[getName]();
  1978. },
  1979. configurable: true
  1980. });
  1981. }
  1982. };
  1983. for (var getName in classProto) {
  1984. var _ret = _loop(getName);
  1985. if (_ret === "continue") continue;
  1986. }
  1987. }
  1988. }; // promise polyfill relies on setTimeout implementation
  1989. require('./promise.min');
  1990. },{"./Blob":1,"./base64/base64.min":2,"./glOptMode":3,"./jsb-adapter":27,"./jsb_audioengine":32,"./jsb_input":33,"./jsb_opengl":34,"./jsb_prepare":36,"./promise.min":37,"./renderer/enums":38,"./renderer/jsb-gfx":39,"./renderer/jsb-renderer":40,"./renderer/jsb-vertex-format":41,"./xmldom/dom-parser":42}],5:[function(require,module,exports){
  1991. "use strict";
  1992. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1993. var DOMRect = function DOMRect(x, y, width, height) {
  1994. _classCallCheck(this, DOMRect);
  1995. this.x = x ? x : 0;
  1996. this.y = y ? y : 0;
  1997. this.width = width ? width : 0;
  1998. this.height = height ? height : 0;
  1999. this.left = this.x;
  2000. this.top = this.y;
  2001. this.right = this.x + this.width;
  2002. this.bottom = this.y + this.height;
  2003. };
  2004. module.exports = DOMRect;
  2005. },{}],6:[function(require,module,exports){
  2006. "use strict";
  2007. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2008. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2009. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2010. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2011. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2012. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2013. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2014. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2015. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2016. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2017. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2018. var Event = require('./Event');
  2019. var DeviceMotionEvent = /*#__PURE__*/function (_Event) {
  2020. _inherits(DeviceMotionEvent, _Event);
  2021. var _super = _createSuper(DeviceMotionEvent);
  2022. function DeviceMotionEvent(initArgs) {
  2023. var _this;
  2024. _classCallCheck(this, DeviceMotionEvent);
  2025. _this = _super.call(this, 'devicemotion');
  2026. if (initArgs) {
  2027. _this._acceleration = initArgs.acceleration ? initArgs.acceleration : {
  2028. x: 0,
  2029. y: 0,
  2030. z: 0
  2031. };
  2032. _this._accelerationIncludingGravity = initArgs.accelerationIncludingGravity ? initArgs.accelerationIncludingGravity : {
  2033. x: 0,
  2034. y: 0,
  2035. z: 0
  2036. };
  2037. _this._rotationRate = initArgs.rotationRate ? initArgs.rotationRate : {
  2038. alpha: 0,
  2039. beta: 0,
  2040. gamma: 0
  2041. };
  2042. _this._interval = initArgs.interval;
  2043. } else {
  2044. _this._acceleration = {
  2045. x: 0,
  2046. y: 0,
  2047. z: 0
  2048. };
  2049. _this._accelerationIncludingGravity = {
  2050. x: 0,
  2051. y: 0,
  2052. z: 0
  2053. };
  2054. _this._rotationRate = {
  2055. alpha: 0,
  2056. beta: 0,
  2057. gamma: 0
  2058. };
  2059. _this._interval = 0;
  2060. }
  2061. return _this;
  2062. }
  2063. _createClass(DeviceMotionEvent, [{
  2064. key: "acceleration",
  2065. get: function get() {
  2066. return this._acceleration;
  2067. }
  2068. }, {
  2069. key: "accelerationIncludingGravity",
  2070. get: function get() {
  2071. return this._accelerationIncludingGravity;
  2072. }
  2073. }, {
  2074. key: "rotationRate",
  2075. get: function get() {
  2076. return this._rotationRate;
  2077. }
  2078. }, {
  2079. key: "interval",
  2080. get: function get() {
  2081. return this._interval;
  2082. }
  2083. }]);
  2084. return DeviceMotionEvent;
  2085. }(Event);
  2086. module.exports = DeviceMotionEvent;
  2087. },{"./Event":8}],7:[function(require,module,exports){
  2088. "use strict";
  2089. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2090. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2091. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2092. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2093. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2094. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2095. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2096. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2097. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2098. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2099. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2100. var Node = require('./Node');
  2101. var DOMRect = require('./DOMRect');
  2102. var Element = /*#__PURE__*/function (_Node) {
  2103. _inherits(Element, _Node);
  2104. var _super = _createSuper(Element);
  2105. function Element() {
  2106. var _this;
  2107. _classCallCheck(this, Element);
  2108. _this = _super.call(this);
  2109. _this.className = '';
  2110. _this.children = [];
  2111. _this.clientLeft = 0;
  2112. _this.clientTop = 0;
  2113. _this.scrollLeft = 0;
  2114. _this.scrollTop = 0;
  2115. return _this;
  2116. }
  2117. _createClass(Element, [{
  2118. key: "clientWidth",
  2119. get: function get() {
  2120. return 0;
  2121. }
  2122. }, {
  2123. key: "clientHeight",
  2124. get: function get() {
  2125. return 0;
  2126. }
  2127. }, {
  2128. key: "getBoundingClientRect",
  2129. value: function getBoundingClientRect() {
  2130. return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
  2131. } // attrName is a string that names the attribute to be removed from element.
  2132. }, {
  2133. key: "removeAttribute",
  2134. value: function removeAttribute(attrName) {}
  2135. }]);
  2136. return Element;
  2137. }(Node);
  2138. module.exports = Element;
  2139. },{"./DOMRect":5,"./Node":24}],8:[function(require,module,exports){
  2140. "use strict";
  2141. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2142. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2143. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2144. /**
  2145. * @see https://dom.spec.whatwg.org/#interface-event
  2146. * @private
  2147. */
  2148. /**
  2149. * The event wrapper.
  2150. * @constructor
  2151. * @param {EventTarget} eventTarget The event target of this dispatching.
  2152. * @param {Event|{type:string}} event The original event to wrap.
  2153. */
  2154. var Event = /*#__PURE__*/function () {
  2155. function Event(type, eventInit) {
  2156. _classCallCheck(this, Event);
  2157. this._type = type;
  2158. this._target = null;
  2159. this._eventPhase = 2;
  2160. this._currentTarget = null;
  2161. this._canceled = false;
  2162. this._stopped = false; // The flag to stop propagation immediately.
  2163. this._passiveListener = null;
  2164. this._timeStamp = Date.now();
  2165. }
  2166. /**
  2167. * The type of this event.
  2168. * @type {string}
  2169. */
  2170. _createClass(Event, [{
  2171. key: "type",
  2172. get: function get() {
  2173. return this._type;
  2174. }
  2175. /**
  2176. * The target of this event.
  2177. * @type {EventTarget}
  2178. */
  2179. }, {
  2180. key: "target",
  2181. get: function get() {
  2182. return this._target;
  2183. }
  2184. /**
  2185. * The target of this event.
  2186. * @type {EventTarget}
  2187. */
  2188. }, {
  2189. key: "currentTarget",
  2190. get: function get() {
  2191. return this._currentTarget;
  2192. }
  2193. }, {
  2194. key: "isTrusted",
  2195. get: function get() {
  2196. // https://heycam.github.io/webidl/#Unforgeable
  2197. return false;
  2198. }
  2199. }, {
  2200. key: "timeStamp",
  2201. get:
  2202. /**
  2203. * The unix time of this event.
  2204. * @type {number}
  2205. */
  2206. function get() {
  2207. return this._timeStamp;
  2208. }
  2209. }, {
  2210. key: "composedPath",
  2211. value:
  2212. /**
  2213. * @returns {EventTarget[]} The composed path of this event.
  2214. */
  2215. function composedPath() {
  2216. var currentTarget = this._currentTarget;
  2217. if (currentTarget === null) {
  2218. return [];
  2219. }
  2220. return [currentTarget];
  2221. }
  2222. /**
  2223. * The target of this event.
  2224. * @type {number}
  2225. */
  2226. }, {
  2227. key: "eventPhase",
  2228. get: function get() {
  2229. return this._eventPhase;
  2230. }
  2231. /**
  2232. * Stop event bubbling.
  2233. * @returns {void}
  2234. */
  2235. }, {
  2236. key: "stopPropagation",
  2237. value: function stopPropagation() {}
  2238. /**
  2239. * Stop event bubbling.
  2240. * @returns {void}
  2241. */
  2242. }, {
  2243. key: "stopImmediatePropagation",
  2244. value: function stopImmediatePropagation() {
  2245. this._stopped = true;
  2246. }
  2247. /**
  2248. * The flag to be bubbling.
  2249. * @type {boolean}
  2250. */
  2251. }, {
  2252. key: "bubbles",
  2253. get: function get() {
  2254. return false;
  2255. }
  2256. /**
  2257. * The flag to be cancelable.
  2258. * @type {boolean}
  2259. */
  2260. }, {
  2261. key: "cancelable",
  2262. get: function get() {
  2263. return true;
  2264. }
  2265. /**
  2266. * Cancel this event.
  2267. * @returns {void}
  2268. */
  2269. }, {
  2270. key: "preventDefault",
  2271. value: function preventDefault() {
  2272. if (this._passiveListener !== null) {
  2273. console.warn("Event#preventDefault() was called from a passive listener:", this._passiveListener);
  2274. return;
  2275. }
  2276. if (!this.cancelable) {
  2277. return;
  2278. }
  2279. this._canceled = true;
  2280. }
  2281. /**
  2282. * The flag to indicate cancellation state.
  2283. * @type {boolean}
  2284. */
  2285. }, {
  2286. key: "defaultPrevented",
  2287. get: function get() {
  2288. return this._canceled;
  2289. }
  2290. /**
  2291. * The flag to be composed.
  2292. * @type {boolean}
  2293. */
  2294. }, {
  2295. key: "composed",
  2296. get: function get() {
  2297. return false;
  2298. }
  2299. }]);
  2300. return Event;
  2301. }();
  2302. /**
  2303. * Constant of NONE.
  2304. * @type {number}
  2305. */
  2306. Event.NONE = 0;
  2307. /**
  2308. * Constant of CAPTURING_PHASE.
  2309. * @type {number}
  2310. */
  2311. Event.CAPTURING_PHASE = 1;
  2312. /**
  2313. * Constant of AT_TARGET.
  2314. * @type {number}
  2315. */
  2316. Event.AT_TARGET = 2;
  2317. /**
  2318. * Constant of BUBBLING_PHASE.
  2319. * @type {number}
  2320. */
  2321. Event.BUBBLING_PHASE = 3;
  2322. module.exports = Event;
  2323. },{}],9:[function(require,module,exports){
  2324. "use strict";
  2325. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2326. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2327. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2328. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2329. var __targetID = 0;
  2330. var __listenerMap = {
  2331. touch: {},
  2332. mouse: {},
  2333. keyboard: {},
  2334. devicemotion: {}
  2335. };
  2336. var __listenerCountMap = {
  2337. touch: 0,
  2338. mouse: 0,
  2339. keyboard: 0,
  2340. devicemotion: 0
  2341. };
  2342. var __enableCallbackMap = {
  2343. touch: null,
  2344. mouse: null,
  2345. keyboard: null,
  2346. //FIXME: Cocos Creator invokes addEventListener('devicemotion') when engine initializes, it will active sensor hardware.
  2347. // In that case, CPU and temperature cost will increase. Therefore, we require developer to invoke 'jsb.device.setMotionEnabled(true)'
  2348. // on native platforms since most games will not listen motion event.
  2349. devicemotion: null // devicemotion: function() {
  2350. // jsb.device.setMotionEnabled(true);
  2351. // }
  2352. };
  2353. var __disableCallbackMap = {
  2354. touch: null,
  2355. mouse: null,
  2356. //FIXME: Cocos Creator invokes addEventListener('devicemotion') when engine initializes, it will active sensor hardware.
  2357. // In that case, CPU and temperature cost will increase. Therefore, we require developer to invoke 'jsb.device.setMotionEnabled(true)'
  2358. // on native platforms since most games will not listen motion event.
  2359. keyboard: null,
  2360. devicemotion: null // devicemotion: function() {
  2361. // jsb.device.setMotionEnabled(false);
  2362. // }
  2363. };
  2364. var __handleEventNames = {
  2365. touch: ['touchstart', 'touchmove', 'touchend', 'touchcancel'],
  2366. mouse: ['mousedown', 'mousemove', 'mouseup', 'mousewheel'],
  2367. keyboard: ['keydown', 'keyup', 'keypress'],
  2368. devicemotion: ['devicemotion']
  2369. }; // Listener types
  2370. var CAPTURE = 1;
  2371. var BUBBLE = 2;
  2372. var ATTRIBUTE = 3;
  2373. /**
  2374. * Check whether a given value is an object or not.
  2375. * @param {any} x The value to check.
  2376. * @returns {boolean} `true` if the value is an object.
  2377. */
  2378. function isObject(x) {
  2379. return x && _typeof(x) === "object"; //eslint-disable-line no-restricted-syntax
  2380. }
  2381. /**
  2382. * EventTarget.
  2383. *
  2384. * - This is constructor if no arguments.
  2385. * - This is a function which returns a CustomEventTarget constructor if there are arguments.
  2386. *
  2387. * For example:
  2388. *
  2389. * class A extends EventTarget {}
  2390. */
  2391. var EventTarget = /*#__PURE__*/function () {
  2392. function EventTarget() {
  2393. _classCallCheck(this, EventTarget);
  2394. this._targetID = ++__targetID;
  2395. this._listenerCount = {
  2396. touch: 0,
  2397. mouse: 0,
  2398. keyboard: 0,
  2399. devicemotion: 0
  2400. };
  2401. this._listeners = new Map();
  2402. }
  2403. _createClass(EventTarget, [{
  2404. key: "_associateSystemEventListener",
  2405. value: function _associateSystemEventListener(eventName) {
  2406. var handleEventNames;
  2407. for (var key in __handleEventNames) {
  2408. handleEventNames = __handleEventNames[key];
  2409. if (handleEventNames.indexOf(eventName) > -1) {
  2410. if (__enableCallbackMap[key] && __listenerCountMap[key] === 0) {
  2411. __enableCallbackMap[key]();
  2412. }
  2413. if (this._listenerCount[key] === 0) __listenerMap[key][this._targetID] = this;
  2414. ++this._listenerCount[key];
  2415. ++__listenerCountMap[key];
  2416. break;
  2417. }
  2418. }
  2419. }
  2420. }, {
  2421. key: "_dissociateSystemEventListener",
  2422. value: function _dissociateSystemEventListener(eventName) {
  2423. var handleEventNames;
  2424. for (var key in __handleEventNames) {
  2425. handleEventNames = __handleEventNames[key];
  2426. if (handleEventNames.indexOf(eventName) > -1) {
  2427. if (this._listenerCount[key] <= 0) delete __listenerMap[key][this._targetID];
  2428. --__listenerCountMap[key];
  2429. if (__disableCallbackMap[key] && __listenerCountMap[key] === 0) {
  2430. __disableCallbackMap[key]();
  2431. }
  2432. break;
  2433. }
  2434. }
  2435. }
  2436. /**
  2437. * Add a given listener to this event target.
  2438. * @param {string} eventName The event name to add.
  2439. * @param {Function} listener The listener to add.
  2440. * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
  2441. * @returns {boolean} `true` if the listener was added actually.
  2442. */
  2443. }, {
  2444. key: "addEventListener",
  2445. value: function addEventListener(eventName, listener, options) {
  2446. if (!listener) {
  2447. return false;
  2448. }
  2449. if (typeof listener !== "function" && !isObject(listener)) {
  2450. throw new TypeError("'listener' should be a function or an object.");
  2451. }
  2452. var listeners = this._listeners;
  2453. var optionsIsObj = isObject(options);
  2454. var capture = optionsIsObj ? Boolean(options.capture) : Boolean(options);
  2455. var listenerType = capture ? CAPTURE : BUBBLE;
  2456. var newNode = {
  2457. listener: listener,
  2458. listenerType: listenerType,
  2459. passive: optionsIsObj && Boolean(options.passive),
  2460. once: optionsIsObj && Boolean(options.once),
  2461. next: null
  2462. }; // Set it as the first node if the first node is null.
  2463. var node = listeners.get(eventName);
  2464. if (node === undefined) {
  2465. listeners.set(eventName, newNode);
  2466. this._associateSystemEventListener(eventName);
  2467. return true;
  2468. } // Traverse to the tail while checking duplication..
  2469. var prev = null;
  2470. while (node) {
  2471. if (node.listener === listener && node.listenerType === listenerType) {
  2472. // Should ignore duplication.
  2473. return false;
  2474. }
  2475. prev = node;
  2476. node = node.next;
  2477. } // Add it.
  2478. prev.next = newNode;
  2479. this._associateSystemEventListener(eventName);
  2480. return true;
  2481. }
  2482. /**
  2483. * Remove a given listener from this event target.
  2484. * @param {string} eventName The event name to remove.
  2485. * @param {Function} listener The listener to remove.
  2486. * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
  2487. * @returns {boolean} `true` if the listener was removed actually.
  2488. */
  2489. }, {
  2490. key: "removeEventListener",
  2491. value: function removeEventListener(eventName, listener, options) {
  2492. if (!listener) {
  2493. return false;
  2494. }
  2495. var listeners = this._listeners;
  2496. var capture = isObject(options) ? Boolean(options.capture) : Boolean(options);
  2497. var listenerType = capture ? CAPTURE : BUBBLE;
  2498. var prev = null;
  2499. var node = listeners.get(eventName);
  2500. while (node) {
  2501. if (node.listener === listener && node.listenerType === listenerType) {
  2502. if (prev) {
  2503. prev.next = node.next;
  2504. } else if (node.next) {
  2505. listeners.set(eventName, node.next);
  2506. } else {
  2507. listeners["delete"](eventName);
  2508. }
  2509. this._dissociateSystemEventListener(eventName);
  2510. return true;
  2511. }
  2512. prev = node;
  2513. node = node.next;
  2514. }
  2515. return false;
  2516. }
  2517. /**
  2518. * Dispatch a given event.
  2519. * @param {Event|{type:string}} event The event to dispatch.
  2520. * @returns {boolean} `false` if canceled.
  2521. */
  2522. }, {
  2523. key: "dispatchEvent",
  2524. value: function dispatchEvent(event) {
  2525. if (!event || typeof event.type !== "string") {
  2526. throw new TypeError("\"event.type\" should be a string.");
  2527. }
  2528. var eventName = event.type;
  2529. var onFunc = this['on' + eventName];
  2530. if (onFunc && typeof onFunc === 'function') {
  2531. event._target = event._currentTarget = this;
  2532. onFunc.call(this, event);
  2533. event._target = event._currentTarget = null;
  2534. event._eventPhase = 0;
  2535. event._passiveListener = null;
  2536. if (event.defaultPrevented) return false;
  2537. } // If listeners aren't registered, terminate.
  2538. var listeners = this._listeners;
  2539. var node = listeners.get(eventName);
  2540. if (!node) {
  2541. return true;
  2542. }
  2543. event._target = event._currentTarget = this; // This doesn't process capturing phase and bubbling phase.
  2544. // This isn't participating in a tree.
  2545. var prev = null;
  2546. while (node) {
  2547. // Remove this listener if it's once
  2548. if (node.once) {
  2549. if (prev) {
  2550. prev.next = node.next;
  2551. } else if (node.next) {
  2552. listeners.set(eventName, node.next);
  2553. } else {
  2554. listeners["delete"](eventName);
  2555. }
  2556. } else {
  2557. prev = node;
  2558. } // Call this listener
  2559. event._passiveListener = node.passive ? node.listener : null;
  2560. if (typeof node.listener === "function") {
  2561. node.listener.call(this, event);
  2562. } // Break if `event.stopImmediatePropagation` was called.
  2563. if (event._stopped) {
  2564. break;
  2565. }
  2566. node = node.next;
  2567. }
  2568. event._target = event._currentTarget = null;
  2569. event._eventPhase = 0;
  2570. event._passiveListener = null;
  2571. return !event.defaultPrevented;
  2572. }
  2573. }]);
  2574. return EventTarget;
  2575. }();
  2576. function touchEventHandlerFactory(type) {
  2577. return function (touches) {
  2578. var touchEvent = new TouchEvent(type);
  2579. touchEvent.touches = touches;
  2580. touchEvent.targetTouches = Array.prototype.slice.call(touchEvent.touches);
  2581. touchEvent.changedTouches = touches; //event.changedTouches
  2582. // touchEvent.timeStamp = event.timeStamp
  2583. var i = 0,
  2584. touchCount = touches.length;
  2585. var target;
  2586. var touchListenerMap = __listenerMap.touch;
  2587. for (var key in touchListenerMap) {
  2588. target = touchListenerMap[key];
  2589. for (i = 0; i < touchCount; ++i) {
  2590. touches[i].target = target;
  2591. }
  2592. target.dispatchEvent(touchEvent);
  2593. }
  2594. };
  2595. }
  2596. jsb.onTouchStart = touchEventHandlerFactory('touchstart');
  2597. jsb.onTouchMove = touchEventHandlerFactory('touchmove');
  2598. jsb.onTouchEnd = touchEventHandlerFactory('touchend');
  2599. jsb.onTouchCancel = touchEventHandlerFactory('touchcancel');
  2600. function mouseEventHandlerFactory(type) {
  2601. return function (event) {
  2602. var button = event.button;
  2603. var x = event.x;
  2604. var y = event.y;
  2605. var mouseEvent = new MouseEvent(type, {
  2606. button: button,
  2607. which: button + 1,
  2608. wheelDelta: event.wheelDeltaY,
  2609. clientX: x,
  2610. clientY: y,
  2611. screenX: x,
  2612. screenY: y,
  2613. pageX: x,
  2614. pageY: y
  2615. });
  2616. var target;
  2617. var mouseListenerMap = __listenerMap.mouse;
  2618. for (var key in mouseListenerMap) {
  2619. target = mouseListenerMap[key];
  2620. target.dispatchEvent(mouseEvent);
  2621. }
  2622. };
  2623. }
  2624. jsb.onMouseDown = mouseEventHandlerFactory('mousedown');
  2625. jsb.onMouseMove = mouseEventHandlerFactory('mousemove');
  2626. jsb.onMouseUp = mouseEventHandlerFactory('mouseup');
  2627. jsb.onMouseWheel = mouseEventHandlerFactory('mousewheel');
  2628. function keyboardEventHandlerFactory(type) {
  2629. return function (event) {
  2630. var keyboardEvent = new KeyboardEvent(type, {
  2631. altKey: event.altKey,
  2632. ctrlKey: event.ctrlKey,
  2633. metaKey: event.metaKey,
  2634. shiftKey: event.shiftKey,
  2635. repeat: event.repeat,
  2636. keyCode: event.keyCode
  2637. });
  2638. var target;
  2639. var keyboardListenerMap = __listenerMap.keyboard;
  2640. for (var key in keyboardListenerMap) {
  2641. target = keyboardListenerMap[key];
  2642. target.dispatchEvent(keyboardEvent);
  2643. }
  2644. };
  2645. }
  2646. jsb.onKeyDown = keyboardEventHandlerFactory('keydown');
  2647. jsb.onKeyUp = keyboardEventHandlerFactory('keyup');
  2648. jsb.device.dispatchDeviceMotionEvent = function (event) {
  2649. var target;
  2650. var devicemotionListenerMap = __listenerMap.devicemotion;
  2651. for (var key in devicemotionListenerMap) {
  2652. target = devicemotionListenerMap[key];
  2653. target.dispatchEvent(event);
  2654. }
  2655. };
  2656. module.exports = EventTarget;
  2657. },{}],10:[function(require,module,exports){
  2658. "use strict";
  2659. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2660. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2661. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2662. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2663. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2664. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2665. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2666. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2667. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2668. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2669. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2670. var EventTarget = require('./EventTarget');
  2671. var FileReader = /*#__PURE__*/function (_EventTarget) {
  2672. _inherits(FileReader, _EventTarget);
  2673. var _super = _createSuper(FileReader);
  2674. function FileReader() {
  2675. _classCallCheck(this, FileReader);
  2676. return _super.apply(this, arguments);
  2677. }
  2678. _createClass(FileReader, [{
  2679. key: "construct",
  2680. value: function construct() {
  2681. this.result = null;
  2682. } // Aborts the read operation. Upon return, the readyState will be DONE.
  2683. }, {
  2684. key: "abort",
  2685. value: function abort() {} // Starts reading the contents of the specified Blob, once finished, the result attribute contains an ArrayBuffer representing the file's data.
  2686. }, {
  2687. key: "readAsArrayBuffer",
  2688. value: function readAsArrayBuffer() {} // Starts reading the contents of the specified Blob, once finished, the result attribute contains a data: URL representing the file's data.
  2689. }, {
  2690. key: "readAsDataURL",
  2691. value: function readAsDataURL(blob) {
  2692. this.result = 'data:image/png;base64,' + window.btoa(blob);
  2693. var event = new Event('load');
  2694. this.dispatchEvent(event);
  2695. } // Starts reading the contents of the specified Blob, once finished, the result attribute contains the contents of the file as a text string.
  2696. }, {
  2697. key: "readAsText",
  2698. value: function readAsText() {}
  2699. }]);
  2700. return FileReader;
  2701. }(EventTarget);
  2702. module.exports = FileReader;
  2703. },{"./EventTarget":9}],11:[function(require,module,exports){
  2704. "use strict";
  2705. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2706. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2707. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2708. var FontFace = /*#__PURE__*/function () {
  2709. function FontFace(family, source, descriptors) {
  2710. var _this = this;
  2711. _classCallCheck(this, FontFace);
  2712. this.family = family;
  2713. this.source = source;
  2714. this.descriptors = descriptors;
  2715. this._status = 'unloaded';
  2716. this._loaded = new Promise(function (resolve, reject) {
  2717. _this._resolveCB = resolve;
  2718. _this._rejectCB = reject;
  2719. });
  2720. }
  2721. _createClass(FontFace, [{
  2722. key: "load",
  2723. value: function load() {// class FontFaceSet, add(fontFace) have done the load work
  2724. }
  2725. }, {
  2726. key: "status",
  2727. get: function get() {
  2728. return this._status;
  2729. }
  2730. }, {
  2731. key: "loaded",
  2732. get: function get() {
  2733. return this._loaded;
  2734. }
  2735. }]);
  2736. return FontFace;
  2737. }();
  2738. module.exports = FontFace;
  2739. },{}],12:[function(require,module,exports){
  2740. "use strict";
  2741. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2742. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2743. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2744. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2745. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2746. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2747. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2748. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2749. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2750. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2751. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2752. var EventTarget = require('./EventTarget');
  2753. var Event = require('./Event');
  2754. var FontFaceSet = /*#__PURE__*/function (_EventTarget) {
  2755. _inherits(FontFaceSet, _EventTarget);
  2756. var _super = _createSuper(FontFaceSet);
  2757. function FontFaceSet() {
  2758. var _this;
  2759. _classCallCheck(this, FontFaceSet);
  2760. _this = _super.call(this);
  2761. _this._status = 'loading';
  2762. return _this;
  2763. }
  2764. _createClass(FontFaceSet, [{
  2765. key: "status",
  2766. get: function get() {
  2767. return this._status;
  2768. }
  2769. }, {
  2770. key: "onloading",
  2771. set: function set(listener) {
  2772. this.addEventListener('loading', listener);
  2773. }
  2774. }, {
  2775. key: "onloadingdone",
  2776. set: function set(listener) {
  2777. this.addEventListener('loadingdone', listener);
  2778. }
  2779. }, {
  2780. key: "onloadingerror",
  2781. set: function set(listener) {
  2782. this.addEventListener('loadingerror', listener);
  2783. }
  2784. }, {
  2785. key: "add",
  2786. value: function add(fontFace) {
  2787. var _this2 = this;
  2788. this._status = fontFace._status = 'loading';
  2789. this.dispatchEvent(new Event('loading')); // Call native binding method to set the ttf font to native platform.
  2790. var family = jsb.loadFont(fontFace.family, fontFace.source);
  2791. setTimeout(function () {
  2792. if (family) {
  2793. fontFace._status = _this2._status = 'loaded';
  2794. fontFace._resolveCB();
  2795. _this2.dispatchEvent(new Event('loadingdone'));
  2796. } else {
  2797. fontFace._status = _this2._status = 'error';
  2798. fontFace._rejectCB();
  2799. _this2.dispatchEvent(new Event('loadingerror'));
  2800. }
  2801. }, 0);
  2802. }
  2803. }, {
  2804. key: "clear",
  2805. value: function clear() {}
  2806. }, {
  2807. key: "delete",
  2808. value: function _delete() {}
  2809. }, {
  2810. key: "load",
  2811. value: function load() {}
  2812. }, {
  2813. key: "ready",
  2814. value: function ready() {}
  2815. }]);
  2816. return FontFaceSet;
  2817. }(EventTarget);
  2818. module.exports = FontFaceSet;
  2819. },{"./Event":8,"./EventTarget":9}],13:[function(require,module,exports){
  2820. "use strict";
  2821. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2822. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2823. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2824. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2825. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2826. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2827. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2828. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2829. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2830. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2831. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2832. var HTMLElement = require('./HTMLElement');
  2833. var ImageData = require('./ImageData');
  2834. var DOMRect = require('./DOMRect');
  2835. var clamp = function clamp(value) {
  2836. value = Math.round(value);
  2837. return value < 0 ? 0 : value < 255 ? value : 255;
  2838. };
  2839. var CanvasGradient = /*#__PURE__*/function () {
  2840. function CanvasGradient() {
  2841. _classCallCheck(this, CanvasGradient);
  2842. console.log("==> CanvasGradient constructor");
  2843. }
  2844. _createClass(CanvasGradient, [{
  2845. key: "addColorStop",
  2846. value: function addColorStop(offset, color) {
  2847. console.log("==> CanvasGradient addColorStop");
  2848. }
  2849. }]);
  2850. return CanvasGradient;
  2851. }();
  2852. var TextMetrics = /*#__PURE__*/function () {
  2853. function TextMetrics(width) {
  2854. _classCallCheck(this, TextMetrics);
  2855. this._width = width;
  2856. }
  2857. _createClass(TextMetrics, [{
  2858. key: "width",
  2859. get: function get() {
  2860. return this._width;
  2861. }
  2862. }]);
  2863. return TextMetrics;
  2864. }();
  2865. var HTMLCanvasElement = /*#__PURE__*/function (_HTMLElement) {
  2866. _inherits(HTMLCanvasElement, _HTMLElement);
  2867. var _super = _createSuper(HTMLCanvasElement);
  2868. function HTMLCanvasElement(width, height) {
  2869. var _this;
  2870. _classCallCheck(this, HTMLCanvasElement);
  2871. _this = _super.call(this, 'canvas');
  2872. _this.id = 'glcanvas';
  2873. _this.type = 'canvas';
  2874. _this.top = 0;
  2875. _this.left = 0;
  2876. _this._width = width ? Math.ceil(width) : 0;
  2877. _this._height = height ? Math.ceil(height) : 0;
  2878. _this._context2D = null;
  2879. _this._data = null;
  2880. _this._alignment = 4; // Canvas is used for rendering text only and we make sure the data format is RGBA.
  2881. // Whether the pixel data is premultiplied.
  2882. _this._premultiplied = false;
  2883. return _this;
  2884. } //REFINE: implement opts.
  2885. _createClass(HTMLCanvasElement, [{
  2886. key: "getContext",
  2887. value: function getContext(name, opts) {
  2888. var self = this; // console.log(`==> Canvas getContext(${name})`);
  2889. if (name === 'webgl' || name === 'experimental-webgl') {
  2890. if (this === window.__canvas) return window.__gl;else return null;
  2891. } else if (name === '2d') {
  2892. if (!this._context2D) {
  2893. this._context2D = new CanvasRenderingContext2D(this._width, this._height);
  2894. this._data = new ImageData(this._width, this._height);
  2895. this._context2D._canvas = this;
  2896. this._context2D._setCanvasBufferUpdatedCallback(function (data) {
  2897. // FIXME: Canvas's data will take 2x memory size, one in C++, another is obtained by Uint8Array here.
  2898. self._data = new ImageData(data, self._width, self._height); // If the width of canvas could be divided by 2, it means that the bytes per row could be divided by 8.
  2899. self._alignment = self._width % 2 === 0 ? 8 : 4;
  2900. });
  2901. }
  2902. return this._context2D;
  2903. }
  2904. return null;
  2905. }
  2906. }, {
  2907. key: "width",
  2908. get: function get() {
  2909. return this._width;
  2910. },
  2911. set: function set(width) {
  2912. width = Math.ceil(width);
  2913. if (this._width !== width) {
  2914. this._width = width;
  2915. if (this._context2D) {
  2916. this._context2D._width = width;
  2917. }
  2918. }
  2919. }
  2920. }, {
  2921. key: "height",
  2922. get: function get() {
  2923. return this._height;
  2924. },
  2925. set: function set(height) {
  2926. height = Math.ceil(height);
  2927. if (this._height !== height) {
  2928. this._height = height;
  2929. if (this._context2D) {
  2930. this._context2D._height = height;
  2931. }
  2932. }
  2933. }
  2934. }, {
  2935. key: "clientWidth",
  2936. get: function get() {
  2937. return window.innerWidth;
  2938. }
  2939. }, {
  2940. key: "clientHeight",
  2941. get: function get() {
  2942. return window.innerHeight;
  2943. }
  2944. }, {
  2945. key: "data",
  2946. get: function get() {
  2947. if (this._data) {
  2948. return this._data.data;
  2949. }
  2950. return null;
  2951. }
  2952. }, {
  2953. key: "getBoundingClientRect",
  2954. value: function getBoundingClientRect() {
  2955. return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
  2956. }
  2957. }]);
  2958. return HTMLCanvasElement;
  2959. }(HTMLElement);
  2960. var ctx2DProto = CanvasRenderingContext2D.prototype; // ImageData ctx.createImageData(imagedata);
  2961. // ImageData ctx.createImageData(width, height);
  2962. ctx2DProto.createImageData = function (args1, args2) {
  2963. if (typeof args1 === 'number' && typeof args2 == 'number') {
  2964. return new ImageData(args1, args2);
  2965. } else if (args1 instanceof ImageData) {
  2966. return new ImageData(args1.data, args1.width, args1.height);
  2967. }
  2968. }; // void ctx.putImageData(imagedata, dx, dy);
  2969. // void ctx.putImageData(imagedata, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight);
  2970. ctx2DProto.putImageData = function (imageData, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight) {
  2971. if (typeof loadRuntime === "function") {
  2972. var height = imageData.height;
  2973. var width = imageData.width;
  2974. var canvasWidth = this._canvas._width;
  2975. var canvasHeight = this._canvas._height;
  2976. dirtyX = dirtyX || 0;
  2977. dirtyY = dirtyY || 0;
  2978. dirtyWidth = dirtyWidth !== undefined ? dirtyWidth : width;
  2979. dirtyHeight = dirtyHeight !== undefined ? dirtyHeight : height;
  2980. var limitBottom = dirtyY + dirtyHeight;
  2981. var limitRight = dirtyX + dirtyWidth; // shrink dirty rect if next image rect bigger than canvas rect
  2982. dirtyHeight = limitBottom < canvasHeight ? dirtyHeight : dirtyHeight - (limitBottom - canvasHeight);
  2983. dirtyWidth = limitRight < canvasWidth ? dirtyWidth : dirtyWidth - (limitRight - canvasWidth); // collect data needed to put
  2984. dirtyWidth = Math.floor(dirtyWidth);
  2985. dirtyHeight = Math.floor(dirtyHeight);
  2986. var imageToFill = new ImageData(dirtyWidth, dirtyHeight);
  2987. for (var y = dirtyY; y < limitBottom; y++) {
  2988. for (var x = dirtyX; x < limitRight; x++) {
  2989. var imgPos = y * width + x;
  2990. var toPos = (y - dirtyY) * dirtyWidth + (x - dirtyX);
  2991. imageToFill.data[toPos * 4 + 0] = imageData.data[imgPos * 4 + 0];
  2992. imageToFill.data[toPos * 4 + 1] = imageData.data[imgPos * 4 + 1];
  2993. imageToFill.data[toPos * 4 + 2] = imageData.data[imgPos * 4 + 2];
  2994. imageToFill.data[toPos * 4 + 3] = imageData.data[imgPos * 4 + 3];
  2995. }
  2996. } // do image data write operation at Native (only impl on Android)
  2997. this._fillImageData(imageToFill.data, dirtyWidth, dirtyHeight, dx, dy);
  2998. } else {
  2999. this._canvas._data = imageData;
  3000. }
  3001. }; // ImageData ctx.getImageData(sx, sy, sw, sh);
  3002. ctx2DProto.getImageData = function (sx, sy, sw, sh) {
  3003. var canvasWidth = this._canvas._width;
  3004. var canvasHeight = this._canvas._height;
  3005. var canvasBuffer = this._canvas._data.data; // image rect may bigger that canvas rect
  3006. var maxValidSH = sh + sy < canvasHeight ? sh : canvasHeight - sy;
  3007. var maxValidSW = sw + sx < canvasWidth ? sw : canvasWidth - sx;
  3008. var imgBuffer = new Uint8ClampedArray(sw * sh * 4);
  3009. for (var y = 0; y < maxValidSH; y++) {
  3010. for (var x = 0; x < maxValidSW; x++) {
  3011. var canvasPos = (y + sy) * canvasWidth + (x + sx);
  3012. var imgPos = y * sw + x;
  3013. imgBuffer[imgPos * 4 + 0] = canvasBuffer[canvasPos * 4 + 0];
  3014. imgBuffer[imgPos * 4 + 1] = canvasBuffer[canvasPos * 4 + 1];
  3015. imgBuffer[imgPos * 4 + 2] = canvasBuffer[canvasPos * 4 + 2];
  3016. imgBuffer[imgPos * 4 + 3] = canvasBuffer[canvasPos * 4 + 3];
  3017. }
  3018. }
  3019. return new ImageData(imgBuffer, sw, sh);
  3020. };
  3021. module.exports = HTMLCanvasElement;
  3022. },{"./DOMRect":5,"./HTMLElement":14,"./ImageData":20}],14:[function(require,module,exports){
  3023. "use strict";
  3024. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3025. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3026. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3027. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3028. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3029. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3030. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3031. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3032. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3033. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3034. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3035. var Element = require('./Element');
  3036. var _require = require('./util'),
  3037. noop = _require.noop;
  3038. var HTMLElement = /*#__PURE__*/function (_Element) {
  3039. _inherits(HTMLElement, _Element);
  3040. var _super = _createSuper(HTMLElement);
  3041. function HTMLElement() {
  3042. var _this;
  3043. var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  3044. _classCallCheck(this, HTMLElement);
  3045. _this = _super.call(this);
  3046. _this.tagName = tagName.toUpperCase();
  3047. _this.className = '';
  3048. _this.children = [];
  3049. _this.style = {
  3050. width: "".concat(window.innerWidth, "px"),
  3051. height: "".concat(window.innerHeight, "px")
  3052. };
  3053. _this.innerHTML = '';
  3054. _this.parentElement = window.__canvas;
  3055. return _this;
  3056. }
  3057. _createClass(HTMLElement, [{
  3058. key: "setAttribute",
  3059. value: function setAttribute(name, value) {
  3060. this[name] = value;
  3061. }
  3062. }, {
  3063. key: "getAttribute",
  3064. value: function getAttribute(name) {
  3065. return this[name];
  3066. }
  3067. }, {
  3068. key: "focus",
  3069. value: function focus() {}
  3070. }]);
  3071. return HTMLElement;
  3072. }(Element);
  3073. module.exports = HTMLElement;
  3074. },{"./Element":7,"./util":30}],15:[function(require,module,exports){
  3075. "use strict";
  3076. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3077. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3078. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3079. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3080. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3081. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3082. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3083. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3084. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3085. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3086. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3087. var HTMLElement = require('./HTMLElement');
  3088. var Event = require('./Event');
  3089. var gl = window.__gl;
  3090. var HTMLImageElement = /*#__PURE__*/function (_HTMLElement) {
  3091. _inherits(HTMLImageElement, _HTMLElement);
  3092. var _super = _createSuper(HTMLImageElement);
  3093. function HTMLImageElement(width, height, isCalledFromImage) {
  3094. var _this;
  3095. _classCallCheck(this, HTMLImageElement);
  3096. if (!isCalledFromImage) {
  3097. throw new TypeError("Illegal constructor, use 'new Image(w, h); instead!'");
  3098. return _possibleConstructorReturn(_this);
  3099. }
  3100. _this = _super.call(this, 'img');
  3101. _this.width = width ? width : 0;
  3102. _this.height = height ? height : 0;
  3103. _this._data = null;
  3104. _this._src = null;
  3105. _this.complete = false;
  3106. _this._glFormat = _this._glInternalFormat = gl.RGBA;
  3107. _this.crossOrigin = null;
  3108. return _this;
  3109. }
  3110. _createClass(HTMLImageElement, [{
  3111. key: "src",
  3112. get: function get() {
  3113. return this._src;
  3114. },
  3115. set: function set(src) {
  3116. var _this2 = this;
  3117. this._src = src;
  3118. jsb.loadImage(src, function (info) {
  3119. if (!info) {
  3120. _this2._data = null;
  3121. return;
  3122. } else if (info && info.errorMsg) {
  3123. _this2._data = null;
  3124. var event = new Event('error');
  3125. _this2.dispatchEvent(event);
  3126. return;
  3127. }
  3128. _this2.width = _this2.naturalWidth = info.width;
  3129. _this2.height = _this2.naturalHeight = info.height;
  3130. _this2._data = info.data; // console.log(`glFormat: ${info.glFormat}, glInternalFormat: ${info.glInternalFormat}, glType: ${info.glType}`);
  3131. _this2._glFormat = info.glFormat;
  3132. _this2._glInternalFormat = info.glInternalFormat;
  3133. _this2._glType = info.glType;
  3134. _this2._numberOfMipmaps = info.numberOfMipmaps;
  3135. _this2._compressed = info.compressed;
  3136. _this2._bpp = info.bpp;
  3137. _this2._premultiplyAlpha = info.premultiplyAlpha;
  3138. _this2._alignment = 1; // Set the row align only when mipmapsNum == 1 and the data is uncompressed
  3139. if ((_this2._numberOfMipmaps == 0 || _this2._numberOfMipmaps == 1) && !_this2._compressed) {
  3140. var bytesPerRow = _this2.width * _this2._bpp / 8;
  3141. if (bytesPerRow % 8 == 0) _this2._alignment = 8;else if (bytesPerRow % 4 == 0) _this2._alignment = 4;else if (bytesPerRow % 2 == 0) _this2._alignment = 2;
  3142. }
  3143. _this2.complete = true;
  3144. var event = new Event('load');
  3145. _this2.dispatchEvent(event);
  3146. });
  3147. }
  3148. }, {
  3149. key: "clientWidth",
  3150. get: function get() {
  3151. return this.width;
  3152. }
  3153. }, {
  3154. key: "clientHeight",
  3155. get: function get() {
  3156. return this.height;
  3157. }
  3158. }, {
  3159. key: "getBoundingClientRect",
  3160. value: function getBoundingClientRect() {
  3161. return new DOMRect(0, 0, this.width, this.height);
  3162. }
  3163. }]);
  3164. return HTMLImageElement;
  3165. }(HTMLElement);
  3166. module.exports = HTMLImageElement;
  3167. },{"./Event":8,"./HTMLElement":14}],16:[function(require,module,exports){
  3168. "use strict";
  3169. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3170. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3171. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3172. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3173. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3174. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3175. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3176. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3177. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3178. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3179. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3180. var HTMLElement = require('./HTMLElement');
  3181. var MediaError = require('./MediaError');
  3182. var HAVE_NOTHING = 0;
  3183. var HAVE_METADATA = 1;
  3184. var HAVE_CURRENT_DATA = 2;
  3185. var HAVE_FUTURE_DATA = 3;
  3186. var HAVE_ENOUGH_DATA = 4;
  3187. var HTMLMediaElement = /*#__PURE__*/function (_HTMLElement) {
  3188. _inherits(HTMLMediaElement, _HTMLElement);
  3189. var _super = _createSuper(HTMLMediaElement);
  3190. function HTMLMediaElement(type) {
  3191. var _this;
  3192. _classCallCheck(this, HTMLMediaElement);
  3193. _this = _super.call(this, type);
  3194. _this._volume = 1.0;
  3195. _this._duration = 0;
  3196. _this._isEnded = false;
  3197. _this._isMute = false;
  3198. _this._readyState = HAVE_NOTHING;
  3199. _this._error = new MediaError();
  3200. return _this;
  3201. }
  3202. _createClass(HTMLMediaElement, [{
  3203. key: "addTextTrack",
  3204. value: function addTextTrack() {}
  3205. }, {
  3206. key: "captureStream",
  3207. value: function captureStream() {}
  3208. }, {
  3209. key: "fastSeek",
  3210. value: function fastSeek() {}
  3211. }, {
  3212. key: "load",
  3213. value: function load() {}
  3214. }, {
  3215. key: "pause",
  3216. value: function pause() {}
  3217. }, {
  3218. key: "play",
  3219. value: function play() {}
  3220. }, {
  3221. key: "canPlayType",
  3222. value: function canPlayType(mediaType) {
  3223. return '';
  3224. }
  3225. }, {
  3226. key: "volume",
  3227. get: function get() {
  3228. return this._volume;
  3229. },
  3230. set: function set(volume) {
  3231. this._volume = volume;
  3232. }
  3233. }, {
  3234. key: "duration",
  3235. get: function get() {
  3236. return this._duration;
  3237. }
  3238. }, {
  3239. key: "ended",
  3240. get: function get() {
  3241. return this._isEnded;
  3242. }
  3243. }, {
  3244. key: "muted",
  3245. get: function get() {
  3246. return this._isMute;
  3247. }
  3248. }, {
  3249. key: "readyState",
  3250. get: function get() {
  3251. return this._readyState;
  3252. }
  3253. }, {
  3254. key: "error",
  3255. get: function get() {
  3256. return this._error;
  3257. }
  3258. }, {
  3259. key: "currentTime",
  3260. get: function get() {
  3261. return 0;
  3262. }
  3263. }]);
  3264. return HTMLMediaElement;
  3265. }(HTMLElement);
  3266. module.exports = HTMLMediaElement;
  3267. },{"./HTMLElement":14,"./MediaError":22}],17:[function(require,module,exports){
  3268. "use strict";
  3269. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3270. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3271. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3272. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3273. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3274. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3275. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3276. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3277. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3278. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3279. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3280. var HTMLElement = require('./HTMLElement');
  3281. var Event = require('./Event');
  3282. var HTMLScriptElement = /*#__PURE__*/function (_HTMLElement) {
  3283. _inherits(HTMLScriptElement, _HTMLElement);
  3284. var _super = _createSuper(HTMLScriptElement);
  3285. function HTMLScriptElement(width, height) {
  3286. _classCallCheck(this, HTMLScriptElement);
  3287. return _super.call(this, 'script');
  3288. }
  3289. _createClass(HTMLScriptElement, [{
  3290. key: "src",
  3291. set: function set(url) {
  3292. var _this = this;
  3293. setTimeout(function () {
  3294. require(url);
  3295. _this.dispatchEvent(new Event('load'));
  3296. }, 0);
  3297. }
  3298. }]);
  3299. return HTMLScriptElement;
  3300. }(HTMLElement);
  3301. module.exports = HTMLScriptElement;
  3302. },{"./Event":8,"./HTMLElement":14}],18:[function(require,module,exports){
  3303. "use strict";
  3304. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3305. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3306. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3307. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3308. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3309. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3310. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3311. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3312. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3313. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3314. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3315. var HTMLMediaElement = require('./HTMLMediaElement');
  3316. var HTMLVideoElement = /*#__PURE__*/function (_HTMLMediaElement) {
  3317. _inherits(HTMLVideoElement, _HTMLMediaElement);
  3318. var _super = _createSuper(HTMLVideoElement);
  3319. function HTMLVideoElement() {
  3320. _classCallCheck(this, HTMLVideoElement);
  3321. return _super.call(this, 'video');
  3322. }
  3323. _createClass(HTMLVideoElement, [{
  3324. key: "canPlayType",
  3325. value: function canPlayType(type) {
  3326. if (type === 'video/mp4') return true;
  3327. return false;
  3328. }
  3329. }]);
  3330. return HTMLVideoElement;
  3331. }(HTMLMediaElement);
  3332. module.exports = HTMLVideoElement;
  3333. },{"./HTMLMediaElement":16}],19:[function(require,module,exports){
  3334. "use strict";
  3335. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3336. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3337. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3338. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3339. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3340. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3341. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3342. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3343. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3344. var HTMLImageElement = require('./HTMLImageElement');
  3345. var Image = /*#__PURE__*/function (_HTMLImageElement) {
  3346. _inherits(Image, _HTMLImageElement);
  3347. var _super = _createSuper(Image);
  3348. function Image(width, height) {
  3349. _classCallCheck(this, Image);
  3350. return _super.call(this, width, height, true);
  3351. }
  3352. return Image;
  3353. }(HTMLImageElement);
  3354. module.exports = Image;
  3355. },{"./HTMLImageElement":15}],20:[function(require,module,exports){
  3356. "use strict";
  3357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3358. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3359. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3360. var ImageData = /*#__PURE__*/function () {
  3361. // var imageData = new ImageData(array, width, height);
  3362. // var imageData = new ImageData(width, height);
  3363. function ImageData(array, width, height) {
  3364. _classCallCheck(this, ImageData);
  3365. if (typeof array === 'number' && typeof width == 'number') {
  3366. height = width;
  3367. width = array;
  3368. array = null;
  3369. }
  3370. if (array === null) {
  3371. this._data = new Uint8ClampedArray(width * height * 4);
  3372. } else {
  3373. this._data = array;
  3374. }
  3375. this._width = width;
  3376. this._height = height;
  3377. }
  3378. _createClass(ImageData, [{
  3379. key: "data",
  3380. get: function get() {
  3381. return this._data;
  3382. }
  3383. }, {
  3384. key: "width",
  3385. get: function get() {
  3386. return this._width;
  3387. }
  3388. }, {
  3389. key: "height",
  3390. get: function get() {
  3391. return this._height;
  3392. }
  3393. }]);
  3394. return ImageData;
  3395. }();
  3396. module.exports = ImageData;
  3397. },{}],21:[function(require,module,exports){
  3398. "use strict";
  3399. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3400. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3401. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3402. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3403. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3404. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3405. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3406. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3407. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3408. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3409. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3410. var Event = require('./Event');
  3411. var __numberShiftMap = {
  3412. '48': ')',
  3413. // 0
  3414. '49': '!',
  3415. // 1
  3416. '50': '@',
  3417. // 2
  3418. '51': '#',
  3419. // 3
  3420. '52': '$',
  3421. // 4
  3422. '53': '%',
  3423. // 5
  3424. '54': '^',
  3425. // 6
  3426. '55': '&',
  3427. // 7
  3428. '56': '*',
  3429. // 8
  3430. '57': '(' // 9
  3431. };
  3432. var __capsLockActive = false;
  3433. var KeyboardEvent = /*#__PURE__*/function (_Event) {
  3434. _inherits(KeyboardEvent, _Event);
  3435. var _super = _createSuper(KeyboardEvent);
  3436. function KeyboardEvent(type, KeyboardEventInit) {
  3437. var _this;
  3438. _classCallCheck(this, KeyboardEvent);
  3439. _this = _super.call(this, type);
  3440. if (_typeof(KeyboardEventInit) === 'object') {
  3441. _this._altKeyActive = KeyboardEventInit.altKey ? KeyboardEventInit.altKey : false;
  3442. _this._ctrlKeyActive = KeyboardEventInit.ctrlKey ? KeyboardEventInit.ctrlKey : false;
  3443. _this._metaKeyActive = KeyboardEventInit.metaKey ? KeyboardEventInit.metaKey : false;
  3444. _this._shiftKeyActive = KeyboardEventInit.shiftKey ? KeyboardEventInit.shiftKey : false;
  3445. _this._keyCode = KeyboardEventInit.keyCode ? KeyboardEventInit.keyCode : -1;
  3446. _this._repeat = KeyboardEventInit.repeat ? KeyboardEventInit.repeat : false;
  3447. } else {
  3448. _this._altKeyActive = false;
  3449. _this._ctrlKeyActive = false;
  3450. _this._metaKeyActive = false;
  3451. _this._shiftKeyActive = false;
  3452. _this._keyCode = -1;
  3453. _this._repeat = false;
  3454. }
  3455. var keyCode = _this._keyCode;
  3456. if (keyCode >= 48 && keyCode <= 57) {
  3457. // 0 ~ 9
  3458. var number = keyCode - 48;
  3459. _this._code = 'Digit' + number;
  3460. _this._key = _this._shiftKeyActive ? __numberShiftMap[keyCode] : '' + number;
  3461. } else if (keyCode >= 10048 && keyCode <= 10057) {
  3462. // Numberpad 0 ~ 9
  3463. // reset to web keyCode since it's a hack in C++ for distinguish numbers in Numberpad.
  3464. keyCode = _this._keyCode = keyCode - 10000;
  3465. var number = keyCode - 48;
  3466. _this._code = 'Numpad' + number;
  3467. _this._key = '' + number;
  3468. } else if (keyCode >= 65 && keyCode <= 90) {
  3469. // A ~ Z
  3470. var charCode = String.fromCharCode(keyCode);
  3471. _this._code = 'Key' + charCode;
  3472. _this._key = _this._shiftKeyActive || __capsLockActive ? charCode : charCode.toLowerCase();
  3473. } else if (keyCode >= 112 && keyCode <= 123) {
  3474. // F1 ~ F12
  3475. _this._code = _this._key = 'F' + (keyCode - 111);
  3476. } else if (keyCode === 27) {
  3477. _this._code = _this._key = 'Escape';
  3478. } else if (keyCode === 189) {
  3479. _this._code = 'Minus';
  3480. _this._key = _this._shiftKeyActive ? '_' : '-';
  3481. } else if (keyCode === 187) {
  3482. _this._code = 'Equal';
  3483. _this._key = _this._shiftKeyActive ? '+' : '=';
  3484. } else if (keyCode === 220) {
  3485. _this._code = 'Backslash';
  3486. _this._key = _this._shiftKeyActive ? '|' : '\\';
  3487. } else if (keyCode === 192) {
  3488. _this._code = 'Backquote';
  3489. _this._key = _this._shiftKeyActive ? '~' : '`';
  3490. } else if (keyCode === 8) {
  3491. _this._code = _this._key = 'Backspace';
  3492. } else if (keyCode === 13) {
  3493. _this._code = _this._key = 'Enter';
  3494. } else if (keyCode === 219) {
  3495. _this._code = 'BracketLeft';
  3496. _this._key = _this._shiftKeyActive ? '{' : '[';
  3497. } else if (keyCode === 221) {
  3498. _this._code = 'BracketRight';
  3499. _this._key = _this._shiftKeyActive ? '}' : ']';
  3500. } else if (keyCode === 186) {
  3501. _this._code = 'Semicolon';
  3502. _this._key = _this._shiftKeyActive ? ':' : ';';
  3503. } else if (keyCode === 222) {
  3504. _this._code = 'Quote';
  3505. _this._key = _this._shiftKeyActive ? '"' : "'";
  3506. } else if (keyCode === 9) {
  3507. _this._code = _this._key = 'Tab';
  3508. } else if (keyCode === 17) {
  3509. _this._code = 'ControlLeft';
  3510. _this._key = 'Control';
  3511. } else if (keyCode === 20017) {
  3512. _this._keyCode = 17; // Reset to the real value.
  3513. _this._code = 'ControlRight';
  3514. _this._key = 'Control';
  3515. } else if (keyCode === 16) {
  3516. _this._code = 'ShiftLeft';
  3517. _this._key = 'Shift';
  3518. } else if (keyCode === 20016) {
  3519. _this._keyCode = 16; // Reset to the real value.
  3520. _this._code = 'ShiftRight';
  3521. _this._key = 'Shift';
  3522. } else if (keyCode === 18) {
  3523. _this._code = 'AltLeft';
  3524. _this._key = 'Alt';
  3525. } else if (keyCode === 20018) {
  3526. _this._keyCode = 18; // Reset to the real value.
  3527. _this._code = 'AltRight';
  3528. _this._key = 'Alt';
  3529. } else if (keyCode === 91) {
  3530. _this._code = 'MetaLeft';
  3531. _this._key = 'Meta';
  3532. } else if (keyCode === 93) {
  3533. _this._code = 'MetaRight';
  3534. _this._key = 'Meta';
  3535. } else if (keyCode === 37) {
  3536. _this._code = _this._key = 'ArrowLeft';
  3537. } else if (keyCode === 38) {
  3538. _this._code = _this._key = 'ArrowUp';
  3539. } else if (keyCode === 39) {
  3540. _this._code = _this._key = 'ArrowRight';
  3541. } else if (keyCode === 40) {
  3542. _this._code = _this._key = 'ArrowDown';
  3543. } else if (keyCode === 20093) {
  3544. _this._keyCode = 93; // Bug of brower since its keycode is the same as MetaRight.
  3545. _this._code = _this._key = 'ContextMenu';
  3546. } else if (keyCode === 20013) {
  3547. _this._keyCode = 13;
  3548. _this._code = 'NumpadEnter';
  3549. _this._key = 'Enter';
  3550. } else if (keyCode === 107) {
  3551. _this._code = 'NumpadAdd';
  3552. _this._key = '+';
  3553. } else if (keyCode === 109) {
  3554. _this._code = 'NumpadSubtract';
  3555. _this._key = '-';
  3556. } else if (keyCode === 106) {
  3557. _this._code = 'NumpadMultiply';
  3558. _this._key = '*';
  3559. } else if (keyCode === 111) {
  3560. _this._code = 'NumpadDivide';
  3561. _this._key = '/';
  3562. } else if (keyCode === 12) {
  3563. _this._code = 'NumLock';
  3564. _this._key = 'Clear';
  3565. } else if (keyCode === 124) {
  3566. _this._code = _this._key = 'F13';
  3567. } else if (keyCode === 36) {
  3568. _this._code = _this._key = 'Home';
  3569. } else if (keyCode === 33) {
  3570. _this._code = _this._key = 'PageUp';
  3571. } else if (keyCode === 34) {
  3572. _this._code = _this._key = 'PageDown';
  3573. } else if (keyCode === 35) {
  3574. _this._code = _this._key = 'End';
  3575. } else if (keyCode === 188) {
  3576. _this._code = 'Comma';
  3577. _this._key = _this._shiftKeyActive ? '<' : ',';
  3578. } else if (keyCode === 190) {
  3579. _this._code = 'Period';
  3580. _this._key = _this._shiftKeyActive ? '>' : '.';
  3581. } else if (keyCode === 191) {
  3582. _this._code = 'Slash';
  3583. _this._key = _this._shiftKeyActive ? '?' : '/';
  3584. } else if (keyCode === 32) {
  3585. _this._code = 'Space';
  3586. _this._key = ' ';
  3587. } else if (keyCode === 46) {
  3588. _this._code = _this._key = 'Delete';
  3589. } else if (keyCode === 110) {
  3590. _this._code = 'NumpadDecimal';
  3591. _this._key = '.';
  3592. } else if (keyCode === 20) {
  3593. _this._code = _this._key = 'CapsLock';
  3594. if (type === 'keyup') {
  3595. __capsLockActive = !__capsLockActive;
  3596. }
  3597. } else {
  3598. console.log("Unknown keyCode: " + _this._keyCode);
  3599. }
  3600. return _this;
  3601. } // Returns a Boolean indicating if the modifier key, like Alt, Shift, Ctrl, or Meta, was pressed when the event was created.
  3602. _createClass(KeyboardEvent, [{
  3603. key: "getModifierState",
  3604. value: function getModifierState() {
  3605. return false;
  3606. } // Returns a Boolean that is true if the Alt ( Option or ⌥ on OS X) key was active when the key event was generated.
  3607. }, {
  3608. key: "altKey",
  3609. get: function get() {
  3610. return this._altKeyActive;
  3611. } // Returns a DOMString with the code value of the key represented by the event.
  3612. }, {
  3613. key: "code",
  3614. get: function get() {
  3615. return this._code;
  3616. } // Returns a Boolean that is true if the Ctrl key was active when the key event was generated.
  3617. }, {
  3618. key: "ctrlKey",
  3619. get: function get() {
  3620. return this._ctrlKeyActive;
  3621. } // Returns a Boolean that is true if the event is fired between after compositionstart and before compositionend.
  3622. }, {
  3623. key: "isComposing",
  3624. get: function get() {
  3625. return false;
  3626. } // Returns a DOMString representing the key value of the key represented by the event.
  3627. }, {
  3628. key: "key",
  3629. get: function get() {
  3630. return this._key;
  3631. }
  3632. }, {
  3633. key: "keyCode",
  3634. get: function get() {
  3635. return this._keyCode;
  3636. } // Returns a Number representing the location of the key on the keyboard or other input device.
  3637. }, {
  3638. key: "location",
  3639. get: function get() {
  3640. return 0;
  3641. } // Returns a Boolean that is true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated.
  3642. }, {
  3643. key: "metaKey",
  3644. get: function get() {
  3645. return this._metaKeyActive;
  3646. } // Returns a Boolean that is true if the key is being held down such that it is automatically repeating.
  3647. }, {
  3648. key: "repeat",
  3649. get: function get() {
  3650. return this._repeat;
  3651. } // Returns a Boolean that is true if the Shift key was active when the key event was generated.
  3652. }, {
  3653. key: "shiftKey",
  3654. get: function get() {
  3655. return this._shiftKeyActive;
  3656. }
  3657. }]);
  3658. return KeyboardEvent;
  3659. }(Event);
  3660. module.exports = KeyboardEvent;
  3661. },{"./Event":8}],22:[function(require,module,exports){
  3662. "use strict";
  3663. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3664. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3665. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3666. var MEDIA_ERR_ABORTED = 1;
  3667. var MEDIA_ERR_NETWORK = 2;
  3668. var MEDIA_ERR_DECODE = 3;
  3669. var MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  3670. var MediaError = /*#__PURE__*/function () {
  3671. function MediaError() {
  3672. _classCallCheck(this, MediaError);
  3673. }
  3674. _createClass(MediaError, [{
  3675. key: "code",
  3676. get: function get() {
  3677. return MEDIA_ERR_ABORTED;
  3678. }
  3679. }, {
  3680. key: "message",
  3681. get: function get() {
  3682. return "";
  3683. }
  3684. }]);
  3685. return MediaError;
  3686. }();
  3687. module.exports = MediaError;
  3688. },{}],23:[function(require,module,exports){
  3689. "use strict";
  3690. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3691. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3692. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3693. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3694. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3695. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3696. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3697. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3698. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3699. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3700. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3701. var Event = require('./Event');
  3702. var MouseEvent = /*#__PURE__*/function (_Event) {
  3703. _inherits(MouseEvent, _Event);
  3704. var _super = _createSuper(MouseEvent);
  3705. function MouseEvent(type, initArgs) {
  3706. var _this;
  3707. _classCallCheck(this, MouseEvent);
  3708. _this = _super.call(this, type);
  3709. _this._button = initArgs.button;
  3710. _this._which = initArgs.which;
  3711. _this._wheelDelta = initArgs.wheelDelta;
  3712. _this._clientX = initArgs.clientX;
  3713. _this._clientY = initArgs.clientY;
  3714. _this._screenX = initArgs.screenX;
  3715. _this._screenY = initArgs.screenY;
  3716. _this._pageX = initArgs.pageX;
  3717. _this._pageY = initArgs.pageY;
  3718. return _this;
  3719. }
  3720. _createClass(MouseEvent, [{
  3721. key: "button",
  3722. get: function get() {
  3723. return this._button;
  3724. }
  3725. }, {
  3726. key: "which",
  3727. get: function get() {
  3728. return this._which;
  3729. }
  3730. }, {
  3731. key: "wheelDelta",
  3732. get: function get() {
  3733. return this._wheelDelta;
  3734. }
  3735. }, {
  3736. key: "clientX",
  3737. get: function get() {
  3738. return this._clientX;
  3739. }
  3740. }, {
  3741. key: "clientY",
  3742. get: function get() {
  3743. return this._clientY;
  3744. }
  3745. }, {
  3746. key: "screenX",
  3747. get: function get() {
  3748. return this._screenX;
  3749. }
  3750. }, {
  3751. key: "screenY",
  3752. get: function get() {
  3753. return this._screenY;
  3754. }
  3755. }, {
  3756. key: "pageX",
  3757. get: function get() {
  3758. return this._pageX;
  3759. }
  3760. }, {
  3761. key: "pageY",
  3762. get: function get() {
  3763. return this._pageY;
  3764. }
  3765. }]);
  3766. return MouseEvent;
  3767. }(Event);
  3768. module.exports = MouseEvent;
  3769. },{"./Event":8}],24:[function(require,module,exports){
  3770. "use strict";
  3771. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3772. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3773. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3774. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3775. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3776. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3777. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3778. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3779. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3780. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3781. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3782. var EventTarget = require('./EventTarget');
  3783. var Node = /*#__PURE__*/function (_EventTarget) {
  3784. _inherits(Node, _EventTarget);
  3785. var _super = _createSuper(Node);
  3786. function Node() {
  3787. var _this;
  3788. _classCallCheck(this, Node);
  3789. _this = _super.call(this);
  3790. _this.childNodes = [];
  3791. _this.parentNode = window.__canvas;
  3792. return _this;
  3793. }
  3794. _createClass(Node, [{
  3795. key: "appendChild",
  3796. value: function appendChild(node) {
  3797. if (node instanceof Node) {
  3798. this.childNodes.push(node);
  3799. } else {
  3800. throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.');
  3801. }
  3802. }
  3803. }, {
  3804. key: "insertBefore",
  3805. value: function insertBefore(newNode, referenceNode) {
  3806. //REFINE:
  3807. return newNode;
  3808. }
  3809. }, {
  3810. key: "replaceChild",
  3811. value: function replaceChild(newChild, oldChild) {
  3812. //REFINE:
  3813. return oldChild;
  3814. }
  3815. }, {
  3816. key: "cloneNode",
  3817. value: function cloneNode() {
  3818. var copyNode = Object.create(this);
  3819. Object.assign(copyNode, this);
  3820. return copyNode;
  3821. }
  3822. }, {
  3823. key: "removeChild",
  3824. value: function removeChild(node) {
  3825. var index = this.childNodes.findIndex(function (child) {
  3826. return child === node;
  3827. });
  3828. if (index > -1) {
  3829. return this.childNodes.splice(index, 1);
  3830. }
  3831. return null;
  3832. }
  3833. }, {
  3834. key: "contains",
  3835. value: function contains(node) {
  3836. return this.childNodes.indexOf(node) > -1;
  3837. }
  3838. }]);
  3839. return Node;
  3840. }(EventTarget);
  3841. module.exports = Node;
  3842. },{"./EventTarget":9}],25:[function(require,module,exports){
  3843. "use strict";
  3844. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3845. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3846. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3847. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3848. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3849. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3850. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3851. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3852. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3853. var Event = require('./Event');
  3854. var TouchEvent = /*#__PURE__*/function (_Event) {
  3855. _inherits(TouchEvent, _Event);
  3856. var _super = _createSuper(TouchEvent);
  3857. function TouchEvent(type, touchEventInit) {
  3858. var _this;
  3859. _classCallCheck(this, TouchEvent);
  3860. _this = _super.call(this, type);
  3861. _this.touches = [];
  3862. _this.targetTouches = [];
  3863. _this.changedTouches = [];
  3864. return _this;
  3865. }
  3866. return TouchEvent;
  3867. }(Event);
  3868. module.exports = TouchEvent;
  3869. },{"./Event":8}],26:[function(require,module,exports){
  3870. "use strict";
  3871. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3872. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3873. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3874. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3875. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3876. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3877. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3878. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  3879. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3880. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3881. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3882. var HTMLElement = require('./HTMLElement');
  3883. var Image = require('./Image');
  3884. var HTMLCanvasElement = require('./HTMLCanvasElement');
  3885. var HTMLVideoElement = require('./HTMLVideoElement');
  3886. var HTMLScriptElement = require('./HTMLScriptElement');
  3887. var Node = require('./Node');
  3888. var FontFaceSet = require('./FontFaceSet');
  3889. var Document = /*#__PURE__*/function (_Node) {
  3890. _inherits(Document, _Node);
  3891. var _super = _createSuper(Document);
  3892. function Document() {
  3893. var _this;
  3894. _classCallCheck(this, Document);
  3895. _this = _super.call(this);
  3896. _this.readyState = 'complete';
  3897. _this.visibilityState = 'visible';
  3898. _this.documentElement = window;
  3899. _this.hidden = false;
  3900. _this.style = {};
  3901. _this.location = require('./location');
  3902. _this.head = new HTMLElement('head');
  3903. _this.body = new HTMLElement('body');
  3904. _this.fonts = new FontFaceSet();
  3905. _this.scripts = [];
  3906. return _this;
  3907. }
  3908. _createClass(Document, [{
  3909. key: "createElementNS",
  3910. value: function createElementNS(namespaceURI, qualifiedName, options) {
  3911. return this.createElement(qualifiedName);
  3912. }
  3913. }, {
  3914. key: "createElement",
  3915. value: function createElement(tagName) {
  3916. if (tagName === 'canvas') {
  3917. return new HTMLCanvasElement();
  3918. } else if (tagName === 'img') {
  3919. return new Image();
  3920. } else if (tagName === 'video') {
  3921. return new HTMLVideoElement();
  3922. } else if (tagName === 'script') {
  3923. return new HTMLScriptElement();
  3924. }
  3925. return new HTMLElement(tagName);
  3926. }
  3927. }, {
  3928. key: "getElementById",
  3929. value: function getElementById(id) {
  3930. if (id === window.__canvas.id || id === 'canvas') {
  3931. return window.__canvas;
  3932. }
  3933. return new HTMLElement(id);
  3934. }
  3935. }, {
  3936. key: "getElementsByTagName",
  3937. value: function getElementsByTagName(tagName) {
  3938. if (tagName === 'head') {
  3939. return [document.head];
  3940. } else if (tagName === 'body') {
  3941. return [document.body];
  3942. } else if (tagName === 'canvas') {
  3943. return [window.__canvas];
  3944. }
  3945. return [new HTMLElement(tagName)];
  3946. }
  3947. }, {
  3948. key: "getElementsByName",
  3949. value: function getElementsByName(tagName) {
  3950. if (tagName === 'head') {
  3951. return [document.head];
  3952. } else if (tagName === 'body') {
  3953. return [document.body];
  3954. } else if (tagName === 'canvas') {
  3955. return [window.__canvas];
  3956. }
  3957. return [new HTMLElement(tagName)];
  3958. }
  3959. }, {
  3960. key: "querySelector",
  3961. value: function querySelector(query) {
  3962. if (query === 'head') {
  3963. return document.head;
  3964. } else if (query === 'body') {
  3965. return document.body;
  3966. } else if (query === 'canvas') {
  3967. return window.__canvas;
  3968. } else if (query === "#".concat(window.__canvas.id)) {
  3969. return window.__canvas;
  3970. }
  3971. return new HTMLElement(query);
  3972. }
  3973. }, {
  3974. key: "querySelectorAll",
  3975. value: function querySelectorAll(query) {
  3976. if (query === 'head') {
  3977. return [document.head];
  3978. } else if (query === 'body') {
  3979. return [document.body];
  3980. } else if (query === 'canvas') {
  3981. return [window.__canvas];
  3982. }
  3983. return [new HTMLElement(query)];
  3984. }
  3985. }, {
  3986. key: "createTextNode",
  3987. value: function createTextNode() {
  3988. return new HTMLElement('text');
  3989. }
  3990. }, {
  3991. key: "elementFromPoint",
  3992. value: function elementFromPoint() {
  3993. return window.canvas;
  3994. }
  3995. }, {
  3996. key: "createEvent",
  3997. value: function createEvent(type) {
  3998. if (window[type]) {
  3999. return new window[type]();
  4000. }
  4001. return null;
  4002. }
  4003. }]);
  4004. return Document;
  4005. }(Node);
  4006. var document = new Document();
  4007. module.exports = document;
  4008. },{"./FontFaceSet":12,"./HTMLCanvasElement":13,"./HTMLElement":14,"./HTMLScriptElement":17,"./HTMLVideoElement":18,"./Image":19,"./Node":24,"./location":28}],27:[function(require,module,exports){
  4009. "use strict";
  4010. require('./window');
  4011. },{"./window":31}],28:[function(require,module,exports){
  4012. "use strict";
  4013. var location = {
  4014. href: 'game.js',
  4015. pathname: 'game.js',
  4016. search: '',
  4017. hash: '',
  4018. reload: function reload() {}
  4019. };
  4020. module.exports = location;
  4021. },{}],29:[function(require,module,exports){
  4022. "use strict";
  4023. var _require = require('./util'),
  4024. noop = _require.noop;
  4025. var navigator = {
  4026. platform: __getOS(),
  4027. language: __getCurrentLanguage(),
  4028. appVersion: '5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
  4029. userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 NetType/WIFI Language/zh_CN',
  4030. onLine: true,
  4031. //FIXME:
  4032. geolocation: {
  4033. getCurrentPosition: noop,
  4034. watchPosition: noop,
  4035. clearWatch: noop
  4036. },
  4037. maxTouchPoints: 10 //FIXME: getting the number from OS.
  4038. };
  4039. module.exports = navigator;
  4040. },{"./util":30}],30:[function(require,module,exports){
  4041. "use strict";
  4042. function noop() {}
  4043. module.exports = noop;
  4044. },{}],31:[function(require,module,exports){
  4045. "use strict";
  4046. function inject() {
  4047. window.top = window.parent = window;
  4048. window.ontouchstart = null;
  4049. window.ontouchmove = null;
  4050. window.ontouchend = null;
  4051. window.ontouchcancel = null;
  4052. window.pageXOffset = window.pageYOffset = window.clientTop = window.clientLeft = 0;
  4053. window.outerWidth = window.innerWidth;
  4054. window.outerHeight = window.innerHeight;
  4055. window.location = require('./location');
  4056. window.document = require('./document');
  4057. window.Element = require('./Element');
  4058. window.HTMLElement = require('./HTMLElement');
  4059. window.HTMLCanvasElement = require('./HTMLCanvasElement');
  4060. window.HTMLImageElement = require('./HTMLImageElement');
  4061. window.HTMLMediaElement = require('./HTMLMediaElement');
  4062. window.HTMLVideoElement = require('./HTMLVideoElement');
  4063. window.HTMLScriptElement = require('./HTMLScriptElement');
  4064. window.__canvas = new HTMLCanvasElement();
  4065. window.__canvas._width = window.innerWidth;
  4066. window.__canvas._height = window.innerHeight;
  4067. window.__gl.canvas = window.__canvas;
  4068. window.navigator = require('./navigator');
  4069. window.Image = require('./Image');
  4070. window.FileReader = require('./FileReader');
  4071. window.FontFace = require('./FontFace');
  4072. window.FontFaceSet = require('./FontFaceSet');
  4073. window.EventTarget = require('./EventTarget');
  4074. window.Event = require('./Event');
  4075. window.TouchEvent = require('./TouchEvent');
  4076. window.MouseEvent = require('./MouseEvent');
  4077. window.KeyboardEvent = require('./KeyboardEvent');
  4078. window.DeviceMotionEvent = require('./DeviceMotionEvent'); // window.devicePixelRatio is readonly
  4079. Object.defineProperty(window, "devicePixelRatio", {
  4080. get: function get() {
  4081. return jsb.device.getDevicePixelRatio ? jsb.device.getDevicePixelRatio() : 1;
  4082. },
  4083. set: function set(_dpr) {
  4084. /* ignore */
  4085. },
  4086. enumerable: true,
  4087. configurable: true
  4088. });
  4089. window.addEventListener = function (eventName, listener, options) {
  4090. window.__canvas.addEventListener(eventName, listener, options);
  4091. };
  4092. window.removeEventListener = function (eventName, listener, options) {
  4093. window.__canvas.removeEventListener(eventName, listener, options);
  4094. };
  4095. window.dispatchEvent = function (event) {
  4096. window.__canvas.dispatchEvent(event);
  4097. };
  4098. window.screen = {
  4099. availTop: 0,
  4100. availLeft: 0,
  4101. availHeight: window.innerWidth,
  4102. availWidth: window.innerHeight,
  4103. colorDepth: 8,
  4104. pixelDepth: 8,
  4105. left: 0,
  4106. top: 0,
  4107. width: window.innerWidth,
  4108. height: window.innerHeight,
  4109. orientation: {
  4110. //FIXME:cjh
  4111. type: 'portrait-primary' // portrait-primary, portrait-secondary, landscape-primary, landscape-secondary
  4112. },
  4113. //screen orientation enum
  4114. SCREEN_ORIENTATION: {
  4115. ROTATION_0: 0,
  4116. ROTATION_90: 1,
  4117. ROTATION_180: 2,
  4118. ROTATION_270: 3
  4119. },
  4120. onOrientationChanged: function onOrientationChanged(event) {
  4121. switch (event.rotation) {
  4122. case window.screen.SCREEN_ORIENTATION.ROTATION_0:
  4123. window.orientation = 0;
  4124. break;
  4125. case window.screen.SCREEN_ORIENTATION.ROTATION_90:
  4126. window.orientation = 90;
  4127. break;
  4128. case window.screen.SCREEN_ORIENTATION.ROTATION_180:
  4129. window.orientation = 180;
  4130. break;
  4131. case window.screen.SCREEN_ORIENTATION.ROTATION_270:
  4132. window.orientation = -90;
  4133. break;
  4134. default:
  4135. break;
  4136. } // emit resize consistent with web behavior
  4137. var resizeEvent = new Event('orientationchange');
  4138. window.dispatchEvent(resizeEvent);
  4139. }
  4140. };
  4141. jsb.onOrientationChanged = function (event) {
  4142. window.screen.onOrientationChanged(event);
  4143. };
  4144. window.screen.onOrientationChanged({
  4145. rotation: jsb.device.getDeviceRotation()
  4146. });
  4147. window.getComputedStyle = function (element) {
  4148. return {
  4149. position: 'absolute',
  4150. left: '0px',
  4151. top: '0px',
  4152. height: '0px'
  4153. };
  4154. };
  4155. window.resize = function (width, height) {
  4156. window.innerWidth = width;
  4157. window.innerHeight = height;
  4158. window.outerWidth = window.innerWidth;
  4159. window.outerHeight = window.innerHeight;
  4160. window.__canvas._width = window.innerWidth;
  4161. window.__canvas._height = window.innerHeight;
  4162. window.screen.availWidth = window.innerWidth;
  4163. window.screen.availHeight = window.innerHeight;
  4164. window.screen.width = window.innerWidth;
  4165. window.screen.height = window.innerHeight; // emit resize consistent with web behavior
  4166. var resizeEvent = new Event('resize');
  4167. resizeEvent._target = window;
  4168. window.dispatchEvent(resizeEvent);
  4169. };
  4170. window.focus = function () {};
  4171. window.scroll = function () {};
  4172. window._isInjected = true;
  4173. }
  4174. if (!window._isInjected) {
  4175. inject();
  4176. }
  4177. window.localStorage = sys.localStorage;
  4178. },{"./DeviceMotionEvent":6,"./Element":7,"./Event":8,"./EventTarget":9,"./FileReader":10,"./FontFace":11,"./FontFaceSet":12,"./HTMLCanvasElement":13,"./HTMLElement":14,"./HTMLImageElement":15,"./HTMLMediaElement":16,"./HTMLScriptElement":17,"./HTMLVideoElement":18,"./Image":19,"./KeyboardEvent":21,"./MouseEvent":23,"./TouchEvent":25,"./document":26,"./location":28,"./navigator":29}],32:[function(require,module,exports){
  4179. "use strict";
  4180. (function (jsb) {
  4181. if (!jsb || !jsb.AudioEngine) return;
  4182. jsb.AudioEngine.AudioState = {
  4183. ERROR: -1,
  4184. INITIALZING: 0,
  4185. PLAYING: 1,
  4186. PAUSED: 2,
  4187. STOPPED: 3
  4188. };
  4189. jsb.AudioEngine.INVALID_AUDIO_ID = -1;
  4190. jsb.AudioEngine.TIME_UNKNOWN = -1;
  4191. })(jsb);
  4192. },{}],33:[function(require,module,exports){
  4193. "use strict";
  4194. var EventTarget = require('./jsb-adapter/EventTarget');
  4195. var Event = require('./jsb-adapter/Event');
  4196. var eventTarget = new EventTarget();
  4197. var callbackWrappers = {};
  4198. var callbacks = {};
  4199. var index = 1;
  4200. var callbackWrapper = function callbackWrapper(cb) {
  4201. if (!cb) return null;
  4202. var func = function func(event) {
  4203. cb({
  4204. value: event.text
  4205. });
  4206. };
  4207. cb.___index = index++;
  4208. callbackWrappers[cb.___index] = func;
  4209. return func;
  4210. };
  4211. var getCallbackWrapper = function getCallbackWrapper(cb) {
  4212. if (cb && cb.___index) {
  4213. var ret = callbackWrappers[cb.___index];
  4214. delete callbackWrappers[cb.___index];
  4215. return ret;
  4216. } else return null;
  4217. };
  4218. var removeListener = function removeListener(name, cb) {
  4219. if (cb) eventTarget.removeEventListener(name, getCallbackWrapper(cb));else {
  4220. // remove all listeners of name
  4221. var cbs = callbacks[name];
  4222. if (!cbs) return;
  4223. for (var i = 0, len = cbs.length; i < len; ++i) {
  4224. eventTarget.removeEventListener(name, cbs[i]);
  4225. }
  4226. delete callbacks[name];
  4227. }
  4228. };
  4229. var recordCallback = function recordCallback(name, cb) {
  4230. if (!cb || !name || name === '') return;
  4231. if (!callbacks[name]) callbacks[name] = [];
  4232. callbacks[name].push(cb);
  4233. };
  4234. jsb.inputBox = {
  4235. onConfirm: function onConfirm(cb) {
  4236. var newCb = callbackWrapper(cb);
  4237. eventTarget.addEventListener('confirm', newCb);
  4238. recordCallback('confirm', newCb);
  4239. },
  4240. offConfirm: function offConfirm(cb) {
  4241. removeListener('confirm', cb);
  4242. },
  4243. onComplete: function onComplete(cb) {
  4244. var newCb = callbackWrapper(cb);
  4245. eventTarget.addEventListener('complete', newCb);
  4246. recordCallback('complete', newCb);
  4247. },
  4248. offComplete: function offComplete(cb) {
  4249. removeListener('complete', cb);
  4250. },
  4251. onInput: function onInput(cb) {
  4252. var newCb = callbackWrapper(cb);
  4253. eventTarget.addEventListener('input', newCb);
  4254. recordCallback('input', newCb);
  4255. },
  4256. offInput: function offInput(cb) {
  4257. removeListener('input', cb);
  4258. },
  4259. /**
  4260. * @param {string} options.defaultValue
  4261. * @param {number} options.maxLength
  4262. * @param {bool} options.multiple
  4263. * @param {bool} options.confirmHold
  4264. * @param {string} options.confirmType
  4265. * @param {string} options.inputType
  4266. *
  4267. * Values of options.confirmType can be [done|next|search|go|send].
  4268. * Values of options.inputType can be [text|email|number|phone|password].
  4269. */
  4270. show: function show(options) {
  4271. jsb.showInputBox(options);
  4272. },
  4273. hide: function hide() {
  4274. jsb.hideInputBox();
  4275. },
  4276. updateRect: function updateRect(x, y, width, height) {
  4277. jsb.updateInputBoxRect(x, y, width, height);
  4278. }
  4279. };
  4280. jsb.onTextInput = function (eventName, text) {
  4281. var event = new Event(eventName);
  4282. event.text = text;
  4283. eventTarget.dispatchEvent(event);
  4284. };
  4285. },{"./jsb-adapter/Event":8,"./jsb-adapter/EventTarget":9}],34:[function(require,module,exports){
  4286. "use strict";
  4287. require('./jsb_opengl_constants');
  4288. var gl = __gl;
  4289. gl.drawingBufferWidth = window.innerWidth;
  4290. gl.drawingBufferHeight = window.innerHeight; //
  4291. // Extensions
  4292. //
  4293. var WebGLCompressedTextureS3TC = {
  4294. COMPRESSED_RGB_S3TC_DXT1_EXT: 0x83F0,
  4295. // A DXT1-compressed image in an RGB image format.
  4296. COMPRESSED_RGBA_S3TC_DXT1_EXT: 0x83F1,
  4297. // A DXT1-compressed image in an RGB image format with a simple on/off alpha value.
  4298. COMPRESSED_RGBA_S3TC_DXT3_EXT: 0x83F2,
  4299. // A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.
  4300. COMPRESSED_RGBA_S3TC_DXT5_EXT: 0x83F3 // A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3 compression in how the alpha compression is done.
  4301. };
  4302. var WebGLCompressedTextureETC1 = {
  4303. COMPRESSED_RGB_ETC1_WEBGL: 0x8D64 // Compresses 24-bit RGB data with no alpha channel.
  4304. };
  4305. var WebGLCompressedTexturePVRTC = {
  4306. COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 0x8C00,
  4307. // RGB compression in 4-bit mode. One block for each 4×4 pixels.
  4308. COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 0x8C02,
  4309. // RGBA compression in 4-bit mode. One block for each 4×4 pixels.
  4310. COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 0x8C01,
  4311. // RGB compression in 2-bit mode. One block for each 8×4 pixels.
  4312. COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 0x8C03 // RGBA compression in 2-bit mode. One block for each 8×4 pixe
  4313. };
  4314. var extensionPrefixArr = ['MOZ_', 'WEBKIT_'];
  4315. var extensionMap = {
  4316. WEBGL_compressed_texture_s3tc: WebGLCompressedTextureS3TC,
  4317. WEBGL_compressed_texture_pvrtc: WebGLCompressedTexturePVRTC,
  4318. WEBGL_compressed_texture_etc1: WebGLCompressedTextureETC1
  4319. }; // From the WebGL spec:
  4320. // Returns an object if, and only if, name is an ASCII case-insensitive match [HTML] for one of the names returned from getSupportedExtensions;
  4321. // otherwise, returns null. The object returned from getExtension contains any constants or functions provided by the extension.
  4322. // A returned object may have no constants or functions if the extension does not define any, but a unique object must still be returned.
  4323. // That object is used to indicate that the extension has been enabled.
  4324. // XXX: The returned object must return the functions and constants.
  4325. var supportedExtensions = gl.getSupportedExtensions();
  4326. gl.getExtension = function (extension) {
  4327. var prefix;
  4328. for (var i = 0, len = extensionPrefixArr.length; i < len; ++i) {
  4329. prefix = extensionPrefixArr[i];
  4330. if (extension.startsWith(prefix)) {
  4331. extension = extension.substring(prefix.length);
  4332. break;
  4333. }
  4334. }
  4335. if (supportedExtensions.indexOf(extension) > -1) {
  4336. if (extension in extensionMap) {
  4337. return extensionMap[extension];
  4338. }
  4339. return {}; //REFINE: Return an empty object to indicate this platform supports the extension. But we should not return an empty object actually.
  4340. }
  4341. return null;
  4342. };
  4343. var HTMLCanvasElement = require('./jsb-adapter/HTMLCanvasElement');
  4344. var HTMLImageElement = require('./jsb-adapter/HTMLImageElement');
  4345. var ImageData = require('./jsb-adapter/ImageData');
  4346. var _glTexImage2D = gl.texImage2D;
  4347. /*
  4348. // WebGL1:
  4349. void gl.texImage2D(target, level, internalformat, width, height, border, format, type, ArrayBufferView? pixels);
  4350. void gl.texImage2D(target, level, internalformat, format, type, ImageData? pixels);
  4351. void gl.texImage2D(target, level, internalformat, format, type, HTMLImageElement? pixels);
  4352. void gl.texImage2D(target, level, internalformat, format, type, HTMLCanvasElement? pixels);
  4353. void gl.texImage2D(target, level, internalformat, format, type, HTMLVideoElement? pixels);
  4354. void gl.texImage2D(target, level, internalformat, format, type, ImageBitmap? pixels);
  4355. */
  4356. gl.texImage2D = function (target, level, internalformat, width, height, border, format, type, pixels) {
  4357. var argCount = arguments.length;
  4358. if (argCount == 6) {
  4359. var image = border;
  4360. type = height;
  4361. format = width;
  4362. if (image instanceof HTMLImageElement) {
  4363. _glTexImage2D(target, level, image._glInternalFormat, image.width, image.height, 0, image._glFormat, image._glType, image._data, image._alignment);
  4364. } else if (image instanceof HTMLCanvasElement) {
  4365. var data = image.data;
  4366. _glTexImage2D(target, level, internalformat, image.width, image.height, 0, format, type, data, image._alignment);
  4367. } else if (image instanceof ImageData) {
  4368. _glTexImage2D(target, level, internalformat, image.width, image.height, 0, format, type, image._data, 0);
  4369. } else {
  4370. console.error("Invalid pixel argument passed to gl.texImage2D!");
  4371. }
  4372. } else if (argCount == 9) {
  4373. _glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, 0);
  4374. } else {
  4375. console.error("gl.texImage2D: invalid argument count!");
  4376. }
  4377. };
  4378. var _glTexSubImage2D = gl.texSubImage2D;
  4379. /*
  4380. // WebGL 1:
  4381. void gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, ArrayBufferView? pixels);
  4382. void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, ImageData? pixels);
  4383. void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, HTMLImageElement? pixels);
  4384. void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, HTMLCanvasElement? pixels);
  4385. void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, HTMLVideoElement? pixels);
  4386. void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, ImageBitmap? pixels);
  4387. */
  4388. gl.texSubImage2D = function (target, level, xoffset, yoffset, width, height, format, type, pixels) {
  4389. var argCount = arguments.length;
  4390. if (argCount == 7) {
  4391. var image = format;
  4392. type = height;
  4393. format = width;
  4394. if (image instanceof HTMLImageElement) {
  4395. _glTexSubImage2D(target, level, xoffset, yoffset, image.width, image.height, image._glFormat, image._glType, image._data, image._alignment);
  4396. } else if (image instanceof HTMLCanvasElement) {
  4397. var data = image.data;
  4398. _glTexSubImage2D(target, level, xoffset, yoffset, image.width, image.height, format, type, data, image._alignment);
  4399. } else if (image instanceof ImageData) {
  4400. _glTexSubImage2D(target, level, xoffset, yoffset, image.width, image.height, format, type, image._data, 0);
  4401. } else {
  4402. console.error("Invalid pixel argument passed to gl.texImage2D!");
  4403. }
  4404. } else if (argCount == 9) {
  4405. _glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels, 0);
  4406. } else {
  4407. console.error(new Error("gl.texImage2D: invalid argument count!").stack);
  4408. }
  4409. }; //REFINE:cjh get the real value
  4410. gl.getContextAttributes = function () {
  4411. return {
  4412. alpha: true,
  4413. antialias: false,
  4414. depth: true,
  4415. failIfMajorPerformanceCaveat: false,
  4416. premultipliedAlpha: true,
  4417. preserveDrawingBuffer: false,
  4418. stencil: true
  4419. };
  4420. };
  4421. gl.isContextLost = function () {
  4422. return false;
  4423. };
  4424. },{"./jsb-adapter/HTMLCanvasElement":13,"./jsb-adapter/HTMLImageElement":15,"./jsb-adapter/ImageData":20,"./jsb_opengl_constants":35}],35:[function(require,module,exports){
  4425. "use strict";
  4426. var gl = __gl;
  4427. gl.GCCSO_SHADER_BINARY_FJ = 0x9260;
  4428. gl._3DC_XY_AMD = 0x87fa;
  4429. gl._3DC_X_AMD = 0x87f9;
  4430. gl.ACTIVE_ATTRIBUTES = 0x8b89;
  4431. gl.ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8b8a;
  4432. gl.ACTIVE_PROGRAM_EXT = 0x8259;
  4433. gl.ACTIVE_TEXTURE = 0x84e0;
  4434. gl.ACTIVE_UNIFORMS = 0x8b86;
  4435. gl.ACTIVE_UNIFORM_MAX_LENGTH = 0x8b87;
  4436. gl.ALIASED_LINE_WIDTH_RANGE = 0x846e;
  4437. gl.ALIASED_POINT_SIZE_RANGE = 0x846d;
  4438. gl.ALL_COMPLETED_NV = 0x84f2;
  4439. gl.ALL_SHADER_BITS_EXT = 0xffffffff;
  4440. gl.ALPHA = 0x1906;
  4441. gl.ALPHA16F_EXT = 0x881c;
  4442. gl.ALPHA32F_EXT = 0x8816;
  4443. gl.ALPHA8_EXT = 0x803c;
  4444. gl.ALPHA8_OES = 0x803c;
  4445. gl.ALPHA_BITS = 0xd55;
  4446. gl.ALPHA_TEST_FUNC_QCOM = 0xbc1;
  4447. gl.ALPHA_TEST_QCOM = 0xbc0;
  4448. gl.ALPHA_TEST_REF_QCOM = 0xbc2;
  4449. gl.ALREADY_SIGNALED_APPLE = 0x911a;
  4450. gl.ALWAYS = 0x207;
  4451. gl.AMD_compressed_3DC_texture = 0x1;
  4452. gl.AMD_compressed_ATC_texture = 0x1;
  4453. gl.AMD_performance_monitor = 0x1;
  4454. gl.AMD_program_binary_Z400 = 0x1;
  4455. gl.ANGLE_depth_texture = 0x1;
  4456. gl.ANGLE_framebuffer_blit = 0x1;
  4457. gl.ANGLE_framebuffer_multisample = 0x1;
  4458. gl.ANGLE_instanced_arrays = 0x1;
  4459. gl.ANGLE_pack_reverse_row_order = 0x1;
  4460. gl.ANGLE_program_binary = 0x1;
  4461. gl.ANGLE_texture_compression_dxt3 = 0x1;
  4462. gl.ANGLE_texture_compression_dxt5 = 0x1;
  4463. gl.ANGLE_texture_usage = 0x1;
  4464. gl.ANGLE_translated_shader_source = 0x1;
  4465. gl.ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8d6a;
  4466. gl.ANY_SAMPLES_PASSED_EXT = 0x8c2f;
  4467. gl.APPLE_copy_texture_levels = 0x1;
  4468. gl.APPLE_framebuffer_multisample = 0x1;
  4469. gl.APPLE_rgb_422 = 0x1;
  4470. gl.APPLE_sync = 0x1;
  4471. gl.APPLE_texture_format_BGRA8888 = 0x1;
  4472. gl.APPLE_texture_max_level = 0x1;
  4473. gl.ARM_mali_program_binary = 0x1;
  4474. gl.ARM_mali_shader_binary = 0x1;
  4475. gl.ARM_rgba8 = 0x1;
  4476. gl.ARRAY_BUFFER = 0x8892;
  4477. gl.ARRAY_BUFFER_BINDING = 0x8894;
  4478. gl.ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8c93;
  4479. gl.ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87ee;
  4480. gl.ATC_RGB_AMD = 0x8c92;
  4481. gl.ATTACHED_SHADERS = 0x8b85;
  4482. gl.BACK = 0x405;
  4483. gl.BGRA8_EXT = 0x93a1;
  4484. gl.BGRA_EXT = 0x80e1;
  4485. gl.BGRA_IMG = 0x80e1;
  4486. gl.BINNING_CONTROL_HINT_QCOM = 0x8fb0;
  4487. gl.BLEND = 0xbe2;
  4488. gl.BLEND_COLOR = 0x8005;
  4489. gl.BLEND_DST_ALPHA = 0x80ca;
  4490. gl.BLEND_DST_RGB = 0x80c8;
  4491. gl.BLEND_EQUATION = 0x8009;
  4492. gl.BLEND_EQUATION_ALPHA = 0x883d;
  4493. gl.BLEND_EQUATION_RGB = 0x8009;
  4494. gl.BLEND_SRC_ALPHA = 0x80cb;
  4495. gl.BLEND_SRC_RGB = 0x80c9;
  4496. gl.BLUE_BITS = 0xd54;
  4497. gl.BOOL = 0x8b56;
  4498. gl.BOOL_VEC2 = 0x8b57;
  4499. gl.BOOL_VEC3 = 0x8b58;
  4500. gl.BOOL_VEC4 = 0x8b59;
  4501. gl.BUFFER = 0x82e0;
  4502. gl.BUFFER_ACCESS_OES = 0x88bb;
  4503. gl.BUFFER_MAPPED_OES = 0x88bc;
  4504. gl.BUFFER_MAP_POINTER_OES = 0x88bd;
  4505. gl.BUFFER_OBJECT_EXT = 0x9151;
  4506. gl.BUFFER_SIZE = 0x8764;
  4507. gl.BUFFER_USAGE = 0x8765;
  4508. gl.BYTE = 0x1400;
  4509. gl.CCW = 0x901;
  4510. gl.CLAMP_TO_BORDER_NV = 0x812d;
  4511. gl.CLAMP_TO_EDGE = 0x812f;
  4512. gl.COLOR_ATTACHMENT0 = 0x8ce0;
  4513. gl.COLOR_ATTACHMENT0_NV = 0x8ce0;
  4514. gl.COLOR_ATTACHMENT10_NV = 0x8cea;
  4515. gl.COLOR_ATTACHMENT11_NV = 0x8ceb;
  4516. gl.COLOR_ATTACHMENT12_NV = 0x8cec;
  4517. gl.COLOR_ATTACHMENT13_NV = 0x8ced;
  4518. gl.COLOR_ATTACHMENT14_NV = 0x8cee;
  4519. gl.COLOR_ATTACHMENT15_NV = 0x8cef;
  4520. gl.COLOR_ATTACHMENT1_NV = 0x8ce1;
  4521. gl.COLOR_ATTACHMENT2_NV = 0x8ce2;
  4522. gl.COLOR_ATTACHMENT3_NV = 0x8ce3;
  4523. gl.COLOR_ATTACHMENT4_NV = 0x8ce4;
  4524. gl.COLOR_ATTACHMENT5_NV = 0x8ce5;
  4525. gl.COLOR_ATTACHMENT6_NV = 0x8ce6;
  4526. gl.COLOR_ATTACHMENT7_NV = 0x8ce7;
  4527. gl.COLOR_ATTACHMENT8_NV = 0x8ce8;
  4528. gl.COLOR_ATTACHMENT9_NV = 0x8ce9;
  4529. gl.COLOR_ATTACHMENT_EXT = 0x90f0;
  4530. gl.COLOR_BUFFER_BIT = 0x4000;
  4531. gl.COLOR_BUFFER_BIT0_QCOM = 0x1;
  4532. gl.COLOR_BUFFER_BIT1_QCOM = 0x2;
  4533. gl.COLOR_BUFFER_BIT2_QCOM = 0x4;
  4534. gl.COLOR_BUFFER_BIT3_QCOM = 0x8;
  4535. gl.COLOR_BUFFER_BIT4_QCOM = 0x10;
  4536. gl.COLOR_BUFFER_BIT5_QCOM = 0x20;
  4537. gl.COLOR_BUFFER_BIT6_QCOM = 0x40;
  4538. gl.COLOR_BUFFER_BIT7_QCOM = 0x80;
  4539. gl.COLOR_CLEAR_VALUE = 0xc22;
  4540. gl.COLOR_EXT = 0x1800;
  4541. gl.COLOR_WRITEMASK = 0xc23;
  4542. gl.COMPARE_REF_TO_TEXTURE_EXT = 0x884e;
  4543. gl.COMPILE_STATUS = 0x8b81;
  4544. gl.COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb;
  4545. gl.COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8;
  4546. gl.COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9;
  4547. gl.COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba;
  4548. gl.COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc;
  4549. gl.COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd;
  4550. gl.COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0;
  4551. gl.COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1;
  4552. gl.COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2;
  4553. gl.COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3;
  4554. gl.COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4;
  4555. gl.COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5;
  4556. gl.COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6;
  4557. gl.COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7;
  4558. gl.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03;
  4559. gl.COMPRESSED_RGBA_PVRTC_2BPPV2_IMG = 0x9137;
  4560. gl.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02;
  4561. gl.COMPRESSED_RGBA_PVRTC_4BPPV2_IMG = 0x9138;
  4562. gl.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1;
  4563. gl.COMPRESSED_RGBA_S3TC_DXT3_ANGLE = 0x83f2;
  4564. gl.COMPRESSED_RGBA_S3TC_DXT5_ANGLE = 0x83f3;
  4565. gl.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01;
  4566. gl.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00;
  4567. gl.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0;
  4568. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db;
  4569. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8;
  4570. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9;
  4571. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da;
  4572. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc;
  4573. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd;
  4574. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0;
  4575. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1;
  4576. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2;
  4577. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3;
  4578. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4;
  4579. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5;
  4580. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6;
  4581. gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7;
  4582. gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV = 0x8c4d;
  4583. gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV = 0x8c4e;
  4584. gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV = 0x8c4f;
  4585. gl.COMPRESSED_SRGB_S3TC_DXT1_NV = 0x8c4c;
  4586. gl.COMPRESSED_TEXTURE_FORMATS = 0x86a3;
  4587. gl.CONDITION_SATISFIED_APPLE = 0x911c;
  4588. gl.CONSTANT_ALPHA = 0x8003;
  4589. gl.CONSTANT_COLOR = 0x8001;
  4590. gl.CONTEXT_FLAG_DEBUG_BIT = 0x2;
  4591. gl.CONTEXT_ROBUST_ACCESS_EXT = 0x90f3;
  4592. gl.COUNTER_RANGE_AMD = 0x8bc1;
  4593. gl.COUNTER_TYPE_AMD = 0x8bc0;
  4594. gl.COVERAGE_ALL_FRAGMENTS_NV = 0x8ed5;
  4595. gl.COVERAGE_ATTACHMENT_NV = 0x8ed2;
  4596. gl.COVERAGE_AUTOMATIC_NV = 0x8ed7;
  4597. gl.COVERAGE_BUFFERS_NV = 0x8ed3;
  4598. gl.COVERAGE_BUFFER_BIT_NV = 0x8000;
  4599. gl.COVERAGE_COMPONENT4_NV = 0x8ed1;
  4600. gl.COVERAGE_COMPONENT_NV = 0x8ed0;
  4601. gl.COVERAGE_EDGE_FRAGMENTS_NV = 0x8ed6;
  4602. gl.COVERAGE_SAMPLES_NV = 0x8ed4;
  4603. gl.CPU_OPTIMIZED_QCOM = 0x8fb1;
  4604. gl.CULL_FACE = 0xb44;
  4605. gl.CULL_FACE_MODE = 0xb45;
  4606. gl.CURRENT_PROGRAM = 0x8b8d;
  4607. gl.CURRENT_QUERY_EXT = 0x8865;
  4608. gl.CURRENT_VERTEX_ATTRIB = 0x8626;
  4609. gl.CW = 0x900;
  4610. gl.DEBUG_CALLBACK_FUNCTION = 0x8244;
  4611. gl.DEBUG_CALLBACK_USER_PARAM = 0x8245;
  4612. gl.DEBUG_GROUP_STACK_DEPTH = 0x826d;
  4613. gl.DEBUG_LOGGED_MESSAGES = 0x9145;
  4614. gl.DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243;
  4615. gl.DEBUG_OUTPUT = 0x92e0;
  4616. gl.DEBUG_OUTPUT_SYNCHRONOUS = 0x8242;
  4617. gl.DEBUG_SEVERITY_HIGH = 0x9146;
  4618. gl.DEBUG_SEVERITY_LOW = 0x9148;
  4619. gl.DEBUG_SEVERITY_MEDIUM = 0x9147;
  4620. gl.DEBUG_SEVERITY_NOTIFICATION = 0x826b;
  4621. gl.DEBUG_SOURCE_API = 0x8246;
  4622. gl.DEBUG_SOURCE_APPLICATION = 0x824a;
  4623. gl.DEBUG_SOURCE_OTHER = 0x824b;
  4624. gl.DEBUG_SOURCE_SHADER_COMPILER = 0x8248;
  4625. gl.DEBUG_SOURCE_THIRD_PARTY = 0x8249;
  4626. gl.DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247;
  4627. gl.DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824d;
  4628. gl.DEBUG_TYPE_ERROR = 0x824c;
  4629. gl.DEBUG_TYPE_MARKER = 0x8268;
  4630. gl.DEBUG_TYPE_OTHER = 0x8251;
  4631. gl.DEBUG_TYPE_PERFORMANCE = 0x8250;
  4632. gl.DEBUG_TYPE_POP_GROUP = 0x826a;
  4633. gl.DEBUG_TYPE_PORTABILITY = 0x824f;
  4634. gl.DEBUG_TYPE_PUSH_GROUP = 0x8269;
  4635. gl.DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824e;
  4636. gl.DECR = 0x1e03;
  4637. gl.DECR_WRAP = 0x8508;
  4638. gl.DELETE_STATUS = 0x8b80;
  4639. gl.DEPTH24_STENCIL8_OES = 0x88f0;
  4640. gl.DEPTH_ATTACHMENT = 0x8d00;
  4641. gl.DEPTH_STENCIL_ATTACHMENT = 0x821a;
  4642. gl.DEPTH_BITS = 0xd56;
  4643. gl.DEPTH_BUFFER_BIT = 0x100;
  4644. gl.DEPTH_BUFFER_BIT0_QCOM = 0x100;
  4645. gl.DEPTH_BUFFER_BIT1_QCOM = 0x200;
  4646. gl.DEPTH_BUFFER_BIT2_QCOM = 0x400;
  4647. gl.DEPTH_BUFFER_BIT3_QCOM = 0x800;
  4648. gl.DEPTH_BUFFER_BIT4_QCOM = 0x1000;
  4649. gl.DEPTH_BUFFER_BIT5_QCOM = 0x2000;
  4650. gl.DEPTH_BUFFER_BIT6_QCOM = 0x4000;
  4651. gl.DEPTH_BUFFER_BIT7_QCOM = 0x8000;
  4652. gl.DEPTH_CLEAR_VALUE = 0xb73;
  4653. gl.DEPTH_COMPONENT = 0x1902;
  4654. gl.DEPTH_COMPONENT16 = 0x81a5;
  4655. gl.DEPTH_COMPONENT16_NONLINEAR_NV = 0x8e2c;
  4656. gl.DEPTH_COMPONENT16_OES = 0x81a5;
  4657. gl.DEPTH_COMPONENT24_OES = 0x81a6;
  4658. gl.DEPTH_COMPONENT32_OES = 0x81a7;
  4659. gl.DEPTH_EXT = 0x1801;
  4660. gl.DEPTH_FUNC = 0xb74;
  4661. gl.DEPTH_RANGE = 0xb70;
  4662. gl.DEPTH_STENCIL = 0x84f9;
  4663. gl.DEPTH_STENCIL_OES = 0x84f9;
  4664. gl.DEPTH_TEST = 0xb71;
  4665. gl.DEPTH_WRITEMASK = 0xb72;
  4666. gl.DITHER = 0xbd0;
  4667. gl.DMP_shader_binary = 0x1;
  4668. gl.DONT_CARE = 0x1100;
  4669. gl.DRAW_BUFFER0_NV = 0x8825;
  4670. gl.DRAW_BUFFER10_NV = 0x882f;
  4671. gl.DRAW_BUFFER11_NV = 0x8830;
  4672. gl.DRAW_BUFFER12_NV = 0x8831;
  4673. gl.DRAW_BUFFER13_NV = 0x8832;
  4674. gl.DRAW_BUFFER14_NV = 0x8833;
  4675. gl.DRAW_BUFFER15_NV = 0x8834;
  4676. gl.DRAW_BUFFER1_NV = 0x8826;
  4677. gl.DRAW_BUFFER2_NV = 0x8827;
  4678. gl.DRAW_BUFFER3_NV = 0x8828;
  4679. gl.DRAW_BUFFER4_NV = 0x8829;
  4680. gl.DRAW_BUFFER5_NV = 0x882a;
  4681. gl.DRAW_BUFFER6_NV = 0x882b;
  4682. gl.DRAW_BUFFER7_NV = 0x882c;
  4683. gl.DRAW_BUFFER8_NV = 0x882d;
  4684. gl.DRAW_BUFFER9_NV = 0x882e;
  4685. gl.DRAW_BUFFER_EXT = 0xc01;
  4686. gl.DRAW_FRAMEBUFFER_ANGLE = 0x8ca9;
  4687. gl.DRAW_FRAMEBUFFER_APPLE = 0x8ca9;
  4688. gl.DRAW_FRAMEBUFFER_BINDING_ANGLE = 0x8ca6;
  4689. gl.DRAW_FRAMEBUFFER_BINDING_APPLE = 0x8ca6;
  4690. gl.DRAW_FRAMEBUFFER_BINDING_NV = 0x8ca6;
  4691. gl.DRAW_FRAMEBUFFER_NV = 0x8ca9;
  4692. gl.DST_ALPHA = 0x304;
  4693. gl.DST_COLOR = 0x306;
  4694. gl.DYNAMIC_DRAW = 0x88e8;
  4695. gl.ELEMENT_ARRAY_BUFFER = 0x8893;
  4696. gl.ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
  4697. gl.EQUAL = 0x202;
  4698. gl.ES_VERSION_2_0 = 0x1;
  4699. gl.ETC1_RGB8_OES = 0x8d64;
  4700. gl.ETC1_SRGB8_NV = 0x88ee;
  4701. gl.EXTENSIONS = 0x1f03;
  4702. gl.EXT_blend_minmax = 0x1;
  4703. gl.EXT_color_buffer_half_float = 0x1;
  4704. gl.EXT_debug_label = 0x1;
  4705. gl.EXT_debug_marker = 0x1;
  4706. gl.EXT_discard_framebuffer = 0x1;
  4707. gl.EXT_map_buffer_range = 0x1;
  4708. gl.EXT_multi_draw_arrays = 0x1;
  4709. gl.EXT_multisampled_render_to_texture = 0x1;
  4710. gl.EXT_multiview_draw_buffers = 0x1;
  4711. gl.EXT_occlusion_query_boolean = 0x1;
  4712. gl.EXT_read_format_bgra = 0x1;
  4713. gl.EXT_robustness = 0x1;
  4714. gl.EXT_sRGB = 0x1;
  4715. gl.EXT_separate_shader_objects = 0x1;
  4716. gl.EXT_shader_framebuffer_fetch = 0x1;
  4717. gl.EXT_shader_texture_lod = 0x1;
  4718. gl.EXT_shadow_samplers = 0x1;
  4719. gl.EXT_texture_compression_dxt1 = 0x1;
  4720. gl.EXT_texture_filter_anisotropic = 0x1;
  4721. gl.EXT_texture_format_BGRA8888 = 0x1;
  4722. gl.EXT_texture_rg = 0x1;
  4723. gl.EXT_texture_storage = 0x1;
  4724. gl.EXT_texture_type_2_10_10_10_REV = 0x1;
  4725. gl.EXT_unpack_subimage = 0x1;
  4726. gl.FALSE = 0x0;
  4727. gl.FASTEST = 0x1101;
  4728. gl.FENCE_CONDITION_NV = 0x84f4;
  4729. gl.FENCE_STATUS_NV = 0x84f3;
  4730. gl.FIXED = 0x140c;
  4731. gl.FJ_shader_binary_GCCSO = 0x1;
  4732. gl.FLOAT = 0x1406;
  4733. gl.FLOAT_MAT2 = 0x8b5a;
  4734. gl.FLOAT_MAT3 = 0x8b5b;
  4735. gl.FLOAT_MAT4 = 0x8b5c;
  4736. gl.FLOAT_VEC2 = 0x8b50;
  4737. gl.FLOAT_VEC3 = 0x8b51;
  4738. gl.FLOAT_VEC4 = 0x8b52;
  4739. gl.FRAGMENT_SHADER = 0x8b30;
  4740. gl.FRAGMENT_SHADER_BIT_EXT = 0x2;
  4741. gl.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8b8b;
  4742. gl.FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT = 0x8a52;
  4743. gl.FRAMEBUFFER = 0x8d40;
  4744. gl.FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93a3;
  4745. gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210;
  4746. gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 0x8211;
  4747. gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8cd1;
  4748. gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8cd0;
  4749. gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES = 0x8cd4;
  4750. gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8cd3;
  4751. gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8cd2;
  4752. gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT = 0x8d6c;
  4753. gl.FRAMEBUFFER_BINDING = 0x8ca6;
  4754. gl.FRAMEBUFFER_COMPLETE = 0x8cd5;
  4755. gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8cd6;
  4756. gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9;
  4757. gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8cd7;
  4758. gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE = 0x8d56;
  4759. gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE = 0x8d56;
  4760. gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8d56;
  4761. gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134;
  4762. gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV = 0x8d56;
  4763. gl.FRAMEBUFFER_UNDEFINED_OES = 0x8219;
  4764. gl.FRAMEBUFFER_UNSUPPORTED = 0x8cdd;
  4765. gl.FRONT = 0x404;
  4766. gl.FRONT_AND_BACK = 0x408;
  4767. gl.FRONT_FACE = 0xb46;
  4768. gl.FUNC_ADD = 0x8006;
  4769. gl.FUNC_REVERSE_SUBTRACT = 0x800b;
  4770. gl.FUNC_SUBTRACT = 0x800a;
  4771. gl.GENERATE_MIPMAP_HINT = 0x8192;
  4772. gl.GEQUAL = 0x206;
  4773. gl.GPU_OPTIMIZED_QCOM = 0x8fb2;
  4774. gl.GREATER = 0x204;
  4775. gl.GREEN_BITS = 0xd53;
  4776. gl.GUILTY_CONTEXT_RESET_EXT = 0x8253;
  4777. gl.HALF_FLOAT_OES = 0x8d61;
  4778. gl.HIGH_FLOAT = 0x8df2;
  4779. gl.HIGH_INT = 0x8df5;
  4780. gl.IMG_multisampled_render_to_texture = 0x1;
  4781. gl.IMG_program_binary = 0x1;
  4782. gl.IMG_read_format = 0x1;
  4783. gl.IMG_shader_binary = 0x1;
  4784. gl.IMG_texture_compression_pvrtc = 0x1;
  4785. gl.IMG_texture_compression_pvrtc2 = 0x1;
  4786. gl.IMPLEMENTATION_COLOR_READ_FORMAT = 0x8b9b;
  4787. gl.IMPLEMENTATION_COLOR_READ_TYPE = 0x8b9a;
  4788. gl.INCR = 0x1e02;
  4789. gl.INCR_WRAP = 0x8507;
  4790. gl.INFO_LOG_LENGTH = 0x8b84;
  4791. gl.INNOCENT_CONTEXT_RESET_EXT = 0x8254;
  4792. gl.INT = 0x1404;
  4793. gl.INT_10_10_10_2_OES = 0x8df7;
  4794. gl.INT_VEC2 = 0x8b53;
  4795. gl.INT_VEC3 = 0x8b54;
  4796. gl.INT_VEC4 = 0x8b55;
  4797. gl.INVALID_ENUM = 0x500;
  4798. gl.INVALID_FRAMEBUFFER_OPERATION = 0x506;
  4799. gl.INVALID_OPERATION = 0x502;
  4800. gl.INVALID_VALUE = 0x501;
  4801. gl.INVERT = 0x150a;
  4802. gl.KEEP = 0x1e00;
  4803. gl.KHR_debug = 0x1;
  4804. gl.KHR_texture_compression_astc_ldr = 0x1;
  4805. gl.LEFT = 0x0406;
  4806. gl.LEQUAL = 0x203;
  4807. gl.LESS = 0x201;
  4808. gl.LINEAR = 0x2601;
  4809. gl.LINEAR_MIPMAP_LINEAR = 0x2703;
  4810. gl.LINEAR_MIPMAP_NEAREST = 0x2701;
  4811. gl.LINES = 0x1;
  4812. gl.LINE_LOOP = 0x2;
  4813. gl.LINE_STRIP = 0x3;
  4814. gl.LINE_WIDTH = 0xb21;
  4815. gl.LINK_STATUS = 0x8b82;
  4816. gl.LOSE_CONTEXT_ON_RESET_EXT = 0x8252;
  4817. gl.LOW_FLOAT = 0x8df0;
  4818. gl.LOW_INT = 0x8df3;
  4819. gl.LUMINANCE = 0x1909;
  4820. gl.LUMINANCE16F_EXT = 0x881e;
  4821. gl.LUMINANCE32F_EXT = 0x8818;
  4822. gl.LUMINANCE4_ALPHA4_OES = 0x8043;
  4823. gl.LUMINANCE8_ALPHA8_EXT = 0x8045;
  4824. gl.LUMINANCE8_ALPHA8_OES = 0x8045;
  4825. gl.LUMINANCE8_EXT = 0x8040;
  4826. gl.LUMINANCE8_OES = 0x8040;
  4827. gl.LUMINANCE_ALPHA = 0x190a;
  4828. gl.LUMINANCE_ALPHA16F_EXT = 0x881f;
  4829. gl.LUMINANCE_ALPHA32F_EXT = 0x8819;
  4830. gl.MALI_PROGRAM_BINARY_ARM = 0x8f61;
  4831. gl.MALI_SHADER_BINARY_ARM = 0x8f60;
  4832. gl.MAP_FLUSH_EXPLICIT_BIT_EXT = 0x10;
  4833. gl.MAP_INVALIDATE_BUFFER_BIT_EXT = 0x8;
  4834. gl.MAP_INVALIDATE_RANGE_BIT_EXT = 0x4;
  4835. gl.MAP_READ_BIT_EXT = 0x1;
  4836. gl.MAP_UNSYNCHRONIZED_BIT_EXT = 0x20;
  4837. gl.MAP_WRITE_BIT_EXT = 0x2;
  4838. gl.MAX_3D_TEXTURE_SIZE_OES = 0x8073;
  4839. gl.MAX_COLOR_ATTACHMENTS_NV = 0x8cdf;
  4840. gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8b4d;
  4841. gl.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c;
  4842. gl.MAX_DEBUG_GROUP_STACK_DEPTH = 0x826c;
  4843. gl.MAX_DEBUG_LOGGED_MESSAGES = 0x9144;
  4844. gl.MAX_DEBUG_MESSAGE_LENGTH = 0x9143;
  4845. gl.MAX_DRAW_BUFFERS_NV = 0x8824;
  4846. gl.MAX_EXT = 0x8008;
  4847. gl.MAX_FRAGMENT_UNIFORM_VECTORS = 0x8dfd;
  4848. gl.MAX_LABEL_LENGTH = 0x82e8;
  4849. gl.MAX_MULTIVIEW_BUFFERS_EXT = 0x90f2;
  4850. gl.MAX_RENDERBUFFER_SIZE = 0x84e8;
  4851. gl.MAX_SAMPLES_ANGLE = 0x8d57;
  4852. gl.MAX_SAMPLES_APPLE = 0x8d57;
  4853. gl.MAX_SAMPLES_EXT = 0x8d57;
  4854. gl.MAX_SAMPLES_IMG = 0x9135;
  4855. gl.MAX_SAMPLES_NV = 0x8d57;
  4856. gl.MAX_SERVER_WAIT_TIMEOUT_APPLE = 0x9111;
  4857. gl.MAX_TEXTURE_IMAGE_UNITS = 0x8872;
  4858. gl.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff;
  4859. gl.MAX_TEXTURE_SIZE = 0xd33;
  4860. gl.MAX_VARYING_VECTORS = 0x8dfc;
  4861. gl.MAX_VERTEX_ATTRIBS = 0x8869;
  4862. gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8b4c;
  4863. gl.MAX_VERTEX_UNIFORM_VECTORS = 0x8dfb;
  4864. gl.MAX_VIEWPORT_DIMS = 0xd3a;
  4865. gl.MEDIUM_FLOAT = 0x8df1;
  4866. gl.MEDIUM_INT = 0x8df4;
  4867. gl.MIN_EXT = 0x8007;
  4868. gl.MIRRORED_REPEAT = 0x8370;
  4869. gl.MULTISAMPLE_BUFFER_BIT0_QCOM = 0x1000000;
  4870. gl.MULTISAMPLE_BUFFER_BIT1_QCOM = 0x2000000;
  4871. gl.MULTISAMPLE_BUFFER_BIT2_QCOM = 0x4000000;
  4872. gl.MULTISAMPLE_BUFFER_BIT3_QCOM = 0x8000000;
  4873. gl.MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000;
  4874. gl.MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000;
  4875. gl.MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000;
  4876. gl.MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000;
  4877. gl.MULTIVIEW_EXT = 0x90f1;
  4878. gl.NEAREST = 0x2600;
  4879. gl.NEAREST_MIPMAP_LINEAR = 0x2702;
  4880. gl.NEAREST_MIPMAP_NEAREST = 0x2700;
  4881. gl.NEVER = 0x200;
  4882. gl.NICEST = 0x1102;
  4883. gl.NONE = 0x0;
  4884. gl.NOTEQUAL = 0x205;
  4885. gl.NO_ERROR = 0x0;
  4886. gl.NO_RESET_NOTIFICATION_EXT = 0x8261;
  4887. gl.NUM_COMPRESSED_TEXTURE_FORMATS = 0x86a2;
  4888. gl.NUM_PROGRAM_BINARY_FORMATS_OES = 0x87fe;
  4889. gl.NUM_SHADER_BINARY_FORMATS = 0x8df9;
  4890. gl.NV_coverage_sample = 0x1;
  4891. gl.NV_depth_nonlinear = 0x1;
  4892. gl.NV_draw_buffers = 0x1;
  4893. gl.NV_draw_instanced = 0x1;
  4894. gl.NV_fbo_color_attachments = 0x1;
  4895. gl.NV_fence = 0x1;
  4896. gl.NV_framebuffer_blit = 0x1;
  4897. gl.NV_framebuffer_multisample = 0x1;
  4898. gl.NV_generate_mipmap_sRGB = 0x1;
  4899. gl.NV_instanced_arrays = 0x1;
  4900. gl.NV_read_buffer = 0x1;
  4901. gl.NV_read_buffer_front = 0x1;
  4902. gl.NV_read_depth = 0x1;
  4903. gl.NV_read_depth_stencil = 0x1;
  4904. gl.NV_read_stencil = 0x1;
  4905. gl.NV_sRGB_formats = 0x1;
  4906. gl.NV_shadow_samplers_array = 0x1;
  4907. gl.NV_shadow_samplers_cube = 0x1;
  4908. gl.NV_texture_border_clamp = 0x1;
  4909. gl.NV_texture_compression_s3tc_update = 0x1;
  4910. gl.NV_texture_npot_2D_mipmap = 0x1;
  4911. gl.OBJECT_TYPE_APPLE = 0x9112;
  4912. gl.OES_EGL_image = 0x1;
  4913. gl.OES_EGL_image_external = 0x1;
  4914. gl.OES_compressed_ETC1_RGB8_texture = 0x1;
  4915. gl.OES_compressed_paletted_texture = 0x1;
  4916. gl.OES_depth24 = 0x1;
  4917. gl.OES_depth32 = 0x1;
  4918. gl.OES_depth_texture = 0x1;
  4919. gl.OES_element_index_uint = 0x1;
  4920. gl.OES_fbo_render_mipmap = 0x1;
  4921. gl.OES_fragment_precision_high = 0x1;
  4922. gl.OES_get_program_binary = 0x1;
  4923. gl.OES_mapbuffer = 0x1;
  4924. gl.OES_packed_depth_stencil = 0x1;
  4925. gl.OES_required_internalformat = 0x1;
  4926. gl.OES_rgb8_rgba8 = 0x1;
  4927. gl.OES_standard_derivatives = 0x1;
  4928. gl.OES_stencil1 = 0x1;
  4929. gl.OES_stencil4 = 0x1;
  4930. gl.OES_surfaceless_context = 0x1;
  4931. gl.OES_texture_3D = 0x1;
  4932. gl.OES_texture_float = 0x1;
  4933. gl.OES_texture_float_linear = 0x1;
  4934. gl.OES_texture_half_float = 0x1;
  4935. gl.OES_texture_half_float_linear = 0x1;
  4936. gl.OES_texture_npot = 0x1;
  4937. gl.OES_vertex_array_object = 0x1;
  4938. gl.OES_vertex_half_float = 0x1;
  4939. gl.OES_vertex_type_10_10_10_2 = 0x1;
  4940. gl.ONE = 0x1;
  4941. gl.ONE_MINUS_CONSTANT_ALPHA = 0x8004;
  4942. gl.ONE_MINUS_CONSTANT_COLOR = 0x8002;
  4943. gl.ONE_MINUS_DST_ALPHA = 0x305;
  4944. gl.ONE_MINUS_DST_COLOR = 0x307;
  4945. gl.ONE_MINUS_SRC_ALPHA = 0x303;
  4946. gl.ONE_MINUS_SRC_COLOR = 0x301;
  4947. gl.OUT_OF_MEMORY = 0x505;
  4948. gl.PACK_ALIGNMENT = 0xd05;
  4949. gl.PACK_REVERSE_ROW_ORDER_ANGLE = 0x93a4;
  4950. gl.PALETTE4_R5_G6_B5_OES = 0x8b92;
  4951. gl.PALETTE4_RGB5_A1_OES = 0x8b94;
  4952. gl.PALETTE4_RGB8_OES = 0x8b90;
  4953. gl.PALETTE4_RGBA4_OES = 0x8b93;
  4954. gl.PALETTE4_RGBA8_OES = 0x8b91;
  4955. gl.PALETTE8_R5_G6_B5_OES = 0x8b97;
  4956. gl.PALETTE8_RGB5_A1_OES = 0x8b99;
  4957. gl.PALETTE8_RGB8_OES = 0x8b95;
  4958. gl.PALETTE8_RGBA4_OES = 0x8b98;
  4959. gl.PALETTE8_RGBA8_OES = 0x8b96;
  4960. gl.PERCENTAGE_AMD = 0x8bc3;
  4961. gl.PERFMON_GLOBAL_MODE_QCOM = 0x8fa0;
  4962. gl.PERFMON_RESULT_AMD = 0x8bc6;
  4963. gl.PERFMON_RESULT_AVAILABLE_AMD = 0x8bc4;
  4964. gl.PERFMON_RESULT_SIZE_AMD = 0x8bc5;
  4965. gl.POINTS = 0x0;
  4966. gl.POLYGON_OFFSET_FACTOR = 0x8038;
  4967. gl.POLYGON_OFFSET_FILL = 0x8037;
  4968. gl.POLYGON_OFFSET_UNITS = 0x2a00;
  4969. gl.PROGRAM = 0x82e2;
  4970. gl.PROGRAM_BINARY_ANGLE = 0x93a6;
  4971. gl.PROGRAM_BINARY_FORMATS_OES = 0x87ff;
  4972. gl.PROGRAM_BINARY_LENGTH_OES = 0x8741;
  4973. gl.PROGRAM_OBJECT_EXT = 0x8b40;
  4974. gl.PROGRAM_PIPELINE_BINDING_EXT = 0x825a;
  4975. gl.PROGRAM_PIPELINE_OBJECT_EXT = 0x8a4f;
  4976. gl.PROGRAM_SEPARABLE_EXT = 0x8258;
  4977. gl.QCOM_alpha_test = 0x1;
  4978. gl.QCOM_binning_control = 0x1;
  4979. gl.QCOM_driver_control = 0x1;
  4980. gl.QCOM_extended_get = 0x1;
  4981. gl.QCOM_extended_get2 = 0x1;
  4982. gl.QCOM_perfmon_global_mode = 0x1;
  4983. gl.QCOM_tiled_rendering = 0x1;
  4984. gl.QCOM_writeonly_rendering = 0x1;
  4985. gl.QUERY = 0x82e3;
  4986. gl.QUERY_OBJECT_EXT = 0x9153;
  4987. gl.QUERY_RESULT_AVAILABLE_EXT = 0x8867;
  4988. gl.QUERY_RESULT_EXT = 0x8866;
  4989. gl.R16F_EXT = 0x822d;
  4990. gl.R32F_EXT = 0x822e;
  4991. gl.R8_EXT = 0x8229;
  4992. gl.READ_BUFFER_EXT = 0xc02;
  4993. gl.READ_BUFFER_NV = 0xc02;
  4994. gl.READ_FRAMEBUFFER_ANGLE = 0x8ca8;
  4995. gl.READ_FRAMEBUFFER_APPLE = 0x8ca8;
  4996. gl.READ_FRAMEBUFFER_BINDING_ANGLE = 0x8caa;
  4997. gl.READ_FRAMEBUFFER_BINDING_APPLE = 0x8caa;
  4998. gl.READ_FRAMEBUFFER_BINDING_NV = 0x8caa;
  4999. gl.READ_FRAMEBUFFER_NV = 0x8ca8;
  5000. gl.RED_BITS = 0xd52;
  5001. gl.RED_EXT = 0x1903;
  5002. gl.RENDERBUFFER = 0x8d41;
  5003. gl.RENDERBUFFER_ALPHA_SIZE = 0x8d53;
  5004. gl.RENDERBUFFER_BINDING = 0x8ca7;
  5005. gl.RENDERBUFFER_BLUE_SIZE = 0x8d52;
  5006. gl.RENDERBUFFER_DEPTH_SIZE = 0x8d54;
  5007. gl.RENDERBUFFER_GREEN_SIZE = 0x8d51;
  5008. gl.RENDERBUFFER_HEIGHT = 0x8d43;
  5009. gl.RENDERBUFFER_INTERNAL_FORMAT = 0x8d44;
  5010. gl.RENDERBUFFER_RED_SIZE = 0x8d50;
  5011. gl.RENDERBUFFER_SAMPLES_ANGLE = 0x8cab;
  5012. gl.RENDERBUFFER_SAMPLES_APPLE = 0x8cab;
  5013. gl.RENDERBUFFER_SAMPLES_EXT = 0x8cab;
  5014. gl.RENDERBUFFER_SAMPLES_IMG = 0x9133;
  5015. gl.RENDERBUFFER_SAMPLES_NV = 0x8cab;
  5016. gl.RENDERBUFFER_STENCIL_SIZE = 0x8d55;
  5017. gl.RENDERBUFFER_WIDTH = 0x8d42;
  5018. gl.RENDERER = 0x1f01;
  5019. gl.RENDER_DIRECT_TO_FRAMEBUFFER_QCOM = 0x8fb3;
  5020. gl.REPEAT = 0x2901;
  5021. gl.REPLACE = 0x1e01;
  5022. gl.REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8d68;
  5023. gl.RESET_NOTIFICATION_STRATEGY_EXT = 0x8256;
  5024. gl.RG16F_EXT = 0x822f;
  5025. gl.RG32F_EXT = 0x8230;
  5026. gl.RG8_EXT = 0x822b;
  5027. gl.RGB = 0x1907;
  5028. gl.RGB10_A2_EXT = 0x8059;
  5029. gl.RGB10_EXT = 0x8052;
  5030. gl.RGB16F_EXT = 0x881b;
  5031. gl.RGB32F_EXT = 0x8815;
  5032. gl.RGB565 = 0x8d62;
  5033. gl.RGB565_OES = 0x8d62;
  5034. gl.RGB5_A1 = 0x8057;
  5035. gl.RGB5_A1_OES = 0x8057;
  5036. gl.RGB8_OES = 0x8051;
  5037. gl.RGBA = 0x1908;
  5038. gl.RGBA16F_EXT = 0x881a;
  5039. gl.RGBA32F_EXT = 0x8814;
  5040. gl.RGBA4 = 0x8056;
  5041. gl.RGBA4_OES = 0x8056;
  5042. gl.RGBA8_OES = 0x8058;
  5043. gl.RGB_422_APPLE = 0x8a1f;
  5044. gl.RG_EXT = 0x8227;
  5045. gl.RIGHT = 0x0407;
  5046. gl.SAMPLER = 0x82e6;
  5047. gl.SAMPLER_2D = 0x8b5e;
  5048. gl.SAMPLER_2D_ARRAY_SHADOW_NV = 0x8dc4;
  5049. gl.SAMPLER_2D_SHADOW_EXT = 0x8b62;
  5050. gl.SAMPLER_3D_OES = 0x8b5f;
  5051. gl.SAMPLER_CUBE = 0x8b60;
  5052. gl.SAMPLER_CUBE_SHADOW_NV = 0x8dc5;
  5053. gl.SAMPLER_EXTERNAL_OES = 0x8d66;
  5054. gl.SAMPLES = 0x80a9;
  5055. gl.SAMPLE_ALPHA_TO_COVERAGE = 0x809e;
  5056. gl.SAMPLE_BUFFERS = 0x80a8;
  5057. gl.SAMPLE_COVERAGE = 0x80a0;
  5058. gl.SAMPLE_COVERAGE_INVERT = 0x80ab;
  5059. gl.SAMPLE_COVERAGE_VALUE = 0x80aa;
  5060. gl.SCISSOR_BOX = 0xc10;
  5061. gl.SCISSOR_TEST = 0xc11;
  5062. gl.SGX_BINARY_IMG = 0x8c0a;
  5063. gl.SGX_PROGRAM_BINARY_IMG = 0x9130;
  5064. gl.SHADER = 0x82e1;
  5065. gl.SHADER_BINARY_DMP = 0x9250;
  5066. gl.SHADER_BINARY_FORMATS = 0x8df8;
  5067. gl.SHADER_BINARY_VIV = 0x8fc4;
  5068. gl.SHADER_COMPILER = 0x8dfa;
  5069. gl.SHADER_OBJECT_EXT = 0x8b48;
  5070. gl.SHADER_SOURCE_LENGTH = 0x8b88;
  5071. gl.SHADER_TYPE = 0x8b4f;
  5072. gl.SHADING_LANGUAGE_VERSION = 0x8b8c;
  5073. gl.SHORT = 0x1402;
  5074. gl.SIGNALED_APPLE = 0x9119;
  5075. gl.SLUMINANCE8_ALPHA8_NV = 0x8c45;
  5076. gl.SLUMINANCE8_NV = 0x8c47;
  5077. gl.SLUMINANCE_ALPHA_NV = 0x8c44;
  5078. gl.SLUMINANCE_NV = 0x8c46;
  5079. gl.SRC_ALPHA = 0x302;
  5080. gl.SRC_ALPHA_SATURATE = 0x308;
  5081. gl.SRC_COLOR = 0x300;
  5082. gl.SRGB8_ALPHA8_EXT = 0x8c43;
  5083. gl.SRGB8_NV = 0x8c41;
  5084. gl.SRGB_ALPHA_EXT = 0x8c42;
  5085. gl.SRGB_EXT = 0x8c40;
  5086. gl.STACK_OVERFLOW = 0x503;
  5087. gl.STACK_UNDERFLOW = 0x504;
  5088. gl.STATE_RESTORE = 0x8bdc;
  5089. gl.STATIC_DRAW = 0x88e4;
  5090. gl.STENCIL_ATTACHMENT = 0x8d20;
  5091. gl.STENCIL_BACK_FAIL = 0x8801;
  5092. gl.STENCIL_BACK_FUNC = 0x8800;
  5093. gl.STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
  5094. gl.STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
  5095. gl.STENCIL_BACK_REF = 0x8ca3;
  5096. gl.STENCIL_BACK_VALUE_MASK = 0x8ca4;
  5097. gl.STENCIL_BACK_WRITEMASK = 0x8ca5;
  5098. gl.STENCIL_BITS = 0xd57;
  5099. gl.STENCIL_BUFFER_BIT = 0x400;
  5100. gl.STENCIL_BUFFER_BIT0_QCOM = 0x10000;
  5101. gl.STENCIL_BUFFER_BIT1_QCOM = 0x20000;
  5102. gl.STENCIL_BUFFER_BIT2_QCOM = 0x40000;
  5103. gl.STENCIL_BUFFER_BIT3_QCOM = 0x80000;
  5104. gl.STENCIL_BUFFER_BIT4_QCOM = 0x100000;
  5105. gl.STENCIL_BUFFER_BIT5_QCOM = 0x200000;
  5106. gl.STENCIL_BUFFER_BIT6_QCOM = 0x400000;
  5107. gl.STENCIL_BUFFER_BIT7_QCOM = 0x800000;
  5108. gl.STENCIL_CLEAR_VALUE = 0xb91;
  5109. gl.STENCIL_EXT = 0x1802;
  5110. gl.STENCIL_FAIL = 0xb94;
  5111. gl.STENCIL_FUNC = 0xb92;
  5112. gl.STENCIL_INDEX1_OES = 0x8d46;
  5113. gl.STENCIL_INDEX4_OES = 0x8d47;
  5114. gl.STENCIL_INDEX = 0x1901;
  5115. gl.STENCIL_INDEX8 = 0x8d48;
  5116. gl.STENCIL_PASS_DEPTH_FAIL = 0xb95;
  5117. gl.STENCIL_PASS_DEPTH_PASS = 0xb96;
  5118. gl.STENCIL_REF = 0xb97;
  5119. gl.STENCIL_TEST = 0xb90;
  5120. gl.STENCIL_VALUE_MASK = 0xb93;
  5121. gl.STENCIL_WRITEMASK = 0xb98;
  5122. gl.STREAM_DRAW = 0x88e0;
  5123. gl.SUBPIXEL_BITS = 0xd50;
  5124. gl.SYNC_CONDITION_APPLE = 0x9113;
  5125. gl.SYNC_FENCE_APPLE = 0x9116;
  5126. gl.SYNC_FLAGS_APPLE = 0x9115;
  5127. gl.SYNC_FLUSH_COMMANDS_BIT_APPLE = 0x1;
  5128. gl.SYNC_GPU_COMMANDS_COMPLETE_APPLE = 0x9117;
  5129. gl.SYNC_OBJECT_APPLE = 0x8a53;
  5130. gl.SYNC_STATUS_APPLE = 0x9114;
  5131. gl.TEXTURE = 0x1702;
  5132. gl.TEXTURE0 = 0x84c0;
  5133. gl.TEXTURE1 = 0x84c1;
  5134. gl.TEXTURE10 = 0x84ca;
  5135. gl.TEXTURE11 = 0x84cb;
  5136. gl.TEXTURE12 = 0x84cc;
  5137. gl.TEXTURE13 = 0x84cd;
  5138. gl.TEXTURE14 = 0x84ce;
  5139. gl.TEXTURE15 = 0x84cf;
  5140. gl.TEXTURE16 = 0x84d0;
  5141. gl.TEXTURE17 = 0x84d1;
  5142. gl.TEXTURE18 = 0x84d2;
  5143. gl.TEXTURE19 = 0x84d3;
  5144. gl.TEXTURE2 = 0x84c2;
  5145. gl.TEXTURE20 = 0x84d4;
  5146. gl.TEXTURE21 = 0x84d5;
  5147. gl.TEXTURE22 = 0x84d6;
  5148. gl.TEXTURE23 = 0x84d7;
  5149. gl.TEXTURE24 = 0x84d8;
  5150. gl.TEXTURE25 = 0x84d9;
  5151. gl.TEXTURE26 = 0x84da;
  5152. gl.TEXTURE27 = 0x84db;
  5153. gl.TEXTURE28 = 0x84dc;
  5154. gl.TEXTURE29 = 0x84dd;
  5155. gl.TEXTURE3 = 0x84c3;
  5156. gl.TEXTURE30 = 0x84de;
  5157. gl.TEXTURE31 = 0x84df;
  5158. gl.TEXTURE4 = 0x84c4;
  5159. gl.TEXTURE5 = 0x84c5;
  5160. gl.TEXTURE6 = 0x84c6;
  5161. gl.TEXTURE7 = 0x84c7;
  5162. gl.TEXTURE8 = 0x84c8;
  5163. gl.TEXTURE9 = 0x84c9;
  5164. gl.TEXTURE_2D = 0xde1;
  5165. gl.TEXTURE_3D_OES = 0x806f;
  5166. gl.TEXTURE_BINDING_2D = 0x8069;
  5167. gl.TEXTURE_BINDING_3D_OES = 0x806a;
  5168. gl.TEXTURE_BINDING_CUBE_MAP = 0x8514;
  5169. gl.TEXTURE_BINDING_EXTERNAL_OES = 0x8d67;
  5170. gl.TEXTURE_BORDER_COLOR_NV = 0x1004;
  5171. gl.TEXTURE_COMPARE_FUNC_EXT = 0x884d;
  5172. gl.TEXTURE_COMPARE_MODE_EXT = 0x884c;
  5173. gl.TEXTURE_CUBE_MAP = 0x8513;
  5174. gl.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
  5175. gl.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
  5176. gl.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a;
  5177. gl.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
  5178. gl.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
  5179. gl.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
  5180. gl.TEXTURE_DEPTH_QCOM = 0x8bd4;
  5181. gl.TEXTURE_EXTERNAL_OES = 0x8d65;
  5182. gl.TEXTURE_FORMAT_QCOM = 0x8bd6;
  5183. gl.TEXTURE_HEIGHT_QCOM = 0x8bd3;
  5184. gl.TEXTURE_IMAGE_VALID_QCOM = 0x8bd8;
  5185. gl.TEXTURE_IMMUTABLE_FORMAT_EXT = 0x912f;
  5186. gl.TEXTURE_INTERNAL_FORMAT_QCOM = 0x8bd5;
  5187. gl.TEXTURE_MAG_FILTER = 0x2800;
  5188. gl.TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe;
  5189. gl.TEXTURE_MAX_LEVEL_APPLE = 0x813d;
  5190. gl.TEXTURE_MIN_FILTER = 0x2801;
  5191. gl.TEXTURE_NUM_LEVELS_QCOM = 0x8bd9;
  5192. gl.TEXTURE_OBJECT_VALID_QCOM = 0x8bdb;
  5193. gl.TEXTURE_SAMPLES_IMG = 0x9136;
  5194. gl.TEXTURE_TARGET_QCOM = 0x8bda;
  5195. gl.TEXTURE_TYPE_QCOM = 0x8bd7;
  5196. gl.TEXTURE_USAGE_ANGLE = 0x93a2;
  5197. gl.TEXTURE_WIDTH_QCOM = 0x8bd2;
  5198. gl.TEXTURE_WRAP_R_OES = 0x8072;
  5199. gl.TEXTURE_WRAP_S = 0x2802;
  5200. gl.TEXTURE_WRAP_T = 0x2803;
  5201. gl.TIMEOUT_EXPIRED_APPLE = 0x911b;
  5202. gl.TIMEOUT_IGNORED_APPLE = 0xffffffffffffffff;
  5203. gl.TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93a0;
  5204. gl.TRIANGLES = 0x4;
  5205. gl.TRIANGLE_FAN = 0x6;
  5206. gl.TRIANGLE_STRIP = 0x5;
  5207. gl.TRUE = 0x1;
  5208. gl.UNKNOWN_CONTEXT_RESET_EXT = 0x8255;
  5209. gl.UNPACK_ALIGNMENT = 0xcf5;
  5210. gl.UNPACK_ROW_LENGTH = 0xcf2;
  5211. gl.UNPACK_SKIP_PIXELS = 0xcf4;
  5212. gl.UNPACK_SKIP_ROWS = 0xcf3;
  5213. gl.UNSIGNALED_APPLE = 0x9118;
  5214. gl.UNSIGNED_BYTE = 0x1401;
  5215. gl.UNSIGNED_INT = 0x1405;
  5216. gl.UNSIGNED_INT64_AMD = 0x8bc2;
  5217. gl.UNSIGNED_INT_10_10_10_2_OES = 0x8df6;
  5218. gl.UNSIGNED_INT_24_8_OES = 0x84fa;
  5219. gl.UNSIGNED_INT_2_10_10_10_REV_EXT = 0x8368;
  5220. gl.UNSIGNED_NORMALIZED_EXT = 0x8c17;
  5221. gl.UNSIGNED_SHORT = 0x1403;
  5222. gl.UNSIGNED_SHORT_1_5_5_5_REV_EXT = 0x8366;
  5223. gl.UNSIGNED_SHORT_4_4_4_4 = 0x8033;
  5224. gl.UNSIGNED_SHORT_4_4_4_4_REV_EXT = 0x8365;
  5225. gl.UNSIGNED_SHORT_4_4_4_4_REV_IMG = 0x8365;
  5226. gl.UNSIGNED_SHORT_5_5_5_1 = 0x8034;
  5227. gl.UNSIGNED_SHORT_5_6_5 = 0x8363;
  5228. gl.UNSIGNED_SHORT_8_8_APPLE = 0x85ba;
  5229. gl.UNSIGNED_SHORT_8_8_REV_APPLE = 0x85bb;
  5230. gl.VALIDATE_STATUS = 0x8b83;
  5231. gl.VENDOR = 0x1f00;
  5232. gl.VERSION = 0x1f02;
  5233. gl.VERTEX_ARRAY_BINDING_OES = 0x85b5;
  5234. gl.VERTEX_ARRAY_OBJECT_EXT = 0x9154;
  5235. gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f;
  5236. gl.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88fe;
  5237. gl.VERTEX_ATTRIB_ARRAY_DIVISOR_NV = 0x88fe;
  5238. gl.VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
  5239. gl.VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886a;
  5240. gl.VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
  5241. gl.VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
  5242. gl.VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
  5243. gl.VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
  5244. gl.VERTEX_SHADER = 0x8b31;
  5245. gl.VERTEX_SHADER_BIT_EXT = 0x1;
  5246. gl.VIEWPORT = 0xba2;
  5247. gl.VIV_shader_binary = 0x1;
  5248. gl.WAIT_FAILED_APPLE = 0x911d;
  5249. gl.WRITEONLY_RENDERING_QCOM = 0x8823;
  5250. gl.WRITE_ONLY_OES = 0x88b9;
  5251. gl.Z400_BINARY_AMD = 0x8740;
  5252. gl.ZERO = 0x0;
  5253. gl.RASTERIZER_DISCARD = 0x8C89;
  5254. gl.UNPACK_FLIP_Y_WEBGL = 0x9240;
  5255. gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
  5256. gl.CONTEXT_LOST_WEBGL = 0x9242;
  5257. gl.UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
  5258. gl.BROWSER_DEFAULT_WEBGL = 0x9244;
  5259. },{}],36:[function(require,module,exports){
  5260. "use strict";
  5261. jsb.__obj_ref_id = 0;
  5262. jsb.registerNativeRef = function (owner, target) {
  5263. if (owner && target && owner !== target) {
  5264. var targetID = target.__jsb_ref_id;
  5265. if (targetID === undefined) targetID = target.__jsb_ref_id = jsb.__obj_ref_id++;
  5266. var refs = owner.__nativeRefs;
  5267. if (!refs) {
  5268. refs = owner.__nativeRefs = {};
  5269. }
  5270. refs[targetID] = target;
  5271. }
  5272. };
  5273. jsb.unregisterNativeRef = function (owner, target) {
  5274. if (owner && target && owner !== target) {
  5275. var targetID = target.__jsb_ref_id;
  5276. if (targetID === undefined) return;
  5277. var refs = owner.__nativeRefs;
  5278. if (!refs) {
  5279. return;
  5280. }
  5281. delete refs[targetID];
  5282. }
  5283. };
  5284. jsb.unregisterAllNativeRefs = function (owner) {
  5285. if (!owner) return;
  5286. delete owner.__nativeRefs;
  5287. };
  5288. jsb.unregisterChildRefsForNode = function (node, recursive) {
  5289. recursive = !!recursive;
  5290. var children = node.getChildren(),
  5291. i,
  5292. l,
  5293. child;
  5294. for (i = 0, l = children.length; i < l; ++i) {
  5295. child = children[i];
  5296. jsb.unregisterNativeRef(node, child);
  5297. if (recursive) {
  5298. jsb.unregisterChildRefsForNode(child, recursive);
  5299. }
  5300. }
  5301. };
  5302. },{}],37:[function(require,module,exports){
  5303. (function (global){
  5304. "use strict";
  5305. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5306. /* promise.min.js
  5307. * A Promise polyfill implementation.
  5308. * 2018-11-16
  5309. *
  5310. * By taylorhakes, https://github.com/taylorhakes
  5311. * License: MIT
  5312. * See https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE
  5313. */
  5314. /*! @source https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js */
  5315. !function (e, n) {
  5316. "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? n() : "function" == typeof define && define.amd ? define(n) : n();
  5317. }(0, function () {
  5318. "use strict";
  5319. function e(e) {
  5320. var n = this.constructor;
  5321. return this.then(function (t) {
  5322. return n.resolve(e()).then(function () {
  5323. return t;
  5324. });
  5325. }, function (t) {
  5326. return n.resolve(e()).then(function () {
  5327. return n.reject(t);
  5328. });
  5329. });
  5330. }
  5331. function n() {}
  5332. function t(e) {
  5333. if (!(this instanceof t)) throw new TypeError("Promises must be constructed via new");
  5334. if ("function" != typeof e) throw new TypeError("not a function");
  5335. this._state = 0, this._handled = !1, this._value = undefined, this._deferreds = [], u(e, this);
  5336. }
  5337. function o(e, n) {
  5338. for (; 3 === e._state;) {
  5339. e = e._value;
  5340. }
  5341. 0 !== e._state ? (e._handled = !0, t._immediateFn(function () {
  5342. var t = 1 === e._state ? n.onFulfilled : n.onRejected;
  5343. if (null !== t) {
  5344. var o;
  5345. try {
  5346. o = t(e._value);
  5347. } catch (f) {
  5348. return void i(n.promise, f);
  5349. }
  5350. r(n.promise, o);
  5351. } else (1 === e._state ? r : i)(n.promise, e._value);
  5352. })) : e._deferreds.push(n);
  5353. }
  5354. function r(e, n) {
  5355. try {
  5356. if (n === e) throw new TypeError("A promise cannot be resolved with itself.");
  5357. if (n && ("object" == _typeof(n) || "function" == typeof n)) {
  5358. var o = n.then;
  5359. if (n instanceof t) return e._state = 3, e._value = n, void f(e);
  5360. if ("function" == typeof o) return void u(function (e, n) {
  5361. return function () {
  5362. e.apply(n, arguments);
  5363. };
  5364. }(o, n), e);
  5365. }
  5366. e._state = 1, e._value = n, f(e);
  5367. } catch (r) {
  5368. i(e, r);
  5369. }
  5370. }
  5371. function i(e, n) {
  5372. e._state = 2, e._value = n, f(e);
  5373. }
  5374. function f(e) {
  5375. 2 === e._state && 0 === e._deferreds.length && t._immediateFn(function () {
  5376. e._handled || t._unhandledRejectionFn(e._value);
  5377. });
  5378. for (var n = 0, r = e._deferreds.length; r > n; n++) {
  5379. o(e, e._deferreds[n]);
  5380. }
  5381. e._deferreds = null;
  5382. }
  5383. function u(e, n) {
  5384. var t = !1;
  5385. try {
  5386. e(function (e) {
  5387. t || (t = !0, r(n, e));
  5388. }, function (e) {
  5389. t || (t = !0, i(n, e));
  5390. });
  5391. } catch (o) {
  5392. if (t) return;
  5393. t = !0, i(n, o);
  5394. }
  5395. }
  5396. var c = setTimeout;
  5397. t.prototype["catch"] = function (e) {
  5398. return this.then(null, e);
  5399. }, t.prototype.then = function (e, t) {
  5400. var r = new this.constructor(n);
  5401. return o(this, new function (e, n, t) {
  5402. this.onFulfilled = "function" == typeof e ? e : null, this.onRejected = "function" == typeof n ? n : null, this.promise = t;
  5403. }(e, t, r)), r;
  5404. }, t.prototype["finally"] = e, t.all = function (e) {
  5405. return new t(function (n, t) {
  5406. function o(e, f) {
  5407. try {
  5408. if (f && ("object" == _typeof(f) || "function" == typeof f)) {
  5409. var u = f.then;
  5410. if ("function" == typeof u) return void u.call(f, function (n) {
  5411. o(e, n);
  5412. }, t);
  5413. }
  5414. r[e] = f, 0 == --i && n(r);
  5415. } catch (c) {
  5416. t(c);
  5417. }
  5418. }
  5419. if (!e || "undefined" == typeof e.length) throw new TypeError("Promise.all accepts an array");
  5420. var r = Array.prototype.slice.call(e);
  5421. if (0 === r.length) return n([]);
  5422. for (var i = r.length, f = 0; r.length > f; f++) {
  5423. o(f, r[f]);
  5424. }
  5425. });
  5426. }, t.resolve = function (e) {
  5427. return e && "object" == _typeof(e) && e.constructor === t ? e : new t(function (n) {
  5428. n(e);
  5429. });
  5430. }, t.reject = function (e) {
  5431. return new t(function (n, t) {
  5432. t(e);
  5433. });
  5434. }, t.race = function (e) {
  5435. return new t(function (n, t) {
  5436. for (var o = 0, r = e.length; r > o; o++) {
  5437. e[o].then(n, t);
  5438. }
  5439. });
  5440. }, t._immediateFn = "function" == typeof setImmediate && function (e) {
  5441. setImmediate(e);
  5442. } || function (e) {
  5443. c(e, 0);
  5444. }, t._unhandledRejectionFn = function (e) {
  5445. void 0 !== console && console && console.warn("Possible Unhandled Promise Rejection:", e);
  5446. };
  5447. var l = function () {
  5448. if ("undefined" != typeof self) return self;
  5449. if ("undefined" != typeof window) return window;
  5450. if ("undefined" != typeof global) return global;
  5451. throw Error("unable to locate global object");
  5452. }();
  5453. "Promise" in l ? l.Promise.prototype["finally"] || (l.Promise.prototype["finally"] = e) : l.Promise = t;
  5454. });
  5455. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  5456. },{}],38:[function(require,module,exports){
  5457. "use strict";
  5458. Object.defineProperty(exports, "__esModule", {
  5459. value: true
  5460. });
  5461. exports.attrTypeBytes = attrTypeBytes;
  5462. exports.glFilter = glFilter;
  5463. exports.glTextureFmt = glTextureFmt;
  5464. exports.enums = void 0;
  5465. /****************************************************************************
  5466. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  5467. http://www.cocos.com
  5468. Permission is hereby granted, free of charge, to any person obtaining a copy
  5469. of this software and associated documentation files (the "Software"), to deal
  5470. in the Software without restriction, including without limitation the rights
  5471. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5472. copies of the Software, and to permit persons to whom the Software is
  5473. furnished to do so, subject to the following conditions:
  5474. The above copyright notice and this permission notice shall be included in
  5475. all copies or substantial portions of the Software.
  5476. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5477. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5478. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5479. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5480. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5481. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5482. THE SOFTWARE.
  5483. ****************************************************************************/
  5484. var gl = window.__gl;
  5485. var GL_NEAREST = 9728; // gl.NEAREST
  5486. var GL_LINEAR = 9729; // gl.LINEAR
  5487. var GL_NEAREST_MIPMAP_NEAREST = 9984; // gl.NEAREST_MIPMAP_NEAREST
  5488. var GL_LINEAR_MIPMAP_NEAREST = 9985; // gl.LINEAR_MIPMAP_NEAREST
  5489. var GL_NEAREST_MIPMAP_LINEAR = 9986; // gl.NEAREST_MIPMAP_LINEAR
  5490. var GL_LINEAR_MIPMAP_LINEAR = 9987; // gl.LINEAR_MIPMAP_LINEAR
  5491. // const GL_BYTE = 5120; // gl.BYTE
  5492. var GL_UNSIGNED_BYTE = 5121; // gl.UNSIGNED_BYTE
  5493. // const GL_SHORT = 5122; // gl.SHORT
  5494. var GL_UNSIGNED_SHORT = 5123; // gl.UNSIGNED_SHORT
  5495. var GL_UNSIGNED_INT = 5125; // gl.UNSIGNED_INT
  5496. var GL_FLOAT = 5126; // gl.FLOAT
  5497. var GL_UNSIGNED_SHORT_5_6_5 = 33635; // gl.UNSIGNED_SHORT_5_6_5
  5498. var GL_UNSIGNED_SHORT_4_4_4_4 = 32819; // gl.UNSIGNED_SHORT_4_4_4_4
  5499. var GL_UNSIGNED_SHORT_5_5_5_1 = 32820; // gl.UNSIGNED_SHORT_5_5_5_1
  5500. var GL_HALF_FLOAT_OES = 36193; // gl.HALF_FLOAT_OES
  5501. var GL_DEPTH_COMPONENT = 6402; // gl.DEPTH_COMPONENT
  5502. var GL_ALPHA = 6406; // gl.ALPHA
  5503. var GL_RGB = 6407; // gl.RGB
  5504. var GL_RGBA = 6408; // gl.RGBA
  5505. var GL_LUMINANCE = 6409; // gl.LUMINANCE
  5506. var GL_LUMINANCE_ALPHA = 6410; // gl.LUMINANCE_ALPHA
  5507. // https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_texture_float.txt
  5508. // for native GL_ARB_texture_float extension
  5509. var GL_RGBA32F = 0x8814;
  5510. var GL_RGB32F = 0x8815;
  5511. var GL_RGBA16F = 0x881A;
  5512. var GL_RGB16F = 0x881B;
  5513. var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; // ext.COMPRESSED_RGB_S3TC_DXT1_EXT
  5514. var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; // ext.COMPRESSED_RGBA_S3TC_DXT1_EXT
  5515. var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; // ext.COMPRESSED_RGBA_S3TC_DXT3_EXT
  5516. var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; // ext.COMPRESSED_RGBA_S3TC_DXT5_EXT
  5517. var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; // ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
  5518. var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01; // ext.COMPRESSED_RGB_PVRTC_2BPPV1_IMG
  5519. var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; // ext.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
  5520. var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03; // ext.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
  5521. var GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; // ext.COMPRESSED_RGB_ETC1_WEBGL
  5522. var GL_COMPRESSED_RGB8_ETC2 = 0x9274; // ext.COMPRESSED_RGB8_ETC2
  5523. var GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278; // ext.COMPRESSED_RGBA8_ETC2_EAC
  5524. var _filterGL = [[GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR], [GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR]];
  5525. var _textureFmtGL = [// TEXTURE_FMT_RGB_DXT1: 0
  5526. {
  5527. format: GL_RGB,
  5528. internalFormat: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
  5529. pixelType: null
  5530. }, // TEXTURE_FMT_RGBA_DXT1: 1
  5531. {
  5532. format: GL_RGBA,
  5533. internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
  5534. pixelType: null
  5535. }, // TEXTURE_FMT_RGBA_DXT3: 2
  5536. {
  5537. format: GL_RGBA,
  5538. internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  5539. pixelType: null
  5540. }, // TEXTURE_FMT_RGBA_DXT5: 3
  5541. {
  5542. format: GL_RGBA,
  5543. internalFormat: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
  5544. pixelType: null
  5545. }, // TEXTURE_FMT_RGB_ETC1: 4
  5546. {
  5547. format: GL_RGB,
  5548. internalFormat: GL_COMPRESSED_RGB_ETC1_WEBGL,
  5549. pixelType: null
  5550. }, // TEXTURE_FMT_RGB_PVRTC_2BPPV1: 5
  5551. {
  5552. format: GL_RGB,
  5553. internalFormat: GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
  5554. pixelType: null
  5555. }, // TEXTURE_FMT_RGBA_PVRTC_2BPPV1: 6
  5556. {
  5557. format: GL_RGBA,
  5558. internalFormat: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
  5559. pixelType: null
  5560. }, // TEXTURE_FMT_RGB_PVRTC_4BPPV1: 7
  5561. {
  5562. format: GL_RGB,
  5563. internalFormat: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
  5564. pixelType: null
  5565. }, // TEXTURE_FMT_RGBA_PVRTC_4BPPV1: 8
  5566. {
  5567. format: GL_RGBA,
  5568. internalFormat: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
  5569. pixelType: null
  5570. }, // TEXTURE_FMT_A8: 9
  5571. {
  5572. format: GL_ALPHA,
  5573. internalFormat: GL_ALPHA,
  5574. pixelType: GL_UNSIGNED_BYTE
  5575. }, // TEXTURE_FMT_L8: 10
  5576. {
  5577. format: GL_LUMINANCE,
  5578. internalFormat: GL_LUMINANCE,
  5579. pixelType: GL_UNSIGNED_BYTE
  5580. }, // TEXTURE_FMT_L8_A8: 11
  5581. {
  5582. format: GL_LUMINANCE_ALPHA,
  5583. internalFormat: GL_LUMINANCE_ALPHA,
  5584. pixelType: GL_UNSIGNED_BYTE
  5585. }, // TEXTURE_FMT_R5_G6_B5: 12
  5586. {
  5587. format: GL_RGB,
  5588. internalFormat: GL_RGB,
  5589. pixelType: GL_UNSIGNED_SHORT_5_6_5
  5590. }, // TEXTURE_FMT_R5_G5_B5_A1: 13
  5591. {
  5592. format: GL_RGBA,
  5593. internalFormat: GL_RGBA,
  5594. pixelType: GL_UNSIGNED_SHORT_5_5_5_1
  5595. }, // TEXTURE_FMT_R4_G4_B4_A4: 14
  5596. {
  5597. format: GL_RGBA,
  5598. internalFormat: GL_RGBA,
  5599. pixelType: GL_UNSIGNED_SHORT_4_4_4_4
  5600. }, // TEXTURE_FMT_RGB8: 15
  5601. {
  5602. format: GL_RGB,
  5603. internalFormat: GL_RGB,
  5604. pixelType: GL_UNSIGNED_BYTE
  5605. }, // TEXTURE_FMT_RGBA8: 16
  5606. {
  5607. format: GL_RGBA,
  5608. internalFormat: GL_RGBA,
  5609. pixelType: GL_UNSIGNED_BYTE
  5610. }, // TEXTURE_FMT_RGB16F: 17
  5611. {
  5612. format: GL_RGB,
  5613. internalFormat: GL_RGB16F,
  5614. pixelType: GL_HALF_FLOAT_OES
  5615. }, // TEXTURE_FMT_RGBA16F: 18
  5616. {
  5617. format: GL_RGBA,
  5618. internalFormat: GL_RGBA16F,
  5619. pixelType: GL_HALF_FLOAT_OES
  5620. }, // TEXTURE_FMT_RGB32F: 19
  5621. {
  5622. format: GL_RGB,
  5623. internalFormat: GL_RGB32F,
  5624. pixelType: GL_FLOAT
  5625. }, // TEXTURE_FMT_RGBA32F: 20
  5626. {
  5627. format: GL_RGBA,
  5628. internalFormat: GL_RGBA32F,
  5629. pixelType: GL_FLOAT
  5630. }, // TEXTURE_FMT_R32F: 21
  5631. {
  5632. format: null,
  5633. internalFormat: null,
  5634. pixelType: null
  5635. }, // TEXTURE_FMT_111110F: 22
  5636. {
  5637. format: null,
  5638. internalFormat: null,
  5639. pixelType: null
  5640. }, // TEXTURE_FMT_SRGB: 23
  5641. {
  5642. format: null,
  5643. internalFormat: null,
  5644. pixelType: null
  5645. }, // TEXTURE_FMT_SRGBA: 24
  5646. {
  5647. format: null,
  5648. internalFormat: null,
  5649. pixelType: null
  5650. }, // TEXTURE_FMT_D16: 25
  5651. {
  5652. format: GL_DEPTH_COMPONENT,
  5653. internalFormat: GL_DEPTH_COMPONENT,
  5654. pixelType: GL_UNSIGNED_SHORT
  5655. }, // TEXTURE_FMT_D32: 26
  5656. {
  5657. format: GL_DEPTH_COMPONENT,
  5658. internalFormat: GL_DEPTH_COMPONENT,
  5659. pixelType: GL_UNSIGNED_INT
  5660. }, // TEXTURE_FMT_D24S8: 27
  5661. {
  5662. format: GL_DEPTH_COMPONENT,
  5663. internalFormat: GL_DEPTH_COMPONENT,
  5664. pixelType: GL_UNSIGNED_INT
  5665. }, // TEXTURE_FMT_RGB_ETC2: 28
  5666. {
  5667. format: GL_RGB,
  5668. internalFormat: GL_COMPRESSED_RGB8_ETC2,
  5669. pixelType: null
  5670. }, // TEXTURE_FMT_RGBA_ETC2: 29
  5671. {
  5672. format: GL_RGBA,
  5673. internalFormat: GL_COMPRESSED_RGBA8_ETC2_EAC,
  5674. pixelType: null
  5675. }];
  5676. /**
  5677. * enums
  5678. */
  5679. var enums = {
  5680. // buffer usage
  5681. USAGE_STATIC: 35044,
  5682. // gl.STATIC_DRAW
  5683. USAGE_DYNAMIC: 35048,
  5684. // gl.DYNAMIC_DRAW
  5685. USAGE_STREAM: 35040,
  5686. // gl.STREAM_DRAW
  5687. // index buffer format
  5688. INDEX_FMT_UINT8: 5121,
  5689. // gl.UNSIGNED_BYTE
  5690. INDEX_FMT_UINT16: 5123,
  5691. // gl.UNSIGNED_SHORT
  5692. INDEX_FMT_UINT32: 5125,
  5693. // gl.UNSIGNED_INT (OES_element_index_uint)
  5694. // vertex attribute semantic
  5695. ATTR_POSITION: 'a_position',
  5696. ATTR_NORMAL: 'a_normal',
  5697. ATTR_TANGENT: 'a_tangent',
  5698. ATTR_BITANGENT: 'a_bitangent',
  5699. ATTR_WEIGHTS: 'a_weights',
  5700. ATTR_JOINTS: 'a_joints',
  5701. ATTR_COLOR: 'a_color',
  5702. ATTR_COLOR0: 'a_color0',
  5703. ATTR_COLOR1: 'a_color1',
  5704. ATTR_UV: 'a_uv',
  5705. ATTR_UV0: 'a_uv0',
  5706. ATTR_UV1: 'a_uv1',
  5707. ATTR_UV2: 'a_uv2',
  5708. ATTR_UV3: 'a_uv3',
  5709. ATTR_UV4: 'a_uv4',
  5710. ATTR_UV5: 'a_uv5',
  5711. ATTR_UV6: 'a_uv6',
  5712. ATTR_UV7: 'a_uv7',
  5713. ATTR_TEX_COORD: 'a_texCoord',
  5714. ATTR_TEX_COORD1: 'a_texCoord1',
  5715. ATTR_TEX_COORD2: 'a_texCoord2',
  5716. ATTR_TEX_COORD3: 'a_texCoord3',
  5717. ATTR_TEX_COORD4: 'a_texCoord4',
  5718. ATTR_TEX_COORD5: 'a_texCoord5',
  5719. ATTR_TEX_COORD6: 'a_texCoord6',
  5720. ATTR_TEX_COORD7: 'a_texCoord7',
  5721. ATTR_TEX_COORD8: 'a_texCoord8',
  5722. // vertex attribute type
  5723. ATTR_TYPE_INT8: 5120,
  5724. // gl.BYTE
  5725. ATTR_TYPE_UINT8: 5121,
  5726. // gl.UNSIGNED_BYTE
  5727. ATTR_TYPE_INT16: 5122,
  5728. // gl.SHORT
  5729. ATTR_TYPE_UINT16: 5123,
  5730. // gl.UNSIGNED_SHORT
  5731. ATTR_TYPE_INT32: 5124,
  5732. // gl.INT
  5733. ATTR_TYPE_UINT32: 5125,
  5734. // gl.UNSIGNED_INT
  5735. ATTR_TYPE_FLOAT32: 5126,
  5736. // gl.FLOAT
  5737. // texture filter
  5738. FILTER_NEAREST: 0,
  5739. FILTER_LINEAR: 1,
  5740. // texture wrap mode
  5741. WRAP_REPEAT: 10497,
  5742. // gl.REPEAT
  5743. WRAP_CLAMP: 33071,
  5744. // gl.CLAMP_TO_EDGE
  5745. WRAP_MIRROR: 33648,
  5746. // gl.MIRRORED_REPEAT
  5747. // texture format
  5748. // compress formats
  5749. TEXTURE_FMT_RGB_DXT1: 0,
  5750. TEXTURE_FMT_RGBA_DXT1: 1,
  5751. TEXTURE_FMT_RGBA_DXT3: 2,
  5752. TEXTURE_FMT_RGBA_DXT5: 3,
  5753. TEXTURE_FMT_RGB_ETC1: 4,
  5754. TEXTURE_FMT_RGB_PVRTC_2BPPV1: 5,
  5755. TEXTURE_FMT_RGBA_PVRTC_2BPPV1: 6,
  5756. TEXTURE_FMT_RGB_PVRTC_4BPPV1: 7,
  5757. TEXTURE_FMT_RGBA_PVRTC_4BPPV1: 8,
  5758. // normal formats
  5759. TEXTURE_FMT_A8: 9,
  5760. TEXTURE_FMT_L8: 10,
  5761. TEXTURE_FMT_L8_A8: 11,
  5762. TEXTURE_FMT_R5_G6_B5: 12,
  5763. TEXTURE_FMT_R5_G5_B5_A1: 13,
  5764. TEXTURE_FMT_R4_G4_B4_A4: 14,
  5765. TEXTURE_FMT_RGB8: 15,
  5766. TEXTURE_FMT_RGBA8: 16,
  5767. TEXTURE_FMT_RGB16F: 17,
  5768. TEXTURE_FMT_RGBA16F: 18,
  5769. TEXTURE_FMT_RGB32F: 19,
  5770. TEXTURE_FMT_RGBA32F: 20,
  5771. TEXTURE_FMT_R32F: 21,
  5772. TEXTURE_FMT_111110F: 22,
  5773. TEXTURE_FMT_SRGB: 23,
  5774. TEXTURE_FMT_SRGBA: 24,
  5775. // depth formats
  5776. TEXTURE_FMT_D16: 25,
  5777. TEXTURE_FMT_D32: 26,
  5778. TEXTURE_FMT_D24S8: 27,
  5779. // etc2 format
  5780. TEXTURE_FMT_RGB_ETC2: 28,
  5781. TEXTURE_FMT_RGBA_ETC2: 29,
  5782. // depth and stencil function
  5783. DS_FUNC_NEVER: 512,
  5784. // gl.NEVER
  5785. DS_FUNC_LESS: 513,
  5786. // gl.LESS
  5787. DS_FUNC_EQUAL: 514,
  5788. // gl.EQUAL
  5789. DS_FUNC_LEQUAL: 515,
  5790. // gl.LEQUAL
  5791. DS_FUNC_GREATER: 516,
  5792. // gl.GREATER
  5793. DS_FUNC_NOTEQUAL: 517,
  5794. // gl.NOTEQUAL
  5795. DS_FUNC_GEQUAL: 518,
  5796. // gl.GEQUAL
  5797. DS_FUNC_ALWAYS: 519,
  5798. // gl.ALWAYS
  5799. // render-buffer format
  5800. RB_FMT_RGBA4: 32854,
  5801. // gl.RGBA4
  5802. RB_FMT_RGB5_A1: 32855,
  5803. // gl.RGB5_A1
  5804. RB_FMT_RGB565: 36194,
  5805. // gl.RGB565
  5806. RB_FMT_D16: 33189,
  5807. // gl.DEPTH_COMPONENT16
  5808. RB_FMT_S8: 36168,
  5809. // gl.STENCIL_INDEX8
  5810. RB_FMT_D24S8: 34041,
  5811. // gl.DEPTH_STENCIL
  5812. // blend-equation
  5813. BLEND_FUNC_ADD: 32774,
  5814. // gl.FUNC_ADD
  5815. BLEND_FUNC_SUBTRACT: 32778,
  5816. // gl.FUNC_SUBTRACT
  5817. BLEND_FUNC_REVERSE_SUBTRACT: 32779,
  5818. // gl.FUNC_REVERSE_SUBTRACT
  5819. // blend
  5820. BLEND_ZERO: 0,
  5821. // gl.ZERO
  5822. BLEND_ONE: 1,
  5823. // gl.ONE
  5824. BLEND_SRC_COLOR: 768,
  5825. // gl.SRC_COLOR
  5826. BLEND_ONE_MINUS_SRC_COLOR: 769,
  5827. // gl.ONE_MINUS_SRC_COLOR
  5828. BLEND_DST_COLOR: 774,
  5829. // gl.DST_COLOR
  5830. BLEND_ONE_MINUS_DST_COLOR: 775,
  5831. // gl.ONE_MINUS_DST_COLOR
  5832. BLEND_SRC_ALPHA: 770,
  5833. // gl.SRC_ALPHA
  5834. BLEND_ONE_MINUS_SRC_ALPHA: 771,
  5835. // gl.ONE_MINUS_SRC_ALPHA
  5836. BLEND_DST_ALPHA: 772,
  5837. // gl.DST_ALPHA
  5838. BLEND_ONE_MINUS_DST_ALPHA: 773,
  5839. // gl.ONE_MINUS_DST_ALPHA
  5840. BLEND_CONSTANT_COLOR: 32769,
  5841. // gl.CONSTANT_COLOR
  5842. BLEND_ONE_MINUS_CONSTANT_COLOR: 32770,
  5843. // gl.ONE_MINUS_CONSTANT_COLOR
  5844. BLEND_CONSTANT_ALPHA: 32771,
  5845. // gl.CONSTANT_ALPHA
  5846. BLEND_ONE_MINUS_CONSTANT_ALPHA: 32772,
  5847. // gl.ONE_MINUS_CONSTANT_ALPHA
  5848. BLEND_SRC_ALPHA_SATURATE: 776,
  5849. // gl.SRC_ALPHA_SATURATE
  5850. // stencil operation
  5851. STENCIL_DISABLE: 0,
  5852. // disable stencil
  5853. STENCIL_ENABLE: 1,
  5854. // enable stencil
  5855. STENCIL_INHERIT: 2,
  5856. // inherit stencil states
  5857. STENCIL_OP_KEEP: 7680,
  5858. // gl.KEEP
  5859. STENCIL_OP_ZERO: 0,
  5860. // gl.ZERO
  5861. STENCIL_OP_REPLACE: 7681,
  5862. // gl.REPLACE
  5863. STENCIL_OP_INCR: 7682,
  5864. // gl.INCR
  5865. STENCIL_OP_INCR_WRAP: 34055,
  5866. // gl.INCR_WRAP
  5867. STENCIL_OP_DECR: 7683,
  5868. // gl.DECR
  5869. STENCIL_OP_DECR_WRAP: 34056,
  5870. // gl.DECR_WRAP
  5871. STENCIL_OP_INVERT: 5386,
  5872. // gl.INVERT
  5873. // cull
  5874. CULL_NONE: 0,
  5875. CULL_FRONT: 1028,
  5876. CULL_BACK: 1029,
  5877. CULL_FRONT_AND_BACK: 1032,
  5878. // primitive type
  5879. PT_POINTS: 0,
  5880. // gl.POINTS
  5881. PT_LINES: 1,
  5882. // gl.LINES
  5883. PT_LINE_LOOP: 2,
  5884. // gl.LINE_LOOP
  5885. PT_LINE_STRIP: 3,
  5886. // gl.LINE_STRIP
  5887. PT_TRIANGLES: 4,
  5888. // gl.TRIANGLES
  5889. PT_TRIANGLE_STRIP: 5,
  5890. // gl.TRIANGLE_STRIP
  5891. PT_TRIANGLE_FAN: 6 // gl.TRIANGLE_FAN
  5892. };
  5893. /**
  5894. * @method attrTypeBytes
  5895. * @param {ATTR_TYPE_*} attrType
  5896. */
  5897. exports.enums = enums;
  5898. function attrTypeBytes(attrType) {
  5899. if (attrType === enums.ATTR_TYPE_INT8) {
  5900. return 1;
  5901. } else if (attrType === enums.ATTR_TYPE_UINT8) {
  5902. return 1;
  5903. } else if (attrType === enums.ATTR_TYPE_INT16) {
  5904. return 2;
  5905. } else if (attrType === enums.ATTR_TYPE_UINT16) {
  5906. return 2;
  5907. } else if (attrType === enums.ATTR_TYPE_INT32) {
  5908. return 4;
  5909. } else if (attrType === enums.ATTR_TYPE_UINT32) {
  5910. return 4;
  5911. } else if (attrType === enums.ATTR_TYPE_FLOAT32) {
  5912. return 4;
  5913. }
  5914. console.warn("Unknown ATTR_TYPE: ".concat(attrType));
  5915. return 0;
  5916. }
  5917. /**
  5918. * @method glFilter
  5919. * @param {WebGLContext} gl
  5920. * @param {FILTER_*} filter
  5921. * @param {FILTER_*} mipFilter
  5922. */
  5923. function glFilter(gl, filter) {
  5924. var mipFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
  5925. var result = _filterGL[filter][mipFilter + 1];
  5926. if (result === undefined) {
  5927. console.warn("Unknown FILTER: ".concat(filter));
  5928. return mipFilter === -1 ? gl.LINEAR : gl.LINEAR_MIPMAP_LINEAR;
  5929. }
  5930. return result;
  5931. }
  5932. /**
  5933. * @method glTextureFmt
  5934. * @param {TEXTURE_FMT_*} fmt
  5935. */
  5936. function glTextureFmt(fmt) {
  5937. var result = _textureFmtGL[fmt];
  5938. if (result === undefined) {
  5939. console.warn("Unknown TEXTURE_FMT: ".concat(fmt));
  5940. return _textureFmtGL[enums.TEXTURE_FMT_RGBA8];
  5941. }
  5942. return result;
  5943. }
  5944. },{}],39:[function(require,module,exports){
  5945. "use strict";
  5946. Object.defineProperty(exports, "__esModule", {
  5947. value: true
  5948. });
  5949. exports["default"] = void 0;
  5950. var _enums = require("./enums");
  5951. var _jsbVertexFormat = _interopRequireDefault(require("./jsb-vertex-format"));
  5952. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5953. /****************************************************************************
  5954. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  5955. http://www.cocos.com
  5956. Permission is hereby granted, free of charge, to any person obtaining a copy
  5957. of this software and associated documentation files (the "Software"), to deal
  5958. in the Software without restriction, including without limitation the rights
  5959. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5960. copies of the Software, and to permit persons to whom the Software is
  5961. furnished to do so, subject to the following conditions:
  5962. The above copyright notice and this permission notice shall be included in
  5963. all copies or substantial portions of the Software.
  5964. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5965. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5966. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5967. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5968. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5969. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5970. THE SOFTWARE.
  5971. ****************************************************************************/
  5972. var gfx = window.gfx;
  5973. var _tmpGetSetDesc = {
  5974. get: undefined,
  5975. set: undefined,
  5976. enumerable: true,
  5977. configurable: true
  5978. };
  5979. /**
  5980. * Device
  5981. */
  5982. var deviceInstance;
  5983. gfx.Device.prototype.setBlendColor32 = gfx.Device.prototype.setBlendColor;
  5984. gfx.Device._getInstance = gfx.Device.getInstance;
  5985. gfx.Device.getInstance = function () {
  5986. // init native device instance
  5987. if (!deviceInstance) {
  5988. deviceInstance = gfx.Device._getInstance();
  5989. deviceInstance._gl = window.__gl;
  5990. deviceInstance.ext = function (extName) {
  5991. return window.__gl.getExtension(extName);
  5992. };
  5993. }
  5994. return deviceInstance;
  5995. }; //FIXME:
  5996. // window.device._stats = { vb: 0 };
  5997. // window.device._caps = {
  5998. // maxVextexTextures: 16,
  5999. // maxFragUniforms: 1024,
  6000. // maxTextureUints: 8,
  6001. // maxVertexAttributes: 16,
  6002. // maxDrawBuffers: 8,
  6003. // maxColorAttatchments: 8
  6004. // };
  6005. /**
  6006. * Program
  6007. */
  6008. var _p = gfx.Program.prototype;
  6009. _p._ctor = function (device, options) {
  6010. if (device) {
  6011. this.init(device, options.vert, options.frag);
  6012. }
  6013. };
  6014. /**
  6015. * VertexBuffer
  6016. */
  6017. _p = gfx.VertexBuffer.prototype;
  6018. _p._ctor = function (device, format, usage, data, numVertices) {
  6019. this._attr2el = format._attr2el;
  6020. if (device && format) {
  6021. this.init(device, format._nativeObj, usage, data, numVertices);
  6022. }
  6023. this._nativePtr = this.self();
  6024. };
  6025. _p.getFormat = function (name) {
  6026. return this._attr2el[name];
  6027. };
  6028. _tmpGetSetDesc.get = _p.getCount;
  6029. _tmpGetSetDesc.set = undefined;
  6030. Object.defineProperty(_p, "count", _tmpGetSetDesc);
  6031. /**
  6032. * IndexBuffer
  6033. */
  6034. _p = gfx.IndexBuffer.prototype;
  6035. _p._ctor = function (device, format, usage, data, numIndices) {
  6036. if (device) {
  6037. this.init(device, format, usage, data, numIndices);
  6038. }
  6039. this._nativePtr = this.self();
  6040. };
  6041. _tmpGetSetDesc.get = _p.getCount;
  6042. _tmpGetSetDesc.set = undefined;
  6043. Object.defineProperty(_p, "count", _tmpGetSetDesc);
  6044. gfx.VertexFormat = _jsbVertexFormat["default"];
  6045. Object.assign(gfx, _enums.enums);
  6046. /**
  6047. * Texture2D
  6048. */
  6049. function convertImages(images) {
  6050. if (images) {
  6051. for (var i = 0, len = images.length; i < len; ++i) {
  6052. var image = images[i];
  6053. if (image !== null) {
  6054. if (image instanceof window.HTMLCanvasElement) {
  6055. if (image._data) {
  6056. images[i] = image._data._data;
  6057. } else {
  6058. images[i] = null;
  6059. }
  6060. } else if (image instanceof window.HTMLImageElement) {
  6061. images[i] = image._data;
  6062. }
  6063. }
  6064. }
  6065. }
  6066. }
  6067. function convertOptions(texture, options) {
  6068. var gl = window.__gl;
  6069. if (options.images && options.images[0] instanceof HTMLImageElement) {
  6070. var image = options.images[0];
  6071. options.glInternalFormat = image._glInternalFormat;
  6072. options.glFormat = image._glFormat;
  6073. options.glType = image._glType;
  6074. options.bpp = image._bpp;
  6075. options.compressed = image._compressed;
  6076. } else if (options.images && options.images[0] instanceof HTMLCanvasElement) {
  6077. options.glInternalFormat = gl.RGBA;
  6078. options.glFormat = gl.RGBA;
  6079. options.glType = gl.UNSIGNED_BYTE;
  6080. options.bpp = 32;
  6081. options.compressed = false;
  6082. } else {
  6083. var format = options.format || texture._format;
  6084. var gltf = (0, _enums.glTextureFmt)(format);
  6085. options.glInternalFormat = gltf.internalFormat;
  6086. options.glFormat = gltf.format;
  6087. options.glType = gltf.pixelType;
  6088. options.bpp = gltf.bpp;
  6089. options.compressed = format >= _enums.enums.TEXTURE_FMT_RGB_DXT1 && format <= _enums.enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1 || format >= _enums.enums.TEXTURE_FMT_RGB_ETC2 && format <= _enums.enums.TEXTURE_FMT_RGBA_ETC2;
  6090. }
  6091. options.width = options.width || texture._width;
  6092. options.height = options.height || texture._height;
  6093. convertImages(options.images);
  6094. }
  6095. _p = gfx.Texture2D.prototype;
  6096. var _textureID = 0;
  6097. _p._ctor = function (device, options) {
  6098. if (device) {
  6099. convertOptions(this, options);
  6100. this.init(device, options);
  6101. }
  6102. this._id = _textureID++;
  6103. };
  6104. _p.destroy = function () {};
  6105. _p.update = function (options) {
  6106. convertOptions(this, options);
  6107. this.updateNative(options);
  6108. };
  6109. _p.updateSubImage = function (option) {
  6110. var images = [option.image];
  6111. convertImages(images);
  6112. var data = new Uint32Array(8 + (images[0].length + 3) / 4);
  6113. data[0] = option.x;
  6114. data[1] = option.y;
  6115. data[2] = option.width;
  6116. data[3] = option.height;
  6117. data[4] = option.level;
  6118. data[5] = option.flipY;
  6119. data[6] = false;
  6120. data[7] = images[0].length;
  6121. var imageData = new Uint8Array(data.buffer);
  6122. imageData.set(images[0], 32);
  6123. this.updateSubImageNative(data);
  6124. };
  6125. _tmpGetSetDesc.get = _p.getWidth;
  6126. _tmpGetSetDesc.set = undefined;
  6127. Object.defineProperty(_p, "_width", _tmpGetSetDesc);
  6128. _tmpGetSetDesc.get = _p.getHeight;
  6129. Object.defineProperty(_p, "_height", _tmpGetSetDesc);
  6130. /**
  6131. * FrameBuffer
  6132. */
  6133. _p = gfx.FrameBuffer.prototype;
  6134. _p._ctor = function (device, width, height, options) {
  6135. if (!device) return;
  6136. this.init(device, width, height, options);
  6137. this._glID = {
  6138. _id: this.getHandle()
  6139. };
  6140. this.getHandle = function () {
  6141. return this._glID;
  6142. };
  6143. };
  6144. /**
  6145. * FrameBuffer
  6146. */
  6147. _p = gfx.RenderBuffer.prototype;
  6148. _p._ctor = function (device, format, width, height) {
  6149. if (!device) return;
  6150. this.init(device, format, width, height);
  6151. this._glID = {
  6152. _id: this.getHandle()
  6153. };
  6154. this.getHandle = function () {
  6155. return this._glID;
  6156. };
  6157. };
  6158. gfx.RB_FMT_D16 = 0x81A5; // GL_DEPTH_COMPONENT16 hack for JSB
  6159. var _default = gfx;
  6160. exports["default"] = _default;
  6161. },{"./enums":38,"./jsb-vertex-format":41}],40:[function(require,module,exports){
  6162. "use strict";
  6163. Object.defineProperty(exports, "__esModule", {
  6164. value: true
  6165. });
  6166. exports["default"] = void 0;
  6167. /****************************************************************************
  6168. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  6169. http://www.cocos.com
  6170. Permission is hereby granted, free of charge, to any person obtaining a copy
  6171. of this software and associated documentation files (the "Software"), to deal
  6172. in the Software without restriction, including without limitation the rights
  6173. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6174. copies of the Software, and to permit persons to whom the Software is
  6175. furnished to do so, subject to the following conditions:
  6176. The above copyright notice and this permission notice shall be included in
  6177. all copies or substantial portions of the Software.
  6178. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6179. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6180. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6181. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6182. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6183. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6184. THE SOFTWARE.
  6185. ****************************************************************************/
  6186. var renderer = window.renderer; // program lib
  6187. _p = renderer.ProgramLib.prototype;
  6188. var _define = _p.define;
  6189. var _shdID = 0;
  6190. var _templates = {};
  6191. var libDefine = function libDefine(prog) {
  6192. var name = prog.name,
  6193. defines = prog.defines,
  6194. glsl1 = prog.glsl1;
  6195. var _ref = glsl1 || prog,
  6196. vert = _ref.vert,
  6197. frag = _ref.frag;
  6198. if (_templates[name]) {
  6199. console.warn("Failed to define shader ".concat(name, ": already exists."));
  6200. return;
  6201. }
  6202. var id = ++_shdID; // calculate option mask offset
  6203. var offset = 0;
  6204. for (var i = 0; i < defines.length; ++i) {
  6205. var def = defines[i];
  6206. var cnt = 1;
  6207. if (def.type === 'number') {
  6208. var range = def.range || [];
  6209. def.min = range[0] || 0;
  6210. def.max = range[1] || 4;
  6211. cnt = Math.ceil(Math.log2(def.max - def.min));
  6212. def._map = function (value) {
  6213. return value - this.min << this._offset;
  6214. }.bind(def);
  6215. } else {
  6216. // boolean
  6217. def._map = function (value) {
  6218. if (value) {
  6219. return 1 << this._offset;
  6220. }
  6221. return 0;
  6222. }.bind(def);
  6223. }
  6224. offset += cnt;
  6225. def._offset = offset;
  6226. }
  6227. var uniforms = prog.uniforms || [];
  6228. if (prog.samplers) {
  6229. for (var _i = 0; _i < prog.samplers.length; _i++) {
  6230. uniforms.push(prog.samplers[_i]);
  6231. }
  6232. }
  6233. if (prog.blocks) {
  6234. for (var _i2 = 0; _i2 < prog.blocks.length; _i2++) {
  6235. var _defines = prog.blocks[_i2].defines;
  6236. var members = prog.blocks[_i2].members;
  6237. for (var j = 0; j < members.length; j++) {
  6238. uniforms.push({
  6239. defines: _defines,
  6240. name: members[j].name,
  6241. type: members[j].type
  6242. });
  6243. }
  6244. }
  6245. } // store it
  6246. _templates[name] = {
  6247. id: id,
  6248. name: name,
  6249. vert: vert,
  6250. frag: frag,
  6251. defines: defines,
  6252. attributes: prog.attributes,
  6253. uniforms: uniforms,
  6254. extensions: prog.extensions
  6255. };
  6256. _define.call(this, name, vert, frag, defines);
  6257. };
  6258. var libGetTemplate = function libGetTemplate(name) {
  6259. return _templates[name];
  6260. }; // ForwardRenderer adapter
  6261. var _p = renderer.ForwardRenderer.prototype;
  6262. _p._ctor = function (device, builtin) {
  6263. if (device) {
  6264. this.init(device, [], builtin.defaultTexture, window.innerWidth, window.innerHeight);
  6265. var templates = builtin.programTemplates;
  6266. this._programLib = this.getProgramLib();
  6267. this._programLib.define = libDefine;
  6268. this._programLib.getTemplate = libGetTemplate;
  6269. for (var i = 0; i < templates.length; ++i) {
  6270. this._programLib.define(templates[i]);
  6271. }
  6272. }
  6273. }; // Camera
  6274. _p = renderer.Camera.prototype;
  6275. Object.defineProperty(_p, "cullingMask", {
  6276. get: function get() {
  6277. return this.getCullingMask();
  6278. },
  6279. set: function set(value) {
  6280. this.setCullingMask(value);
  6281. }
  6282. });
  6283. var _default = renderer;
  6284. exports["default"] = _default;
  6285. },{}],41:[function(require,module,exports){
  6286. "use strict";
  6287. Object.defineProperty(exports, "__esModule", {
  6288. value: true
  6289. });
  6290. exports["default"] = void 0;
  6291. var _enums = require("./enums");
  6292. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6293. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6294. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6295. var gfx = window.gfx; // ====================
  6296. // exports
  6297. // ====================
  6298. var VertexFormat = /*#__PURE__*/function () {
  6299. /**
  6300. * @constructor
  6301. * @param {Array} infos
  6302. *
  6303. * @example
  6304. * let vertexFmt = new VertexFormat([
  6305. * { name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3 },
  6306. * { name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 },
  6307. * { name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_FLOAT32, num: 4, normalize: true },
  6308. * ])
  6309. */
  6310. function VertexFormat(infos) {
  6311. _classCallCheck(this, VertexFormat);
  6312. this._attr2el = {};
  6313. this._elements = [];
  6314. this._bytes = 0;
  6315. var offset = 0;
  6316. for (var i = 0, len = infos.length; i < len; ++i) {
  6317. var info = infos[i];
  6318. var el = {
  6319. name: info.name,
  6320. offset: offset,
  6321. stride: 0,
  6322. stream: -1,
  6323. type: info.type,
  6324. num: info.num,
  6325. normalize: info.normalize === undefined ? false : info.normalize,
  6326. bytes: info.num * (0, _enums.attrTypeBytes)(info.type)
  6327. }; // log('info.num is:' + info.num + ' attrTypeBytes(info.type) is:' + attrTypeBytes(info.type));
  6328. this._attr2el[el.name] = el;
  6329. this._elements.push(el);
  6330. this._bytes += el.bytes;
  6331. offset += el.bytes;
  6332. }
  6333. for (var _i = 0, _len = this._elements.length; _i < _len; ++_i) {
  6334. var _el = this._elements[_i];
  6335. _el.stride = this._bytes;
  6336. }
  6337. this._nativeObj = new gfx.VertexFormatNative(this._elements);
  6338. }
  6339. /**
  6340. * @method element
  6341. * @param {string} attrName
  6342. */
  6343. _createClass(VertexFormat, [{
  6344. key: "element",
  6345. value: function element(attrName) {
  6346. return this._attr2el[attrName];
  6347. }
  6348. }, {
  6349. key: "getElement",
  6350. value: function getElement(attrName) {
  6351. return this._attr2el[attrName];
  6352. }
  6353. }, {
  6354. key: "getBytes",
  6355. value: function getBytes() {
  6356. return this._bytes;
  6357. }
  6358. }, {
  6359. key: "getAttributeNames",
  6360. value: function getAttributeNames() {
  6361. return Object.keys(this._attr2el);
  6362. }
  6363. }]);
  6364. return VertexFormat;
  6365. }();
  6366. exports["default"] = VertexFormat;
  6367. },{"./enums":38}],42:[function(require,module,exports){
  6368. "use strict";
  6369. function DOMParser(options) {
  6370. this.options = options || {
  6371. locator: {}
  6372. };
  6373. }
  6374. DOMParser.prototype.parseFromString = function (source, mimeType) {
  6375. var options = this.options;
  6376. var sax = new XMLReader();
  6377. var domBuilder = options.domBuilder || new DOMHandler(); //contentHandler and LexicalHandler
  6378. var errorHandler = options.errorHandler;
  6379. var locator = options.locator;
  6380. var defaultNSMap = options.xmlns || {};
  6381. var isHTML = /\/x?html?$/.test(mimeType); //mimeType.toLowerCase().indexOf('html') > -1;
  6382. var entityMap = isHTML ? htmlEntity.entityMap : {
  6383. 'lt': '<',
  6384. 'gt': '>',
  6385. 'amp': '&',
  6386. 'quot': '"',
  6387. 'apos': "'"
  6388. };
  6389. if (locator) {
  6390. domBuilder.setDocumentLocator(locator);
  6391. }
  6392. sax.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
  6393. sax.domBuilder = options.domBuilder || domBuilder;
  6394. if (isHTML) {
  6395. defaultNSMap[''] = 'http://www.w3.org/1999/xhtml';
  6396. }
  6397. defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
  6398. if (source) {
  6399. sax.parse(source, defaultNSMap, entityMap);
  6400. } else {
  6401. sax.errorHandler.error("invalid doc source");
  6402. }
  6403. return domBuilder.doc;
  6404. };
  6405. function buildErrorHandler(errorImpl, domBuilder, locator) {
  6406. if (!errorImpl) {
  6407. if (domBuilder instanceof DOMHandler) {
  6408. return domBuilder;
  6409. }
  6410. errorImpl = domBuilder;
  6411. }
  6412. var errorHandler = {};
  6413. var isCallback = errorImpl instanceof Function;
  6414. locator = locator || {};
  6415. function build(key) {
  6416. var fn = errorImpl[key];
  6417. if (!fn && isCallback) {
  6418. fn = errorImpl.length == 2 ? function (msg) {
  6419. errorImpl(key, msg);
  6420. } : errorImpl;
  6421. }
  6422. errorHandler[key] = fn && function (msg) {
  6423. fn('[xmldom ' + key + ']\t' + msg + _locator(locator));
  6424. } || function () {};
  6425. }
  6426. build('warning');
  6427. build('error');
  6428. build('fatalError');
  6429. return errorHandler;
  6430. } //console.log('#\n\n\n\n\n\n\n####')
  6431. /**
  6432. * +ContentHandler+ErrorHandler
  6433. * +LexicalHandler+EntityResolver2
  6434. * -DeclHandler-DTDHandler
  6435. *
  6436. * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  6437. * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
  6438. * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
  6439. */
  6440. function DOMHandler() {
  6441. this.cdata = false;
  6442. }
  6443. function position(locator, node) {
  6444. node.lineNumber = locator.lineNumber;
  6445. node.columnNumber = locator.columnNumber;
  6446. }
  6447. /**
  6448. * @see org.xml.sax.ContentHandler#startDocument
  6449. * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
  6450. */
  6451. DOMHandler.prototype = {
  6452. startDocument: function startDocument() {
  6453. this.doc = new DOMImplementation().createDocument(null, null, null);
  6454. if (this.locator) {
  6455. this.doc.documentURI = this.locator.systemId;
  6456. }
  6457. },
  6458. startElement: function startElement(namespaceURI, localName, qName, attrs) {
  6459. var doc = this.doc;
  6460. var el = doc.createElementNS(namespaceURI, qName || localName);
  6461. var len = attrs.length;
  6462. appendElement(this, el);
  6463. this.currentElement = el;
  6464. this.locator && position(this.locator, el);
  6465. for (var i = 0; i < len; i++) {
  6466. var namespaceURI = attrs.getURI(i);
  6467. var value = attrs.getValue(i);
  6468. var qName = attrs.getQName(i);
  6469. var attr = doc.createAttributeNS(namespaceURI, qName);
  6470. this.locator && position(attrs.getLocator(i), attr);
  6471. attr.value = attr.nodeValue = value;
  6472. el.setAttributeNode(attr);
  6473. }
  6474. },
  6475. endElement: function endElement(namespaceURI, localName, qName) {
  6476. var current = this.currentElement;
  6477. var tagName = current.tagName;
  6478. this.currentElement = current.parentNode;
  6479. },
  6480. startPrefixMapping: function startPrefixMapping(prefix, uri) {},
  6481. endPrefixMapping: function endPrefixMapping(prefix) {},
  6482. processingInstruction: function processingInstruction(target, data) {
  6483. var ins = this.doc.createProcessingInstruction(target, data);
  6484. this.locator && position(this.locator, ins);
  6485. appendElement(this, ins);
  6486. },
  6487. ignorableWhitespace: function ignorableWhitespace(ch, start, length) {},
  6488. characters: function characters(chars, start, length) {
  6489. chars = _toString.apply(this, arguments); //console.log(chars)
  6490. if (chars) {
  6491. if (this.cdata) {
  6492. var charNode = this.doc.createCDATASection(chars);
  6493. } else {
  6494. var charNode = this.doc.createTextNode(chars);
  6495. }
  6496. if (this.currentElement) {
  6497. this.currentElement.appendChild(charNode);
  6498. } else if (/^\s*$/.test(chars)) {
  6499. this.doc.appendChild(charNode); //process xml
  6500. }
  6501. this.locator && position(this.locator, charNode);
  6502. }
  6503. },
  6504. skippedEntity: function skippedEntity(name) {},
  6505. endDocument: function endDocument() {
  6506. this.doc.normalize();
  6507. },
  6508. setDocumentLocator: function setDocumentLocator(locator) {
  6509. if (this.locator = locator) {
  6510. // && !('lineNumber' in locator)){
  6511. locator.lineNumber = 0;
  6512. }
  6513. },
  6514. //LexicalHandler
  6515. comment: function comment(chars, start, length) {
  6516. chars = _toString.apply(this, arguments);
  6517. var comm = this.doc.createComment(chars);
  6518. this.locator && position(this.locator, comm);
  6519. appendElement(this, comm);
  6520. },
  6521. startCDATA: function startCDATA() {
  6522. //used in characters() methods
  6523. this.cdata = true;
  6524. },
  6525. endCDATA: function endCDATA() {
  6526. this.cdata = false;
  6527. },
  6528. startDTD: function startDTD(name, publicId, systemId) {
  6529. var impl = this.doc.implementation;
  6530. if (impl && impl.createDocumentType) {
  6531. var dt = impl.createDocumentType(name, publicId, systemId);
  6532. this.locator && position(this.locator, dt);
  6533. appendElement(this, dt);
  6534. }
  6535. },
  6536. /**
  6537. * @see org.xml.sax.ErrorHandler
  6538. * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
  6539. */
  6540. warning: function warning(error) {
  6541. console.warn('[xmldom warning]\t' + error, _locator(this.locator));
  6542. },
  6543. error: function error(_error) {
  6544. console.error('[xmldom error]\t' + _error, _locator(this.locator));
  6545. },
  6546. fatalError: function fatalError(error) {
  6547. console.error('[xmldom fatalError]\t' + error, _locator(this.locator));
  6548. throw error;
  6549. }
  6550. };
  6551. function _locator(l) {
  6552. if (l) {
  6553. return '\n@' + (l.systemId || '') + '#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';
  6554. }
  6555. }
  6556. function _toString(chars, start, length) {
  6557. if (typeof chars == 'string') {
  6558. return chars.substr(start, length);
  6559. } else {
  6560. //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
  6561. if (chars.length >= start + length || start) {
  6562. return new java.lang.String(chars, start, length) + '';
  6563. }
  6564. return chars;
  6565. }
  6566. }
  6567. /*
  6568. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
  6569. * used method of org.xml.sax.ext.LexicalHandler:
  6570. * #comment(chars, start, length)
  6571. * #startCDATA()
  6572. * #endCDATA()
  6573. * #startDTD(name, publicId, systemId)
  6574. *
  6575. *
  6576. * IGNORED method of org.xml.sax.ext.LexicalHandler:
  6577. * #endDTD()
  6578. * #startEntity(name)
  6579. * #endEntity(name)
  6580. *
  6581. *
  6582. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
  6583. * IGNORED method of org.xml.sax.ext.DeclHandler
  6584. * #attributeDecl(eName, aName, type, mode, value)
  6585. * #elementDecl(name, model)
  6586. * #externalEntityDecl(name, publicId, systemId)
  6587. * #internalEntityDecl(name, value)
  6588. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
  6589. * IGNORED method of org.xml.sax.EntityResolver2
  6590. * #resolveEntity(String name,String publicId,String baseURI,String systemId)
  6591. * #resolveEntity(publicId, systemId)
  6592. * #getExternalSubset(name, baseURI)
  6593. * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
  6594. * IGNORED method of org.xml.sax.DTDHandler
  6595. * #notationDecl(name, publicId, systemId) {};
  6596. * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
  6597. */
  6598. "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function (key) {
  6599. DOMHandler.prototype[key] = function () {
  6600. return null;
  6601. };
  6602. });
  6603. /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
  6604. function appendElement(hander, node) {
  6605. if (!hander.currentElement) {
  6606. hander.doc.appendChild(node);
  6607. } else {
  6608. hander.currentElement.appendChild(node);
  6609. }
  6610. } //appendChild and setAttributeNS are preformance key
  6611. //if(typeof require == 'function'){
  6612. var htmlEntity = require('./entities');
  6613. var XMLReader = require('./sax').XMLReader;
  6614. var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
  6615. exports.XMLSerializer = require('./dom').XMLSerializer;
  6616. exports.DOMParser = DOMParser; //}
  6617. },{"./dom":43,"./entities":44,"./sax":45}],43:[function(require,module,exports){
  6618. "use strict";
  6619. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6620. /*
  6621. * DOM Level 2
  6622. * Object DOMException
  6623. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  6624. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  6625. */
  6626. function copy(src, dest) {
  6627. for (var p in src) {
  6628. dest[p] = src[p];
  6629. }
  6630. }
  6631. /**
  6632. ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
  6633. ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
  6634. */
  6635. function _extends(Class, Super) {
  6636. var pt = Class.prototype;
  6637. if (!(pt instanceof Super)) {
  6638. var t = function t() {};
  6639. ;
  6640. t.prototype = Super.prototype;
  6641. t = new t();
  6642. copy(pt, t);
  6643. Class.prototype = pt = t;
  6644. }
  6645. if (pt.constructor != Class) {
  6646. if (typeof Class != 'function') {
  6647. console.error("unknow Class:" + Class);
  6648. }
  6649. pt.constructor = Class;
  6650. }
  6651. }
  6652. var htmlns = 'http://www.w3.org/1999/xhtml'; // Node Types
  6653. var NodeType = {};
  6654. var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
  6655. var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
  6656. var TEXT_NODE = NodeType.TEXT_NODE = 3;
  6657. var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
  6658. var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
  6659. var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
  6660. var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
  6661. var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
  6662. var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
  6663. var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
  6664. var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
  6665. var NOTATION_NODE = NodeType.NOTATION_NODE = 12; // ExceptionCode
  6666. var ExceptionCode = {};
  6667. var ExceptionMessage = {};
  6668. var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
  6669. var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
  6670. var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
  6671. var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
  6672. var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
  6673. var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
  6674. var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
  6675. var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
  6676. var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
  6677. var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10); //level2
  6678. var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
  6679. var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
  6680. var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
  6681. var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
  6682. var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
  6683. function DOMException(code, message) {
  6684. if (message instanceof Error) {
  6685. var error = message;
  6686. } else {
  6687. error = this;
  6688. Error.call(this, ExceptionMessage[code]);
  6689. this.message = ExceptionMessage[code];
  6690. if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
  6691. }
  6692. error.code = code;
  6693. if (message) this.message = this.message + ": " + message;
  6694. return error;
  6695. }
  6696. ;
  6697. DOMException.prototype = Error.prototype;
  6698. copy(ExceptionCode, DOMException);
  6699. /**
  6700. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
  6701. * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
  6702. * The items in the NodeList are accessible via an integral index, starting from 0.
  6703. */
  6704. function NodeList() {}
  6705. ;
  6706. NodeList.prototype = {
  6707. /**
  6708. * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
  6709. * @standard level1
  6710. */
  6711. length: 0,
  6712. /**
  6713. * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
  6714. * @standard level1
  6715. * @param index unsigned long
  6716. * Index into the collection.
  6717. * @return Node
  6718. * The node at the indexth position in the NodeList, or null if that is not a valid index.
  6719. */
  6720. item: function item(index) {
  6721. return this[index] || null;
  6722. },
  6723. toString: function toString(isHTML, nodeFilter) {
  6724. for (var buf = [], i = 0; i < this.length; i++) {
  6725. serializeToString(this[i], buf, isHTML, nodeFilter);
  6726. }
  6727. return buf.join('');
  6728. }
  6729. };
  6730. function LiveNodeList(node, refresh) {
  6731. this._node = node;
  6732. this._refresh = refresh;
  6733. _updateLiveList(this);
  6734. }
  6735. function _updateLiveList(list) {
  6736. var inc = list._node._inc || list._node.ownerDocument._inc;
  6737. if (list._inc != inc) {
  6738. var ls = list._refresh(list._node); //console.log(ls.length)
  6739. __set__(list, 'length', ls.length);
  6740. copy(ls, list);
  6741. list._inc = inc;
  6742. }
  6743. }
  6744. LiveNodeList.prototype.item = function (i) {
  6745. _updateLiveList(this);
  6746. return this[i];
  6747. };
  6748. _extends(LiveNodeList, NodeList);
  6749. /**
  6750. *
  6751. * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
  6752. * NamedNodeMap objects in the DOM are live.
  6753. * used for attributes or DocumentType entities
  6754. */
  6755. function NamedNodeMap() {}
  6756. ;
  6757. function _findNodeIndex(list, node) {
  6758. var i = list.length;
  6759. while (i--) {
  6760. if (list[i] === node) {
  6761. return i;
  6762. }
  6763. }
  6764. }
  6765. function _addNamedNode(el, list, newAttr, oldAttr) {
  6766. if (oldAttr) {
  6767. list[_findNodeIndex(list, oldAttr)] = newAttr;
  6768. } else {
  6769. list[list.length++] = newAttr;
  6770. }
  6771. if (el) {
  6772. newAttr.ownerElement = el;
  6773. var doc = el.ownerDocument;
  6774. if (doc) {
  6775. oldAttr && _onRemoveAttribute(doc, el, oldAttr);
  6776. _onAddAttribute(doc, el, newAttr);
  6777. }
  6778. }
  6779. }
  6780. function _removeNamedNode(el, list, attr) {
  6781. //console.log('remove attr:'+attr)
  6782. var i = _findNodeIndex(list, attr);
  6783. if (i >= 0) {
  6784. var lastIndex = list.length - 1;
  6785. while (i < lastIndex) {
  6786. list[i] = list[++i];
  6787. }
  6788. list.length = lastIndex;
  6789. if (el) {
  6790. var doc = el.ownerDocument;
  6791. if (doc) {
  6792. _onRemoveAttribute(doc, el, attr);
  6793. attr.ownerElement = null;
  6794. }
  6795. }
  6796. } else {
  6797. throw DOMException(NOT_FOUND_ERR, new Error(el.tagName + '@' + attr));
  6798. }
  6799. }
  6800. NamedNodeMap.prototype = {
  6801. length: 0,
  6802. item: NodeList.prototype.item,
  6803. getNamedItem: function getNamedItem(key) {
  6804. // if(key.indexOf(':')>0 || key == 'xmlns'){
  6805. // return null;
  6806. // }
  6807. //console.log()
  6808. var i = this.length;
  6809. while (i--) {
  6810. var attr = this[i]; //console.log(attr.nodeName,key)
  6811. if (attr.nodeName == key) {
  6812. return attr;
  6813. }
  6814. }
  6815. },
  6816. setNamedItem: function setNamedItem(attr) {
  6817. var el = attr.ownerElement;
  6818. if (el && el != this._ownerElement) {
  6819. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  6820. }
  6821. var oldAttr = this.getNamedItem(attr.nodeName);
  6822. _addNamedNode(this._ownerElement, this, attr, oldAttr);
  6823. return oldAttr;
  6824. },
  6825. /* returns Node */
  6826. setNamedItemNS: function setNamedItemNS(attr) {
  6827. // raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
  6828. var el = attr.ownerElement,
  6829. oldAttr;
  6830. if (el && el != this._ownerElement) {
  6831. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  6832. }
  6833. oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
  6834. _addNamedNode(this._ownerElement, this, attr, oldAttr);
  6835. return oldAttr;
  6836. },
  6837. /* returns Node */
  6838. removeNamedItem: function removeNamedItem(key) {
  6839. var attr = this.getNamedItem(key);
  6840. _removeNamedNode(this._ownerElement, this, attr);
  6841. return attr;
  6842. },
  6843. // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
  6844. //for level2
  6845. removeNamedItemNS: function removeNamedItemNS(namespaceURI, localName) {
  6846. var attr = this.getNamedItemNS(namespaceURI, localName);
  6847. _removeNamedNode(this._ownerElement, this, attr);
  6848. return attr;
  6849. },
  6850. getNamedItemNS: function getNamedItemNS(namespaceURI, localName) {
  6851. var i = this.length;
  6852. while (i--) {
  6853. var node = this[i];
  6854. if (node.localName == localName && node.namespaceURI == namespaceURI) {
  6855. return node;
  6856. }
  6857. }
  6858. return null;
  6859. }
  6860. };
  6861. /**
  6862. * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
  6863. */
  6864. function DOMImplementation(
  6865. /* Object */
  6866. features) {
  6867. this._features = {};
  6868. if (features) {
  6869. for (var feature in features) {
  6870. this._features = features[feature];
  6871. }
  6872. }
  6873. }
  6874. ;
  6875. DOMImplementation.prototype = {
  6876. hasFeature: function hasFeature(
  6877. /* string */
  6878. feature,
  6879. /* string */
  6880. version) {
  6881. var versions = this._features[feature.toLowerCase()];
  6882. if (versions && (!version || version in versions)) {
  6883. return true;
  6884. } else {
  6885. return false;
  6886. }
  6887. },
  6888. // Introduced in DOM Level 2:
  6889. createDocument: function createDocument(namespaceURI, qualifiedName, doctype) {
  6890. // raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
  6891. var doc = new Document();
  6892. doc.implementation = this;
  6893. doc.childNodes = new NodeList();
  6894. doc.doctype = doctype;
  6895. if (doctype) {
  6896. doc.appendChild(doctype);
  6897. }
  6898. if (qualifiedName) {
  6899. var root = doc.createElementNS(namespaceURI, qualifiedName);
  6900. doc.appendChild(root);
  6901. }
  6902. return doc;
  6903. },
  6904. // Introduced in DOM Level 2:
  6905. createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) {
  6906. // raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
  6907. var node = new DocumentType();
  6908. node.name = qualifiedName;
  6909. node.nodeName = qualifiedName;
  6910. node.publicId = publicId;
  6911. node.systemId = systemId; // Introduced in DOM Level 2:
  6912. //readonly attribute DOMString internalSubset;
  6913. //REFINE:..
  6914. // readonly attribute NamedNodeMap entities;
  6915. // readonly attribute NamedNodeMap notations;
  6916. return node;
  6917. }
  6918. };
  6919. /**
  6920. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  6921. */
  6922. function Node() {}
  6923. ;
  6924. Node.prototype = {
  6925. firstChild: null,
  6926. lastChild: null,
  6927. previousSibling: null,
  6928. nextSibling: null,
  6929. attributes: null,
  6930. parentNode: null,
  6931. childNodes: null,
  6932. ownerDocument: null,
  6933. nodeValue: null,
  6934. namespaceURI: null,
  6935. prefix: null,
  6936. localName: null,
  6937. // Modified in DOM Level 2:
  6938. insertBefore: function insertBefore(newChild, refChild) {
  6939. //raises
  6940. return _insertBefore(this, newChild, refChild);
  6941. },
  6942. replaceChild: function replaceChild(newChild, oldChild) {
  6943. //raises
  6944. this.insertBefore(newChild, oldChild);
  6945. if (oldChild) {
  6946. this.removeChild(oldChild);
  6947. }
  6948. },
  6949. removeChild: function removeChild(oldChild) {
  6950. return _removeChild(this, oldChild);
  6951. },
  6952. appendChild: function appendChild(newChild) {
  6953. return this.insertBefore(newChild, null);
  6954. },
  6955. hasChildNodes: function hasChildNodes() {
  6956. return this.firstChild != null;
  6957. },
  6958. cloneNode: function cloneNode(deep) {
  6959. return _cloneNode(this.ownerDocument || this, this, deep);
  6960. },
  6961. // Modified in DOM Level 2:
  6962. normalize: function normalize() {
  6963. var child = this.firstChild;
  6964. while (child) {
  6965. var next = child.nextSibling;
  6966. if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
  6967. this.removeChild(next);
  6968. child.appendData(next.data);
  6969. } else {
  6970. child.normalize();
  6971. child = next;
  6972. }
  6973. }
  6974. },
  6975. // Introduced in DOM Level 2:
  6976. isSupported: function isSupported(feature, version) {
  6977. return this.ownerDocument.implementation.hasFeature(feature, version);
  6978. },
  6979. // Introduced in DOM Level 2:
  6980. hasAttributes: function hasAttributes() {
  6981. return this.attributes.length > 0;
  6982. },
  6983. lookupPrefix: function lookupPrefix(namespaceURI) {
  6984. var el = this;
  6985. while (el) {
  6986. var map = el._nsMap; //console.dir(map)
  6987. if (map) {
  6988. for (var n in map) {
  6989. if (map[n] == namespaceURI) {
  6990. return n;
  6991. }
  6992. }
  6993. }
  6994. el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
  6995. }
  6996. return null;
  6997. },
  6998. // Introduced in DOM Level 3:
  6999. lookupNamespaceURI: function lookupNamespaceURI(prefix) {
  7000. var el = this;
  7001. while (el) {
  7002. var map = el._nsMap; //console.dir(map)
  7003. if (map) {
  7004. if (prefix in map) {
  7005. return map[prefix];
  7006. }
  7007. }
  7008. el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
  7009. }
  7010. return null;
  7011. },
  7012. // Introduced in DOM Level 3:
  7013. isDefaultNamespace: function isDefaultNamespace(namespaceURI) {
  7014. var prefix = this.lookupPrefix(namespaceURI);
  7015. return prefix == null;
  7016. }
  7017. };
  7018. function _xmlEncoder(c) {
  7019. return c == '<' && '&lt;' || c == '>' && '&gt;' || c == '&' && '&amp;' || c == '"' && '&quot;' || '&#' + c.charCodeAt() + ';';
  7020. }
  7021. copy(NodeType, Node);
  7022. copy(NodeType, Node.prototype);
  7023. /**
  7024. * @param callback return true for continue,false for break
  7025. * @return boolean true: break visit;
  7026. */
  7027. function _visitNode(node, callback) {
  7028. if (callback(node)) {
  7029. return true;
  7030. }
  7031. if (node = node.firstChild) {
  7032. do {
  7033. if (_visitNode(node, callback)) {
  7034. return true;
  7035. }
  7036. } while (node = node.nextSibling);
  7037. }
  7038. }
  7039. function Document() {}
  7040. function _onAddAttribute(doc, el, newAttr) {
  7041. doc && doc._inc++;
  7042. var ns = newAttr.namespaceURI;
  7043. if (ns == 'http://www.w3.org/2000/xmlns/') {
  7044. //update namespace
  7045. el._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;
  7046. }
  7047. }
  7048. function _onRemoveAttribute(doc, el, newAttr, remove) {
  7049. doc && doc._inc++;
  7050. var ns = newAttr.namespaceURI;
  7051. if (ns == 'http://www.w3.org/2000/xmlns/') {
  7052. //update namespace
  7053. delete el._nsMap[newAttr.prefix ? newAttr.localName : ''];
  7054. }
  7055. }
  7056. function _onUpdateChild(doc, el, newChild) {
  7057. if (doc && doc._inc) {
  7058. doc._inc++; //update childNodes
  7059. var cs = el.childNodes;
  7060. if (newChild) {
  7061. cs[cs.length++] = newChild;
  7062. } else {
  7063. //console.log(1)
  7064. var child = el.firstChild;
  7065. var i = 0;
  7066. while (child) {
  7067. cs[i++] = child;
  7068. child = child.nextSibling;
  7069. }
  7070. cs.length = i;
  7071. }
  7072. }
  7073. }
  7074. /**
  7075. * attributes;
  7076. * children;
  7077. *
  7078. * writeable properties:
  7079. * nodeValue,Attr:value,CharacterData:data
  7080. * prefix
  7081. */
  7082. function _removeChild(parentNode, child) {
  7083. var previous = child.previousSibling;
  7084. var next = child.nextSibling;
  7085. if (previous) {
  7086. previous.nextSibling = next;
  7087. } else {
  7088. parentNode.firstChild = next;
  7089. }
  7090. if (next) {
  7091. next.previousSibling = previous;
  7092. } else {
  7093. parentNode.lastChild = previous;
  7094. }
  7095. _onUpdateChild(parentNode.ownerDocument, parentNode);
  7096. return child;
  7097. }
  7098. /**
  7099. * preformance key(refChild == null)
  7100. */
  7101. function _insertBefore(parentNode, newChild, nextChild) {
  7102. var cp = newChild.parentNode;
  7103. if (cp) {
  7104. cp.removeChild(newChild); //remove and update
  7105. }
  7106. if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
  7107. var newFirst = newChild.firstChild;
  7108. if (newFirst == null) {
  7109. return newChild;
  7110. }
  7111. var newLast = newChild.lastChild;
  7112. } else {
  7113. newFirst = newLast = newChild;
  7114. }
  7115. var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
  7116. newFirst.previousSibling = pre;
  7117. newLast.nextSibling = nextChild;
  7118. if (pre) {
  7119. pre.nextSibling = newFirst;
  7120. } else {
  7121. parentNode.firstChild = newFirst;
  7122. }
  7123. if (nextChild == null) {
  7124. parentNode.lastChild = newLast;
  7125. } else {
  7126. nextChild.previousSibling = newLast;
  7127. }
  7128. do {
  7129. newFirst.parentNode = parentNode;
  7130. } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
  7131. _onUpdateChild(parentNode.ownerDocument || parentNode, parentNode); //console.log(parentNode.lastChild.nextSibling == null)
  7132. if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
  7133. newChild.firstChild = newChild.lastChild = null;
  7134. }
  7135. return newChild;
  7136. }
  7137. function _appendSingleChild(parentNode, newChild) {
  7138. var cp = newChild.parentNode;
  7139. if (cp) {
  7140. var pre = parentNode.lastChild;
  7141. cp.removeChild(newChild); //remove and update
  7142. var pre = parentNode.lastChild;
  7143. }
  7144. var pre = parentNode.lastChild;
  7145. newChild.parentNode = parentNode;
  7146. newChild.previousSibling = pre;
  7147. newChild.nextSibling = null;
  7148. if (pre) {
  7149. pre.nextSibling = newChild;
  7150. } else {
  7151. parentNode.firstChild = newChild;
  7152. }
  7153. parentNode.lastChild = newChild;
  7154. _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
  7155. return newChild; //console.log("__aa",parentNode.lastChild.nextSibling == null)
  7156. }
  7157. Document.prototype = {
  7158. //implementation : null,
  7159. nodeName: '#document',
  7160. nodeType: DOCUMENT_NODE,
  7161. doctype: null,
  7162. documentElement: null,
  7163. _inc: 1,
  7164. insertBefore: function insertBefore(newChild, refChild) {
  7165. //raises
  7166. if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
  7167. var child = newChild.firstChild;
  7168. while (child) {
  7169. var next = child.nextSibling;
  7170. this.insertBefore(child, refChild);
  7171. child = next;
  7172. }
  7173. return newChild;
  7174. }
  7175. if (this.documentElement == null && newChild.nodeType == ELEMENT_NODE) {
  7176. this.documentElement = newChild;
  7177. }
  7178. return _insertBefore(this, newChild, refChild), newChild.ownerDocument = this, newChild;
  7179. },
  7180. removeChild: function removeChild(oldChild) {
  7181. if (this.documentElement == oldChild) {
  7182. this.documentElement = null;
  7183. }
  7184. return _removeChild(this, oldChild);
  7185. },
  7186. // Introduced in DOM Level 2:
  7187. importNode: function importNode(importedNode, deep) {
  7188. return _importNode(this, importedNode, deep);
  7189. },
  7190. // Introduced in DOM Level 2:
  7191. getElementById: function getElementById(id) {
  7192. var rtv = null;
  7193. _visitNode(this.documentElement, function (node) {
  7194. if (node.nodeType == ELEMENT_NODE) {
  7195. if (node.getAttribute('id') == id) {
  7196. rtv = node;
  7197. return true;
  7198. }
  7199. }
  7200. });
  7201. return rtv;
  7202. },
  7203. //document factory method:
  7204. createElement: function createElement(tagName) {
  7205. var node = new Element();
  7206. node.ownerDocument = this;
  7207. node.nodeName = tagName;
  7208. node.tagName = tagName;
  7209. node.childNodes = new NodeList();
  7210. var attrs = node.attributes = new NamedNodeMap();
  7211. attrs._ownerElement = node;
  7212. return node;
  7213. },
  7214. createDocumentFragment: function createDocumentFragment() {
  7215. var node = new DocumentFragment();
  7216. node.ownerDocument = this;
  7217. node.childNodes = new NodeList();
  7218. return node;
  7219. },
  7220. createTextNode: function createTextNode(data) {
  7221. var node = new Text();
  7222. node.ownerDocument = this;
  7223. node.appendData(data);
  7224. return node;
  7225. },
  7226. createComment: function createComment(data) {
  7227. var node = new Comment();
  7228. node.ownerDocument = this;
  7229. node.appendData(data);
  7230. return node;
  7231. },
  7232. createCDATASection: function createCDATASection(data) {
  7233. var node = new CDATASection();
  7234. node.ownerDocument = this;
  7235. node.appendData(data);
  7236. return node;
  7237. },
  7238. createProcessingInstruction: function createProcessingInstruction(target, data) {
  7239. var node = new ProcessingInstruction();
  7240. node.ownerDocument = this;
  7241. node.tagName = node.target = target;
  7242. node.nodeValue = node.data = data;
  7243. return node;
  7244. },
  7245. createAttribute: function createAttribute(name) {
  7246. var node = new Attr();
  7247. node.ownerDocument = this;
  7248. node.name = name;
  7249. node.nodeName = name;
  7250. node.localName = name;
  7251. node.specified = true;
  7252. return node;
  7253. },
  7254. createEntityReference: function createEntityReference(name) {
  7255. var node = new EntityReference();
  7256. node.ownerDocument = this;
  7257. node.nodeName = name;
  7258. return node;
  7259. },
  7260. // Introduced in DOM Level 2:
  7261. createElementNS: function createElementNS(namespaceURI, qualifiedName) {
  7262. var node = new Element();
  7263. var pl = qualifiedName.split(':');
  7264. var attrs = node.attributes = new NamedNodeMap();
  7265. node.childNodes = new NodeList();
  7266. node.ownerDocument = this;
  7267. node.nodeName = qualifiedName;
  7268. node.tagName = qualifiedName;
  7269. node.namespaceURI = namespaceURI;
  7270. if (pl.length == 2) {
  7271. node.prefix = pl[0];
  7272. node.localName = pl[1];
  7273. } else {
  7274. //el.prefix = null;
  7275. node.localName = qualifiedName;
  7276. }
  7277. attrs._ownerElement = node;
  7278. return node;
  7279. },
  7280. // Introduced in DOM Level 2:
  7281. createAttributeNS: function createAttributeNS(namespaceURI, qualifiedName) {
  7282. var node = new Attr();
  7283. var pl = qualifiedName.split(':');
  7284. node.ownerDocument = this;
  7285. node.nodeName = qualifiedName;
  7286. node.name = qualifiedName;
  7287. node.namespaceURI = namespaceURI;
  7288. node.specified = true;
  7289. if (pl.length == 2) {
  7290. node.prefix = pl[0];
  7291. node.localName = pl[1];
  7292. } else {
  7293. //el.prefix = null;
  7294. node.localName = qualifiedName;
  7295. }
  7296. return node;
  7297. }
  7298. };
  7299. _extends(Document, Node);
  7300. function Element() {
  7301. this._nsMap = {};
  7302. }
  7303. ;
  7304. Element.prototype = {
  7305. nodeType: ELEMENT_NODE,
  7306. hasAttribute: function hasAttribute(name) {
  7307. return this.getAttributeNode(name) != null;
  7308. },
  7309. getAttribute: function getAttribute(name) {
  7310. var attr = this.getAttributeNode(name);
  7311. return attr && attr.value || '';
  7312. },
  7313. getAttributeNode: function getAttributeNode(name) {
  7314. return this.attributes.getNamedItem(name);
  7315. },
  7316. setAttribute: function setAttribute(name, value) {
  7317. var attr = this.ownerDocument.createAttribute(name);
  7318. attr.value = attr.nodeValue = "" + value;
  7319. this.setAttributeNode(attr);
  7320. },
  7321. removeAttribute: function removeAttribute(name) {
  7322. var attr = this.getAttributeNode(name);
  7323. attr && this.removeAttributeNode(attr);
  7324. },
  7325. //four real opeartion method
  7326. appendChild: function appendChild(newChild) {
  7327. if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
  7328. return this.insertBefore(newChild, null);
  7329. } else {
  7330. return _appendSingleChild(this, newChild);
  7331. }
  7332. },
  7333. setAttributeNode: function setAttributeNode(newAttr) {
  7334. return this.attributes.setNamedItem(newAttr);
  7335. },
  7336. setAttributeNodeNS: function setAttributeNodeNS(newAttr) {
  7337. return this.attributes.setNamedItemNS(newAttr);
  7338. },
  7339. removeAttributeNode: function removeAttributeNode(oldAttr) {
  7340. //console.log(this == oldAttr.ownerElement)
  7341. return this.attributes.removeNamedItem(oldAttr.nodeName);
  7342. },
  7343. //get real attribute name,and remove it by removeAttributeNode
  7344. removeAttributeNS: function removeAttributeNS(namespaceURI, localName) {
  7345. var old = this.getAttributeNodeNS(namespaceURI, localName);
  7346. old && this.removeAttributeNode(old);
  7347. },
  7348. hasAttributeNS: function hasAttributeNS(namespaceURI, localName) {
  7349. return this.getAttributeNodeNS(namespaceURI, localName) != null;
  7350. },
  7351. getAttributeNS: function getAttributeNS(namespaceURI, localName) {
  7352. var attr = this.getAttributeNodeNS(namespaceURI, localName);
  7353. return attr && attr.value || '';
  7354. },
  7355. setAttributeNS: function setAttributeNS(namespaceURI, qualifiedName, value) {
  7356. var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
  7357. attr.value = attr.nodeValue = "" + value;
  7358. this.setAttributeNode(attr);
  7359. },
  7360. getAttributeNodeNS: function getAttributeNodeNS(namespaceURI, localName) {
  7361. return this.attributes.getNamedItemNS(namespaceURI, localName);
  7362. },
  7363. getElementsByTagName: function getElementsByTagName(tagName) {
  7364. return new LiveNodeList(this, function (base) {
  7365. var ls = [];
  7366. _visitNode(base, function (node) {
  7367. if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)) {
  7368. ls.push(node);
  7369. }
  7370. });
  7371. return ls;
  7372. });
  7373. },
  7374. getElementsByTagNameNS: function getElementsByTagNameNS(namespaceURI, localName) {
  7375. return new LiveNodeList(this, function (base) {
  7376. var ls = [];
  7377. _visitNode(base, function (node) {
  7378. if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)) {
  7379. ls.push(node);
  7380. }
  7381. });
  7382. return ls;
  7383. });
  7384. }
  7385. };
  7386. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
  7387. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
  7388. _extends(Element, Node);
  7389. function Attr() {}
  7390. ;
  7391. Attr.prototype.nodeType = ATTRIBUTE_NODE;
  7392. _extends(Attr, Node);
  7393. function CharacterData() {}
  7394. ;
  7395. CharacterData.prototype = {
  7396. data: '',
  7397. substringData: function substringData(offset, count) {
  7398. return this.data.substring(offset, offset + count);
  7399. },
  7400. appendData: function appendData(text) {
  7401. text = this.data + text;
  7402. this.nodeValue = this.data = text;
  7403. this.length = text.length;
  7404. },
  7405. insertData: function insertData(offset, text) {
  7406. this.replaceData(offset, 0, text);
  7407. },
  7408. appendChild: function appendChild(newChild) {
  7409. throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
  7410. },
  7411. deleteData: function deleteData(offset, count) {
  7412. this.replaceData(offset, count, "");
  7413. },
  7414. replaceData: function replaceData(offset, count, text) {
  7415. var start = this.data.substring(0, offset);
  7416. var end = this.data.substring(offset + count);
  7417. text = start + text + end;
  7418. this.nodeValue = this.data = text;
  7419. this.length = text.length;
  7420. }
  7421. };
  7422. _extends(CharacterData, Node);
  7423. function Text() {}
  7424. ;
  7425. Text.prototype = {
  7426. nodeName: "#text",
  7427. nodeType: TEXT_NODE,
  7428. splitText: function splitText(offset) {
  7429. var text = this.data;
  7430. var newText = text.substring(offset);
  7431. text = text.substring(0, offset);
  7432. this.data = this.nodeValue = text;
  7433. this.length = text.length;
  7434. var newNode = this.ownerDocument.createTextNode(newText);
  7435. if (this.parentNode) {
  7436. this.parentNode.insertBefore(newNode, this.nextSibling);
  7437. }
  7438. return newNode;
  7439. }
  7440. };
  7441. _extends(Text, CharacterData);
  7442. function Comment() {}
  7443. ;
  7444. Comment.prototype = {
  7445. nodeName: "#comment",
  7446. nodeType: COMMENT_NODE
  7447. };
  7448. _extends(Comment, CharacterData);
  7449. function CDATASection() {}
  7450. ;
  7451. CDATASection.prototype = {
  7452. nodeName: "#cdata-section",
  7453. nodeType: CDATA_SECTION_NODE
  7454. };
  7455. _extends(CDATASection, CharacterData);
  7456. function DocumentType() {}
  7457. ;
  7458. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
  7459. _extends(DocumentType, Node);
  7460. function Notation() {}
  7461. ;
  7462. Notation.prototype.nodeType = NOTATION_NODE;
  7463. _extends(Notation, Node);
  7464. function Entity() {}
  7465. ;
  7466. Entity.prototype.nodeType = ENTITY_NODE;
  7467. _extends(Entity, Node);
  7468. function EntityReference() {}
  7469. ;
  7470. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
  7471. _extends(EntityReference, Node);
  7472. function DocumentFragment() {}
  7473. ;
  7474. DocumentFragment.prototype.nodeName = "#document-fragment";
  7475. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
  7476. _extends(DocumentFragment, Node);
  7477. function ProcessingInstruction() {}
  7478. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
  7479. _extends(ProcessingInstruction, Node);
  7480. function XMLSerializer() {}
  7481. XMLSerializer.prototype.serializeToString = function (node, isHtml, nodeFilter) {
  7482. return nodeSerializeToString.call(node, isHtml, nodeFilter);
  7483. };
  7484. Node.prototype.toString = nodeSerializeToString;
  7485. function nodeSerializeToString(isHtml, nodeFilter) {
  7486. var buf = [];
  7487. var refNode = this.nodeType == 9 && this.documentElement || this;
  7488. var prefix = refNode.prefix;
  7489. var uri = refNode.namespaceURI;
  7490. if (uri && prefix == null) {
  7491. //console.log(prefix)
  7492. var prefix = refNode.lookupPrefix(uri);
  7493. if (prefix == null) {
  7494. //isHTML = true;
  7495. var visibleNamespaces = [{
  7496. namespace: uri,
  7497. prefix: null
  7498. } //{namespace:uri,prefix:''}
  7499. ];
  7500. }
  7501. }
  7502. serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces); //console.log('###',this.nodeType,uri,prefix,buf.join(''))
  7503. return buf.join('');
  7504. }
  7505. function needNamespaceDefine(node, isHTML, visibleNamespaces) {
  7506. var prefix = node.prefix || '';
  7507. var uri = node.namespaceURI;
  7508. if (!prefix && !uri) {
  7509. return false;
  7510. }
  7511. if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" || uri == 'http://www.w3.org/2000/xmlns/') {
  7512. return false;
  7513. }
  7514. var i = visibleNamespaces.length; //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
  7515. while (i--) {
  7516. var ns = visibleNamespaces[i]; // get namespace prefix
  7517. //console.log(node.nodeType,node.tagName,ns.prefix,prefix)
  7518. if (ns.prefix == prefix) {
  7519. return ns.namespace != uri;
  7520. }
  7521. } //console.log(isHTML,uri,prefix=='')
  7522. //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
  7523. // return false;
  7524. //}
  7525. //node.flag = '11111'
  7526. //console.error(3,true,node.flag,node.prefix,node.namespaceURI)
  7527. return true;
  7528. }
  7529. function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
  7530. if (nodeFilter) {
  7531. node = nodeFilter(node);
  7532. if (node) {
  7533. if (typeof node == 'string') {
  7534. buf.push(node);
  7535. return;
  7536. }
  7537. } else {
  7538. return;
  7539. } //buf.sort.apply(attrs, attributeSorter);
  7540. }
  7541. switch (node.nodeType) {
  7542. case ELEMENT_NODE:
  7543. if (!visibleNamespaces) visibleNamespaces = [];
  7544. var startVisibleNamespaces = visibleNamespaces.length;
  7545. var attrs = node.attributes;
  7546. var len = attrs.length;
  7547. var child = node.firstChild;
  7548. var nodeName = node.tagName;
  7549. isHTML = htmlns === node.namespaceURI || isHTML;
  7550. buf.push('<', nodeName);
  7551. for (var i = 0; i < len; i++) {
  7552. // add namespaces for attributes
  7553. var attr = attrs.item(i);
  7554. if (attr.prefix == 'xmlns') {
  7555. visibleNamespaces.push({
  7556. prefix: attr.localName,
  7557. namespace: attr.value
  7558. });
  7559. } else if (attr.nodeName == 'xmlns') {
  7560. visibleNamespaces.push({
  7561. prefix: '',
  7562. namespace: attr.value
  7563. });
  7564. }
  7565. }
  7566. for (var i = 0; i < len; i++) {
  7567. var attr = attrs.item(i);
  7568. if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
  7569. var prefix = attr.prefix || '';
  7570. var uri = attr.namespaceURI;
  7571. var ns = prefix ? ' xmlns:' + prefix : " xmlns";
  7572. buf.push(ns, '="', uri, '"');
  7573. visibleNamespaces.push({
  7574. prefix: prefix,
  7575. namespace: uri
  7576. });
  7577. }
  7578. serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
  7579. } // add namespace for current node
  7580. if (needNamespaceDefine(node, isHTML, visibleNamespaces)) {
  7581. var prefix = node.prefix || '';
  7582. var uri = node.namespaceURI;
  7583. var ns = prefix ? ' xmlns:' + prefix : " xmlns";
  7584. buf.push(ns, '="', uri, '"');
  7585. visibleNamespaces.push({
  7586. prefix: prefix,
  7587. namespace: uri
  7588. });
  7589. }
  7590. if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
  7591. buf.push('>'); //if is cdata child node
  7592. if (isHTML && /^script$/i.test(nodeName)) {
  7593. while (child) {
  7594. if (child.data) {
  7595. buf.push(child.data);
  7596. } else {
  7597. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
  7598. }
  7599. child = child.nextSibling;
  7600. }
  7601. } else {
  7602. while (child) {
  7603. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
  7604. child = child.nextSibling;
  7605. }
  7606. }
  7607. buf.push('</', nodeName, '>');
  7608. } else {
  7609. buf.push('/>');
  7610. } // remove added visible namespaces
  7611. //visibleNamespaces.length = startVisibleNamespaces;
  7612. return;
  7613. case DOCUMENT_NODE:
  7614. case DOCUMENT_FRAGMENT_NODE:
  7615. var child = node.firstChild;
  7616. while (child) {
  7617. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
  7618. child = child.nextSibling;
  7619. }
  7620. return;
  7621. case ATTRIBUTE_NODE:
  7622. return buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g, _xmlEncoder), '"');
  7623. case TEXT_NODE:
  7624. return buf.push(node.data.replace(/[<&]/g, _xmlEncoder));
  7625. case CDATA_SECTION_NODE:
  7626. return buf.push('<![CDATA[', node.data, ']]>');
  7627. case COMMENT_NODE:
  7628. return buf.push("<!--", node.data, "-->");
  7629. case DOCUMENT_TYPE_NODE:
  7630. var pubid = node.publicId;
  7631. var sysid = node.systemId;
  7632. buf.push('<!DOCTYPE ', node.name);
  7633. if (pubid) {
  7634. buf.push(' PUBLIC "', pubid);
  7635. if (sysid && sysid != '.') {
  7636. buf.push('" "', sysid);
  7637. }
  7638. buf.push('">');
  7639. } else if (sysid && sysid != '.') {
  7640. buf.push(' SYSTEM "', sysid, '">');
  7641. } else {
  7642. var sub = node.internalSubset;
  7643. if (sub) {
  7644. buf.push(" [", sub, "]");
  7645. }
  7646. buf.push(">");
  7647. }
  7648. return;
  7649. case PROCESSING_INSTRUCTION_NODE:
  7650. return buf.push("<?", node.target, " ", node.data, "?>");
  7651. case ENTITY_REFERENCE_NODE:
  7652. return buf.push('&', node.nodeName, ';');
  7653. //case ENTITY_NODE:
  7654. //case NOTATION_NODE:
  7655. default:
  7656. buf.push('??', node.nodeName);
  7657. }
  7658. }
  7659. function _importNode(doc, node, deep) {
  7660. var node2;
  7661. switch (node.nodeType) {
  7662. case ELEMENT_NODE:
  7663. node2 = node.cloneNode(false);
  7664. node2.ownerDocument = doc;
  7665. //var attrs = node2.attributes;
  7666. //var len = attrs.length;
  7667. //for(var i=0;i<len;i++){
  7668. //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
  7669. //}
  7670. case DOCUMENT_FRAGMENT_NODE:
  7671. break;
  7672. case ATTRIBUTE_NODE:
  7673. deep = true;
  7674. break;
  7675. //case ENTITY_REFERENCE_NODE:
  7676. //case PROCESSING_INSTRUCTION_NODE:
  7677. ////case TEXT_NODE:
  7678. //case CDATA_SECTION_NODE:
  7679. //case COMMENT_NODE:
  7680. // deep = false;
  7681. // break;
  7682. //case DOCUMENT_NODE:
  7683. //case DOCUMENT_TYPE_NODE:
  7684. //cannot be imported.
  7685. //case ENTITY_NODE:
  7686. //case NOTATION_NODE:
  7687. //can not hit in level3
  7688. //default:throw e;
  7689. }
  7690. if (!node2) {
  7691. node2 = node.cloneNode(false); //false
  7692. }
  7693. node2.ownerDocument = doc;
  7694. node2.parentNode = null;
  7695. if (deep) {
  7696. var child = node.firstChild;
  7697. while (child) {
  7698. node2.appendChild(_importNode(doc, child, deep));
  7699. child = child.nextSibling;
  7700. }
  7701. }
  7702. return node2;
  7703. } //
  7704. //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
  7705. // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
  7706. function _cloneNode(doc, node, deep) {
  7707. var node2 = new node.constructor();
  7708. for (var n in node) {
  7709. var v = node[n];
  7710. if (_typeof(v) != 'object') {
  7711. if (v != node2[n]) {
  7712. node2[n] = v;
  7713. }
  7714. }
  7715. }
  7716. if (node.childNodes) {
  7717. node2.childNodes = new NodeList();
  7718. }
  7719. node2.ownerDocument = doc;
  7720. switch (node2.nodeType) {
  7721. case ELEMENT_NODE:
  7722. var attrs = node.attributes;
  7723. var attrs2 = node2.attributes = new NamedNodeMap();
  7724. var len = attrs.length;
  7725. attrs2._ownerElement = node2;
  7726. for (var i = 0; i < len; i++) {
  7727. node2.setAttributeNode(_cloneNode(doc, attrs.item(i), true));
  7728. }
  7729. break;
  7730. ;
  7731. case ATTRIBUTE_NODE:
  7732. deep = true;
  7733. }
  7734. if (deep) {
  7735. var child = node.firstChild;
  7736. while (child) {
  7737. node2.appendChild(_cloneNode(doc, child, deep));
  7738. child = child.nextSibling;
  7739. }
  7740. }
  7741. return node2;
  7742. }
  7743. function __set__(object, key, value) {
  7744. object[key] = value;
  7745. } //do dynamic
  7746. try {
  7747. if (Object.defineProperty) {
  7748. var getTextContent = function getTextContent(node) {
  7749. switch (node.nodeType) {
  7750. case ELEMENT_NODE:
  7751. case DOCUMENT_FRAGMENT_NODE:
  7752. var buf = [];
  7753. node = node.firstChild;
  7754. while (node) {
  7755. if (node.nodeType !== 7 && node.nodeType !== 8) {
  7756. buf.push(getTextContent(node));
  7757. }
  7758. node = node.nextSibling;
  7759. }
  7760. return buf.join('');
  7761. default:
  7762. return node.nodeValue;
  7763. }
  7764. };
  7765. Object.defineProperty(LiveNodeList.prototype, 'length', {
  7766. get: function get() {
  7767. _updateLiveList(this);
  7768. return this.$$length;
  7769. }
  7770. });
  7771. Object.defineProperty(Node.prototype, 'textContent', {
  7772. get: function get() {
  7773. return getTextContent(this);
  7774. },
  7775. set: function set(data) {
  7776. switch (this.nodeType) {
  7777. case ELEMENT_NODE:
  7778. case DOCUMENT_FRAGMENT_NODE:
  7779. while (this.firstChild) {
  7780. this.removeChild(this.firstChild);
  7781. }
  7782. if (data || String(data)) {
  7783. this.appendChild(this.ownerDocument.createTextNode(data));
  7784. }
  7785. break;
  7786. default:
  7787. //REFINE:
  7788. this.data = data;
  7789. this.value = data;
  7790. this.nodeValue = data;
  7791. }
  7792. }
  7793. });
  7794. __set__ = function __set__(object, key, value) {
  7795. //console.log(value)
  7796. object['$$' + key] = value;
  7797. };
  7798. }
  7799. } catch (e) {//ie8
  7800. } //if(typeof require == 'function'){
  7801. exports.DOMImplementation = DOMImplementation;
  7802. exports.XMLSerializer = XMLSerializer; //}
  7803. },{}],44:[function(require,module,exports){
  7804. "use strict";
  7805. exports.entityMap = {
  7806. lt: '<',
  7807. gt: '>',
  7808. amp: '&',
  7809. quot: '"',
  7810. apos: "'",
  7811. Agrave: "À",
  7812. Aacute: "Á",
  7813. Acirc: "Â",
  7814. Atilde: "Ã",
  7815. Auml: "Ä",
  7816. Aring: "Å",
  7817. AElig: "Æ",
  7818. Ccedil: "Ç",
  7819. Egrave: "È",
  7820. Eacute: "É",
  7821. Ecirc: "Ê",
  7822. Euml: "Ë",
  7823. Igrave: "Ì",
  7824. Iacute: "Í",
  7825. Icirc: "Î",
  7826. Iuml: "Ï",
  7827. ETH: "Ð",
  7828. Ntilde: "Ñ",
  7829. Ograve: "Ò",
  7830. Oacute: "Ó",
  7831. Ocirc: "Ô",
  7832. Otilde: "Õ",
  7833. Ouml: "Ö",
  7834. Oslash: "Ø",
  7835. Ugrave: "Ù",
  7836. Uacute: "Ú",
  7837. Ucirc: "Û",
  7838. Uuml: "Ü",
  7839. Yacute: "Ý",
  7840. THORN: "Þ",
  7841. szlig: "ß",
  7842. agrave: "à",
  7843. aacute: "á",
  7844. acirc: "â",
  7845. atilde: "ã",
  7846. auml: "ä",
  7847. aring: "å",
  7848. aelig: "æ",
  7849. ccedil: "ç",
  7850. egrave: "è",
  7851. eacute: "é",
  7852. ecirc: "ê",
  7853. euml: "ë",
  7854. igrave: "ì",
  7855. iacute: "í",
  7856. icirc: "î",
  7857. iuml: "ï",
  7858. eth: "ð",
  7859. ntilde: "ñ",
  7860. ograve: "ò",
  7861. oacute: "ó",
  7862. ocirc: "ô",
  7863. otilde: "õ",
  7864. ouml: "ö",
  7865. oslash: "ø",
  7866. ugrave: "ù",
  7867. uacute: "ú",
  7868. ucirc: "û",
  7869. uuml: "ü",
  7870. yacute: "ý",
  7871. thorn: "þ",
  7872. yuml: "ÿ",
  7873. nbsp: " ",
  7874. iexcl: "¡",
  7875. cent: "¢",
  7876. pound: "£",
  7877. curren: "¤",
  7878. yen: "¥",
  7879. brvbar: "¦",
  7880. sect: "§",
  7881. uml: "¨",
  7882. copy: "©",
  7883. ordf: "ª",
  7884. laquo: "«",
  7885. not: "¬",
  7886. shy: "­­",
  7887. reg: "®",
  7888. macr: "¯",
  7889. deg: "°",
  7890. plusmn: "±",
  7891. sup2: "²",
  7892. sup3: "³",
  7893. acute: "´",
  7894. micro: "µ",
  7895. para: "¶",
  7896. middot: "·",
  7897. cedil: "¸",
  7898. sup1: "¹",
  7899. ordm: "º",
  7900. raquo: "»",
  7901. frac14: "¼",
  7902. frac12: "½",
  7903. frac34: "¾",
  7904. iquest: "¿",
  7905. times: "×",
  7906. divide: "÷",
  7907. forall: "∀",
  7908. part: "∂",
  7909. exist: "∃",
  7910. empty: "∅",
  7911. nabla: "∇",
  7912. isin: "∈",
  7913. notin: "∉",
  7914. ni: "∋",
  7915. prod: "∏",
  7916. sum: "∑",
  7917. minus: "−",
  7918. lowast: "∗",
  7919. radic: "√",
  7920. prop: "∝",
  7921. infin: "∞",
  7922. ang: "∠",
  7923. and: "∧",
  7924. or: "∨",
  7925. cap: "∩",
  7926. cup: "∪",
  7927. 'int': "∫",
  7928. there4: "∴",
  7929. sim: "∼",
  7930. cong: "≅",
  7931. asymp: "≈",
  7932. ne: "≠",
  7933. equiv: "≡",
  7934. le: "≤",
  7935. ge: "≥",
  7936. sub: "⊂",
  7937. sup: "⊃",
  7938. nsub: "⊄",
  7939. sube: "⊆",
  7940. supe: "⊇",
  7941. oplus: "⊕",
  7942. otimes: "⊗",
  7943. perp: "⊥",
  7944. sdot: "⋅",
  7945. Alpha: "Α",
  7946. Beta: "Β",
  7947. Gamma: "Γ",
  7948. Delta: "Δ",
  7949. Epsilon: "Ε",
  7950. Zeta: "Ζ",
  7951. Eta: "Η",
  7952. Theta: "Θ",
  7953. Iota: "Ι",
  7954. Kappa: "Κ",
  7955. Lambda: "Λ",
  7956. Mu: "Μ",
  7957. Nu: "Ν",
  7958. Xi: "Ξ",
  7959. Omicron: "Ο",
  7960. Pi: "Π",
  7961. Rho: "Ρ",
  7962. Sigma: "Σ",
  7963. Tau: "Τ",
  7964. Upsilon: "Υ",
  7965. Phi: "Φ",
  7966. Chi: "Χ",
  7967. Psi: "Ψ",
  7968. Omega: "Ω",
  7969. alpha: "α",
  7970. beta: "β",
  7971. gamma: "γ",
  7972. delta: "δ",
  7973. epsilon: "ε",
  7974. zeta: "ζ",
  7975. eta: "η",
  7976. theta: "θ",
  7977. iota: "ι",
  7978. kappa: "κ",
  7979. lambda: "λ",
  7980. mu: "μ",
  7981. nu: "ν",
  7982. xi: "ξ",
  7983. omicron: "ο",
  7984. pi: "π",
  7985. rho: "ρ",
  7986. sigmaf: "ς",
  7987. sigma: "σ",
  7988. tau: "τ",
  7989. upsilon: "υ",
  7990. phi: "φ",
  7991. chi: "χ",
  7992. psi: "ψ",
  7993. omega: "ω",
  7994. thetasym: "ϑ",
  7995. upsih: "ϒ",
  7996. piv: "ϖ",
  7997. OElig: "Œ",
  7998. oelig: "œ",
  7999. Scaron: "Š",
  8000. scaron: "š",
  8001. Yuml: "Ÿ",
  8002. fnof: "ƒ",
  8003. circ: "ˆ",
  8004. tilde: "˜",
  8005. ensp: " ",
  8006. emsp: " ",
  8007. thinsp: " ",
  8008. zwnj: "‌",
  8009. zwj: "‍",
  8010. lrm: "‎",
  8011. rlm: "‏",
  8012. ndash: "–",
  8013. mdash: "—",
  8014. lsquo: "‘",
  8015. rsquo: "’",
  8016. sbquo: "‚",
  8017. ldquo: "“",
  8018. rdquo: "”",
  8019. bdquo: "„",
  8020. dagger: "†",
  8021. Dagger: "‡",
  8022. bull: "•",
  8023. hellip: "…",
  8024. permil: "‰",
  8025. prime: "′",
  8026. Prime: "″",
  8027. lsaquo: "‹",
  8028. rsaquo: "›",
  8029. oline: "‾",
  8030. euro: "€",
  8031. trade: "™",
  8032. larr: "←",
  8033. uarr: "↑",
  8034. rarr: "→",
  8035. darr: "↓",
  8036. harr: "↔",
  8037. crarr: "↵",
  8038. lceil: "⌈",
  8039. rceil: "⌉",
  8040. lfloor: "⌊",
  8041. rfloor: "⌋",
  8042. loz: "◊",
  8043. spades: "♠",
  8044. clubs: "♣",
  8045. hearts: "♥",
  8046. diams: "♦"
  8047. }; //for(var n in exports.entityMap){console.log(exports.entityMap[n].charCodeAt())}
  8048. },{}],45:[function(require,module,exports){
  8049. "use strict";
  8050. //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
  8051. //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
  8052. //[5] Name ::= NameStartChar (NameChar)*
  8053. var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; //\u10000-\uEFFFF
  8054. var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
  8055. var tagNamePattern = new RegExp('^' + nameStartChar.source + nameChar.source + '*(?:\:' + nameStartChar.source + nameChar.source + '*)?$'); //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
  8056. //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
  8057. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  8058. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  8059. var S_TAG = 0; //tag name offerring
  8060. var S_ATTR = 1; //attr name offerring
  8061. var S_ATTR_SPACE = 2; //attr name end and space offer
  8062. var S_EQ = 3; //=space?
  8063. var S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)
  8064. var S_ATTR_END = 5; //attr value end and no space(quot end)
  8065. var S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)
  8066. var S_TAG_CLOSE = 7; //closed el<el />
  8067. function XMLReader() {}
  8068. XMLReader.prototype = {
  8069. parse: function parse(source, defaultNSMap, entityMap) {
  8070. var domBuilder = this.domBuilder;
  8071. domBuilder.startDocument();
  8072. _copy(defaultNSMap, defaultNSMap = {});
  8073. _parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
  8074. domBuilder.endDocument();
  8075. }
  8076. };
  8077. function _parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
  8078. function fixedFromCharCode(code) {
  8079. // String.prototype.fromCharCode does not supports
  8080. // > 2 bytes unicode chars directly
  8081. if (code > 0xffff) {
  8082. code -= 0x10000;
  8083. var surrogate1 = 0xd800 + (code >> 10),
  8084. surrogate2 = 0xdc00 + (code & 0x3ff);
  8085. return String.fromCharCode(surrogate1, surrogate2);
  8086. } else {
  8087. return String.fromCharCode(code);
  8088. }
  8089. }
  8090. function entityReplacer(a) {
  8091. var k = a.slice(1, -1);
  8092. if (k in entityMap) {
  8093. return entityMap[k];
  8094. } else if (k.charAt(0) === '#') {
  8095. return fixedFromCharCode(parseInt(k.substr(1).replace('x', '0x')));
  8096. } else {
  8097. errorHandler.error('entity not found:' + a);
  8098. return a;
  8099. }
  8100. }
  8101. function appendText(end) {
  8102. //has some bugs
  8103. if (end > start) {
  8104. var xt = source.substring(start, end).replace(/&#?\w+;/g, entityReplacer);
  8105. locator && position(start);
  8106. domBuilder.characters(xt, 0, end - start);
  8107. start = end;
  8108. }
  8109. }
  8110. function position(p, m) {
  8111. while (p >= lineEnd && (m = linePattern.exec(source))) {
  8112. lineStart = m.index;
  8113. lineEnd = lineStart + m[0].length;
  8114. locator.lineNumber++; //console.log('line++:',locator,startPos,endPos)
  8115. }
  8116. locator.columnNumber = p - lineStart + 1;
  8117. }
  8118. var lineStart = 0;
  8119. var lineEnd = 0;
  8120. var linePattern = /.*(?:\r\n?|\n)|.*$/g;
  8121. var locator = domBuilder.locator;
  8122. var parseStack = [{
  8123. currentNSMap: defaultNSMapCopy
  8124. }];
  8125. var closeMap = {};
  8126. var start = 0;
  8127. while (true) {
  8128. try {
  8129. var tagStart = source.indexOf('<', start);
  8130. if (tagStart < 0) {
  8131. if (!source.substr(start).match(/^\s*$/)) {
  8132. var doc = domBuilder.doc;
  8133. var text = doc.createTextNode(source.substr(start));
  8134. doc.appendChild(text);
  8135. domBuilder.currentElement = text;
  8136. }
  8137. return;
  8138. }
  8139. if (tagStart > start) {
  8140. appendText(tagStart);
  8141. }
  8142. switch (source.charAt(tagStart + 1)) {
  8143. case '/':
  8144. var end = source.indexOf('>', tagStart + 3);
  8145. var tagName = source.substring(tagStart + 2, end);
  8146. var config = parseStack.pop();
  8147. if (end < 0) {
  8148. tagName = source.substring(tagStart + 2).replace(/[\s<].*/, ''); //console.error('#@@@@@@'+tagName)
  8149. errorHandler.error("end tag name: " + tagName + ' is not complete:' + config.tagName);
  8150. end = tagStart + 1 + tagName.length;
  8151. } else if (tagName.match(/\s</)) {
  8152. tagName = tagName.replace(/[\s<].*/, '');
  8153. errorHandler.error("end tag name: " + tagName + ' maybe not complete');
  8154. end = tagStart + 1 + tagName.length;
  8155. } //console.error(parseStack.length,parseStack)
  8156. //console.error(config);
  8157. var localNSMap = config.localNSMap;
  8158. var endMatch = config.tagName == tagName;
  8159. var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
  8160. if (endIgnoreCaseMach) {
  8161. domBuilder.endElement(config.uri, config.localName, tagName);
  8162. if (localNSMap) {
  8163. for (var prefix in localNSMap) {
  8164. domBuilder.endPrefixMapping(prefix);
  8165. }
  8166. }
  8167. if (!endMatch) {
  8168. errorHandler.fatalError("end tag name: " + tagName + ' is not match the current start tagName:' + config.tagName);
  8169. }
  8170. } else {
  8171. parseStack.push(config);
  8172. }
  8173. end++;
  8174. break;
  8175. // end elment
  8176. case '?':
  8177. // <?...?>
  8178. locator && position(tagStart);
  8179. end = parseInstruction(source, tagStart, domBuilder);
  8180. break;
  8181. case '!':
  8182. // <!doctype,<![CDATA,<!--
  8183. locator && position(tagStart);
  8184. end = parseDCC(source, tagStart, domBuilder, errorHandler);
  8185. break;
  8186. default:
  8187. locator && position(tagStart);
  8188. var el = new ElementAttributes();
  8189. var currentNSMap = parseStack[parseStack.length - 1].currentNSMap; //elStartEnd
  8190. var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
  8191. var len = el.length;
  8192. if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
  8193. el.closed = true;
  8194. if (!entityMap.nbsp) {
  8195. errorHandler.warning('unclosed xml attribute');
  8196. }
  8197. }
  8198. if (locator && len) {
  8199. var locator2 = copyLocator(locator, {}); //try{//attribute position fixed
  8200. for (var i = 0; i < len; i++) {
  8201. var a = el[i];
  8202. position(a.offset);
  8203. a.locator = copyLocator(locator, {});
  8204. } //}catch(e){console.error('@@@@@'+e)}
  8205. domBuilder.locator = locator2;
  8206. if (appendElement(el, domBuilder, currentNSMap)) {
  8207. parseStack.push(el);
  8208. }
  8209. domBuilder.locator = locator;
  8210. } else {
  8211. if (appendElement(el, domBuilder, currentNSMap)) {
  8212. parseStack.push(el);
  8213. }
  8214. }
  8215. if (el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed) {
  8216. end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
  8217. } else {
  8218. end++;
  8219. }
  8220. }
  8221. } catch (e) {
  8222. errorHandler.error('element parse error: ' + e); //errorHandler.error('element parse error: '+e);
  8223. end = -1; //throw e;
  8224. }
  8225. if (end > start) {
  8226. start = end;
  8227. } else {
  8228. //REFINE: 这里有可能sax回退,有位置错误风险
  8229. appendText(Math.max(tagStart, start) + 1);
  8230. }
  8231. }
  8232. }
  8233. function copyLocator(f, t) {
  8234. t.lineNumber = f.lineNumber;
  8235. t.columnNumber = f.columnNumber;
  8236. return t;
  8237. }
  8238. /**
  8239. * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
  8240. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  8241. */
  8242. function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
  8243. var attrName;
  8244. var value;
  8245. var p = ++start;
  8246. var s = S_TAG; //status
  8247. while (true) {
  8248. var c = source.charAt(p);
  8249. switch (c) {
  8250. case '=':
  8251. if (s === S_ATTR) {
  8252. //attrName
  8253. attrName = source.slice(start, p);
  8254. s = S_EQ;
  8255. } else if (s === S_ATTR_SPACE) {
  8256. s = S_EQ;
  8257. } else {
  8258. //fatalError: equal must after attrName or space after attrName
  8259. throw new Error('attribute equal must after attrName');
  8260. }
  8261. break;
  8262. case '\'':
  8263. case '"':
  8264. if (s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
  8265. ) {
  8266. //equal
  8267. if (s === S_ATTR) {
  8268. errorHandler.warning('attribute value must after "="');
  8269. attrName = source.slice(start, p);
  8270. }
  8271. start = p + 1;
  8272. p = source.indexOf(c, start);
  8273. if (p > 0) {
  8274. value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
  8275. el.add(attrName, value, start - 1);
  8276. s = S_ATTR_END;
  8277. } else {
  8278. //fatalError: no end quot match
  8279. throw new Error('attribute value no end \'' + c + '\' match');
  8280. }
  8281. } else if (s == S_ATTR_NOQUOT_VALUE) {
  8282. value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer); //console.log(attrName,value,start,p)
  8283. el.add(attrName, value, start); //console.dir(el)
  8284. errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ')!!');
  8285. start = p + 1;
  8286. s = S_ATTR_END;
  8287. } else {
  8288. //fatalError: no equal before
  8289. throw new Error('attribute value must after "="');
  8290. }
  8291. break;
  8292. case '/':
  8293. switch (s) {
  8294. case S_TAG:
  8295. el.setTagName(source.slice(start, p));
  8296. case S_ATTR_END:
  8297. case S_TAG_SPACE:
  8298. case S_TAG_CLOSE:
  8299. s = S_TAG_CLOSE;
  8300. el.closed = true;
  8301. case S_ATTR_NOQUOT_VALUE:
  8302. case S_ATTR:
  8303. case S_ATTR_SPACE:
  8304. break;
  8305. //case S_EQ:
  8306. default:
  8307. throw new Error("attribute invalid close char('/')");
  8308. }
  8309. break;
  8310. case '':
  8311. //end document
  8312. //throw new Error('unexpected end of input')
  8313. errorHandler.error('unexpected end of input');
  8314. if (s == S_TAG) {
  8315. el.setTagName(source.slice(start, p));
  8316. }
  8317. return p;
  8318. case '>':
  8319. switch (s) {
  8320. case S_TAG:
  8321. el.setTagName(source.slice(start, p));
  8322. case S_ATTR_END:
  8323. case S_TAG_SPACE:
  8324. case S_TAG_CLOSE:
  8325. break;
  8326. //normal
  8327. case S_ATTR_NOQUOT_VALUE: //Compatible state
  8328. case S_ATTR:
  8329. value = source.slice(start, p);
  8330. if (value.slice(-1) === '/') {
  8331. el.closed = true;
  8332. value = value.slice(0, -1);
  8333. }
  8334. case S_ATTR_SPACE:
  8335. if (s === S_ATTR_SPACE) {
  8336. value = attrName;
  8337. }
  8338. if (s == S_ATTR_NOQUOT_VALUE) {
  8339. errorHandler.warning('attribute "' + value + '" missed quot(")!!');
  8340. el.add(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
  8341. } else {
  8342. if (currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)) {
  8343. errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
  8344. }
  8345. el.add(value, value, start);
  8346. }
  8347. break;
  8348. case S_EQ:
  8349. throw new Error('attribute value missed!!');
  8350. } // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
  8351. return p;
  8352. /*xml space '\x20' | #x9 | #xD | #xA; */
  8353. case "\x80":
  8354. c = ' ';
  8355. default:
  8356. if (c <= ' ') {
  8357. //space
  8358. switch (s) {
  8359. case S_TAG:
  8360. el.setTagName(source.slice(start, p)); //tagName
  8361. s = S_TAG_SPACE;
  8362. break;
  8363. case S_ATTR:
  8364. attrName = source.slice(start, p);
  8365. s = S_ATTR_SPACE;
  8366. break;
  8367. case S_ATTR_NOQUOT_VALUE:
  8368. var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
  8369. errorHandler.warning('attribute "' + value + '" missed quot(")!!');
  8370. el.add(attrName, value, start);
  8371. case S_ATTR_END:
  8372. s = S_TAG_SPACE;
  8373. break;
  8374. //case S_TAG_SPACE:
  8375. //case S_EQ:
  8376. //case S_ATTR_SPACE:
  8377. // void();break;
  8378. //case S_TAG_CLOSE:
  8379. //ignore warning
  8380. }
  8381. } else {
  8382. //not space
  8383. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  8384. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  8385. switch (s) {
  8386. //case S_TAG:void();break;
  8387. //case S_ATTR:void();break;
  8388. //case S_ATTR_NOQUOT_VALUE:void();break;
  8389. case S_ATTR_SPACE:
  8390. var tagName = el.tagName;
  8391. if (currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
  8392. errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
  8393. }
  8394. el.add(attrName, attrName, start);
  8395. start = p;
  8396. s = S_ATTR;
  8397. break;
  8398. case S_ATTR_END:
  8399. errorHandler.warning('attribute space is required"' + attrName + '"!!');
  8400. case S_TAG_SPACE:
  8401. s = S_ATTR;
  8402. start = p;
  8403. break;
  8404. case S_EQ:
  8405. s = S_ATTR_NOQUOT_VALUE;
  8406. start = p;
  8407. break;
  8408. case S_TAG_CLOSE:
  8409. throw new Error("elements closed character '/' and '>' must be connected to");
  8410. }
  8411. }
  8412. } //end outer switch
  8413. //console.log('p++',p)
  8414. p++;
  8415. }
  8416. }
  8417. /**
  8418. * @return true if has new namespace define
  8419. */
  8420. function appendElement(el, domBuilder, currentNSMap) {
  8421. var tagName = el.tagName;
  8422. var localNSMap = null; //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  8423. var i = el.length;
  8424. while (i--) {
  8425. var a = el[i];
  8426. var qName = a.qName;
  8427. var value = a.value;
  8428. var nsp = qName.indexOf(':');
  8429. if (nsp > 0) {
  8430. var prefix = a.prefix = qName.slice(0, nsp);
  8431. var localName = qName.slice(nsp + 1);
  8432. var nsPrefix = prefix === 'xmlns' && localName;
  8433. } else {
  8434. localName = qName;
  8435. prefix = null;
  8436. nsPrefix = qName === 'xmlns' && '';
  8437. } //can not set prefix,because prefix !== ''
  8438. a.localName = localName; //prefix == null for no ns prefix attribute
  8439. if (nsPrefix !== false) {
  8440. //hack!!
  8441. if (localNSMap == null) {
  8442. localNSMap = {}; //console.log(currentNSMap,0)
  8443. _copy(currentNSMap, currentNSMap = {}); //console.log(currentNSMap,1)
  8444. }
  8445. currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
  8446. a.uri = 'http://www.w3.org/2000/xmlns/';
  8447. domBuilder.startPrefixMapping(nsPrefix, value);
  8448. }
  8449. }
  8450. var i = el.length;
  8451. while (i--) {
  8452. a = el[i];
  8453. var prefix = a.prefix;
  8454. if (prefix) {
  8455. //no prefix attribute has no namespace
  8456. if (prefix === 'xml') {
  8457. a.uri = 'http://www.w3.org/XML/1998/namespace';
  8458. }
  8459. if (prefix !== 'xmlns') {
  8460. a.uri = currentNSMap[prefix || '']; //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
  8461. }
  8462. }
  8463. }
  8464. var nsp = tagName.indexOf(':');
  8465. if (nsp > 0) {
  8466. prefix = el.prefix = tagName.slice(0, nsp);
  8467. localName = el.localName = tagName.slice(nsp + 1);
  8468. } else {
  8469. prefix = null; //important!!
  8470. localName = el.localName = tagName;
  8471. } //no prefix element has default namespace
  8472. var ns = el.uri = currentNSMap[prefix || ''];
  8473. domBuilder.startElement(ns, localName, tagName, el); //endPrefixMapping and startPrefixMapping have not any help for dom builder
  8474. //localNSMap = null
  8475. if (el.closed) {
  8476. domBuilder.endElement(ns, localName, tagName);
  8477. if (localNSMap) {
  8478. for (prefix in localNSMap) {
  8479. domBuilder.endPrefixMapping(prefix);
  8480. }
  8481. }
  8482. } else {
  8483. el.currentNSMap = currentNSMap;
  8484. el.localNSMap = localNSMap; //parseStack.push(el);
  8485. return true;
  8486. }
  8487. }
  8488. function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
  8489. if (/^(?:script|textarea)$/i.test(tagName)) {
  8490. var elEndStart = source.indexOf('</' + tagName + '>', elStartEnd);
  8491. var text = source.substring(elStartEnd + 1, elEndStart);
  8492. if (/[&<]/.test(text)) {
  8493. if (/^script$/i.test(tagName)) {
  8494. //if(!/\]\]>/.test(text)){
  8495. //lexHandler.startCDATA();
  8496. domBuilder.characters(text, 0, text.length); //lexHandler.endCDATA();
  8497. return elEndStart; //}
  8498. } //}else{//text area
  8499. text = text.replace(/&#?\w+;/g, entityReplacer);
  8500. domBuilder.characters(text, 0, text.length);
  8501. return elEndStart; //}
  8502. }
  8503. }
  8504. return elStartEnd + 1;
  8505. }
  8506. function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
  8507. //if(tagName in closeMap){
  8508. var pos = closeMap[tagName];
  8509. if (pos == null) {
  8510. //console.log(tagName)
  8511. pos = source.lastIndexOf('</' + tagName + '>');
  8512. if (pos < elStartEnd) {
  8513. //忘记闭合
  8514. pos = source.lastIndexOf('</' + tagName);
  8515. }
  8516. closeMap[tagName] = pos;
  8517. }
  8518. return pos < elStartEnd; //}
  8519. }
  8520. function _copy(source, target) {
  8521. for (var n in source) {
  8522. target[n] = source[n];
  8523. }
  8524. }
  8525. function parseDCC(source, start, domBuilder, errorHandler) {
  8526. //sure start with '<!'
  8527. var next = source.charAt(start + 2);
  8528. switch (next) {
  8529. case '-':
  8530. if (source.charAt(start + 3) === '-') {
  8531. var end = source.indexOf('-->', start + 4); //append comment source.substring(4,end)//<!--
  8532. if (end > start) {
  8533. domBuilder.comment(source, start + 4, end - start - 4);
  8534. return end + 3;
  8535. } else {
  8536. errorHandler.error("Unclosed comment");
  8537. return -1;
  8538. }
  8539. } else {
  8540. //error
  8541. return -1;
  8542. }
  8543. default:
  8544. if (source.substr(start + 3, 6) == 'CDATA[') {
  8545. var end = source.indexOf(']]>', start + 9);
  8546. domBuilder.startCDATA();
  8547. domBuilder.characters(source, start + 9, end - start - 9);
  8548. domBuilder.endCDATA();
  8549. return end + 3;
  8550. } //<!DOCTYPE
  8551. //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
  8552. var matchs = split(source, start);
  8553. var len = matchs.length;
  8554. if (len > 1 && /!doctype/i.test(matchs[0][0])) {
  8555. var name = matchs[1][0];
  8556. var pubid = len > 3 && /^public$/i.test(matchs[2][0]) && matchs[3][0];
  8557. var sysid = len > 4 && matchs[4][0];
  8558. var lastMatch = matchs[len - 1];
  8559. domBuilder.startDTD(name, pubid && pubid.replace(/^(['"])(.*?)\1$/, '$2'), sysid && sysid.replace(/^(['"])(.*?)\1$/, '$2'));
  8560. domBuilder.endDTD();
  8561. return lastMatch.index + lastMatch[0].length;
  8562. }
  8563. }
  8564. return -1;
  8565. }
  8566. function parseInstruction(source, start, domBuilder) {
  8567. var end = source.indexOf('?>', start);
  8568. if (end) {
  8569. var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
  8570. if (match) {
  8571. var len = match[0].length;
  8572. domBuilder.processingInstruction(match[1], match[2]);
  8573. return end + 2;
  8574. } else {
  8575. //error
  8576. return -1;
  8577. }
  8578. }
  8579. return -1;
  8580. }
  8581. /**
  8582. * @param source
  8583. */
  8584. function ElementAttributes(source) {}
  8585. ElementAttributes.prototype = {
  8586. setTagName: function setTagName(tagName) {
  8587. if (!tagNamePattern.test(tagName)) {
  8588. throw new Error('invalid tagName:' + tagName);
  8589. }
  8590. this.tagName = tagName;
  8591. },
  8592. add: function add(qName, value, offset) {
  8593. if (!tagNamePattern.test(qName)) {
  8594. throw new Error('invalid attribute:' + qName);
  8595. }
  8596. this[this.length++] = {
  8597. qName: qName,
  8598. value: value,
  8599. offset: offset
  8600. };
  8601. },
  8602. length: 0,
  8603. getLocalName: function getLocalName(i) {
  8604. return this[i].localName;
  8605. },
  8606. getLocator: function getLocator(i) {
  8607. return this[i].locator;
  8608. },
  8609. getQName: function getQName(i) {
  8610. return this[i].qName;
  8611. },
  8612. getURI: function getURI(i) {
  8613. return this[i].uri;
  8614. },
  8615. getValue: function getValue(i) {
  8616. return this[i].value;
  8617. } // ,getIndex:function(uri, localName)){
  8618. // if(localName){
  8619. //
  8620. // }else{
  8621. // var qName = uri
  8622. // }
  8623. // },
  8624. // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
  8625. // getType:function(uri,localName){}
  8626. // getType:function(i){},
  8627. };
  8628. function split(source, start) {
  8629. var match;
  8630. var buf = [];
  8631. var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
  8632. reg.lastIndex = start;
  8633. reg.exec(source); //skip <
  8634. while (match = reg.exec(source)) {
  8635. buf.push(match);
  8636. if (match[1]) return buf;
  8637. }
  8638. }
  8639. exports.XMLReader = XMLReader;
  8640. },{}]},{},[4]);