workerMain.js 485 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498
  1. /*!-----------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.20.0(6363745c0a33c27b149b89342a7b96d354fb554c)
  4. * Released under the MIT license
  5. * https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
  6. *-----------------------------------------------------------*/
  7. (function() {
  8. var __m = ["require","exports","vs/editor/common/core/position","vs/base/common/errors","vs/base/common/platform","vs/editor/common/core/range","vs/base/common/diff/diff","vs/base/common/iterator","vs/base/common/lifecycle","vs/base/common/event","vs/base/common/types","vs/base/common/uint","vs/base/common/uri","vs/base/common/arrays","vs/base/common/diff/diffChange","vs/base/common/functional","vs/base/common/hash","vs/base/common/keyCodes","vs/base/common/linkedList","vs/base/common/cancellation","vs/base/common/strings","vs/editor/common/core/characterClassifier","vs/editor/common/core/selection","vs/editor/common/core/token","vs/editor/common/diff/diffComputer","vs/editor/common/model/wordHelper","vs/editor/common/modes/linkComputer","vs/editor/common/modes/supports/inplaceReplaceSupport","vs/editor/common/standalone/standaloneEnums","vs/editor/common/standalone/standaloneBase","vs/editor/common/viewModel/prefixSumComputer","vs/editor/common/model/mirrorTextModel","vs/base/common/worker/simpleWorker","vs/editor/common/standalone/promise-polyfill/polyfill","vs/editor/common/services/editorSimpleWorker"];
  9. var __M = function(deps) {
  10. var result = [];
  11. for (var i = 0, len = deps.length; i < len; i++) {
  12. result[i] = __m[deps[i]];
  13. }
  14. return result;
  15. };
  16. /*---------------------------------------------------------------------------------------------
  17. * Copyright (c) Microsoft Corporation. All rights reserved.
  18. * Licensed under the MIT License. See License.txt in the project root for license information.
  19. *--------------------------------------------------------------------------------------------*/
  20. 'use strict';
  21. /*---------------------------------------------------------------------------------------------
  22. * Copyright (c) Microsoft Corporation. All rights reserved.
  23. * Licensed under the MIT License. See License.txt in the project root for license information.
  24. *--------------------------------------------------------------------------------------------*/
  25. /*---------------------------------------------------------------------------------------------
  26. *---------------------------------------------------------------------------------------------
  27. *---------------------------------------------------------------------------------------------
  28. *---------------------------------------------------------------------------------------------
  29. *---------------------------------------------------------------------------------------------
  30. * Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
  31. *---------------------------------------------------------------------------------------------
  32. *---------------------------------------------------------------------------------------------
  33. *---------------------------------------------------------------------------------------------
  34. *---------------------------------------------------------------------------------------------
  35. *--------------------------------------------------------------------------------------------*/
  36. var _amdLoaderGlobal = this;
  37. var _commonjsGlobal = typeof global === 'object' ? global : {};
  38. var AMDLoader;
  39. (function (AMDLoader) {
  40. AMDLoader.global = _amdLoaderGlobal;
  41. var Environment = /** @class */ (function () {
  42. function Environment() {
  43. this._detected = false;
  44. this._isWindows = false;
  45. this._isNode = false;
  46. this._isElectronRenderer = false;
  47. this._isWebWorker = false;
  48. }
  49. Object.defineProperty(Environment.prototype, "isWindows", {
  50. get: function () {
  51. this._detect();
  52. return this._isWindows;
  53. },
  54. enumerable: true,
  55. configurable: true
  56. });
  57. Object.defineProperty(Environment.prototype, "isNode", {
  58. get: function () {
  59. this._detect();
  60. return this._isNode;
  61. },
  62. enumerable: true,
  63. configurable: true
  64. });
  65. Object.defineProperty(Environment.prototype, "isElectronRenderer", {
  66. get: function () {
  67. this._detect();
  68. return this._isElectronRenderer;
  69. },
  70. enumerable: true,
  71. configurable: true
  72. });
  73. Object.defineProperty(Environment.prototype, "isWebWorker", {
  74. get: function () {
  75. this._detect();
  76. return this._isWebWorker;
  77. },
  78. enumerable: true,
  79. configurable: true
  80. });
  81. Environment.prototype._detect = function () {
  82. if (this._detected) {
  83. return;
  84. }
  85. this._detected = true;
  86. this._isWindows = Environment._isWindows();
  87. this._isNode = (typeof module !== 'undefined' && !!module.exports);
  88. this._isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
  89. this._isWebWorker = (typeof AMDLoader.global.importScripts === 'function');
  90. };
  91. Environment._isWindows = function () {
  92. if (typeof navigator !== 'undefined') {
  93. if (navigator.userAgent && navigator.userAgent.indexOf('Windows') >= 0) {
  94. return true;
  95. }
  96. }
  97. if (typeof process !== 'undefined') {
  98. return (process.platform === 'win32');
  99. }
  100. return false;
  101. };
  102. return Environment;
  103. }());
  104. AMDLoader.Environment = Environment;
  105. })(AMDLoader || (AMDLoader = {}));
  106. /*---------------------------------------------------------------------------------------------
  107. * Copyright (c) Microsoft Corporation. All rights reserved.
  108. * Licensed under the MIT License. See License.txt in the project root for license information.
  109. *--------------------------------------------------------------------------------------------*/
  110. var AMDLoader;
  111. (function (AMDLoader) {
  112. var LoaderEvent = /** @class */ (function () {
  113. function LoaderEvent(type, detail, timestamp) {
  114. this.type = type;
  115. this.detail = detail;
  116. this.timestamp = timestamp;
  117. }
  118. return LoaderEvent;
  119. }());
  120. AMDLoader.LoaderEvent = LoaderEvent;
  121. var LoaderEventRecorder = /** @class */ (function () {
  122. function LoaderEventRecorder(loaderAvailableTimestamp) {
  123. this._events = [new LoaderEvent(1 /* LoaderAvailable */, '', loaderAvailableTimestamp)];
  124. }
  125. LoaderEventRecorder.prototype.record = function (type, detail) {
  126. this._events.push(new LoaderEvent(type, detail, AMDLoader.Utilities.getHighPerformanceTimestamp()));
  127. };
  128. LoaderEventRecorder.prototype.getEvents = function () {
  129. return this._events;
  130. };
  131. return LoaderEventRecorder;
  132. }());
  133. AMDLoader.LoaderEventRecorder = LoaderEventRecorder;
  134. var NullLoaderEventRecorder = /** @class */ (function () {
  135. function NullLoaderEventRecorder() {
  136. }
  137. NullLoaderEventRecorder.prototype.record = function (type, detail) {
  138. // Nothing to do
  139. };
  140. NullLoaderEventRecorder.prototype.getEvents = function () {
  141. return [];
  142. };
  143. NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();
  144. return NullLoaderEventRecorder;
  145. }());
  146. AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder;
  147. })(AMDLoader || (AMDLoader = {}));
  148. /*---------------------------------------------------------------------------------------------
  149. * Copyright (c) Microsoft Corporation. All rights reserved.
  150. * Licensed under the MIT License. See License.txt in the project root for license information.
  151. *--------------------------------------------------------------------------------------------*/
  152. var AMDLoader;
  153. (function (AMDLoader) {
  154. var Utilities = /** @class */ (function () {
  155. function Utilities() {
  156. }
  157. /**
  158. * This method does not take care of / vs \
  159. */
  160. Utilities.fileUriToFilePath = function (isWindows, uri) {
  161. uri = decodeURI(uri).replace(/%23/g, '#');
  162. if (isWindows) {
  163. if (/^file:\/\/\//.test(uri)) {
  164. // This is a URI without a hostname => return only the path segment
  165. return uri.substr(8);
  166. }
  167. if (/^file:\/\//.test(uri)) {
  168. return uri.substr(5);
  169. }
  170. }
  171. else {
  172. if (/^file:\/\//.test(uri)) {
  173. return uri.substr(7);
  174. }
  175. }
  176. // Not sure...
  177. return uri;
  178. };
  179. Utilities.startsWith = function (haystack, needle) {
  180. return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;
  181. };
  182. Utilities.endsWith = function (haystack, needle) {
  183. return haystack.length >= needle.length && haystack.substr(haystack.length - needle.length) === needle;
  184. };
  185. // only check for "?" before "#" to ensure that there is a real Query-String
  186. Utilities.containsQueryString = function (url) {
  187. return /^[^\#]*\?/gi.test(url);
  188. };
  189. /**
  190. * Does `url` start with http:// or https:// or file:// or / ?
  191. */
  192. Utilities.isAbsolutePath = function (url) {
  193. return /^((http:\/\/)|(https:\/\/)|(file:\/\/)|(\/))/.test(url);
  194. };
  195. Utilities.forEachProperty = function (obj, callback) {
  196. if (obj) {
  197. var key = void 0;
  198. for (key in obj) {
  199. if (obj.hasOwnProperty(key)) {
  200. callback(key, obj[key]);
  201. }
  202. }
  203. }
  204. };
  205. Utilities.isEmpty = function (obj) {
  206. var isEmpty = true;
  207. Utilities.forEachProperty(obj, function () {
  208. isEmpty = false;
  209. });
  210. return isEmpty;
  211. };
  212. Utilities.recursiveClone = function (obj) {
  213. if (!obj || typeof obj !== 'object') {
  214. return obj;
  215. }
  216. var result = Array.isArray(obj) ? [] : {};
  217. Utilities.forEachProperty(obj, function (key, value) {
  218. if (value && typeof value === 'object') {
  219. result[key] = Utilities.recursiveClone(value);
  220. }
  221. else {
  222. result[key] = value;
  223. }
  224. });
  225. return result;
  226. };
  227. Utilities.generateAnonymousModule = function () {
  228. return '===anonymous' + (Utilities.NEXT_ANONYMOUS_ID++) + '===';
  229. };
  230. Utilities.isAnonymousModule = function (id) {
  231. return Utilities.startsWith(id, '===anonymous');
  232. };
  233. Utilities.getHighPerformanceTimestamp = function () {
  234. if (!this.PERFORMANCE_NOW_PROBED) {
  235. this.PERFORMANCE_NOW_PROBED = true;
  236. this.HAS_PERFORMANCE_NOW = (AMDLoader.global.performance && typeof AMDLoader.global.performance.now === 'function');
  237. }
  238. return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now());
  239. };
  240. Utilities.NEXT_ANONYMOUS_ID = 1;
  241. Utilities.PERFORMANCE_NOW_PROBED = false;
  242. Utilities.HAS_PERFORMANCE_NOW = false;
  243. return Utilities;
  244. }());
  245. AMDLoader.Utilities = Utilities;
  246. })(AMDLoader || (AMDLoader = {}));
  247. /*---------------------------------------------------------------------------------------------
  248. * Copyright (c) Microsoft Corporation. All rights reserved.
  249. * Licensed under the MIT License. See License.txt in the project root for license information.
  250. *--------------------------------------------------------------------------------------------*/
  251. var AMDLoader;
  252. (function (AMDLoader) {
  253. function ensureError(err) {
  254. if (err instanceof Error) {
  255. return err;
  256. }
  257. var result = new Error(err.message || String(err) || 'Unknown Error');
  258. if (err.stack) {
  259. result.stack = err.stack;
  260. }
  261. return result;
  262. }
  263. AMDLoader.ensureError = ensureError;
  264. ;
  265. var ConfigurationOptionsUtil = /** @class */ (function () {
  266. function ConfigurationOptionsUtil() {
  267. }
  268. /**
  269. * Ensure configuration options make sense
  270. */
  271. ConfigurationOptionsUtil.validateConfigurationOptions = function (options) {
  272. function defaultOnError(err) {
  273. if (err.phase === 'loading') {
  274. console.error('Loading "' + err.moduleId + '" failed');
  275. console.error(err);
  276. console.error('Here are the modules that depend on it:');
  277. console.error(err.neededBy);
  278. return;
  279. }
  280. if (err.phase === 'factory') {
  281. console.error('The factory method of "' + err.moduleId + '" has thrown an exception');
  282. console.error(err);
  283. return;
  284. }
  285. }
  286. options = options || {};
  287. if (typeof options.baseUrl !== 'string') {
  288. options.baseUrl = '';
  289. }
  290. if (typeof options.isBuild !== 'boolean') {
  291. options.isBuild = false;
  292. }
  293. if (typeof options.paths !== 'object') {
  294. options.paths = {};
  295. }
  296. if (typeof options.config !== 'object') {
  297. options.config = {};
  298. }
  299. if (typeof options.catchError === 'undefined') {
  300. options.catchError = false;
  301. }
  302. if (typeof options.recordStats === 'undefined') {
  303. options.recordStats = false;
  304. }
  305. if (typeof options.urlArgs !== 'string') {
  306. options.urlArgs = '';
  307. }
  308. if (typeof options.onError !== 'function') {
  309. options.onError = defaultOnError;
  310. }
  311. if (!Array.isArray(options.ignoreDuplicateModules)) {
  312. options.ignoreDuplicateModules = [];
  313. }
  314. if (options.baseUrl.length > 0) {
  315. if (!AMDLoader.Utilities.endsWith(options.baseUrl, '/')) {
  316. options.baseUrl += '/';
  317. }
  318. }
  319. if (typeof options.cspNonce !== 'string') {
  320. options.cspNonce = '';
  321. }
  322. if (!Array.isArray(options.nodeModules)) {
  323. options.nodeModules = [];
  324. }
  325. if (options.nodeCachedData && typeof options.nodeCachedData === 'object') {
  326. if (typeof options.nodeCachedData.seed !== 'string') {
  327. options.nodeCachedData.seed = 'seed';
  328. }
  329. if (typeof options.nodeCachedData.writeDelay !== 'number' || options.nodeCachedData.writeDelay < 0) {
  330. options.nodeCachedData.writeDelay = 1000 * 7;
  331. }
  332. if (!options.nodeCachedData.path || typeof options.nodeCachedData.path !== 'string') {
  333. var err = ensureError(new Error('INVALID cached data configuration, \'path\' MUST be set'));
  334. err.phase = 'configuration';
  335. options.onError(err);
  336. options.nodeCachedData = undefined;
  337. }
  338. }
  339. return options;
  340. };
  341. ConfigurationOptionsUtil.mergeConfigurationOptions = function (overwrite, base) {
  342. if (overwrite === void 0) { overwrite = null; }
  343. if (base === void 0) { base = null; }
  344. var result = AMDLoader.Utilities.recursiveClone(base || {});
  345. // Merge known properties and overwrite the unknown ones
  346. AMDLoader.Utilities.forEachProperty(overwrite, function (key, value) {
  347. if (key === 'ignoreDuplicateModules' && typeof result.ignoreDuplicateModules !== 'undefined') {
  348. result.ignoreDuplicateModules = result.ignoreDuplicateModules.concat(value);
  349. }
  350. else if (key === 'paths' && typeof result.paths !== 'undefined') {
  351. AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.paths[key2] = value2; });
  352. }
  353. else if (key === 'config' && typeof result.config !== 'undefined') {
  354. AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.config[key2] = value2; });
  355. }
  356. else {
  357. result[key] = AMDLoader.Utilities.recursiveClone(value);
  358. }
  359. });
  360. return ConfigurationOptionsUtil.validateConfigurationOptions(result);
  361. };
  362. return ConfigurationOptionsUtil;
  363. }());
  364. AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil;
  365. var Configuration = /** @class */ (function () {
  366. function Configuration(env, options) {
  367. this._env = env;
  368. this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);
  369. this._createIgnoreDuplicateModulesMap();
  370. this._createNodeModulesMap();
  371. this._createSortedPathsRules();
  372. if (this.options.baseUrl === '') {
  373. if (this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename && this._env.isNode) {
  374. var nodeMain = this.options.nodeRequire.main.filename;
  375. var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
  376. this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
  377. }
  378. if (this.options.nodeMain && this._env.isNode) {
  379. var nodeMain = this.options.nodeMain;
  380. var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
  381. this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
  382. }
  383. }
  384. }
  385. Configuration.prototype._createIgnoreDuplicateModulesMap = function () {
  386. // Build a map out of the ignoreDuplicateModules array
  387. this.ignoreDuplicateModulesMap = {};
  388. for (var i = 0; i < this.options.ignoreDuplicateModules.length; i++) {
  389. this.ignoreDuplicateModulesMap[this.options.ignoreDuplicateModules[i]] = true;
  390. }
  391. };
  392. Configuration.prototype._createNodeModulesMap = function () {
  393. // Build a map out of nodeModules array
  394. this.nodeModulesMap = Object.create(null);
  395. for (var _i = 0, _a = this.options.nodeModules; _i < _a.length; _i++) {
  396. var nodeModule = _a[_i];
  397. this.nodeModulesMap[nodeModule] = true;
  398. }
  399. };
  400. Configuration.prototype._createSortedPathsRules = function () {
  401. var _this = this;
  402. // Create an array our of the paths rules, sorted descending by length to
  403. // result in a more specific -> less specific order
  404. this.sortedPathsRules = [];
  405. AMDLoader.Utilities.forEachProperty(this.options.paths, function (from, to) {
  406. if (!Array.isArray(to)) {
  407. _this.sortedPathsRules.push({
  408. from: from,
  409. to: [to]
  410. });
  411. }
  412. else {
  413. _this.sortedPathsRules.push({
  414. from: from,
  415. to: to
  416. });
  417. }
  418. });
  419. this.sortedPathsRules.sort(function (a, b) {
  420. return b.from.length - a.from.length;
  421. });
  422. };
  423. /**
  424. * Clone current configuration and overwrite options selectively.
  425. * @param options The selective options to overwrite with.
  426. * @result A new configuration
  427. */
  428. Configuration.prototype.cloneAndMerge = function (options) {
  429. return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(options, this.options));
  430. };
  431. /**
  432. * Get current options bag. Useful for passing it forward to plugins.
  433. */
  434. Configuration.prototype.getOptionsLiteral = function () {
  435. return this.options;
  436. };
  437. Configuration.prototype._applyPaths = function (moduleId) {
  438. var pathRule;
  439. for (var i = 0, len = this.sortedPathsRules.length; i < len; i++) {
  440. pathRule = this.sortedPathsRules[i];
  441. if (AMDLoader.Utilities.startsWith(moduleId, pathRule.from)) {
  442. var result = [];
  443. for (var j = 0, lenJ = pathRule.to.length; j < lenJ; j++) {
  444. result.push(pathRule.to[j] + moduleId.substr(pathRule.from.length));
  445. }
  446. return result;
  447. }
  448. }
  449. return [moduleId];
  450. };
  451. Configuration.prototype._addUrlArgsToUrl = function (url) {
  452. if (AMDLoader.Utilities.containsQueryString(url)) {
  453. return url + '&' + this.options.urlArgs;
  454. }
  455. else {
  456. return url + '?' + this.options.urlArgs;
  457. }
  458. };
  459. Configuration.prototype._addUrlArgsIfNecessaryToUrl = function (url) {
  460. if (this.options.urlArgs) {
  461. return this._addUrlArgsToUrl(url);
  462. }
  463. return url;
  464. };
  465. Configuration.prototype._addUrlArgsIfNecessaryToUrls = function (urls) {
  466. if (this.options.urlArgs) {
  467. for (var i = 0, len = urls.length; i < len; i++) {
  468. urls[i] = this._addUrlArgsToUrl(urls[i]);
  469. }
  470. }
  471. return urls;
  472. };
  473. /**
  474. * Transform a module id to a location. Appends .js to module ids
  475. */
  476. Configuration.prototype.moduleIdToPaths = function (moduleId) {
  477. if (this.nodeModulesMap[moduleId] === true) {
  478. // This is a node module...
  479. if (this.isBuild()) {
  480. // ...and we are at build time, drop it
  481. return ['empty:'];
  482. }
  483. else {
  484. // ...and at runtime we create a `shortcut`-path
  485. return ['node|' + moduleId];
  486. }
  487. }
  488. var result = moduleId;
  489. var results;
  490. if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.isAbsolutePath(result)) {
  491. results = this._applyPaths(result);
  492. for (var i = 0, len = results.length; i < len; i++) {
  493. if (this.isBuild() && results[i] === 'empty:') {
  494. continue;
  495. }
  496. if (!AMDLoader.Utilities.isAbsolutePath(results[i])) {
  497. results[i] = this.options.baseUrl + results[i];
  498. }
  499. if (!AMDLoader.Utilities.endsWith(results[i], '.js') && !AMDLoader.Utilities.containsQueryString(results[i])) {
  500. results[i] = results[i] + '.js';
  501. }
  502. }
  503. }
  504. else {
  505. if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.containsQueryString(result)) {
  506. result = result + '.js';
  507. }
  508. results = [result];
  509. }
  510. return this._addUrlArgsIfNecessaryToUrls(results);
  511. };
  512. /**
  513. * Transform a module id or url to a location.
  514. */
  515. Configuration.prototype.requireToUrl = function (url) {
  516. var result = url;
  517. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  518. result = this._applyPaths(result)[0];
  519. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  520. result = this.options.baseUrl + result;
  521. }
  522. }
  523. return this._addUrlArgsIfNecessaryToUrl(result);
  524. };
  525. /**
  526. * Flag to indicate if current execution is as part of a build.
  527. */
  528. Configuration.prototype.isBuild = function () {
  529. return this.options.isBuild;
  530. };
  531. /**
  532. * Test if module `moduleId` is expected to be defined multiple times
  533. */
  534. Configuration.prototype.isDuplicateMessageIgnoredFor = function (moduleId) {
  535. return this.ignoreDuplicateModulesMap.hasOwnProperty(moduleId);
  536. };
  537. /**
  538. * Get the configuration settings for the provided module id
  539. */
  540. Configuration.prototype.getConfigForModule = function (moduleId) {
  541. if (this.options.config) {
  542. return this.options.config[moduleId];
  543. }
  544. };
  545. /**
  546. * Should errors be caught when executing module factories?
  547. */
  548. Configuration.prototype.shouldCatchError = function () {
  549. return this.options.catchError;
  550. };
  551. /**
  552. * Should statistics be recorded?
  553. */
  554. Configuration.prototype.shouldRecordStats = function () {
  555. return this.options.recordStats;
  556. };
  557. /**
  558. * Forward an error to the error handler.
  559. */
  560. Configuration.prototype.onError = function (err) {
  561. this.options.onError(err);
  562. };
  563. return Configuration;
  564. }());
  565. AMDLoader.Configuration = Configuration;
  566. })(AMDLoader || (AMDLoader = {}));
  567. /*---------------------------------------------------------------------------------------------
  568. * Copyright (c) Microsoft Corporation. All rights reserved.
  569. * Licensed under the MIT License. See License.txt in the project root for license information.
  570. *--------------------------------------------------------------------------------------------*/
  571. var AMDLoader;
  572. (function (AMDLoader) {
  573. /**
  574. * Load `scriptSrc` only once (avoid multiple <script> tags)
  575. */
  576. var OnlyOnceScriptLoader = /** @class */ (function () {
  577. function OnlyOnceScriptLoader(env) {
  578. this._env = env;
  579. this._scriptLoader = null;
  580. this._callbackMap = {};
  581. }
  582. OnlyOnceScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  583. var _this = this;
  584. if (!this._scriptLoader) {
  585. this._scriptLoader = (this._env.isWebWorker
  586. ? new WorkerScriptLoader()
  587. : this._env.isNode
  588. ? new NodeScriptLoader(this._env)
  589. : new BrowserScriptLoader());
  590. }
  591. var scriptCallbacks = {
  592. callback: callback,
  593. errorback: errorback
  594. };
  595. if (this._callbackMap.hasOwnProperty(scriptSrc)) {
  596. this._callbackMap[scriptSrc].push(scriptCallbacks);
  597. return;
  598. }
  599. this._callbackMap[scriptSrc] = [scriptCallbacks];
  600. this._scriptLoader.load(moduleManager, scriptSrc, function () { return _this.triggerCallback(scriptSrc); }, function (err) { return _this.triggerErrorback(scriptSrc, err); });
  601. };
  602. OnlyOnceScriptLoader.prototype.triggerCallback = function (scriptSrc) {
  603. var scriptCallbacks = this._callbackMap[scriptSrc];
  604. delete this._callbackMap[scriptSrc];
  605. for (var i = 0; i < scriptCallbacks.length; i++) {
  606. scriptCallbacks[i].callback();
  607. }
  608. };
  609. OnlyOnceScriptLoader.prototype.triggerErrorback = function (scriptSrc, err) {
  610. var scriptCallbacks = this._callbackMap[scriptSrc];
  611. delete this._callbackMap[scriptSrc];
  612. for (var i = 0; i < scriptCallbacks.length; i++) {
  613. scriptCallbacks[i].errorback(err);
  614. }
  615. };
  616. return OnlyOnceScriptLoader;
  617. }());
  618. var BrowserScriptLoader = /** @class */ (function () {
  619. function BrowserScriptLoader() {
  620. }
  621. /**
  622. * Attach load / error listeners to a script element and remove them when either one has fired.
  623. * Implemented for browssers supporting HTML5 standard 'load' and 'error' events.
  624. */
  625. BrowserScriptLoader.prototype.attachListeners = function (script, callback, errorback) {
  626. var unbind = function () {
  627. script.removeEventListener('load', loadEventListener);
  628. script.removeEventListener('error', errorEventListener);
  629. };
  630. var loadEventListener = function (e) {
  631. unbind();
  632. callback();
  633. };
  634. var errorEventListener = function (e) {
  635. unbind();
  636. errorback(e);
  637. };
  638. script.addEventListener('load', loadEventListener);
  639. script.addEventListener('error', errorEventListener);
  640. };
  641. BrowserScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  642. var script = document.createElement('script');
  643. script.setAttribute('async', 'async');
  644. script.setAttribute('type', 'text/javascript');
  645. this.attachListeners(script, callback, errorback);
  646. script.setAttribute('src', scriptSrc);
  647. // Propagate CSP nonce to dynamically created script tag.
  648. var cspNonce = moduleManager.getConfig().getOptionsLiteral().cspNonce;
  649. if (cspNonce) {
  650. script.setAttribute('nonce', cspNonce);
  651. }
  652. document.getElementsByTagName('head')[0].appendChild(script);
  653. };
  654. return BrowserScriptLoader;
  655. }());
  656. var WorkerScriptLoader = /** @class */ (function () {
  657. function WorkerScriptLoader() {
  658. }
  659. WorkerScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  660. try {
  661. importScripts(scriptSrc);
  662. callback();
  663. }
  664. catch (e) {
  665. errorback(e);
  666. }
  667. };
  668. return WorkerScriptLoader;
  669. }());
  670. var NodeScriptLoader = /** @class */ (function () {
  671. function NodeScriptLoader(env) {
  672. this._env = env;
  673. this._didInitialize = false;
  674. this._didPatchNodeRequire = false;
  675. }
  676. NodeScriptLoader.prototype._init = function (nodeRequire) {
  677. if (this._didInitialize) {
  678. return;
  679. }
  680. this._didInitialize = true;
  681. // capture node modules
  682. this._fs = nodeRequire('fs');
  683. this._vm = nodeRequire('vm');
  684. this._path = nodeRequire('path');
  685. this._crypto = nodeRequire('crypto');
  686. };
  687. // patch require-function of nodejs such that we can manually create a script
  688. // from cached data. this is done by overriding the `Module._compile` function
  689. NodeScriptLoader.prototype._initNodeRequire = function (nodeRequire, moduleManager) {
  690. // It is important to check for `nodeCachedData` first and then set `_didPatchNodeRequire`.
  691. // That's because `nodeCachedData` is set _after_ calling this for the first time...
  692. var nodeCachedData = moduleManager.getConfig().getOptionsLiteral().nodeCachedData;
  693. if (!nodeCachedData) {
  694. return;
  695. }
  696. if (this._didPatchNodeRequire) {
  697. return;
  698. }
  699. this._didPatchNodeRequire = true;
  700. var that = this;
  701. var Module = nodeRequire('module');
  702. function makeRequireFunction(mod) {
  703. var Module = mod.constructor;
  704. var require = function require(path) {
  705. try {
  706. return mod.require(path);
  707. }
  708. finally {
  709. // nothing
  710. }
  711. };
  712. require.resolve = function resolve(request) {
  713. return Module._resolveFilename(request, mod);
  714. };
  715. require.main = process.mainModule;
  716. require.extensions = Module._extensions;
  717. require.cache = Module._cache;
  718. return require;
  719. }
  720. Module.prototype._compile = function (content, filename) {
  721. // remove shebang and create wrapper function
  722. var scriptSource = Module.wrap(content.replace(/^#!.*/, ''));
  723. // create script
  724. var recorder = moduleManager.getRecorder();
  725. var cachedDataPath = that._getCachedDataPath(nodeCachedData, filename);
  726. var options = { filename: filename };
  727. var hashData;
  728. try {
  729. var data = that._fs.readFileSync(cachedDataPath);
  730. hashData = data.slice(0, 16);
  731. options.cachedData = data.slice(16);
  732. recorder.record(60 /* CachedDataFound */, cachedDataPath);
  733. }
  734. catch (_e) {
  735. recorder.record(61 /* CachedDataMissed */, cachedDataPath);
  736. }
  737. var script = new that._vm.Script(scriptSource, options);
  738. var compileWrapper = script.runInThisContext(options);
  739. // run script
  740. var dirname = that._path.dirname(filename);
  741. var require = makeRequireFunction(this);
  742. var args = [this.exports, require, this, filename, dirname, process, _commonjsGlobal, Buffer];
  743. var result = compileWrapper.apply(this.exports, args);
  744. // cached data aftermath
  745. that._handleCachedData(script, scriptSource, cachedDataPath, !options.cachedData, moduleManager);
  746. that._verifyCachedData(script, scriptSource, cachedDataPath, hashData, moduleManager);
  747. return result;
  748. };
  749. };
  750. NodeScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  751. var _this = this;
  752. var opts = moduleManager.getConfig().getOptionsLiteral();
  753. var nodeRequire = (opts.nodeRequire || AMDLoader.global.nodeRequire);
  754. var nodeInstrumenter = (opts.nodeInstrumenter || function (c) { return c; });
  755. this._init(nodeRequire);
  756. this._initNodeRequire(nodeRequire, moduleManager);
  757. var recorder = moduleManager.getRecorder();
  758. if (/^node\|/.test(scriptSrc)) {
  759. var pieces = scriptSrc.split('|');
  760. var moduleExports_1 = null;
  761. try {
  762. moduleExports_1 = nodeRequire(pieces[1]);
  763. }
  764. catch (err) {
  765. errorback(err);
  766. return;
  767. }
  768. moduleManager.enqueueDefineAnonymousModule([], function () { return moduleExports_1; });
  769. callback();
  770. }
  771. else {
  772. scriptSrc = AMDLoader.Utilities.fileUriToFilePath(this._env.isWindows, scriptSrc);
  773. var normalizedScriptSrc_1 = this._path.normalize(scriptSrc);
  774. var vmScriptPathOrUri_1 = this._getElectronRendererScriptPathOrUri(normalizedScriptSrc_1);
  775. var wantsCachedData_1 = Boolean(opts.nodeCachedData);
  776. var cachedDataPath_1 = wantsCachedData_1 ? this._getCachedDataPath(opts.nodeCachedData, scriptSrc) : undefined;
  777. this._readSourceAndCachedData(normalizedScriptSrc_1, cachedDataPath_1, recorder, function (err, data, cachedData, hashData) {
  778. if (err) {
  779. errorback(err);
  780. return;
  781. }
  782. var scriptSource;
  783. if (data.charCodeAt(0) === NodeScriptLoader._BOM) {
  784. scriptSource = NodeScriptLoader._PREFIX + data.substring(1) + NodeScriptLoader._SUFFIX;
  785. }
  786. else {
  787. scriptSource = NodeScriptLoader._PREFIX + data + NodeScriptLoader._SUFFIX;
  788. }
  789. scriptSource = nodeInstrumenter(scriptSource, normalizedScriptSrc_1);
  790. var scriptOpts = { filename: vmScriptPathOrUri_1, cachedData: cachedData };
  791. var script = _this._createAndEvalScript(moduleManager, scriptSource, scriptOpts, callback, errorback);
  792. _this._handleCachedData(script, scriptSource, cachedDataPath_1, wantsCachedData_1 && !cachedData, moduleManager);
  793. _this._verifyCachedData(script, scriptSource, cachedDataPath_1, hashData, moduleManager);
  794. });
  795. }
  796. };
  797. NodeScriptLoader.prototype._createAndEvalScript = function (moduleManager, contents, options, callback, errorback) {
  798. var recorder = moduleManager.getRecorder();
  799. recorder.record(31 /* NodeBeginEvaluatingScript */, options.filename);
  800. var script = new this._vm.Script(contents, options);
  801. var ret = script.runInThisContext(options);
  802. var globalDefineFunc = moduleManager.getGlobalAMDDefineFunc();
  803. var receivedDefineCall = false;
  804. var localDefineFunc = function () {
  805. receivedDefineCall = true;
  806. return globalDefineFunc.apply(null, arguments);
  807. };
  808. localDefineFunc.amd = globalDefineFunc.amd;
  809. ret.call(AMDLoader.global, moduleManager.getGlobalAMDRequireFunc(), localDefineFunc, options.filename, this._path.dirname(options.filename));
  810. recorder.record(32 /* NodeEndEvaluatingScript */, options.filename);
  811. if (receivedDefineCall) {
  812. callback();
  813. }
  814. else {
  815. errorback(new Error("Didn't receive define call in " + options.filename + "!"));
  816. }
  817. return script;
  818. };
  819. NodeScriptLoader.prototype._getElectronRendererScriptPathOrUri = function (path) {
  820. if (!this._env.isElectronRenderer) {
  821. return path;
  822. }
  823. var driveLetterMatch = path.match(/^([a-z])\:(.*)/i);
  824. if (driveLetterMatch) {
  825. // windows
  826. return "file:///" + (driveLetterMatch[1].toUpperCase() + ':' + driveLetterMatch[2]).replace(/\\/g, '/');
  827. }
  828. else {
  829. // nix
  830. return "file://" + path;
  831. }
  832. };
  833. NodeScriptLoader.prototype._getCachedDataPath = function (config, filename) {
  834. var hash = this._crypto.createHash('md5').update(filename, 'utf8').update(config.seed, 'utf8').digest('hex');
  835. var basename = this._path.basename(filename).replace(/\.js$/, '');
  836. return this._path.join(config.path, basename + "-" + hash + ".code");
  837. };
  838. NodeScriptLoader.prototype._handleCachedData = function (script, scriptSource, cachedDataPath, createCachedData, moduleManager) {
  839. var _this = this;
  840. if (script.cachedDataRejected) {
  841. // cached data got rejected -> delete and re-create
  842. this._fs.unlink(cachedDataPath, function (err) {
  843. moduleManager.getRecorder().record(62 /* CachedDataRejected */, cachedDataPath);
  844. _this._createAndWriteCachedData(script, scriptSource, cachedDataPath, moduleManager);
  845. if (err) {
  846. moduleManager.getConfig().onError(err);
  847. }
  848. });
  849. }
  850. else if (createCachedData) {
  851. // no cached data, but wanted
  852. this._createAndWriteCachedData(script, scriptSource, cachedDataPath, moduleManager);
  853. }
  854. };
  855. // Cached data format: | SOURCE_HASH | V8_CACHED_DATA |
  856. // -SOURCE_HASH is the md5 hash of the JS source (always 16 bytes)
  857. // -V8_CACHED_DATA is what v8 produces
  858. NodeScriptLoader.prototype._createAndWriteCachedData = function (script, scriptSource, cachedDataPath, moduleManager) {
  859. var _this = this;
  860. var timeout = Math.ceil(moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay * (1 + Math.random()));
  861. var lastSize = -1;
  862. var iteration = 0;
  863. var hashData = undefined;
  864. var createLoop = function () {
  865. setTimeout(function () {
  866. if (!hashData) {
  867. hashData = _this._crypto.createHash('md5').update(scriptSource, 'utf8').digest();
  868. }
  869. var cachedData = script.createCachedData();
  870. if (cachedData.length === 0 || cachedData.length === lastSize || iteration >= 5) {
  871. return;
  872. }
  873. lastSize = cachedData.length;
  874. _this._fs.writeFile(cachedDataPath, Buffer.concat([hashData, cachedData]), function (err) {
  875. if (err) {
  876. moduleManager.getConfig().onError(err);
  877. }
  878. moduleManager.getRecorder().record(63 /* CachedDataCreated */, cachedDataPath);
  879. createLoop();
  880. });
  881. }, timeout * (Math.pow(4, iteration++)));
  882. };
  883. // with some delay (`timeout`) create cached data
  884. // and repeat that (with backoff delay) until the
  885. // data seems to be not changing anymore
  886. createLoop();
  887. };
  888. NodeScriptLoader.prototype._readSourceAndCachedData = function (sourcePath, cachedDataPath, recorder, callback) {
  889. if (!cachedDataPath) {
  890. // no cached data case
  891. this._fs.readFile(sourcePath, { encoding: 'utf8' }, callback);
  892. }
  893. else {
  894. // cached data case: read both files in parallel
  895. var source_1 = undefined;
  896. var cachedData_1 = undefined;
  897. var hashData_1 = undefined;
  898. var steps_1 = 2;
  899. var step_1 = function (err) {
  900. if (err) {
  901. callback(err);
  902. }
  903. else if (--steps_1 === 0) {
  904. callback(undefined, source_1, cachedData_1, hashData_1);
  905. }
  906. };
  907. this._fs.readFile(sourcePath, { encoding: 'utf8' }, function (err, data) {
  908. source_1 = data;
  909. step_1(err);
  910. });
  911. this._fs.readFile(cachedDataPath, function (err, data) {
  912. if (!err && data && data.length > 0) {
  913. hashData_1 = data.slice(0, 16);
  914. cachedData_1 = data.slice(16);
  915. recorder.record(60 /* CachedDataFound */, cachedDataPath);
  916. }
  917. else {
  918. recorder.record(61 /* CachedDataMissed */, cachedDataPath);
  919. }
  920. step_1(); // ignored: cached data is optional
  921. });
  922. }
  923. };
  924. NodeScriptLoader.prototype._verifyCachedData = function (script, scriptSource, cachedDataPath, hashData, moduleManager) {
  925. var _this = this;
  926. if (!hashData) {
  927. // nothing to do
  928. return;
  929. }
  930. if (script.cachedDataRejected) {
  931. // invalid anyways
  932. return;
  933. }
  934. setTimeout(function () {
  935. // check source hash - the contract is that file paths change when file content
  936. // change (e.g use the commit or version id as cache path). this check is
  937. // for violations of this contract.
  938. var hashDataNow = _this._crypto.createHash('md5').update(scriptSource, 'utf8').digest();
  939. if (!hashData.equals(hashDataNow)) {
  940. moduleManager.getConfig().onError(new Error("FAILED TO VERIFY CACHED DATA, deleting stale '" + cachedDataPath + "' now, but a RESTART IS REQUIRED"));
  941. _this._fs.unlink(cachedDataPath, function (err) { return moduleManager.getConfig().onError(err); });
  942. }
  943. }, Math.ceil(5000 * (1 + Math.random())));
  944. };
  945. NodeScriptLoader._BOM = 0xFEFF;
  946. NodeScriptLoader._PREFIX = '(function (require, define, __filename, __dirname) { ';
  947. NodeScriptLoader._SUFFIX = '\n});';
  948. return NodeScriptLoader;
  949. }());
  950. function createScriptLoader(env) {
  951. return new OnlyOnceScriptLoader(env);
  952. }
  953. AMDLoader.createScriptLoader = createScriptLoader;
  954. })(AMDLoader || (AMDLoader = {}));
  955. /*---------------------------------------------------------------------------------------------
  956. * Copyright (c) Microsoft Corporation. All rights reserved.
  957. * Licensed under the MIT License. See License.txt in the project root for license information.
  958. *--------------------------------------------------------------------------------------------*/
  959. var AMDLoader;
  960. (function (AMDLoader) {
  961. // ------------------------------------------------------------------------
  962. // ModuleIdResolver
  963. var ModuleIdResolver = /** @class */ (function () {
  964. function ModuleIdResolver(fromModuleId) {
  965. var lastSlash = fromModuleId.lastIndexOf('/');
  966. if (lastSlash !== -1) {
  967. this.fromModulePath = fromModuleId.substr(0, lastSlash + 1);
  968. }
  969. else {
  970. this.fromModulePath = '';
  971. }
  972. }
  973. /**
  974. * Normalize 'a/../name' to 'name', etc.
  975. */
  976. ModuleIdResolver._normalizeModuleId = function (moduleId) {
  977. var r = moduleId, pattern;
  978. // replace /./ => /
  979. pattern = /\/\.\//;
  980. while (pattern.test(r)) {
  981. r = r.replace(pattern, '/');
  982. }
  983. // replace ^./ => nothing
  984. r = r.replace(/^\.\//g, '');
  985. // replace /aa/../ => / (BUT IGNORE /../../)
  986. pattern = /\/(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//;
  987. while (pattern.test(r)) {
  988. r = r.replace(pattern, '/');
  989. }
  990. // replace ^aa/../ => nothing (BUT IGNORE ../../)
  991. r = r.replace(/^(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//, '');
  992. return r;
  993. };
  994. /**
  995. * Resolve relative module ids
  996. */
  997. ModuleIdResolver.prototype.resolveModule = function (moduleId) {
  998. var result = moduleId;
  999. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  1000. if (AMDLoader.Utilities.startsWith(result, './') || AMDLoader.Utilities.startsWith(result, '../')) {
  1001. result = ModuleIdResolver._normalizeModuleId(this.fromModulePath + result);
  1002. }
  1003. }
  1004. return result;
  1005. };
  1006. ModuleIdResolver.ROOT = new ModuleIdResolver('');
  1007. return ModuleIdResolver;
  1008. }());
  1009. AMDLoader.ModuleIdResolver = ModuleIdResolver;
  1010. // ------------------------------------------------------------------------
  1011. // Module
  1012. var Module = /** @class */ (function () {
  1013. function Module(id, strId, dependencies, callback, errorback, moduleIdResolver) {
  1014. this.id = id;
  1015. this.strId = strId;
  1016. this.dependencies = dependencies;
  1017. this._callback = callback;
  1018. this._errorback = errorback;
  1019. this.moduleIdResolver = moduleIdResolver;
  1020. this.exports = {};
  1021. this.error = null;
  1022. this.exportsPassedIn = false;
  1023. this.unresolvedDependenciesCount = this.dependencies.length;
  1024. this._isComplete = false;
  1025. }
  1026. Module._safeInvokeFunction = function (callback, args) {
  1027. try {
  1028. return {
  1029. returnedValue: callback.apply(AMDLoader.global, args),
  1030. producedError: null
  1031. };
  1032. }
  1033. catch (e) {
  1034. return {
  1035. returnedValue: null,
  1036. producedError: e
  1037. };
  1038. }
  1039. };
  1040. Module._invokeFactory = function (config, strModuleId, callback, dependenciesValues) {
  1041. if (config.isBuild() && !AMDLoader.Utilities.isAnonymousModule(strModuleId)) {
  1042. return {
  1043. returnedValue: null,
  1044. producedError: null
  1045. };
  1046. }
  1047. if (config.shouldCatchError()) {
  1048. return this._safeInvokeFunction(callback, dependenciesValues);
  1049. }
  1050. return {
  1051. returnedValue: callback.apply(AMDLoader.global, dependenciesValues),
  1052. producedError: null
  1053. };
  1054. };
  1055. Module.prototype.complete = function (recorder, config, dependenciesValues) {
  1056. this._isComplete = true;
  1057. var producedError = null;
  1058. if (this._callback) {
  1059. if (typeof this._callback === 'function') {
  1060. recorder.record(21 /* BeginInvokeFactory */, this.strId);
  1061. var r = Module._invokeFactory(config, this.strId, this._callback, dependenciesValues);
  1062. producedError = r.producedError;
  1063. recorder.record(22 /* EndInvokeFactory */, this.strId);
  1064. if (!producedError && typeof r.returnedValue !== 'undefined' && (!this.exportsPassedIn || AMDLoader.Utilities.isEmpty(this.exports))) {
  1065. this.exports = r.returnedValue;
  1066. }
  1067. }
  1068. else {
  1069. this.exports = this._callback;
  1070. }
  1071. }
  1072. if (producedError) {
  1073. var err = AMDLoader.ensureError(producedError);
  1074. err.phase = 'factory';
  1075. err.moduleId = this.strId;
  1076. this.error = err;
  1077. config.onError(err);
  1078. }
  1079. this.dependencies = null;
  1080. this._callback = null;
  1081. this._errorback = null;
  1082. this.moduleIdResolver = null;
  1083. };
  1084. /**
  1085. * One of the direct dependencies or a transitive dependency has failed to load.
  1086. */
  1087. Module.prototype.onDependencyError = function (err) {
  1088. this._isComplete = true;
  1089. this.error = err;
  1090. if (this._errorback) {
  1091. this._errorback(err);
  1092. return true;
  1093. }
  1094. return false;
  1095. };
  1096. /**
  1097. * Is the current module complete?
  1098. */
  1099. Module.prototype.isComplete = function () {
  1100. return this._isComplete;
  1101. };
  1102. return Module;
  1103. }());
  1104. AMDLoader.Module = Module;
  1105. var ModuleIdProvider = /** @class */ (function () {
  1106. function ModuleIdProvider() {
  1107. this._nextId = 0;
  1108. this._strModuleIdToIntModuleId = new Map();
  1109. this._intModuleIdToStrModuleId = [];
  1110. // Ensure values 0, 1, 2 are assigned accordingly with ModuleId
  1111. this.getModuleId('exports');
  1112. this.getModuleId('module');
  1113. this.getModuleId('require');
  1114. }
  1115. ModuleIdProvider.prototype.getMaxModuleId = function () {
  1116. return this._nextId;
  1117. };
  1118. ModuleIdProvider.prototype.getModuleId = function (strModuleId) {
  1119. var id = this._strModuleIdToIntModuleId.get(strModuleId);
  1120. if (typeof id === 'undefined') {
  1121. id = this._nextId++;
  1122. this._strModuleIdToIntModuleId.set(strModuleId, id);
  1123. this._intModuleIdToStrModuleId[id] = strModuleId;
  1124. }
  1125. return id;
  1126. };
  1127. ModuleIdProvider.prototype.getStrModuleId = function (moduleId) {
  1128. return this._intModuleIdToStrModuleId[moduleId];
  1129. };
  1130. return ModuleIdProvider;
  1131. }());
  1132. var RegularDependency = /** @class */ (function () {
  1133. function RegularDependency(id) {
  1134. this.id = id;
  1135. }
  1136. RegularDependency.EXPORTS = new RegularDependency(0 /* EXPORTS */);
  1137. RegularDependency.MODULE = new RegularDependency(1 /* MODULE */);
  1138. RegularDependency.REQUIRE = new RegularDependency(2 /* REQUIRE */);
  1139. return RegularDependency;
  1140. }());
  1141. AMDLoader.RegularDependency = RegularDependency;
  1142. var PluginDependency = /** @class */ (function () {
  1143. function PluginDependency(id, pluginId, pluginParam) {
  1144. this.id = id;
  1145. this.pluginId = pluginId;
  1146. this.pluginParam = pluginParam;
  1147. }
  1148. return PluginDependency;
  1149. }());
  1150. AMDLoader.PluginDependency = PluginDependency;
  1151. var ModuleManager = /** @class */ (function () {
  1152. function ModuleManager(env, scriptLoader, defineFunc, requireFunc, loaderAvailableTimestamp) {
  1153. if (loaderAvailableTimestamp === void 0) { loaderAvailableTimestamp = 0; }
  1154. this._env = env;
  1155. this._scriptLoader = scriptLoader;
  1156. this._loaderAvailableTimestamp = loaderAvailableTimestamp;
  1157. this._defineFunc = defineFunc;
  1158. this._requireFunc = requireFunc;
  1159. this._moduleIdProvider = new ModuleIdProvider();
  1160. this._config = new AMDLoader.Configuration(this._env);
  1161. this._modules2 = [];
  1162. this._knownModules2 = [];
  1163. this._inverseDependencies2 = [];
  1164. this._inversePluginDependencies2 = new Map();
  1165. this._currentAnnonymousDefineCall = null;
  1166. this._recorder = null;
  1167. this._buildInfoPath = [];
  1168. this._buildInfoDefineStack = [];
  1169. this._buildInfoDependencies = [];
  1170. }
  1171. ModuleManager.prototype.reset = function () {
  1172. return new ModuleManager(this._env, this._scriptLoader, this._defineFunc, this._requireFunc, this._loaderAvailableTimestamp);
  1173. };
  1174. ModuleManager.prototype.getGlobalAMDDefineFunc = function () {
  1175. return this._defineFunc;
  1176. };
  1177. ModuleManager.prototype.getGlobalAMDRequireFunc = function () {
  1178. return this._requireFunc;
  1179. };
  1180. ModuleManager._findRelevantLocationInStack = function (needle, stack) {
  1181. var normalize = function (str) { return str.replace(/\\/g, '/'); };
  1182. var normalizedPath = normalize(needle);
  1183. var stackPieces = stack.split(/\n/);
  1184. for (var i = 0; i < stackPieces.length; i++) {
  1185. var m = stackPieces[i].match(/(.*):(\d+):(\d+)\)?$/);
  1186. if (m) {
  1187. var stackPath = m[1];
  1188. var stackLine = m[2];
  1189. var stackColumn = m[3];
  1190. var trimPathOffset = Math.max(stackPath.lastIndexOf(' ') + 1, stackPath.lastIndexOf('(') + 1);
  1191. stackPath = stackPath.substr(trimPathOffset);
  1192. stackPath = normalize(stackPath);
  1193. if (stackPath === normalizedPath) {
  1194. var r = {
  1195. line: parseInt(stackLine, 10),
  1196. col: parseInt(stackColumn, 10)
  1197. };
  1198. if (r.line === 1) {
  1199. r.col -= '(function (require, define, __filename, __dirname) { '.length;
  1200. }
  1201. return r;
  1202. }
  1203. }
  1204. }
  1205. throw new Error('Could not correlate define call site for needle ' + needle);
  1206. };
  1207. ModuleManager.prototype.getBuildInfo = function () {
  1208. if (!this._config.isBuild()) {
  1209. return null;
  1210. }
  1211. var result = [], resultLen = 0;
  1212. for (var i = 0, len = this._modules2.length; i < len; i++) {
  1213. var m = this._modules2[i];
  1214. if (!m) {
  1215. continue;
  1216. }
  1217. var location_1 = this._buildInfoPath[m.id] || null;
  1218. var defineStack = this._buildInfoDefineStack[m.id] || null;
  1219. var dependencies = this._buildInfoDependencies[m.id];
  1220. result[resultLen++] = {
  1221. id: m.strId,
  1222. path: location_1,
  1223. defineLocation: (location_1 && defineStack ? ModuleManager._findRelevantLocationInStack(location_1, defineStack) : null),
  1224. dependencies: dependencies,
  1225. shim: null,
  1226. exports: m.exports
  1227. };
  1228. }
  1229. return result;
  1230. };
  1231. ModuleManager.prototype.getRecorder = function () {
  1232. if (!this._recorder) {
  1233. if (this._config.shouldRecordStats()) {
  1234. this._recorder = new AMDLoader.LoaderEventRecorder(this._loaderAvailableTimestamp);
  1235. }
  1236. else {
  1237. this._recorder = AMDLoader.NullLoaderEventRecorder.INSTANCE;
  1238. }
  1239. }
  1240. return this._recorder;
  1241. };
  1242. ModuleManager.prototype.getLoaderEvents = function () {
  1243. return this.getRecorder().getEvents();
  1244. };
  1245. /**
  1246. * Defines an anonymous module (without an id). Its name will be resolved as we receive a callback from the scriptLoader.
  1247. * @param dependecies @see defineModule
  1248. * @param callback @see defineModule
  1249. */
  1250. ModuleManager.prototype.enqueueDefineAnonymousModule = function (dependencies, callback) {
  1251. if (this._currentAnnonymousDefineCall !== null) {
  1252. throw new Error('Can only have one anonymous define call per script file');
  1253. }
  1254. var stack = null;
  1255. if (this._config.isBuild()) {
  1256. stack = new Error('StackLocation').stack || null;
  1257. }
  1258. this._currentAnnonymousDefineCall = {
  1259. stack: stack,
  1260. dependencies: dependencies,
  1261. callback: callback
  1262. };
  1263. };
  1264. /**
  1265. * Creates a module and stores it in _modules. The manager will immediately begin resolving its dependencies.
  1266. * @param strModuleId An unique and absolute id of the module. This must not collide with another module's id
  1267. * @param dependencies An array with the dependencies of the module. Special keys are: "require", "exports" and "module"
  1268. * @param callback if callback is a function, it will be called with the resolved dependencies. if callback is an object, it will be considered as the exports of the module.
  1269. */
  1270. ModuleManager.prototype.defineModule = function (strModuleId, dependencies, callback, errorback, stack, moduleIdResolver) {
  1271. var _this = this;
  1272. if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(strModuleId); }
  1273. var moduleId = this._moduleIdProvider.getModuleId(strModuleId);
  1274. if (this._modules2[moduleId]) {
  1275. if (!this._config.isDuplicateMessageIgnoredFor(strModuleId)) {
  1276. console.warn('Duplicate definition of module \'' + strModuleId + '\'');
  1277. }
  1278. // Super important! Completely ignore duplicate module definition
  1279. return;
  1280. }
  1281. var m = new Module(moduleId, strModuleId, this._normalizeDependencies(dependencies, moduleIdResolver), callback, errorback, moduleIdResolver);
  1282. this._modules2[moduleId] = m;
  1283. if (this._config.isBuild()) {
  1284. this._buildInfoDefineStack[moduleId] = stack;
  1285. this._buildInfoDependencies[moduleId] = (m.dependencies || []).map(function (dep) { return _this._moduleIdProvider.getStrModuleId(dep.id); });
  1286. }
  1287. // Resolving of dependencies is immediate (not in a timeout). If there's a need to support a packer that concatenates in an
  1288. // unordered manner, in order to finish processing the file, execute the following method in a timeout
  1289. this._resolve(m);
  1290. };
  1291. ModuleManager.prototype._normalizeDependency = function (dependency, moduleIdResolver) {
  1292. if (dependency === 'exports') {
  1293. return RegularDependency.EXPORTS;
  1294. }
  1295. if (dependency === 'module') {
  1296. return RegularDependency.MODULE;
  1297. }
  1298. if (dependency === 'require') {
  1299. return RegularDependency.REQUIRE;
  1300. }
  1301. // Normalize dependency and then request it from the manager
  1302. var bangIndex = dependency.indexOf('!');
  1303. if (bangIndex >= 0) {
  1304. var strPluginId = moduleIdResolver.resolveModule(dependency.substr(0, bangIndex));
  1305. var pluginParam = moduleIdResolver.resolveModule(dependency.substr(bangIndex + 1));
  1306. var dependencyId = this._moduleIdProvider.getModuleId(strPluginId + '!' + pluginParam);
  1307. var pluginId = this._moduleIdProvider.getModuleId(strPluginId);
  1308. return new PluginDependency(dependencyId, pluginId, pluginParam);
  1309. }
  1310. return new RegularDependency(this._moduleIdProvider.getModuleId(moduleIdResolver.resolveModule(dependency)));
  1311. };
  1312. ModuleManager.prototype._normalizeDependencies = function (dependencies, moduleIdResolver) {
  1313. var result = [], resultLen = 0;
  1314. for (var i = 0, len = dependencies.length; i < len; i++) {
  1315. result[resultLen++] = this._normalizeDependency(dependencies[i], moduleIdResolver);
  1316. }
  1317. return result;
  1318. };
  1319. ModuleManager.prototype._relativeRequire = function (moduleIdResolver, dependencies, callback, errorback) {
  1320. if (typeof dependencies === 'string') {
  1321. return this.synchronousRequire(dependencies, moduleIdResolver);
  1322. }
  1323. this.defineModule(AMDLoader.Utilities.generateAnonymousModule(), dependencies, callback, errorback, null, moduleIdResolver);
  1324. };
  1325. /**
  1326. * Require synchronously a module by its absolute id. If the module is not loaded, an exception will be thrown.
  1327. * @param id The unique and absolute id of the required module
  1328. * @return The exports of module 'id'
  1329. */
  1330. ModuleManager.prototype.synchronousRequire = function (_strModuleId, moduleIdResolver) {
  1331. if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(_strModuleId); }
  1332. var dependency = this._normalizeDependency(_strModuleId, moduleIdResolver);
  1333. var m = this._modules2[dependency.id];
  1334. if (!m) {
  1335. throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This is the first mention of this module!');
  1336. }
  1337. if (!m.isComplete()) {
  1338. throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This module has not been resolved completely yet.');
  1339. }
  1340. if (m.error) {
  1341. throw m.error;
  1342. }
  1343. return m.exports;
  1344. };
  1345. ModuleManager.prototype.configure = function (params, shouldOverwrite) {
  1346. var oldShouldRecordStats = this._config.shouldRecordStats();
  1347. if (shouldOverwrite) {
  1348. this._config = new AMDLoader.Configuration(this._env, params);
  1349. }
  1350. else {
  1351. this._config = this._config.cloneAndMerge(params);
  1352. }
  1353. if (this._config.shouldRecordStats() && !oldShouldRecordStats) {
  1354. this._recorder = null;
  1355. }
  1356. };
  1357. ModuleManager.prototype.getConfig = function () {
  1358. return this._config;
  1359. };
  1360. /**
  1361. * Callback from the scriptLoader when a module has been loaded.
  1362. * This means its code is available and has been executed.
  1363. */
  1364. ModuleManager.prototype._onLoad = function (moduleId) {
  1365. if (this._currentAnnonymousDefineCall !== null) {
  1366. var defineCall = this._currentAnnonymousDefineCall;
  1367. this._currentAnnonymousDefineCall = null;
  1368. // Hit an anonymous define call
  1369. this.defineModule(this._moduleIdProvider.getStrModuleId(moduleId), defineCall.dependencies, defineCall.callback, null, defineCall.stack);
  1370. }
  1371. };
  1372. ModuleManager.prototype._createLoadError = function (moduleId, _err) {
  1373. var _this = this;
  1374. var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
  1375. var neededBy = (this._inverseDependencies2[moduleId] || []).map(function (intModuleId) { return _this._moduleIdProvider.getStrModuleId(intModuleId); });
  1376. var err = AMDLoader.ensureError(_err);
  1377. err.phase = 'loading';
  1378. err.moduleId = strModuleId;
  1379. err.neededBy = neededBy;
  1380. return err;
  1381. };
  1382. /**
  1383. * Callback from the scriptLoader when a module hasn't been loaded.
  1384. * This means that the script was not found (e.g. 404) or there was an error in the script.
  1385. */
  1386. ModuleManager.prototype._onLoadError = function (moduleId, err) {
  1387. var error = this._createLoadError(moduleId, err);
  1388. if (!this._modules2[moduleId]) {
  1389. this._modules2[moduleId] = new Module(moduleId, this._moduleIdProvider.getStrModuleId(moduleId), [], function () { }, function () { }, null);
  1390. }
  1391. // Find any 'local' error handlers, walk the entire chain of inverse dependencies if necessary.
  1392. var seenModuleId = [];
  1393. for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
  1394. seenModuleId[i] = false;
  1395. }
  1396. var someoneNotified = false;
  1397. var queue = [];
  1398. queue.push(moduleId);
  1399. seenModuleId[moduleId] = true;
  1400. while (queue.length > 0) {
  1401. var queueElement = queue.shift();
  1402. var m = this._modules2[queueElement];
  1403. if (m) {
  1404. someoneNotified = m.onDependencyError(error) || someoneNotified;
  1405. }
  1406. var inverseDeps = this._inverseDependencies2[queueElement];
  1407. if (inverseDeps) {
  1408. for (var i = 0, len = inverseDeps.length; i < len; i++) {
  1409. var inverseDep = inverseDeps[i];
  1410. if (!seenModuleId[inverseDep]) {
  1411. queue.push(inverseDep);
  1412. seenModuleId[inverseDep] = true;
  1413. }
  1414. }
  1415. }
  1416. }
  1417. if (!someoneNotified) {
  1418. this._config.onError(error);
  1419. }
  1420. };
  1421. /**
  1422. * Walks (recursively) the dependencies of 'from' in search of 'to'.
  1423. * Returns true if there is such a path or false otherwise.
  1424. * @param from Module id to start at
  1425. * @param to Module id to look for
  1426. */
  1427. ModuleManager.prototype._hasDependencyPath = function (fromId, toId) {
  1428. var from = this._modules2[fromId];
  1429. if (!from) {
  1430. return false;
  1431. }
  1432. var inQueue = [];
  1433. for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
  1434. inQueue[i] = false;
  1435. }
  1436. var queue = [];
  1437. // Insert 'from' in queue
  1438. queue.push(from);
  1439. inQueue[fromId] = true;
  1440. while (queue.length > 0) {
  1441. // Pop first inserted element of queue
  1442. var element = queue.shift();
  1443. var dependencies = element.dependencies;
  1444. if (dependencies) {
  1445. // Walk the element's dependencies
  1446. for (var i = 0, len = dependencies.length; i < len; i++) {
  1447. var dependency = dependencies[i];
  1448. if (dependency.id === toId) {
  1449. // There is a path to 'to'
  1450. return true;
  1451. }
  1452. var dependencyModule = this._modules2[dependency.id];
  1453. if (dependencyModule && !inQueue[dependency.id]) {
  1454. // Insert 'dependency' in queue
  1455. inQueue[dependency.id] = true;
  1456. queue.push(dependencyModule);
  1457. }
  1458. }
  1459. }
  1460. }
  1461. // There is no path to 'to'
  1462. return false;
  1463. };
  1464. /**
  1465. * Walks (recursively) the dependencies of 'from' in search of 'to'.
  1466. * Returns cycle as array.
  1467. * @param from Module id to start at
  1468. * @param to Module id to look for
  1469. */
  1470. ModuleManager.prototype._findCyclePath = function (fromId, toId, depth) {
  1471. if (fromId === toId || depth === 50) {
  1472. return [fromId];
  1473. }
  1474. var from = this._modules2[fromId];
  1475. if (!from) {
  1476. return null;
  1477. }
  1478. // Walk the element's dependencies
  1479. var dependencies = from.dependencies;
  1480. if (dependencies) {
  1481. for (var i = 0, len = dependencies.length; i < len; i++) {
  1482. var path = this._findCyclePath(dependencies[i].id, toId, depth + 1);
  1483. if (path !== null) {
  1484. path.push(fromId);
  1485. return path;
  1486. }
  1487. }
  1488. }
  1489. return null;
  1490. };
  1491. /**
  1492. * Create the local 'require' that is passed into modules
  1493. */
  1494. ModuleManager.prototype._createRequire = function (moduleIdResolver) {
  1495. var _this = this;
  1496. var result = (function (dependencies, callback, errorback) {
  1497. return _this._relativeRequire(moduleIdResolver, dependencies, callback, errorback);
  1498. });
  1499. result.toUrl = function (id) {
  1500. return _this._config.requireToUrl(moduleIdResolver.resolveModule(id));
  1501. };
  1502. result.getStats = function () {
  1503. return _this.getLoaderEvents();
  1504. };
  1505. result.__$__nodeRequire = AMDLoader.global.nodeRequire;
  1506. return result;
  1507. };
  1508. ModuleManager.prototype._loadModule = function (moduleId) {
  1509. var _this = this;
  1510. if (this._modules2[moduleId] || this._knownModules2[moduleId]) {
  1511. // known module
  1512. return;
  1513. }
  1514. this._knownModules2[moduleId] = true;
  1515. var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
  1516. var paths = this._config.moduleIdToPaths(strModuleId);
  1517. var scopedPackageRegex = /^@[^\/]+\/[^\/]+$/; // matches @scope/package-name
  1518. if (this._env.isNode && (strModuleId.indexOf('/') === -1 || scopedPackageRegex.test(strModuleId))) {
  1519. paths.push('node|' + strModuleId);
  1520. }
  1521. var lastPathIndex = -1;
  1522. var loadNextPath = function (err) {
  1523. lastPathIndex++;
  1524. if (lastPathIndex >= paths.length) {
  1525. // No more paths to try
  1526. _this._onLoadError(moduleId, err);
  1527. }
  1528. else {
  1529. var currentPath_1 = paths[lastPathIndex];
  1530. var recorder_1 = _this.getRecorder();
  1531. if (_this._config.isBuild() && currentPath_1 === 'empty:') {
  1532. _this._buildInfoPath[moduleId] = currentPath_1;
  1533. _this.defineModule(_this._moduleIdProvider.getStrModuleId(moduleId), [], null, null, null);
  1534. _this._onLoad(moduleId);
  1535. return;
  1536. }
  1537. recorder_1.record(10 /* BeginLoadingScript */, currentPath_1);
  1538. _this._scriptLoader.load(_this, currentPath_1, function () {
  1539. if (_this._config.isBuild()) {
  1540. _this._buildInfoPath[moduleId] = currentPath_1;
  1541. }
  1542. recorder_1.record(11 /* EndLoadingScriptOK */, currentPath_1);
  1543. _this._onLoad(moduleId);
  1544. }, function (err) {
  1545. recorder_1.record(12 /* EndLoadingScriptError */, currentPath_1);
  1546. loadNextPath(err);
  1547. });
  1548. }
  1549. };
  1550. loadNextPath(null);
  1551. };
  1552. /**
  1553. * Resolve a plugin dependency with the plugin loaded & complete
  1554. * @param module The module that has this dependency
  1555. * @param pluginDependency The semi-normalized dependency that appears in the module. e.g. 'vs/css!./mycssfile'. Only the plugin part (before !) is normalized
  1556. * @param plugin The plugin (what the plugin exports)
  1557. */
  1558. ModuleManager.prototype._loadPluginDependency = function (plugin, pluginDependency) {
  1559. var _this = this;
  1560. if (this._modules2[pluginDependency.id] || this._knownModules2[pluginDependency.id]) {
  1561. // known module
  1562. return;
  1563. }
  1564. this._knownModules2[pluginDependency.id] = true;
  1565. // Delegate the loading of the resource to the plugin
  1566. var load = (function (value) {
  1567. _this.defineModule(_this._moduleIdProvider.getStrModuleId(pluginDependency.id), [], value, null, null);
  1568. });
  1569. load.error = function (err) {
  1570. _this._config.onError(_this._createLoadError(pluginDependency.id, err));
  1571. };
  1572. plugin.load(pluginDependency.pluginParam, this._createRequire(ModuleIdResolver.ROOT), load, this._config.getOptionsLiteral());
  1573. };
  1574. /**
  1575. * Examine the dependencies of module 'module' and resolve them as needed.
  1576. */
  1577. ModuleManager.prototype._resolve = function (module) {
  1578. var _this = this;
  1579. var dependencies = module.dependencies;
  1580. if (dependencies) {
  1581. for (var i = 0, len = dependencies.length; i < len; i++) {
  1582. var dependency = dependencies[i];
  1583. if (dependency === RegularDependency.EXPORTS) {
  1584. module.exportsPassedIn = true;
  1585. module.unresolvedDependenciesCount--;
  1586. continue;
  1587. }
  1588. if (dependency === RegularDependency.MODULE) {
  1589. module.unresolvedDependenciesCount--;
  1590. continue;
  1591. }
  1592. if (dependency === RegularDependency.REQUIRE) {
  1593. module.unresolvedDependenciesCount--;
  1594. continue;
  1595. }
  1596. var dependencyModule = this._modules2[dependency.id];
  1597. if (dependencyModule && dependencyModule.isComplete()) {
  1598. if (dependencyModule.error) {
  1599. module.onDependencyError(dependencyModule.error);
  1600. return;
  1601. }
  1602. module.unresolvedDependenciesCount--;
  1603. continue;
  1604. }
  1605. if (this._hasDependencyPath(dependency.id, module.id)) {
  1606. console.warn('There is a dependency cycle between \'' + this._moduleIdProvider.getStrModuleId(dependency.id) + '\' and \'' + this._moduleIdProvider.getStrModuleId(module.id) + '\'. The cyclic path follows:');
  1607. var cyclePath = this._findCyclePath(dependency.id, module.id, 0) || [];
  1608. cyclePath.reverse();
  1609. cyclePath.push(dependency.id);
  1610. console.warn(cyclePath.map(function (id) { return _this._moduleIdProvider.getStrModuleId(id); }).join(' => \n'));
  1611. // Break the cycle
  1612. module.unresolvedDependenciesCount--;
  1613. continue;
  1614. }
  1615. // record inverse dependency
  1616. this._inverseDependencies2[dependency.id] = this._inverseDependencies2[dependency.id] || [];
  1617. this._inverseDependencies2[dependency.id].push(module.id);
  1618. if (dependency instanceof PluginDependency) {
  1619. var plugin = this._modules2[dependency.pluginId];
  1620. if (plugin && plugin.isComplete()) {
  1621. this._loadPluginDependency(plugin.exports, dependency);
  1622. continue;
  1623. }
  1624. // Record dependency for when the plugin gets loaded
  1625. var inversePluginDeps = this._inversePluginDependencies2.get(dependency.pluginId);
  1626. if (!inversePluginDeps) {
  1627. inversePluginDeps = [];
  1628. this._inversePluginDependencies2.set(dependency.pluginId, inversePluginDeps);
  1629. }
  1630. inversePluginDeps.push(dependency);
  1631. this._loadModule(dependency.pluginId);
  1632. continue;
  1633. }
  1634. this._loadModule(dependency.id);
  1635. }
  1636. }
  1637. if (module.unresolvedDependenciesCount === 0) {
  1638. this._onModuleComplete(module);
  1639. }
  1640. };
  1641. ModuleManager.prototype._onModuleComplete = function (module) {
  1642. var _this = this;
  1643. var recorder = this.getRecorder();
  1644. if (module.isComplete()) {
  1645. // already done
  1646. return;
  1647. }
  1648. var dependencies = module.dependencies;
  1649. var dependenciesValues = [];
  1650. if (dependencies) {
  1651. for (var i = 0, len = dependencies.length; i < len; i++) {
  1652. var dependency = dependencies[i];
  1653. if (dependency === RegularDependency.EXPORTS) {
  1654. dependenciesValues[i] = module.exports;
  1655. continue;
  1656. }
  1657. if (dependency === RegularDependency.MODULE) {
  1658. dependenciesValues[i] = {
  1659. id: module.strId,
  1660. config: function () {
  1661. return _this._config.getConfigForModule(module.strId);
  1662. }
  1663. };
  1664. continue;
  1665. }
  1666. if (dependency === RegularDependency.REQUIRE) {
  1667. dependenciesValues[i] = this._createRequire(module.moduleIdResolver);
  1668. continue;
  1669. }
  1670. var dependencyModule = this._modules2[dependency.id];
  1671. if (dependencyModule) {
  1672. dependenciesValues[i] = dependencyModule.exports;
  1673. continue;
  1674. }
  1675. dependenciesValues[i] = null;
  1676. }
  1677. }
  1678. module.complete(recorder, this._config, dependenciesValues);
  1679. // Fetch and clear inverse dependencies
  1680. var inverseDeps = this._inverseDependencies2[module.id];
  1681. this._inverseDependencies2[module.id] = null;
  1682. if (inverseDeps) {
  1683. // Resolve one inverse dependency at a time, always
  1684. // on the lookout for a completed module.
  1685. for (var i = 0, len = inverseDeps.length; i < len; i++) {
  1686. var inverseDependencyId = inverseDeps[i];
  1687. var inverseDependency = this._modules2[inverseDependencyId];
  1688. inverseDependency.unresolvedDependenciesCount--;
  1689. if (inverseDependency.unresolvedDependenciesCount === 0) {
  1690. this._onModuleComplete(inverseDependency);
  1691. }
  1692. }
  1693. }
  1694. var inversePluginDeps = this._inversePluginDependencies2.get(module.id);
  1695. if (inversePluginDeps) {
  1696. // This module is used as a plugin at least once
  1697. // Fetch and clear these inverse plugin dependencies
  1698. this._inversePluginDependencies2.delete(module.id);
  1699. // Resolve plugin dependencies one at a time
  1700. for (var i = 0, len = inversePluginDeps.length; i < len; i++) {
  1701. this._loadPluginDependency(module.exports, inversePluginDeps[i]);
  1702. }
  1703. }
  1704. };
  1705. return ModuleManager;
  1706. }());
  1707. AMDLoader.ModuleManager = ModuleManager;
  1708. })(AMDLoader || (AMDLoader = {}));
  1709. var define;
  1710. var AMDLoader;
  1711. (function (AMDLoader) {
  1712. var env = new AMDLoader.Environment();
  1713. var moduleManager = null;
  1714. var DefineFunc = function (id, dependencies, callback) {
  1715. if (typeof id !== 'string') {
  1716. callback = dependencies;
  1717. dependencies = id;
  1718. id = null;
  1719. }
  1720. if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
  1721. callback = dependencies;
  1722. dependencies = null;
  1723. }
  1724. if (!dependencies) {
  1725. dependencies = ['require', 'exports', 'module'];
  1726. }
  1727. if (id) {
  1728. moduleManager.defineModule(id, dependencies, callback, null, null);
  1729. }
  1730. else {
  1731. moduleManager.enqueueDefineAnonymousModule(dependencies, callback);
  1732. }
  1733. };
  1734. DefineFunc.amd = {
  1735. jQuery: true
  1736. };
  1737. var _requireFunc_config = function (params, shouldOverwrite) {
  1738. if (shouldOverwrite === void 0) { shouldOverwrite = false; }
  1739. moduleManager.configure(params, shouldOverwrite);
  1740. };
  1741. var RequireFunc = function () {
  1742. if (arguments.length === 1) {
  1743. if ((arguments[0] instanceof Object) && !Array.isArray(arguments[0])) {
  1744. _requireFunc_config(arguments[0]);
  1745. return;
  1746. }
  1747. if (typeof arguments[0] === 'string') {
  1748. return moduleManager.synchronousRequire(arguments[0]);
  1749. }
  1750. }
  1751. if (arguments.length === 2 || arguments.length === 3) {
  1752. if (Array.isArray(arguments[0])) {
  1753. moduleManager.defineModule(AMDLoader.Utilities.generateAnonymousModule(), arguments[0], arguments[1], arguments[2], null);
  1754. return;
  1755. }
  1756. }
  1757. throw new Error('Unrecognized require call');
  1758. };
  1759. RequireFunc.config = _requireFunc_config;
  1760. RequireFunc.getConfig = function () {
  1761. return moduleManager.getConfig().getOptionsLiteral();
  1762. };
  1763. RequireFunc.reset = function () {
  1764. moduleManager = moduleManager.reset();
  1765. };
  1766. RequireFunc.getBuildInfo = function () {
  1767. return moduleManager.getBuildInfo();
  1768. };
  1769. RequireFunc.getStats = function () {
  1770. return moduleManager.getLoaderEvents();
  1771. };
  1772. RequireFunc.define = function () {
  1773. return DefineFunc.apply(null, arguments);
  1774. };
  1775. function init() {
  1776. if (typeof AMDLoader.global.require !== 'undefined' || typeof require !== 'undefined') {
  1777. var _nodeRequire_1 = (AMDLoader.global.require || require);
  1778. if (typeof _nodeRequire_1 === 'function' && typeof _nodeRequire_1.resolve === 'function') {
  1779. // re-expose node's require function
  1780. var nodeRequire = function (what) {
  1781. moduleManager.getRecorder().record(33 /* NodeBeginNativeRequire */, what);
  1782. try {
  1783. return _nodeRequire_1(what);
  1784. }
  1785. finally {
  1786. moduleManager.getRecorder().record(34 /* NodeEndNativeRequire */, what);
  1787. }
  1788. };
  1789. AMDLoader.global.nodeRequire = nodeRequire;
  1790. RequireFunc.nodeRequire = nodeRequire;
  1791. RequireFunc.__$__nodeRequire = nodeRequire;
  1792. }
  1793. }
  1794. if (env.isNode && !env.isElectronRenderer) {
  1795. module.exports = RequireFunc;
  1796. require = RequireFunc;
  1797. }
  1798. else {
  1799. if (!env.isElectronRenderer) {
  1800. AMDLoader.global.define = DefineFunc;
  1801. }
  1802. AMDLoader.global.require = RequireFunc;
  1803. }
  1804. }
  1805. AMDLoader.init = init;
  1806. if (typeof AMDLoader.global.define !== 'function' || !AMDLoader.global.define.amd) {
  1807. moduleManager = new AMDLoader.ModuleManager(env, AMDLoader.createScriptLoader(env), DefineFunc, RequireFunc, AMDLoader.Utilities.getHighPerformanceTimestamp());
  1808. // The global variable require can configure the loader
  1809. if (typeof AMDLoader.global.require !== 'undefined' && typeof AMDLoader.global.require !== 'function') {
  1810. RequireFunc.config(AMDLoader.global.require);
  1811. }
  1812. // This define is for the local closure defined in node in the case that the loader is concatenated
  1813. define = function () {
  1814. return DefineFunc.apply(null, arguments);
  1815. };
  1816. define.amd = DefineFunc.amd;
  1817. if (typeof doNotInitLoader === 'undefined') {
  1818. init();
  1819. }
  1820. }
  1821. })(AMDLoader || (AMDLoader = {}));
  1822. define(__m[13/*vs/base/common/arrays*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1823. "use strict";
  1824. Object.defineProperty(exports, "__esModule", { value: true });
  1825. /**
  1826. * Returns the last element of an array.
  1827. * @param array The array.
  1828. * @param n Which element from the end (default is zero).
  1829. */
  1830. function tail(array, n) {
  1831. if (n === void 0) { n = 0; }
  1832. return array[array.length - (1 + n)];
  1833. }
  1834. exports.tail = tail;
  1835. function tail2(arr) {
  1836. if (arr.length === 0) {
  1837. throw new Error('Invalid tail call');
  1838. }
  1839. return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
  1840. }
  1841. exports.tail2 = tail2;
  1842. function equals(one, other, itemEquals) {
  1843. if (itemEquals === void 0) { itemEquals = function (a, b) { return a === b; }; }
  1844. if (one === other) {
  1845. return true;
  1846. }
  1847. if (!one || !other) {
  1848. return false;
  1849. }
  1850. if (one.length !== other.length) {
  1851. return false;
  1852. }
  1853. for (var i = 0, len = one.length; i < len; i++) {
  1854. if (!itemEquals(one[i], other[i])) {
  1855. return false;
  1856. }
  1857. }
  1858. return true;
  1859. }
  1860. exports.equals = equals;
  1861. function binarySearch(array, key, comparator) {
  1862. var low = 0, high = array.length - 1;
  1863. while (low <= high) {
  1864. var mid = ((low + high) / 2) | 0;
  1865. var comp = comparator(array[mid], key);
  1866. if (comp < 0) {
  1867. low = mid + 1;
  1868. }
  1869. else if (comp > 0) {
  1870. high = mid - 1;
  1871. }
  1872. else {
  1873. return mid;
  1874. }
  1875. }
  1876. return -(low + 1);
  1877. }
  1878. exports.binarySearch = binarySearch;
  1879. /**
  1880. * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false
  1881. * are located before all elements where p(x) is true.
  1882. * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
  1883. */
  1884. function findFirstInSorted(array, p) {
  1885. var low = 0, high = array.length;
  1886. if (high === 0) {
  1887. return 0; // no children
  1888. }
  1889. while (low < high) {
  1890. var mid = Math.floor((low + high) / 2);
  1891. if (p(array[mid])) {
  1892. high = mid;
  1893. }
  1894. else {
  1895. low = mid + 1;
  1896. }
  1897. }
  1898. return low;
  1899. }
  1900. exports.findFirstInSorted = findFirstInSorted;
  1901. /**
  1902. * Like `Array#sort` but always stable. Usually runs a little slower `than Array#sort`
  1903. * so only use this when actually needing stable sort.
  1904. */
  1905. function mergeSort(data, compare) {
  1906. _sort(data, compare, 0, data.length - 1, []);
  1907. return data;
  1908. }
  1909. exports.mergeSort = mergeSort;
  1910. function _merge(a, compare, lo, mid, hi, aux) {
  1911. var leftIdx = lo, rightIdx = mid + 1;
  1912. for (var i = lo; i <= hi; i++) {
  1913. aux[i] = a[i];
  1914. }
  1915. for (var i = lo; i <= hi; i++) {
  1916. if (leftIdx > mid) {
  1917. // left side consumed
  1918. a[i] = aux[rightIdx++];
  1919. }
  1920. else if (rightIdx > hi) {
  1921. // right side consumed
  1922. a[i] = aux[leftIdx++];
  1923. }
  1924. else if (compare(aux[rightIdx], aux[leftIdx]) < 0) {
  1925. // right element is less -> comes first
  1926. a[i] = aux[rightIdx++];
  1927. }
  1928. else {
  1929. // left element comes first (less or equal)
  1930. a[i] = aux[leftIdx++];
  1931. }
  1932. }
  1933. }
  1934. function _sort(a, compare, lo, hi, aux) {
  1935. if (hi <= lo) {
  1936. return;
  1937. }
  1938. var mid = lo + ((hi - lo) / 2) | 0;
  1939. _sort(a, compare, lo, mid, aux);
  1940. _sort(a, compare, mid + 1, hi, aux);
  1941. if (compare(a[mid], a[mid + 1]) <= 0) {
  1942. // left and right are sorted and if the last-left element is less
  1943. // or equals than the first-right element there is nothing else
  1944. // to do
  1945. return;
  1946. }
  1947. _merge(a, compare, lo, mid, hi, aux);
  1948. }
  1949. function groupBy(data, compare) {
  1950. var result = [];
  1951. var currentGroup = undefined;
  1952. for (var _i = 0, _a = mergeSort(data.slice(0), compare); _i < _a.length; _i++) {
  1953. var element = _a[_i];
  1954. if (!currentGroup || compare(currentGroup[0], element) !== 0) {
  1955. currentGroup = [element];
  1956. result.push(currentGroup);
  1957. }
  1958. else {
  1959. currentGroup.push(element);
  1960. }
  1961. }
  1962. return result;
  1963. }
  1964. exports.groupBy = groupBy;
  1965. /**
  1966. * @returns New array with all falsy values removed. The original array IS NOT modified.
  1967. */
  1968. function coalesce(array) {
  1969. return array.filter(function (e) { return !!e; });
  1970. }
  1971. exports.coalesce = coalesce;
  1972. /**
  1973. * @returns false if the provided object is an array and not empty.
  1974. */
  1975. function isFalsyOrEmpty(obj) {
  1976. return !Array.isArray(obj) || obj.length === 0;
  1977. }
  1978. exports.isFalsyOrEmpty = isFalsyOrEmpty;
  1979. function isNonEmptyArray(obj) {
  1980. return Array.isArray(obj) && obj.length > 0;
  1981. }
  1982. exports.isNonEmptyArray = isNonEmptyArray;
  1983. /**
  1984. * Removes duplicates from the given array. The optional keyFn allows to specify
  1985. * how elements are checked for equalness by returning a unique string for each.
  1986. */
  1987. function distinct(array, keyFn) {
  1988. if (!keyFn) {
  1989. return array.filter(function (element, position) {
  1990. return array.indexOf(element) === position;
  1991. });
  1992. }
  1993. var seen = Object.create(null);
  1994. return array.filter(function (elem) {
  1995. var key = keyFn(elem);
  1996. if (seen[key]) {
  1997. return false;
  1998. }
  1999. seen[key] = true;
  2000. return true;
  2001. });
  2002. }
  2003. exports.distinct = distinct;
  2004. function distinctES6(array) {
  2005. var seen = new Set();
  2006. return array.filter(function (element) {
  2007. if (seen.has(element)) {
  2008. return false;
  2009. }
  2010. seen.add(element);
  2011. return true;
  2012. });
  2013. }
  2014. exports.distinctES6 = distinctES6;
  2015. function fromSet(set) {
  2016. var result = [];
  2017. set.forEach(function (o) { return result.push(o); });
  2018. return result;
  2019. }
  2020. exports.fromSet = fromSet;
  2021. function firstIndex(array, fn) {
  2022. for (var i = 0; i < array.length; i++) {
  2023. var element = array[i];
  2024. if (fn(element)) {
  2025. return i;
  2026. }
  2027. }
  2028. return -1;
  2029. }
  2030. exports.firstIndex = firstIndex;
  2031. function first(array, fn, notFoundValue) {
  2032. if (notFoundValue === void 0) { notFoundValue = undefined; }
  2033. var index = firstIndex(array, fn);
  2034. return index < 0 ? notFoundValue : array[index];
  2035. }
  2036. exports.first = first;
  2037. function firstOrDefault(array, notFoundValue) {
  2038. return array.length > 0 ? array[0] : notFoundValue;
  2039. }
  2040. exports.firstOrDefault = firstOrDefault;
  2041. function flatten(arr) {
  2042. var _a;
  2043. return (_a = []).concat.apply(_a, arr);
  2044. }
  2045. exports.flatten = flatten;
  2046. function range(arg, to) {
  2047. var from = typeof to === 'number' ? arg : 0;
  2048. if (typeof to === 'number') {
  2049. from = arg;
  2050. }
  2051. else {
  2052. from = 0;
  2053. to = arg;
  2054. }
  2055. var result = [];
  2056. if (from <= to) {
  2057. for (var i = from; i < to; i++) {
  2058. result.push(i);
  2059. }
  2060. }
  2061. else {
  2062. for (var i = from; i > to; i--) {
  2063. result.push(i);
  2064. }
  2065. }
  2066. return result;
  2067. }
  2068. exports.range = range;
  2069. /**
  2070. * Insert `insertArr` inside `target` at `insertIndex`.
  2071. * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
  2072. */
  2073. function arrayInsert(target, insertIndex, insertArr) {
  2074. var before = target.slice(0, insertIndex);
  2075. var after = target.slice(insertIndex);
  2076. return before.concat(insertArr, after);
  2077. }
  2078. exports.arrayInsert = arrayInsert;
  2079. /**
  2080. * Pushes an element to the start of the array, if found.
  2081. */
  2082. function pushToStart(arr, value) {
  2083. var index = arr.indexOf(value);
  2084. if (index > -1) {
  2085. arr.splice(index, 1);
  2086. arr.unshift(value);
  2087. }
  2088. }
  2089. exports.pushToStart = pushToStart;
  2090. /**
  2091. * Pushes an element to the end of the array, if found.
  2092. */
  2093. function pushToEnd(arr, value) {
  2094. var index = arr.indexOf(value);
  2095. if (index > -1) {
  2096. arr.splice(index, 1);
  2097. arr.push(value);
  2098. }
  2099. }
  2100. exports.pushToEnd = pushToEnd;
  2101. function find(arr, predicate) {
  2102. for (var i = 0; i < arr.length; i++) {
  2103. var element = arr[i];
  2104. if (predicate(element, i, arr)) {
  2105. return element;
  2106. }
  2107. }
  2108. return undefined;
  2109. }
  2110. exports.find = find;
  2111. function asArray(x) {
  2112. return Array.isArray(x) ? x : [x];
  2113. }
  2114. exports.asArray = asArray;
  2115. });
  2116. /*---------------------------------------------------------------------------------------------
  2117. * Copyright (c) Microsoft Corporation. All rights reserved.
  2118. * Licensed under the MIT License. See License.txt in the project root for license information.
  2119. *--------------------------------------------------------------------------------------------*/
  2120. define(__m[14/*vs/base/common/diff/diffChange*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2121. "use strict";
  2122. Object.defineProperty(exports, "__esModule", { value: true });
  2123. /**
  2124. * Represents information about a specific difference between two sequences.
  2125. */
  2126. var DiffChange = /** @class */ (function () {
  2127. /**
  2128. * Constructs a new DiffChange with the given sequence information
  2129. * and content.
  2130. */
  2131. function DiffChange(originalStart, originalLength, modifiedStart, modifiedLength) {
  2132. //Debug.Assert(originalLength > 0 || modifiedLength > 0, "originalLength and modifiedLength cannot both be <= 0");
  2133. this.originalStart = originalStart;
  2134. this.originalLength = originalLength;
  2135. this.modifiedStart = modifiedStart;
  2136. this.modifiedLength = modifiedLength;
  2137. }
  2138. /**
  2139. * The end point (exclusive) of the change in the original sequence.
  2140. */
  2141. DiffChange.prototype.getOriginalEnd = function () {
  2142. return this.originalStart + this.originalLength;
  2143. };
  2144. /**
  2145. * The end point (exclusive) of the change in the modified sequence.
  2146. */
  2147. DiffChange.prototype.getModifiedEnd = function () {
  2148. return this.modifiedStart + this.modifiedLength;
  2149. };
  2150. return DiffChange;
  2151. }());
  2152. exports.DiffChange = DiffChange;
  2153. });
  2154. /*---------------------------------------------------------------------------------------------
  2155. * Copyright (c) Microsoft Corporation. All rights reserved.
  2156. * Licensed under the MIT License. See License.txt in the project root for license information.
  2157. *--------------------------------------------------------------------------------------------*/
  2158. define(__m[3/*vs/base/common/errors*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2159. "use strict";
  2160. Object.defineProperty(exports, "__esModule", { value: true });
  2161. // Avoid circular dependency on EventEmitter by implementing a subset of the interface.
  2162. var ErrorHandler = /** @class */ (function () {
  2163. function ErrorHandler() {
  2164. this.listeners = [];
  2165. this.unexpectedErrorHandler = function (e) {
  2166. setTimeout(function () {
  2167. if (e.stack) {
  2168. throw new Error(e.message + '\n\n' + e.stack);
  2169. }
  2170. throw e;
  2171. }, 0);
  2172. };
  2173. }
  2174. ErrorHandler.prototype.emit = function (e) {
  2175. this.listeners.forEach(function (listener) {
  2176. listener(e);
  2177. });
  2178. };
  2179. ErrorHandler.prototype.onUnexpectedError = function (e) {
  2180. this.unexpectedErrorHandler(e);
  2181. this.emit(e);
  2182. };
  2183. // For external errors, we don't want the listeners to be called
  2184. ErrorHandler.prototype.onUnexpectedExternalError = function (e) {
  2185. this.unexpectedErrorHandler(e);
  2186. };
  2187. return ErrorHandler;
  2188. }());
  2189. exports.ErrorHandler = ErrorHandler;
  2190. exports.errorHandler = new ErrorHandler();
  2191. function onUnexpectedError(e) {
  2192. // ignore errors from cancelled promises
  2193. if (!isPromiseCanceledError(e)) {
  2194. exports.errorHandler.onUnexpectedError(e);
  2195. }
  2196. return undefined;
  2197. }
  2198. exports.onUnexpectedError = onUnexpectedError;
  2199. function onUnexpectedExternalError(e) {
  2200. // ignore errors from cancelled promises
  2201. if (!isPromiseCanceledError(e)) {
  2202. exports.errorHandler.onUnexpectedExternalError(e);
  2203. }
  2204. return undefined;
  2205. }
  2206. exports.onUnexpectedExternalError = onUnexpectedExternalError;
  2207. function transformErrorForSerialization(error) {
  2208. if (error instanceof Error) {
  2209. var name_1 = error.name, message = error.message;
  2210. var stack = error.stacktrace || error.stack;
  2211. return {
  2212. $isError: true,
  2213. name: name_1,
  2214. message: message,
  2215. stack: stack
  2216. };
  2217. }
  2218. // return as is
  2219. return error;
  2220. }
  2221. exports.transformErrorForSerialization = transformErrorForSerialization;
  2222. var canceledName = 'Canceled';
  2223. /**
  2224. * Checks if the given error is a promise in canceled state
  2225. */
  2226. function isPromiseCanceledError(error) {
  2227. return error instanceof Error && error.name === canceledName && error.message === canceledName;
  2228. }
  2229. exports.isPromiseCanceledError = isPromiseCanceledError;
  2230. /**
  2231. * Returns an error that signals cancellation.
  2232. */
  2233. function canceled() {
  2234. var error = new Error(canceledName);
  2235. error.name = error.message;
  2236. return error;
  2237. }
  2238. exports.canceled = canceled;
  2239. function illegalArgument(name) {
  2240. if (name) {
  2241. return new Error("Illegal argument: " + name);
  2242. }
  2243. else {
  2244. return new Error('Illegal argument');
  2245. }
  2246. }
  2247. exports.illegalArgument = illegalArgument;
  2248. function illegalState(name) {
  2249. if (name) {
  2250. return new Error("Illegal state: " + name);
  2251. }
  2252. else {
  2253. return new Error('Illegal state');
  2254. }
  2255. }
  2256. exports.illegalState = illegalState;
  2257. });
  2258. /*---------------------------------------------------------------------------------------------
  2259. * Copyright (c) Microsoft Corporation. All rights reserved.
  2260. * Licensed under the MIT License. See License.txt in the project root for license information.
  2261. *--------------------------------------------------------------------------------------------*/
  2262. define(__m[15/*vs/base/common/functional*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2263. "use strict";
  2264. Object.defineProperty(exports, "__esModule", { value: true });
  2265. function once(fn) {
  2266. var _this = this;
  2267. var didCall = false;
  2268. var result;
  2269. return function () {
  2270. if (didCall) {
  2271. return result;
  2272. }
  2273. didCall = true;
  2274. result = fn.apply(_this, arguments);
  2275. return result;
  2276. };
  2277. }
  2278. exports.once = once;
  2279. });
  2280. /*---------------------------------------------------------------------------------------------
  2281. * Copyright (c) Microsoft Corporation. All rights reserved.
  2282. * Licensed under the MIT License. See License.txt in the project root for license information.
  2283. *--------------------------------------------------------------------------------------------*/
  2284. define(__m[16/*vs/base/common/hash*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2285. "use strict";
  2286. Object.defineProperty(exports, "__esModule", { value: true });
  2287. /**
  2288. * Return a hash value for an object.
  2289. */
  2290. function hash(obj, hashVal) {
  2291. if (hashVal === void 0) { hashVal = 0; }
  2292. switch (typeof obj) {
  2293. case 'object':
  2294. if (obj === null) {
  2295. return numberHash(349, hashVal);
  2296. }
  2297. else if (Array.isArray(obj)) {
  2298. return arrayHash(obj, hashVal);
  2299. }
  2300. return objectHash(obj, hashVal);
  2301. case 'string':
  2302. return stringHash(obj, hashVal);
  2303. case 'boolean':
  2304. return booleanHash(obj, hashVal);
  2305. case 'number':
  2306. return numberHash(obj, hashVal);
  2307. case 'undefined':
  2308. return numberHash(0, 937);
  2309. default:
  2310. return numberHash(0, 617);
  2311. }
  2312. }
  2313. exports.hash = hash;
  2314. function numberHash(val, initialHashVal) {
  2315. return (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32
  2316. }
  2317. function booleanHash(b, initialHashVal) {
  2318. return numberHash(b ? 433 : 863, initialHashVal);
  2319. }
  2320. function stringHash(s, hashVal) {
  2321. hashVal = numberHash(149417, hashVal);
  2322. for (var i = 0, length_1 = s.length; i < length_1; i++) {
  2323. hashVal = numberHash(s.charCodeAt(i), hashVal);
  2324. }
  2325. return hashVal;
  2326. }
  2327. exports.stringHash = stringHash;
  2328. function arrayHash(arr, initialHashVal) {
  2329. initialHashVal = numberHash(104579, initialHashVal);
  2330. return arr.reduce(function (hashVal, item) { return hash(item, hashVal); }, initialHashVal);
  2331. }
  2332. function objectHash(obj, initialHashVal) {
  2333. initialHashVal = numberHash(181387, initialHashVal);
  2334. return Object.keys(obj).sort().reduce(function (hashVal, key) {
  2335. hashVal = stringHash(key, hashVal);
  2336. return hash(obj[key], hashVal);
  2337. }, initialHashVal);
  2338. }
  2339. });
  2340. /*---------------------------------------------------------------------------------------------
  2341. * Copyright (c) Microsoft Corporation. All rights reserved.
  2342. * Licensed under the MIT License. See License.txt in the project root for license information.
  2343. *--------------------------------------------------------------------------------------------*/
  2344. define(__m[6/*vs/base/common/diff/diff*/], __M([0/*require*/,1/*exports*/,14/*vs/base/common/diff/diffChange*/,16/*vs/base/common/hash*/]), function (require, exports, diffChange_1, hash_1) {
  2345. "use strict";
  2346. Object.defineProperty(exports, "__esModule", { value: true });
  2347. var StringDiffSequence = /** @class */ (function () {
  2348. function StringDiffSequence(source) {
  2349. this.source = source;
  2350. }
  2351. StringDiffSequence.prototype.getElements = function () {
  2352. var source = this.source;
  2353. var characters = new Int32Array(source.length);
  2354. for (var i = 0, len = source.length; i < len; i++) {
  2355. characters[i] = source.charCodeAt(i);
  2356. }
  2357. return characters;
  2358. };
  2359. return StringDiffSequence;
  2360. }());
  2361. exports.StringDiffSequence = StringDiffSequence;
  2362. function stringDiff(original, modified, pretty) {
  2363. return new LcsDiff(new StringDiffSequence(original), new StringDiffSequence(modified)).ComputeDiff(pretty).changes;
  2364. }
  2365. exports.stringDiff = stringDiff;
  2366. //
  2367. // The code below has been ported from a C# implementation in VS
  2368. //
  2369. var Debug = /** @class */ (function () {
  2370. function Debug() {
  2371. }
  2372. Debug.Assert = function (condition, message) {
  2373. if (!condition) {
  2374. throw new Error(message);
  2375. }
  2376. };
  2377. return Debug;
  2378. }());
  2379. exports.Debug = Debug;
  2380. var MyArray = /** @class */ (function () {
  2381. function MyArray() {
  2382. }
  2383. /**
  2384. * Copies a range of elements from an Array starting at the specified source index and pastes
  2385. * them to another Array starting at the specified destination index. The length and the indexes
  2386. * are specified as 64-bit integers.
  2387. * sourceArray:
  2388. * The Array that contains the data to copy.
  2389. * sourceIndex:
  2390. * A 64-bit integer that represents the index in the sourceArray at which copying begins.
  2391. * destinationArray:
  2392. * The Array that receives the data.
  2393. * destinationIndex:
  2394. * A 64-bit integer that represents the index in the destinationArray at which storing begins.
  2395. * length:
  2396. * A 64-bit integer that represents the number of elements to copy.
  2397. */
  2398. MyArray.Copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  2399. for (var i = 0; i < length; i++) {
  2400. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  2401. }
  2402. };
  2403. MyArray.Copy2 = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  2404. for (var i = 0; i < length; i++) {
  2405. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  2406. }
  2407. };
  2408. return MyArray;
  2409. }());
  2410. exports.MyArray = MyArray;
  2411. /**
  2412. * A utility class which helps to create the set of DiffChanges from
  2413. * a difference operation. This class accepts original DiffElements and
  2414. * modified DiffElements that are involved in a particular change. The
  2415. * MarktNextChange() method can be called to mark the separation between
  2416. * distinct changes. At the end, the Changes property can be called to retrieve
  2417. * the constructed changes.
  2418. */
  2419. var DiffChangeHelper = /** @class */ (function () {
  2420. /**
  2421. * Constructs a new DiffChangeHelper for the given DiffSequences.
  2422. */
  2423. function DiffChangeHelper() {
  2424. this.m_changes = [];
  2425. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2426. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2427. this.m_originalCount = 0;
  2428. this.m_modifiedCount = 0;
  2429. }
  2430. /**
  2431. * Marks the beginning of the next change in the set of differences.
  2432. */
  2433. DiffChangeHelper.prototype.MarkNextChange = function () {
  2434. // Only add to the list if there is something to add
  2435. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  2436. // Add the new change to our list
  2437. this.m_changes.push(new diffChange_1.DiffChange(this.m_originalStart, this.m_originalCount, this.m_modifiedStart, this.m_modifiedCount));
  2438. }
  2439. // Reset for the next change
  2440. this.m_originalCount = 0;
  2441. this.m_modifiedCount = 0;
  2442. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2443. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2444. };
  2445. /**
  2446. * Adds the original element at the given position to the elements
  2447. * affected by the current change. The modified index gives context
  2448. * to the change position with respect to the original sequence.
  2449. * @param originalIndex The index of the original element to add.
  2450. * @param modifiedIndex The index of the modified element that provides corresponding position in the modified sequence.
  2451. */
  2452. DiffChangeHelper.prototype.AddOriginalElement = function (originalIndex, modifiedIndex) {
  2453. // The 'true' start index is the smallest of the ones we've seen
  2454. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  2455. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  2456. this.m_originalCount++;
  2457. };
  2458. /**
  2459. * Adds the modified element at the given position to the elements
  2460. * affected by the current change. The original index gives context
  2461. * to the change position with respect to the modified sequence.
  2462. * @param originalIndex The index of the original element that provides corresponding position in the original sequence.
  2463. * @param modifiedIndex The index of the modified element to add.
  2464. */
  2465. DiffChangeHelper.prototype.AddModifiedElement = function (originalIndex, modifiedIndex) {
  2466. // The 'true' start index is the smallest of the ones we've seen
  2467. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  2468. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  2469. this.m_modifiedCount++;
  2470. };
  2471. /**
  2472. * Retrieves all of the changes marked by the class.
  2473. */
  2474. DiffChangeHelper.prototype.getChanges = function () {
  2475. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  2476. // Finish up on whatever is left
  2477. this.MarkNextChange();
  2478. }
  2479. return this.m_changes;
  2480. };
  2481. /**
  2482. * Retrieves all of the changes marked by the class in the reverse order
  2483. */
  2484. DiffChangeHelper.prototype.getReverseChanges = function () {
  2485. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  2486. // Finish up on whatever is left
  2487. this.MarkNextChange();
  2488. }
  2489. this.m_changes.reverse();
  2490. return this.m_changes;
  2491. };
  2492. return DiffChangeHelper;
  2493. }());
  2494. /**
  2495. * An implementation of the difference algorithm described in
  2496. * "An O(ND) Difference Algorithm and its variations" by Eugene W. Myers
  2497. */
  2498. var LcsDiff = /** @class */ (function () {
  2499. /**
  2500. * Constructs the DiffFinder
  2501. */
  2502. function LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate) {
  2503. if (continueProcessingPredicate === void 0) { continueProcessingPredicate = null; }
  2504. this.ContinueProcessingPredicate = continueProcessingPredicate;
  2505. var _a = LcsDiff._getElements(originalSequence), originalStringElements = _a[0], originalElementsOrHash = _a[1], originalHasStrings = _a[2];
  2506. var _b = LcsDiff._getElements(modifiedSequence), modifiedStringElements = _b[0], modifiedElementsOrHash = _b[1], modifiedHasStrings = _b[2];
  2507. this._hasStrings = (originalHasStrings && modifiedHasStrings);
  2508. this._originalStringElements = originalStringElements;
  2509. this._originalElementsOrHash = originalElementsOrHash;
  2510. this._modifiedStringElements = modifiedStringElements;
  2511. this._modifiedElementsOrHash = modifiedElementsOrHash;
  2512. this.m_forwardHistory = [];
  2513. this.m_reverseHistory = [];
  2514. }
  2515. LcsDiff._isStringArray = function (arr) {
  2516. return (arr.length > 0 && typeof arr[0] === 'string');
  2517. };
  2518. LcsDiff._getElements = function (sequence) {
  2519. var elements = sequence.getElements();
  2520. if (LcsDiff._isStringArray(elements)) {
  2521. var hashes = new Int32Array(elements.length);
  2522. for (var i = 0, len = elements.length; i < len; i++) {
  2523. hashes[i] = hash_1.stringHash(elements[i], 0);
  2524. }
  2525. return [elements, hashes, true];
  2526. }
  2527. if (elements instanceof Int32Array) {
  2528. return [[], elements, false];
  2529. }
  2530. return [[], new Int32Array(elements), false];
  2531. };
  2532. LcsDiff.prototype.ElementsAreEqual = function (originalIndex, newIndex) {
  2533. if (this._originalElementsOrHash[originalIndex] !== this._modifiedElementsOrHash[newIndex]) {
  2534. return false;
  2535. }
  2536. return (this._hasStrings ? this._originalStringElements[originalIndex] === this._modifiedStringElements[newIndex] : true);
  2537. };
  2538. LcsDiff.prototype.OriginalElementsAreEqual = function (index1, index2) {
  2539. if (this._originalElementsOrHash[index1] !== this._originalElementsOrHash[index2]) {
  2540. return false;
  2541. }
  2542. return (this._hasStrings ? this._originalStringElements[index1] === this._originalStringElements[index2] : true);
  2543. };
  2544. LcsDiff.prototype.ModifiedElementsAreEqual = function (index1, index2) {
  2545. if (this._modifiedElementsOrHash[index1] !== this._modifiedElementsOrHash[index2]) {
  2546. return false;
  2547. }
  2548. return (this._hasStrings ? this._modifiedStringElements[index1] === this._modifiedStringElements[index2] : true);
  2549. };
  2550. LcsDiff.prototype.ComputeDiff = function (pretty) {
  2551. return this._ComputeDiff(0, this._originalElementsOrHash.length - 1, 0, this._modifiedElementsOrHash.length - 1, pretty);
  2552. };
  2553. /**
  2554. * Computes the differences between the original and modified input
  2555. * sequences on the bounded range.
  2556. * @returns An array of the differences between the two input sequences.
  2557. */
  2558. LcsDiff.prototype._ComputeDiff = function (originalStart, originalEnd, modifiedStart, modifiedEnd, pretty) {
  2559. var quitEarlyArr = [false];
  2560. var changes = this.ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr);
  2561. if (pretty) {
  2562. // We have to clean up the computed diff to be more intuitive
  2563. // but it turns out this cannot be done correctly until the entire set
  2564. // of diffs have been computed
  2565. changes = this.PrettifyChanges(changes);
  2566. }
  2567. return {
  2568. quitEarly: quitEarlyArr[0],
  2569. changes: changes
  2570. };
  2571. };
  2572. /**
  2573. * Private helper method which computes the differences on the bounded range
  2574. * recursively.
  2575. * @returns An array of the differences between the two input sequences.
  2576. */
  2577. LcsDiff.prototype.ComputeDiffRecursive = function (originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr) {
  2578. quitEarlyArr[0] = false;
  2579. // Find the start of the differences
  2580. while (originalStart <= originalEnd && modifiedStart <= modifiedEnd && this.ElementsAreEqual(originalStart, modifiedStart)) {
  2581. originalStart++;
  2582. modifiedStart++;
  2583. }
  2584. // Find the end of the differences
  2585. while (originalEnd >= originalStart && modifiedEnd >= modifiedStart && this.ElementsAreEqual(originalEnd, modifiedEnd)) {
  2586. originalEnd--;
  2587. modifiedEnd--;
  2588. }
  2589. // In the special case where we either have all insertions or all deletions or the sequences are identical
  2590. if (originalStart > originalEnd || modifiedStart > modifiedEnd) {
  2591. var changes = void 0;
  2592. if (modifiedStart <= modifiedEnd) {
  2593. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  2594. // All insertions
  2595. changes = [
  2596. new diffChange_1.DiffChange(originalStart, 0, modifiedStart, modifiedEnd - modifiedStart + 1)
  2597. ];
  2598. }
  2599. else if (originalStart <= originalEnd) {
  2600. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  2601. // All deletions
  2602. changes = [
  2603. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, 0)
  2604. ];
  2605. }
  2606. else {
  2607. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  2608. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  2609. // Identical sequences - No differences
  2610. changes = [];
  2611. }
  2612. return changes;
  2613. }
  2614. // This problem can be solved using the Divide-And-Conquer technique.
  2615. var midOriginalArr = [0];
  2616. var midModifiedArr = [0];
  2617. var result = this.ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr);
  2618. var midOriginal = midOriginalArr[0];
  2619. var midModified = midModifiedArr[0];
  2620. if (result !== null) {
  2621. // Result is not-null when there was enough memory to compute the changes while
  2622. // searching for the recursion point
  2623. return result;
  2624. }
  2625. else if (!quitEarlyArr[0]) {
  2626. // We can break the problem down recursively by finding the changes in the
  2627. // First Half: (originalStart, modifiedStart) to (midOriginal, midModified)
  2628. // Second Half: (midOriginal + 1, minModified + 1) to (originalEnd, modifiedEnd)
  2629. // NOTE: ComputeDiff() is inclusive, therefore the second range starts on the next point
  2630. var leftChanges = this.ComputeDiffRecursive(originalStart, midOriginal, modifiedStart, midModified, quitEarlyArr);
  2631. var rightChanges = [];
  2632. if (!quitEarlyArr[0]) {
  2633. rightChanges = this.ComputeDiffRecursive(midOriginal + 1, originalEnd, midModified + 1, modifiedEnd, quitEarlyArr);
  2634. }
  2635. else {
  2636. // We did't have time to finish the first half, so we don't have time to compute this half.
  2637. // Consider the entire rest of the sequence different.
  2638. rightChanges = [
  2639. new diffChange_1.DiffChange(midOriginal + 1, originalEnd - (midOriginal + 1) + 1, midModified + 1, modifiedEnd - (midModified + 1) + 1)
  2640. ];
  2641. }
  2642. return this.ConcatenateChanges(leftChanges, rightChanges);
  2643. }
  2644. // If we hit here, we quit early, and so can't return anything meaningful
  2645. return [
  2646. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  2647. ];
  2648. };
  2649. LcsDiff.prototype.WALKTRACE = function (diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr) {
  2650. var forwardChanges = null;
  2651. var reverseChanges = null;
  2652. // First, walk backward through the forward diagonals history
  2653. var changeHelper = new DiffChangeHelper();
  2654. var diagonalMin = diagonalForwardStart;
  2655. var diagonalMax = diagonalForwardEnd;
  2656. var diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalForwardOffset;
  2657. var lastOriginalIndex = -1073741824 /* MIN_SAFE_SMALL_INTEGER */;
  2658. var historyIndex = this.m_forwardHistory.length - 1;
  2659. do {
  2660. // Get the diagonal index from the relative diagonal number
  2661. var diagonal = diagonalRelative + diagonalForwardBase;
  2662. // Figure out where we came from
  2663. if (diagonal === diagonalMin || (diagonal < diagonalMax && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  2664. // Vertical line (the element is an insert)
  2665. originalIndex = forwardPoints[diagonal + 1];
  2666. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  2667. if (originalIndex < lastOriginalIndex) {
  2668. changeHelper.MarkNextChange();
  2669. }
  2670. lastOriginalIndex = originalIndex;
  2671. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex);
  2672. diagonalRelative = (diagonal + 1) - diagonalForwardBase; //Setup for the next iteration
  2673. }
  2674. else {
  2675. // Horizontal line (the element is a deletion)
  2676. originalIndex = forwardPoints[diagonal - 1] + 1;
  2677. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  2678. if (originalIndex < lastOriginalIndex) {
  2679. changeHelper.MarkNextChange();
  2680. }
  2681. lastOriginalIndex = originalIndex - 1;
  2682. changeHelper.AddOriginalElement(originalIndex, modifiedIndex + 1);
  2683. diagonalRelative = (diagonal - 1) - diagonalForwardBase; //Setup for the next iteration
  2684. }
  2685. if (historyIndex >= 0) {
  2686. forwardPoints = this.m_forwardHistory[historyIndex];
  2687. diagonalForwardBase = forwardPoints[0]; //We stored this in the first spot
  2688. diagonalMin = 1;
  2689. diagonalMax = forwardPoints.length - 1;
  2690. }
  2691. } while (--historyIndex >= -1);
  2692. // Ironically, we get the forward changes as the reverse of the
  2693. // order we added them since we technically added them backwards
  2694. forwardChanges = changeHelper.getReverseChanges();
  2695. if (quitEarlyArr[0]) {
  2696. // TODO: Calculate a partial from the reverse diagonals.
  2697. // For now, just assume everything after the midOriginal/midModified point is a diff
  2698. var originalStartPoint = midOriginalArr[0] + 1;
  2699. var modifiedStartPoint = midModifiedArr[0] + 1;
  2700. if (forwardChanges !== null && forwardChanges.length > 0) {
  2701. var lastForwardChange = forwardChanges[forwardChanges.length - 1];
  2702. originalStartPoint = Math.max(originalStartPoint, lastForwardChange.getOriginalEnd());
  2703. modifiedStartPoint = Math.max(modifiedStartPoint, lastForwardChange.getModifiedEnd());
  2704. }
  2705. reverseChanges = [
  2706. new diffChange_1.DiffChange(originalStartPoint, originalEnd - originalStartPoint + 1, modifiedStartPoint, modifiedEnd - modifiedStartPoint + 1)
  2707. ];
  2708. }
  2709. else {
  2710. // Now walk backward through the reverse diagonals history
  2711. changeHelper = new DiffChangeHelper();
  2712. diagonalMin = diagonalReverseStart;
  2713. diagonalMax = diagonalReverseEnd;
  2714. diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalReverseOffset;
  2715. lastOriginalIndex = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2716. historyIndex = (deltaIsEven) ? this.m_reverseHistory.length - 1 : this.m_reverseHistory.length - 2;
  2717. do {
  2718. // Get the diagonal index from the relative diagonal number
  2719. var diagonal = diagonalRelative + diagonalReverseBase;
  2720. // Figure out where we came from
  2721. if (diagonal === diagonalMin || (diagonal < diagonalMax && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  2722. // Horizontal line (the element is a deletion))
  2723. originalIndex = reversePoints[diagonal + 1] - 1;
  2724. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  2725. if (originalIndex > lastOriginalIndex) {
  2726. changeHelper.MarkNextChange();
  2727. }
  2728. lastOriginalIndex = originalIndex + 1;
  2729. changeHelper.AddOriginalElement(originalIndex + 1, modifiedIndex + 1);
  2730. diagonalRelative = (diagonal + 1) - diagonalReverseBase; //Setup for the next iteration
  2731. }
  2732. else {
  2733. // Vertical line (the element is an insertion)
  2734. originalIndex = reversePoints[diagonal - 1];
  2735. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  2736. if (originalIndex > lastOriginalIndex) {
  2737. changeHelper.MarkNextChange();
  2738. }
  2739. lastOriginalIndex = originalIndex;
  2740. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex + 1);
  2741. diagonalRelative = (diagonal - 1) - diagonalReverseBase; //Setup for the next iteration
  2742. }
  2743. if (historyIndex >= 0) {
  2744. reversePoints = this.m_reverseHistory[historyIndex];
  2745. diagonalReverseBase = reversePoints[0]; //We stored this in the first spot
  2746. diagonalMin = 1;
  2747. diagonalMax = reversePoints.length - 1;
  2748. }
  2749. } while (--historyIndex >= -1);
  2750. // There are cases where the reverse history will find diffs that
  2751. // are correct, but not intuitive, so we need shift them.
  2752. reverseChanges = changeHelper.getChanges();
  2753. }
  2754. return this.ConcatenateChanges(forwardChanges, reverseChanges);
  2755. };
  2756. /**
  2757. * Given the range to compute the diff on, this method finds the point:
  2758. * (midOriginal, midModified)
  2759. * that exists in the middle of the LCS of the two sequences and
  2760. * is the point at which the LCS problem may be broken down recursively.
  2761. * This method will try to keep the LCS trace in memory. If the LCS recursion
  2762. * point is calculated and the full trace is available in memory, then this method
  2763. * will return the change list.
  2764. * @param originalStart The start bound of the original sequence range
  2765. * @param originalEnd The end bound of the original sequence range
  2766. * @param modifiedStart The start bound of the modified sequence range
  2767. * @param modifiedEnd The end bound of the modified sequence range
  2768. * @param midOriginal The middle point of the original sequence range
  2769. * @param midModified The middle point of the modified sequence range
  2770. * @returns The diff changes, if available, otherwise null
  2771. */
  2772. LcsDiff.prototype.ComputeRecursionPoint = function (originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr) {
  2773. var originalIndex = 0, modifiedIndex = 0;
  2774. var diagonalForwardStart = 0, diagonalForwardEnd = 0;
  2775. var diagonalReverseStart = 0, diagonalReverseEnd = 0;
  2776. // To traverse the edit graph and produce the proper LCS, our actual
  2777. // start position is just outside the given boundary
  2778. originalStart--;
  2779. modifiedStart--;
  2780. // We set these up to make the compiler happy, but they will
  2781. // be replaced before we return with the actual recursion point
  2782. midOriginalArr[0] = 0;
  2783. midModifiedArr[0] = 0;
  2784. // Clear out the history
  2785. this.m_forwardHistory = [];
  2786. this.m_reverseHistory = [];
  2787. // Each cell in the two arrays corresponds to a diagonal in the edit graph.
  2788. // The integer value in the cell represents the originalIndex of the furthest
  2789. // reaching point found so far that ends in that diagonal.
  2790. // The modifiedIndex can be computed mathematically from the originalIndex and the diagonal number.
  2791. var maxDifferences = (originalEnd - originalStart) + (modifiedEnd - modifiedStart);
  2792. var numDiagonals = maxDifferences + 1;
  2793. var forwardPoints = new Int32Array(numDiagonals);
  2794. var reversePoints = new Int32Array(numDiagonals);
  2795. // diagonalForwardBase: Index into forwardPoints of the diagonal which passes through (originalStart, modifiedStart)
  2796. // diagonalReverseBase: Index into reversePoints of the diagonal which passes through (originalEnd, modifiedEnd)
  2797. var diagonalForwardBase = (modifiedEnd - modifiedStart);
  2798. var diagonalReverseBase = (originalEnd - originalStart);
  2799. // diagonalForwardOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  2800. // diagonal number (relative to diagonalForwardBase)
  2801. // diagonalReverseOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  2802. // diagonal number (relative to diagonalReverseBase)
  2803. var diagonalForwardOffset = (originalStart - modifiedStart);
  2804. var diagonalReverseOffset = (originalEnd - modifiedEnd);
  2805. // delta: The difference between the end diagonal and the start diagonal. This is used to relate diagonal numbers
  2806. // relative to the start diagonal with diagonal numbers relative to the end diagonal.
  2807. // The Even/Oddn-ness of this delta is important for determining when we should check for overlap
  2808. var delta = diagonalReverseBase - diagonalForwardBase;
  2809. var deltaIsEven = (delta % 2 === 0);
  2810. // Here we set up the start and end points as the furthest points found so far
  2811. // in both the forward and reverse directions, respectively
  2812. forwardPoints[diagonalForwardBase] = originalStart;
  2813. reversePoints[diagonalReverseBase] = originalEnd;
  2814. // Remember if we quit early, and thus need to do a best-effort result instead of a real result.
  2815. quitEarlyArr[0] = false;
  2816. // A couple of points:
  2817. // --With this method, we iterate on the number of differences between the two sequences.
  2818. // The more differences there actually are, the longer this will take.
  2819. // --Also, as the number of differences increases, we have to search on diagonals further
  2820. // away from the reference diagonal (which is diagonalForwardBase for forward, diagonalReverseBase for reverse).
  2821. // --We extend on even diagonals (relative to the reference diagonal) only when numDifferences
  2822. // is even and odd diagonals only when numDifferences is odd.
  2823. for (var numDifferences = 1; numDifferences <= (maxDifferences / 2) + 1; numDifferences++) {
  2824. var furthestOriginalIndex = 0;
  2825. var furthestModifiedIndex = 0;
  2826. // Run the algorithm in the forward direction
  2827. diagonalForwardStart = this.ClipDiagonalBound(diagonalForwardBase - numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  2828. diagonalForwardEnd = this.ClipDiagonalBound(diagonalForwardBase + numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  2829. for (var diagonal = diagonalForwardStart; diagonal <= diagonalForwardEnd; diagonal += 2) {
  2830. // STEP 1: We extend the furthest reaching point in the present diagonal
  2831. // by looking at the diagonals above and below and picking the one whose point
  2832. // is further away from the start point (originalStart, modifiedStart)
  2833. if (diagonal === diagonalForwardStart || (diagonal < diagonalForwardEnd && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  2834. originalIndex = forwardPoints[diagonal + 1];
  2835. }
  2836. else {
  2837. originalIndex = forwardPoints[diagonal - 1] + 1;
  2838. }
  2839. modifiedIndex = originalIndex - (diagonal - diagonalForwardBase) - diagonalForwardOffset;
  2840. // Save the current originalIndex so we can test for false overlap in step 3
  2841. var tempOriginalIndex = originalIndex;
  2842. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  2843. // so long as the elements are equal.
  2844. while (originalIndex < originalEnd && modifiedIndex < modifiedEnd && this.ElementsAreEqual(originalIndex + 1, modifiedIndex + 1)) {
  2845. originalIndex++;
  2846. modifiedIndex++;
  2847. }
  2848. forwardPoints[diagonal] = originalIndex;
  2849. if (originalIndex + modifiedIndex > furthestOriginalIndex + furthestModifiedIndex) {
  2850. furthestOriginalIndex = originalIndex;
  2851. furthestModifiedIndex = modifiedIndex;
  2852. }
  2853. // STEP 3: If delta is odd (overlap first happens on forward when delta is odd)
  2854. // and diagonal is in the range of reverse diagonals computed for numDifferences-1
  2855. // (the previous iteration; we haven't computed reverse diagonals for numDifferences yet)
  2856. // then check for overlap.
  2857. if (!deltaIsEven && Math.abs(diagonal - diagonalReverseBase) <= (numDifferences - 1)) {
  2858. if (originalIndex >= reversePoints[diagonal]) {
  2859. midOriginalArr[0] = originalIndex;
  2860. midModifiedArr[0] = modifiedIndex;
  2861. if (tempOriginalIndex <= reversePoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2862. // BINGO! We overlapped, and we have the full trace in memory!
  2863. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2864. }
  2865. else {
  2866. // Either false overlap, or we didn't have enough memory for the full trace
  2867. // Just return the recursion point
  2868. return null;
  2869. }
  2870. }
  2871. }
  2872. }
  2873. // Check to see if we should be quitting early, before moving on to the next iteration.
  2874. var matchLengthOfLongest = ((furthestOriginalIndex - originalStart) + (furthestModifiedIndex - modifiedStart) - numDifferences) / 2;
  2875. if (this.ContinueProcessingPredicate !== null && !this.ContinueProcessingPredicate(furthestOriginalIndex, matchLengthOfLongest)) {
  2876. // We can't finish, so skip ahead to generating a result from what we have.
  2877. quitEarlyArr[0] = true;
  2878. // Use the furthest distance we got in the forward direction.
  2879. midOriginalArr[0] = furthestOriginalIndex;
  2880. midModifiedArr[0] = furthestModifiedIndex;
  2881. if (matchLengthOfLongest > 0 && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2882. // Enough of the history is in memory to walk it backwards
  2883. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2884. }
  2885. else {
  2886. // We didn't actually remember enough of the history.
  2887. //Since we are quiting the diff early, we need to shift back the originalStart and modified start
  2888. //back into the boundary limits since we decremented their value above beyond the boundary limit.
  2889. originalStart++;
  2890. modifiedStart++;
  2891. return [
  2892. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  2893. ];
  2894. }
  2895. }
  2896. // Run the algorithm in the reverse direction
  2897. diagonalReverseStart = this.ClipDiagonalBound(diagonalReverseBase - numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  2898. diagonalReverseEnd = this.ClipDiagonalBound(diagonalReverseBase + numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  2899. for (var diagonal = diagonalReverseStart; diagonal <= diagonalReverseEnd; diagonal += 2) {
  2900. // STEP 1: We extend the furthest reaching point in the present diagonal
  2901. // by looking at the diagonals above and below and picking the one whose point
  2902. // is further away from the start point (originalEnd, modifiedEnd)
  2903. if (diagonal === diagonalReverseStart || (diagonal < diagonalReverseEnd && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  2904. originalIndex = reversePoints[diagonal + 1] - 1;
  2905. }
  2906. else {
  2907. originalIndex = reversePoints[diagonal - 1];
  2908. }
  2909. modifiedIndex = originalIndex - (diagonal - diagonalReverseBase) - diagonalReverseOffset;
  2910. // Save the current originalIndex so we can test for false overlap
  2911. var tempOriginalIndex = originalIndex;
  2912. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  2913. // as long as the elements are equal.
  2914. while (originalIndex > originalStart && modifiedIndex > modifiedStart && this.ElementsAreEqual(originalIndex, modifiedIndex)) {
  2915. originalIndex--;
  2916. modifiedIndex--;
  2917. }
  2918. reversePoints[diagonal] = originalIndex;
  2919. // STEP 4: If delta is even (overlap first happens on reverse when delta is even)
  2920. // and diagonal is in the range of forward diagonals computed for numDifferences
  2921. // then check for overlap.
  2922. if (deltaIsEven && Math.abs(diagonal - diagonalForwardBase) <= numDifferences) {
  2923. if (originalIndex <= forwardPoints[diagonal]) {
  2924. midOriginalArr[0] = originalIndex;
  2925. midModifiedArr[0] = modifiedIndex;
  2926. if (tempOriginalIndex >= forwardPoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2927. // BINGO! We overlapped, and we have the full trace in memory!
  2928. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2929. }
  2930. else {
  2931. // Either false overlap, or we didn't have enough memory for the full trace
  2932. // Just return the recursion point
  2933. return null;
  2934. }
  2935. }
  2936. }
  2937. }
  2938. // Save current vectors to history before the next iteration
  2939. if (numDifferences <= 1447 /* MaxDifferencesHistory */) {
  2940. // We are allocating space for one extra int, which we fill with
  2941. // the index of the diagonal base index
  2942. var temp = new Int32Array(diagonalForwardEnd - diagonalForwardStart + 2);
  2943. temp[0] = diagonalForwardBase - diagonalForwardStart + 1;
  2944. MyArray.Copy2(forwardPoints, diagonalForwardStart, temp, 1, diagonalForwardEnd - diagonalForwardStart + 1);
  2945. this.m_forwardHistory.push(temp);
  2946. temp = new Int32Array(diagonalReverseEnd - diagonalReverseStart + 2);
  2947. temp[0] = diagonalReverseBase - diagonalReverseStart + 1;
  2948. MyArray.Copy2(reversePoints, diagonalReverseStart, temp, 1, diagonalReverseEnd - diagonalReverseStart + 1);
  2949. this.m_reverseHistory.push(temp);
  2950. }
  2951. }
  2952. // If we got here, then we have the full trace in history. We just have to convert it to a change list
  2953. // NOTE: This part is a bit messy
  2954. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2955. };
  2956. /**
  2957. * Shifts the given changes to provide a more intuitive diff.
  2958. * While the first element in a diff matches the first element after the diff,
  2959. * we shift the diff down.
  2960. *
  2961. * @param changes The list of changes to shift
  2962. * @returns The shifted changes
  2963. */
  2964. LcsDiff.prototype.PrettifyChanges = function (changes) {
  2965. // Shift all the changes down first
  2966. for (var i = 0; i < changes.length; i++) {
  2967. var change = changes[i];
  2968. var originalStop = (i < changes.length - 1) ? changes[i + 1].originalStart : this._originalElementsOrHash.length;
  2969. var modifiedStop = (i < changes.length - 1) ? changes[i + 1].modifiedStart : this._modifiedElementsOrHash.length;
  2970. var checkOriginal = change.originalLength > 0;
  2971. var checkModified = change.modifiedLength > 0;
  2972. while (change.originalStart + change.originalLength < originalStop &&
  2973. change.modifiedStart + change.modifiedLength < modifiedStop &&
  2974. (!checkOriginal || this.OriginalElementsAreEqual(change.originalStart, change.originalStart + change.originalLength)) &&
  2975. (!checkModified || this.ModifiedElementsAreEqual(change.modifiedStart, change.modifiedStart + change.modifiedLength))) {
  2976. change.originalStart++;
  2977. change.modifiedStart++;
  2978. }
  2979. var mergedChangeArr = [null];
  2980. if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
  2981. changes[i] = mergedChangeArr[0];
  2982. changes.splice(i + 1, 1);
  2983. i--;
  2984. continue;
  2985. }
  2986. }
  2987. // Shift changes back up until we hit empty or whitespace-only lines
  2988. for (var i = changes.length - 1; i >= 0; i--) {
  2989. var change = changes[i];
  2990. var originalStop = 0;
  2991. var modifiedStop = 0;
  2992. if (i > 0) {
  2993. var prevChange = changes[i - 1];
  2994. if (prevChange.originalLength > 0) {
  2995. originalStop = prevChange.originalStart + prevChange.originalLength;
  2996. }
  2997. if (prevChange.modifiedLength > 0) {
  2998. modifiedStop = prevChange.modifiedStart + prevChange.modifiedLength;
  2999. }
  3000. }
  3001. var checkOriginal = change.originalLength > 0;
  3002. var checkModified = change.modifiedLength > 0;
  3003. var bestDelta = 0;
  3004. var bestScore = this._boundaryScore(change.originalStart, change.originalLength, change.modifiedStart, change.modifiedLength);
  3005. for (var delta = 1;; delta++) {
  3006. var originalStart = change.originalStart - delta;
  3007. var modifiedStart = change.modifiedStart - delta;
  3008. if (originalStart < originalStop || modifiedStart < modifiedStop) {
  3009. break;
  3010. }
  3011. if (checkOriginal && !this.OriginalElementsAreEqual(originalStart, originalStart + change.originalLength)) {
  3012. break;
  3013. }
  3014. if (checkModified && !this.ModifiedElementsAreEqual(modifiedStart, modifiedStart + change.modifiedLength)) {
  3015. break;
  3016. }
  3017. var score = this._boundaryScore(originalStart, change.originalLength, modifiedStart, change.modifiedLength);
  3018. if (score > bestScore) {
  3019. bestScore = score;
  3020. bestDelta = delta;
  3021. }
  3022. }
  3023. change.originalStart -= bestDelta;
  3024. change.modifiedStart -= bestDelta;
  3025. }
  3026. return changes;
  3027. };
  3028. LcsDiff.prototype._OriginalIsBoundary = function (index) {
  3029. if (index <= 0 || index >= this._originalElementsOrHash.length - 1) {
  3030. return true;
  3031. }
  3032. return (this._hasStrings && /^\s*$/.test(this._originalStringElements[index]));
  3033. };
  3034. LcsDiff.prototype._OriginalRegionIsBoundary = function (originalStart, originalLength) {
  3035. if (this._OriginalIsBoundary(originalStart) || this._OriginalIsBoundary(originalStart - 1)) {
  3036. return true;
  3037. }
  3038. if (originalLength > 0) {
  3039. var originalEnd = originalStart + originalLength;
  3040. if (this._OriginalIsBoundary(originalEnd - 1) || this._OriginalIsBoundary(originalEnd)) {
  3041. return true;
  3042. }
  3043. }
  3044. return false;
  3045. };
  3046. LcsDiff.prototype._ModifiedIsBoundary = function (index) {
  3047. if (index <= 0 || index >= this._modifiedElementsOrHash.length - 1) {
  3048. return true;
  3049. }
  3050. return (this._hasStrings && /^\s*$/.test(this._modifiedStringElements[index]));
  3051. };
  3052. LcsDiff.prototype._ModifiedRegionIsBoundary = function (modifiedStart, modifiedLength) {
  3053. if (this._ModifiedIsBoundary(modifiedStart) || this._ModifiedIsBoundary(modifiedStart - 1)) {
  3054. return true;
  3055. }
  3056. if (modifiedLength > 0) {
  3057. var modifiedEnd = modifiedStart + modifiedLength;
  3058. if (this._ModifiedIsBoundary(modifiedEnd - 1) || this._ModifiedIsBoundary(modifiedEnd)) {
  3059. return true;
  3060. }
  3061. }
  3062. return false;
  3063. };
  3064. LcsDiff.prototype._boundaryScore = function (originalStart, originalLength, modifiedStart, modifiedLength) {
  3065. var originalScore = (this._OriginalRegionIsBoundary(originalStart, originalLength) ? 1 : 0);
  3066. var modifiedScore = (this._ModifiedRegionIsBoundary(modifiedStart, modifiedLength) ? 1 : 0);
  3067. return (originalScore + modifiedScore);
  3068. };
  3069. /**
  3070. * Concatenates the two input DiffChange lists and returns the resulting
  3071. * list.
  3072. * @param The left changes
  3073. * @param The right changes
  3074. * @returns The concatenated list
  3075. */
  3076. LcsDiff.prototype.ConcatenateChanges = function (left, right) {
  3077. var mergedChangeArr = [];
  3078. if (left.length === 0 || right.length === 0) {
  3079. return (right.length > 0) ? right : left;
  3080. }
  3081. else if (this.ChangesOverlap(left[left.length - 1], right[0], mergedChangeArr)) {
  3082. // Since we break the problem down recursively, it is possible that we
  3083. // might recurse in the middle of a change thereby splitting it into
  3084. // two changes. Here in the combining stage, we detect and fuse those
  3085. // changes back together
  3086. var result = new Array(left.length + right.length - 1);
  3087. MyArray.Copy(left, 0, result, 0, left.length - 1);
  3088. result[left.length - 1] = mergedChangeArr[0];
  3089. MyArray.Copy(right, 1, result, left.length, right.length - 1);
  3090. return result;
  3091. }
  3092. else {
  3093. var result = new Array(left.length + right.length);
  3094. MyArray.Copy(left, 0, result, 0, left.length);
  3095. MyArray.Copy(right, 0, result, left.length, right.length);
  3096. return result;
  3097. }
  3098. };
  3099. /**
  3100. * Returns true if the two changes overlap and can be merged into a single
  3101. * change
  3102. * @param left The left change
  3103. * @param right The right change
  3104. * @param mergedChange The merged change if the two overlap, null otherwise
  3105. * @returns True if the two changes overlap
  3106. */
  3107. LcsDiff.prototype.ChangesOverlap = function (left, right, mergedChangeArr) {
  3108. Debug.Assert(left.originalStart <= right.originalStart, 'Left change is not less than or equal to right change');
  3109. Debug.Assert(left.modifiedStart <= right.modifiedStart, 'Left change is not less than or equal to right change');
  3110. if (left.originalStart + left.originalLength >= right.originalStart || left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  3111. var originalStart = left.originalStart;
  3112. var originalLength = left.originalLength;
  3113. var modifiedStart = left.modifiedStart;
  3114. var modifiedLength = left.modifiedLength;
  3115. if (left.originalStart + left.originalLength >= right.originalStart) {
  3116. originalLength = right.originalStart + right.originalLength - left.originalStart;
  3117. }
  3118. if (left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  3119. modifiedLength = right.modifiedStart + right.modifiedLength - left.modifiedStart;
  3120. }
  3121. mergedChangeArr[0] = new diffChange_1.DiffChange(originalStart, originalLength, modifiedStart, modifiedLength);
  3122. return true;
  3123. }
  3124. else {
  3125. mergedChangeArr[0] = null;
  3126. return false;
  3127. }
  3128. };
  3129. /**
  3130. * Helper method used to clip a diagonal index to the range of valid
  3131. * diagonals. This also decides whether or not the diagonal index,
  3132. * if it exceeds the boundary, should be clipped to the boundary or clipped
  3133. * one inside the boundary depending on the Even/Odd status of the boundary
  3134. * and numDifferences.
  3135. * @param diagonal The index of the diagonal to clip.
  3136. * @param numDifferences The current number of differences being iterated upon.
  3137. * @param diagonalBaseIndex The base reference diagonal.
  3138. * @param numDiagonals The total number of diagonals.
  3139. * @returns The clipped diagonal index.
  3140. */
  3141. LcsDiff.prototype.ClipDiagonalBound = function (diagonal, numDifferences, diagonalBaseIndex, numDiagonals) {
  3142. if (diagonal >= 0 && diagonal < numDiagonals) {
  3143. // Nothing to clip, its in range
  3144. return diagonal;
  3145. }
  3146. // diagonalsBelow: The number of diagonals below the reference diagonal
  3147. // diagonalsAbove: The number of diagonals above the reference diagonal
  3148. var diagonalsBelow = diagonalBaseIndex;
  3149. var diagonalsAbove = numDiagonals - diagonalBaseIndex - 1;
  3150. var diffEven = (numDifferences % 2 === 0);
  3151. if (diagonal < 0) {
  3152. var lowerBoundEven = (diagonalsBelow % 2 === 0);
  3153. return (diffEven === lowerBoundEven) ? 0 : 1;
  3154. }
  3155. else {
  3156. var upperBoundEven = (diagonalsAbove % 2 === 0);
  3157. return (diffEven === upperBoundEven) ? numDiagonals - 1 : numDiagonals - 2;
  3158. }
  3159. };
  3160. return LcsDiff;
  3161. }());
  3162. exports.LcsDiff = LcsDiff;
  3163. });
  3164. /*---------------------------------------------------------------------------------------------
  3165. * Copyright (c) Microsoft Corporation. All rights reserved.
  3166. * Licensed under the MIT License. See License.txt in the project root for license information.
  3167. *--------------------------------------------------------------------------------------------*/
  3168. var __extends = (this && this.__extends) || (function () {
  3169. var extendStatics = function (d, b) {
  3170. extendStatics = Object.setPrototypeOf ||
  3171. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3172. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3173. return extendStatics(d, b);
  3174. };
  3175. return function (d, b) {
  3176. extendStatics(d, b);
  3177. function __() { this.constructor = d; }
  3178. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3179. };
  3180. })();
  3181. define(__m[7/*vs/base/common/iterator*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3182. "use strict";
  3183. Object.defineProperty(exports, "__esModule", { value: true });
  3184. exports.FIN = { done: true, value: undefined };
  3185. var Iterator;
  3186. (function (Iterator) {
  3187. var _empty = {
  3188. next: function () {
  3189. return exports.FIN;
  3190. }
  3191. };
  3192. function empty() {
  3193. return _empty;
  3194. }
  3195. Iterator.empty = empty;
  3196. function single(value) {
  3197. var done = false;
  3198. return {
  3199. next: function () {
  3200. if (done) {
  3201. return exports.FIN;
  3202. }
  3203. done = true;
  3204. return { done: false, value: value };
  3205. }
  3206. };
  3207. }
  3208. Iterator.single = single;
  3209. function fromArray(array, index, length) {
  3210. if (index === void 0) { index = 0; }
  3211. if (length === void 0) { length = array.length; }
  3212. return {
  3213. next: function () {
  3214. if (index >= length) {
  3215. return exports.FIN;
  3216. }
  3217. return { done: false, value: array[index++] };
  3218. }
  3219. };
  3220. }
  3221. Iterator.fromArray = fromArray;
  3222. function fromNativeIterator(it) {
  3223. return {
  3224. next: function () {
  3225. var result = it.next();
  3226. if (result.done) {
  3227. return exports.FIN;
  3228. }
  3229. return { done: false, value: result.value };
  3230. }
  3231. };
  3232. }
  3233. Iterator.fromNativeIterator = fromNativeIterator;
  3234. function from(elements) {
  3235. if (!elements) {
  3236. return Iterator.empty();
  3237. }
  3238. else if (Array.isArray(elements)) {
  3239. return Iterator.fromArray(elements);
  3240. }
  3241. else {
  3242. return elements;
  3243. }
  3244. }
  3245. Iterator.from = from;
  3246. function map(iterator, fn) {
  3247. return {
  3248. next: function () {
  3249. var element = iterator.next();
  3250. if (element.done) {
  3251. return exports.FIN;
  3252. }
  3253. else {
  3254. return { done: false, value: fn(element.value) };
  3255. }
  3256. }
  3257. };
  3258. }
  3259. Iterator.map = map;
  3260. function filter(iterator, fn) {
  3261. return {
  3262. next: function () {
  3263. while (true) {
  3264. var element = iterator.next();
  3265. if (element.done) {
  3266. return exports.FIN;
  3267. }
  3268. if (fn(element.value)) {
  3269. return { done: false, value: element.value };
  3270. }
  3271. }
  3272. }
  3273. };
  3274. }
  3275. Iterator.filter = filter;
  3276. function forEach(iterator, fn) {
  3277. for (var next = iterator.next(); !next.done; next = iterator.next()) {
  3278. fn(next.value);
  3279. }
  3280. }
  3281. Iterator.forEach = forEach;
  3282. function collect(iterator, atMost) {
  3283. if (atMost === void 0) { atMost = Number.POSITIVE_INFINITY; }
  3284. var result = [];
  3285. if (atMost === 0) {
  3286. return result;
  3287. }
  3288. var i = 0;
  3289. for (var next = iterator.next(); !next.done; next = iterator.next()) {
  3290. result.push(next.value);
  3291. if (++i >= atMost) {
  3292. break;
  3293. }
  3294. }
  3295. return result;
  3296. }
  3297. Iterator.collect = collect;
  3298. function concat() {
  3299. var iterators = [];
  3300. for (var _i = 0; _i < arguments.length; _i++) {
  3301. iterators[_i] = arguments[_i];
  3302. }
  3303. var i = 0;
  3304. return {
  3305. next: function () {
  3306. if (i >= iterators.length) {
  3307. return exports.FIN;
  3308. }
  3309. var iterator = iterators[i];
  3310. var result = iterator.next();
  3311. if (result.done) {
  3312. i++;
  3313. return this.next();
  3314. }
  3315. return result;
  3316. }
  3317. };
  3318. }
  3319. Iterator.concat = concat;
  3320. function chain(iterator) {
  3321. return new ChainableIterator(iterator);
  3322. }
  3323. Iterator.chain = chain;
  3324. })(Iterator = exports.Iterator || (exports.Iterator = {}));
  3325. var ChainableIterator = /** @class */ (function () {
  3326. function ChainableIterator(it) {
  3327. this.it = it;
  3328. }
  3329. ChainableIterator.prototype.next = function () { return this.it.next(); };
  3330. return ChainableIterator;
  3331. }());
  3332. exports.ChainableIterator = ChainableIterator;
  3333. function getSequenceIterator(arg) {
  3334. if (Array.isArray(arg)) {
  3335. return Iterator.fromArray(arg);
  3336. }
  3337. else if (!arg) {
  3338. return Iterator.empty();
  3339. }
  3340. else {
  3341. return arg;
  3342. }
  3343. }
  3344. exports.getSequenceIterator = getSequenceIterator;
  3345. var ArrayIterator = /** @class */ (function () {
  3346. function ArrayIterator(items, start, end, index) {
  3347. if (start === void 0) { start = 0; }
  3348. if (end === void 0) { end = items.length; }
  3349. if (index === void 0) { index = start - 1; }
  3350. this.items = items;
  3351. this.start = start;
  3352. this.end = end;
  3353. this.index = index;
  3354. }
  3355. ArrayIterator.prototype.first = function () {
  3356. this.index = this.start;
  3357. return this.current();
  3358. };
  3359. ArrayIterator.prototype.next = function () {
  3360. this.index = Math.min(this.index + 1, this.end);
  3361. return this.current();
  3362. };
  3363. ArrayIterator.prototype.current = function () {
  3364. if (this.index === this.start - 1 || this.index === this.end) {
  3365. return null;
  3366. }
  3367. return this.items[this.index];
  3368. };
  3369. return ArrayIterator;
  3370. }());
  3371. exports.ArrayIterator = ArrayIterator;
  3372. var ArrayNavigator = /** @class */ (function (_super) {
  3373. __extends(ArrayNavigator, _super);
  3374. function ArrayNavigator(items, start, end, index) {
  3375. if (start === void 0) { start = 0; }
  3376. if (end === void 0) { end = items.length; }
  3377. if (index === void 0) { index = start - 1; }
  3378. return _super.call(this, items, start, end, index) || this;
  3379. }
  3380. ArrayNavigator.prototype.current = function () {
  3381. return _super.prototype.current.call(this);
  3382. };
  3383. ArrayNavigator.prototype.previous = function () {
  3384. this.index = Math.max(this.index - 1, this.start - 1);
  3385. return this.current();
  3386. };
  3387. ArrayNavigator.prototype.first = function () {
  3388. this.index = this.start;
  3389. return this.current();
  3390. };
  3391. ArrayNavigator.prototype.last = function () {
  3392. this.index = this.end - 1;
  3393. return this.current();
  3394. };
  3395. ArrayNavigator.prototype.parent = function () {
  3396. return null;
  3397. };
  3398. return ArrayNavigator;
  3399. }(ArrayIterator));
  3400. exports.ArrayNavigator = ArrayNavigator;
  3401. var MappedIterator = /** @class */ (function () {
  3402. function MappedIterator(iterator, fn) {
  3403. this.iterator = iterator;
  3404. this.fn = fn;
  3405. // noop
  3406. }
  3407. MappedIterator.prototype.next = function () { return this.fn(this.iterator.next()); };
  3408. return MappedIterator;
  3409. }());
  3410. exports.MappedIterator = MappedIterator;
  3411. });
  3412. /*---------------------------------------------------------------------------------------------
  3413. * Copyright (c) Microsoft Corporation. All rights reserved.
  3414. * Licensed under the MIT License. See License.txt in the project root for license information.
  3415. *--------------------------------------------------------------------------------------------*/
  3416. define(__m[17/*vs/base/common/keyCodes*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/errors*/]), function (require, exports, errors_1) {
  3417. "use strict";
  3418. Object.defineProperty(exports, "__esModule", { value: true });
  3419. var KeyCodeStrMap = /** @class */ (function () {
  3420. function KeyCodeStrMap() {
  3421. this._keyCodeToStr = [];
  3422. this._strToKeyCode = Object.create(null);
  3423. }
  3424. KeyCodeStrMap.prototype.define = function (keyCode, str) {
  3425. this._keyCodeToStr[keyCode] = str;
  3426. this._strToKeyCode[str.toLowerCase()] = keyCode;
  3427. };
  3428. KeyCodeStrMap.prototype.keyCodeToStr = function (keyCode) {
  3429. return this._keyCodeToStr[keyCode];
  3430. };
  3431. KeyCodeStrMap.prototype.strToKeyCode = function (str) {
  3432. return this._strToKeyCode[str.toLowerCase()] || 0 /* Unknown */;
  3433. };
  3434. return KeyCodeStrMap;
  3435. }());
  3436. var uiMap = new KeyCodeStrMap();
  3437. var userSettingsUSMap = new KeyCodeStrMap();
  3438. var userSettingsGeneralMap = new KeyCodeStrMap();
  3439. (function () {
  3440. function define(keyCode, uiLabel, usUserSettingsLabel, generalUserSettingsLabel) {
  3441. if (usUserSettingsLabel === void 0) { usUserSettingsLabel = uiLabel; }
  3442. if (generalUserSettingsLabel === void 0) { generalUserSettingsLabel = usUserSettingsLabel; }
  3443. uiMap.define(keyCode, uiLabel);
  3444. userSettingsUSMap.define(keyCode, usUserSettingsLabel);
  3445. userSettingsGeneralMap.define(keyCode, generalUserSettingsLabel);
  3446. }
  3447. define(0 /* Unknown */, 'unknown');
  3448. define(1 /* Backspace */, 'Backspace');
  3449. define(2 /* Tab */, 'Tab');
  3450. define(3 /* Enter */, 'Enter');
  3451. define(4 /* Shift */, 'Shift');
  3452. define(5 /* Ctrl */, 'Ctrl');
  3453. define(6 /* Alt */, 'Alt');
  3454. define(7 /* PauseBreak */, 'PauseBreak');
  3455. define(8 /* CapsLock */, 'CapsLock');
  3456. define(9 /* Escape */, 'Escape');
  3457. define(10 /* Space */, 'Space');
  3458. define(11 /* PageUp */, 'PageUp');
  3459. define(12 /* PageDown */, 'PageDown');
  3460. define(13 /* End */, 'End');
  3461. define(14 /* Home */, 'Home');
  3462. define(15 /* LeftArrow */, 'LeftArrow', 'Left');
  3463. define(16 /* UpArrow */, 'UpArrow', 'Up');
  3464. define(17 /* RightArrow */, 'RightArrow', 'Right');
  3465. define(18 /* DownArrow */, 'DownArrow', 'Down');
  3466. define(19 /* Insert */, 'Insert');
  3467. define(20 /* Delete */, 'Delete');
  3468. define(21 /* KEY_0 */, '0');
  3469. define(22 /* KEY_1 */, '1');
  3470. define(23 /* KEY_2 */, '2');
  3471. define(24 /* KEY_3 */, '3');
  3472. define(25 /* KEY_4 */, '4');
  3473. define(26 /* KEY_5 */, '5');
  3474. define(27 /* KEY_6 */, '6');
  3475. define(28 /* KEY_7 */, '7');
  3476. define(29 /* KEY_8 */, '8');
  3477. define(30 /* KEY_9 */, '9');
  3478. define(31 /* KEY_A */, 'A');
  3479. define(32 /* KEY_B */, 'B');
  3480. define(33 /* KEY_C */, 'C');
  3481. define(34 /* KEY_D */, 'D');
  3482. define(35 /* KEY_E */, 'E');
  3483. define(36 /* KEY_F */, 'F');
  3484. define(37 /* KEY_G */, 'G');
  3485. define(38 /* KEY_H */, 'H');
  3486. define(39 /* KEY_I */, 'I');
  3487. define(40 /* KEY_J */, 'J');
  3488. define(41 /* KEY_K */, 'K');
  3489. define(42 /* KEY_L */, 'L');
  3490. define(43 /* KEY_M */, 'M');
  3491. define(44 /* KEY_N */, 'N');
  3492. define(45 /* KEY_O */, 'O');
  3493. define(46 /* KEY_P */, 'P');
  3494. define(47 /* KEY_Q */, 'Q');
  3495. define(48 /* KEY_R */, 'R');
  3496. define(49 /* KEY_S */, 'S');
  3497. define(50 /* KEY_T */, 'T');
  3498. define(51 /* KEY_U */, 'U');
  3499. define(52 /* KEY_V */, 'V');
  3500. define(53 /* KEY_W */, 'W');
  3501. define(54 /* KEY_X */, 'X');
  3502. define(55 /* KEY_Y */, 'Y');
  3503. define(56 /* KEY_Z */, 'Z');
  3504. define(57 /* Meta */, 'Meta');
  3505. define(58 /* ContextMenu */, 'ContextMenu');
  3506. define(59 /* F1 */, 'F1');
  3507. define(60 /* F2 */, 'F2');
  3508. define(61 /* F3 */, 'F3');
  3509. define(62 /* F4 */, 'F4');
  3510. define(63 /* F5 */, 'F5');
  3511. define(64 /* F6 */, 'F6');
  3512. define(65 /* F7 */, 'F7');
  3513. define(66 /* F8 */, 'F8');
  3514. define(67 /* F9 */, 'F9');
  3515. define(68 /* F10 */, 'F10');
  3516. define(69 /* F11 */, 'F11');
  3517. define(70 /* F12 */, 'F12');
  3518. define(71 /* F13 */, 'F13');
  3519. define(72 /* F14 */, 'F14');
  3520. define(73 /* F15 */, 'F15');
  3521. define(74 /* F16 */, 'F16');
  3522. define(75 /* F17 */, 'F17');
  3523. define(76 /* F18 */, 'F18');
  3524. define(77 /* F19 */, 'F19');
  3525. define(78 /* NumLock */, 'NumLock');
  3526. define(79 /* ScrollLock */, 'ScrollLock');
  3527. define(80 /* US_SEMICOLON */, ';', ';', 'OEM_1');
  3528. define(81 /* US_EQUAL */, '=', '=', 'OEM_PLUS');
  3529. define(82 /* US_COMMA */, ',', ',', 'OEM_COMMA');
  3530. define(83 /* US_MINUS */, '-', '-', 'OEM_MINUS');
  3531. define(84 /* US_DOT */, '.', '.', 'OEM_PERIOD');
  3532. define(85 /* US_SLASH */, '/', '/', 'OEM_2');
  3533. define(86 /* US_BACKTICK */, '`', '`', 'OEM_3');
  3534. define(110 /* ABNT_C1 */, 'ABNT_C1');
  3535. define(111 /* ABNT_C2 */, 'ABNT_C2');
  3536. define(87 /* US_OPEN_SQUARE_BRACKET */, '[', '[', 'OEM_4');
  3537. define(88 /* US_BACKSLASH */, '\\', '\\', 'OEM_5');
  3538. define(89 /* US_CLOSE_SQUARE_BRACKET */, ']', ']', 'OEM_6');
  3539. define(90 /* US_QUOTE */, '\'', '\'', 'OEM_7');
  3540. define(91 /* OEM_8 */, 'OEM_8');
  3541. define(92 /* OEM_102 */, 'OEM_102');
  3542. define(93 /* NUMPAD_0 */, 'NumPad0');
  3543. define(94 /* NUMPAD_1 */, 'NumPad1');
  3544. define(95 /* NUMPAD_2 */, 'NumPad2');
  3545. define(96 /* NUMPAD_3 */, 'NumPad3');
  3546. define(97 /* NUMPAD_4 */, 'NumPad4');
  3547. define(98 /* NUMPAD_5 */, 'NumPad5');
  3548. define(99 /* NUMPAD_6 */, 'NumPad6');
  3549. define(100 /* NUMPAD_7 */, 'NumPad7');
  3550. define(101 /* NUMPAD_8 */, 'NumPad8');
  3551. define(102 /* NUMPAD_9 */, 'NumPad9');
  3552. define(103 /* NUMPAD_MULTIPLY */, 'NumPad_Multiply');
  3553. define(104 /* NUMPAD_ADD */, 'NumPad_Add');
  3554. define(105 /* NUMPAD_SEPARATOR */, 'NumPad_Separator');
  3555. define(106 /* NUMPAD_SUBTRACT */, 'NumPad_Subtract');
  3556. define(107 /* NUMPAD_DECIMAL */, 'NumPad_Decimal');
  3557. define(108 /* NUMPAD_DIVIDE */, 'NumPad_Divide');
  3558. })();
  3559. var KeyCodeUtils;
  3560. (function (KeyCodeUtils) {
  3561. function toString(keyCode) {
  3562. return uiMap.keyCodeToStr(keyCode);
  3563. }
  3564. KeyCodeUtils.toString = toString;
  3565. function fromString(key) {
  3566. return uiMap.strToKeyCode(key);
  3567. }
  3568. KeyCodeUtils.fromString = fromString;
  3569. function toUserSettingsUS(keyCode) {
  3570. return userSettingsUSMap.keyCodeToStr(keyCode);
  3571. }
  3572. KeyCodeUtils.toUserSettingsUS = toUserSettingsUS;
  3573. function toUserSettingsGeneral(keyCode) {
  3574. return userSettingsGeneralMap.keyCodeToStr(keyCode);
  3575. }
  3576. KeyCodeUtils.toUserSettingsGeneral = toUserSettingsGeneral;
  3577. function fromUserSettings(key) {
  3578. return userSettingsUSMap.strToKeyCode(key) || userSettingsGeneralMap.strToKeyCode(key);
  3579. }
  3580. KeyCodeUtils.fromUserSettings = fromUserSettings;
  3581. })(KeyCodeUtils = exports.KeyCodeUtils || (exports.KeyCodeUtils = {}));
  3582. function KeyChord(firstPart, secondPart) {
  3583. var chordPart = ((secondPart & 0x0000FFFF) << 16) >>> 0;
  3584. return (firstPart | chordPart) >>> 0;
  3585. }
  3586. exports.KeyChord = KeyChord;
  3587. function createKeybinding(keybinding, OS) {
  3588. if (keybinding === 0) {
  3589. return null;
  3590. }
  3591. var firstPart = (keybinding & 0x0000FFFF) >>> 0;
  3592. var chordPart = (keybinding & 0xFFFF0000) >>> 16;
  3593. if (chordPart !== 0) {
  3594. return new ChordKeybinding([
  3595. createSimpleKeybinding(firstPart, OS),
  3596. createSimpleKeybinding(chordPart, OS)
  3597. ]);
  3598. }
  3599. return new ChordKeybinding([createSimpleKeybinding(firstPart, OS)]);
  3600. }
  3601. exports.createKeybinding = createKeybinding;
  3602. function createSimpleKeybinding(keybinding, OS) {
  3603. var ctrlCmd = (keybinding & 2048 /* CtrlCmd */ ? true : false);
  3604. var winCtrl = (keybinding & 256 /* WinCtrl */ ? true : false);
  3605. var ctrlKey = (OS === 2 /* Macintosh */ ? winCtrl : ctrlCmd);
  3606. var shiftKey = (keybinding & 1024 /* Shift */ ? true : false);
  3607. var altKey = (keybinding & 512 /* Alt */ ? true : false);
  3608. var metaKey = (OS === 2 /* Macintosh */ ? ctrlCmd : winCtrl);
  3609. var keyCode = (keybinding & 255 /* KeyCode */);
  3610. return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, keyCode);
  3611. }
  3612. exports.createSimpleKeybinding = createSimpleKeybinding;
  3613. var SimpleKeybinding = /** @class */ (function () {
  3614. function SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, keyCode) {
  3615. this.ctrlKey = ctrlKey;
  3616. this.shiftKey = shiftKey;
  3617. this.altKey = altKey;
  3618. this.metaKey = metaKey;
  3619. this.keyCode = keyCode;
  3620. }
  3621. SimpleKeybinding.prototype.equals = function (other) {
  3622. return (this.ctrlKey === other.ctrlKey
  3623. && this.shiftKey === other.shiftKey
  3624. && this.altKey === other.altKey
  3625. && this.metaKey === other.metaKey
  3626. && this.keyCode === other.keyCode);
  3627. };
  3628. SimpleKeybinding.prototype.isModifierKey = function () {
  3629. return (this.keyCode === 0 /* Unknown */
  3630. || this.keyCode === 5 /* Ctrl */
  3631. || this.keyCode === 57 /* Meta */
  3632. || this.keyCode === 6 /* Alt */
  3633. || this.keyCode === 4 /* Shift */);
  3634. };
  3635. SimpleKeybinding.prototype.toChord = function () {
  3636. return new ChordKeybinding([this]);
  3637. };
  3638. /**
  3639. * Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
  3640. */
  3641. SimpleKeybinding.prototype.isDuplicateModifierCase = function () {
  3642. return ((this.ctrlKey && this.keyCode === 5 /* Ctrl */)
  3643. || (this.shiftKey && this.keyCode === 4 /* Shift */)
  3644. || (this.altKey && this.keyCode === 6 /* Alt */)
  3645. || (this.metaKey && this.keyCode === 57 /* Meta */));
  3646. };
  3647. return SimpleKeybinding;
  3648. }());
  3649. exports.SimpleKeybinding = SimpleKeybinding;
  3650. var ChordKeybinding = /** @class */ (function () {
  3651. function ChordKeybinding(parts) {
  3652. if (parts.length === 0) {
  3653. throw errors_1.illegalArgument("parts");
  3654. }
  3655. this.parts = parts;
  3656. }
  3657. ChordKeybinding.prototype.equals = function (other) {
  3658. if (other === null) {
  3659. return false;
  3660. }
  3661. if (this.parts.length !== other.parts.length) {
  3662. return false;
  3663. }
  3664. for (var i = 0; i < this.parts.length; i++) {
  3665. if (!this.parts[i].equals(other.parts[i])) {
  3666. return false;
  3667. }
  3668. }
  3669. return true;
  3670. };
  3671. return ChordKeybinding;
  3672. }());
  3673. exports.ChordKeybinding = ChordKeybinding;
  3674. var ResolvedKeybindingPart = /** @class */ (function () {
  3675. function ResolvedKeybindingPart(ctrlKey, shiftKey, altKey, metaKey, kbLabel, kbAriaLabel) {
  3676. this.ctrlKey = ctrlKey;
  3677. this.shiftKey = shiftKey;
  3678. this.altKey = altKey;
  3679. this.metaKey = metaKey;
  3680. this.keyLabel = kbLabel;
  3681. this.keyAriaLabel = kbAriaLabel;
  3682. }
  3683. return ResolvedKeybindingPart;
  3684. }());
  3685. exports.ResolvedKeybindingPart = ResolvedKeybindingPart;
  3686. /**
  3687. * A resolved keybinding. Can be a simple keybinding or a chord keybinding.
  3688. */
  3689. var ResolvedKeybinding = /** @class */ (function () {
  3690. function ResolvedKeybinding() {
  3691. }
  3692. return ResolvedKeybinding;
  3693. }());
  3694. exports.ResolvedKeybinding = ResolvedKeybinding;
  3695. });
  3696. define(__m[8/*vs/base/common/lifecycle*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3697. "use strict";
  3698. Object.defineProperty(exports, "__esModule", { value: true });
  3699. /**
  3700. * Enables logging of potentially leaked disposables.
  3701. *
  3702. * A disposable is considered leaked if it is not disposed or not registered as the child of
  3703. * another disposable. This tracking is very simple an only works for classes that either
  3704. * extend Disposable or use a DisposableStore. This means there are a lot of false positives.
  3705. */
  3706. var TRACK_DISPOSABLES = false;
  3707. var __is_disposable_tracked__ = '__is_disposable_tracked__';
  3708. function markTracked(x) {
  3709. if (!TRACK_DISPOSABLES) {
  3710. return;
  3711. }
  3712. if (x && x !== Disposable.None) {
  3713. try {
  3714. x[__is_disposable_tracked__] = true;
  3715. }
  3716. catch (_a) {
  3717. // noop
  3718. }
  3719. }
  3720. }
  3721. function trackDisposable(x) {
  3722. if (!TRACK_DISPOSABLES) {
  3723. return x;
  3724. }
  3725. var stack = new Error('Potentially leaked disposable').stack;
  3726. setTimeout(function () {
  3727. if (!x[__is_disposable_tracked__]) {
  3728. console.log(stack);
  3729. }
  3730. }, 3000);
  3731. return x;
  3732. }
  3733. function isDisposable(thing) {
  3734. return typeof thing.dispose === 'function'
  3735. && thing.dispose.length === 0;
  3736. }
  3737. exports.isDisposable = isDisposable;
  3738. function dispose(disposables) {
  3739. if (Array.isArray(disposables)) {
  3740. disposables.forEach(function (d) {
  3741. if (d) {
  3742. markTracked(d);
  3743. d.dispose();
  3744. }
  3745. });
  3746. return [];
  3747. }
  3748. else if (disposables) {
  3749. markTracked(disposables);
  3750. disposables.dispose();
  3751. return disposables;
  3752. }
  3753. else {
  3754. return undefined;
  3755. }
  3756. }
  3757. exports.dispose = dispose;
  3758. function combinedDisposable() {
  3759. var disposables = [];
  3760. for (var _i = 0; _i < arguments.length; _i++) {
  3761. disposables[_i] = arguments[_i];
  3762. }
  3763. disposables.forEach(markTracked);
  3764. return trackDisposable({ dispose: function () { return dispose(disposables); } });
  3765. }
  3766. exports.combinedDisposable = combinedDisposable;
  3767. function toDisposable(fn) {
  3768. var self = trackDisposable({
  3769. dispose: function () {
  3770. markTracked(self);
  3771. fn();
  3772. }
  3773. });
  3774. return self;
  3775. }
  3776. exports.toDisposable = toDisposable;
  3777. var DisposableStore = /** @class */ (function () {
  3778. function DisposableStore() {
  3779. this._toDispose = new Set();
  3780. this._isDisposed = false;
  3781. }
  3782. /**
  3783. * Dispose of all registered disposables and mark this object as disposed.
  3784. *
  3785. * Any future disposables added to this object will be disposed of on `add`.
  3786. */
  3787. DisposableStore.prototype.dispose = function () {
  3788. if (this._isDisposed) {
  3789. return;
  3790. }
  3791. markTracked(this);
  3792. this._isDisposed = true;
  3793. this.clear();
  3794. };
  3795. /**
  3796. * Dispose of all registered disposables but do not mark this object as disposed.
  3797. */
  3798. DisposableStore.prototype.clear = function () {
  3799. this._toDispose.forEach(function (item) { return item.dispose(); });
  3800. this._toDispose.clear();
  3801. };
  3802. DisposableStore.prototype.add = function (t) {
  3803. if (!t) {
  3804. return t;
  3805. }
  3806. if (t === this) {
  3807. throw new Error('Cannot register a disposable on itself!');
  3808. }
  3809. markTracked(t);
  3810. if (this._isDisposed) {
  3811. console.warn(new Error('Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!').stack);
  3812. }
  3813. else {
  3814. this._toDispose.add(t);
  3815. }
  3816. return t;
  3817. };
  3818. return DisposableStore;
  3819. }());
  3820. exports.DisposableStore = DisposableStore;
  3821. var Disposable = /** @class */ (function () {
  3822. function Disposable() {
  3823. this._store = new DisposableStore();
  3824. trackDisposable(this);
  3825. }
  3826. Disposable.prototype.dispose = function () {
  3827. markTracked(this);
  3828. this._store.dispose();
  3829. };
  3830. Disposable.prototype._register = function (t) {
  3831. if (t === this) {
  3832. throw new Error('Cannot register a disposable on itself!');
  3833. }
  3834. return this._store.add(t);
  3835. };
  3836. Disposable.None = Object.freeze({ dispose: function () { } });
  3837. return Disposable;
  3838. }());
  3839. exports.Disposable = Disposable;
  3840. /**
  3841. * Manages the lifecycle of a disposable value that may be changed.
  3842. *
  3843. * This ensures that when the disposable value is changed, the previously held disposable is disposed of. You can
  3844. * also register a `MutableDisposable` on a `Disposable` to ensure it is automatically cleaned up.
  3845. */
  3846. var MutableDisposable = /** @class */ (function () {
  3847. function MutableDisposable() {
  3848. this._isDisposed = false;
  3849. trackDisposable(this);
  3850. }
  3851. Object.defineProperty(MutableDisposable.prototype, "value", {
  3852. get: function () {
  3853. return this._isDisposed ? undefined : this._value;
  3854. },
  3855. set: function (value) {
  3856. if (this._isDisposed || value === this._value) {
  3857. return;
  3858. }
  3859. if (this._value) {
  3860. this._value.dispose();
  3861. }
  3862. if (value) {
  3863. markTracked(value);
  3864. }
  3865. this._value = value;
  3866. },
  3867. enumerable: true,
  3868. configurable: true
  3869. });
  3870. MutableDisposable.prototype.clear = function () {
  3871. this.value = undefined;
  3872. };
  3873. MutableDisposable.prototype.dispose = function () {
  3874. this._isDisposed = true;
  3875. markTracked(this);
  3876. if (this._value) {
  3877. this._value.dispose();
  3878. }
  3879. this._value = undefined;
  3880. };
  3881. return MutableDisposable;
  3882. }());
  3883. exports.MutableDisposable = MutableDisposable;
  3884. var ImmortalReference = /** @class */ (function () {
  3885. function ImmortalReference(object) {
  3886. this.object = object;
  3887. }
  3888. ImmortalReference.prototype.dispose = function () { };
  3889. return ImmortalReference;
  3890. }());
  3891. exports.ImmortalReference = ImmortalReference;
  3892. });
  3893. /*---------------------------------------------------------------------------------------------
  3894. * Copyright (c) Microsoft Corporation. All rights reserved.
  3895. * Licensed under the MIT License. See License.txt in the project root for license information.
  3896. *--------------------------------------------------------------------------------------------*/
  3897. define(__m[18/*vs/base/common/linkedList*/], __M([0/*require*/,1/*exports*/,7/*vs/base/common/iterator*/]), function (require, exports, iterator_1) {
  3898. "use strict";
  3899. Object.defineProperty(exports, "__esModule", { value: true });
  3900. var Node = /** @class */ (function () {
  3901. function Node(element) {
  3902. this.element = element;
  3903. this.next = Node.Undefined;
  3904. this.prev = Node.Undefined;
  3905. }
  3906. Node.Undefined = new Node(undefined);
  3907. return Node;
  3908. }());
  3909. var LinkedList = /** @class */ (function () {
  3910. function LinkedList() {
  3911. this._first = Node.Undefined;
  3912. this._last = Node.Undefined;
  3913. this._size = 0;
  3914. }
  3915. Object.defineProperty(LinkedList.prototype, "size", {
  3916. get: function () {
  3917. return this._size;
  3918. },
  3919. enumerable: true,
  3920. configurable: true
  3921. });
  3922. LinkedList.prototype.isEmpty = function () {
  3923. return this._first === Node.Undefined;
  3924. };
  3925. LinkedList.prototype.clear = function () {
  3926. this._first = Node.Undefined;
  3927. this._last = Node.Undefined;
  3928. this._size = 0;
  3929. };
  3930. LinkedList.prototype.unshift = function (element) {
  3931. return this._insert(element, false);
  3932. };
  3933. LinkedList.prototype.push = function (element) {
  3934. return this._insert(element, true);
  3935. };
  3936. LinkedList.prototype._insert = function (element, atTheEnd) {
  3937. var _this = this;
  3938. var newNode = new Node(element);
  3939. if (this._first === Node.Undefined) {
  3940. this._first = newNode;
  3941. this._last = newNode;
  3942. }
  3943. else if (atTheEnd) {
  3944. // push
  3945. var oldLast = this._last;
  3946. this._last = newNode;
  3947. newNode.prev = oldLast;
  3948. oldLast.next = newNode;
  3949. }
  3950. else {
  3951. // unshift
  3952. var oldFirst = this._first;
  3953. this._first = newNode;
  3954. newNode.next = oldFirst;
  3955. oldFirst.prev = newNode;
  3956. }
  3957. this._size += 1;
  3958. var didRemove = false;
  3959. return function () {
  3960. if (!didRemove) {
  3961. didRemove = true;
  3962. _this._remove(newNode);
  3963. }
  3964. };
  3965. };
  3966. LinkedList.prototype.shift = function () {
  3967. if (this._first === Node.Undefined) {
  3968. return undefined;
  3969. }
  3970. else {
  3971. var res = this._first.element;
  3972. this._remove(this._first);
  3973. return res;
  3974. }
  3975. };
  3976. LinkedList.prototype.pop = function () {
  3977. if (this._last === Node.Undefined) {
  3978. return undefined;
  3979. }
  3980. else {
  3981. var res = this._last.element;
  3982. this._remove(this._last);
  3983. return res;
  3984. }
  3985. };
  3986. LinkedList.prototype._remove = function (node) {
  3987. if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
  3988. // middle
  3989. var anchor = node.prev;
  3990. anchor.next = node.next;
  3991. node.next.prev = anchor;
  3992. }
  3993. else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
  3994. // only node
  3995. this._first = Node.Undefined;
  3996. this._last = Node.Undefined;
  3997. }
  3998. else if (node.next === Node.Undefined) {
  3999. // last
  4000. this._last = this._last.prev;
  4001. this._last.next = Node.Undefined;
  4002. }
  4003. else if (node.prev === Node.Undefined) {
  4004. // first
  4005. this._first = this._first.next;
  4006. this._first.prev = Node.Undefined;
  4007. }
  4008. // done
  4009. this._size -= 1;
  4010. };
  4011. LinkedList.prototype.iterator = function () {
  4012. var element;
  4013. var node = this._first;
  4014. return {
  4015. next: function () {
  4016. if (node === Node.Undefined) {
  4017. return iterator_1.FIN;
  4018. }
  4019. if (!element) {
  4020. element = { done: false, value: node.element };
  4021. }
  4022. else {
  4023. element.value = node.element;
  4024. }
  4025. node = node.next;
  4026. return element;
  4027. }
  4028. };
  4029. };
  4030. LinkedList.prototype.toArray = function () {
  4031. var result = [];
  4032. for (var node = this._first; node !== Node.Undefined; node = node.next) {
  4033. result.push(node.element);
  4034. }
  4035. return result;
  4036. };
  4037. return LinkedList;
  4038. }());
  4039. exports.LinkedList = LinkedList;
  4040. });
  4041. /*---------------------------------------------------------------------------------------------
  4042. * Copyright (c) Microsoft Corporation. All rights reserved.
  4043. * Licensed under the MIT License. See License.txt in the project root for license information.
  4044. *--------------------------------------------------------------------------------------------*/
  4045. define(__m[9/*vs/base/common/event*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/errors*/,15/*vs/base/common/functional*/,8/*vs/base/common/lifecycle*/,18/*vs/base/common/linkedList*/]), function (require, exports, errors_1, functional_1, lifecycle_1, linkedList_1) {
  4046. "use strict";
  4047. Object.defineProperty(exports, "__esModule", { value: true });
  4048. var Event;
  4049. (function (Event) {
  4050. Event.None = function () { return lifecycle_1.Disposable.None; };
  4051. /**
  4052. * Given an event, returns another event which only fires once.
  4053. */
  4054. function once(event) {
  4055. return function (listener, thisArgs, disposables) {
  4056. if (thisArgs === void 0) { thisArgs = null; }
  4057. // we need this, in case the event fires during the listener call
  4058. var didFire = false;
  4059. var result;
  4060. result = event(function (e) {
  4061. if (didFire) {
  4062. return;
  4063. }
  4064. else if (result) {
  4065. result.dispose();
  4066. }
  4067. else {
  4068. didFire = true;
  4069. }
  4070. return listener.call(thisArgs, e);
  4071. }, null, disposables);
  4072. if (didFire) {
  4073. result.dispose();
  4074. }
  4075. return result;
  4076. };
  4077. }
  4078. Event.once = once;
  4079. /**
  4080. * Given an event and a `map` function, returns another event which maps each element
  4081. * through the mapping function.
  4082. */
  4083. function map(event, map) {
  4084. return snapshot(function (listener, thisArgs, disposables) {
  4085. if (thisArgs === void 0) { thisArgs = null; }
  4086. return event(function (i) { return listener.call(thisArgs, map(i)); }, null, disposables);
  4087. });
  4088. }
  4089. Event.map = map;
  4090. /**
  4091. * Given an event and an `each` function, returns another identical event and calls
  4092. * the `each` function per each element.
  4093. */
  4094. function forEach(event, each) {
  4095. return snapshot(function (listener, thisArgs, disposables) {
  4096. if (thisArgs === void 0) { thisArgs = null; }
  4097. return event(function (i) { each(i); listener.call(thisArgs, i); }, null, disposables);
  4098. });
  4099. }
  4100. Event.forEach = forEach;
  4101. function filter(event, filter) {
  4102. return snapshot(function (listener, thisArgs, disposables) {
  4103. if (thisArgs === void 0) { thisArgs = null; }
  4104. return event(function (e) { return filter(e) && listener.call(thisArgs, e); }, null, disposables);
  4105. });
  4106. }
  4107. Event.filter = filter;
  4108. /**
  4109. * Given an event, returns the same event but typed as `Event<void>`.
  4110. */
  4111. function signal(event) {
  4112. return event;
  4113. }
  4114. Event.signal = signal;
  4115. /**
  4116. * Given a collection of events, returns a single event which emits
  4117. * whenever any of the provided events emit.
  4118. */
  4119. function any() {
  4120. var events = [];
  4121. for (var _i = 0; _i < arguments.length; _i++) {
  4122. events[_i] = arguments[_i];
  4123. }
  4124. return function (listener, thisArgs, disposables) {
  4125. if (thisArgs === void 0) { thisArgs = null; }
  4126. return lifecycle_1.combinedDisposable.apply(void 0, events.map(function (event) { return event(function (e) { return listener.call(thisArgs, e); }, null, disposables); }));
  4127. };
  4128. }
  4129. Event.any = any;
  4130. /**
  4131. * Given an event and a `merge` function, returns another event which maps each element
  4132. * and the cumulative result through the `merge` function. Similar to `map`, but with memory.
  4133. */
  4134. function reduce(event, merge, initial) {
  4135. var output = initial;
  4136. return map(event, function (e) {
  4137. output = merge(output, e);
  4138. return output;
  4139. });
  4140. }
  4141. Event.reduce = reduce;
  4142. /**
  4143. * Given a chain of event processing functions (filter, map, etc), each
  4144. * function will be invoked per event & per listener. Snapshotting an event
  4145. * chain allows each function to be invoked just once per event.
  4146. */
  4147. function snapshot(event) {
  4148. var listener;
  4149. var emitter = new Emitter({
  4150. onFirstListenerAdd: function () {
  4151. listener = event(emitter.fire, emitter);
  4152. },
  4153. onLastListenerRemove: function () {
  4154. listener.dispose();
  4155. }
  4156. });
  4157. return emitter.event;
  4158. }
  4159. Event.snapshot = snapshot;
  4160. function debounce(event, merge, delay, leading, leakWarningThreshold) {
  4161. if (delay === void 0) { delay = 100; }
  4162. if (leading === void 0) { leading = false; }
  4163. var subscription;
  4164. var output = undefined;
  4165. var handle = undefined;
  4166. var numDebouncedCalls = 0;
  4167. var emitter = new Emitter({
  4168. leakWarningThreshold: leakWarningThreshold,
  4169. onFirstListenerAdd: function () {
  4170. subscription = event(function (cur) {
  4171. numDebouncedCalls++;
  4172. output = merge(output, cur);
  4173. if (leading && !handle) {
  4174. emitter.fire(output);
  4175. output = undefined;
  4176. }
  4177. clearTimeout(handle);
  4178. handle = setTimeout(function () {
  4179. var _output = output;
  4180. output = undefined;
  4181. handle = undefined;
  4182. if (!leading || numDebouncedCalls > 1) {
  4183. emitter.fire(_output);
  4184. }
  4185. numDebouncedCalls = 0;
  4186. }, delay);
  4187. });
  4188. },
  4189. onLastListenerRemove: function () {
  4190. subscription.dispose();
  4191. }
  4192. });
  4193. return emitter.event;
  4194. }
  4195. Event.debounce = debounce;
  4196. /**
  4197. * Given an event, it returns another event which fires only once and as soon as
  4198. * the input event emits. The event data is the number of millis it took for the
  4199. * event to fire.
  4200. */
  4201. function stopwatch(event) {
  4202. var start = new Date().getTime();
  4203. return map(once(event), function (_) { return new Date().getTime() - start; });
  4204. }
  4205. Event.stopwatch = stopwatch;
  4206. /**
  4207. * Given an event, it returns another event which fires only when the event
  4208. * element changes.
  4209. */
  4210. function latch(event) {
  4211. var firstCall = true;
  4212. var cache;
  4213. return filter(event, function (value) {
  4214. var shouldEmit = firstCall || value !== cache;
  4215. firstCall = false;
  4216. cache = value;
  4217. return shouldEmit;
  4218. });
  4219. }
  4220. Event.latch = latch;
  4221. /**
  4222. * Buffers the provided event until a first listener comes
  4223. * along, at which point fire all the events at once and
  4224. * pipe the event from then on.
  4225. *
  4226. * ```typescript
  4227. * const emitter = new Emitter<number>();
  4228. * const event = emitter.event;
  4229. * const bufferedEvent = buffer(event);
  4230. *
  4231. * emitter.fire(1);
  4232. * emitter.fire(2);
  4233. * emitter.fire(3);
  4234. * // nothing...
  4235. *
  4236. * const listener = bufferedEvent(num => console.log(num));
  4237. * // 1, 2, 3
  4238. *
  4239. * emitter.fire(4);
  4240. * // 4
  4241. * ```
  4242. */
  4243. function buffer(event, nextTick, _buffer) {
  4244. if (nextTick === void 0) { nextTick = false; }
  4245. if (_buffer === void 0) { _buffer = []; }
  4246. var buffer = _buffer.slice();
  4247. var listener = event(function (e) {
  4248. if (buffer) {
  4249. buffer.push(e);
  4250. }
  4251. else {
  4252. emitter.fire(e);
  4253. }
  4254. });
  4255. var flush = function () {
  4256. if (buffer) {
  4257. buffer.forEach(function (e) { return emitter.fire(e); });
  4258. }
  4259. buffer = null;
  4260. };
  4261. var emitter = new Emitter({
  4262. onFirstListenerAdd: function () {
  4263. if (!listener) {
  4264. listener = event(function (e) { return emitter.fire(e); });
  4265. }
  4266. },
  4267. onFirstListenerDidAdd: function () {
  4268. if (buffer) {
  4269. if (nextTick) {
  4270. setTimeout(flush);
  4271. }
  4272. else {
  4273. flush();
  4274. }
  4275. }
  4276. },
  4277. onLastListenerRemove: function () {
  4278. if (listener) {
  4279. listener.dispose();
  4280. }
  4281. listener = null;
  4282. }
  4283. });
  4284. return emitter.event;
  4285. }
  4286. Event.buffer = buffer;
  4287. var ChainableEvent = /** @class */ (function () {
  4288. function ChainableEvent(event) {
  4289. this.event = event;
  4290. }
  4291. ChainableEvent.prototype.map = function (fn) {
  4292. return new ChainableEvent(map(this.event, fn));
  4293. };
  4294. ChainableEvent.prototype.forEach = function (fn) {
  4295. return new ChainableEvent(forEach(this.event, fn));
  4296. };
  4297. ChainableEvent.prototype.filter = function (fn) {
  4298. return new ChainableEvent(filter(this.event, fn));
  4299. };
  4300. ChainableEvent.prototype.reduce = function (merge, initial) {
  4301. return new ChainableEvent(reduce(this.event, merge, initial));
  4302. };
  4303. ChainableEvent.prototype.latch = function () {
  4304. return new ChainableEvent(latch(this.event));
  4305. };
  4306. ChainableEvent.prototype.debounce = function (merge, delay, leading, leakWarningThreshold) {
  4307. if (delay === void 0) { delay = 100; }
  4308. if (leading === void 0) { leading = false; }
  4309. return new ChainableEvent(debounce(this.event, merge, delay, leading, leakWarningThreshold));
  4310. };
  4311. ChainableEvent.prototype.on = function (listener, thisArgs, disposables) {
  4312. return this.event(listener, thisArgs, disposables);
  4313. };
  4314. ChainableEvent.prototype.once = function (listener, thisArgs, disposables) {
  4315. return once(this.event)(listener, thisArgs, disposables);
  4316. };
  4317. return ChainableEvent;
  4318. }());
  4319. function chain(event) {
  4320. return new ChainableEvent(event);
  4321. }
  4322. Event.chain = chain;
  4323. function fromNodeEventEmitter(emitter, eventName, map) {
  4324. if (map === void 0) { map = function (id) { return id; }; }
  4325. var fn = function () {
  4326. var args = [];
  4327. for (var _i = 0; _i < arguments.length; _i++) {
  4328. args[_i] = arguments[_i];
  4329. }
  4330. return result.fire(map.apply(void 0, args));
  4331. };
  4332. var onFirstListenerAdd = function () { return emitter.on(eventName, fn); };
  4333. var onLastListenerRemove = function () { return emitter.removeListener(eventName, fn); };
  4334. var result = new Emitter({ onFirstListenerAdd: onFirstListenerAdd, onLastListenerRemove: onLastListenerRemove });
  4335. return result.event;
  4336. }
  4337. Event.fromNodeEventEmitter = fromNodeEventEmitter;
  4338. function fromDOMEventEmitter(emitter, eventName, map) {
  4339. if (map === void 0) { map = function (id) { return id; }; }
  4340. var fn = function () {
  4341. var args = [];
  4342. for (var _i = 0; _i < arguments.length; _i++) {
  4343. args[_i] = arguments[_i];
  4344. }
  4345. return result.fire(map.apply(void 0, args));
  4346. };
  4347. var onFirstListenerAdd = function () { return emitter.addEventListener(eventName, fn); };
  4348. var onLastListenerRemove = function () { return emitter.removeEventListener(eventName, fn); };
  4349. var result = new Emitter({ onFirstListenerAdd: onFirstListenerAdd, onLastListenerRemove: onLastListenerRemove });
  4350. return result.event;
  4351. }
  4352. Event.fromDOMEventEmitter = fromDOMEventEmitter;
  4353. function fromPromise(promise) {
  4354. var emitter = new Emitter();
  4355. var shouldEmit = false;
  4356. promise
  4357. .then(undefined, function () { return null; })
  4358. .then(function () {
  4359. if (!shouldEmit) {
  4360. setTimeout(function () { return emitter.fire(undefined); }, 0);
  4361. }
  4362. else {
  4363. emitter.fire(undefined);
  4364. }
  4365. });
  4366. shouldEmit = true;
  4367. return emitter.event;
  4368. }
  4369. Event.fromPromise = fromPromise;
  4370. function toPromise(event) {
  4371. return new Promise(function (c) { return once(event)(c); });
  4372. }
  4373. Event.toPromise = toPromise;
  4374. })(Event = exports.Event || (exports.Event = {}));
  4375. var _globalLeakWarningThreshold = -1;
  4376. var LeakageMonitor = /** @class */ (function () {
  4377. function LeakageMonitor(customThreshold, name) {
  4378. if (name === void 0) { name = Math.random().toString(18).slice(2, 5); }
  4379. this.customThreshold = customThreshold;
  4380. this.name = name;
  4381. this._warnCountdown = 0;
  4382. }
  4383. LeakageMonitor.prototype.dispose = function () {
  4384. if (this._stacks) {
  4385. this._stacks.clear();
  4386. }
  4387. };
  4388. LeakageMonitor.prototype.check = function (listenerCount) {
  4389. var _this = this;
  4390. var threshold = _globalLeakWarningThreshold;
  4391. if (typeof this.customThreshold === 'number') {
  4392. threshold = this.customThreshold;
  4393. }
  4394. if (threshold <= 0 || listenerCount < threshold) {
  4395. return undefined;
  4396. }
  4397. if (!this._stacks) {
  4398. this._stacks = new Map();
  4399. }
  4400. var stack = new Error().stack.split('\n').slice(3).join('\n');
  4401. var count = (this._stacks.get(stack) || 0);
  4402. this._stacks.set(stack, count + 1);
  4403. this._warnCountdown -= 1;
  4404. if (this._warnCountdown <= 0) {
  4405. // only warn on first exceed and then every time the limit
  4406. // is exceeded by 50% again
  4407. this._warnCountdown = threshold * 0.5;
  4408. // find most frequent listener and print warning
  4409. var topStack_1;
  4410. var topCount_1 = 0;
  4411. this._stacks.forEach(function (count, stack) {
  4412. if (!topStack_1 || topCount_1 < count) {
  4413. topStack_1 = stack;
  4414. topCount_1 = count;
  4415. }
  4416. });
  4417. console.warn("[" + this.name + "] potential listener LEAK detected, having " + listenerCount + " listeners already. MOST frequent listener (" + topCount_1 + "):");
  4418. console.warn(topStack_1);
  4419. }
  4420. return function () {
  4421. var count = (_this._stacks.get(stack) || 0);
  4422. _this._stacks.set(stack, count - 1);
  4423. };
  4424. };
  4425. return LeakageMonitor;
  4426. }());
  4427. /**
  4428. * The Emitter can be used to expose an Event to the public
  4429. * to fire it from the insides.
  4430. * Sample:
  4431. class Document {
  4432. private readonly _onDidChange = new Emitter<(value:string)=>any>();
  4433. public onDidChange = this._onDidChange.event;
  4434. // getter-style
  4435. // get onDidChange(): Event<(value:string)=>any> {
  4436. // return this._onDidChange.event;
  4437. // }
  4438. private _doIt() {
  4439. //...
  4440. this._onDidChange.fire(value);
  4441. }
  4442. }
  4443. */
  4444. var Emitter = /** @class */ (function () {
  4445. function Emitter(options) {
  4446. this._disposed = false;
  4447. this._options = options;
  4448. this._leakageMon = _globalLeakWarningThreshold > 0
  4449. ? new LeakageMonitor(this._options && this._options.leakWarningThreshold)
  4450. : undefined;
  4451. }
  4452. Object.defineProperty(Emitter.prototype, "event", {
  4453. /**
  4454. * For the public to allow to subscribe
  4455. * to events from this Emitter
  4456. */
  4457. get: function () {
  4458. var _this = this;
  4459. if (!this._event) {
  4460. this._event = function (listener, thisArgs, disposables) {
  4461. if (!_this._listeners) {
  4462. _this._listeners = new linkedList_1.LinkedList();
  4463. }
  4464. var firstListener = _this._listeners.isEmpty();
  4465. if (firstListener && _this._options && _this._options.onFirstListenerAdd) {
  4466. _this._options.onFirstListenerAdd(_this);
  4467. }
  4468. var remove = _this._listeners.push(!thisArgs ? listener : [listener, thisArgs]);
  4469. if (firstListener && _this._options && _this._options.onFirstListenerDidAdd) {
  4470. _this._options.onFirstListenerDidAdd(_this);
  4471. }
  4472. if (_this._options && _this._options.onListenerDidAdd) {
  4473. _this._options.onListenerDidAdd(_this, listener, thisArgs);
  4474. }
  4475. // check and record this emitter for potential leakage
  4476. var removeMonitor;
  4477. if (_this._leakageMon) {
  4478. removeMonitor = _this._leakageMon.check(_this._listeners.size);
  4479. }
  4480. var result;
  4481. result = {
  4482. dispose: function () {
  4483. if (removeMonitor) {
  4484. removeMonitor();
  4485. }
  4486. result.dispose = Emitter._noop;
  4487. if (!_this._disposed) {
  4488. remove();
  4489. if (_this._options && _this._options.onLastListenerRemove) {
  4490. var hasListeners = (_this._listeners && !_this._listeners.isEmpty());
  4491. if (!hasListeners) {
  4492. _this._options.onLastListenerRemove(_this);
  4493. }
  4494. }
  4495. }
  4496. }
  4497. };
  4498. if (disposables instanceof lifecycle_1.DisposableStore) {
  4499. disposables.add(result);
  4500. }
  4501. else if (Array.isArray(disposables)) {
  4502. disposables.push(result);
  4503. }
  4504. return result;
  4505. };
  4506. }
  4507. return this._event;
  4508. },
  4509. enumerable: true,
  4510. configurable: true
  4511. });
  4512. /**
  4513. * To be kept private to fire an event to
  4514. * subscribers
  4515. */
  4516. Emitter.prototype.fire = function (event) {
  4517. if (this._listeners) {
  4518. // put all [listener,event]-pairs into delivery queue
  4519. // then emit all event. an inner/nested event might be
  4520. // the driver of this
  4521. if (!this._deliveryQueue) {
  4522. this._deliveryQueue = new linkedList_1.LinkedList();
  4523. }
  4524. for (var iter = this._listeners.iterator(), e = iter.next(); !e.done; e = iter.next()) {
  4525. this._deliveryQueue.push([e.value, event]);
  4526. }
  4527. while (this._deliveryQueue.size > 0) {
  4528. var _a = this._deliveryQueue.shift(), listener = _a[0], event_1 = _a[1];
  4529. try {
  4530. if (typeof listener === 'function') {
  4531. listener.call(undefined, event_1);
  4532. }
  4533. else {
  4534. listener[0].call(listener[1], event_1);
  4535. }
  4536. }
  4537. catch (e) {
  4538. errors_1.onUnexpectedError(e);
  4539. }
  4540. }
  4541. }
  4542. };
  4543. Emitter.prototype.dispose = function () {
  4544. if (this._listeners) {
  4545. this._listeners.clear();
  4546. }
  4547. if (this._deliveryQueue) {
  4548. this._deliveryQueue.clear();
  4549. }
  4550. if (this._leakageMon) {
  4551. this._leakageMon.dispose();
  4552. }
  4553. this._disposed = true;
  4554. };
  4555. Emitter._noop = function () { };
  4556. return Emitter;
  4557. }());
  4558. exports.Emitter = Emitter;
  4559. var PauseableEmitter = /** @class */ (function (_super) {
  4560. __extends(PauseableEmitter, _super);
  4561. function PauseableEmitter(options) {
  4562. var _this = _super.call(this, options) || this;
  4563. _this._isPaused = 0;
  4564. _this._eventQueue = new linkedList_1.LinkedList();
  4565. _this._mergeFn = options && options.merge;
  4566. return _this;
  4567. }
  4568. PauseableEmitter.prototype.pause = function () {
  4569. this._isPaused++;
  4570. };
  4571. PauseableEmitter.prototype.resume = function () {
  4572. if (this._isPaused !== 0 && --this._isPaused === 0) {
  4573. if (this._mergeFn) {
  4574. // use the merge function to create a single composite
  4575. // event. make a copy in case firing pauses this emitter
  4576. var events = this._eventQueue.toArray();
  4577. this._eventQueue.clear();
  4578. _super.prototype.fire.call(this, this._mergeFn(events));
  4579. }
  4580. else {
  4581. // no merging, fire each event individually and test
  4582. // that this emitter isn't paused halfway through
  4583. while (!this._isPaused && this._eventQueue.size !== 0) {
  4584. _super.prototype.fire.call(this, this._eventQueue.shift());
  4585. }
  4586. }
  4587. }
  4588. };
  4589. PauseableEmitter.prototype.fire = function (event) {
  4590. if (this._listeners) {
  4591. if (this._isPaused !== 0) {
  4592. this._eventQueue.push(event);
  4593. }
  4594. else {
  4595. _super.prototype.fire.call(this, event);
  4596. }
  4597. }
  4598. };
  4599. return PauseableEmitter;
  4600. }(Emitter));
  4601. exports.PauseableEmitter = PauseableEmitter;
  4602. var EventMultiplexer = /** @class */ (function () {
  4603. function EventMultiplexer() {
  4604. var _this = this;
  4605. this.hasListeners = false;
  4606. this.events = [];
  4607. this.emitter = new Emitter({
  4608. onFirstListenerAdd: function () { return _this.onFirstListenerAdd(); },
  4609. onLastListenerRemove: function () { return _this.onLastListenerRemove(); }
  4610. });
  4611. }
  4612. Object.defineProperty(EventMultiplexer.prototype, "event", {
  4613. get: function () {
  4614. return this.emitter.event;
  4615. },
  4616. enumerable: true,
  4617. configurable: true
  4618. });
  4619. EventMultiplexer.prototype.add = function (event) {
  4620. var _this = this;
  4621. var e = { event: event, listener: null };
  4622. this.events.push(e);
  4623. if (this.hasListeners) {
  4624. this.hook(e);
  4625. }
  4626. var dispose = function () {
  4627. if (_this.hasListeners) {
  4628. _this.unhook(e);
  4629. }
  4630. var idx = _this.events.indexOf(e);
  4631. _this.events.splice(idx, 1);
  4632. };
  4633. return lifecycle_1.toDisposable(functional_1.once(dispose));
  4634. };
  4635. EventMultiplexer.prototype.onFirstListenerAdd = function () {
  4636. var _this = this;
  4637. this.hasListeners = true;
  4638. this.events.forEach(function (e) { return _this.hook(e); });
  4639. };
  4640. EventMultiplexer.prototype.onLastListenerRemove = function () {
  4641. var _this = this;
  4642. this.hasListeners = false;
  4643. this.events.forEach(function (e) { return _this.unhook(e); });
  4644. };
  4645. EventMultiplexer.prototype.hook = function (e) {
  4646. var _this = this;
  4647. e.listener = e.event(function (r) { return _this.emitter.fire(r); });
  4648. };
  4649. EventMultiplexer.prototype.unhook = function (e) {
  4650. if (e.listener) {
  4651. e.listener.dispose();
  4652. }
  4653. e.listener = null;
  4654. };
  4655. EventMultiplexer.prototype.dispose = function () {
  4656. this.emitter.dispose();
  4657. };
  4658. return EventMultiplexer;
  4659. }());
  4660. exports.EventMultiplexer = EventMultiplexer;
  4661. /**
  4662. * The EventBufferer is useful in situations in which you want
  4663. * to delay firing your events during some code.
  4664. * You can wrap that code and be sure that the event will not
  4665. * be fired during that wrap.
  4666. *
  4667. * ```
  4668. * const emitter: Emitter;
  4669. * const delayer = new EventDelayer();
  4670. * const delayedEvent = delayer.wrapEvent(emitter.event);
  4671. *
  4672. * delayedEvent(console.log);
  4673. *
  4674. * delayer.bufferEvents(() => {
  4675. * emitter.fire(); // event will not be fired yet
  4676. * });
  4677. *
  4678. * // event will only be fired at this point
  4679. * ```
  4680. */
  4681. var EventBufferer = /** @class */ (function () {
  4682. function EventBufferer() {
  4683. this.buffers = [];
  4684. }
  4685. EventBufferer.prototype.wrapEvent = function (event) {
  4686. var _this = this;
  4687. return function (listener, thisArgs, disposables) {
  4688. return event(function (i) {
  4689. var buffer = _this.buffers[_this.buffers.length - 1];
  4690. if (buffer) {
  4691. buffer.push(function () { return listener.call(thisArgs, i); });
  4692. }
  4693. else {
  4694. listener.call(thisArgs, i);
  4695. }
  4696. }, undefined, disposables);
  4697. };
  4698. };
  4699. EventBufferer.prototype.bufferEvents = function (fn) {
  4700. var buffer = [];
  4701. this.buffers.push(buffer);
  4702. var r = fn();
  4703. this.buffers.pop();
  4704. buffer.forEach(function (flush) { return flush(); });
  4705. return r;
  4706. };
  4707. return EventBufferer;
  4708. }());
  4709. exports.EventBufferer = EventBufferer;
  4710. /**
  4711. * A Relay is an event forwarder which functions as a replugabble event pipe.
  4712. * Once created, you can connect an input event to it and it will simply forward
  4713. * events from that input event through its own `event` property. The `input`
  4714. * can be changed at any point in time.
  4715. */
  4716. var Relay = /** @class */ (function () {
  4717. function Relay() {
  4718. var _this = this;
  4719. this.listening = false;
  4720. this.inputEvent = Event.None;
  4721. this.inputEventListener = lifecycle_1.Disposable.None;
  4722. this.emitter = new Emitter({
  4723. onFirstListenerDidAdd: function () {
  4724. _this.listening = true;
  4725. _this.inputEventListener = _this.inputEvent(_this.emitter.fire, _this.emitter);
  4726. },
  4727. onLastListenerRemove: function () {
  4728. _this.listening = false;
  4729. _this.inputEventListener.dispose();
  4730. }
  4731. });
  4732. this.event = this.emitter.event;
  4733. }
  4734. Object.defineProperty(Relay.prototype, "input", {
  4735. set: function (event) {
  4736. this.inputEvent = event;
  4737. if (this.listening) {
  4738. this.inputEventListener.dispose();
  4739. this.inputEventListener = event(this.emitter.fire, this.emitter);
  4740. }
  4741. },
  4742. enumerable: true,
  4743. configurable: true
  4744. });
  4745. Relay.prototype.dispose = function () {
  4746. this.inputEventListener.dispose();
  4747. this.emitter.dispose();
  4748. };
  4749. return Relay;
  4750. }());
  4751. exports.Relay = Relay;
  4752. });
  4753. /*---------------------------------------------------------------------------------------------
  4754. * Copyright (c) Microsoft Corporation. All rights reserved.
  4755. * Licensed under the MIT License. See License.txt in the project root for license information.
  4756. *--------------------------------------------------------------------------------------------*/
  4757. define(__m[19/*vs/base/common/cancellation*/], __M([0/*require*/,1/*exports*/,9/*vs/base/common/event*/]), function (require, exports, event_1) {
  4758. "use strict";
  4759. Object.defineProperty(exports, "__esModule", { value: true });
  4760. var shortcutEvent = Object.freeze(function (callback, context) {
  4761. var handle = setTimeout(callback.bind(context), 0);
  4762. return { dispose: function () { clearTimeout(handle); } };
  4763. });
  4764. var CancellationToken;
  4765. (function (CancellationToken) {
  4766. function isCancellationToken(thing) {
  4767. if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {
  4768. return true;
  4769. }
  4770. if (thing instanceof MutableToken) {
  4771. return true;
  4772. }
  4773. if (!thing || typeof thing !== 'object') {
  4774. return false;
  4775. }
  4776. return typeof thing.isCancellationRequested === 'boolean'
  4777. && typeof thing.onCancellationRequested === 'function';
  4778. }
  4779. CancellationToken.isCancellationToken = isCancellationToken;
  4780. CancellationToken.None = Object.freeze({
  4781. isCancellationRequested: false,
  4782. onCancellationRequested: event_1.Event.None
  4783. });
  4784. CancellationToken.Cancelled = Object.freeze({
  4785. isCancellationRequested: true,
  4786. onCancellationRequested: shortcutEvent
  4787. });
  4788. })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
  4789. var MutableToken = /** @class */ (function () {
  4790. function MutableToken() {
  4791. this._isCancelled = false;
  4792. this._emitter = null;
  4793. }
  4794. MutableToken.prototype.cancel = function () {
  4795. if (!this._isCancelled) {
  4796. this._isCancelled = true;
  4797. if (this._emitter) {
  4798. this._emitter.fire(undefined);
  4799. this.dispose();
  4800. }
  4801. }
  4802. };
  4803. Object.defineProperty(MutableToken.prototype, "isCancellationRequested", {
  4804. get: function () {
  4805. return this._isCancelled;
  4806. },
  4807. enumerable: true,
  4808. configurable: true
  4809. });
  4810. Object.defineProperty(MutableToken.prototype, "onCancellationRequested", {
  4811. get: function () {
  4812. if (this._isCancelled) {
  4813. return shortcutEvent;
  4814. }
  4815. if (!this._emitter) {
  4816. this._emitter = new event_1.Emitter();
  4817. }
  4818. return this._emitter.event;
  4819. },
  4820. enumerable: true,
  4821. configurable: true
  4822. });
  4823. MutableToken.prototype.dispose = function () {
  4824. if (this._emitter) {
  4825. this._emitter.dispose();
  4826. this._emitter = null;
  4827. }
  4828. };
  4829. return MutableToken;
  4830. }());
  4831. var CancellationTokenSource = /** @class */ (function () {
  4832. function CancellationTokenSource(parent) {
  4833. this._token = undefined;
  4834. this._parentListener = undefined;
  4835. this._parentListener = parent && parent.onCancellationRequested(this.cancel, this);
  4836. }
  4837. Object.defineProperty(CancellationTokenSource.prototype, "token", {
  4838. get: function () {
  4839. if (!this._token) {
  4840. // be lazy and create the token only when
  4841. // actually needed
  4842. this._token = new MutableToken();
  4843. }
  4844. return this._token;
  4845. },
  4846. enumerable: true,
  4847. configurable: true
  4848. });
  4849. CancellationTokenSource.prototype.cancel = function () {
  4850. if (!this._token) {
  4851. // save an object by returning the default
  4852. // cancelled token when cancellation happens
  4853. // before someone asks for the token
  4854. this._token = CancellationToken.Cancelled;
  4855. }
  4856. else if (this._token instanceof MutableToken) {
  4857. // actually cancel
  4858. this._token.cancel();
  4859. }
  4860. };
  4861. CancellationTokenSource.prototype.dispose = function (cancel) {
  4862. if (cancel === void 0) { cancel = false; }
  4863. if (cancel) {
  4864. this.cancel();
  4865. }
  4866. if (this._parentListener) {
  4867. this._parentListener.dispose();
  4868. }
  4869. if (!this._token) {
  4870. // ensure to initialize with an empty token if we had none
  4871. this._token = CancellationToken.None;
  4872. }
  4873. else if (this._token instanceof MutableToken) {
  4874. // actually dispose
  4875. this._token.dispose();
  4876. }
  4877. };
  4878. return CancellationTokenSource;
  4879. }());
  4880. exports.CancellationTokenSource = CancellationTokenSource;
  4881. });
  4882. /*---------------------------------------------------------------------------------------------
  4883. * Copyright (c) Microsoft Corporation. All rights reserved.
  4884. * Licensed under the MIT License. See License.txt in the project root for license information.
  4885. *--------------------------------------------------------------------------------------------*/
  4886. define(__m[4/*vs/base/common/platform*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  4887. "use strict";
  4888. Object.defineProperty(exports, "__esModule", { value: true });
  4889. var LANGUAGE_DEFAULT = 'en';
  4890. var _isWindows = false;
  4891. var _isMacintosh = false;
  4892. var _isLinux = false;
  4893. var _isNative = false;
  4894. var _isWeb = false;
  4895. var _isIOS = false;
  4896. var _locale = undefined;
  4897. var _language = LANGUAGE_DEFAULT;
  4898. var _translationsConfigFile = undefined;
  4899. var _userAgent = undefined;
  4900. var isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
  4901. // OS detection
  4902. if (typeof navigator === 'object' && !isElectronRenderer) {
  4903. _userAgent = navigator.userAgent;
  4904. _isWindows = _userAgent.indexOf('Windows') >= 0;
  4905. _isMacintosh = _userAgent.indexOf('Macintosh') >= 0;
  4906. _isIOS = _userAgent.indexOf('Macintosh') >= 0 && !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
  4907. _isLinux = _userAgent.indexOf('Linux') >= 0;
  4908. _isWeb = true;
  4909. _locale = navigator.language;
  4910. _language = _locale;
  4911. }
  4912. else if (typeof process === 'object') {
  4913. _isWindows = (process.platform === 'win32');
  4914. _isMacintosh = (process.platform === 'darwin');
  4915. _isLinux = (process.platform === 'linux');
  4916. _locale = LANGUAGE_DEFAULT;
  4917. _language = LANGUAGE_DEFAULT;
  4918. var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
  4919. if (rawNlsConfig) {
  4920. try {
  4921. var nlsConfig = JSON.parse(rawNlsConfig);
  4922. var resolved = nlsConfig.availableLanguages['*'];
  4923. _locale = nlsConfig.locale;
  4924. // VSCode's default language is 'en'
  4925. _language = resolved ? resolved : LANGUAGE_DEFAULT;
  4926. _translationsConfigFile = nlsConfig._translationsConfigFile;
  4927. }
  4928. catch (e) {
  4929. }
  4930. }
  4931. _isNative = true;
  4932. }
  4933. var _platform = 0 /* Web */;
  4934. if (_isMacintosh) {
  4935. _platform = 1 /* Mac */;
  4936. }
  4937. else if (_isWindows) {
  4938. _platform = 3 /* Windows */;
  4939. }
  4940. else if (_isLinux) {
  4941. _platform = 2 /* Linux */;
  4942. }
  4943. exports.isWindows = _isWindows;
  4944. exports.isMacintosh = _isMacintosh;
  4945. exports.isLinux = _isLinux;
  4946. exports.isNative = _isNative;
  4947. exports.isWeb = _isWeb;
  4948. exports.isIOS = _isIOS;
  4949. var _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
  4950. exports.globals = _globals;
  4951. exports.setImmediate = (function defineSetImmediate() {
  4952. if (exports.globals.setImmediate) {
  4953. return exports.globals.setImmediate.bind(exports.globals);
  4954. }
  4955. if (typeof exports.globals.postMessage === 'function' && !exports.globals.importScripts) {
  4956. var pending_1 = [];
  4957. exports.globals.addEventListener('message', function (e) {
  4958. if (e.data && e.data.vscodeSetImmediateId) {
  4959. for (var i = 0, len = pending_1.length; i < len; i++) {
  4960. var candidate = pending_1[i];
  4961. if (candidate.id === e.data.vscodeSetImmediateId) {
  4962. pending_1.splice(i, 1);
  4963. candidate.callback();
  4964. return;
  4965. }
  4966. }
  4967. }
  4968. });
  4969. var lastId_1 = 0;
  4970. return function (callback) {
  4971. var myId = ++lastId_1;
  4972. pending_1.push({
  4973. id: myId,
  4974. callback: callback
  4975. });
  4976. exports.globals.postMessage({ vscodeSetImmediateId: myId }, '*');
  4977. };
  4978. }
  4979. if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
  4980. return process.nextTick.bind(process);
  4981. }
  4982. var _promise = Promise.resolve();
  4983. return function (callback) { return _promise.then(callback); };
  4984. })();
  4985. exports.OS = (_isMacintosh ? 2 /* Macintosh */ : (_isWindows ? 1 /* Windows */ : 3 /* Linux */));
  4986. });
  4987. /*---------------------------------------------------------------------------------------------
  4988. * Copyright (c) Microsoft Corporation. All rights reserved.
  4989. * Licensed under the MIT License. See License.txt in the project root for license information.
  4990. *--------------------------------------------------------------------------------------------*/
  4991. define(__m[20/*vs/base/common/strings*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  4992. "use strict";
  4993. Object.defineProperty(exports, "__esModule", { value: true });
  4994. function isFalsyOrWhitespace(str) {
  4995. if (!str || typeof str !== 'string') {
  4996. return true;
  4997. }
  4998. return str.trim().length === 0;
  4999. }
  5000. exports.isFalsyOrWhitespace = isFalsyOrWhitespace;
  5001. /**
  5002. * @returns the provided number with the given number of preceding zeros.
  5003. */
  5004. function pad(n, l, char) {
  5005. if (char === void 0) { char = '0'; }
  5006. var str = '' + n;
  5007. var r = [str];
  5008. for (var i = str.length; i < l; i++) {
  5009. r.push(char);
  5010. }
  5011. return r.reverse().join('');
  5012. }
  5013. exports.pad = pad;
  5014. var _formatRegexp = /{(\d+)}/g;
  5015. /**
  5016. * Helper to produce a string with a variable number of arguments. Insert variable segments
  5017. * into the string using the {n} notation where N is the index of the argument following the string.
  5018. * @param value string to which formatting is applied
  5019. * @param args replacements for {n}-entries
  5020. */
  5021. function format(value) {
  5022. var args = [];
  5023. for (var _i = 1; _i < arguments.length; _i++) {
  5024. args[_i - 1] = arguments[_i];
  5025. }
  5026. if (args.length === 0) {
  5027. return value;
  5028. }
  5029. return value.replace(_formatRegexp, function (match, group) {
  5030. var idx = parseInt(group, 10);
  5031. return isNaN(idx) || idx < 0 || idx >= args.length ?
  5032. match :
  5033. args[idx];
  5034. });
  5035. }
  5036. exports.format = format;
  5037. /**
  5038. * Converts HTML characters inside the string to use entities instead. Makes the string safe from
  5039. * being used e.g. in HTMLElement.innerHTML.
  5040. */
  5041. function escape(html) {
  5042. return html.replace(/[<>&]/g, function (match) {
  5043. switch (match) {
  5044. case '<': return '&lt;';
  5045. case '>': return '&gt;';
  5046. case '&': return '&amp;';
  5047. default: return match;
  5048. }
  5049. });
  5050. }
  5051. exports.escape = escape;
  5052. /**
  5053. * Escapes regular expression characters in a given string
  5054. */
  5055. function escapeRegExpCharacters(value) {
  5056. return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
  5057. }
  5058. exports.escapeRegExpCharacters = escapeRegExpCharacters;
  5059. /**
  5060. * Removes all occurrences of needle from the beginning and end of haystack.
  5061. * @param haystack string to trim
  5062. * @param needle the thing to trim (default is a blank)
  5063. */
  5064. function trim(haystack, needle) {
  5065. if (needle === void 0) { needle = ' '; }
  5066. var trimmed = ltrim(haystack, needle);
  5067. return rtrim(trimmed, needle);
  5068. }
  5069. exports.trim = trim;
  5070. /**
  5071. * Removes all occurrences of needle from the beginning of haystack.
  5072. * @param haystack string to trim
  5073. * @param needle the thing to trim
  5074. */
  5075. function ltrim(haystack, needle) {
  5076. if (!haystack || !needle) {
  5077. return haystack;
  5078. }
  5079. var needleLen = needle.length;
  5080. if (needleLen === 0 || haystack.length === 0) {
  5081. return haystack;
  5082. }
  5083. var offset = 0;
  5084. while (haystack.indexOf(needle, offset) === offset) {
  5085. offset = offset + needleLen;
  5086. }
  5087. return haystack.substring(offset);
  5088. }
  5089. exports.ltrim = ltrim;
  5090. /**
  5091. * Removes all occurrences of needle from the end of haystack.
  5092. * @param haystack string to trim
  5093. * @param needle the thing to trim
  5094. */
  5095. function rtrim(haystack, needle) {
  5096. if (!haystack || !needle) {
  5097. return haystack;
  5098. }
  5099. var needleLen = needle.length, haystackLen = haystack.length;
  5100. if (needleLen === 0 || haystackLen === 0) {
  5101. return haystack;
  5102. }
  5103. var offset = haystackLen, idx = -1;
  5104. while (true) {
  5105. idx = haystack.lastIndexOf(needle, offset - 1);
  5106. if (idx === -1 || idx + needleLen !== offset) {
  5107. break;
  5108. }
  5109. if (idx === 0) {
  5110. return '';
  5111. }
  5112. offset = idx;
  5113. }
  5114. return haystack.substring(0, offset);
  5115. }
  5116. exports.rtrim = rtrim;
  5117. function convertSimple2RegExpPattern(pattern) {
  5118. return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
  5119. }
  5120. exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
  5121. /**
  5122. * Determines if haystack starts with needle.
  5123. */
  5124. function startsWith(haystack, needle) {
  5125. if (haystack.length < needle.length) {
  5126. return false;
  5127. }
  5128. if (haystack === needle) {
  5129. return true;
  5130. }
  5131. for (var i = 0; i < needle.length; i++) {
  5132. if (haystack[i] !== needle[i]) {
  5133. return false;
  5134. }
  5135. }
  5136. return true;
  5137. }
  5138. exports.startsWith = startsWith;
  5139. /**
  5140. * Determines if haystack ends with needle.
  5141. */
  5142. function endsWith(haystack, needle) {
  5143. var diff = haystack.length - needle.length;
  5144. if (diff > 0) {
  5145. return haystack.indexOf(needle, diff) === diff;
  5146. }
  5147. else if (diff === 0) {
  5148. return haystack === needle;
  5149. }
  5150. else {
  5151. return false;
  5152. }
  5153. }
  5154. exports.endsWith = endsWith;
  5155. function createRegExp(searchString, isRegex, options) {
  5156. if (options === void 0) { options = {}; }
  5157. if (!searchString) {
  5158. throw new Error('Cannot create regex from empty string');
  5159. }
  5160. if (!isRegex) {
  5161. searchString = escapeRegExpCharacters(searchString);
  5162. }
  5163. if (options.wholeWord) {
  5164. if (!/\B/.test(searchString.charAt(0))) {
  5165. searchString = '\\b' + searchString;
  5166. }
  5167. if (!/\B/.test(searchString.charAt(searchString.length - 1))) {
  5168. searchString = searchString + '\\b';
  5169. }
  5170. }
  5171. var modifiers = '';
  5172. if (options.global) {
  5173. modifiers += 'g';
  5174. }
  5175. if (!options.matchCase) {
  5176. modifiers += 'i';
  5177. }
  5178. if (options.multiline) {
  5179. modifiers += 'm';
  5180. }
  5181. if (options.unicode) {
  5182. modifiers += 'u';
  5183. }
  5184. return new RegExp(searchString, modifiers);
  5185. }
  5186. exports.createRegExp = createRegExp;
  5187. function regExpLeadsToEndlessLoop(regexp) {
  5188. // Exit early if it's one of these special cases which are meant to match
  5189. // against an empty string
  5190. if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\s*$') {
  5191. return false;
  5192. }
  5193. // We check against an empty string. If the regular expression doesn't advance
  5194. // (e.g. ends in an endless loop) it will match an empty string.
  5195. var match = regexp.exec('');
  5196. return !!(match && regexp.lastIndex === 0);
  5197. }
  5198. exports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;
  5199. function regExpFlags(regexp) {
  5200. return (regexp.global ? 'g' : '')
  5201. + (regexp.ignoreCase ? 'i' : '')
  5202. + (regexp.multiline ? 'm' : '')
  5203. + (regexp.unicode ? 'u' : '');
  5204. }
  5205. exports.regExpFlags = regExpFlags;
  5206. /**
  5207. * Returns first index of the string that is not whitespace.
  5208. * If string is empty or contains only whitespaces, returns -1
  5209. */
  5210. function firstNonWhitespaceIndex(str) {
  5211. for (var i = 0, len = str.length; i < len; i++) {
  5212. var chCode = str.charCodeAt(i);
  5213. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5214. return i;
  5215. }
  5216. }
  5217. return -1;
  5218. }
  5219. exports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;
  5220. /**
  5221. * Returns the leading whitespace of the string.
  5222. * If the string contains only whitespaces, returns entire string
  5223. */
  5224. function getLeadingWhitespace(str, start, end) {
  5225. if (start === void 0) { start = 0; }
  5226. if (end === void 0) { end = str.length; }
  5227. for (var i = start; i < end; i++) {
  5228. var chCode = str.charCodeAt(i);
  5229. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5230. return str.substring(start, i);
  5231. }
  5232. }
  5233. return str.substring(start, end);
  5234. }
  5235. exports.getLeadingWhitespace = getLeadingWhitespace;
  5236. /**
  5237. * Returns last index of the string that is not whitespace.
  5238. * If string is empty or contains only whitespaces, returns -1
  5239. */
  5240. function lastNonWhitespaceIndex(str, startIndex) {
  5241. if (startIndex === void 0) { startIndex = str.length - 1; }
  5242. for (var i = startIndex; i >= 0; i--) {
  5243. var chCode = str.charCodeAt(i);
  5244. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5245. return i;
  5246. }
  5247. }
  5248. return -1;
  5249. }
  5250. exports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;
  5251. function compare(a, b) {
  5252. if (a < b) {
  5253. return -1;
  5254. }
  5255. else if (a > b) {
  5256. return 1;
  5257. }
  5258. else {
  5259. return 0;
  5260. }
  5261. }
  5262. exports.compare = compare;
  5263. function compareIgnoreCase(a, b) {
  5264. var len = Math.min(a.length, b.length);
  5265. for (var i = 0; i < len; i++) {
  5266. var codeA = a.charCodeAt(i);
  5267. var codeB = b.charCodeAt(i);
  5268. if (codeA === codeB) {
  5269. // equal
  5270. continue;
  5271. }
  5272. if (isUpperAsciiLetter(codeA)) {
  5273. codeA += 32;
  5274. }
  5275. if (isUpperAsciiLetter(codeB)) {
  5276. codeB += 32;
  5277. }
  5278. var diff = codeA - codeB;
  5279. if (diff === 0) {
  5280. // equal -> ignoreCase
  5281. continue;
  5282. }
  5283. else if (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {
  5284. //
  5285. return diff;
  5286. }
  5287. else {
  5288. return compare(a.toLowerCase(), b.toLowerCase());
  5289. }
  5290. }
  5291. if (a.length < b.length) {
  5292. return -1;
  5293. }
  5294. else if (a.length > b.length) {
  5295. return 1;
  5296. }
  5297. else {
  5298. return 0;
  5299. }
  5300. }
  5301. exports.compareIgnoreCase = compareIgnoreCase;
  5302. function isLowerAsciiLetter(code) {
  5303. return code >= 97 /* a */ && code <= 122 /* z */;
  5304. }
  5305. exports.isLowerAsciiLetter = isLowerAsciiLetter;
  5306. function isUpperAsciiLetter(code) {
  5307. return code >= 65 /* A */ && code <= 90 /* Z */;
  5308. }
  5309. exports.isUpperAsciiLetter = isUpperAsciiLetter;
  5310. function isAsciiLetter(code) {
  5311. return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
  5312. }
  5313. function equalsIgnoreCase(a, b) {
  5314. return a.length === b.length && doEqualsIgnoreCase(a, b);
  5315. }
  5316. exports.equalsIgnoreCase = equalsIgnoreCase;
  5317. function doEqualsIgnoreCase(a, b, stopAt) {
  5318. if (stopAt === void 0) { stopAt = a.length; }
  5319. for (var i = 0; i < stopAt; i++) {
  5320. var codeA = a.charCodeAt(i);
  5321. var codeB = b.charCodeAt(i);
  5322. if (codeA === codeB) {
  5323. continue;
  5324. }
  5325. // a-z A-Z
  5326. if (isAsciiLetter(codeA) && isAsciiLetter(codeB)) {
  5327. var diff = Math.abs(codeA - codeB);
  5328. if (diff !== 0 && diff !== 32) {
  5329. return false;
  5330. }
  5331. }
  5332. // Any other charcode
  5333. else {
  5334. if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {
  5335. return false;
  5336. }
  5337. }
  5338. }
  5339. return true;
  5340. }
  5341. function startsWithIgnoreCase(str, candidate) {
  5342. var candidateLength = candidate.length;
  5343. if (candidate.length > str.length) {
  5344. return false;
  5345. }
  5346. return doEqualsIgnoreCase(str, candidate, candidateLength);
  5347. }
  5348. exports.startsWithIgnoreCase = startsWithIgnoreCase;
  5349. /**
  5350. * @returns the length of the common prefix of the two strings.
  5351. */
  5352. function commonPrefixLength(a, b) {
  5353. var i, len = Math.min(a.length, b.length);
  5354. for (i = 0; i < len; i++) {
  5355. if (a.charCodeAt(i) !== b.charCodeAt(i)) {
  5356. return i;
  5357. }
  5358. }
  5359. return len;
  5360. }
  5361. exports.commonPrefixLength = commonPrefixLength;
  5362. /**
  5363. * @returns the length of the common suffix of the two strings.
  5364. */
  5365. function commonSuffixLength(a, b) {
  5366. var i, len = Math.min(a.length, b.length);
  5367. var aLastIndex = a.length - 1;
  5368. var bLastIndex = b.length - 1;
  5369. for (i = 0; i < len; i++) {
  5370. if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {
  5371. return i;
  5372. }
  5373. }
  5374. return len;
  5375. }
  5376. exports.commonSuffixLength = commonSuffixLength;
  5377. // --- unicode
  5378. // http://en.wikipedia.org/wiki/Surrogate_pair
  5379. // Returns the code point starting at a specified index in a string
  5380. // Code points U+0000 to U+D7FF and U+E000 to U+FFFF are represented on a single character
  5381. // Code points U+10000 to U+10FFFF are represented on two consecutive characters
  5382. //export function getUnicodePoint(str:string, index:number, len:number):number {
  5383. // const chrCode = str.charCodeAt(index);
  5384. // if (0xD800 <= chrCode && chrCode <= 0xDBFF && index + 1 < len) {
  5385. // const nextChrCode = str.charCodeAt(index + 1);
  5386. // if (0xDC00 <= nextChrCode && nextChrCode <= 0xDFFF) {
  5387. // return (chrCode - 0xD800) << 10 + (nextChrCode - 0xDC00) + 0x10000;
  5388. // }
  5389. // }
  5390. // return chrCode;
  5391. //}
  5392. function isHighSurrogate(charCode) {
  5393. return (0xD800 <= charCode && charCode <= 0xDBFF);
  5394. }
  5395. exports.isHighSurrogate = isHighSurrogate;
  5396. function isLowSurrogate(charCode) {
  5397. return (0xDC00 <= charCode && charCode <= 0xDFFF);
  5398. }
  5399. exports.isLowSurrogate = isLowSurrogate;
  5400. /**
  5401. * get the code point that begins at offset `offset`
  5402. */
  5403. function getNextCodePoint(str, len, offset) {
  5404. var charCode = str.charCodeAt(offset);
  5405. if (isHighSurrogate(charCode) && offset + 1 < len) {
  5406. var nextCharCode = str.charCodeAt(offset + 1);
  5407. if (isLowSurrogate(nextCharCode)) {
  5408. return ((charCode - 0xD800) << 10) + (nextCharCode - 0xDC00) + 0x10000;
  5409. }
  5410. }
  5411. return charCode;
  5412. }
  5413. exports.getNextCodePoint = getNextCodePoint;
  5414. /**
  5415. * get the code point that ends right before offset `offset`
  5416. */
  5417. function getPrevCodePoint(str, offset) {
  5418. var charCode = str.charCodeAt(offset - 1);
  5419. if (isLowSurrogate(charCode) && offset > 1) {
  5420. var prevCharCode = str.charCodeAt(offset - 2);
  5421. if (isHighSurrogate(prevCharCode)) {
  5422. return ((prevCharCode - 0xD800) << 10) + (charCode - 0xDC00) + 0x10000;
  5423. }
  5424. }
  5425. return charCode;
  5426. }
  5427. function nextCharLength(str, offset) {
  5428. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  5429. var initialOffset = offset;
  5430. var len = str.length;
  5431. var initialCodePoint = getNextCodePoint(str, len, offset);
  5432. offset += (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  5433. var graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  5434. while (offset < len) {
  5435. var nextCodePoint = getNextCodePoint(str, len, offset);
  5436. var nextGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(nextCodePoint);
  5437. if (breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
  5438. break;
  5439. }
  5440. offset += (nextCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  5441. graphemeBreakType = nextGraphemeBreakType;
  5442. }
  5443. return (offset - initialOffset);
  5444. }
  5445. exports.nextCharLength = nextCharLength;
  5446. function prevCharLength(str, offset) {
  5447. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  5448. var initialOffset = offset;
  5449. var initialCodePoint = getPrevCodePoint(str, offset);
  5450. offset -= (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  5451. var graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  5452. while (offset > 0) {
  5453. var prevCodePoint = getPrevCodePoint(str, offset);
  5454. var prevGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(prevCodePoint);
  5455. if (breakBetweenGraphemeBreakType(prevGraphemeBreakType, graphemeBreakType)) {
  5456. break;
  5457. }
  5458. offset -= (prevCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  5459. graphemeBreakType = prevGraphemeBreakType;
  5460. }
  5461. return (initialOffset - offset);
  5462. }
  5463. exports.prevCharLength = prevCharLength;
  5464. /**
  5465. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-rtl-test.js
  5466. */
  5467. var CONTAINS_RTL = /(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u08BD\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE33\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDCFF]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD50-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;
  5468. /**
  5469. * Returns true if `str` contains any Unicode character that is classified as "R" or "AL".
  5470. */
  5471. function containsRTL(str) {
  5472. return CONTAINS_RTL.test(str);
  5473. }
  5474. exports.containsRTL = containsRTL;
  5475. /**
  5476. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js
  5477. */
  5478. var CONTAINS_EMOJI = /(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD00-\uDDFF\uDE70-\uDE73\uDE78-\uDE82\uDE90-\uDE95])/;
  5479. function containsEmoji(str) {
  5480. return CONTAINS_EMOJI.test(str);
  5481. }
  5482. exports.containsEmoji = containsEmoji;
  5483. var IS_BASIC_ASCII = /^[\t\n\r\x20-\x7E]*$/;
  5484. /**
  5485. * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \n, \r, \t
  5486. */
  5487. function isBasicASCII(str) {
  5488. return IS_BASIC_ASCII.test(str);
  5489. }
  5490. exports.isBasicASCII = isBasicASCII;
  5491. function containsFullWidthCharacter(str) {
  5492. for (var i = 0, len = str.length; i < len; i++) {
  5493. if (isFullWidthCharacter(str.charCodeAt(i))) {
  5494. return true;
  5495. }
  5496. }
  5497. return false;
  5498. }
  5499. exports.containsFullWidthCharacter = containsFullWidthCharacter;
  5500. function isFullWidthCharacter(charCode) {
  5501. // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns
  5502. // http://jrgraphix.net/research/unicode_blocks.php
  5503. // 2E80 — 2EFF CJK Radicals Supplement
  5504. // 2F00 — 2FDF Kangxi Radicals
  5505. // 2FF0 — 2FFF Ideographic Description Characters
  5506. // 3000 — 303F CJK Symbols and Punctuation
  5507. // 3040 — 309F Hiragana
  5508. // 30A0 — 30FF Katakana
  5509. // 3100 — 312F Bopomofo
  5510. // 3130 — 318F Hangul Compatibility Jamo
  5511. // 3190 — 319F Kanbun
  5512. // 31A0 — 31BF Bopomofo Extended
  5513. // 31F0 — 31FF Katakana Phonetic Extensions
  5514. // 3200 — 32FF Enclosed CJK Letters and Months
  5515. // 3300 — 33FF CJK Compatibility
  5516. // 3400 — 4DBF CJK Unified Ideographs Extension A
  5517. // 4DC0 — 4DFF Yijing Hexagram Symbols
  5518. // 4E00 — 9FFF CJK Unified Ideographs
  5519. // A000 — A48F Yi Syllables
  5520. // A490 — A4CF Yi Radicals
  5521. // AC00 — D7AF Hangul Syllables
  5522. // [IGNORE] D800 — DB7F High Surrogates
  5523. // [IGNORE] DB80 — DBFF High Private Use Surrogates
  5524. // [IGNORE] DC00 — DFFF Low Surrogates
  5525. // [IGNORE] E000 — F8FF Private Use Area
  5526. // F900 — FAFF CJK Compatibility Ideographs
  5527. // [IGNORE] FB00 — FB4F Alphabetic Presentation Forms
  5528. // [IGNORE] FB50 — FDFF Arabic Presentation Forms-A
  5529. // [IGNORE] FE00 — FE0F Variation Selectors
  5530. // [IGNORE] FE20 — FE2F Combining Half Marks
  5531. // [IGNORE] FE30 — FE4F CJK Compatibility Forms
  5532. // [IGNORE] FE50 — FE6F Small Form Variants
  5533. // [IGNORE] FE70 — FEFF Arabic Presentation Forms-B
  5534. // FF00 — FFEF Halfwidth and Fullwidth Forms
  5535. // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]
  5536. // of which FF01 - FF5E fullwidth ASCII of 21 to 7E
  5537. // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
  5538. // [IGNORE] FFF0 — FFFF Specials
  5539. charCode = +charCode; // @perf
  5540. return ((charCode >= 0x2E80 && charCode <= 0xD7AF)
  5541. || (charCode >= 0xF900 && charCode <= 0xFAFF)
  5542. || (charCode >= 0xFF01 && charCode <= 0xFF5E));
  5543. }
  5544. exports.isFullWidthCharacter = isFullWidthCharacter;
  5545. /**
  5546. * A fast function (therefore imprecise) to check if code points are emojis.
  5547. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js
  5548. */
  5549. function isEmojiImprecise(x) {
  5550. return ((x >= 0x1F1E6 && x <= 0x1F1FF) || (x >= 9728 && x <= 10175) || (x >= 127744 && x <= 128591)
  5551. || (x >= 128640 && x <= 128764) || (x >= 128992 && x <= 129003) || (x >= 129280 && x <= 129535)
  5552. || (x >= 129648 && x <= 129651) || (x >= 129656 && x <= 129666) || (x >= 129680 && x <= 129685));
  5553. }
  5554. exports.isEmojiImprecise = isEmojiImprecise;
  5555. // -- UTF-8 BOM
  5556. exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
  5557. function startsWithUTF8BOM(str) {
  5558. return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
  5559. }
  5560. exports.startsWithUTF8BOM = startsWithUTF8BOM;
  5561. function safeBtoa(str) {
  5562. return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values
  5563. }
  5564. exports.safeBtoa = safeBtoa;
  5565. function repeat(s, count) {
  5566. var result = '';
  5567. for (var i = 0; i < count; i++) {
  5568. result += s;
  5569. }
  5570. return result;
  5571. }
  5572. exports.repeat = repeat;
  5573. function containsUppercaseCharacter(target, ignoreEscapedChars) {
  5574. if (ignoreEscapedChars === void 0) { ignoreEscapedChars = false; }
  5575. if (!target) {
  5576. return false;
  5577. }
  5578. if (ignoreEscapedChars) {
  5579. target = target.replace(/\\./g, '');
  5580. }
  5581. return target.toLowerCase() !== target;
  5582. }
  5583. exports.containsUppercaseCharacter = containsUppercaseCharacter;
  5584. /**
  5585. * Produces 'a'-'z', followed by 'A'-'Z'... followed by 'a'-'z', etc.
  5586. */
  5587. function singleLetterHash(n) {
  5588. var LETTERS_CNT = (90 /* Z */ - 65 /* A */ + 1);
  5589. n = n % (2 * LETTERS_CNT);
  5590. if (n < LETTERS_CNT) {
  5591. return String.fromCharCode(97 /* a */ + n);
  5592. }
  5593. return String.fromCharCode(65 /* A */ + n - LETTERS_CNT);
  5594. }
  5595. exports.singleLetterHash = singleLetterHash;
  5596. //#region Unicode Grapheme Break
  5597. function getGraphemeBreakType(codePoint) {
  5598. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  5599. return graphemeBreakTree.getGraphemeBreakType(codePoint);
  5600. }
  5601. exports.getGraphemeBreakType = getGraphemeBreakType;
  5602. function breakBetweenGraphemeBreakType(breakTypeA, breakTypeB) {
  5603. // http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
  5604. // !!! Let's make the common case a bit faster
  5605. if (breakTypeA === 0 /* Other */) {
  5606. // see https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakTest-13.0.0d10.html#table
  5607. return (breakTypeB !== 5 /* Extend */ && breakTypeB !== 7 /* SpacingMark */);
  5608. }
  5609. // Do not break between a CR and LF. Otherwise, break before and after controls.
  5610. // GB3 CR × LF
  5611. // GB4 (Control | CR | LF) ÷
  5612. // GB5 ÷ (Control | CR | LF)
  5613. if (breakTypeA === 2 /* CR */) {
  5614. if (breakTypeB === 3 /* LF */) {
  5615. return false; // GB3
  5616. }
  5617. }
  5618. if (breakTypeA === 4 /* Control */ || breakTypeA === 2 /* CR */ || breakTypeA === 3 /* LF */) {
  5619. return true; // GB4
  5620. }
  5621. if (breakTypeB === 4 /* Control */ || breakTypeB === 2 /* CR */ || breakTypeB === 3 /* LF */) {
  5622. return true; // GB5
  5623. }
  5624. // Do not break Hangul syllable sequences.
  5625. // GB6 L × (L | V | LV | LVT)
  5626. // GB7 (LV | V) × (V | T)
  5627. // GB8 (LVT | T) × T
  5628. if (breakTypeA === 8 /* L */) {
  5629. if (breakTypeB === 8 /* L */ || breakTypeB === 9 /* V */ || breakTypeB === 11 /* LV */ || breakTypeB === 12 /* LVT */) {
  5630. return false; // GB6
  5631. }
  5632. }
  5633. if (breakTypeA === 11 /* LV */ || breakTypeA === 9 /* V */) {
  5634. if (breakTypeB === 9 /* V */ || breakTypeB === 10 /* T */) {
  5635. return false; // GB7
  5636. }
  5637. }
  5638. if (breakTypeA === 12 /* LVT */ || breakTypeA === 10 /* T */) {
  5639. if (breakTypeB === 10 /* T */) {
  5640. return false; // GB8
  5641. }
  5642. }
  5643. // Do not break before extending characters or ZWJ.
  5644. // GB9 × (Extend | ZWJ)
  5645. if (breakTypeB === 5 /* Extend */ || breakTypeB === 13 /* ZWJ */) {
  5646. return false; // GB9
  5647. }
  5648. // The GB9a and GB9b rules only apply to extended grapheme clusters:
  5649. // Do not break before SpacingMarks, or after Prepend characters.
  5650. // GB9a × SpacingMark
  5651. // GB9b Prepend ×
  5652. if (breakTypeB === 7 /* SpacingMark */) {
  5653. return false; // GB9a
  5654. }
  5655. if (breakTypeA === 1 /* Prepend */) {
  5656. return false; // GB9b
  5657. }
  5658. // Do not break within emoji modifier sequences or emoji zwj sequences.
  5659. // GB11 \p{Extended_Pictographic} Extend* ZWJ × \p{Extended_Pictographic}
  5660. if (breakTypeA === 13 /* ZWJ */ && breakTypeB === 14 /* Extended_Pictographic */) {
  5661. // Note: we are not implementing the rule entirely here to avoid introducing states
  5662. return false; // GB11
  5663. }
  5664. // GB12 sot (RI RI)* RI × RI
  5665. // GB13 [^RI] (RI RI)* RI × RI
  5666. if (breakTypeA === 6 /* Regional_Indicator */ && breakTypeB === 6 /* Regional_Indicator */) {
  5667. // Note: we are not implementing the rule entirely here to avoid introducing states
  5668. return false; // GB12 & GB13
  5669. }
  5670. // GB999 Any ÷ Any
  5671. return true;
  5672. }
  5673. exports.breakBetweenGraphemeBreakType = breakBetweenGraphemeBreakType;
  5674. var GraphemeBreakTree = /** @class */ (function () {
  5675. function GraphemeBreakTree() {
  5676. this._data = getGraphemeBreakRawData();
  5677. }
  5678. GraphemeBreakTree.getInstance = function () {
  5679. if (!GraphemeBreakTree._INSTANCE) {
  5680. GraphemeBreakTree._INSTANCE = new GraphemeBreakTree();
  5681. }
  5682. return GraphemeBreakTree._INSTANCE;
  5683. };
  5684. GraphemeBreakTree.prototype.getGraphemeBreakType = function (codePoint) {
  5685. // !!! Let's make 7bit ASCII a bit faster: 0..31
  5686. if (codePoint < 32) {
  5687. if (codePoint === 10 /* LineFeed */) {
  5688. return 3 /* LF */;
  5689. }
  5690. if (codePoint === 13 /* CarriageReturn */) {
  5691. return 2 /* CR */;
  5692. }
  5693. return 4 /* Control */;
  5694. }
  5695. // !!! Let's make 7bit ASCII a bit faster: 32..126
  5696. if (codePoint < 127) {
  5697. return 0 /* Other */;
  5698. }
  5699. var data = this._data;
  5700. var nodeCount = data.length / 3;
  5701. var nodeIndex = 1;
  5702. while (nodeIndex <= nodeCount) {
  5703. if (codePoint < data[3 * nodeIndex]) {
  5704. // go left
  5705. nodeIndex = 2 * nodeIndex;
  5706. }
  5707. else if (codePoint > data[3 * nodeIndex + 1]) {
  5708. // go right
  5709. nodeIndex = 2 * nodeIndex + 1;
  5710. }
  5711. else {
  5712. // hit
  5713. return data[3 * nodeIndex + 2];
  5714. }
  5715. }
  5716. return 0 /* Other */;
  5717. };
  5718. GraphemeBreakTree._INSTANCE = null;
  5719. return GraphemeBreakTree;
  5720. }());
  5721. function getGraphemeBreakRawData() {
  5722. // generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-grapheme-break.js
  5723. return JSON.parse('[0,0,0,51592,51592,11,44424,44424,11,72251,72254,5,7150,7150,7,48008,48008,11,55176,55176,11,128420,128420,14,3276,3277,5,9979,9980,14,46216,46216,11,49800,49800,11,53384,53384,11,70726,70726,5,122915,122916,5,129320,129327,14,2558,2558,5,5906,5908,5,9762,9763,14,43360,43388,8,45320,45320,11,47112,47112,11,48904,48904,11,50696,50696,11,52488,52488,11,54280,54280,11,70082,70083,1,71350,71350,7,73111,73111,5,127892,127893,14,128726,128727,14,129473,129474,14,2027,2035,5,2901,2902,5,3784,3789,5,6754,6754,5,8418,8420,5,9877,9877,14,11088,11088,14,44008,44008,5,44872,44872,11,45768,45768,11,46664,46664,11,47560,47560,11,48456,48456,11,49352,49352,11,50248,50248,11,51144,51144,11,52040,52040,11,52936,52936,11,53832,53832,11,54728,54728,11,69811,69814,5,70459,70460,5,71096,71099,7,71998,71998,5,72874,72880,5,119149,119149,7,127374,127374,14,128335,128335,14,128482,128482,14,128765,128767,14,129399,129400,14,129680,129685,14,1476,1477,5,2377,2380,7,2759,2760,5,3137,3140,7,3458,3459,7,4153,4154,5,6432,6434,5,6978,6978,5,7675,7679,5,9723,9726,14,9823,9823,14,9919,9923,14,10035,10036,14,42736,42737,5,43596,43596,5,44200,44200,11,44648,44648,11,45096,45096,11,45544,45544,11,45992,45992,11,46440,46440,11,46888,46888,11,47336,47336,11,47784,47784,11,48232,48232,11,48680,48680,11,49128,49128,11,49576,49576,11,50024,50024,11,50472,50472,11,50920,50920,11,51368,51368,11,51816,51816,11,52264,52264,11,52712,52712,11,53160,53160,11,53608,53608,11,54056,54056,11,54504,54504,11,54952,54952,11,68108,68111,5,69933,69940,5,70197,70197,7,70498,70499,7,70845,70845,5,71229,71229,5,71727,71735,5,72154,72155,5,72344,72345,5,73023,73029,5,94095,94098,5,121403,121452,5,126981,127182,14,127538,127546,14,127990,127990,14,128391,128391,14,128445,128449,14,128500,128505,14,128752,128752,14,129160,129167,14,129356,129356,14,129432,129442,14,129648,129651,14,129751,131069,14,173,173,4,1757,1757,1,2274,2274,1,2494,2494,5,2641,2641,5,2876,2876,5,3014,3016,7,3262,3262,7,3393,3396,5,3570,3571,7,3968,3972,5,4228,4228,7,6086,6086,5,6679,6680,5,6912,6915,5,7080,7081,5,7380,7392,5,8252,8252,14,9096,9096,14,9748,9749,14,9784,9786,14,9833,9850,14,9890,9894,14,9938,9938,14,9999,9999,14,10085,10087,14,12349,12349,14,43136,43137,7,43454,43456,7,43755,43755,7,44088,44088,11,44312,44312,11,44536,44536,11,44760,44760,11,44984,44984,11,45208,45208,11,45432,45432,11,45656,45656,11,45880,45880,11,46104,46104,11,46328,46328,11,46552,46552,11,46776,46776,11,47000,47000,11,47224,47224,11,47448,47448,11,47672,47672,11,47896,47896,11,48120,48120,11,48344,48344,11,48568,48568,11,48792,48792,11,49016,49016,11,49240,49240,11,49464,49464,11,49688,49688,11,49912,49912,11,50136,50136,11,50360,50360,11,50584,50584,11,50808,50808,11,51032,51032,11,51256,51256,11,51480,51480,11,51704,51704,11,51928,51928,11,52152,52152,11,52376,52376,11,52600,52600,11,52824,52824,11,53048,53048,11,53272,53272,11,53496,53496,11,53720,53720,11,53944,53944,11,54168,54168,11,54392,54392,11,54616,54616,11,54840,54840,11,55064,55064,11,65438,65439,5,69633,69633,5,69837,69837,1,70018,70018,7,70188,70190,7,70368,70370,7,70465,70468,7,70712,70719,5,70835,70840,5,70850,70851,5,71132,71133,5,71340,71340,7,71458,71461,5,71985,71989,7,72002,72002,7,72193,72202,5,72281,72283,5,72766,72766,7,72885,72886,5,73104,73105,5,92912,92916,5,113824,113827,4,119173,119179,5,121505,121519,5,125136,125142,5,127279,127279,14,127489,127490,14,127570,127743,14,127900,127901,14,128254,128254,14,128369,128370,14,128400,128400,14,128425,128432,14,128468,128475,14,128489,128494,14,128715,128720,14,128745,128745,14,128759,128760,14,129004,129023,14,129296,129304,14,129340,129342,14,129388,129392,14,129404,129407,14,129454,129455,14,129485,129487,14,129659,129663,14,129719,129727,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2363,2363,7,2402,2403,5,2507,2508,7,2622,2624,7,2691,2691,7,2786,2787,5,2881,2884,5,3006,3006,5,3072,3072,5,3170,3171,5,3267,3268,7,3330,3331,7,3406,3406,1,3538,3540,5,3655,3662,5,3897,3897,5,4038,4038,5,4184,4185,5,4352,4447,8,6068,6069,5,6155,6157,5,6448,6449,7,6742,6742,5,6783,6783,5,6966,6970,5,7042,7042,7,7143,7143,7,7212,7219,5,7412,7412,5,8206,8207,4,8294,8303,4,8596,8601,14,9410,9410,14,9742,9742,14,9757,9757,14,9770,9770,14,9794,9794,14,9828,9828,14,9855,9855,14,9882,9882,14,9900,9903,14,9929,9933,14,9963,9967,14,9987,9988,14,10006,10006,14,10062,10062,14,10175,10175,14,11744,11775,5,42607,42607,5,43043,43044,7,43263,43263,5,43444,43445,7,43569,43570,5,43698,43700,5,43766,43766,5,44032,44032,11,44144,44144,11,44256,44256,11,44368,44368,11,44480,44480,11,44592,44592,11,44704,44704,11,44816,44816,11,44928,44928,11,45040,45040,11,45152,45152,11,45264,45264,11,45376,45376,11,45488,45488,11,45600,45600,11,45712,45712,11,45824,45824,11,45936,45936,11,46048,46048,11,46160,46160,11,46272,46272,11,46384,46384,11,46496,46496,11,46608,46608,11,46720,46720,11,46832,46832,11,46944,46944,11,47056,47056,11,47168,47168,11,47280,47280,11,47392,47392,11,47504,47504,11,47616,47616,11,47728,47728,11,47840,47840,11,47952,47952,11,48064,48064,11,48176,48176,11,48288,48288,11,48400,48400,11,48512,48512,11,48624,48624,11,48736,48736,11,48848,48848,11,48960,48960,11,49072,49072,11,49184,49184,11,49296,49296,11,49408,49408,11,49520,49520,11,49632,49632,11,49744,49744,11,49856,49856,11,49968,49968,11,50080,50080,11,50192,50192,11,50304,50304,11,50416,50416,11,50528,50528,11,50640,50640,11,50752,50752,11,50864,50864,11,50976,50976,11,51088,51088,11,51200,51200,11,51312,51312,11,51424,51424,11,51536,51536,11,51648,51648,11,51760,51760,11,51872,51872,11,51984,51984,11,52096,52096,11,52208,52208,11,52320,52320,11,52432,52432,11,52544,52544,11,52656,52656,11,52768,52768,11,52880,52880,11,52992,52992,11,53104,53104,11,53216,53216,11,53328,53328,11,53440,53440,11,53552,53552,11,53664,53664,11,53776,53776,11,53888,53888,11,54000,54000,11,54112,54112,11,54224,54224,11,54336,54336,11,54448,54448,11,54560,54560,11,54672,54672,11,54784,54784,11,54896,54896,11,55008,55008,11,55120,55120,11,64286,64286,5,66272,66272,5,68900,68903,5,69762,69762,7,69817,69818,5,69927,69931,5,70003,70003,5,70070,70078,5,70094,70094,7,70194,70195,7,70206,70206,5,70400,70401,5,70463,70463,7,70475,70477,7,70512,70516,5,70722,70724,5,70832,70832,5,70842,70842,5,70847,70848,5,71088,71089,7,71102,71102,7,71219,71226,5,71231,71232,5,71342,71343,7,71453,71455,5,71463,71467,5,71737,71738,5,71995,71996,5,72000,72000,7,72145,72147,7,72160,72160,5,72249,72249,7,72273,72278,5,72330,72342,5,72752,72758,5,72850,72871,5,72882,72883,5,73018,73018,5,73031,73031,5,73109,73109,5,73461,73462,7,94031,94031,5,94192,94193,7,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,126976,126979,14,127184,127231,14,127344,127345,14,127405,127461,14,127514,127514,14,127561,127567,14,127778,127779,14,127896,127896,14,127985,127986,14,127995,127999,5,128326,128328,14,128360,128366,14,128378,128378,14,128394,128397,14,128405,128406,14,128422,128423,14,128435,128443,14,128453,128464,14,128479,128480,14,128484,128487,14,128496,128498,14,128640,128709,14,128723,128724,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129096,129103,14,129292,129292,14,129311,129311,14,129329,129330,14,129344,129349,14,129360,129374,14,129394,129394,14,129402,129402,14,129413,129425,14,129445,129450,14,129466,129471,14,129483,129483,14,129511,129535,14,129653,129655,14,129667,129670,14,129705,129711,14,129731,129743,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2307,2307,7,2366,2368,7,2382,2383,7,2434,2435,7,2497,2500,5,2519,2519,5,2563,2563,7,2631,2632,5,2677,2677,5,2750,2752,7,2763,2764,7,2817,2817,5,2879,2879,5,2891,2892,7,2914,2915,5,3008,3008,5,3021,3021,5,3076,3076,5,3146,3149,5,3202,3203,7,3264,3265,7,3271,3272,7,3298,3299,5,3390,3390,5,3402,3404,7,3426,3427,5,3535,3535,5,3544,3550,7,3635,3635,7,3763,3763,7,3893,3893,5,3953,3966,5,3981,3991,5,4145,4145,7,4157,4158,5,4209,4212,5,4237,4237,5,4520,4607,10,5970,5971,5,6071,6077,5,6089,6099,5,6277,6278,5,6439,6440,5,6451,6456,7,6683,6683,5,6744,6750,5,6765,6770,7,6846,6846,5,6964,6964,5,6972,6972,5,7019,7027,5,7074,7077,5,7083,7085,5,7146,7148,7,7154,7155,7,7222,7223,5,7394,7400,5,7416,7417,5,8204,8204,5,8233,8233,4,8288,8292,4,8413,8416,5,8482,8482,14,8986,8987,14,9193,9203,14,9654,9654,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9775,14,9792,9792,14,9800,9811,14,9825,9826,14,9831,9831,14,9852,9853,14,9872,9873,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9936,9936,14,9941,9960,14,9974,9974,14,9982,9985,14,9992,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10145,10145,14,11013,11015,14,11503,11505,5,12334,12335,5,12951,12951,14,42612,42621,5,43014,43014,5,43047,43047,7,43204,43205,5,43335,43345,5,43395,43395,7,43450,43451,7,43561,43566,5,43573,43574,5,43644,43644,5,43710,43711,5,43758,43759,7,44005,44005,5,44012,44012,7,44060,44060,11,44116,44116,11,44172,44172,11,44228,44228,11,44284,44284,11,44340,44340,11,44396,44396,11,44452,44452,11,44508,44508,11,44564,44564,11,44620,44620,11,44676,44676,11,44732,44732,11,44788,44788,11,44844,44844,11,44900,44900,11,44956,44956,11,45012,45012,11,45068,45068,11,45124,45124,11,45180,45180,11,45236,45236,11,45292,45292,11,45348,45348,11,45404,45404,11,45460,45460,11,45516,45516,11,45572,45572,11,45628,45628,11,45684,45684,11,45740,45740,11,45796,45796,11,45852,45852,11,45908,45908,11,45964,45964,11,46020,46020,11,46076,46076,11,46132,46132,11,46188,46188,11,46244,46244,11,46300,46300,11,46356,46356,11,46412,46412,11,46468,46468,11,46524,46524,11,46580,46580,11,46636,46636,11,46692,46692,11,46748,46748,11,46804,46804,11,46860,46860,11,46916,46916,11,46972,46972,11,47028,47028,11,47084,47084,11,47140,47140,11,47196,47196,11,47252,47252,11,47308,47308,11,47364,47364,11,47420,47420,11,47476,47476,11,47532,47532,11,47588,47588,11,47644,47644,11,47700,47700,11,47756,47756,11,47812,47812,11,47868,47868,11,47924,47924,11,47980,47980,11,48036,48036,11,48092,48092,11,48148,48148,11,48204,48204,11,48260,48260,11,48316,48316,11,48372,48372,11,48428,48428,11,48484,48484,11,48540,48540,11,48596,48596,11,48652,48652,11,48708,48708,11,48764,48764,11,48820,48820,11,48876,48876,11,48932,48932,11,48988,48988,11,49044,49044,11,49100,49100,11,49156,49156,11,49212,49212,11,49268,49268,11,49324,49324,11,49380,49380,11,49436,49436,11,49492,49492,11,49548,49548,11,49604,49604,11,49660,49660,11,49716,49716,11,49772,49772,11,49828,49828,11,49884,49884,11,49940,49940,11,49996,49996,11,50052,50052,11,50108,50108,11,50164,50164,11,50220,50220,11,50276,50276,11,50332,50332,11,50388,50388,11,50444,50444,11,50500,50500,11,50556,50556,11,50612,50612,11,50668,50668,11,50724,50724,11,50780,50780,11,50836,50836,11,50892,50892,11,50948,50948,11,51004,51004,11,51060,51060,11,51116,51116,11,51172,51172,11,51228,51228,11,51284,51284,11,51340,51340,11,51396,51396,11,51452,51452,11,51508,51508,11,51564,51564,11,51620,51620,11,51676,51676,11,51732,51732,11,51788,51788,11,51844,51844,11,51900,51900,11,51956,51956,11,52012,52012,11,52068,52068,11,52124,52124,11,52180,52180,11,52236,52236,11,52292,52292,11,52348,52348,11,52404,52404,11,52460,52460,11,52516,52516,11,52572,52572,11,52628,52628,11,52684,52684,11,52740,52740,11,52796,52796,11,52852,52852,11,52908,52908,11,52964,52964,11,53020,53020,11,53076,53076,11,53132,53132,11,53188,53188,11,53244,53244,11,53300,53300,11,53356,53356,11,53412,53412,11,53468,53468,11,53524,53524,11,53580,53580,11,53636,53636,11,53692,53692,11,53748,53748,11,53804,53804,11,53860,53860,11,53916,53916,11,53972,53972,11,54028,54028,11,54084,54084,11,54140,54140,11,54196,54196,11,54252,54252,11,54308,54308,11,54364,54364,11,54420,54420,11,54476,54476,11,54532,54532,11,54588,54588,11,54644,54644,11,54700,54700,11,54756,54756,11,54812,54812,11,54868,54868,11,54924,54924,11,54980,54980,11,55036,55036,11,55092,55092,11,55148,55148,11,55216,55238,9,65056,65071,5,65529,65531,4,68097,68099,5,68159,68159,5,69446,69456,5,69688,69702,5,69808,69810,7,69815,69816,7,69821,69821,1,69888,69890,5,69932,69932,7,69957,69958,7,70016,70017,5,70067,70069,7,70079,70080,7,70089,70092,5,70095,70095,5,70191,70193,5,70196,70196,5,70198,70199,5,70367,70367,5,70371,70378,5,70402,70403,7,70462,70462,5,70464,70464,5,70471,70472,7,70487,70487,5,70502,70508,5,70709,70711,7,70720,70721,7,70725,70725,7,70750,70750,5,70833,70834,7,70841,70841,7,70843,70844,7,70846,70846,7,70849,70849,7,71087,71087,5,71090,71093,5,71100,71101,5,71103,71104,5,71216,71218,7,71227,71228,7,71230,71230,7,71339,71339,5,71341,71341,5,71344,71349,5,71351,71351,5,71456,71457,7,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123628,123631,5,125252,125258,5,126980,126980,14,127183,127183,14,127245,127247,14,127340,127343,14,127358,127359,14,127377,127386,14,127462,127487,6,127491,127503,14,127535,127535,14,127548,127551,14,127568,127569,14,127744,127777,14,127780,127891,14,127894,127895,14,127897,127899,14,127902,127984,14,127987,127989,14,127991,127994,14,128000,128253,14,128255,128317,14,128329,128334,14,128336,128359,14,128367,128368,14,128371,128377,14,128379,128390,14,128392,128393,14,128398,128399,14,128401,128404,14,128407,128419,14,128421,128421,14,128424,128424,14,128433,128434,14,128444,128444,14,128450,128452,14,128465,128467,14,128476,128478,14,128481,128481,14,128483,128483,14,128488,128488,14,128495,128495,14,128499,128499,14,128506,128591,14,128710,128714,14,128721,128722,14,128725,128725,14,128728,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129664,129666,14,129671,129679,14,129686,129704,14,129712,129718,14,129728,129730,14,129744,129750,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2259,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3134,3136,5,3142,3144,5,3157,3158,5,3201,3201,5,3260,3260,5,3263,3263,5,3266,3266,5,3270,3270,5,3274,3275,7,3285,3286,5,3328,3329,5,3387,3388,5,3391,3392,7,3398,3400,7,3405,3405,5,3415,3415,5,3457,3457,5,3530,3530,5,3536,3537,7,3542,3542,5,3551,3551,5,3633,3633,5,3636,3642,5,3761,3761,5,3764,3772,5,3864,3865,5,3895,3895,5,3902,3903,7,3967,3967,7,3974,3975,5,3993,4028,5,4141,4144,5,4146,4151,5,4155,4156,7,4182,4183,7,4190,4192,5,4226,4226,5,4229,4230,5,4253,4253,5,4448,4519,9,4957,4959,5,5938,5940,5,6002,6003,5,6070,6070,7,6078,6085,7,6087,6088,7,6109,6109,5,6158,6158,4,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6848,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7673,5,8203,8203,4,8205,8205,13,8232,8232,4,8234,8238,4,8265,8265,14,8293,8293,4,8400,8412,5,8417,8417,5,8421,8432,5,8505,8505,14,8617,8618,14,9000,9000,14,9167,9167,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9776,9783,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9935,14,9937,9937,14,9939,9940,14,9961,9962,14,9968,9973,14,9975,9978,14,9981,9981,14,9986,9986,14,9989,9989,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10084,14,10133,10135,14,10160,10160,14,10548,10549,14,11035,11036,14,11093,11093,14,11647,11647,5,12330,12333,5,12336,12336,14,12441,12442,5,12953,12953,14,42608,42610,5,42654,42655,5,43010,43010,5,43019,43019,5,43045,43046,5,43052,43052,5,43188,43203,7,43232,43249,5,43302,43309,5,43346,43347,7,43392,43394,5,43443,43443,5,43446,43449,5,43452,43453,5,43493,43493,5,43567,43568,7,43571,43572,7,43587,43587,5,43597,43597,7,43696,43696,5,43703,43704,5,43713,43713,5,43756,43757,5,43765,43765,7,44003,44004,7,44006,44007,7,44009,44010,7,44013,44013,5,44033,44059,12,44061,44087,12,44089,44115,12,44117,44143,12,44145,44171,12,44173,44199,12,44201,44227,12,44229,44255,12,44257,44283,12,44285,44311,12,44313,44339,12,44341,44367,12,44369,44395,12,44397,44423,12,44425,44451,12,44453,44479,12,44481,44507,12,44509,44535,12,44537,44563,12,44565,44591,12,44593,44619,12,44621,44647,12,44649,44675,12,44677,44703,12,44705,44731,12,44733,44759,12,44761,44787,12,44789,44815,12,44817,44843,12,44845,44871,12,44873,44899,12,44901,44927,12,44929,44955,12,44957,44983,12,44985,45011,12,45013,45039,12,45041,45067,12,45069,45095,12,45097,45123,12,45125,45151,12,45153,45179,12,45181,45207,12,45209,45235,12,45237,45263,12,45265,45291,12,45293,45319,12,45321,45347,12,45349,45375,12,45377,45403,12,45405,45431,12,45433,45459,12,45461,45487,12,45489,45515,12,45517,45543,12,45545,45571,12,45573,45599,12,45601,45627,12,45629,45655,12,45657,45683,12,45685,45711,12,45713,45739,12,45741,45767,12,45769,45795,12,45797,45823,12,45825,45851,12,45853,45879,12,45881,45907,12,45909,45935,12,45937,45963,12,45965,45991,12,45993,46019,12,46021,46047,12,46049,46075,12,46077,46103,12,46105,46131,12,46133,46159,12,46161,46187,12,46189,46215,12,46217,46243,12,46245,46271,12,46273,46299,12,46301,46327,12,46329,46355,12,46357,46383,12,46385,46411,12,46413,46439,12,46441,46467,12,46469,46495,12,46497,46523,12,46525,46551,12,46553,46579,12,46581,46607,12,46609,46635,12,46637,46663,12,46665,46691,12,46693,46719,12,46721,46747,12,46749,46775,12,46777,46803,12,46805,46831,12,46833,46859,12,46861,46887,12,46889,46915,12,46917,46943,12,46945,46971,12,46973,46999,12,47001,47027,12,47029,47055,12,47057,47083,12,47085,47111,12,47113,47139,12,47141,47167,12,47169,47195,12,47197,47223,12,47225,47251,12,47253,47279,12,47281,47307,12,47309,47335,12,47337,47363,12,47365,47391,12,47393,47419,12,47421,47447,12,47449,47475,12,47477,47503,12,47505,47531,12,47533,47559,12,47561,47587,12,47589,47615,12,47617,47643,12,47645,47671,12,47673,47699,12,47701,47727,12,47729,47755,12,47757,47783,12,47785,47811,12,47813,47839,12,47841,47867,12,47869,47895,12,47897,47923,12,47925,47951,12,47953,47979,12,47981,48007,12,48009,48035,12,48037,48063,12,48065,48091,12,48093,48119,12,48121,48147,12,48149,48175,12,48177,48203,12,48205,48231,12,48233,48259,12,48261,48287,12,48289,48315,12,48317,48343,12,48345,48371,12,48373,48399,12,48401,48427,12,48429,48455,12,48457,48483,12,48485,48511,12,48513,48539,12,48541,48567,12,48569,48595,12,48597,48623,12,48625,48651,12,48653,48679,12,48681,48707,12,48709,48735,12,48737,48763,12,48765,48791,12,48793,48819,12,48821,48847,12,48849,48875,12,48877,48903,12,48905,48931,12,48933,48959,12,48961,48987,12,48989,49015,12,49017,49043,12,49045,49071,12,49073,49099,12,49101,49127,12,49129,49155,12,49157,49183,12,49185,49211,12,49213,49239,12,49241,49267,12,49269,49295,12,49297,49323,12,49325,49351,12,49353,49379,12,49381,49407,12,49409,49435,12,49437,49463,12,49465,49491,12,49493,49519,12,49521,49547,12,49549,49575,12,49577,49603,12,49605,49631,12,49633,49659,12,49661,49687,12,49689,49715,12,49717,49743,12,49745,49771,12,49773,49799,12,49801,49827,12,49829,49855,12,49857,49883,12,49885,49911,12,49913,49939,12,49941,49967,12,49969,49995,12,49997,50023,12,50025,50051,12,50053,50079,12,50081,50107,12,50109,50135,12,50137,50163,12,50165,50191,12,50193,50219,12,50221,50247,12,50249,50275,12,50277,50303,12,50305,50331,12,50333,50359,12,50361,50387,12,50389,50415,12,50417,50443,12,50445,50471,12,50473,50499,12,50501,50527,12,50529,50555,12,50557,50583,12,50585,50611,12,50613,50639,12,50641,50667,12,50669,50695,12,50697,50723,12,50725,50751,12,50753,50779,12,50781,50807,12,50809,50835,12,50837,50863,12,50865,50891,12,50893,50919,12,50921,50947,12,50949,50975,12,50977,51003,12,51005,51031,12,51033,51059,12,51061,51087,12,51089,51115,12,51117,51143,12,51145,51171,12,51173,51199,12,51201,51227,12,51229,51255,12,51257,51283,12,51285,51311,12,51313,51339,12,51341,51367,12,51369,51395,12,51397,51423,12,51425,51451,12,51453,51479,12,51481,51507,12,51509,51535,12,51537,51563,12,51565,51591,12,51593,51619,12,51621,51647,12,51649,51675,12,51677,51703,12,51705,51731,12,51733,51759,12,51761,51787,12,51789,51815,12,51817,51843,12,51845,51871,12,51873,51899,12,51901,51927,12,51929,51955,12,51957,51983,12,51985,52011,12,52013,52039,12,52041,52067,12,52069,52095,12,52097,52123,12,52125,52151,12,52153,52179,12,52181,52207,12,52209,52235,12,52237,52263,12,52265,52291,12,52293,52319,12,52321,52347,12,52349,52375,12,52377,52403,12,52405,52431,12,52433,52459,12,52461,52487,12,52489,52515,12,52517,52543,12,52545,52571,12,52573,52599,12,52601,52627,12,52629,52655,12,52657,52683,12,52685,52711,12,52713,52739,12,52741,52767,12,52769,52795,12,52797,52823,12,52825,52851,12,52853,52879,12,52881,52907,12,52909,52935,12,52937,52963,12,52965,52991,12,52993,53019,12,53021,53047,12,53049,53075,12,53077,53103,12,53105,53131,12,53133,53159,12,53161,53187,12,53189,53215,12,53217,53243,12,53245,53271,12,53273,53299,12,53301,53327,12,53329,53355,12,53357,53383,12,53385,53411,12,53413,53439,12,53441,53467,12,53469,53495,12,53497,53523,12,53525,53551,12,53553,53579,12,53581,53607,12,53609,53635,12,53637,53663,12,53665,53691,12,53693,53719,12,53721,53747,12,53749,53775,12,53777,53803,12,53805,53831,12,53833,53859,12,53861,53887,12,53889,53915,12,53917,53943,12,53945,53971,12,53973,53999,12,54001,54027,12,54029,54055,12,54057,54083,12,54085,54111,12,54113,54139,12,54141,54167,12,54169,54195,12,54197,54223,12,54225,54251,12,54253,54279,12,54281,54307,12,54309,54335,12,54337,54363,12,54365,54391,12,54393,54419,12,54421,54447,12,54449,54475,12,54477,54503,12,54505,54531,12,54533,54559,12,54561,54587,12,54589,54615,12,54617,54643,12,54645,54671,12,54673,54699,12,54701,54727,12,54729,54755,12,54757,54783,12,54785,54811,12,54813,54839,12,54841,54867,12,54869,54895,12,54897,54923,12,54925,54951,12,54953,54979,12,54981,55007,12,55009,55035,12,55037,55063,12,55065,55091,12,55093,55119,12,55121,55147,12,55149,55175,12,55177,55203,12,55243,55291,10,65024,65039,5,65279,65279,4,65520,65528,4,66045,66045,5,66422,66426,5,68101,68102,5,68152,68154,5,68325,68326,5,69291,69292,5,69632,69632,7,69634,69634,7,69759,69761,5]');
  5724. }
  5725. });
  5726. //#endregion
  5727. /*---------------------------------------------------------------------------------------------
  5728. * Copyright (c) Microsoft Corporation. All rights reserved.
  5729. * Licensed under the MIT License. See License.txt in the project root for license information.
  5730. *--------------------------------------------------------------------------------------------*/
  5731. define(__m[10/*vs/base/common/types*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  5732. "use strict";
  5733. Object.defineProperty(exports, "__esModule", { value: true });
  5734. var _typeof = {
  5735. number: 'number',
  5736. string: 'string',
  5737. undefined: 'undefined',
  5738. object: 'object',
  5739. function: 'function'
  5740. };
  5741. /**
  5742. * @returns whether the provided parameter is a JavaScript Array or not.
  5743. */
  5744. function isArray(array) {
  5745. if (Array.isArray) {
  5746. return Array.isArray(array);
  5747. }
  5748. if (array && typeof (array.length) === _typeof.number && array.constructor === Array) {
  5749. return true;
  5750. }
  5751. return false;
  5752. }
  5753. exports.isArray = isArray;
  5754. /**
  5755. * @returns whether the provided parameter is a JavaScript String or not.
  5756. */
  5757. function isString(str) {
  5758. if (typeof (str) === _typeof.string || str instanceof String) {
  5759. return true;
  5760. }
  5761. return false;
  5762. }
  5763. exports.isString = isString;
  5764. /**
  5765. *
  5766. * @returns whether the provided parameter is of type `object` but **not**
  5767. * `null`, an `array`, a `regexp`, nor a `date`.
  5768. */
  5769. function isObject(obj) {
  5770. // The method can't do a type cast since there are type (like strings) which
  5771. // are subclasses of any put not positvely matched by the function. Hence type
  5772. // narrowing results in wrong results.
  5773. return typeof obj === _typeof.object
  5774. && obj !== null
  5775. && !Array.isArray(obj)
  5776. && !(obj instanceof RegExp)
  5777. && !(obj instanceof Date);
  5778. }
  5779. exports.isObject = isObject;
  5780. /**
  5781. * In **contrast** to just checking `typeof` this will return `false` for `NaN`.
  5782. * @returns whether the provided parameter is a JavaScript Number or not.
  5783. */
  5784. function isNumber(obj) {
  5785. if ((typeof (obj) === _typeof.number || obj instanceof Number) && !isNaN(obj)) {
  5786. return true;
  5787. }
  5788. return false;
  5789. }
  5790. exports.isNumber = isNumber;
  5791. /**
  5792. * @returns whether the provided parameter is a JavaScript Boolean or not.
  5793. */
  5794. function isBoolean(obj) {
  5795. return obj === true || obj === false;
  5796. }
  5797. exports.isBoolean = isBoolean;
  5798. /**
  5799. * @returns whether the provided parameter is undefined.
  5800. */
  5801. function isUndefined(obj) {
  5802. return typeof (obj) === _typeof.undefined;
  5803. }
  5804. exports.isUndefined = isUndefined;
  5805. /**
  5806. * @returns whether the provided parameter is undefined or null.
  5807. */
  5808. function isUndefinedOrNull(obj) {
  5809. return isUndefined(obj) || obj === null;
  5810. }
  5811. exports.isUndefinedOrNull = isUndefinedOrNull;
  5812. function assertType(condition, type) {
  5813. if (!condition) {
  5814. throw new Error(type ? "Unexpected type, expected '" + type + "'" : 'Unexpected type');
  5815. }
  5816. }
  5817. exports.assertType = assertType;
  5818. var hasOwnProperty = Object.prototype.hasOwnProperty;
  5819. /**
  5820. * @returns whether the provided parameter is an empty JavaScript Object or not.
  5821. */
  5822. function isEmptyObject(obj) {
  5823. if (!isObject(obj)) {
  5824. return false;
  5825. }
  5826. for (var key in obj) {
  5827. if (hasOwnProperty.call(obj, key)) {
  5828. return false;
  5829. }
  5830. }
  5831. return true;
  5832. }
  5833. exports.isEmptyObject = isEmptyObject;
  5834. /**
  5835. * @returns whether the provided parameter is a JavaScript Function or not.
  5836. */
  5837. function isFunction(obj) {
  5838. return typeof obj === _typeof.function;
  5839. }
  5840. exports.isFunction = isFunction;
  5841. function validateConstraints(args, constraints) {
  5842. var len = Math.min(args.length, constraints.length);
  5843. for (var i = 0; i < len; i++) {
  5844. validateConstraint(args[i], constraints[i]);
  5845. }
  5846. }
  5847. exports.validateConstraints = validateConstraints;
  5848. function validateConstraint(arg, constraint) {
  5849. if (isString(constraint)) {
  5850. if (typeof arg !== constraint) {
  5851. throw new Error("argument does not match constraint: typeof " + constraint);
  5852. }
  5853. }
  5854. else if (isFunction(constraint)) {
  5855. try {
  5856. if (arg instanceof constraint) {
  5857. return;
  5858. }
  5859. }
  5860. catch (_a) {
  5861. // ignore
  5862. }
  5863. if (!isUndefinedOrNull(arg) && arg.constructor === constraint) {
  5864. return;
  5865. }
  5866. if (constraint.length === 1 && constraint.call(undefined, arg) === true) {
  5867. return;
  5868. }
  5869. throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true");
  5870. }
  5871. }
  5872. exports.validateConstraint = validateConstraint;
  5873. function getAllPropertyNames(obj) {
  5874. var res = [];
  5875. var proto = Object.getPrototypeOf(obj);
  5876. while (Object.prototype !== proto) {
  5877. res = res.concat(Object.getOwnPropertyNames(proto));
  5878. proto = Object.getPrototypeOf(proto);
  5879. }
  5880. return res;
  5881. }
  5882. exports.getAllPropertyNames = getAllPropertyNames;
  5883. function getAllMethodNames(obj) {
  5884. var methods = [];
  5885. for (var _i = 0, _a = getAllPropertyNames(obj); _i < _a.length; _i++) {
  5886. var prop = _a[_i];
  5887. if (typeof obj[prop] === 'function') {
  5888. methods.push(prop);
  5889. }
  5890. }
  5891. return methods;
  5892. }
  5893. exports.getAllMethodNames = getAllMethodNames;
  5894. function createProxyObject(methodNames, invoke) {
  5895. var createProxyMethod = function (method) {
  5896. return function () {
  5897. var args = Array.prototype.slice.call(arguments, 0);
  5898. return invoke(method, args);
  5899. };
  5900. };
  5901. var result = {};
  5902. for (var _i = 0, methodNames_1 = methodNames; _i < methodNames_1.length; _i++) {
  5903. var methodName = methodNames_1[_i];
  5904. result[methodName] = createProxyMethod(methodName);
  5905. }
  5906. return result;
  5907. }
  5908. exports.createProxyObject = createProxyObject;
  5909. /**
  5910. * Converts null to undefined, passes all other values through.
  5911. */
  5912. function withNullAsUndefined(x) {
  5913. return x === null ? undefined : x;
  5914. }
  5915. exports.withNullAsUndefined = withNullAsUndefined;
  5916. /**
  5917. * Converts undefined to null, passes all other values through.
  5918. */
  5919. function withUndefinedAsNull(x) {
  5920. return typeof x === 'undefined' ? null : x;
  5921. }
  5922. exports.withUndefinedAsNull = withUndefinedAsNull;
  5923. });
  5924. /*---------------------------------------------------------------------------------------------
  5925. * Copyright (c) Microsoft Corporation. All rights reserved.
  5926. * Licensed under the MIT License. See License.txt in the project root for license information.
  5927. *--------------------------------------------------------------------------------------------*/
  5928. define(__m[11/*vs/base/common/uint*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  5929. "use strict";
  5930. Object.defineProperty(exports, "__esModule", { value: true });
  5931. function toUint8(v) {
  5932. if (v < 0) {
  5933. return 0;
  5934. }
  5935. if (v > 255 /* MAX_UINT_8 */) {
  5936. return 255 /* MAX_UINT_8 */;
  5937. }
  5938. return v | 0;
  5939. }
  5940. exports.toUint8 = toUint8;
  5941. function toUint32(v) {
  5942. if (v < 0) {
  5943. return 0;
  5944. }
  5945. if (v > 4294967295 /* MAX_UINT_32 */) {
  5946. return 4294967295 /* MAX_UINT_32 */;
  5947. }
  5948. return v | 0;
  5949. }
  5950. exports.toUint32 = toUint32;
  5951. });
  5952. /*---------------------------------------------------------------------------------------------
  5953. * Copyright (c) Microsoft Corporation. All rights reserved.
  5954. * Licensed under the MIT License. See License.txt in the project root for license information.
  5955. *--------------------------------------------------------------------------------------------*/
  5956. define(__m[12/*vs/base/common/uri*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  5957. "use strict";
  5958. var _a;
  5959. Object.defineProperty(exports, "__esModule", { value: true });
  5960. var _schemePattern = /^\w[\w\d+.-]*$/;
  5961. var _singleSlashStart = /^\//;
  5962. var _doubleSlashStart = /^\/\//;
  5963. function _validateUri(ret, _strict) {
  5964. // scheme, must be set
  5965. if (!ret.scheme && _strict) {
  5966. throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
  5967. }
  5968. // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
  5969. // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  5970. if (ret.scheme && !_schemePattern.test(ret.scheme)) {
  5971. throw new Error('[UriError]: Scheme contains illegal characters.');
  5972. }
  5973. // path, http://tools.ietf.org/html/rfc3986#section-3.3
  5974. // If a URI contains an authority component, then the path component
  5975. // must either be empty or begin with a slash ("/") character. If a URI
  5976. // does not contain an authority component, then the path cannot begin
  5977. // with two slash characters ("//").
  5978. if (ret.path) {
  5979. if (ret.authority) {
  5980. if (!_singleSlashStart.test(ret.path)) {
  5981. throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
  5982. }
  5983. }
  5984. else {
  5985. if (_doubleSlashStart.test(ret.path)) {
  5986. throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
  5987. }
  5988. }
  5989. }
  5990. }
  5991. // for a while we allowed uris *without* schemes and this is the migration
  5992. // for them, e.g. an uri without scheme and without strict-mode warns and falls
  5993. // back to the file-scheme. that should cause the least carnage and still be a
  5994. // clear warning
  5995. function _schemeFix(scheme, _strict) {
  5996. if (!scheme && !_strict) {
  5997. return 'file';
  5998. }
  5999. return scheme;
  6000. }
  6001. // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
  6002. function _referenceResolution(scheme, path) {
  6003. // the slash-character is our 'default base' as we don't
  6004. // support constructing URIs relative to other URIs. This
  6005. // also means that we alter and potentially break paths.
  6006. // see https://tools.ietf.org/html/rfc3986#section-5.1.4
  6007. switch (scheme) {
  6008. case 'https':
  6009. case 'http':
  6010. case 'file':
  6011. if (!path) {
  6012. path = _slash;
  6013. }
  6014. else if (path[0] !== _slash) {
  6015. path = _slash + path;
  6016. }
  6017. break;
  6018. }
  6019. return path;
  6020. }
  6021. var _empty = '';
  6022. var _slash = '/';
  6023. var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
  6024. /**
  6025. * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
  6026. * This class is a simple parser which creates the basic component parts
  6027. * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
  6028. * and encoding.
  6029. *
  6030. * foo://example.com:8042/over/there?name=ferret#nose
  6031. * \_/ \______________/\_________/ \_________/ \__/
  6032. * | | | | |
  6033. * scheme authority path query fragment
  6034. * | _____________________|__
  6035. * / \ / \
  6036. * urn:example:animal:ferret:nose
  6037. */
  6038. var URI = /** @class */ (function () {
  6039. /**
  6040. * @internal
  6041. */
  6042. function URI(schemeOrData, authority, path, query, fragment, _strict) {
  6043. if (_strict === void 0) { _strict = false; }
  6044. if (typeof schemeOrData === 'object') {
  6045. this.scheme = schemeOrData.scheme || _empty;
  6046. this.authority = schemeOrData.authority || _empty;
  6047. this.path = schemeOrData.path || _empty;
  6048. this.query = schemeOrData.query || _empty;
  6049. this.fragment = schemeOrData.fragment || _empty;
  6050. // no validation because it's this URI
  6051. // that creates uri components.
  6052. // _validateUri(this);
  6053. }
  6054. else {
  6055. this.scheme = _schemeFix(schemeOrData, _strict);
  6056. this.authority = authority || _empty;
  6057. this.path = _referenceResolution(this.scheme, path || _empty);
  6058. this.query = query || _empty;
  6059. this.fragment = fragment || _empty;
  6060. _validateUri(this, _strict);
  6061. }
  6062. }
  6063. URI.isUri = function (thing) {
  6064. if (thing instanceof URI) {
  6065. return true;
  6066. }
  6067. if (!thing) {
  6068. return false;
  6069. }
  6070. return typeof thing.authority === 'string'
  6071. && typeof thing.fragment === 'string'
  6072. && typeof thing.path === 'string'
  6073. && typeof thing.query === 'string'
  6074. && typeof thing.scheme === 'string'
  6075. && typeof thing.fsPath === 'function'
  6076. && typeof thing.with === 'function'
  6077. && typeof thing.toString === 'function';
  6078. };
  6079. Object.defineProperty(URI.prototype, "fsPath", {
  6080. // ---- filesystem path -----------------------
  6081. /**
  6082. * Returns a string representing the corresponding file system path of this URI.
  6083. * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
  6084. * platform specific path separator.
  6085. *
  6086. * * Will *not* validate the path for invalid characters and semantics.
  6087. * * Will *not* look at the scheme of this URI.
  6088. * * The result shall *not* be used for display purposes but for accessing a file on disk.
  6089. *
  6090. *
  6091. * The *difference* to `URI#path` is the use of the platform specific separator and the handling
  6092. * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
  6093. *
  6094. * ```ts
  6095. const u = URI.parse('file://server/c$/folder/file.txt')
  6096. u.authority === 'server'
  6097. u.path === '/shares/c$/file.txt'
  6098. u.fsPath === '\\server\c$\folder\file.txt'
  6099. ```
  6100. *
  6101. * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
  6102. * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
  6103. * with URIs that represent files on disk (`file` scheme).
  6104. */
  6105. get: function () {
  6106. // if (this.scheme !== 'file') {
  6107. // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
  6108. // }
  6109. return _makeFsPath(this);
  6110. },
  6111. enumerable: true,
  6112. configurable: true
  6113. });
  6114. // ---- modify to new -------------------------
  6115. URI.prototype.with = function (change) {
  6116. if (!change) {
  6117. return this;
  6118. }
  6119. var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
  6120. if (scheme === undefined) {
  6121. scheme = this.scheme;
  6122. }
  6123. else if (scheme === null) {
  6124. scheme = _empty;
  6125. }
  6126. if (authority === undefined) {
  6127. authority = this.authority;
  6128. }
  6129. else if (authority === null) {
  6130. authority = _empty;
  6131. }
  6132. if (path === undefined) {
  6133. path = this.path;
  6134. }
  6135. else if (path === null) {
  6136. path = _empty;
  6137. }
  6138. if (query === undefined) {
  6139. query = this.query;
  6140. }
  6141. else if (query === null) {
  6142. query = _empty;
  6143. }
  6144. if (fragment === undefined) {
  6145. fragment = this.fragment;
  6146. }
  6147. else if (fragment === null) {
  6148. fragment = _empty;
  6149. }
  6150. if (scheme === this.scheme
  6151. && authority === this.authority
  6152. && path === this.path
  6153. && query === this.query
  6154. && fragment === this.fragment) {
  6155. return this;
  6156. }
  6157. return new _URI(scheme, authority, path, query, fragment);
  6158. };
  6159. // ---- parse & validate ------------------------
  6160. /**
  6161. * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
  6162. * `file:///usr/home`, or `scheme:with/path`.
  6163. *
  6164. * @param value A string which represents an URI (see `URI#toString`).
  6165. */
  6166. URI.parse = function (value, _strict) {
  6167. if (_strict === void 0) { _strict = false; }
  6168. var match = _regexp.exec(value);
  6169. if (!match) {
  6170. return new _URI(_empty, _empty, _empty, _empty, _empty);
  6171. }
  6172. return new _URI(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict);
  6173. };
  6174. /**
  6175. * Creates a new URI from a file system path, e.g. `c:\my\files`,
  6176. * `/usr/home`, or `\\server\share\some\path`.
  6177. *
  6178. * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
  6179. * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
  6180. * `URI.parse('file://' + path)` because the path might contain characters that are
  6181. * interpreted (# and ?). See the following sample:
  6182. * ```ts
  6183. const good = URI.file('/coding/c#/project1');
  6184. good.scheme === 'file';
  6185. good.path === '/coding/c#/project1';
  6186. good.fragment === '';
  6187. const bad = URI.parse('file://' + '/coding/c#/project1');
  6188. bad.scheme === 'file';
  6189. bad.path === '/coding/c'; // path is now broken
  6190. bad.fragment === '/project1';
  6191. ```
  6192. *
  6193. * @param path A file system path (see `URI#fsPath`)
  6194. */
  6195. URI.file = function (path) {
  6196. var authority = _empty;
  6197. // normalize to fwd-slashes on windows,
  6198. // on other systems bwd-slashes are valid
  6199. // filename character, eg /f\oo/ba\r.txt
  6200. if (platform_1.isWindows) {
  6201. path = path.replace(/\\/g, _slash);
  6202. }
  6203. // check for authority as used in UNC shares
  6204. // or use the path as given
  6205. if (path[0] === _slash && path[1] === _slash) {
  6206. var idx = path.indexOf(_slash, 2);
  6207. if (idx === -1) {
  6208. authority = path.substring(2);
  6209. path = _slash;
  6210. }
  6211. else {
  6212. authority = path.substring(2, idx);
  6213. path = path.substring(idx) || _slash;
  6214. }
  6215. }
  6216. return new _URI('file', authority, path, _empty, _empty);
  6217. };
  6218. URI.from = function (components) {
  6219. return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
  6220. };
  6221. // ---- printing/externalize ---------------------------
  6222. /**
  6223. * Creates a string representation for this URI. It's guaranteed that calling
  6224. * `URI.parse` with the result of this function creates an URI which is equal
  6225. * to this URI.
  6226. *
  6227. * * The result shall *not* be used for display purposes but for externalization or transport.
  6228. * * The result will be encoded using the percentage encoding and encoding happens mostly
  6229. * ignore the scheme-specific encoding rules.
  6230. *
  6231. * @param skipEncoding Do not encode the result, default is `false`
  6232. */
  6233. URI.prototype.toString = function (skipEncoding) {
  6234. if (skipEncoding === void 0) { skipEncoding = false; }
  6235. return _asFormatted(this, skipEncoding);
  6236. };
  6237. URI.prototype.toJSON = function () {
  6238. return this;
  6239. };
  6240. URI.revive = function (data) {
  6241. if (!data) {
  6242. return data;
  6243. }
  6244. else if (data instanceof URI) {
  6245. return data;
  6246. }
  6247. else {
  6248. var result = new _URI(data);
  6249. result._formatted = data.external;
  6250. result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
  6251. return result;
  6252. }
  6253. };
  6254. return URI;
  6255. }());
  6256. exports.URI = URI;
  6257. var _pathSepMarker = platform_1.isWindows ? 1 : undefined;
  6258. // eslint-disable-next-line @typescript-eslint/class-name-casing
  6259. var _URI = /** @class */ (function (_super) {
  6260. __extends(_URI, _super);
  6261. function _URI() {
  6262. var _this = _super !== null && _super.apply(this, arguments) || this;
  6263. _this._formatted = null;
  6264. _this._fsPath = null;
  6265. return _this;
  6266. }
  6267. Object.defineProperty(_URI.prototype, "fsPath", {
  6268. get: function () {
  6269. if (!this._fsPath) {
  6270. this._fsPath = _makeFsPath(this);
  6271. }
  6272. return this._fsPath;
  6273. },
  6274. enumerable: true,
  6275. configurable: true
  6276. });
  6277. _URI.prototype.toString = function (skipEncoding) {
  6278. if (skipEncoding === void 0) { skipEncoding = false; }
  6279. if (!skipEncoding) {
  6280. if (!this._formatted) {
  6281. this._formatted = _asFormatted(this, false);
  6282. }
  6283. return this._formatted;
  6284. }
  6285. else {
  6286. // we don't cache that
  6287. return _asFormatted(this, true);
  6288. }
  6289. };
  6290. _URI.prototype.toJSON = function () {
  6291. var res = {
  6292. $mid: 1
  6293. };
  6294. // cached state
  6295. if (this._fsPath) {
  6296. res.fsPath = this._fsPath;
  6297. res._sep = _pathSepMarker;
  6298. }
  6299. if (this._formatted) {
  6300. res.external = this._formatted;
  6301. }
  6302. // uri components
  6303. if (this.path) {
  6304. res.path = this.path;
  6305. }
  6306. if (this.scheme) {
  6307. res.scheme = this.scheme;
  6308. }
  6309. if (this.authority) {
  6310. res.authority = this.authority;
  6311. }
  6312. if (this.query) {
  6313. res.query = this.query;
  6314. }
  6315. if (this.fragment) {
  6316. res.fragment = this.fragment;
  6317. }
  6318. return res;
  6319. };
  6320. return _URI;
  6321. }(URI));
  6322. // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
  6323. var encodeTable = (_a = {},
  6324. _a[58 /* Colon */] = '%3A',
  6325. _a[47 /* Slash */] = '%2F',
  6326. _a[63 /* QuestionMark */] = '%3F',
  6327. _a[35 /* Hash */] = '%23',
  6328. _a[91 /* OpenSquareBracket */] = '%5B',
  6329. _a[93 /* CloseSquareBracket */] = '%5D',
  6330. _a[64 /* AtSign */] = '%40',
  6331. _a[33 /* ExclamationMark */] = '%21',
  6332. _a[36 /* DollarSign */] = '%24',
  6333. _a[38 /* Ampersand */] = '%26',
  6334. _a[39 /* SingleQuote */] = '%27',
  6335. _a[40 /* OpenParen */] = '%28',
  6336. _a[41 /* CloseParen */] = '%29',
  6337. _a[42 /* Asterisk */] = '%2A',
  6338. _a[43 /* Plus */] = '%2B',
  6339. _a[44 /* Comma */] = '%2C',
  6340. _a[59 /* Semicolon */] = '%3B',
  6341. _a[61 /* Equals */] = '%3D',
  6342. _a[32 /* Space */] = '%20',
  6343. _a);
  6344. function encodeURIComponentFast(uriComponent, allowSlash) {
  6345. var res = undefined;
  6346. var nativeEncodePos = -1;
  6347. for (var pos = 0; pos < uriComponent.length; pos++) {
  6348. var code = uriComponent.charCodeAt(pos);
  6349. // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
  6350. if ((code >= 97 /* a */ && code <= 122 /* z */)
  6351. || (code >= 65 /* A */ && code <= 90 /* Z */)
  6352. || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
  6353. || code === 45 /* Dash */
  6354. || code === 46 /* Period */
  6355. || code === 95 /* Underline */
  6356. || code === 126 /* Tilde */
  6357. || (allowSlash && code === 47 /* Slash */)) {
  6358. // check if we are delaying native encode
  6359. if (nativeEncodePos !== -1) {
  6360. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  6361. nativeEncodePos = -1;
  6362. }
  6363. // check if we write into a new string (by default we try to return the param)
  6364. if (res !== undefined) {
  6365. res += uriComponent.charAt(pos);
  6366. }
  6367. }
  6368. else {
  6369. // encoding needed, we need to allocate a new string
  6370. if (res === undefined) {
  6371. res = uriComponent.substr(0, pos);
  6372. }
  6373. // check with default table first
  6374. var escaped = encodeTable[code];
  6375. if (escaped !== undefined) {
  6376. // check if we are delaying native encode
  6377. if (nativeEncodePos !== -1) {
  6378. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  6379. nativeEncodePos = -1;
  6380. }
  6381. // append escaped variant to result
  6382. res += escaped;
  6383. }
  6384. else if (nativeEncodePos === -1) {
  6385. // use native encode only when needed
  6386. nativeEncodePos = pos;
  6387. }
  6388. }
  6389. }
  6390. if (nativeEncodePos !== -1) {
  6391. res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
  6392. }
  6393. return res !== undefined ? res : uriComponent;
  6394. }
  6395. function encodeURIComponentMinimal(path) {
  6396. var res = undefined;
  6397. for (var pos = 0; pos < path.length; pos++) {
  6398. var code = path.charCodeAt(pos);
  6399. if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
  6400. if (res === undefined) {
  6401. res = path.substr(0, pos);
  6402. }
  6403. res += encodeTable[code];
  6404. }
  6405. else {
  6406. if (res !== undefined) {
  6407. res += path[pos];
  6408. }
  6409. }
  6410. }
  6411. return res !== undefined ? res : path;
  6412. }
  6413. /**
  6414. * Compute `fsPath` for the given uri
  6415. */
  6416. function _makeFsPath(uri) {
  6417. var value;
  6418. if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
  6419. // unc path: file://shares/c$/far/boo
  6420. value = "//" + uri.authority + uri.path;
  6421. }
  6422. else if (uri.path.charCodeAt(0) === 47 /* Slash */
  6423. && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
  6424. && uri.path.charCodeAt(2) === 58 /* Colon */) {
  6425. // windows drive letter: file:///c:/far/boo
  6426. value = uri.path[1].toLowerCase() + uri.path.substr(2);
  6427. }
  6428. else {
  6429. // other path
  6430. value = uri.path;
  6431. }
  6432. if (platform_1.isWindows) {
  6433. value = value.replace(/\//g, '\\');
  6434. }
  6435. return value;
  6436. }
  6437. /**
  6438. * Create the external version of a uri
  6439. */
  6440. function _asFormatted(uri, skipEncoding) {
  6441. var encoder = !skipEncoding
  6442. ? encodeURIComponentFast
  6443. : encodeURIComponentMinimal;
  6444. var res = '';
  6445. var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
  6446. if (scheme) {
  6447. res += scheme;
  6448. res += ':';
  6449. }
  6450. if (authority || scheme === 'file') {
  6451. res += _slash;
  6452. res += _slash;
  6453. }
  6454. if (authority) {
  6455. var idx = authority.indexOf('@');
  6456. if (idx !== -1) {
  6457. // <user>@<auth>
  6458. var userinfo = authority.substr(0, idx);
  6459. authority = authority.substr(idx + 1);
  6460. idx = userinfo.indexOf(':');
  6461. if (idx === -1) {
  6462. res += encoder(userinfo, false);
  6463. }
  6464. else {
  6465. // <user>:<pass>@<auth>
  6466. res += encoder(userinfo.substr(0, idx), false);
  6467. res += ':';
  6468. res += encoder(userinfo.substr(idx + 1), false);
  6469. }
  6470. res += '@';
  6471. }
  6472. authority = authority.toLowerCase();
  6473. idx = authority.indexOf(':');
  6474. if (idx === -1) {
  6475. res += encoder(authority, false);
  6476. }
  6477. else {
  6478. // <auth>:<port>
  6479. res += encoder(authority.substr(0, idx), false);
  6480. res += authority.substr(idx);
  6481. }
  6482. }
  6483. if (path) {
  6484. // lower-case windows drive letters in /C:/fff or C:/fff
  6485. if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
  6486. var code = path.charCodeAt(1);
  6487. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  6488. path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
  6489. }
  6490. }
  6491. else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
  6492. var code = path.charCodeAt(0);
  6493. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  6494. path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
  6495. }
  6496. }
  6497. // encode the rest of the path
  6498. res += encoder(path, true);
  6499. }
  6500. if (query) {
  6501. res += '?';
  6502. res += encoder(query, false);
  6503. }
  6504. if (fragment) {
  6505. res += '#';
  6506. res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
  6507. }
  6508. return res;
  6509. }
  6510. // --- decode
  6511. function decodeURIComponentGraceful(str) {
  6512. try {
  6513. return decodeURIComponent(str);
  6514. }
  6515. catch (_a) {
  6516. if (str.length > 3) {
  6517. return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
  6518. }
  6519. else {
  6520. return str;
  6521. }
  6522. }
  6523. }
  6524. var _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
  6525. function percentDecode(str) {
  6526. if (!str.match(_rEncodedAsHex)) {
  6527. return str;
  6528. }
  6529. return str.replace(_rEncodedAsHex, function (match) { return decodeURIComponentGraceful(match); });
  6530. }
  6531. });
  6532. /*---------------------------------------------------------------------------------------------
  6533. * Copyright (c) Microsoft Corporation. All rights reserved.
  6534. * Licensed under the MIT License. See License.txt in the project root for license information.
  6535. *--------------------------------------------------------------------------------------------*/
  6536. define(__m[32/*vs/base/common/worker/simpleWorker*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/errors*/,8/*vs/base/common/lifecycle*/,4/*vs/base/common/platform*/,10/*vs/base/common/types*/]), function (require, exports, errors_1, lifecycle_1, platform_1, types) {
  6537. "use strict";
  6538. Object.defineProperty(exports, "__esModule", { value: true });
  6539. var INITIALIZE = '$initialize';
  6540. var webWorkerWarningLogged = false;
  6541. function logOnceWebWorkerWarning(err) {
  6542. if (!platform_1.isWeb) {
  6543. // running tests
  6544. return;
  6545. }
  6546. if (!webWorkerWarningLogged) {
  6547. webWorkerWarningLogged = true;
  6548. console.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/Microsoft/monaco-editor#faq');
  6549. }
  6550. console.warn(err.message);
  6551. }
  6552. exports.logOnceWebWorkerWarning = logOnceWebWorkerWarning;
  6553. var SimpleWorkerProtocol = /** @class */ (function () {
  6554. function SimpleWorkerProtocol(handler) {
  6555. this._workerId = -1;
  6556. this._handler = handler;
  6557. this._lastSentReq = 0;
  6558. this._pendingReplies = Object.create(null);
  6559. }
  6560. SimpleWorkerProtocol.prototype.setWorkerId = function (workerId) {
  6561. this._workerId = workerId;
  6562. };
  6563. SimpleWorkerProtocol.prototype.sendMessage = function (method, args) {
  6564. var _this = this;
  6565. var req = String(++this._lastSentReq);
  6566. return new Promise(function (resolve, reject) {
  6567. _this._pendingReplies[req] = {
  6568. resolve: resolve,
  6569. reject: reject
  6570. };
  6571. _this._send({
  6572. vsWorker: _this._workerId,
  6573. req: req,
  6574. method: method,
  6575. args: args
  6576. });
  6577. });
  6578. };
  6579. SimpleWorkerProtocol.prototype.handleMessage = function (message) {
  6580. if (!message || !message.vsWorker) {
  6581. return;
  6582. }
  6583. if (this._workerId !== -1 && message.vsWorker !== this._workerId) {
  6584. return;
  6585. }
  6586. this._handleMessage(message);
  6587. };
  6588. SimpleWorkerProtocol.prototype._handleMessage = function (msg) {
  6589. var _this = this;
  6590. if (msg.seq) {
  6591. var replyMessage = msg;
  6592. if (!this._pendingReplies[replyMessage.seq]) {
  6593. console.warn('Got reply to unknown seq');
  6594. return;
  6595. }
  6596. var reply = this._pendingReplies[replyMessage.seq];
  6597. delete this._pendingReplies[replyMessage.seq];
  6598. if (replyMessage.err) {
  6599. var err = replyMessage.err;
  6600. if (replyMessage.err.$isError) {
  6601. err = new Error();
  6602. err.name = replyMessage.err.name;
  6603. err.message = replyMessage.err.message;
  6604. err.stack = replyMessage.err.stack;
  6605. }
  6606. reply.reject(err);
  6607. return;
  6608. }
  6609. reply.resolve(replyMessage.res);
  6610. return;
  6611. }
  6612. var requestMessage = msg;
  6613. var req = requestMessage.req;
  6614. var result = this._handler.handleMessage(requestMessage.method, requestMessage.args);
  6615. result.then(function (r) {
  6616. _this._send({
  6617. vsWorker: _this._workerId,
  6618. seq: req,
  6619. res: r,
  6620. err: undefined
  6621. });
  6622. }, function (e) {
  6623. if (e.detail instanceof Error) {
  6624. // Loading errors have a detail property that points to the actual error
  6625. e.detail = errors_1.transformErrorForSerialization(e.detail);
  6626. }
  6627. _this._send({
  6628. vsWorker: _this._workerId,
  6629. seq: req,
  6630. res: undefined,
  6631. err: errors_1.transformErrorForSerialization(e)
  6632. });
  6633. });
  6634. };
  6635. SimpleWorkerProtocol.prototype._send = function (msg) {
  6636. var transfer = [];
  6637. if (msg.req) {
  6638. var m = msg;
  6639. for (var i = 0; i < m.args.length; i++) {
  6640. if (m.args[i] instanceof ArrayBuffer) {
  6641. transfer.push(m.args[i]);
  6642. }
  6643. }
  6644. }
  6645. else {
  6646. var m = msg;
  6647. if (m.res instanceof ArrayBuffer) {
  6648. transfer.push(m.res);
  6649. }
  6650. }
  6651. this._handler.sendMessage(msg, transfer);
  6652. };
  6653. return SimpleWorkerProtocol;
  6654. }());
  6655. /**
  6656. * Main thread side
  6657. */
  6658. var SimpleWorkerClient = /** @class */ (function (_super) {
  6659. __extends(SimpleWorkerClient, _super);
  6660. function SimpleWorkerClient(workerFactory, moduleId, host) {
  6661. var _this = _super.call(this) || this;
  6662. var lazyProxyReject = null;
  6663. _this._worker = _this._register(workerFactory.create('vs/base/common/worker/simpleWorker', function (msg) {
  6664. _this._protocol.handleMessage(msg);
  6665. }, function (err) {
  6666. // in Firefox, web workers fail lazily :(
  6667. // we will reject the proxy
  6668. if (lazyProxyReject) {
  6669. lazyProxyReject(err);
  6670. }
  6671. }));
  6672. _this._protocol = new SimpleWorkerProtocol({
  6673. sendMessage: function (msg, transfer) {
  6674. _this._worker.postMessage(msg, transfer);
  6675. },
  6676. handleMessage: function (method, args) {
  6677. if (typeof host[method] !== 'function') {
  6678. return Promise.reject(new Error('Missing method ' + method + ' on main thread host.'));
  6679. }
  6680. try {
  6681. return Promise.resolve(host[method].apply(host, args));
  6682. }
  6683. catch (e) {
  6684. return Promise.reject(e);
  6685. }
  6686. }
  6687. });
  6688. _this._protocol.setWorkerId(_this._worker.getId());
  6689. // Gather loader configuration
  6690. var loaderConfiguration = null;
  6691. if (typeof self.require !== 'undefined' && typeof self.require.getConfig === 'function') {
  6692. // Get the configuration from the Monaco AMD Loader
  6693. loaderConfiguration = self.require.getConfig();
  6694. }
  6695. else if (typeof self.requirejs !== 'undefined') {
  6696. // Get the configuration from requirejs
  6697. loaderConfiguration = self.requirejs.s.contexts._.config;
  6698. }
  6699. var hostMethods = types.getAllMethodNames(host);
  6700. // Send initialize message
  6701. _this._onModuleLoaded = _this._protocol.sendMessage(INITIALIZE, [
  6702. _this._worker.getId(),
  6703. JSON.parse(JSON.stringify(loaderConfiguration)),
  6704. moduleId,
  6705. hostMethods,
  6706. ]);
  6707. // Create proxy to loaded code
  6708. var proxyMethodRequest = function (method, args) {
  6709. return _this._request(method, args);
  6710. };
  6711. _this._lazyProxy = new Promise(function (resolve, reject) {
  6712. lazyProxyReject = reject;
  6713. _this._onModuleLoaded.then(function (availableMethods) {
  6714. resolve(types.createProxyObject(availableMethods, proxyMethodRequest));
  6715. }, function (e) {
  6716. reject(e);
  6717. _this._onError('Worker failed to load ' + moduleId, e);
  6718. });
  6719. });
  6720. return _this;
  6721. }
  6722. SimpleWorkerClient.prototype.getProxyObject = function () {
  6723. return this._lazyProxy;
  6724. };
  6725. SimpleWorkerClient.prototype._request = function (method, args) {
  6726. var _this = this;
  6727. return new Promise(function (resolve, reject) {
  6728. _this._onModuleLoaded.then(function () {
  6729. _this._protocol.sendMessage(method, args).then(resolve, reject);
  6730. }, reject);
  6731. });
  6732. };
  6733. SimpleWorkerClient.prototype._onError = function (message, error) {
  6734. console.error(message);
  6735. console.info(error);
  6736. };
  6737. return SimpleWorkerClient;
  6738. }(lifecycle_1.Disposable));
  6739. exports.SimpleWorkerClient = SimpleWorkerClient;
  6740. /**
  6741. * Worker side
  6742. */
  6743. var SimpleWorkerServer = /** @class */ (function () {
  6744. function SimpleWorkerServer(postMessage, requestHandlerFactory) {
  6745. var _this = this;
  6746. this._requestHandlerFactory = requestHandlerFactory;
  6747. this._requestHandler = null;
  6748. this._protocol = new SimpleWorkerProtocol({
  6749. sendMessage: function (msg, transfer) {
  6750. postMessage(msg, transfer);
  6751. },
  6752. handleMessage: function (method, args) { return _this._handleMessage(method, args); }
  6753. });
  6754. }
  6755. SimpleWorkerServer.prototype.onmessage = function (msg) {
  6756. this._protocol.handleMessage(msg);
  6757. };
  6758. SimpleWorkerServer.prototype._handleMessage = function (method, args) {
  6759. if (method === INITIALIZE) {
  6760. return this.initialize(args[0], args[1], args[2], args[3]);
  6761. }
  6762. if (!this._requestHandler || typeof this._requestHandler[method] !== 'function') {
  6763. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  6764. }
  6765. try {
  6766. return Promise.resolve(this._requestHandler[method].apply(this._requestHandler, args));
  6767. }
  6768. catch (e) {
  6769. return Promise.reject(e);
  6770. }
  6771. };
  6772. SimpleWorkerServer.prototype.initialize = function (workerId, loaderConfig, moduleId, hostMethods) {
  6773. var _this = this;
  6774. this._protocol.setWorkerId(workerId);
  6775. var proxyMethodRequest = function (method, args) {
  6776. return _this._protocol.sendMessage(method, args);
  6777. };
  6778. var hostProxy = types.createProxyObject(hostMethods, proxyMethodRequest);
  6779. if (this._requestHandlerFactory) {
  6780. // static request handler
  6781. this._requestHandler = this._requestHandlerFactory(hostProxy);
  6782. return Promise.resolve(types.getAllMethodNames(this._requestHandler));
  6783. }
  6784. if (loaderConfig) {
  6785. // Remove 'baseUrl', handling it is beyond scope for now
  6786. if (typeof loaderConfig.baseUrl !== 'undefined') {
  6787. delete loaderConfig['baseUrl'];
  6788. }
  6789. if (typeof loaderConfig.paths !== 'undefined') {
  6790. if (typeof loaderConfig.paths.vs !== 'undefined') {
  6791. delete loaderConfig.paths['vs'];
  6792. }
  6793. }
  6794. // Since this is in a web worker, enable catching errors
  6795. loaderConfig.catchError = true;
  6796. self.require.config(loaderConfig);
  6797. }
  6798. return new Promise(function (resolve, reject) {
  6799. // Use the global require to be sure to get the global config
  6800. self.require([moduleId], function (module) {
  6801. _this._requestHandler = module.create(hostProxy);
  6802. if (!_this._requestHandler) {
  6803. reject(new Error("No RequestHandler!"));
  6804. return;
  6805. }
  6806. resolve(types.getAllMethodNames(_this._requestHandler));
  6807. }, reject);
  6808. });
  6809. };
  6810. return SimpleWorkerServer;
  6811. }());
  6812. exports.SimpleWorkerServer = SimpleWorkerServer;
  6813. /**
  6814. * Called on the worker side
  6815. */
  6816. function create(postMessage) {
  6817. return new SimpleWorkerServer(postMessage, null);
  6818. }
  6819. exports.create = create;
  6820. });
  6821. /*---------------------------------------------------------------------------------------------
  6822. * Copyright (c) Microsoft Corporation. All rights reserved.
  6823. * Licensed under the MIT License. See License.txt in the project root for license information.
  6824. *--------------------------------------------------------------------------------------------*/
  6825. define(__m[21/*vs/editor/common/core/characterClassifier*/], __M([0/*require*/,1/*exports*/,11/*vs/base/common/uint*/]), function (require, exports, uint_1) {
  6826. "use strict";
  6827. Object.defineProperty(exports, "__esModule", { value: true });
  6828. /**
  6829. * A fast character classifier that uses a compact array for ASCII values.
  6830. */
  6831. var CharacterClassifier = /** @class */ (function () {
  6832. function CharacterClassifier(_defaultValue) {
  6833. var defaultValue = uint_1.toUint8(_defaultValue);
  6834. this._defaultValue = defaultValue;
  6835. this._asciiMap = CharacterClassifier._createAsciiMap(defaultValue);
  6836. this._map = new Map();
  6837. }
  6838. CharacterClassifier._createAsciiMap = function (defaultValue) {
  6839. var asciiMap = new Uint8Array(256);
  6840. for (var i = 0; i < 256; i++) {
  6841. asciiMap[i] = defaultValue;
  6842. }
  6843. return asciiMap;
  6844. };
  6845. CharacterClassifier.prototype.set = function (charCode, _value) {
  6846. var value = uint_1.toUint8(_value);
  6847. if (charCode >= 0 && charCode < 256) {
  6848. this._asciiMap[charCode] = value;
  6849. }
  6850. else {
  6851. this._map.set(charCode, value);
  6852. }
  6853. };
  6854. CharacterClassifier.prototype.get = function (charCode) {
  6855. if (charCode >= 0 && charCode < 256) {
  6856. return this._asciiMap[charCode];
  6857. }
  6858. else {
  6859. return (this._map.get(charCode) || this._defaultValue);
  6860. }
  6861. };
  6862. return CharacterClassifier;
  6863. }());
  6864. exports.CharacterClassifier = CharacterClassifier;
  6865. var CharacterSet = /** @class */ (function () {
  6866. function CharacterSet() {
  6867. this._actual = new CharacterClassifier(0 /* False */);
  6868. }
  6869. CharacterSet.prototype.add = function (charCode) {
  6870. this._actual.set(charCode, 1 /* True */);
  6871. };
  6872. CharacterSet.prototype.has = function (charCode) {
  6873. return (this._actual.get(charCode) === 1 /* True */);
  6874. };
  6875. return CharacterSet;
  6876. }());
  6877. exports.CharacterSet = CharacterSet;
  6878. });
  6879. /*---------------------------------------------------------------------------------------------
  6880. * Copyright (c) Microsoft Corporation. All rights reserved.
  6881. * Licensed under the MIT License. See License.txt in the project root for license information.
  6882. *--------------------------------------------------------------------------------------------*/
  6883. define(__m[2/*vs/editor/common/core/position*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  6884. "use strict";
  6885. Object.defineProperty(exports, "__esModule", { value: true });
  6886. /**
  6887. * A position in the editor.
  6888. */
  6889. var Position = /** @class */ (function () {
  6890. function Position(lineNumber, column) {
  6891. this.lineNumber = lineNumber;
  6892. this.column = column;
  6893. }
  6894. /**
  6895. * Create a new position from this position.
  6896. *
  6897. * @param newLineNumber new line number
  6898. * @param newColumn new column
  6899. */
  6900. Position.prototype.with = function (newLineNumber, newColumn) {
  6901. if (newLineNumber === void 0) { newLineNumber = this.lineNumber; }
  6902. if (newColumn === void 0) { newColumn = this.column; }
  6903. if (newLineNumber === this.lineNumber && newColumn === this.column) {
  6904. return this;
  6905. }
  6906. else {
  6907. return new Position(newLineNumber, newColumn);
  6908. }
  6909. };
  6910. /**
  6911. * Derive a new position from this position.
  6912. *
  6913. * @param deltaLineNumber line number delta
  6914. * @param deltaColumn column delta
  6915. */
  6916. Position.prototype.delta = function (deltaLineNumber, deltaColumn) {
  6917. if (deltaLineNumber === void 0) { deltaLineNumber = 0; }
  6918. if (deltaColumn === void 0) { deltaColumn = 0; }
  6919. return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
  6920. };
  6921. /**
  6922. * Test if this position equals other position
  6923. */
  6924. Position.prototype.equals = function (other) {
  6925. return Position.equals(this, other);
  6926. };
  6927. /**
  6928. * Test if position `a` equals position `b`
  6929. */
  6930. Position.equals = function (a, b) {
  6931. if (!a && !b) {
  6932. return true;
  6933. }
  6934. return (!!a &&
  6935. !!b &&
  6936. a.lineNumber === b.lineNumber &&
  6937. a.column === b.column);
  6938. };
  6939. /**
  6940. * Test if this position is before other position.
  6941. * If the two positions are equal, the result will be false.
  6942. */
  6943. Position.prototype.isBefore = function (other) {
  6944. return Position.isBefore(this, other);
  6945. };
  6946. /**
  6947. * Test if position `a` is before position `b`.
  6948. * If the two positions are equal, the result will be false.
  6949. */
  6950. Position.isBefore = function (a, b) {
  6951. if (a.lineNumber < b.lineNumber) {
  6952. return true;
  6953. }
  6954. if (b.lineNumber < a.lineNumber) {
  6955. return false;
  6956. }
  6957. return a.column < b.column;
  6958. };
  6959. /**
  6960. * Test if this position is before other position.
  6961. * If the two positions are equal, the result will be true.
  6962. */
  6963. Position.prototype.isBeforeOrEqual = function (other) {
  6964. return Position.isBeforeOrEqual(this, other);
  6965. };
  6966. /**
  6967. * Test if position `a` is before position `b`.
  6968. * If the two positions are equal, the result will be true.
  6969. */
  6970. Position.isBeforeOrEqual = function (a, b) {
  6971. if (a.lineNumber < b.lineNumber) {
  6972. return true;
  6973. }
  6974. if (b.lineNumber < a.lineNumber) {
  6975. return false;
  6976. }
  6977. return a.column <= b.column;
  6978. };
  6979. /**
  6980. * A function that compares positions, useful for sorting
  6981. */
  6982. Position.compare = function (a, b) {
  6983. var aLineNumber = a.lineNumber | 0;
  6984. var bLineNumber = b.lineNumber | 0;
  6985. if (aLineNumber === bLineNumber) {
  6986. var aColumn = a.column | 0;
  6987. var bColumn = b.column | 0;
  6988. return aColumn - bColumn;
  6989. }
  6990. return aLineNumber - bLineNumber;
  6991. };
  6992. /**
  6993. * Clone this position.
  6994. */
  6995. Position.prototype.clone = function () {
  6996. return new Position(this.lineNumber, this.column);
  6997. };
  6998. /**
  6999. * Convert to a human-readable representation.
  7000. */
  7001. Position.prototype.toString = function () {
  7002. return '(' + this.lineNumber + ',' + this.column + ')';
  7003. };
  7004. // ---
  7005. /**
  7006. * Create a `Position` from an `IPosition`.
  7007. */
  7008. Position.lift = function (pos) {
  7009. return new Position(pos.lineNumber, pos.column);
  7010. };
  7011. /**
  7012. * Test if `obj` is an `IPosition`.
  7013. */
  7014. Position.isIPosition = function (obj) {
  7015. return (obj
  7016. && (typeof obj.lineNumber === 'number')
  7017. && (typeof obj.column === 'number'));
  7018. };
  7019. return Position;
  7020. }());
  7021. exports.Position = Position;
  7022. });
  7023. /*---------------------------------------------------------------------------------------------
  7024. * Copyright (c) Microsoft Corporation. All rights reserved.
  7025. * Licensed under the MIT License. See License.txt in the project root for license information.
  7026. *--------------------------------------------------------------------------------------------*/
  7027. define(__m[5/*vs/editor/common/core/range*/], __M([0/*require*/,1/*exports*/,2/*vs/editor/common/core/position*/]), function (require, exports, position_1) {
  7028. "use strict";
  7029. Object.defineProperty(exports, "__esModule", { value: true });
  7030. /**
  7031. * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
  7032. */
  7033. var Range = /** @class */ (function () {
  7034. function Range(startLineNumber, startColumn, endLineNumber, endColumn) {
  7035. if ((startLineNumber > endLineNumber) || (startLineNumber === endLineNumber && startColumn > endColumn)) {
  7036. this.startLineNumber = endLineNumber;
  7037. this.startColumn = endColumn;
  7038. this.endLineNumber = startLineNumber;
  7039. this.endColumn = startColumn;
  7040. }
  7041. else {
  7042. this.startLineNumber = startLineNumber;
  7043. this.startColumn = startColumn;
  7044. this.endLineNumber = endLineNumber;
  7045. this.endColumn = endColumn;
  7046. }
  7047. }
  7048. /**
  7049. * Test if this range is empty.
  7050. */
  7051. Range.prototype.isEmpty = function () {
  7052. return Range.isEmpty(this);
  7053. };
  7054. /**
  7055. * Test if `range` is empty.
  7056. */
  7057. Range.isEmpty = function (range) {
  7058. return (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn);
  7059. };
  7060. /**
  7061. * Test if position is in this range. If the position is at the edges, will return true.
  7062. */
  7063. Range.prototype.containsPosition = function (position) {
  7064. return Range.containsPosition(this, position);
  7065. };
  7066. /**
  7067. * Test if `position` is in `range`. If the position is at the edges, will return true.
  7068. */
  7069. Range.containsPosition = function (range, position) {
  7070. if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
  7071. return false;
  7072. }
  7073. if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
  7074. return false;
  7075. }
  7076. if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
  7077. return false;
  7078. }
  7079. return true;
  7080. };
  7081. /**
  7082. * Test if range is in this range. If the range is equal to this range, will return true.
  7083. */
  7084. Range.prototype.containsRange = function (range) {
  7085. return Range.containsRange(this, range);
  7086. };
  7087. /**
  7088. * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
  7089. */
  7090. Range.containsRange = function (range, otherRange) {
  7091. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  7092. return false;
  7093. }
  7094. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  7095. return false;
  7096. }
  7097. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
  7098. return false;
  7099. }
  7100. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
  7101. return false;
  7102. }
  7103. return true;
  7104. };
  7105. /**
  7106. * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
  7107. */
  7108. Range.prototype.strictContainsRange = function (range) {
  7109. return Range.strictContainsRange(this, range);
  7110. };
  7111. /**
  7112. * Test if `otherRange` is strinctly in `range` (must start after, and end before). If the ranges are equal, will return false.
  7113. */
  7114. Range.strictContainsRange = function (range, otherRange) {
  7115. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  7116. return false;
  7117. }
  7118. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  7119. return false;
  7120. }
  7121. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn <= range.startColumn) {
  7122. return false;
  7123. }
  7124. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn >= range.endColumn) {
  7125. return false;
  7126. }
  7127. return true;
  7128. };
  7129. /**
  7130. * A reunion of the two ranges.
  7131. * The smallest position will be used as the start point, and the largest one as the end point.
  7132. */
  7133. Range.prototype.plusRange = function (range) {
  7134. return Range.plusRange(this, range);
  7135. };
  7136. /**
  7137. * A reunion of the two ranges.
  7138. * The smallest position will be used as the start point, and the largest one as the end point.
  7139. */
  7140. Range.plusRange = function (a, b) {
  7141. var startLineNumber;
  7142. var startColumn;
  7143. var endLineNumber;
  7144. var endColumn;
  7145. if (b.startLineNumber < a.startLineNumber) {
  7146. startLineNumber = b.startLineNumber;
  7147. startColumn = b.startColumn;
  7148. }
  7149. else if (b.startLineNumber === a.startLineNumber) {
  7150. startLineNumber = b.startLineNumber;
  7151. startColumn = Math.min(b.startColumn, a.startColumn);
  7152. }
  7153. else {
  7154. startLineNumber = a.startLineNumber;
  7155. startColumn = a.startColumn;
  7156. }
  7157. if (b.endLineNumber > a.endLineNumber) {
  7158. endLineNumber = b.endLineNumber;
  7159. endColumn = b.endColumn;
  7160. }
  7161. else if (b.endLineNumber === a.endLineNumber) {
  7162. endLineNumber = b.endLineNumber;
  7163. endColumn = Math.max(b.endColumn, a.endColumn);
  7164. }
  7165. else {
  7166. endLineNumber = a.endLineNumber;
  7167. endColumn = a.endColumn;
  7168. }
  7169. return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
  7170. };
  7171. /**
  7172. * A intersection of the two ranges.
  7173. */
  7174. Range.prototype.intersectRanges = function (range) {
  7175. return Range.intersectRanges(this, range);
  7176. };
  7177. /**
  7178. * A intersection of the two ranges.
  7179. */
  7180. Range.intersectRanges = function (a, b) {
  7181. var resultStartLineNumber = a.startLineNumber;
  7182. var resultStartColumn = a.startColumn;
  7183. var resultEndLineNumber = a.endLineNumber;
  7184. var resultEndColumn = a.endColumn;
  7185. var otherStartLineNumber = b.startLineNumber;
  7186. var otherStartColumn = b.startColumn;
  7187. var otherEndLineNumber = b.endLineNumber;
  7188. var otherEndColumn = b.endColumn;
  7189. if (resultStartLineNumber < otherStartLineNumber) {
  7190. resultStartLineNumber = otherStartLineNumber;
  7191. resultStartColumn = otherStartColumn;
  7192. }
  7193. else if (resultStartLineNumber === otherStartLineNumber) {
  7194. resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
  7195. }
  7196. if (resultEndLineNumber > otherEndLineNumber) {
  7197. resultEndLineNumber = otherEndLineNumber;
  7198. resultEndColumn = otherEndColumn;
  7199. }
  7200. else if (resultEndLineNumber === otherEndLineNumber) {
  7201. resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
  7202. }
  7203. // Check if selection is now empty
  7204. if (resultStartLineNumber > resultEndLineNumber) {
  7205. return null;
  7206. }
  7207. if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
  7208. return null;
  7209. }
  7210. return new Range(resultStartLineNumber, resultStartColumn, resultEndLineNumber, resultEndColumn);
  7211. };
  7212. /**
  7213. * Test if this range equals other.
  7214. */
  7215. Range.prototype.equalsRange = function (other) {
  7216. return Range.equalsRange(this, other);
  7217. };
  7218. /**
  7219. * Test if range `a` equals `b`.
  7220. */
  7221. Range.equalsRange = function (a, b) {
  7222. return (!!a &&
  7223. !!b &&
  7224. a.startLineNumber === b.startLineNumber &&
  7225. a.startColumn === b.startColumn &&
  7226. a.endLineNumber === b.endLineNumber &&
  7227. a.endColumn === b.endColumn);
  7228. };
  7229. /**
  7230. * Return the end position (which will be after or equal to the start position)
  7231. */
  7232. Range.prototype.getEndPosition = function () {
  7233. return new position_1.Position(this.endLineNumber, this.endColumn);
  7234. };
  7235. /**
  7236. * Return the start position (which will be before or equal to the end position)
  7237. */
  7238. Range.prototype.getStartPosition = function () {
  7239. return new position_1.Position(this.startLineNumber, this.startColumn);
  7240. };
  7241. /**
  7242. * Transform to a user presentable string representation.
  7243. */
  7244. Range.prototype.toString = function () {
  7245. return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
  7246. };
  7247. /**
  7248. * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
  7249. */
  7250. Range.prototype.setEndPosition = function (endLineNumber, endColumn) {
  7251. return new Range(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  7252. };
  7253. /**
  7254. * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
  7255. */
  7256. Range.prototype.setStartPosition = function (startLineNumber, startColumn) {
  7257. return new Range(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  7258. };
  7259. /**
  7260. * Create a new empty range using this range's start position.
  7261. */
  7262. Range.prototype.collapseToStart = function () {
  7263. return Range.collapseToStart(this);
  7264. };
  7265. /**
  7266. * Create a new empty range using this range's start position.
  7267. */
  7268. Range.collapseToStart = function (range) {
  7269. return new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
  7270. };
  7271. // ---
  7272. Range.fromPositions = function (start, end) {
  7273. if (end === void 0) { end = start; }
  7274. return new Range(start.lineNumber, start.column, end.lineNumber, end.column);
  7275. };
  7276. Range.lift = function (range) {
  7277. if (!range) {
  7278. return null;
  7279. }
  7280. return new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  7281. };
  7282. /**
  7283. * Test if `obj` is an `IRange`.
  7284. */
  7285. Range.isIRange = function (obj) {
  7286. return (obj
  7287. && (typeof obj.startLineNumber === 'number')
  7288. && (typeof obj.startColumn === 'number')
  7289. && (typeof obj.endLineNumber === 'number')
  7290. && (typeof obj.endColumn === 'number'));
  7291. };
  7292. /**
  7293. * Test if the two ranges are touching in any way.
  7294. */
  7295. Range.areIntersectingOrTouching = function (a, b) {
  7296. // Check if `a` is before `b`
  7297. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn)) {
  7298. return false;
  7299. }
  7300. // Check if `b` is before `a`
  7301. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn)) {
  7302. return false;
  7303. }
  7304. // These ranges must intersect
  7305. return true;
  7306. };
  7307. /**
  7308. * Test if the two ranges are intersecting. If the ranges are touching it returns true.
  7309. */
  7310. Range.areIntersecting = function (a, b) {
  7311. // Check if `a` is before `b`
  7312. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn)) {
  7313. return false;
  7314. }
  7315. // Check if `b` is before `a`
  7316. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn)) {
  7317. return false;
  7318. }
  7319. // These ranges must intersect
  7320. return true;
  7321. };
  7322. /**
  7323. * A function that compares ranges, useful for sorting ranges
  7324. * It will first compare ranges on the startPosition and then on the endPosition
  7325. */
  7326. Range.compareRangesUsingStarts = function (a, b) {
  7327. if (a && b) {
  7328. var aStartLineNumber = a.startLineNumber | 0;
  7329. var bStartLineNumber = b.startLineNumber | 0;
  7330. if (aStartLineNumber === bStartLineNumber) {
  7331. var aStartColumn = a.startColumn | 0;
  7332. var bStartColumn = b.startColumn | 0;
  7333. if (aStartColumn === bStartColumn) {
  7334. var aEndLineNumber = a.endLineNumber | 0;
  7335. var bEndLineNumber = b.endLineNumber | 0;
  7336. if (aEndLineNumber === bEndLineNumber) {
  7337. var aEndColumn = a.endColumn | 0;
  7338. var bEndColumn = b.endColumn | 0;
  7339. return aEndColumn - bEndColumn;
  7340. }
  7341. return aEndLineNumber - bEndLineNumber;
  7342. }
  7343. return aStartColumn - bStartColumn;
  7344. }
  7345. return aStartLineNumber - bStartLineNumber;
  7346. }
  7347. var aExists = (a ? 1 : 0);
  7348. var bExists = (b ? 1 : 0);
  7349. return aExists - bExists;
  7350. };
  7351. /**
  7352. * A function that compares ranges, useful for sorting ranges
  7353. * It will first compare ranges on the endPosition and then on the startPosition
  7354. */
  7355. Range.compareRangesUsingEnds = function (a, b) {
  7356. if (a.endLineNumber === b.endLineNumber) {
  7357. if (a.endColumn === b.endColumn) {
  7358. if (a.startLineNumber === b.startLineNumber) {
  7359. return a.startColumn - b.startColumn;
  7360. }
  7361. return a.startLineNumber - b.startLineNumber;
  7362. }
  7363. return a.endColumn - b.endColumn;
  7364. }
  7365. return a.endLineNumber - b.endLineNumber;
  7366. };
  7367. /**
  7368. * Test if the range spans multiple lines.
  7369. */
  7370. Range.spansMultipleLines = function (range) {
  7371. return range.endLineNumber > range.startLineNumber;
  7372. };
  7373. return Range;
  7374. }());
  7375. exports.Range = Range;
  7376. });
  7377. /*---------------------------------------------------------------------------------------------
  7378. * Copyright (c) Microsoft Corporation. All rights reserved.
  7379. * Licensed under the MIT License. See License.txt in the project root for license information.
  7380. *--------------------------------------------------------------------------------------------*/
  7381. define(__m[22/*vs/editor/common/core/selection*/], __M([0/*require*/,1/*exports*/,2/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/]), function (require, exports, position_1, range_1) {
  7382. "use strict";
  7383. Object.defineProperty(exports, "__esModule", { value: true });
  7384. /**
  7385. * A selection in the editor.
  7386. * The selection is a range that has an orientation.
  7387. */
  7388. var Selection = /** @class */ (function (_super) {
  7389. __extends(Selection, _super);
  7390. function Selection(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) {
  7391. var _this = _super.call(this, selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) || this;
  7392. _this.selectionStartLineNumber = selectionStartLineNumber;
  7393. _this.selectionStartColumn = selectionStartColumn;
  7394. _this.positionLineNumber = positionLineNumber;
  7395. _this.positionColumn = positionColumn;
  7396. return _this;
  7397. }
  7398. /**
  7399. * Transform to a human-readable representation.
  7400. */
  7401. Selection.prototype.toString = function () {
  7402. return '[' + this.selectionStartLineNumber + ',' + this.selectionStartColumn + ' -> ' + this.positionLineNumber + ',' + this.positionColumn + ']';
  7403. };
  7404. /**
  7405. * Test if equals other selection.
  7406. */
  7407. Selection.prototype.equalsSelection = function (other) {
  7408. return (Selection.selectionsEqual(this, other));
  7409. };
  7410. /**
  7411. * Test if the two selections are equal.
  7412. */
  7413. Selection.selectionsEqual = function (a, b) {
  7414. return (a.selectionStartLineNumber === b.selectionStartLineNumber &&
  7415. a.selectionStartColumn === b.selectionStartColumn &&
  7416. a.positionLineNumber === b.positionLineNumber &&
  7417. a.positionColumn === b.positionColumn);
  7418. };
  7419. /**
  7420. * Get directions (LTR or RTL).
  7421. */
  7422. Selection.prototype.getDirection = function () {
  7423. if (this.selectionStartLineNumber === this.startLineNumber && this.selectionStartColumn === this.startColumn) {
  7424. return 0 /* LTR */;
  7425. }
  7426. return 1 /* RTL */;
  7427. };
  7428. /**
  7429. * Create a new selection with a different `positionLineNumber` and `positionColumn`.
  7430. */
  7431. Selection.prototype.setEndPosition = function (endLineNumber, endColumn) {
  7432. if (this.getDirection() === 0 /* LTR */) {
  7433. return new Selection(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  7434. }
  7435. return new Selection(endLineNumber, endColumn, this.startLineNumber, this.startColumn);
  7436. };
  7437. /**
  7438. * Get the position at `positionLineNumber` and `positionColumn`.
  7439. */
  7440. Selection.prototype.getPosition = function () {
  7441. return new position_1.Position(this.positionLineNumber, this.positionColumn);
  7442. };
  7443. /**
  7444. * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
  7445. */
  7446. Selection.prototype.setStartPosition = function (startLineNumber, startColumn) {
  7447. if (this.getDirection() === 0 /* LTR */) {
  7448. return new Selection(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  7449. }
  7450. return new Selection(this.endLineNumber, this.endColumn, startLineNumber, startColumn);
  7451. };
  7452. // ----
  7453. /**
  7454. * Create a `Selection` from one or two positions
  7455. */
  7456. Selection.fromPositions = function (start, end) {
  7457. if (end === void 0) { end = start; }
  7458. return new Selection(start.lineNumber, start.column, end.lineNumber, end.column);
  7459. };
  7460. /**
  7461. * Create a `Selection` from an `ISelection`.
  7462. */
  7463. Selection.liftSelection = function (sel) {
  7464. return new Selection(sel.selectionStartLineNumber, sel.selectionStartColumn, sel.positionLineNumber, sel.positionColumn);
  7465. };
  7466. /**
  7467. * `a` equals `b`.
  7468. */
  7469. Selection.selectionsArrEqual = function (a, b) {
  7470. if (a && !b || !a && b) {
  7471. return false;
  7472. }
  7473. if (!a && !b) {
  7474. return true;
  7475. }
  7476. if (a.length !== b.length) {
  7477. return false;
  7478. }
  7479. for (var i = 0, len = a.length; i < len; i++) {
  7480. if (!this.selectionsEqual(a[i], b[i])) {
  7481. return false;
  7482. }
  7483. }
  7484. return true;
  7485. };
  7486. /**
  7487. * Test if `obj` is an `ISelection`.
  7488. */
  7489. Selection.isISelection = function (obj) {
  7490. return (obj
  7491. && (typeof obj.selectionStartLineNumber === 'number')
  7492. && (typeof obj.selectionStartColumn === 'number')
  7493. && (typeof obj.positionLineNumber === 'number')
  7494. && (typeof obj.positionColumn === 'number'));
  7495. };
  7496. /**
  7497. * Create with a direction.
  7498. */
  7499. Selection.createWithDirection = function (startLineNumber, startColumn, endLineNumber, endColumn, direction) {
  7500. if (direction === 0 /* LTR */) {
  7501. return new Selection(startLineNumber, startColumn, endLineNumber, endColumn);
  7502. }
  7503. return new Selection(endLineNumber, endColumn, startLineNumber, startColumn);
  7504. };
  7505. return Selection;
  7506. }(range_1.Range));
  7507. exports.Selection = Selection;
  7508. });
  7509. /*---------------------------------------------------------------------------------------------
  7510. * Copyright (c) Microsoft Corporation. All rights reserved.
  7511. * Licensed under the MIT License. See License.txt in the project root for license information.
  7512. *--------------------------------------------------------------------------------------------*/
  7513. define(__m[23/*vs/editor/common/core/token*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  7514. "use strict";
  7515. Object.defineProperty(exports, "__esModule", { value: true });
  7516. var Token = /** @class */ (function () {
  7517. function Token(offset, type, language) {
  7518. this.offset = offset | 0; // @perf
  7519. this.type = type;
  7520. this.language = language;
  7521. }
  7522. Token.prototype.toString = function () {
  7523. return '(' + this.offset + ', ' + this.type + ')';
  7524. };
  7525. return Token;
  7526. }());
  7527. exports.Token = Token;
  7528. var TokenizationResult = /** @class */ (function () {
  7529. function TokenizationResult(tokens, endState) {
  7530. this.tokens = tokens;
  7531. this.endState = endState;
  7532. }
  7533. return TokenizationResult;
  7534. }());
  7535. exports.TokenizationResult = TokenizationResult;
  7536. var TokenizationResult2 = /** @class */ (function () {
  7537. function TokenizationResult2(tokens, endState) {
  7538. this.tokens = tokens;
  7539. this.endState = endState;
  7540. }
  7541. return TokenizationResult2;
  7542. }());
  7543. exports.TokenizationResult2 = TokenizationResult2;
  7544. });
  7545. /*---------------------------------------------------------------------------------------------
  7546. * Copyright (c) Microsoft Corporation. All rights reserved.
  7547. * Licensed under the MIT License. See License.txt in the project root for license information.
  7548. *--------------------------------------------------------------------------------------------*/
  7549. define(__m[24/*vs/editor/common/diff/diffComputer*/], __M([0/*require*/,1/*exports*/,6/*vs/base/common/diff/diff*/,20/*vs/base/common/strings*/]), function (require, exports, diff_1, strings) {
  7550. "use strict";
  7551. Object.defineProperty(exports, "__esModule", { value: true });
  7552. var MINIMUM_MATCHING_CHARACTER_LENGTH = 3;
  7553. function computeDiff(originalSequence, modifiedSequence, continueProcessingPredicate, pretty) {
  7554. var diffAlgo = new diff_1.LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate);
  7555. return diffAlgo.ComputeDiff(pretty);
  7556. }
  7557. var LineSequence = /** @class */ (function () {
  7558. function LineSequence(lines) {
  7559. var startColumns = [];
  7560. var endColumns = [];
  7561. for (var i = 0, length_1 = lines.length; i < length_1; i++) {
  7562. startColumns[i] = getFirstNonBlankColumn(lines[i], 1);
  7563. endColumns[i] = getLastNonBlankColumn(lines[i], 1);
  7564. }
  7565. this.lines = lines;
  7566. this._startColumns = startColumns;
  7567. this._endColumns = endColumns;
  7568. }
  7569. LineSequence.prototype.getElements = function () {
  7570. var elements = [];
  7571. for (var i = 0, len = this.lines.length; i < len; i++) {
  7572. elements[i] = this.lines[i].substring(this._startColumns[i] - 1, this._endColumns[i] - 1);
  7573. }
  7574. return elements;
  7575. };
  7576. LineSequence.prototype.getStartLineNumber = function (i) {
  7577. return i + 1;
  7578. };
  7579. LineSequence.prototype.getEndLineNumber = function (i) {
  7580. return i + 1;
  7581. };
  7582. LineSequence.prototype.createCharSequence = function (shouldIgnoreTrimWhitespace, startIndex, endIndex) {
  7583. var charCodes = [];
  7584. var lineNumbers = [];
  7585. var columns = [];
  7586. var len = 0;
  7587. for (var index = startIndex; index <= endIndex; index++) {
  7588. var lineContent = this.lines[index];
  7589. var startColumn = (shouldIgnoreTrimWhitespace ? this._startColumns[index] : 1);
  7590. var endColumn = (shouldIgnoreTrimWhitespace ? this._endColumns[index] : lineContent.length + 1);
  7591. for (var col = startColumn; col < endColumn; col++) {
  7592. charCodes[len] = lineContent.charCodeAt(col - 1);
  7593. lineNumbers[len] = index + 1;
  7594. columns[len] = col;
  7595. len++;
  7596. }
  7597. }
  7598. return new CharSequence(charCodes, lineNumbers, columns);
  7599. };
  7600. return LineSequence;
  7601. }());
  7602. var CharSequence = /** @class */ (function () {
  7603. function CharSequence(charCodes, lineNumbers, columns) {
  7604. this._charCodes = charCodes;
  7605. this._lineNumbers = lineNumbers;
  7606. this._columns = columns;
  7607. }
  7608. CharSequence.prototype.getElements = function () {
  7609. return this._charCodes;
  7610. };
  7611. CharSequence.prototype.getStartLineNumber = function (i) {
  7612. return this._lineNumbers[i];
  7613. };
  7614. CharSequence.prototype.getStartColumn = function (i) {
  7615. return this._columns[i];
  7616. };
  7617. CharSequence.prototype.getEndLineNumber = function (i) {
  7618. return this._lineNumbers[i];
  7619. };
  7620. CharSequence.prototype.getEndColumn = function (i) {
  7621. return this._columns[i] + 1;
  7622. };
  7623. return CharSequence;
  7624. }());
  7625. var CharChange = /** @class */ (function () {
  7626. function CharChange(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn) {
  7627. this.originalStartLineNumber = originalStartLineNumber;
  7628. this.originalStartColumn = originalStartColumn;
  7629. this.originalEndLineNumber = originalEndLineNumber;
  7630. this.originalEndColumn = originalEndColumn;
  7631. this.modifiedStartLineNumber = modifiedStartLineNumber;
  7632. this.modifiedStartColumn = modifiedStartColumn;
  7633. this.modifiedEndLineNumber = modifiedEndLineNumber;
  7634. this.modifiedEndColumn = modifiedEndColumn;
  7635. }
  7636. CharChange.createFromDiffChange = function (diffChange, originalCharSequence, modifiedCharSequence) {
  7637. var originalStartLineNumber;
  7638. var originalStartColumn;
  7639. var originalEndLineNumber;
  7640. var originalEndColumn;
  7641. var modifiedStartLineNumber;
  7642. var modifiedStartColumn;
  7643. var modifiedEndLineNumber;
  7644. var modifiedEndColumn;
  7645. if (diffChange.originalLength === 0) {
  7646. originalStartLineNumber = 0;
  7647. originalStartColumn = 0;
  7648. originalEndLineNumber = 0;
  7649. originalEndColumn = 0;
  7650. }
  7651. else {
  7652. originalStartLineNumber = originalCharSequence.getStartLineNumber(diffChange.originalStart);
  7653. originalStartColumn = originalCharSequence.getStartColumn(diffChange.originalStart);
  7654. originalEndLineNumber = originalCharSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  7655. originalEndColumn = originalCharSequence.getEndColumn(diffChange.originalStart + diffChange.originalLength - 1);
  7656. }
  7657. if (diffChange.modifiedLength === 0) {
  7658. modifiedStartLineNumber = 0;
  7659. modifiedStartColumn = 0;
  7660. modifiedEndLineNumber = 0;
  7661. modifiedEndColumn = 0;
  7662. }
  7663. else {
  7664. modifiedStartLineNumber = modifiedCharSequence.getStartLineNumber(diffChange.modifiedStart);
  7665. modifiedStartColumn = modifiedCharSequence.getStartColumn(diffChange.modifiedStart);
  7666. modifiedEndLineNumber = modifiedCharSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  7667. modifiedEndColumn = modifiedCharSequence.getEndColumn(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  7668. }
  7669. return new CharChange(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn);
  7670. };
  7671. return CharChange;
  7672. }());
  7673. function postProcessCharChanges(rawChanges) {
  7674. if (rawChanges.length <= 1) {
  7675. return rawChanges;
  7676. }
  7677. var result = [rawChanges[0]];
  7678. var prevChange = result[0];
  7679. for (var i = 1, len = rawChanges.length; i < len; i++) {
  7680. var currChange = rawChanges[i];
  7681. var originalMatchingLength = currChange.originalStart - (prevChange.originalStart + prevChange.originalLength);
  7682. var modifiedMatchingLength = currChange.modifiedStart - (prevChange.modifiedStart + prevChange.modifiedLength);
  7683. // Both of the above should be equal, but the continueProcessingPredicate may prevent this from being true
  7684. var matchingLength = Math.min(originalMatchingLength, modifiedMatchingLength);
  7685. if (matchingLength < MINIMUM_MATCHING_CHARACTER_LENGTH) {
  7686. // Merge the current change into the previous one
  7687. prevChange.originalLength = (currChange.originalStart + currChange.originalLength) - prevChange.originalStart;
  7688. prevChange.modifiedLength = (currChange.modifiedStart + currChange.modifiedLength) - prevChange.modifiedStart;
  7689. }
  7690. else {
  7691. // Add the current change
  7692. result.push(currChange);
  7693. prevChange = currChange;
  7694. }
  7695. }
  7696. return result;
  7697. }
  7698. var LineChange = /** @class */ (function () {
  7699. function LineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges) {
  7700. this.originalStartLineNumber = originalStartLineNumber;
  7701. this.originalEndLineNumber = originalEndLineNumber;
  7702. this.modifiedStartLineNumber = modifiedStartLineNumber;
  7703. this.modifiedEndLineNumber = modifiedEndLineNumber;
  7704. this.charChanges = charChanges;
  7705. }
  7706. LineChange.createFromDiffResult = function (shouldIgnoreTrimWhitespace, diffChange, originalLineSequence, modifiedLineSequence, continueCharDiff, shouldComputeCharChanges, shouldPostProcessCharChanges) {
  7707. var originalStartLineNumber;
  7708. var originalEndLineNumber;
  7709. var modifiedStartLineNumber;
  7710. var modifiedEndLineNumber;
  7711. var charChanges = undefined;
  7712. if (diffChange.originalLength === 0) {
  7713. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart) - 1;
  7714. originalEndLineNumber = 0;
  7715. }
  7716. else {
  7717. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart);
  7718. originalEndLineNumber = originalLineSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  7719. }
  7720. if (diffChange.modifiedLength === 0) {
  7721. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart) - 1;
  7722. modifiedEndLineNumber = 0;
  7723. }
  7724. else {
  7725. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart);
  7726. modifiedEndLineNumber = modifiedLineSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  7727. }
  7728. if (shouldComputeCharChanges && diffChange.originalLength > 0 && diffChange.originalLength < 20 && diffChange.modifiedLength > 0 && diffChange.modifiedLength < 20 && continueCharDiff()) {
  7729. // Compute character changes for diff chunks of at most 20 lines...
  7730. var originalCharSequence = originalLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength - 1);
  7731. var modifiedCharSequence = modifiedLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength - 1);
  7732. var rawChanges = computeDiff(originalCharSequence, modifiedCharSequence, continueCharDiff, true).changes;
  7733. if (shouldPostProcessCharChanges) {
  7734. rawChanges = postProcessCharChanges(rawChanges);
  7735. }
  7736. charChanges = [];
  7737. for (var i = 0, length_2 = rawChanges.length; i < length_2; i++) {
  7738. charChanges.push(CharChange.createFromDiffChange(rawChanges[i], originalCharSequence, modifiedCharSequence));
  7739. }
  7740. }
  7741. return new LineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges);
  7742. };
  7743. return LineChange;
  7744. }());
  7745. var DiffComputer = /** @class */ (function () {
  7746. function DiffComputer(originalLines, modifiedLines, opts) {
  7747. this.shouldComputeCharChanges = opts.shouldComputeCharChanges;
  7748. this.shouldPostProcessCharChanges = opts.shouldPostProcessCharChanges;
  7749. this.shouldIgnoreTrimWhitespace = opts.shouldIgnoreTrimWhitespace;
  7750. this.shouldMakePrettyDiff = opts.shouldMakePrettyDiff;
  7751. this.originalLines = originalLines;
  7752. this.modifiedLines = modifiedLines;
  7753. this.original = new LineSequence(originalLines);
  7754. this.modified = new LineSequence(modifiedLines);
  7755. this.continueLineDiff = createContinueProcessingPredicate(opts.maxComputationTime);
  7756. this.continueCharDiff = createContinueProcessingPredicate(opts.maxComputationTime === 0 ? 0 : Math.min(opts.maxComputationTime, 5000)); // never run after 5s for character changes...
  7757. }
  7758. DiffComputer.prototype.computeDiff = function () {
  7759. if (this.original.lines.length === 1 && this.original.lines[0].length === 0) {
  7760. // empty original => fast path
  7761. return {
  7762. quitEarly: false,
  7763. changes: [{
  7764. originalStartLineNumber: 1,
  7765. originalEndLineNumber: 1,
  7766. modifiedStartLineNumber: 1,
  7767. modifiedEndLineNumber: this.modified.lines.length,
  7768. charChanges: [{
  7769. modifiedEndColumn: 0,
  7770. modifiedEndLineNumber: 0,
  7771. modifiedStartColumn: 0,
  7772. modifiedStartLineNumber: 0,
  7773. originalEndColumn: 0,
  7774. originalEndLineNumber: 0,
  7775. originalStartColumn: 0,
  7776. originalStartLineNumber: 0
  7777. }]
  7778. }]
  7779. };
  7780. }
  7781. if (this.modified.lines.length === 1 && this.modified.lines[0].length === 0) {
  7782. // empty modified => fast path
  7783. return {
  7784. quitEarly: false,
  7785. changes: [{
  7786. originalStartLineNumber: 1,
  7787. originalEndLineNumber: this.original.lines.length,
  7788. modifiedStartLineNumber: 1,
  7789. modifiedEndLineNumber: 1,
  7790. charChanges: [{
  7791. modifiedEndColumn: 0,
  7792. modifiedEndLineNumber: 0,
  7793. modifiedStartColumn: 0,
  7794. modifiedStartLineNumber: 0,
  7795. originalEndColumn: 0,
  7796. originalEndLineNumber: 0,
  7797. originalStartColumn: 0,
  7798. originalStartLineNumber: 0
  7799. }]
  7800. }]
  7801. };
  7802. }
  7803. var diffResult = computeDiff(this.original, this.modified, this.continueLineDiff, this.shouldMakePrettyDiff);
  7804. var rawChanges = diffResult.changes;
  7805. var quitEarly = diffResult.quitEarly;
  7806. // The diff is always computed with ignoring trim whitespace
  7807. // This ensures we get the prettiest diff
  7808. if (this.shouldIgnoreTrimWhitespace) {
  7809. var lineChanges = [];
  7810. for (var i = 0, length_3 = rawChanges.length; i < length_3; i++) {
  7811. lineChanges.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, rawChanges[i], this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  7812. }
  7813. return {
  7814. quitEarly: quitEarly,
  7815. changes: lineChanges
  7816. };
  7817. }
  7818. // Need to post-process and introduce changes where the trim whitespace is different
  7819. // Note that we are looping starting at -1 to also cover the lines before the first change
  7820. var result = [];
  7821. var originalLineIndex = 0;
  7822. var modifiedLineIndex = 0;
  7823. for (var i = -1 /* !!!! */, len = rawChanges.length; i < len; i++) {
  7824. var nextChange = (i + 1 < len ? rawChanges[i + 1] : null);
  7825. var originalStop = (nextChange ? nextChange.originalStart : this.originalLines.length);
  7826. var modifiedStop = (nextChange ? nextChange.modifiedStart : this.modifiedLines.length);
  7827. while (originalLineIndex < originalStop && modifiedLineIndex < modifiedStop) {
  7828. var originalLine = this.originalLines[originalLineIndex];
  7829. var modifiedLine = this.modifiedLines[modifiedLineIndex];
  7830. if (originalLine !== modifiedLine) {
  7831. // These lines differ only in trim whitespace
  7832. // Check the leading whitespace
  7833. {
  7834. var originalStartColumn = getFirstNonBlankColumn(originalLine, 1);
  7835. var modifiedStartColumn = getFirstNonBlankColumn(modifiedLine, 1);
  7836. while (originalStartColumn > 1 && modifiedStartColumn > 1) {
  7837. var originalChar = originalLine.charCodeAt(originalStartColumn - 2);
  7838. var modifiedChar = modifiedLine.charCodeAt(modifiedStartColumn - 2);
  7839. if (originalChar !== modifiedChar) {
  7840. break;
  7841. }
  7842. originalStartColumn--;
  7843. modifiedStartColumn--;
  7844. }
  7845. if (originalStartColumn > 1 || modifiedStartColumn > 1) {
  7846. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, 1, originalStartColumn, modifiedLineIndex + 1, 1, modifiedStartColumn);
  7847. }
  7848. }
  7849. // Check the trailing whitespace
  7850. {
  7851. var originalEndColumn = getLastNonBlankColumn(originalLine, 1);
  7852. var modifiedEndColumn = getLastNonBlankColumn(modifiedLine, 1);
  7853. var originalMaxColumn = originalLine.length + 1;
  7854. var modifiedMaxColumn = modifiedLine.length + 1;
  7855. while (originalEndColumn < originalMaxColumn && modifiedEndColumn < modifiedMaxColumn) {
  7856. var originalChar = originalLine.charCodeAt(originalEndColumn - 1);
  7857. var modifiedChar = originalLine.charCodeAt(modifiedEndColumn - 1);
  7858. if (originalChar !== modifiedChar) {
  7859. break;
  7860. }
  7861. originalEndColumn++;
  7862. modifiedEndColumn++;
  7863. }
  7864. if (originalEndColumn < originalMaxColumn || modifiedEndColumn < modifiedMaxColumn) {
  7865. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, originalEndColumn, originalMaxColumn, modifiedLineIndex + 1, modifiedEndColumn, modifiedMaxColumn);
  7866. }
  7867. }
  7868. }
  7869. originalLineIndex++;
  7870. modifiedLineIndex++;
  7871. }
  7872. if (nextChange) {
  7873. // Emit the actual change
  7874. result.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, nextChange, this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  7875. originalLineIndex += nextChange.originalLength;
  7876. modifiedLineIndex += nextChange.modifiedLength;
  7877. }
  7878. }
  7879. return {
  7880. quitEarly: quitEarly,
  7881. changes: result
  7882. };
  7883. };
  7884. DiffComputer.prototype._pushTrimWhitespaceCharChange = function (result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  7885. if (this._mergeTrimWhitespaceCharChange(result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn)) {
  7886. // Merged into previous
  7887. return;
  7888. }
  7889. var charChanges = undefined;
  7890. if (this.shouldComputeCharChanges) {
  7891. charChanges = [new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn)];
  7892. }
  7893. result.push(new LineChange(originalLineNumber, originalLineNumber, modifiedLineNumber, modifiedLineNumber, charChanges));
  7894. };
  7895. DiffComputer.prototype._mergeTrimWhitespaceCharChange = function (result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  7896. var len = result.length;
  7897. if (len === 0) {
  7898. return false;
  7899. }
  7900. var prevChange = result[len - 1];
  7901. if (prevChange.originalEndLineNumber === 0 || prevChange.modifiedEndLineNumber === 0) {
  7902. // Don't merge with inserts/deletes
  7903. return false;
  7904. }
  7905. if (prevChange.originalEndLineNumber + 1 === originalLineNumber && prevChange.modifiedEndLineNumber + 1 === modifiedLineNumber) {
  7906. prevChange.originalEndLineNumber = originalLineNumber;
  7907. prevChange.modifiedEndLineNumber = modifiedLineNumber;
  7908. if (this.shouldComputeCharChanges && prevChange.charChanges) {
  7909. prevChange.charChanges.push(new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn));
  7910. }
  7911. return true;
  7912. }
  7913. return false;
  7914. };
  7915. return DiffComputer;
  7916. }());
  7917. exports.DiffComputer = DiffComputer;
  7918. function getFirstNonBlankColumn(txt, defaultValue) {
  7919. var r = strings.firstNonWhitespaceIndex(txt);
  7920. if (r === -1) {
  7921. return defaultValue;
  7922. }
  7923. return r + 1;
  7924. }
  7925. function getLastNonBlankColumn(txt, defaultValue) {
  7926. var r = strings.lastNonWhitespaceIndex(txt);
  7927. if (r === -1) {
  7928. return defaultValue;
  7929. }
  7930. return r + 2;
  7931. }
  7932. function createContinueProcessingPredicate(maximumRuntime) {
  7933. if (maximumRuntime === 0) {
  7934. return function () { return true; };
  7935. }
  7936. var startTime = Date.now();
  7937. return function () {
  7938. return Date.now() - startTime < maximumRuntime;
  7939. };
  7940. }
  7941. });
  7942. /*---------------------------------------------------------------------------------------------
  7943. * Copyright (c) Microsoft Corporation. All rights reserved.
  7944. * Licensed under the MIT License. See License.txt in the project root for license information.
  7945. *--------------------------------------------------------------------------------------------*/
  7946. define(__m[25/*vs/editor/common/model/wordHelper*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  7947. "use strict";
  7948. Object.defineProperty(exports, "__esModule", { value: true });
  7949. exports.USUAL_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?';
  7950. /**
  7951. * Create a word definition regular expression based on default word separators.
  7952. * Optionally provide allowed separators that should be included in words.
  7953. *
  7954. * The default would look like this:
  7955. * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
  7956. */
  7957. function createWordRegExp(allowInWords) {
  7958. if (allowInWords === void 0) { allowInWords = ''; }
  7959. var source = '(-?\\d*\\.\\d\\w*)|([^';
  7960. for (var _i = 0, USUAL_WORD_SEPARATORS_1 = exports.USUAL_WORD_SEPARATORS; _i < USUAL_WORD_SEPARATORS_1.length; _i++) {
  7961. var sep = USUAL_WORD_SEPARATORS_1[_i];
  7962. if (allowInWords.indexOf(sep) >= 0) {
  7963. continue;
  7964. }
  7965. source += '\\' + sep;
  7966. }
  7967. source += '\\s]+)';
  7968. return new RegExp(source, 'g');
  7969. }
  7970. // catches numbers (including floating numbers) in the first group, and alphanum in the second
  7971. exports.DEFAULT_WORD_REGEXP = createWordRegExp();
  7972. function ensureValidWordDefinition(wordDefinition) {
  7973. var result = exports.DEFAULT_WORD_REGEXP;
  7974. if (wordDefinition && (wordDefinition instanceof RegExp)) {
  7975. if (!wordDefinition.global) {
  7976. var flags = 'g';
  7977. if (wordDefinition.ignoreCase) {
  7978. flags += 'i';
  7979. }
  7980. if (wordDefinition.multiline) {
  7981. flags += 'm';
  7982. }
  7983. if (wordDefinition.unicode) {
  7984. flags += 'u';
  7985. }
  7986. result = new RegExp(wordDefinition.source, flags);
  7987. }
  7988. else {
  7989. result = wordDefinition;
  7990. }
  7991. }
  7992. result.lastIndex = 0;
  7993. return result;
  7994. }
  7995. exports.ensureValidWordDefinition = ensureValidWordDefinition;
  7996. function getWordAtPosFast(column, wordDefinition, text, textOffset) {
  7997. // find whitespace enclosed text around column and match from there
  7998. var pos = column - 1 - textOffset;
  7999. var start = text.lastIndexOf(' ', pos - 1) + 1;
  8000. wordDefinition.lastIndex = start;
  8001. var match;
  8002. while (match = wordDefinition.exec(text)) {
  8003. var matchIndex = match.index || 0;
  8004. if (matchIndex <= pos && wordDefinition.lastIndex >= pos) {
  8005. return {
  8006. word: match[0],
  8007. startColumn: textOffset + 1 + matchIndex,
  8008. endColumn: textOffset + 1 + wordDefinition.lastIndex
  8009. };
  8010. }
  8011. }
  8012. return null;
  8013. }
  8014. function getWordAtPosSlow(column, wordDefinition, text, textOffset) {
  8015. // matches all words starting at the beginning
  8016. // of the input until it finds a match that encloses
  8017. // the desired column. slow but correct
  8018. var pos = column - 1 - textOffset;
  8019. wordDefinition.lastIndex = 0;
  8020. var match;
  8021. while (match = wordDefinition.exec(text)) {
  8022. var matchIndex = match.index || 0;
  8023. if (matchIndex > pos) {
  8024. // |nW -> matched only after the pos
  8025. return null;
  8026. }
  8027. else if (wordDefinition.lastIndex >= pos) {
  8028. // W|W -> match encloses pos
  8029. return {
  8030. word: match[0],
  8031. startColumn: textOffset + 1 + matchIndex,
  8032. endColumn: textOffset + 1 + wordDefinition.lastIndex
  8033. };
  8034. }
  8035. }
  8036. return null;
  8037. }
  8038. function getWordAtText(column, wordDefinition, text, textOffset) {
  8039. // if `words` can contain whitespace character we have to use the slow variant
  8040. // otherwise we use the fast variant of finding a word
  8041. wordDefinition.lastIndex = 0;
  8042. var match = wordDefinition.exec(text);
  8043. if (!match) {
  8044. return null;
  8045. }
  8046. // todo@joh the `match` could already be the (first) word
  8047. var ret = match[0].indexOf(' ') >= 0
  8048. // did match a word which contains a space character -> use slow word find
  8049. ? getWordAtPosSlow(column, wordDefinition, text, textOffset)
  8050. // sane word definition -> use fast word find
  8051. : getWordAtPosFast(column, wordDefinition, text, textOffset);
  8052. // both (getWordAtPosFast and getWordAtPosSlow) leave the wordDefinition-RegExp
  8053. // in an undefined state and to not confuse other users of the wordDefinition
  8054. // we reset the lastIndex
  8055. wordDefinition.lastIndex = 0;
  8056. return ret;
  8057. }
  8058. exports.getWordAtText = getWordAtText;
  8059. });
  8060. /*---------------------------------------------------------------------------------------------
  8061. * Copyright (c) Microsoft Corporation. All rights reserved.
  8062. * Licensed under the MIT License. See License.txt in the project root for license information.
  8063. *--------------------------------------------------------------------------------------------*/
  8064. define(__m[26/*vs/editor/common/modes/linkComputer*/], __M([0/*require*/,1/*exports*/,21/*vs/editor/common/core/characterClassifier*/]), function (require, exports, characterClassifier_1) {
  8065. "use strict";
  8066. Object.defineProperty(exports, "__esModule", { value: true });
  8067. var Uint8Matrix = /** @class */ (function () {
  8068. function Uint8Matrix(rows, cols, defaultValue) {
  8069. var data = new Uint8Array(rows * cols);
  8070. for (var i = 0, len = rows * cols; i < len; i++) {
  8071. data[i] = defaultValue;
  8072. }
  8073. this._data = data;
  8074. this.rows = rows;
  8075. this.cols = cols;
  8076. }
  8077. Uint8Matrix.prototype.get = function (row, col) {
  8078. return this._data[row * this.cols + col];
  8079. };
  8080. Uint8Matrix.prototype.set = function (row, col, value) {
  8081. this._data[row * this.cols + col] = value;
  8082. };
  8083. return Uint8Matrix;
  8084. }());
  8085. exports.Uint8Matrix = Uint8Matrix;
  8086. var StateMachine = /** @class */ (function () {
  8087. function StateMachine(edges) {
  8088. var maxCharCode = 0;
  8089. var maxState = 0 /* Invalid */;
  8090. for (var i = 0, len = edges.length; i < len; i++) {
  8091. var _a = edges[i], from = _a[0], chCode = _a[1], to = _a[2];
  8092. if (chCode > maxCharCode) {
  8093. maxCharCode = chCode;
  8094. }
  8095. if (from > maxState) {
  8096. maxState = from;
  8097. }
  8098. if (to > maxState) {
  8099. maxState = to;
  8100. }
  8101. }
  8102. maxCharCode++;
  8103. maxState++;
  8104. var states = new Uint8Matrix(maxState, maxCharCode, 0 /* Invalid */);
  8105. for (var i = 0, len = edges.length; i < len; i++) {
  8106. var _b = edges[i], from = _b[0], chCode = _b[1], to = _b[2];
  8107. states.set(from, chCode, to);
  8108. }
  8109. this._states = states;
  8110. this._maxCharCode = maxCharCode;
  8111. }
  8112. StateMachine.prototype.nextState = function (currentState, chCode) {
  8113. if (chCode < 0 || chCode >= this._maxCharCode) {
  8114. return 0 /* Invalid */;
  8115. }
  8116. return this._states.get(currentState, chCode);
  8117. };
  8118. return StateMachine;
  8119. }());
  8120. exports.StateMachine = StateMachine;
  8121. // State machine for http:// or https:// or file://
  8122. var _stateMachine = null;
  8123. function getStateMachine() {
  8124. if (_stateMachine === null) {
  8125. _stateMachine = new StateMachine([
  8126. [1 /* Start */, 104 /* h */, 2 /* H */],
  8127. [1 /* Start */, 72 /* H */, 2 /* H */],
  8128. [1 /* Start */, 102 /* f */, 6 /* F */],
  8129. [1 /* Start */, 70 /* F */, 6 /* F */],
  8130. [2 /* H */, 116 /* t */, 3 /* HT */],
  8131. [2 /* H */, 84 /* T */, 3 /* HT */],
  8132. [3 /* HT */, 116 /* t */, 4 /* HTT */],
  8133. [3 /* HT */, 84 /* T */, 4 /* HTT */],
  8134. [4 /* HTT */, 112 /* p */, 5 /* HTTP */],
  8135. [4 /* HTT */, 80 /* P */, 5 /* HTTP */],
  8136. [5 /* HTTP */, 115 /* s */, 9 /* BeforeColon */],
  8137. [5 /* HTTP */, 83 /* S */, 9 /* BeforeColon */],
  8138. [5 /* HTTP */, 58 /* Colon */, 10 /* AfterColon */],
  8139. [6 /* F */, 105 /* i */, 7 /* FI */],
  8140. [6 /* F */, 73 /* I */, 7 /* FI */],
  8141. [7 /* FI */, 108 /* l */, 8 /* FIL */],
  8142. [7 /* FI */, 76 /* L */, 8 /* FIL */],
  8143. [8 /* FIL */, 101 /* e */, 9 /* BeforeColon */],
  8144. [8 /* FIL */, 69 /* E */, 9 /* BeforeColon */],
  8145. [9 /* BeforeColon */, 58 /* Colon */, 10 /* AfterColon */],
  8146. [10 /* AfterColon */, 47 /* Slash */, 11 /* AlmostThere */],
  8147. [11 /* AlmostThere */, 47 /* Slash */, 12 /* End */],
  8148. ]);
  8149. }
  8150. return _stateMachine;
  8151. }
  8152. var _classifier = null;
  8153. function getClassifier() {
  8154. if (_classifier === null) {
  8155. _classifier = new characterClassifier_1.CharacterClassifier(0 /* None */);
  8156. var FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…';
  8157. for (var i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
  8158. _classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), 1 /* ForceTermination */);
  8159. }
  8160. var CANNOT_END_WITH_CHARACTERS = '.,;';
  8161. for (var i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
  8162. _classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), 2 /* CannotEndIn */);
  8163. }
  8164. }
  8165. return _classifier;
  8166. }
  8167. var LinkComputer = /** @class */ (function () {
  8168. function LinkComputer() {
  8169. }
  8170. LinkComputer._createLink = function (classifier, line, lineNumber, linkBeginIndex, linkEndIndex) {
  8171. // Do not allow to end link in certain characters...
  8172. var lastIncludedCharIndex = linkEndIndex - 1;
  8173. do {
  8174. var chCode = line.charCodeAt(lastIncludedCharIndex);
  8175. var chClass = classifier.get(chCode);
  8176. if (chClass !== 2 /* CannotEndIn */) {
  8177. break;
  8178. }
  8179. lastIncludedCharIndex--;
  8180. } while (lastIncludedCharIndex > linkBeginIndex);
  8181. // Handle links enclosed in parens, square brackets and curlys.
  8182. if (linkBeginIndex > 0) {
  8183. var charCodeBeforeLink = line.charCodeAt(linkBeginIndex - 1);
  8184. var lastCharCodeInLink = line.charCodeAt(lastIncludedCharIndex);
  8185. if ((charCodeBeforeLink === 40 /* OpenParen */ && lastCharCodeInLink === 41 /* CloseParen */)
  8186. || (charCodeBeforeLink === 91 /* OpenSquareBracket */ && lastCharCodeInLink === 93 /* CloseSquareBracket */)
  8187. || (charCodeBeforeLink === 123 /* OpenCurlyBrace */ && lastCharCodeInLink === 125 /* CloseCurlyBrace */)) {
  8188. // Do not end in ) if ( is before the link start
  8189. // Do not end in ] if [ is before the link start
  8190. // Do not end in } if { is before the link start
  8191. lastIncludedCharIndex--;
  8192. }
  8193. }
  8194. return {
  8195. range: {
  8196. startLineNumber: lineNumber,
  8197. startColumn: linkBeginIndex + 1,
  8198. endLineNumber: lineNumber,
  8199. endColumn: lastIncludedCharIndex + 2
  8200. },
  8201. url: line.substring(linkBeginIndex, lastIncludedCharIndex + 1)
  8202. };
  8203. };
  8204. LinkComputer.computeLinks = function (model, stateMachine) {
  8205. if (stateMachine === void 0) { stateMachine = getStateMachine(); }
  8206. var classifier = getClassifier();
  8207. var result = [];
  8208. for (var i = 1, lineCount = model.getLineCount(); i <= lineCount; i++) {
  8209. var line = model.getLineContent(i);
  8210. var len = line.length;
  8211. var j = 0;
  8212. var linkBeginIndex = 0;
  8213. var linkBeginChCode = 0;
  8214. var state = 1 /* Start */;
  8215. var hasOpenParens = false;
  8216. var hasOpenSquareBracket = false;
  8217. var hasOpenCurlyBracket = false;
  8218. while (j < len) {
  8219. var resetStateMachine = false;
  8220. var chCode = line.charCodeAt(j);
  8221. if (state === 13 /* Accept */) {
  8222. var chClass = void 0;
  8223. switch (chCode) {
  8224. case 40 /* OpenParen */:
  8225. hasOpenParens = true;
  8226. chClass = 0 /* None */;
  8227. break;
  8228. case 41 /* CloseParen */:
  8229. chClass = (hasOpenParens ? 0 /* None */ : 1 /* ForceTermination */);
  8230. break;
  8231. case 91 /* OpenSquareBracket */:
  8232. hasOpenSquareBracket = true;
  8233. chClass = 0 /* None */;
  8234. break;
  8235. case 93 /* CloseSquareBracket */:
  8236. chClass = (hasOpenSquareBracket ? 0 /* None */ : 1 /* ForceTermination */);
  8237. break;
  8238. case 123 /* OpenCurlyBrace */:
  8239. hasOpenCurlyBracket = true;
  8240. chClass = 0 /* None */;
  8241. break;
  8242. case 125 /* CloseCurlyBrace */:
  8243. chClass = (hasOpenCurlyBracket ? 0 /* None */ : 1 /* ForceTermination */);
  8244. break;
  8245. /* The following three rules make it that ' or " or ` are allowed inside links if the link began with a different one */
  8246. case 39 /* SingleQuote */:
  8247. chClass = (linkBeginChCode === 34 /* DoubleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  8248. break;
  8249. case 34 /* DoubleQuote */:
  8250. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  8251. break;
  8252. case 96 /* BackTick */:
  8253. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 34 /* DoubleQuote */) ? 0 /* None */ : 1 /* ForceTermination */;
  8254. break;
  8255. case 42 /* Asterisk */:
  8256. // `*` terminates a link if the link began with `*`
  8257. chClass = (linkBeginChCode === 42 /* Asterisk */) ? 1 /* ForceTermination */ : 0 /* None */;
  8258. break;
  8259. case 124 /* Pipe */:
  8260. // `|` terminates a link if the link began with `|`
  8261. chClass = (linkBeginChCode === 124 /* Pipe */) ? 1 /* ForceTermination */ : 0 /* None */;
  8262. break;
  8263. default:
  8264. chClass = classifier.get(chCode);
  8265. }
  8266. // Check if character terminates link
  8267. if (chClass === 1 /* ForceTermination */) {
  8268. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j));
  8269. resetStateMachine = true;
  8270. }
  8271. }
  8272. else if (state === 12 /* End */) {
  8273. var chClass = void 0;
  8274. if (chCode === 91 /* OpenSquareBracket */) {
  8275. // Allow for the authority part to contain ipv6 addresses which contain [ and ]
  8276. hasOpenSquareBracket = true;
  8277. chClass = 0 /* None */;
  8278. }
  8279. else {
  8280. chClass = classifier.get(chCode);
  8281. }
  8282. // Check if character terminates link
  8283. if (chClass === 1 /* ForceTermination */) {
  8284. resetStateMachine = true;
  8285. }
  8286. else {
  8287. state = 13 /* Accept */;
  8288. }
  8289. }
  8290. else {
  8291. state = stateMachine.nextState(state, chCode);
  8292. if (state === 0 /* Invalid */) {
  8293. resetStateMachine = true;
  8294. }
  8295. }
  8296. if (resetStateMachine) {
  8297. state = 1 /* Start */;
  8298. hasOpenParens = false;
  8299. hasOpenSquareBracket = false;
  8300. hasOpenCurlyBracket = false;
  8301. // Record where the link started
  8302. linkBeginIndex = j + 1;
  8303. linkBeginChCode = chCode;
  8304. }
  8305. j++;
  8306. }
  8307. if (state === 13 /* Accept */) {
  8308. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, len));
  8309. }
  8310. }
  8311. return result;
  8312. };
  8313. return LinkComputer;
  8314. }());
  8315. exports.LinkComputer = LinkComputer;
  8316. /**
  8317. * Returns an array of all links contains in the provided
  8318. * document. *Note* that this operation is computational
  8319. * expensive and should not run in the UI thread.
  8320. */
  8321. function computeLinks(model) {
  8322. if (!model || typeof model.getLineCount !== 'function' || typeof model.getLineContent !== 'function') {
  8323. // Unknown caller!
  8324. return [];
  8325. }
  8326. return LinkComputer.computeLinks(model);
  8327. }
  8328. exports.computeLinks = computeLinks;
  8329. });
  8330. /*---------------------------------------------------------------------------------------------
  8331. * Copyright (c) Microsoft Corporation. All rights reserved.
  8332. * Licensed under the MIT License. See License.txt in the project root for license information.
  8333. *--------------------------------------------------------------------------------------------*/
  8334. define(__m[27/*vs/editor/common/modes/supports/inplaceReplaceSupport*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  8335. "use strict";
  8336. Object.defineProperty(exports, "__esModule", { value: true });
  8337. var BasicInplaceReplace = /** @class */ (function () {
  8338. function BasicInplaceReplace() {
  8339. this._defaultValueSet = [
  8340. ['true', 'false'],
  8341. ['True', 'False'],
  8342. ['Private', 'Public', 'Friend', 'ReadOnly', 'Partial', 'Protected', 'WriteOnly'],
  8343. ['public', 'protected', 'private'],
  8344. ];
  8345. }
  8346. BasicInplaceReplace.prototype.navigateValueSet = function (range1, text1, range2, text2, up) {
  8347. if (range1 && text1) {
  8348. var result = this.doNavigateValueSet(text1, up);
  8349. if (result) {
  8350. return {
  8351. range: range1,
  8352. value: result
  8353. };
  8354. }
  8355. }
  8356. if (range2 && text2) {
  8357. var result = this.doNavigateValueSet(text2, up);
  8358. if (result) {
  8359. return {
  8360. range: range2,
  8361. value: result
  8362. };
  8363. }
  8364. }
  8365. return null;
  8366. };
  8367. BasicInplaceReplace.prototype.doNavigateValueSet = function (text, up) {
  8368. var numberResult = this.numberReplace(text, up);
  8369. if (numberResult !== null) {
  8370. return numberResult;
  8371. }
  8372. return this.textReplace(text, up);
  8373. };
  8374. BasicInplaceReplace.prototype.numberReplace = function (value, up) {
  8375. var precision = Math.pow(10, value.length - (value.lastIndexOf('.') + 1));
  8376. var n1 = Number(value);
  8377. var n2 = parseFloat(value);
  8378. if (!isNaN(n1) && !isNaN(n2) && n1 === n2) {
  8379. if (n1 === 0 && !up) {
  8380. return null; // don't do negative
  8381. // } else if(n1 === 9 && up) {
  8382. // return null; // don't insert 10 into a number
  8383. }
  8384. else {
  8385. n1 = Math.floor(n1 * precision);
  8386. n1 += up ? precision : -precision;
  8387. return String(n1 / precision);
  8388. }
  8389. }
  8390. return null;
  8391. };
  8392. BasicInplaceReplace.prototype.textReplace = function (value, up) {
  8393. return this.valueSetsReplace(this._defaultValueSet, value, up);
  8394. };
  8395. BasicInplaceReplace.prototype.valueSetsReplace = function (valueSets, value, up) {
  8396. var result = null;
  8397. for (var i = 0, len = valueSets.length; result === null && i < len; i++) {
  8398. result = this.valueSetReplace(valueSets[i], value, up);
  8399. }
  8400. return result;
  8401. };
  8402. BasicInplaceReplace.prototype.valueSetReplace = function (valueSet, value, up) {
  8403. var idx = valueSet.indexOf(value);
  8404. if (idx >= 0) {
  8405. idx += up ? +1 : -1;
  8406. if (idx < 0) {
  8407. idx = valueSet.length - 1;
  8408. }
  8409. else {
  8410. idx %= valueSet.length;
  8411. }
  8412. return valueSet[idx];
  8413. }
  8414. return null;
  8415. };
  8416. BasicInplaceReplace.INSTANCE = new BasicInplaceReplace();
  8417. return BasicInplaceReplace;
  8418. }());
  8419. exports.BasicInplaceReplace = BasicInplaceReplace;
  8420. });
  8421. /*!
  8422. Copyright (c) 2014 Taylor Hakes
  8423. Copyright (c) 2014 Forbes Lindesay
  8424. */
  8425. (function (global, factory) {
  8426. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  8427. typeof define === 'function' && define.amd ? define("vs/editor/common/standalone/promise-polyfill/polyfill", factory) :
  8428. (factory());
  8429. }(this, (function () {
  8430. 'use strict';
  8431. /**
  8432. * @this {Promise}
  8433. */
  8434. function finallyConstructor(callback) {
  8435. var constructor = this.constructor;
  8436. return this.then(
  8437. function (value) {
  8438. return constructor.resolve(callback()).then(function () {
  8439. return value;
  8440. });
  8441. },
  8442. function (reason) {
  8443. return constructor.resolve(callback()).then(function () {
  8444. return constructor.reject(reason);
  8445. });
  8446. }
  8447. );
  8448. }
  8449. // Store setTimeout reference so promise-polyfill will be unaffected by
  8450. // other code modifying setTimeout (like sinon.useFakeTimers())
  8451. var setTimeoutFunc = setTimeout;
  8452. function noop() { }
  8453. // Polyfill for Function.prototype.bind
  8454. function bind(fn, thisArg) {
  8455. return function () {
  8456. fn.apply(thisArg, arguments);
  8457. };
  8458. }
  8459. /**
  8460. * @constructor
  8461. * @param {Function} fn
  8462. */
  8463. function Promise(fn) {
  8464. if (!(this instanceof Promise))
  8465. throw new TypeError('Promises must be constructed via new');
  8466. if (typeof fn !== 'function') throw new TypeError('not a function');
  8467. /** @type {!number} */
  8468. this._state = 0;
  8469. /** @type {!boolean} */
  8470. this._handled = false;
  8471. /** @type {Promise|undefined} */
  8472. this._value = undefined;
  8473. /** @type {!Array<!Function>} */
  8474. this._deferreds = [];
  8475. doResolve(fn, this);
  8476. }
  8477. function handle(self, deferred) {
  8478. while (self._state === 3) {
  8479. self = self._value;
  8480. }
  8481. if (self._state === 0) {
  8482. self._deferreds.push(deferred);
  8483. return;
  8484. }
  8485. self._handled = true;
  8486. Promise._immediateFn(function () {
  8487. var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
  8488. if (cb === null) {
  8489. (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
  8490. return;
  8491. }
  8492. var ret;
  8493. try {
  8494. ret = cb(self._value);
  8495. } catch (e) {
  8496. reject(deferred.promise, e);
  8497. return;
  8498. }
  8499. resolve(deferred.promise, ret);
  8500. });
  8501. }
  8502. function resolve(self, newValue) {
  8503. try {
  8504. // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
  8505. if (newValue === self)
  8506. throw new TypeError('A promise cannot be resolved with itself.');
  8507. if (
  8508. newValue &&
  8509. (typeof newValue === 'object' || typeof newValue === 'function')
  8510. ) {
  8511. var then = newValue.then;
  8512. if (newValue instanceof Promise) {
  8513. self._state = 3;
  8514. self._value = newValue;
  8515. finale(self);
  8516. return;
  8517. } else if (typeof then === 'function') {
  8518. doResolve(bind(then, newValue), self);
  8519. return;
  8520. }
  8521. }
  8522. self._state = 1;
  8523. self._value = newValue;
  8524. finale(self);
  8525. } catch (e) {
  8526. reject(self, e);
  8527. }
  8528. }
  8529. function reject(self, newValue) {
  8530. self._state = 2;
  8531. self._value = newValue;
  8532. finale(self);
  8533. }
  8534. function finale(self) {
  8535. if (self._state === 2 && self._deferreds.length === 0) {
  8536. Promise._immediateFn(function () {
  8537. if (!self._handled) {
  8538. Promise._unhandledRejectionFn(self._value);
  8539. }
  8540. });
  8541. }
  8542. for (var i = 0, len = self._deferreds.length; i < len; i++) {
  8543. handle(self, self._deferreds[i]);
  8544. }
  8545. self._deferreds = null;
  8546. }
  8547. /**
  8548. * @constructor
  8549. */
  8550. function Handler(onFulfilled, onRejected, promise) {
  8551. this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
  8552. this.onRejected = typeof onRejected === 'function' ? onRejected : null;
  8553. this.promise = promise;
  8554. }
  8555. /**
  8556. * Take a potentially misbehaving resolver function and make sure
  8557. * onFulfilled and onRejected are only called once.
  8558. *
  8559. * Makes no guarantees about asynchrony.
  8560. */
  8561. function doResolve(fn, self) {
  8562. var done = false;
  8563. try {
  8564. fn(
  8565. function (value) {
  8566. if (done) return;
  8567. done = true;
  8568. resolve(self, value);
  8569. },
  8570. function (reason) {
  8571. if (done) return;
  8572. done = true;
  8573. reject(self, reason);
  8574. }
  8575. );
  8576. } catch (ex) {
  8577. if (done) return;
  8578. done = true;
  8579. reject(self, ex);
  8580. }
  8581. }
  8582. Promise.prototype['catch'] = function (onRejected) {
  8583. return this.then(null, onRejected);
  8584. };
  8585. Promise.prototype.then = function (onFulfilled, onRejected) {
  8586. // @ts-ignore
  8587. var prom = new this.constructor(noop);
  8588. handle(this, new Handler(onFulfilled, onRejected, prom));
  8589. return prom;
  8590. };
  8591. Promise.prototype['finally'] = finallyConstructor;
  8592. Promise.all = function (arr) {
  8593. return new Promise(function (resolve, reject) {
  8594. if (!arr || typeof arr.length === 'undefined')
  8595. throw new TypeError('Promise.all accepts an array');
  8596. var args = Array.prototype.slice.call(arr);
  8597. if (args.length === 0) return resolve([]);
  8598. var remaining = args.length;
  8599. function res(i, val) {
  8600. try {
  8601. if (val && (typeof val === 'object' || typeof val === 'function')) {
  8602. var then = val.then;
  8603. if (typeof then === 'function') {
  8604. then.call(
  8605. val,
  8606. function (val) {
  8607. res(i, val);
  8608. },
  8609. reject
  8610. );
  8611. return;
  8612. }
  8613. }
  8614. args[i] = val;
  8615. if (--remaining === 0) {
  8616. resolve(args);
  8617. }
  8618. } catch (ex) {
  8619. reject(ex);
  8620. }
  8621. }
  8622. for (var i = 0; i < args.length; i++) {
  8623. res(i, args[i]);
  8624. }
  8625. });
  8626. };
  8627. Promise.resolve = function (value) {
  8628. if (value && typeof value === 'object' && value.constructor === Promise) {
  8629. return value;
  8630. }
  8631. return new Promise(function (resolve) {
  8632. resolve(value);
  8633. });
  8634. };
  8635. Promise.reject = function (value) {
  8636. return new Promise(function (resolve, reject) {
  8637. reject(value);
  8638. });
  8639. };
  8640. Promise.race = function (values) {
  8641. return new Promise(function (resolve, reject) {
  8642. for (var i = 0, len = values.length; i < len; i++) {
  8643. values[i].then(resolve, reject);
  8644. }
  8645. });
  8646. };
  8647. // Use polyfill for setImmediate for performance gains
  8648. Promise._immediateFn =
  8649. (typeof setImmediate === 'function' &&
  8650. function (fn) {
  8651. setImmediate(fn);
  8652. }) ||
  8653. function (fn) {
  8654. setTimeoutFunc(fn, 0);
  8655. };
  8656. Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
  8657. if (typeof console !== 'undefined' && console) {
  8658. console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
  8659. }
  8660. };
  8661. /** @suppress {undefinedVars} */
  8662. var globalNS = (function () {
  8663. // the only reliable means to get the global object is
  8664. // `Function('return this')()`
  8665. // However, this causes CSP violations in Chrome apps.
  8666. if (typeof self !== 'undefined') {
  8667. return self;
  8668. }
  8669. if (typeof window !== 'undefined') {
  8670. return window;
  8671. }
  8672. if (typeof global !== 'undefined') {
  8673. return global;
  8674. }
  8675. throw new Error('unable to locate global object');
  8676. })();
  8677. if (!('Promise' in globalNS)) {
  8678. globalNS['Promise'] = Promise;
  8679. } else if (!globalNS.Promise.prototype['finally']) {
  8680. globalNS.Promise.prototype['finally'] = finallyConstructor;
  8681. }
  8682. })));
  8683. /*---------------------------------------------------------------------------------------------
  8684. * Copyright (c) Microsoft Corporation. All rights reserved.
  8685. * Licensed under the MIT License. See License.txt in the project root for license information.
  8686. *--------------------------------------------------------------------------------------------*/
  8687. define(__m[28/*vs/editor/common/standalone/standaloneEnums*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  8688. "use strict";
  8689. Object.defineProperty(exports, "__esModule", { value: true });
  8690. // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.
  8691. var AccessibilitySupport;
  8692. (function (AccessibilitySupport) {
  8693. /**
  8694. * This should be the browser case where it is not known if a screen reader is attached or no.
  8695. */
  8696. AccessibilitySupport[AccessibilitySupport["Unknown"] = 0] = "Unknown";
  8697. AccessibilitySupport[AccessibilitySupport["Disabled"] = 1] = "Disabled";
  8698. AccessibilitySupport[AccessibilitySupport["Enabled"] = 2] = "Enabled";
  8699. })(AccessibilitySupport = exports.AccessibilitySupport || (exports.AccessibilitySupport = {}));
  8700. var CompletionItemInsertTextRule;
  8701. (function (CompletionItemInsertTextRule) {
  8702. /**
  8703. * Adjust whitespace/indentation of multiline insert texts to
  8704. * match the current line indentation.
  8705. */
  8706. CompletionItemInsertTextRule[CompletionItemInsertTextRule["KeepWhitespace"] = 1] = "KeepWhitespace";
  8707. /**
  8708. * `insertText` is a snippet.
  8709. */
  8710. CompletionItemInsertTextRule[CompletionItemInsertTextRule["InsertAsSnippet"] = 4] = "InsertAsSnippet";
  8711. })(CompletionItemInsertTextRule = exports.CompletionItemInsertTextRule || (exports.CompletionItemInsertTextRule = {}));
  8712. var CompletionItemKind;
  8713. (function (CompletionItemKind) {
  8714. CompletionItemKind[CompletionItemKind["Method"] = 0] = "Method";
  8715. CompletionItemKind[CompletionItemKind["Function"] = 1] = "Function";
  8716. CompletionItemKind[CompletionItemKind["Constructor"] = 2] = "Constructor";
  8717. CompletionItemKind[CompletionItemKind["Field"] = 3] = "Field";
  8718. CompletionItemKind[CompletionItemKind["Variable"] = 4] = "Variable";
  8719. CompletionItemKind[CompletionItemKind["Class"] = 5] = "Class";
  8720. CompletionItemKind[CompletionItemKind["Struct"] = 6] = "Struct";
  8721. CompletionItemKind[CompletionItemKind["Interface"] = 7] = "Interface";
  8722. CompletionItemKind[CompletionItemKind["Module"] = 8] = "Module";
  8723. CompletionItemKind[CompletionItemKind["Property"] = 9] = "Property";
  8724. CompletionItemKind[CompletionItemKind["Event"] = 10] = "Event";
  8725. CompletionItemKind[CompletionItemKind["Operator"] = 11] = "Operator";
  8726. CompletionItemKind[CompletionItemKind["Unit"] = 12] = "Unit";
  8727. CompletionItemKind[CompletionItemKind["Value"] = 13] = "Value";
  8728. CompletionItemKind[CompletionItemKind["Constant"] = 14] = "Constant";
  8729. CompletionItemKind[CompletionItemKind["Enum"] = 15] = "Enum";
  8730. CompletionItemKind[CompletionItemKind["EnumMember"] = 16] = "EnumMember";
  8731. CompletionItemKind[CompletionItemKind["Keyword"] = 17] = "Keyword";
  8732. CompletionItemKind[CompletionItemKind["Text"] = 18] = "Text";
  8733. CompletionItemKind[CompletionItemKind["Color"] = 19] = "Color";
  8734. CompletionItemKind[CompletionItemKind["File"] = 20] = "File";
  8735. CompletionItemKind[CompletionItemKind["Reference"] = 21] = "Reference";
  8736. CompletionItemKind[CompletionItemKind["Customcolor"] = 22] = "Customcolor";
  8737. CompletionItemKind[CompletionItemKind["Folder"] = 23] = "Folder";
  8738. CompletionItemKind[CompletionItemKind["TypeParameter"] = 24] = "TypeParameter";
  8739. CompletionItemKind[CompletionItemKind["Snippet"] = 25] = "Snippet";
  8740. })(CompletionItemKind = exports.CompletionItemKind || (exports.CompletionItemKind = {}));
  8741. var CompletionItemTag;
  8742. (function (CompletionItemTag) {
  8743. CompletionItemTag[CompletionItemTag["Deprecated"] = 1] = "Deprecated";
  8744. })(CompletionItemTag = exports.CompletionItemTag || (exports.CompletionItemTag = {}));
  8745. /**
  8746. * How a suggest provider was triggered.
  8747. */
  8748. var CompletionTriggerKind;
  8749. (function (CompletionTriggerKind) {
  8750. CompletionTriggerKind[CompletionTriggerKind["Invoke"] = 0] = "Invoke";
  8751. CompletionTriggerKind[CompletionTriggerKind["TriggerCharacter"] = 1] = "TriggerCharacter";
  8752. CompletionTriggerKind[CompletionTriggerKind["TriggerForIncompleteCompletions"] = 2] = "TriggerForIncompleteCompletions";
  8753. })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
  8754. /**
  8755. * A positioning preference for rendering content widgets.
  8756. */
  8757. var ContentWidgetPositionPreference;
  8758. (function (ContentWidgetPositionPreference) {
  8759. /**
  8760. * Place the content widget exactly at a position
  8761. */
  8762. ContentWidgetPositionPreference[ContentWidgetPositionPreference["EXACT"] = 0] = "EXACT";
  8763. /**
  8764. * Place the content widget above a position
  8765. */
  8766. ContentWidgetPositionPreference[ContentWidgetPositionPreference["ABOVE"] = 1] = "ABOVE";
  8767. /**
  8768. * Place the content widget below a position
  8769. */
  8770. ContentWidgetPositionPreference[ContentWidgetPositionPreference["BELOW"] = 2] = "BELOW";
  8771. })(ContentWidgetPositionPreference = exports.ContentWidgetPositionPreference || (exports.ContentWidgetPositionPreference = {}));
  8772. /**
  8773. * Describes the reason the cursor has changed its position.
  8774. */
  8775. var CursorChangeReason;
  8776. (function (CursorChangeReason) {
  8777. /**
  8778. * Unknown or not set.
  8779. */
  8780. CursorChangeReason[CursorChangeReason["NotSet"] = 0] = "NotSet";
  8781. /**
  8782. * A `model.setValue()` was called.
  8783. */
  8784. CursorChangeReason[CursorChangeReason["ContentFlush"] = 1] = "ContentFlush";
  8785. /**
  8786. * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
  8787. */
  8788. CursorChangeReason[CursorChangeReason["RecoverFromMarkers"] = 2] = "RecoverFromMarkers";
  8789. /**
  8790. * There was an explicit user gesture.
  8791. */
  8792. CursorChangeReason[CursorChangeReason["Explicit"] = 3] = "Explicit";
  8793. /**
  8794. * There was a Paste.
  8795. */
  8796. CursorChangeReason[CursorChangeReason["Paste"] = 4] = "Paste";
  8797. /**
  8798. * There was an Undo.
  8799. */
  8800. CursorChangeReason[CursorChangeReason["Undo"] = 5] = "Undo";
  8801. /**
  8802. * There was a Redo.
  8803. */
  8804. CursorChangeReason[CursorChangeReason["Redo"] = 6] = "Redo";
  8805. })(CursorChangeReason = exports.CursorChangeReason || (exports.CursorChangeReason = {}));
  8806. /**
  8807. * The default end of line to use when instantiating models.
  8808. */
  8809. var DefaultEndOfLine;
  8810. (function (DefaultEndOfLine) {
  8811. /**
  8812. * Use line feed (\n) as the end of line character.
  8813. */
  8814. DefaultEndOfLine[DefaultEndOfLine["LF"] = 1] = "LF";
  8815. /**
  8816. * Use carriage return and line feed (\r\n) as the end of line character.
  8817. */
  8818. DefaultEndOfLine[DefaultEndOfLine["CRLF"] = 2] = "CRLF";
  8819. })(DefaultEndOfLine = exports.DefaultEndOfLine || (exports.DefaultEndOfLine = {}));
  8820. /**
  8821. * A document highlight kind.
  8822. */
  8823. var DocumentHighlightKind;
  8824. (function (DocumentHighlightKind) {
  8825. /**
  8826. * A textual occurrence.
  8827. */
  8828. DocumentHighlightKind[DocumentHighlightKind["Text"] = 0] = "Text";
  8829. /**
  8830. * Read-access of a symbol, like reading a variable.
  8831. */
  8832. DocumentHighlightKind[DocumentHighlightKind["Read"] = 1] = "Read";
  8833. /**
  8834. * Write-access of a symbol, like writing to a variable.
  8835. */
  8836. DocumentHighlightKind[DocumentHighlightKind["Write"] = 2] = "Write";
  8837. })(DocumentHighlightKind = exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {}));
  8838. /**
  8839. * Configuration options for auto indentation in the editor
  8840. */
  8841. var EditorAutoIndentStrategy;
  8842. (function (EditorAutoIndentStrategy) {
  8843. EditorAutoIndentStrategy[EditorAutoIndentStrategy["None"] = 0] = "None";
  8844. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Keep"] = 1] = "Keep";
  8845. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Brackets"] = 2] = "Brackets";
  8846. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Advanced"] = 3] = "Advanced";
  8847. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Full"] = 4] = "Full";
  8848. })(EditorAutoIndentStrategy = exports.EditorAutoIndentStrategy || (exports.EditorAutoIndentStrategy = {}));
  8849. var EditorOption;
  8850. (function (EditorOption) {
  8851. EditorOption[EditorOption["acceptSuggestionOnCommitCharacter"] = 0] = "acceptSuggestionOnCommitCharacter";
  8852. EditorOption[EditorOption["acceptSuggestionOnEnter"] = 1] = "acceptSuggestionOnEnter";
  8853. EditorOption[EditorOption["accessibilitySupport"] = 2] = "accessibilitySupport";
  8854. EditorOption[EditorOption["accessibilityPageSize"] = 3] = "accessibilityPageSize";
  8855. EditorOption[EditorOption["ariaLabel"] = 4] = "ariaLabel";
  8856. EditorOption[EditorOption["autoClosingBrackets"] = 5] = "autoClosingBrackets";
  8857. EditorOption[EditorOption["autoClosingOvertype"] = 6] = "autoClosingOvertype";
  8858. EditorOption[EditorOption["autoClosingQuotes"] = 7] = "autoClosingQuotes";
  8859. EditorOption[EditorOption["autoIndent"] = 8] = "autoIndent";
  8860. EditorOption[EditorOption["automaticLayout"] = 9] = "automaticLayout";
  8861. EditorOption[EditorOption["autoSurround"] = 10] = "autoSurround";
  8862. EditorOption[EditorOption["codeLens"] = 11] = "codeLens";
  8863. EditorOption[EditorOption["colorDecorators"] = 12] = "colorDecorators";
  8864. EditorOption[EditorOption["comments"] = 13] = "comments";
  8865. EditorOption[EditorOption["contextmenu"] = 14] = "contextmenu";
  8866. EditorOption[EditorOption["copyWithSyntaxHighlighting"] = 15] = "copyWithSyntaxHighlighting";
  8867. EditorOption[EditorOption["cursorBlinking"] = 16] = "cursorBlinking";
  8868. EditorOption[EditorOption["cursorSmoothCaretAnimation"] = 17] = "cursorSmoothCaretAnimation";
  8869. EditorOption[EditorOption["cursorStyle"] = 18] = "cursorStyle";
  8870. EditorOption[EditorOption["cursorSurroundingLines"] = 19] = "cursorSurroundingLines";
  8871. EditorOption[EditorOption["cursorSurroundingLinesStyle"] = 20] = "cursorSurroundingLinesStyle";
  8872. EditorOption[EditorOption["cursorWidth"] = 21] = "cursorWidth";
  8873. EditorOption[EditorOption["disableLayerHinting"] = 22] = "disableLayerHinting";
  8874. EditorOption[EditorOption["disableMonospaceOptimizations"] = 23] = "disableMonospaceOptimizations";
  8875. EditorOption[EditorOption["dragAndDrop"] = 24] = "dragAndDrop";
  8876. EditorOption[EditorOption["emptySelectionClipboard"] = 25] = "emptySelectionClipboard";
  8877. EditorOption[EditorOption["extraEditorClassName"] = 26] = "extraEditorClassName";
  8878. EditorOption[EditorOption["fastScrollSensitivity"] = 27] = "fastScrollSensitivity";
  8879. EditorOption[EditorOption["find"] = 28] = "find";
  8880. EditorOption[EditorOption["fixedOverflowWidgets"] = 29] = "fixedOverflowWidgets";
  8881. EditorOption[EditorOption["folding"] = 30] = "folding";
  8882. EditorOption[EditorOption["foldingStrategy"] = 31] = "foldingStrategy";
  8883. EditorOption[EditorOption["foldingHighlight"] = 32] = "foldingHighlight";
  8884. EditorOption[EditorOption["fontFamily"] = 33] = "fontFamily";
  8885. EditorOption[EditorOption["fontInfo"] = 34] = "fontInfo";
  8886. EditorOption[EditorOption["fontLigatures"] = 35] = "fontLigatures";
  8887. EditorOption[EditorOption["fontSize"] = 36] = "fontSize";
  8888. EditorOption[EditorOption["fontWeight"] = 37] = "fontWeight";
  8889. EditorOption[EditorOption["formatOnPaste"] = 38] = "formatOnPaste";
  8890. EditorOption[EditorOption["formatOnType"] = 39] = "formatOnType";
  8891. EditorOption[EditorOption["glyphMargin"] = 40] = "glyphMargin";
  8892. EditorOption[EditorOption["gotoLocation"] = 41] = "gotoLocation";
  8893. EditorOption[EditorOption["hideCursorInOverviewRuler"] = 42] = "hideCursorInOverviewRuler";
  8894. EditorOption[EditorOption["highlightActiveIndentGuide"] = 43] = "highlightActiveIndentGuide";
  8895. EditorOption[EditorOption["hover"] = 44] = "hover";
  8896. EditorOption[EditorOption["inDiffEditor"] = 45] = "inDiffEditor";
  8897. EditorOption[EditorOption["letterSpacing"] = 46] = "letterSpacing";
  8898. EditorOption[EditorOption["lightbulb"] = 47] = "lightbulb";
  8899. EditorOption[EditorOption["lineDecorationsWidth"] = 48] = "lineDecorationsWidth";
  8900. EditorOption[EditorOption["lineHeight"] = 49] = "lineHeight";
  8901. EditorOption[EditorOption["lineNumbers"] = 50] = "lineNumbers";
  8902. EditorOption[EditorOption["lineNumbersMinChars"] = 51] = "lineNumbersMinChars";
  8903. EditorOption[EditorOption["links"] = 52] = "links";
  8904. EditorOption[EditorOption["matchBrackets"] = 53] = "matchBrackets";
  8905. EditorOption[EditorOption["minimap"] = 54] = "minimap";
  8906. EditorOption[EditorOption["mouseStyle"] = 55] = "mouseStyle";
  8907. EditorOption[EditorOption["mouseWheelScrollSensitivity"] = 56] = "mouseWheelScrollSensitivity";
  8908. EditorOption[EditorOption["mouseWheelZoom"] = 57] = "mouseWheelZoom";
  8909. EditorOption[EditorOption["multiCursorMergeOverlapping"] = 58] = "multiCursorMergeOverlapping";
  8910. EditorOption[EditorOption["multiCursorModifier"] = 59] = "multiCursorModifier";
  8911. EditorOption[EditorOption["multiCursorPaste"] = 60] = "multiCursorPaste";
  8912. EditorOption[EditorOption["occurrencesHighlight"] = 61] = "occurrencesHighlight";
  8913. EditorOption[EditorOption["overviewRulerBorder"] = 62] = "overviewRulerBorder";
  8914. EditorOption[EditorOption["overviewRulerLanes"] = 63] = "overviewRulerLanes";
  8915. EditorOption[EditorOption["parameterHints"] = 64] = "parameterHints";
  8916. EditorOption[EditorOption["peekWidgetDefaultFocus"] = 65] = "peekWidgetDefaultFocus";
  8917. EditorOption[EditorOption["quickSuggestions"] = 66] = "quickSuggestions";
  8918. EditorOption[EditorOption["quickSuggestionsDelay"] = 67] = "quickSuggestionsDelay";
  8919. EditorOption[EditorOption["readOnly"] = 68] = "readOnly";
  8920. EditorOption[EditorOption["renderControlCharacters"] = 69] = "renderControlCharacters";
  8921. EditorOption[EditorOption["renderIndentGuides"] = 70] = "renderIndentGuides";
  8922. EditorOption[EditorOption["renderFinalNewline"] = 71] = "renderFinalNewline";
  8923. EditorOption[EditorOption["renderLineHighlight"] = 72] = "renderLineHighlight";
  8924. EditorOption[EditorOption["renderValidationDecorations"] = 73] = "renderValidationDecorations";
  8925. EditorOption[EditorOption["renderWhitespace"] = 74] = "renderWhitespace";
  8926. EditorOption[EditorOption["revealHorizontalRightPadding"] = 75] = "revealHorizontalRightPadding";
  8927. EditorOption[EditorOption["roundedSelection"] = 76] = "roundedSelection";
  8928. EditorOption[EditorOption["rulers"] = 77] = "rulers";
  8929. EditorOption[EditorOption["scrollbar"] = 78] = "scrollbar";
  8930. EditorOption[EditorOption["scrollBeyondLastColumn"] = 79] = "scrollBeyondLastColumn";
  8931. EditorOption[EditorOption["scrollBeyondLastLine"] = 80] = "scrollBeyondLastLine";
  8932. EditorOption[EditorOption["selectionClipboard"] = 81] = "selectionClipboard";
  8933. EditorOption[EditorOption["selectionHighlight"] = 82] = "selectionHighlight";
  8934. EditorOption[EditorOption["selectOnLineNumbers"] = 83] = "selectOnLineNumbers";
  8935. EditorOption[EditorOption["showFoldingControls"] = 84] = "showFoldingControls";
  8936. EditorOption[EditorOption["showUnused"] = 85] = "showUnused";
  8937. EditorOption[EditorOption["snippetSuggestions"] = 86] = "snippetSuggestions";
  8938. EditorOption[EditorOption["smoothScrolling"] = 87] = "smoothScrolling";
  8939. EditorOption[EditorOption["stopRenderingLineAfter"] = 88] = "stopRenderingLineAfter";
  8940. EditorOption[EditorOption["suggest"] = 89] = "suggest";
  8941. EditorOption[EditorOption["suggestFontSize"] = 90] = "suggestFontSize";
  8942. EditorOption[EditorOption["suggestLineHeight"] = 91] = "suggestLineHeight";
  8943. EditorOption[EditorOption["suggestOnTriggerCharacters"] = 92] = "suggestOnTriggerCharacters";
  8944. EditorOption[EditorOption["suggestSelection"] = 93] = "suggestSelection";
  8945. EditorOption[EditorOption["tabCompletion"] = 94] = "tabCompletion";
  8946. EditorOption[EditorOption["useTabStops"] = 95] = "useTabStops";
  8947. EditorOption[EditorOption["wordSeparators"] = 96] = "wordSeparators";
  8948. EditorOption[EditorOption["wordWrap"] = 97] = "wordWrap";
  8949. EditorOption[EditorOption["wordWrapBreakAfterCharacters"] = 98] = "wordWrapBreakAfterCharacters";
  8950. EditorOption[EditorOption["wordWrapBreakBeforeCharacters"] = 99] = "wordWrapBreakBeforeCharacters";
  8951. EditorOption[EditorOption["wordWrapColumn"] = 100] = "wordWrapColumn";
  8952. EditorOption[EditorOption["wordWrapMinified"] = 101] = "wordWrapMinified";
  8953. EditorOption[EditorOption["wrappingIndent"] = 102] = "wrappingIndent";
  8954. EditorOption[EditorOption["wrappingStrategy"] = 103] = "wrappingStrategy";
  8955. EditorOption[EditorOption["editorClassName"] = 104] = "editorClassName";
  8956. EditorOption[EditorOption["pixelRatio"] = 105] = "pixelRatio";
  8957. EditorOption[EditorOption["tabFocusMode"] = 106] = "tabFocusMode";
  8958. EditorOption[EditorOption["layoutInfo"] = 107] = "layoutInfo";
  8959. EditorOption[EditorOption["wrappingInfo"] = 108] = "wrappingInfo";
  8960. })(EditorOption = exports.EditorOption || (exports.EditorOption = {}));
  8961. /**
  8962. * End of line character preference.
  8963. */
  8964. var EndOfLinePreference;
  8965. (function (EndOfLinePreference) {
  8966. /**
  8967. * Use the end of line character identified in the text buffer.
  8968. */
  8969. EndOfLinePreference[EndOfLinePreference["TextDefined"] = 0] = "TextDefined";
  8970. /**
  8971. * Use line feed (\n) as the end of line character.
  8972. */
  8973. EndOfLinePreference[EndOfLinePreference["LF"] = 1] = "LF";
  8974. /**
  8975. * Use carriage return and line feed (\r\n) as the end of line character.
  8976. */
  8977. EndOfLinePreference[EndOfLinePreference["CRLF"] = 2] = "CRLF";
  8978. })(EndOfLinePreference = exports.EndOfLinePreference || (exports.EndOfLinePreference = {}));
  8979. /**
  8980. * End of line character preference.
  8981. */
  8982. var EndOfLineSequence;
  8983. (function (EndOfLineSequence) {
  8984. /**
  8985. * Use line feed (\n) as the end of line character.
  8986. */
  8987. EndOfLineSequence[EndOfLineSequence["LF"] = 0] = "LF";
  8988. /**
  8989. * Use carriage return and line feed (\r\n) as the end of line character.
  8990. */
  8991. EndOfLineSequence[EndOfLineSequence["CRLF"] = 1] = "CRLF";
  8992. })(EndOfLineSequence = exports.EndOfLineSequence || (exports.EndOfLineSequence = {}));
  8993. /**
  8994. * Describes what to do with the indentation when pressing Enter.
  8995. */
  8996. var IndentAction;
  8997. (function (IndentAction) {
  8998. /**
  8999. * Insert new line and copy the previous line's indentation.
  9000. */
  9001. IndentAction[IndentAction["None"] = 0] = "None";
  9002. /**
  9003. * Insert new line and indent once (relative to the previous line's indentation).
  9004. */
  9005. IndentAction[IndentAction["Indent"] = 1] = "Indent";
  9006. /**
  9007. * Insert two new lines:
  9008. * - the first one indented which will hold the cursor
  9009. * - the second one at the same indentation level
  9010. */
  9011. IndentAction[IndentAction["IndentOutdent"] = 2] = "IndentOutdent";
  9012. /**
  9013. * Insert new line and outdent once (relative to the previous line's indentation).
  9014. */
  9015. IndentAction[IndentAction["Outdent"] = 3] = "Outdent";
  9016. })(IndentAction = exports.IndentAction || (exports.IndentAction = {}));
  9017. /**
  9018. * Virtual Key Codes, the value does not hold any inherent meaning.
  9019. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  9020. * But these are "more general", as they should work across browsers & OS`s.
  9021. */
  9022. var KeyCode;
  9023. (function (KeyCode) {
  9024. /**
  9025. * Placed first to cover the 0 value of the enum.
  9026. */
  9027. KeyCode[KeyCode["Unknown"] = 0] = "Unknown";
  9028. KeyCode[KeyCode["Backspace"] = 1] = "Backspace";
  9029. KeyCode[KeyCode["Tab"] = 2] = "Tab";
  9030. KeyCode[KeyCode["Enter"] = 3] = "Enter";
  9031. KeyCode[KeyCode["Shift"] = 4] = "Shift";
  9032. KeyCode[KeyCode["Ctrl"] = 5] = "Ctrl";
  9033. KeyCode[KeyCode["Alt"] = 6] = "Alt";
  9034. KeyCode[KeyCode["PauseBreak"] = 7] = "PauseBreak";
  9035. KeyCode[KeyCode["CapsLock"] = 8] = "CapsLock";
  9036. KeyCode[KeyCode["Escape"] = 9] = "Escape";
  9037. KeyCode[KeyCode["Space"] = 10] = "Space";
  9038. KeyCode[KeyCode["PageUp"] = 11] = "PageUp";
  9039. KeyCode[KeyCode["PageDown"] = 12] = "PageDown";
  9040. KeyCode[KeyCode["End"] = 13] = "End";
  9041. KeyCode[KeyCode["Home"] = 14] = "Home";
  9042. KeyCode[KeyCode["LeftArrow"] = 15] = "LeftArrow";
  9043. KeyCode[KeyCode["UpArrow"] = 16] = "UpArrow";
  9044. KeyCode[KeyCode["RightArrow"] = 17] = "RightArrow";
  9045. KeyCode[KeyCode["DownArrow"] = 18] = "DownArrow";
  9046. KeyCode[KeyCode["Insert"] = 19] = "Insert";
  9047. KeyCode[KeyCode["Delete"] = 20] = "Delete";
  9048. KeyCode[KeyCode["KEY_0"] = 21] = "KEY_0";
  9049. KeyCode[KeyCode["KEY_1"] = 22] = "KEY_1";
  9050. KeyCode[KeyCode["KEY_2"] = 23] = "KEY_2";
  9051. KeyCode[KeyCode["KEY_3"] = 24] = "KEY_3";
  9052. KeyCode[KeyCode["KEY_4"] = 25] = "KEY_4";
  9053. KeyCode[KeyCode["KEY_5"] = 26] = "KEY_5";
  9054. KeyCode[KeyCode["KEY_6"] = 27] = "KEY_6";
  9055. KeyCode[KeyCode["KEY_7"] = 28] = "KEY_7";
  9056. KeyCode[KeyCode["KEY_8"] = 29] = "KEY_8";
  9057. KeyCode[KeyCode["KEY_9"] = 30] = "KEY_9";
  9058. KeyCode[KeyCode["KEY_A"] = 31] = "KEY_A";
  9059. KeyCode[KeyCode["KEY_B"] = 32] = "KEY_B";
  9060. KeyCode[KeyCode["KEY_C"] = 33] = "KEY_C";
  9061. KeyCode[KeyCode["KEY_D"] = 34] = "KEY_D";
  9062. KeyCode[KeyCode["KEY_E"] = 35] = "KEY_E";
  9063. KeyCode[KeyCode["KEY_F"] = 36] = "KEY_F";
  9064. KeyCode[KeyCode["KEY_G"] = 37] = "KEY_G";
  9065. KeyCode[KeyCode["KEY_H"] = 38] = "KEY_H";
  9066. KeyCode[KeyCode["KEY_I"] = 39] = "KEY_I";
  9067. KeyCode[KeyCode["KEY_J"] = 40] = "KEY_J";
  9068. KeyCode[KeyCode["KEY_K"] = 41] = "KEY_K";
  9069. KeyCode[KeyCode["KEY_L"] = 42] = "KEY_L";
  9070. KeyCode[KeyCode["KEY_M"] = 43] = "KEY_M";
  9071. KeyCode[KeyCode["KEY_N"] = 44] = "KEY_N";
  9072. KeyCode[KeyCode["KEY_O"] = 45] = "KEY_O";
  9073. KeyCode[KeyCode["KEY_P"] = 46] = "KEY_P";
  9074. KeyCode[KeyCode["KEY_Q"] = 47] = "KEY_Q";
  9075. KeyCode[KeyCode["KEY_R"] = 48] = "KEY_R";
  9076. KeyCode[KeyCode["KEY_S"] = 49] = "KEY_S";
  9077. KeyCode[KeyCode["KEY_T"] = 50] = "KEY_T";
  9078. KeyCode[KeyCode["KEY_U"] = 51] = "KEY_U";
  9079. KeyCode[KeyCode["KEY_V"] = 52] = "KEY_V";
  9080. KeyCode[KeyCode["KEY_W"] = 53] = "KEY_W";
  9081. KeyCode[KeyCode["KEY_X"] = 54] = "KEY_X";
  9082. KeyCode[KeyCode["KEY_Y"] = 55] = "KEY_Y";
  9083. KeyCode[KeyCode["KEY_Z"] = 56] = "KEY_Z";
  9084. KeyCode[KeyCode["Meta"] = 57] = "Meta";
  9085. KeyCode[KeyCode["ContextMenu"] = 58] = "ContextMenu";
  9086. KeyCode[KeyCode["F1"] = 59] = "F1";
  9087. KeyCode[KeyCode["F2"] = 60] = "F2";
  9088. KeyCode[KeyCode["F3"] = 61] = "F3";
  9089. KeyCode[KeyCode["F4"] = 62] = "F4";
  9090. KeyCode[KeyCode["F5"] = 63] = "F5";
  9091. KeyCode[KeyCode["F6"] = 64] = "F6";
  9092. KeyCode[KeyCode["F7"] = 65] = "F7";
  9093. KeyCode[KeyCode["F8"] = 66] = "F8";
  9094. KeyCode[KeyCode["F9"] = 67] = "F9";
  9095. KeyCode[KeyCode["F10"] = 68] = "F10";
  9096. KeyCode[KeyCode["F11"] = 69] = "F11";
  9097. KeyCode[KeyCode["F12"] = 70] = "F12";
  9098. KeyCode[KeyCode["F13"] = 71] = "F13";
  9099. KeyCode[KeyCode["F14"] = 72] = "F14";
  9100. KeyCode[KeyCode["F15"] = 73] = "F15";
  9101. KeyCode[KeyCode["F16"] = 74] = "F16";
  9102. KeyCode[KeyCode["F17"] = 75] = "F17";
  9103. KeyCode[KeyCode["F18"] = 76] = "F18";
  9104. KeyCode[KeyCode["F19"] = 77] = "F19";
  9105. KeyCode[KeyCode["NumLock"] = 78] = "NumLock";
  9106. KeyCode[KeyCode["ScrollLock"] = 79] = "ScrollLock";
  9107. /**
  9108. * Used for miscellaneous characters; it can vary by keyboard.
  9109. * For the US standard keyboard, the ';:' key
  9110. */
  9111. KeyCode[KeyCode["US_SEMICOLON"] = 80] = "US_SEMICOLON";
  9112. /**
  9113. * For any country/region, the '+' key
  9114. * For the US standard keyboard, the '=+' key
  9115. */
  9116. KeyCode[KeyCode["US_EQUAL"] = 81] = "US_EQUAL";
  9117. /**
  9118. * For any country/region, the ',' key
  9119. * For the US standard keyboard, the ',<' key
  9120. */
  9121. KeyCode[KeyCode["US_COMMA"] = 82] = "US_COMMA";
  9122. /**
  9123. * For any country/region, the '-' key
  9124. * For the US standard keyboard, the '-_' key
  9125. */
  9126. KeyCode[KeyCode["US_MINUS"] = 83] = "US_MINUS";
  9127. /**
  9128. * For any country/region, the '.' key
  9129. * For the US standard keyboard, the '.>' key
  9130. */
  9131. KeyCode[KeyCode["US_DOT"] = 84] = "US_DOT";
  9132. /**
  9133. * Used for miscellaneous characters; it can vary by keyboard.
  9134. * For the US standard keyboard, the '/?' key
  9135. */
  9136. KeyCode[KeyCode["US_SLASH"] = 85] = "US_SLASH";
  9137. /**
  9138. * Used for miscellaneous characters; it can vary by keyboard.
  9139. * For the US standard keyboard, the '`~' key
  9140. */
  9141. KeyCode[KeyCode["US_BACKTICK"] = 86] = "US_BACKTICK";
  9142. /**
  9143. * Used for miscellaneous characters; it can vary by keyboard.
  9144. * For the US standard keyboard, the '[{' key
  9145. */
  9146. KeyCode[KeyCode["US_OPEN_SQUARE_BRACKET"] = 87] = "US_OPEN_SQUARE_BRACKET";
  9147. /**
  9148. * Used for miscellaneous characters; it can vary by keyboard.
  9149. * For the US standard keyboard, the '\|' key
  9150. */
  9151. KeyCode[KeyCode["US_BACKSLASH"] = 88] = "US_BACKSLASH";
  9152. /**
  9153. * Used for miscellaneous characters; it can vary by keyboard.
  9154. * For the US standard keyboard, the ']}' key
  9155. */
  9156. KeyCode[KeyCode["US_CLOSE_SQUARE_BRACKET"] = 89] = "US_CLOSE_SQUARE_BRACKET";
  9157. /**
  9158. * Used for miscellaneous characters; it can vary by keyboard.
  9159. * For the US standard keyboard, the ''"' key
  9160. */
  9161. KeyCode[KeyCode["US_QUOTE"] = 90] = "US_QUOTE";
  9162. /**
  9163. * Used for miscellaneous characters; it can vary by keyboard.
  9164. */
  9165. KeyCode[KeyCode["OEM_8"] = 91] = "OEM_8";
  9166. /**
  9167. * Either the angle bracket key or the backslash key on the RT 102-key keyboard.
  9168. */
  9169. KeyCode[KeyCode["OEM_102"] = 92] = "OEM_102";
  9170. KeyCode[KeyCode["NUMPAD_0"] = 93] = "NUMPAD_0";
  9171. KeyCode[KeyCode["NUMPAD_1"] = 94] = "NUMPAD_1";
  9172. KeyCode[KeyCode["NUMPAD_2"] = 95] = "NUMPAD_2";
  9173. KeyCode[KeyCode["NUMPAD_3"] = 96] = "NUMPAD_3";
  9174. KeyCode[KeyCode["NUMPAD_4"] = 97] = "NUMPAD_4";
  9175. KeyCode[KeyCode["NUMPAD_5"] = 98] = "NUMPAD_5";
  9176. KeyCode[KeyCode["NUMPAD_6"] = 99] = "NUMPAD_6";
  9177. KeyCode[KeyCode["NUMPAD_7"] = 100] = "NUMPAD_7";
  9178. KeyCode[KeyCode["NUMPAD_8"] = 101] = "NUMPAD_8";
  9179. KeyCode[KeyCode["NUMPAD_9"] = 102] = "NUMPAD_9";
  9180. KeyCode[KeyCode["NUMPAD_MULTIPLY"] = 103] = "NUMPAD_MULTIPLY";
  9181. KeyCode[KeyCode["NUMPAD_ADD"] = 104] = "NUMPAD_ADD";
  9182. KeyCode[KeyCode["NUMPAD_SEPARATOR"] = 105] = "NUMPAD_SEPARATOR";
  9183. KeyCode[KeyCode["NUMPAD_SUBTRACT"] = 106] = "NUMPAD_SUBTRACT";
  9184. KeyCode[KeyCode["NUMPAD_DECIMAL"] = 107] = "NUMPAD_DECIMAL";
  9185. KeyCode[KeyCode["NUMPAD_DIVIDE"] = 108] = "NUMPAD_DIVIDE";
  9186. /**
  9187. * Cover all key codes when IME is processing input.
  9188. */
  9189. KeyCode[KeyCode["KEY_IN_COMPOSITION"] = 109] = "KEY_IN_COMPOSITION";
  9190. KeyCode[KeyCode["ABNT_C1"] = 110] = "ABNT_C1";
  9191. KeyCode[KeyCode["ABNT_C2"] = 111] = "ABNT_C2";
  9192. /**
  9193. * Placed last to cover the length of the enum.
  9194. * Please do not depend on this value!
  9195. */
  9196. KeyCode[KeyCode["MAX_VALUE"] = 112] = "MAX_VALUE";
  9197. })(KeyCode = exports.KeyCode || (exports.KeyCode = {}));
  9198. var MarkerSeverity;
  9199. (function (MarkerSeverity) {
  9200. MarkerSeverity[MarkerSeverity["Hint"] = 1] = "Hint";
  9201. MarkerSeverity[MarkerSeverity["Info"] = 2] = "Info";
  9202. MarkerSeverity[MarkerSeverity["Warning"] = 4] = "Warning";
  9203. MarkerSeverity[MarkerSeverity["Error"] = 8] = "Error";
  9204. })(MarkerSeverity = exports.MarkerSeverity || (exports.MarkerSeverity = {}));
  9205. var MarkerTag;
  9206. (function (MarkerTag) {
  9207. MarkerTag[MarkerTag["Unnecessary"] = 1] = "Unnecessary";
  9208. MarkerTag[MarkerTag["Deprecated"] = 2] = "Deprecated";
  9209. })(MarkerTag = exports.MarkerTag || (exports.MarkerTag = {}));
  9210. /**
  9211. * Position in the minimap to render the decoration.
  9212. */
  9213. var MinimapPosition;
  9214. (function (MinimapPosition) {
  9215. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  9216. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  9217. })(MinimapPosition = exports.MinimapPosition || (exports.MinimapPosition = {}));
  9218. /**
  9219. * Type of hit element with the mouse in the editor.
  9220. */
  9221. var MouseTargetType;
  9222. (function (MouseTargetType) {
  9223. /**
  9224. * Mouse is on top of an unknown element.
  9225. */
  9226. MouseTargetType[MouseTargetType["UNKNOWN"] = 0] = "UNKNOWN";
  9227. /**
  9228. * Mouse is on top of the textarea used for input.
  9229. */
  9230. MouseTargetType[MouseTargetType["TEXTAREA"] = 1] = "TEXTAREA";
  9231. /**
  9232. * Mouse is on top of the glyph margin
  9233. */
  9234. MouseTargetType[MouseTargetType["GUTTER_GLYPH_MARGIN"] = 2] = "GUTTER_GLYPH_MARGIN";
  9235. /**
  9236. * Mouse is on top of the line numbers
  9237. */
  9238. MouseTargetType[MouseTargetType["GUTTER_LINE_NUMBERS"] = 3] = "GUTTER_LINE_NUMBERS";
  9239. /**
  9240. * Mouse is on top of the line decorations
  9241. */
  9242. MouseTargetType[MouseTargetType["GUTTER_LINE_DECORATIONS"] = 4] = "GUTTER_LINE_DECORATIONS";
  9243. /**
  9244. * Mouse is on top of the whitespace left in the gutter by a view zone.
  9245. */
  9246. MouseTargetType[MouseTargetType["GUTTER_VIEW_ZONE"] = 5] = "GUTTER_VIEW_ZONE";
  9247. /**
  9248. * Mouse is on top of text in the content.
  9249. */
  9250. MouseTargetType[MouseTargetType["CONTENT_TEXT"] = 6] = "CONTENT_TEXT";
  9251. /**
  9252. * Mouse is on top of empty space in the content (e.g. after line text or below last line)
  9253. */
  9254. MouseTargetType[MouseTargetType["CONTENT_EMPTY"] = 7] = "CONTENT_EMPTY";
  9255. /**
  9256. * Mouse is on top of a view zone in the content.
  9257. */
  9258. MouseTargetType[MouseTargetType["CONTENT_VIEW_ZONE"] = 8] = "CONTENT_VIEW_ZONE";
  9259. /**
  9260. * Mouse is on top of a content widget.
  9261. */
  9262. MouseTargetType[MouseTargetType["CONTENT_WIDGET"] = 9] = "CONTENT_WIDGET";
  9263. /**
  9264. * Mouse is on top of the decorations overview ruler.
  9265. */
  9266. MouseTargetType[MouseTargetType["OVERVIEW_RULER"] = 10] = "OVERVIEW_RULER";
  9267. /**
  9268. * Mouse is on top of a scrollbar.
  9269. */
  9270. MouseTargetType[MouseTargetType["SCROLLBAR"] = 11] = "SCROLLBAR";
  9271. /**
  9272. * Mouse is on top of an overlay widget.
  9273. */
  9274. MouseTargetType[MouseTargetType["OVERLAY_WIDGET"] = 12] = "OVERLAY_WIDGET";
  9275. /**
  9276. * Mouse is outside of the editor.
  9277. */
  9278. MouseTargetType[MouseTargetType["OUTSIDE_EDITOR"] = 13] = "OUTSIDE_EDITOR";
  9279. })(MouseTargetType = exports.MouseTargetType || (exports.MouseTargetType = {}));
  9280. /**
  9281. * A positioning preference for rendering overlay widgets.
  9282. */
  9283. var OverlayWidgetPositionPreference;
  9284. (function (OverlayWidgetPositionPreference) {
  9285. /**
  9286. * Position the overlay widget in the top right corner
  9287. */
  9288. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_RIGHT_CORNER"] = 0] = "TOP_RIGHT_CORNER";
  9289. /**
  9290. * Position the overlay widget in the bottom right corner
  9291. */
  9292. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["BOTTOM_RIGHT_CORNER"] = 1] = "BOTTOM_RIGHT_CORNER";
  9293. /**
  9294. * Position the overlay widget in the top center
  9295. */
  9296. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_CENTER"] = 2] = "TOP_CENTER";
  9297. })(OverlayWidgetPositionPreference = exports.OverlayWidgetPositionPreference || (exports.OverlayWidgetPositionPreference = {}));
  9298. /**
  9299. * Vertical Lane in the overview ruler of the editor.
  9300. */
  9301. var OverviewRulerLane;
  9302. (function (OverviewRulerLane) {
  9303. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  9304. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  9305. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  9306. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  9307. })(OverviewRulerLane = exports.OverviewRulerLane || (exports.OverviewRulerLane = {}));
  9308. var RenderLineNumbersType;
  9309. (function (RenderLineNumbersType) {
  9310. RenderLineNumbersType[RenderLineNumbersType["Off"] = 0] = "Off";
  9311. RenderLineNumbersType[RenderLineNumbersType["On"] = 1] = "On";
  9312. RenderLineNumbersType[RenderLineNumbersType["Relative"] = 2] = "Relative";
  9313. RenderLineNumbersType[RenderLineNumbersType["Interval"] = 3] = "Interval";
  9314. RenderLineNumbersType[RenderLineNumbersType["Custom"] = 4] = "Custom";
  9315. })(RenderLineNumbersType = exports.RenderLineNumbersType || (exports.RenderLineNumbersType = {}));
  9316. var RenderMinimap;
  9317. (function (RenderMinimap) {
  9318. RenderMinimap[RenderMinimap["None"] = 0] = "None";
  9319. RenderMinimap[RenderMinimap["Text"] = 1] = "Text";
  9320. RenderMinimap[RenderMinimap["Blocks"] = 2] = "Blocks";
  9321. })(RenderMinimap = exports.RenderMinimap || (exports.RenderMinimap = {}));
  9322. var ScrollType;
  9323. (function (ScrollType) {
  9324. ScrollType[ScrollType["Smooth"] = 0] = "Smooth";
  9325. ScrollType[ScrollType["Immediate"] = 1] = "Immediate";
  9326. })(ScrollType = exports.ScrollType || (exports.ScrollType = {}));
  9327. var ScrollbarVisibility;
  9328. (function (ScrollbarVisibility) {
  9329. ScrollbarVisibility[ScrollbarVisibility["Auto"] = 1] = "Auto";
  9330. ScrollbarVisibility[ScrollbarVisibility["Hidden"] = 2] = "Hidden";
  9331. ScrollbarVisibility[ScrollbarVisibility["Visible"] = 3] = "Visible";
  9332. })(ScrollbarVisibility = exports.ScrollbarVisibility || (exports.ScrollbarVisibility = {}));
  9333. /**
  9334. * The direction of a selection.
  9335. */
  9336. var SelectionDirection;
  9337. (function (SelectionDirection) {
  9338. /**
  9339. * The selection starts above where it ends.
  9340. */
  9341. SelectionDirection[SelectionDirection["LTR"] = 0] = "LTR";
  9342. /**
  9343. * The selection starts below where it ends.
  9344. */
  9345. SelectionDirection[SelectionDirection["RTL"] = 1] = "RTL";
  9346. })(SelectionDirection = exports.SelectionDirection || (exports.SelectionDirection = {}));
  9347. var SignatureHelpTriggerKind;
  9348. (function (SignatureHelpTriggerKind) {
  9349. SignatureHelpTriggerKind[SignatureHelpTriggerKind["Invoke"] = 1] = "Invoke";
  9350. SignatureHelpTriggerKind[SignatureHelpTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter";
  9351. SignatureHelpTriggerKind[SignatureHelpTriggerKind["ContentChange"] = 3] = "ContentChange";
  9352. })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
  9353. /**
  9354. * A symbol kind.
  9355. */
  9356. var SymbolKind;
  9357. (function (SymbolKind) {
  9358. SymbolKind[SymbolKind["File"] = 0] = "File";
  9359. SymbolKind[SymbolKind["Module"] = 1] = "Module";
  9360. SymbolKind[SymbolKind["Namespace"] = 2] = "Namespace";
  9361. SymbolKind[SymbolKind["Package"] = 3] = "Package";
  9362. SymbolKind[SymbolKind["Class"] = 4] = "Class";
  9363. SymbolKind[SymbolKind["Method"] = 5] = "Method";
  9364. SymbolKind[SymbolKind["Property"] = 6] = "Property";
  9365. SymbolKind[SymbolKind["Field"] = 7] = "Field";
  9366. SymbolKind[SymbolKind["Constructor"] = 8] = "Constructor";
  9367. SymbolKind[SymbolKind["Enum"] = 9] = "Enum";
  9368. SymbolKind[SymbolKind["Interface"] = 10] = "Interface";
  9369. SymbolKind[SymbolKind["Function"] = 11] = "Function";
  9370. SymbolKind[SymbolKind["Variable"] = 12] = "Variable";
  9371. SymbolKind[SymbolKind["Constant"] = 13] = "Constant";
  9372. SymbolKind[SymbolKind["String"] = 14] = "String";
  9373. SymbolKind[SymbolKind["Number"] = 15] = "Number";
  9374. SymbolKind[SymbolKind["Boolean"] = 16] = "Boolean";
  9375. SymbolKind[SymbolKind["Array"] = 17] = "Array";
  9376. SymbolKind[SymbolKind["Object"] = 18] = "Object";
  9377. SymbolKind[SymbolKind["Key"] = 19] = "Key";
  9378. SymbolKind[SymbolKind["Null"] = 20] = "Null";
  9379. SymbolKind[SymbolKind["EnumMember"] = 21] = "EnumMember";
  9380. SymbolKind[SymbolKind["Struct"] = 22] = "Struct";
  9381. SymbolKind[SymbolKind["Event"] = 23] = "Event";
  9382. SymbolKind[SymbolKind["Operator"] = 24] = "Operator";
  9383. SymbolKind[SymbolKind["TypeParameter"] = 25] = "TypeParameter";
  9384. })(SymbolKind = exports.SymbolKind || (exports.SymbolKind = {}));
  9385. var SymbolTag;
  9386. (function (SymbolTag) {
  9387. SymbolTag[SymbolTag["Deprecated"] = 1] = "Deprecated";
  9388. })(SymbolTag = exports.SymbolTag || (exports.SymbolTag = {}));
  9389. /**
  9390. * The kind of animation in which the editor's cursor should be rendered.
  9391. */
  9392. var TextEditorCursorBlinkingStyle;
  9393. (function (TextEditorCursorBlinkingStyle) {
  9394. /**
  9395. * Hidden
  9396. */
  9397. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Hidden"] = 0] = "Hidden";
  9398. /**
  9399. * Blinking
  9400. */
  9401. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Blink"] = 1] = "Blink";
  9402. /**
  9403. * Blinking with smooth fading
  9404. */
  9405. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Smooth"] = 2] = "Smooth";
  9406. /**
  9407. * Blinking with prolonged filled state and smooth fading
  9408. */
  9409. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Phase"] = 3] = "Phase";
  9410. /**
  9411. * Expand collapse animation on the y axis
  9412. */
  9413. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Expand"] = 4] = "Expand";
  9414. /**
  9415. * No-Blinking
  9416. */
  9417. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Solid"] = 5] = "Solid";
  9418. })(TextEditorCursorBlinkingStyle = exports.TextEditorCursorBlinkingStyle || (exports.TextEditorCursorBlinkingStyle = {}));
  9419. /**
  9420. * The style in which the editor's cursor should be rendered.
  9421. */
  9422. var TextEditorCursorStyle;
  9423. (function (TextEditorCursorStyle) {
  9424. /**
  9425. * As a vertical line (sitting between two characters).
  9426. */
  9427. TextEditorCursorStyle[TextEditorCursorStyle["Line"] = 1] = "Line";
  9428. /**
  9429. * As a block (sitting on top of a character).
  9430. */
  9431. TextEditorCursorStyle[TextEditorCursorStyle["Block"] = 2] = "Block";
  9432. /**
  9433. * As a horizontal line (sitting under a character).
  9434. */
  9435. TextEditorCursorStyle[TextEditorCursorStyle["Underline"] = 3] = "Underline";
  9436. /**
  9437. * As a thin vertical line (sitting between two characters).
  9438. */
  9439. TextEditorCursorStyle[TextEditorCursorStyle["LineThin"] = 4] = "LineThin";
  9440. /**
  9441. * As an outlined block (sitting on top of a character).
  9442. */
  9443. TextEditorCursorStyle[TextEditorCursorStyle["BlockOutline"] = 5] = "BlockOutline";
  9444. /**
  9445. * As a thin horizontal line (sitting under a character).
  9446. */
  9447. TextEditorCursorStyle[TextEditorCursorStyle["UnderlineThin"] = 6] = "UnderlineThin";
  9448. })(TextEditorCursorStyle = exports.TextEditorCursorStyle || (exports.TextEditorCursorStyle = {}));
  9449. /**
  9450. * Describes the behavior of decorations when typing/editing near their edges.
  9451. * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
  9452. */
  9453. var TrackedRangeStickiness;
  9454. (function (TrackedRangeStickiness) {
  9455. TrackedRangeStickiness[TrackedRangeStickiness["AlwaysGrowsWhenTypingAtEdges"] = 0] = "AlwaysGrowsWhenTypingAtEdges";
  9456. TrackedRangeStickiness[TrackedRangeStickiness["NeverGrowsWhenTypingAtEdges"] = 1] = "NeverGrowsWhenTypingAtEdges";
  9457. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingBefore"] = 2] = "GrowsOnlyWhenTypingBefore";
  9458. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingAfter"] = 3] = "GrowsOnlyWhenTypingAfter";
  9459. })(TrackedRangeStickiness = exports.TrackedRangeStickiness || (exports.TrackedRangeStickiness = {}));
  9460. /**
  9461. * Describes how to indent wrapped lines.
  9462. */
  9463. var WrappingIndent;
  9464. (function (WrappingIndent) {
  9465. /**
  9466. * No indentation => wrapped lines begin at column 1.
  9467. */
  9468. WrappingIndent[WrappingIndent["None"] = 0] = "None";
  9469. /**
  9470. * Same => wrapped lines get the same indentation as the parent.
  9471. */
  9472. WrappingIndent[WrappingIndent["Same"] = 1] = "Same";
  9473. /**
  9474. * Indent => wrapped lines get +1 indentation toward the parent.
  9475. */
  9476. WrappingIndent[WrappingIndent["Indent"] = 2] = "Indent";
  9477. /**
  9478. * DeepIndent => wrapped lines get +2 indentation toward the parent.
  9479. */
  9480. WrappingIndent[WrappingIndent["DeepIndent"] = 3] = "DeepIndent";
  9481. })(WrappingIndent = exports.WrappingIndent || (exports.WrappingIndent = {}));
  9482. });
  9483. /*---------------------------------------------------------------------------------------------
  9484. * Copyright (c) Microsoft Corporation. All rights reserved.
  9485. * Licensed under the MIT License. See License.txt in the project root for license information.
  9486. *--------------------------------------------------------------------------------------------*/
  9487. define(__m[29/*vs/editor/common/standalone/standaloneBase*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/cancellation*/,9/*vs/base/common/event*/,17/*vs/base/common/keyCodes*/,12/*vs/base/common/uri*/,2/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/core/token*/,28/*vs/editor/common/standalone/standaloneEnums*/,33/*vs/editor/common/standalone/promise-polyfill/polyfill*/]), function (require, exports, cancellation_1, event_1, keyCodes_1, uri_1, position_1, range_1, selection_1, token_1, standaloneEnums) {
  9488. "use strict";
  9489. Object.defineProperty(exports, "__esModule", { value: true });
  9490. var KeyMod = /** @class */ (function () {
  9491. function KeyMod() {
  9492. }
  9493. KeyMod.chord = function (firstPart, secondPart) {
  9494. return keyCodes_1.KeyChord(firstPart, secondPart);
  9495. };
  9496. KeyMod.CtrlCmd = 2048 /* CtrlCmd */;
  9497. KeyMod.Shift = 1024 /* Shift */;
  9498. KeyMod.Alt = 512 /* Alt */;
  9499. KeyMod.WinCtrl = 256 /* WinCtrl */;
  9500. return KeyMod;
  9501. }());
  9502. exports.KeyMod = KeyMod;
  9503. function createMonacoBaseAPI() {
  9504. return {
  9505. editor: undefined,
  9506. languages: undefined,
  9507. CancellationTokenSource: cancellation_1.CancellationTokenSource,
  9508. Emitter: event_1.Emitter,
  9509. KeyCode: standaloneEnums.KeyCode,
  9510. KeyMod: KeyMod,
  9511. Position: position_1.Position,
  9512. Range: range_1.Range,
  9513. Selection: selection_1.Selection,
  9514. SelectionDirection: standaloneEnums.SelectionDirection,
  9515. MarkerSeverity: standaloneEnums.MarkerSeverity,
  9516. MarkerTag: standaloneEnums.MarkerTag,
  9517. Uri: uri_1.URI,
  9518. Token: token_1.Token
  9519. };
  9520. }
  9521. exports.createMonacoBaseAPI = createMonacoBaseAPI;
  9522. });
  9523. /*---------------------------------------------------------------------------------------------
  9524. * Copyright (c) Microsoft Corporation. All rights reserved.
  9525. * Licensed under the MIT License. See License.txt in the project root for license information.
  9526. *--------------------------------------------------------------------------------------------*/
  9527. define(__m[30/*vs/editor/common/viewModel/prefixSumComputer*/], __M([0/*require*/,1/*exports*/,11/*vs/base/common/uint*/]), function (require, exports, uint_1) {
  9528. "use strict";
  9529. Object.defineProperty(exports, "__esModule", { value: true });
  9530. var PrefixSumIndexOfResult = /** @class */ (function () {
  9531. function PrefixSumIndexOfResult(index, remainder) {
  9532. this.index = index;
  9533. this.remainder = remainder;
  9534. }
  9535. return PrefixSumIndexOfResult;
  9536. }());
  9537. exports.PrefixSumIndexOfResult = PrefixSumIndexOfResult;
  9538. var PrefixSumComputer = /** @class */ (function () {
  9539. function PrefixSumComputer(values) {
  9540. this.values = values;
  9541. this.prefixSum = new Uint32Array(values.length);
  9542. this.prefixSumValidIndex = new Int32Array(1);
  9543. this.prefixSumValidIndex[0] = -1;
  9544. }
  9545. PrefixSumComputer.prototype.insertValues = function (insertIndex, insertValues) {
  9546. insertIndex = uint_1.toUint32(insertIndex);
  9547. var oldValues = this.values;
  9548. var oldPrefixSum = this.prefixSum;
  9549. var insertValuesLen = insertValues.length;
  9550. if (insertValuesLen === 0) {
  9551. return false;
  9552. }
  9553. this.values = new Uint32Array(oldValues.length + insertValuesLen);
  9554. this.values.set(oldValues.subarray(0, insertIndex), 0);
  9555. this.values.set(oldValues.subarray(insertIndex), insertIndex + insertValuesLen);
  9556. this.values.set(insertValues, insertIndex);
  9557. if (insertIndex - 1 < this.prefixSumValidIndex[0]) {
  9558. this.prefixSumValidIndex[0] = insertIndex - 1;
  9559. }
  9560. this.prefixSum = new Uint32Array(this.values.length);
  9561. if (this.prefixSumValidIndex[0] >= 0) {
  9562. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  9563. }
  9564. return true;
  9565. };
  9566. PrefixSumComputer.prototype.changeValue = function (index, value) {
  9567. index = uint_1.toUint32(index);
  9568. value = uint_1.toUint32(value);
  9569. if (this.values[index] === value) {
  9570. return false;
  9571. }
  9572. this.values[index] = value;
  9573. if (index - 1 < this.prefixSumValidIndex[0]) {
  9574. this.prefixSumValidIndex[0] = index - 1;
  9575. }
  9576. return true;
  9577. };
  9578. PrefixSumComputer.prototype.removeValues = function (startIndex, cnt) {
  9579. startIndex = uint_1.toUint32(startIndex);
  9580. cnt = uint_1.toUint32(cnt);
  9581. var oldValues = this.values;
  9582. var oldPrefixSum = this.prefixSum;
  9583. if (startIndex >= oldValues.length) {
  9584. return false;
  9585. }
  9586. var maxCnt = oldValues.length - startIndex;
  9587. if (cnt >= maxCnt) {
  9588. cnt = maxCnt;
  9589. }
  9590. if (cnt === 0) {
  9591. return false;
  9592. }
  9593. this.values = new Uint32Array(oldValues.length - cnt);
  9594. this.values.set(oldValues.subarray(0, startIndex), 0);
  9595. this.values.set(oldValues.subarray(startIndex + cnt), startIndex);
  9596. this.prefixSum = new Uint32Array(this.values.length);
  9597. if (startIndex - 1 < this.prefixSumValidIndex[0]) {
  9598. this.prefixSumValidIndex[0] = startIndex - 1;
  9599. }
  9600. if (this.prefixSumValidIndex[0] >= 0) {
  9601. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  9602. }
  9603. return true;
  9604. };
  9605. PrefixSumComputer.prototype.getTotalValue = function () {
  9606. if (this.values.length === 0) {
  9607. return 0;
  9608. }
  9609. return this._getAccumulatedValue(this.values.length - 1);
  9610. };
  9611. PrefixSumComputer.prototype.getAccumulatedValue = function (index) {
  9612. if (index < 0) {
  9613. return 0;
  9614. }
  9615. index = uint_1.toUint32(index);
  9616. return this._getAccumulatedValue(index);
  9617. };
  9618. PrefixSumComputer.prototype._getAccumulatedValue = function (index) {
  9619. if (index <= this.prefixSumValidIndex[0]) {
  9620. return this.prefixSum[index];
  9621. }
  9622. var startIndex = this.prefixSumValidIndex[0] + 1;
  9623. if (startIndex === 0) {
  9624. this.prefixSum[0] = this.values[0];
  9625. startIndex++;
  9626. }
  9627. if (index >= this.values.length) {
  9628. index = this.values.length - 1;
  9629. }
  9630. for (var i = startIndex; i <= index; i++) {
  9631. this.prefixSum[i] = this.prefixSum[i - 1] + this.values[i];
  9632. }
  9633. this.prefixSumValidIndex[0] = Math.max(this.prefixSumValidIndex[0], index);
  9634. return this.prefixSum[index];
  9635. };
  9636. PrefixSumComputer.prototype.getIndexOf = function (accumulatedValue) {
  9637. accumulatedValue = Math.floor(accumulatedValue); //@perf
  9638. // Compute all sums (to get a fully valid prefixSum)
  9639. this.getTotalValue();
  9640. var low = 0;
  9641. var high = this.values.length - 1;
  9642. var mid = 0;
  9643. var midStop = 0;
  9644. var midStart = 0;
  9645. while (low <= high) {
  9646. mid = low + ((high - low) / 2) | 0;
  9647. midStop = this.prefixSum[mid];
  9648. midStart = midStop - this.values[mid];
  9649. if (accumulatedValue < midStart) {
  9650. high = mid - 1;
  9651. }
  9652. else if (accumulatedValue >= midStop) {
  9653. low = mid + 1;
  9654. }
  9655. else {
  9656. break;
  9657. }
  9658. }
  9659. return new PrefixSumIndexOfResult(mid, accumulatedValue - midStart);
  9660. };
  9661. return PrefixSumComputer;
  9662. }());
  9663. exports.PrefixSumComputer = PrefixSumComputer;
  9664. });
  9665. /*---------------------------------------------------------------------------------------------
  9666. * Copyright (c) Microsoft Corporation. All rights reserved.
  9667. * Licensed under the MIT License. See License.txt in the project root for license information.
  9668. *--------------------------------------------------------------------------------------------*/
  9669. define(__m[31/*vs/editor/common/model/mirrorTextModel*/], __M([0/*require*/,1/*exports*/,2/*vs/editor/common/core/position*/,30/*vs/editor/common/viewModel/prefixSumComputer*/]), function (require, exports, position_1, prefixSumComputer_1) {
  9670. "use strict";
  9671. Object.defineProperty(exports, "__esModule", { value: true });
  9672. var MirrorTextModel = /** @class */ (function () {
  9673. function MirrorTextModel(uri, lines, eol, versionId) {
  9674. this._uri = uri;
  9675. this._lines = lines;
  9676. this._eol = eol;
  9677. this._versionId = versionId;
  9678. this._lineStarts = null;
  9679. }
  9680. MirrorTextModel.prototype.dispose = function () {
  9681. this._lines.length = 0;
  9682. };
  9683. MirrorTextModel.prototype.getText = function () {
  9684. return this._lines.join(this._eol);
  9685. };
  9686. MirrorTextModel.prototype.onEvents = function (e) {
  9687. if (e.eol && e.eol !== this._eol) {
  9688. this._eol = e.eol;
  9689. this._lineStarts = null;
  9690. }
  9691. // Update my lines
  9692. var changes = e.changes;
  9693. for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
  9694. var change = changes_1[_i];
  9695. this._acceptDeleteRange(change.range);
  9696. this._acceptInsertText(new position_1.Position(change.range.startLineNumber, change.range.startColumn), change.text);
  9697. }
  9698. this._versionId = e.versionId;
  9699. };
  9700. MirrorTextModel.prototype._ensureLineStarts = function () {
  9701. if (!this._lineStarts) {
  9702. var eolLength = this._eol.length;
  9703. var linesLength = this._lines.length;
  9704. var lineStartValues = new Uint32Array(linesLength);
  9705. for (var i = 0; i < linesLength; i++) {
  9706. lineStartValues[i] = this._lines[i].length + eolLength;
  9707. }
  9708. this._lineStarts = new prefixSumComputer_1.PrefixSumComputer(lineStartValues);
  9709. }
  9710. };
  9711. /**
  9712. * All changes to a line's text go through this method
  9713. */
  9714. MirrorTextModel.prototype._setLineText = function (lineIndex, newValue) {
  9715. this._lines[lineIndex] = newValue;
  9716. if (this._lineStarts) {
  9717. // update prefix sum
  9718. this._lineStarts.changeValue(lineIndex, this._lines[lineIndex].length + this._eol.length);
  9719. }
  9720. };
  9721. MirrorTextModel.prototype._acceptDeleteRange = function (range) {
  9722. if (range.startLineNumber === range.endLineNumber) {
  9723. if (range.startColumn === range.endColumn) {
  9724. // Nothing to delete
  9725. return;
  9726. }
  9727. // Delete text on the affected line
  9728. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  9729. + this._lines[range.startLineNumber - 1].substring(range.endColumn - 1));
  9730. return;
  9731. }
  9732. // Take remaining text on last line and append it to remaining text on first line
  9733. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  9734. + this._lines[range.endLineNumber - 1].substring(range.endColumn - 1));
  9735. // Delete middle lines
  9736. this._lines.splice(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  9737. if (this._lineStarts) {
  9738. // update prefix sum
  9739. this._lineStarts.removeValues(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  9740. }
  9741. };
  9742. MirrorTextModel.prototype._acceptInsertText = function (position, insertText) {
  9743. if (insertText.length === 0) {
  9744. // Nothing to insert
  9745. return;
  9746. }
  9747. var insertLines = insertText.split(/\r\n|\r|\n/);
  9748. if (insertLines.length === 1) {
  9749. // Inserting text on one line
  9750. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  9751. + insertLines[0]
  9752. + this._lines[position.lineNumber - 1].substring(position.column - 1));
  9753. return;
  9754. }
  9755. // Append overflowing text from first line to the end of text to insert
  9756. insertLines[insertLines.length - 1] += this._lines[position.lineNumber - 1].substring(position.column - 1);
  9757. // Delete overflowing text from first line and insert text on first line
  9758. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  9759. + insertLines[0]);
  9760. // Insert new lines & store lengths
  9761. var newLengths = new Uint32Array(insertLines.length - 1);
  9762. for (var i = 1; i < insertLines.length; i++) {
  9763. this._lines.splice(position.lineNumber + i - 1, 0, insertLines[i]);
  9764. newLengths[i - 1] = insertLines[i].length + this._eol.length;
  9765. }
  9766. if (this._lineStarts) {
  9767. // update prefix sum
  9768. this._lineStarts.insertValues(position.lineNumber, newLengths);
  9769. }
  9770. };
  9771. return MirrorTextModel;
  9772. }());
  9773. exports.MirrorTextModel = MirrorTextModel;
  9774. });
  9775. /*---------------------------------------------------------------------------------------------
  9776. * Copyright (c) Microsoft Corporation. All rights reserved.
  9777. * Licensed under the MIT License. See License.txt in the project root for license information.
  9778. *--------------------------------------------------------------------------------------------*/
  9779. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  9780. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  9781. return new (P || (P = Promise))(function (resolve, reject) {
  9782. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  9783. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  9784. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  9785. step((generator = generator.apply(thisArg, _arguments || [])).next());
  9786. });
  9787. };
  9788. var __generator = (this && this.__generator) || function (thisArg, body) {
  9789. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  9790. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  9791. function verb(n) { return function (v) { return step([n, v]); }; }
  9792. function step(op) {
  9793. if (f) throw new TypeError("Generator is already executing.");
  9794. while (_) try {
  9795. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  9796. if (y = 0, t) op = [op[0] & 2, t.value];
  9797. switch (op[0]) {
  9798. case 0: case 1: t = op; break;
  9799. case 4: _.label++; return { value: op[1], done: false };
  9800. case 5: _.label++; y = op[1]; op = [0]; continue;
  9801. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  9802. default:
  9803. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  9804. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  9805. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  9806. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  9807. if (t[2]) _.ops.pop();
  9808. _.trys.pop(); continue;
  9809. }
  9810. op = body.call(thisArg, _);
  9811. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  9812. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  9813. }
  9814. };
  9815. define(__m[34/*vs/editor/common/services/editorSimpleWorker*/], __M([0/*require*/,1/*exports*/,13/*vs/base/common/arrays*/,6/*vs/base/common/diff/diff*/,7/*vs/base/common/iterator*/,4/*vs/base/common/platform*/,12/*vs/base/common/uri*/,2/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/,24/*vs/editor/common/diff/diffComputer*/,31/*vs/editor/common/model/mirrorTextModel*/,25/*vs/editor/common/model/wordHelper*/,26/*vs/editor/common/modes/linkComputer*/,27/*vs/editor/common/modes/supports/inplaceReplaceSupport*/,29/*vs/editor/common/standalone/standaloneBase*/,10/*vs/base/common/types*/]), function (require, exports, arrays_1, diff_1, iterator_1, platform_1, uri_1, position_1, range_1, diffComputer_1, mirrorTextModel_1, wordHelper_1, linkComputer_1, inplaceReplaceSupport_1, standaloneBase_1, types) {
  9816. "use strict";
  9817. Object.defineProperty(exports, "__esModule", { value: true });
  9818. /**
  9819. * @internal
  9820. */
  9821. var MirrorModel = /** @class */ (function (_super) {
  9822. __extends(MirrorModel, _super);
  9823. function MirrorModel() {
  9824. return _super !== null && _super.apply(this, arguments) || this;
  9825. }
  9826. Object.defineProperty(MirrorModel.prototype, "uri", {
  9827. get: function () {
  9828. return this._uri;
  9829. },
  9830. enumerable: true,
  9831. configurable: true
  9832. });
  9833. Object.defineProperty(MirrorModel.prototype, "version", {
  9834. get: function () {
  9835. return this._versionId;
  9836. },
  9837. enumerable: true,
  9838. configurable: true
  9839. });
  9840. Object.defineProperty(MirrorModel.prototype, "eol", {
  9841. get: function () {
  9842. return this._eol;
  9843. },
  9844. enumerable: true,
  9845. configurable: true
  9846. });
  9847. MirrorModel.prototype.getValue = function () {
  9848. return this.getText();
  9849. };
  9850. MirrorModel.prototype.getLinesContent = function () {
  9851. return this._lines.slice(0);
  9852. };
  9853. MirrorModel.prototype.getLineCount = function () {
  9854. return this._lines.length;
  9855. };
  9856. MirrorModel.prototype.getLineContent = function (lineNumber) {
  9857. return this._lines[lineNumber - 1];
  9858. };
  9859. MirrorModel.prototype.getWordAtPosition = function (position, wordDefinition) {
  9860. var wordAtText = wordHelper_1.getWordAtText(position.column, wordHelper_1.ensureValidWordDefinition(wordDefinition), this._lines[position.lineNumber - 1], 0);
  9861. if (wordAtText) {
  9862. return new range_1.Range(position.lineNumber, wordAtText.startColumn, position.lineNumber, wordAtText.endColumn);
  9863. }
  9864. return null;
  9865. };
  9866. MirrorModel.prototype.createWordIterator = function (wordDefinition) {
  9867. var _this = this;
  9868. var obj;
  9869. var lineNumber = 0;
  9870. var lineText;
  9871. var wordRangesIdx = 0;
  9872. var wordRanges = [];
  9873. var next = function () {
  9874. if (wordRangesIdx < wordRanges.length) {
  9875. var value = lineText.substring(wordRanges[wordRangesIdx].start, wordRanges[wordRangesIdx].end);
  9876. wordRangesIdx += 1;
  9877. if (!obj) {
  9878. obj = { done: false, value: value };
  9879. }
  9880. else {
  9881. obj.value = value;
  9882. }
  9883. return obj;
  9884. }
  9885. else if (lineNumber >= _this._lines.length) {
  9886. return iterator_1.FIN;
  9887. }
  9888. else {
  9889. lineText = _this._lines[lineNumber];
  9890. wordRanges = _this._wordenize(lineText, wordDefinition);
  9891. wordRangesIdx = 0;
  9892. lineNumber += 1;
  9893. return next();
  9894. }
  9895. };
  9896. return { next: next };
  9897. };
  9898. MirrorModel.prototype.getLineWords = function (lineNumber, wordDefinition) {
  9899. var content = this._lines[lineNumber - 1];
  9900. var ranges = this._wordenize(content, wordDefinition);
  9901. var words = [];
  9902. for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) {
  9903. var range = ranges_1[_i];
  9904. words.push({
  9905. word: content.substring(range.start, range.end),
  9906. startColumn: range.start + 1,
  9907. endColumn: range.end + 1
  9908. });
  9909. }
  9910. return words;
  9911. };
  9912. MirrorModel.prototype._wordenize = function (content, wordDefinition) {
  9913. var result = [];
  9914. var match;
  9915. wordDefinition.lastIndex = 0; // reset lastIndex just to be sure
  9916. while (match = wordDefinition.exec(content)) {
  9917. if (match[0].length === 0) {
  9918. // it did match the empty string
  9919. break;
  9920. }
  9921. result.push({ start: match.index, end: match.index + match[0].length });
  9922. }
  9923. return result;
  9924. };
  9925. MirrorModel.prototype.getValueInRange = function (range) {
  9926. range = this._validateRange(range);
  9927. if (range.startLineNumber === range.endLineNumber) {
  9928. return this._lines[range.startLineNumber - 1].substring(range.startColumn - 1, range.endColumn - 1);
  9929. }
  9930. var lineEnding = this._eol;
  9931. var startLineIndex = range.startLineNumber - 1;
  9932. var endLineIndex = range.endLineNumber - 1;
  9933. var resultLines = [];
  9934. resultLines.push(this._lines[startLineIndex].substring(range.startColumn - 1));
  9935. for (var i = startLineIndex + 1; i < endLineIndex; i++) {
  9936. resultLines.push(this._lines[i]);
  9937. }
  9938. resultLines.push(this._lines[endLineIndex].substring(0, range.endColumn - 1));
  9939. return resultLines.join(lineEnding);
  9940. };
  9941. MirrorModel.prototype.offsetAt = function (position) {
  9942. position = this._validatePosition(position);
  9943. this._ensureLineStarts();
  9944. return this._lineStarts.getAccumulatedValue(position.lineNumber - 2) + (position.column - 1);
  9945. };
  9946. MirrorModel.prototype.positionAt = function (offset) {
  9947. offset = Math.floor(offset);
  9948. offset = Math.max(0, offset);
  9949. this._ensureLineStarts();
  9950. var out = this._lineStarts.getIndexOf(offset);
  9951. var lineLength = this._lines[out.index].length;
  9952. // Ensure we return a valid position
  9953. return {
  9954. lineNumber: 1 + out.index,
  9955. column: 1 + Math.min(out.remainder, lineLength)
  9956. };
  9957. };
  9958. MirrorModel.prototype._validateRange = function (range) {
  9959. var start = this._validatePosition({ lineNumber: range.startLineNumber, column: range.startColumn });
  9960. var end = this._validatePosition({ lineNumber: range.endLineNumber, column: range.endColumn });
  9961. if (start.lineNumber !== range.startLineNumber
  9962. || start.column !== range.startColumn
  9963. || end.lineNumber !== range.endLineNumber
  9964. || end.column !== range.endColumn) {
  9965. return {
  9966. startLineNumber: start.lineNumber,
  9967. startColumn: start.column,
  9968. endLineNumber: end.lineNumber,
  9969. endColumn: end.column
  9970. };
  9971. }
  9972. return range;
  9973. };
  9974. MirrorModel.prototype._validatePosition = function (position) {
  9975. if (!position_1.Position.isIPosition(position)) {
  9976. throw new Error('bad position');
  9977. }
  9978. var lineNumber = position.lineNumber, column = position.column;
  9979. var hasChanged = false;
  9980. if (lineNumber < 1) {
  9981. lineNumber = 1;
  9982. column = 1;
  9983. hasChanged = true;
  9984. }
  9985. else if (lineNumber > this._lines.length) {
  9986. lineNumber = this._lines.length;
  9987. column = this._lines[lineNumber - 1].length + 1;
  9988. hasChanged = true;
  9989. }
  9990. else {
  9991. var maxCharacter = this._lines[lineNumber - 1].length + 1;
  9992. if (column < 1) {
  9993. column = 1;
  9994. hasChanged = true;
  9995. }
  9996. else if (column > maxCharacter) {
  9997. column = maxCharacter;
  9998. hasChanged = true;
  9999. }
  10000. }
  10001. if (!hasChanged) {
  10002. return position;
  10003. }
  10004. else {
  10005. return { lineNumber: lineNumber, column: column };
  10006. }
  10007. };
  10008. return MirrorModel;
  10009. }(mirrorTextModel_1.MirrorTextModel));
  10010. /**
  10011. * @internal
  10012. */
  10013. var EditorSimpleWorker = /** @class */ (function () {
  10014. function EditorSimpleWorker(host, foreignModuleFactory) {
  10015. this._host = host;
  10016. this._models = Object.create(null);
  10017. this._foreignModuleFactory = foreignModuleFactory;
  10018. this._foreignModule = null;
  10019. }
  10020. EditorSimpleWorker.prototype.dispose = function () {
  10021. this._models = Object.create(null);
  10022. };
  10023. EditorSimpleWorker.prototype._getModel = function (uri) {
  10024. return this._models[uri];
  10025. };
  10026. EditorSimpleWorker.prototype._getModels = function () {
  10027. var _this = this;
  10028. var all = [];
  10029. Object.keys(this._models).forEach(function (key) { return all.push(_this._models[key]); });
  10030. return all;
  10031. };
  10032. EditorSimpleWorker.prototype.acceptNewModel = function (data) {
  10033. this._models[data.url] = new MirrorModel(uri_1.URI.parse(data.url), data.lines, data.EOL, data.versionId);
  10034. };
  10035. EditorSimpleWorker.prototype.acceptModelChanged = function (strURL, e) {
  10036. if (!this._models[strURL]) {
  10037. return;
  10038. }
  10039. var model = this._models[strURL];
  10040. model.onEvents(e);
  10041. };
  10042. EditorSimpleWorker.prototype.acceptRemovedModel = function (strURL) {
  10043. if (!this._models[strURL]) {
  10044. return;
  10045. }
  10046. delete this._models[strURL];
  10047. };
  10048. // ---- BEGIN diff --------------------------------------------------------------------------
  10049. EditorSimpleWorker.prototype.computeDiff = function (originalUrl, modifiedUrl, ignoreTrimWhitespace, maxComputationTime) {
  10050. return __awaiter(this, void 0, void 0, function () {
  10051. var original, modified, originalLines, modifiedLines, diffComputer, diffResult, identical;
  10052. return __generator(this, function (_a) {
  10053. original = this._getModel(originalUrl);
  10054. modified = this._getModel(modifiedUrl);
  10055. if (!original || !modified) {
  10056. return [2 /*return*/, null];
  10057. }
  10058. originalLines = original.getLinesContent();
  10059. modifiedLines = modified.getLinesContent();
  10060. diffComputer = new diffComputer_1.DiffComputer(originalLines, modifiedLines, {
  10061. shouldComputeCharChanges: true,
  10062. shouldPostProcessCharChanges: true,
  10063. shouldIgnoreTrimWhitespace: ignoreTrimWhitespace,
  10064. shouldMakePrettyDiff: true,
  10065. maxComputationTime: maxComputationTime
  10066. });
  10067. diffResult = diffComputer.computeDiff();
  10068. identical = (diffResult.changes.length > 0 ? false : this._modelsAreIdentical(original, modified));
  10069. return [2 /*return*/, {
  10070. quitEarly: diffResult.quitEarly,
  10071. identical: identical,
  10072. changes: diffResult.changes
  10073. }];
  10074. });
  10075. });
  10076. };
  10077. EditorSimpleWorker.prototype._modelsAreIdentical = function (original, modified) {
  10078. var originalLineCount = original.getLineCount();
  10079. var modifiedLineCount = modified.getLineCount();
  10080. if (originalLineCount !== modifiedLineCount) {
  10081. return false;
  10082. }
  10083. for (var line = 1; line <= originalLineCount; line++) {
  10084. var originalLine = original.getLineContent(line);
  10085. var modifiedLine = modified.getLineContent(line);
  10086. if (originalLine !== modifiedLine) {
  10087. return false;
  10088. }
  10089. }
  10090. return true;
  10091. };
  10092. EditorSimpleWorker.prototype.computeMoreMinimalEdits = function (modelUrl, edits) {
  10093. return __awaiter(this, void 0, void 0, function () {
  10094. var model, result, lastEol, _i, edits_1, _a, range, text, eol, original, changes, editOffset, _b, changes_1, change, start, end, newEdit;
  10095. return __generator(this, function (_c) {
  10096. model = this._getModel(modelUrl);
  10097. if (!model) {
  10098. return [2 /*return*/, edits];
  10099. }
  10100. result = [];
  10101. lastEol = undefined;
  10102. edits = arrays_1.mergeSort(edits, function (a, b) {
  10103. if (a.range && b.range) {
  10104. return range_1.Range.compareRangesUsingStarts(a.range, b.range);
  10105. }
  10106. // eol only changes should go to the end
  10107. var aRng = a.range ? 0 : 1;
  10108. var bRng = b.range ? 0 : 1;
  10109. return aRng - bRng;
  10110. });
  10111. for (_i = 0, edits_1 = edits; _i < edits_1.length; _i++) {
  10112. _a = edits_1[_i], range = _a.range, text = _a.text, eol = _a.eol;
  10113. if (typeof eol === 'number') {
  10114. lastEol = eol;
  10115. }
  10116. if (range_1.Range.isEmpty(range) && !text) {
  10117. // empty change
  10118. continue;
  10119. }
  10120. original = model.getValueInRange(range);
  10121. text = text.replace(/\r\n|\n|\r/g, model.eol);
  10122. if (original === text) {
  10123. // noop
  10124. continue;
  10125. }
  10126. // make sure diff won't take too long
  10127. if (Math.max(text.length, original.length) > EditorSimpleWorker._diffLimit) {
  10128. result.push({ range: range, text: text });
  10129. continue;
  10130. }
  10131. changes = diff_1.stringDiff(original, text, false);
  10132. editOffset = model.offsetAt(range_1.Range.lift(range).getStartPosition());
  10133. for (_b = 0, changes_1 = changes; _b < changes_1.length; _b++) {
  10134. change = changes_1[_b];
  10135. start = model.positionAt(editOffset + change.originalStart);
  10136. end = model.positionAt(editOffset + change.originalStart + change.originalLength);
  10137. newEdit = {
  10138. text: text.substr(change.modifiedStart, change.modifiedLength),
  10139. range: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }
  10140. };
  10141. if (model.getValueInRange(newEdit.range) !== newEdit.text) {
  10142. result.push(newEdit);
  10143. }
  10144. }
  10145. }
  10146. if (typeof lastEol === 'number') {
  10147. result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
  10148. }
  10149. return [2 /*return*/, result];
  10150. });
  10151. });
  10152. };
  10153. // ---- END minimal edits ---------------------------------------------------------------
  10154. EditorSimpleWorker.prototype.computeLinks = function (modelUrl) {
  10155. return __awaiter(this, void 0, void 0, function () {
  10156. var model;
  10157. return __generator(this, function (_a) {
  10158. model = this._getModel(modelUrl);
  10159. if (!model) {
  10160. return [2 /*return*/, null];
  10161. }
  10162. return [2 /*return*/, linkComputer_1.computeLinks(model)];
  10163. });
  10164. });
  10165. };
  10166. EditorSimpleWorker.prototype.textualSuggest = function (modelUrl, position, wordDef, wordDefFlags) {
  10167. return __awaiter(this, void 0, void 0, function () {
  10168. var model, words, seen, wordDefRegExp, wordAt, iter, e, word;
  10169. return __generator(this, function (_a) {
  10170. model = this._getModel(modelUrl);
  10171. if (!model) {
  10172. return [2 /*return*/, null];
  10173. }
  10174. words = [];
  10175. seen = new Set();
  10176. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  10177. wordAt = model.getWordAtPosition(position, wordDefRegExp);
  10178. if (wordAt) {
  10179. seen.add(model.getValueInRange(wordAt));
  10180. }
  10181. for (iter = model.createWordIterator(wordDefRegExp), e = iter.next(); !e.done && seen.size <= EditorSimpleWorker._suggestionsLimit; e = iter.next()) {
  10182. word = e.value;
  10183. if (seen.has(word)) {
  10184. continue;
  10185. }
  10186. seen.add(word);
  10187. if (!isNaN(Number(word))) {
  10188. continue;
  10189. }
  10190. words.push(word);
  10191. }
  10192. return [2 /*return*/, words];
  10193. });
  10194. });
  10195. };
  10196. // ---- END suggest --------------------------------------------------------------------------
  10197. //#region -- word ranges --
  10198. EditorSimpleWorker.prototype.computeWordRanges = function (modelUrl, range, wordDef, wordDefFlags) {
  10199. return __awaiter(this, void 0, void 0, function () {
  10200. var model, wordDefRegExp, result, line, words, _i, words_1, word, array;
  10201. return __generator(this, function (_a) {
  10202. model = this._getModel(modelUrl);
  10203. if (!model) {
  10204. return [2 /*return*/, Object.create(null)];
  10205. }
  10206. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  10207. result = Object.create(null);
  10208. for (line = range.startLineNumber; line < range.endLineNumber; line++) {
  10209. words = model.getLineWords(line, wordDefRegExp);
  10210. for (_i = 0, words_1 = words; _i < words_1.length; _i++) {
  10211. word = words_1[_i];
  10212. if (!isNaN(Number(word.word))) {
  10213. continue;
  10214. }
  10215. array = result[word.word];
  10216. if (!array) {
  10217. array = [];
  10218. result[word.word] = array;
  10219. }
  10220. array.push({
  10221. startLineNumber: line,
  10222. startColumn: word.startColumn,
  10223. endLineNumber: line,
  10224. endColumn: word.endColumn
  10225. });
  10226. }
  10227. }
  10228. return [2 /*return*/, result];
  10229. });
  10230. });
  10231. };
  10232. //#endregion
  10233. EditorSimpleWorker.prototype.navigateValueSet = function (modelUrl, range, up, wordDef, wordDefFlags) {
  10234. return __awaiter(this, void 0, void 0, function () {
  10235. var model, wordDefRegExp, selectionText, wordRange, word, result;
  10236. return __generator(this, function (_a) {
  10237. model = this._getModel(modelUrl);
  10238. if (!model) {
  10239. return [2 /*return*/, null];
  10240. }
  10241. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  10242. if (range.startColumn === range.endColumn) {
  10243. range = {
  10244. startLineNumber: range.startLineNumber,
  10245. startColumn: range.startColumn,
  10246. endLineNumber: range.endLineNumber,
  10247. endColumn: range.endColumn + 1
  10248. };
  10249. }
  10250. selectionText = model.getValueInRange(range);
  10251. wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);
  10252. if (!wordRange) {
  10253. return [2 /*return*/, null];
  10254. }
  10255. word = model.getValueInRange(wordRange);
  10256. result = inplaceReplaceSupport_1.BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);
  10257. return [2 /*return*/, result];
  10258. });
  10259. });
  10260. };
  10261. // ---- BEGIN foreign module support --------------------------------------------------------------------------
  10262. EditorSimpleWorker.prototype.loadForeignModule = function (moduleId, createData, foreignHostMethods) {
  10263. var _this = this;
  10264. var proxyMethodRequest = function (method, args) {
  10265. return _this._host.fhr(method, args);
  10266. };
  10267. var foreignHost = types.createProxyObject(foreignHostMethods, proxyMethodRequest);
  10268. var ctx = {
  10269. host: foreignHost,
  10270. getMirrorModels: function () {
  10271. return _this._getModels();
  10272. }
  10273. };
  10274. if (this._foreignModuleFactory) {
  10275. this._foreignModule = this._foreignModuleFactory(ctx, createData);
  10276. // static foreing module
  10277. return Promise.resolve(types.getAllMethodNames(this._foreignModule));
  10278. }
  10279. // ESM-comment-begin
  10280. return new Promise(function (resolve, reject) {
  10281. require([moduleId], function (foreignModule) {
  10282. _this._foreignModule = foreignModule.create(ctx, createData);
  10283. resolve(types.getAllMethodNames(_this._foreignModule));
  10284. }, reject);
  10285. });
  10286. // ESM-comment-end
  10287. // ESM-uncomment-begin
  10288. // return Promise.reject(new Error(`Unexpected usage`));
  10289. // ESM-uncomment-end
  10290. };
  10291. // foreign method request
  10292. EditorSimpleWorker.prototype.fmr = function (method, args) {
  10293. if (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {
  10294. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  10295. }
  10296. try {
  10297. return Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));
  10298. }
  10299. catch (e) {
  10300. return Promise.reject(e);
  10301. }
  10302. };
  10303. // ---- END diff --------------------------------------------------------------------------
  10304. // ---- BEGIN minimal edits ---------------------------------------------------------------
  10305. EditorSimpleWorker._diffLimit = 100000;
  10306. // ---- BEGIN suggest --------------------------------------------------------------------------
  10307. EditorSimpleWorker._suggestionsLimit = 10000;
  10308. return EditorSimpleWorker;
  10309. }());
  10310. exports.EditorSimpleWorker = EditorSimpleWorker;
  10311. /**
  10312. * Called on the worker side
  10313. * @internal
  10314. */
  10315. function create(host) {
  10316. return new EditorSimpleWorker(host, null);
  10317. }
  10318. exports.create = create;
  10319. if (typeof importScripts === 'function') {
  10320. // Running in a web worker
  10321. platform_1.globals.monaco = standaloneBase_1.createMonacoBaseAPI();
  10322. }
  10323. });
  10324. "use strict";
  10325. /*---------------------------------------------------------------------------------------------
  10326. * Copyright (c) Microsoft Corporation. All rights reserved.
  10327. * Licensed under the MIT License. See License.txt in the project root for license information.
  10328. *--------------------------------------------------------------------------------------------*/
  10329. (function () {
  10330. var MonacoEnvironment = self.MonacoEnvironment;
  10331. var monacoBaseUrl = MonacoEnvironment && MonacoEnvironment.baseUrl ? MonacoEnvironment.baseUrl : '../../../';
  10332. if (typeof self.define !== 'function' || !self.define.amd) {
  10333. importScripts(monacoBaseUrl + 'vs/loader.js');
  10334. }
  10335. require.config({
  10336. baseUrl: monacoBaseUrl,
  10337. catchError: true
  10338. });
  10339. var loadCode = function (moduleId) {
  10340. require([moduleId], function (ws) {
  10341. setTimeout(function () {
  10342. var messageHandler = ws.create(function (msg, transfer) {
  10343. self.postMessage(msg, transfer);
  10344. }, null);
  10345. self.onmessage = function (e) { return messageHandler.onmessage(e.data); };
  10346. while (beforeReadyMessages.length > 0) {
  10347. self.onmessage(beforeReadyMessages.shift());
  10348. }
  10349. }, 0);
  10350. });
  10351. };
  10352. var isFirstMessage = true;
  10353. var beforeReadyMessages = [];
  10354. self.onmessage = function (message) {
  10355. if (!isFirstMessage) {
  10356. beforeReadyMessages.push(message);
  10357. return;
  10358. }
  10359. isFirstMessage = false;
  10360. loadCode(message.data);
  10361. };
  10362. })();
  10363. }).call(this);
  10364. //# sourceMappingURL=workerMain.js.map